Skip to content

Commit

Permalink
Make sure that when we want to open a new instance of a custom chrome…
Browse files Browse the repository at this point in the history
… tab, we are opening a new instance with the provided url and not an old instance.
  • Loading branch information
savy-91 committed Apr 19, 2021
1 parent f06bcdf commit 6e18699
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 3 additions & 1 deletion android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density" />
<activity
android:theme="@style/ThemeTransparent"
android:name="com.pichillilorenzo.flutter_inappwebview.chrome_custom_tabs.ChromeCustomTabsActivity" />
android:name="com.pichillilorenzo.flutter_inappwebview.chrome_custom_tabs.ChromeCustomTabsActivity"
android:launchMode="singleInstance"
/>
<receiver android:name="com.pichillilorenzo.flutter_inappwebview.chrome_custom_tabs.ActionBroadcastReceiver" />
<meta-data
android:name="io.flutter.embedded_views_preview"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ public void open(Activity activity, String id, String url, HashMap<String, Objec
if (CustomTabActivityHelper.isAvailable(activity)) {
intent = new Intent(activity, ChromeCustomTabsActivity.class);
intent.putExtras(extras);
if ((boolean) options.get("noHistory")) {
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
}
activity.startActivity(intent);
result.success(true);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,19 @@ class AndroidChromeCustomTabsOptions
///Set to `true` to enable Keep Alive. The default value is `false`.
bool keepAliveEnabled;

//Set to `true` to launch the intent with the flag FLAG_ACTIVITY_NO_HISTORY
bool noHistory;

AndroidChromeCustomTabsOptions(
{this.addDefaultShareMenuItem = true,
this.showTitle = true,
this.toolbarBackgroundColor,
this.enableUrlBarHiding = false,
this.instantAppsEnabled = false,
this.packageName,
this.keepAliveEnabled = false});
this.keepAliveEnabled = false,
this.noHistory = false
});

@override
Map<String, dynamic> toMap() {
Expand All @@ -53,7 +58,8 @@ class AndroidChromeCustomTabsOptions
"enableUrlBarHiding": enableUrlBarHiding,
"instantAppsEnabled": instantAppsEnabled,
"packageName": packageName,
"keepAliveEnabled": keepAliveEnabled
"keepAliveEnabled": keepAliveEnabled,
"noHistory": noHistory
};
}

Expand All @@ -68,6 +74,7 @@ class AndroidChromeCustomTabsOptions
options.instantAppsEnabled = map["instantAppsEnabled"];
options.packageName = map["packageName"];
options.keepAliveEnabled = map["keepAliveEnabled"];
options.noHistory = map["noHistory"];
return options;
}

Expand Down

0 comments on commit 6e18699

Please sign in to comment.