Migrate to AndroidX
This commit is contained in:
@ -47,12 +47,44 @@ class Logger {
|
||||
|
||||
class HAUtils {
|
||||
static void launchURL(String url) async {
|
||||
if (await canLaunch(url)) {
|
||||
await launch(url);
|
||||
if (await urlLauncher.canLaunch(url)) {
|
||||
await urlLauncher.launch(url);
|
||||
} else {
|
||||
Logger.e( "Could not launch $url");
|
||||
}
|
||||
}
|
||||
|
||||
static void launchURLInCustomTab(BuildContext context, String url) async {
|
||||
try {
|
||||
await launch(
|
||||
"$url",
|
||||
option: new CustomTabsOption(
|
||||
toolbarColor: Theme.of(context).primaryColor,
|
||||
enableDefaultShare: true,
|
||||
enableUrlBarHiding: true,
|
||||
showPageTitle: true,
|
||||
animation: new CustomTabsAnimation.slideIn()
|
||||
// or user defined animation.
|
||||
/*animation: new CustomTabsAnimation(
|
||||
startEnter: 'slide_up',
|
||||
startExit: 'android:anim/fade_out',
|
||||
endEnter: 'android:anim/fade_in',
|
||||
endExit: 'slide_down',
|
||||
)*/,
|
||||
extraCustomTabs: <String>[
|
||||
// ref. https://play.google.com/store/apps/details?id=org.mozilla.firefox
|
||||
'org.mozilla.firefox',
|
||||
// ref. https://play.google.com/store/apps/details?id=com.microsoft.emmx
|
||||
'com.microsoft.emmx',
|
||||
],
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
Logger.w("Can't open custom tab: ${e.toString()}");
|
||||
Logger.w("Launching in default browser");
|
||||
HAUtils.launchURL(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class StateChangedEvent {
|
||||
|
Reference in New Issue
Block a user