From eb5c5a51ec4831af8cc096230cad4af3c31dcbb9 Mon Sep 17 00:00:00 2001 From: Jeremy Massel <1123407+jkmassel@users.noreply.github.com> Date: Mon, 18 Nov 2024 14:51:11 -0700 Subject: [PATCH] Use Custom Chrome Tabs --- WordPress/build.gradle | 2 ++ .../wordpress/android/ui/accounts/LoginActivity.java | 11 ++++++++--- gradle/libs.versions.toml | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/WordPress/build.gradle b/WordPress/build.gradle index beb369732055..c72d933211a1 100644 --- a/WordPress/build.gradle +++ b/WordPress/build.gradle @@ -430,6 +430,8 @@ dependencies { implementation(libs.google.mlkit.text.recognition) implementation(libs.google.mlkit.barcode.scanning.main) + implementation(libs.androidx.browser) + // CameraX implementation(libs.androidx.camera.camera2) implementation(libs.androidx.camera.lifecycle) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginActivity.java index 91d93680b505..2a8cf3a7e758 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginActivity.java @@ -10,6 +10,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.browser.customtabs.CustomTabsIntent; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentTransaction; import androidx.lifecycle.ViewModelProvider; @@ -465,9 +466,13 @@ private void startLogin() { @Override public void showEmailLoginScreen(@NonNull Context context) { - Intent loginWithWPcom = new Intent(Intent.ACTION_VIEW, mLoginHelper.loginUri()); - mUnifiedLoginTracker.setFlowAndStep(Flow.WORDPRESS_COM_WEB, Step.START); - context.startActivity(loginWithWPcom); + CustomTabsIntent intent = new CustomTabsIntent.Builder() + .setShareState(CustomTabsIntent.SHARE_STATE_OFF) + .setStartAnimations(this, R.anim.activity_slide_up_from_bottom, R.anim.activity_slide_up_from_bottom) + .setExitAnimations(this, R.anim.activity_slide_out_to_bottom, R.anim.activity_slide_out_to_bottom) + .setUrlBarHidingEnabled(true) + .build(); + intent.launchUrl(this, mLoginHelper.loginUri()); } @Override diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a1d9199e69aa..b5ef750e64dc 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -9,6 +9,7 @@ androidx-activity = '1.9.3' androidx-annotation = '1.9.0' androidx-appcompat = '1.7.0' androidx-arch-core = '2.2.0' +androidx-browser = '1.5.0' androidx-camera = '1.4.0' androidx-cardview = '1.0.0' androidx-compose-bom = '2024.10.01' @@ -119,6 +120,7 @@ androidx-annotation = { group = "androidx.annotation", name = "annotation", vers androidx-appcompat-main = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidx-appcompat" } androidx-appcompat-resources = { group = "androidx.appcompat", name = "appcompat-resources", version.ref = "androidx-appcompat" } androidx-arch-core-testing = { group = "androidx.arch.core", name = "core-testing", version.ref = "androidx-arch-core" } +androidx-browser = { group="androidx.browser", "name" = "browser", version.ref = "androidx-browser" } androidx-camera-camera2 = { group = "androidx.camera", name = "camera-camera2", version.ref = "androidx-camera" } androidx-camera-lifecycle = { group = "androidx.camera", name = "camera-lifecycle", version.ref = "androidx-camera" } androidx-camera-view = { group = "androidx.camera", name = "camera-view", version.ref = "androidx-camera" }