Lately we've been talking about Turbo and iOS, and about making PWAs installable.
This article is the continuation of those two articles (well, more the one on iOS), so I invite you to skim it, because even if the two systems are quite different, the principle is the same.
As always, the app we're going to talk about is the one I use every time I want to test new technologies. As I write these lines, it's available on the Google Play Store.
As with iOS, you'll need to make Turbo accessible directly from "window", like this:
In the demo project, you'll already be able to understand a few things, and more importantly, you'll be able to compile it.
Yes, there's one here too, but I find that on Android it's even more important than on the other platform, so here's an example:
Already in this file, the "screenshots_enabled" allows you to simply manage transitions, if you want a screenshot of the "view" (the page, basically) to be displayed when you go back, or if you simply want to set a loading spinner.
Next, there's the routing, where we choose which configuration will be loaded via a regex.
In the configuration, we choose :
The most important thing in this file is the choice of the URI to be used, as you'll see later.
This is where everything starts, for example, you can see the import of the different fragments that your application will use. This is also where we create the session and webview.
As in the previous article, instead of repeating things we've already seen over and over again, we're going to include a few concrete examples.
It's quite different from iOS, in fact. In ourMainSessionNavHostFragment.kt file, we'll need to make a few modifications:
And yes, as on the application on the other platform, we'll need to share URLs, to share the invitation with other guests.
In the Stimulus controller :
We simply use the "share" method of the class we created in the previous chapter.
For the Android part:
Sending an e-mail is also fairly straightforward, in the Stimulus controller:
If we're on Android, we simply call the "composeEmail" method of our Android-exposed class.
The "composeEmail" method:
And there you have it, the native code is pretty straightforward.
I won't go into any more detail of the same kind, as I think you've understood the principle, and above all, remember to look at the iOS article, because even if the language is different, it's the same logic.
During development, I had a problem: once I had taken a bank loan by stripe, when I arrived at the reservation confirmation view, for some as yet unknown reason, I couldn't set the view to "replace_root" to prevent the user from pressing return and therefore behaving strangely.
Remember the fragments you can associate with a url in route configuration? Well, I've created a specific fragment for the "complete-" route:
Simply a method that changes the behavior of the back button and returns the user to the device's home screen when he clicks on it, this method is called in "onViewCreated" and "onResume", when the user returns from the home screen to the application.
This article is more concise than the one on iOS, quite simply, because the logic is the same, the platform and programming language change, but the logic remains the same.
Have a great week 😁.