From 063e3143bc4e1875eaff9cf0ec96aba06971dab4 Mon Sep 17 00:00:00 2001 From: Andre Bandarra Date: Fri, 17 May 2024 10:02:58 +0100 Subject: [PATCH 1/2] Move connecting/disconnecting from service to onCreate/Destroy When using minimized Custom Tabs, if a Custom Tab is-relaunched while a previous one is minimized, while connected to the Custom Tabs service, the existing minimized tab will be killed and a new one launched. --- .../ServiceConnectionActivity.java | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/demos/custom-tabs-example-app/src/main/java/org/chromium/customtabsdemos/ServiceConnectionActivity.java b/demos/custom-tabs-example-app/src/main/java/org/chromium/customtabsdemos/ServiceConnectionActivity.java index 140685e9..d4712f2d 100644 --- a/demos/custom-tabs-example-app/src/main/java/org/chromium/customtabsdemos/ServiceConnectionActivity.java +++ b/demos/custom-tabs-example-app/src/main/java/org/chromium/customtabsdemos/ServiceConnectionActivity.java @@ -15,6 +15,7 @@ import android.net.Uri; import android.os.Bundle; +import android.util.Log; import android.view.View; import android.widget.EditText; @@ -36,21 +37,23 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_serviceconnection); - customTabActivityHelper = new CustomTabActivityHelper(); - customTabActivityHelper.setConnectionCallback(this); - mUrlEditText = findViewById(R.id.url); mMayLaunchUrlButton = findViewById(R.id.button_may_launch_url); mMayLaunchUrlButton.setEnabled(false); mMayLaunchUrlButton.setOnClickListener(this); findViewById(R.id.start_custom_tab).setOnClickListener(this); + + customTabActivityHelper = new CustomTabActivityHelper(); + customTabActivityHelper.setConnectionCallback(this); + customTabActivityHelper.bindCustomTabsService(this); } @Override protected void onDestroy() { super.onDestroy(); customTabActivityHelper.setConnectionCallback(null); + customTabActivityHelper.unbindCustomTabsService(this); } @Override @@ -63,19 +66,6 @@ public void onCustomTabsDisconnected() { mMayLaunchUrlButton.setEnabled(false); } - @Override - protected void onStart() { - super.onStart(); - customTabActivityHelper.bindCustomTabsService(this); - } - - @Override - protected void onStop() { - super.onStop(); - customTabActivityHelper.unbindCustomTabsService(this); - mMayLaunchUrlButton.setEnabled(false); - } - @Override public void onClick(View view) { int viewId = view.getId(); From 98a633c212a1e4e3c935c15d187f904e8424c909 Mon Sep 17 00:00:00 2001 From: Andre Bandarra Date: Fri, 17 May 2024 10:23:30 +0100 Subject: [PATCH 2/2] Removes unused Log import --- .../org/chromium/customtabsdemos/ServiceConnectionActivity.java | 1 - 1 file changed, 1 deletion(-) diff --git a/demos/custom-tabs-example-app/src/main/java/org/chromium/customtabsdemos/ServiceConnectionActivity.java b/demos/custom-tabs-example-app/src/main/java/org/chromium/customtabsdemos/ServiceConnectionActivity.java index d4712f2d..366f21e9 100644 --- a/demos/custom-tabs-example-app/src/main/java/org/chromium/customtabsdemos/ServiceConnectionActivity.java +++ b/demos/custom-tabs-example-app/src/main/java/org/chromium/customtabsdemos/ServiceConnectionActivity.java @@ -15,7 +15,6 @@ import android.net.Uri; import android.os.Bundle; -import android.util.Log; import android.view.View; import android.widget.EditText;