Skip to content

Commit dd5451a

Browse files
committed
fix: replace CustomTabIntent with AuthTabIntent
Signed-off-by: mykh-hailo <kristianderonta0205@gmail.com>
1 parent 4a721fd commit dd5451a

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,6 @@
7676
<package android:name="at.bitfire.davdroid" />
7777
<package android:name="org.fairscan.app" />
7878

79-
<intent>
80-
<action android:name="android.support.customtabs.action.CustomTabsService" />
81-
</intent>
8279
<intent>
8380
<action android:name="android.intent.action.VIEW" />
8481

app/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
import com.nextcloud.operations.PostMethod;
6868
import com.nextcloud.utils.extensions.BundleExtensionsKt;
6969
import com.nextcloud.utils.mdm.MDMConfig;
70-
import com.owncloud.android.BuildConfig;
7170
import com.owncloud.android.MainApp;
7271
import com.owncloud.android.R;
7372
import com.owncloud.android.databinding.AccountSetupBinding;
@@ -128,8 +127,7 @@
128127
import androidx.annotation.Nullable;
129128
import androidx.annotation.VisibleForTesting;
130129
import androidx.appcompat.app.ActionBar;
131-
import androidx.browser.customtabs.CustomTabColorSchemeParams;
132-
import androidx.browser.customtabs.CustomTabsIntent;
130+
import androidx.browser.auth.AuthTabIntent;
133131
import androidx.core.content.ContextCompat;
134132
import androidx.core.graphics.Insets;
135133
import androidx.core.view.ViewCompat;
@@ -496,22 +494,15 @@ private void launchDefaultWebBrowser(String url) {
496494
}
497495

498496
Uri uri = Uri.parse(url);
497+
String loginScheme = getString(R.string.login_data_own_scheme);
499498

500499
try {
501500
int toolbarColor = ContextCompat.getColor(this, R.color.primary);
502-
CustomTabColorSchemeParams colorParams = new CustomTabColorSchemeParams.Builder()
503-
.setToolbarColor(toolbarColor)
504-
.build();
505-
CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder()
506-
.setDefaultColorSchemeParams(colorParams)
507-
.setColorScheme(CustomTabsIntent.COLOR_SCHEME_SYSTEM)
508-
.setShowTitle(true)
509-
.setShareState(CustomTabsIntent.SHARE_STATE_OFF)
510-
.build();
511-
customTabsIntent.launchUrl(this, uri);
501+
AuthTabIntent authTabIntent = new AuthTabIntent.Builder().setColorScheme(toolbarColor).build();
502+
authTabIntent.launch(authTabResultLauncher, uri, loginScheme);
512503
return;
513504
} catch (Exception e) {
514-
Log_OC.e(TAG, "Custom Tab login URL launch failed: " + e);
505+
Log_OC.e(TAG, "Auth Tab login URL launch failed: " + e);
515506
}
516507

517508
try {
@@ -1578,6 +1569,11 @@ private void startQRScanner() {
15781569
qrScanResultLauncher.launch(intent);
15791570
}
15801571

1572+
private final ActivityResultLauncher<Intent> authTabResultLauncher = AuthTabIntent.registerActivityResultLauncher(
1573+
this,
1574+
result -> Log_OC.d(TAG, "Auth Tab result code: " + result.resultCode)
1575+
);
1576+
15811577
private final ActivityResultLauncher<Intent> qrScanResultLauncher = registerForActivityResult(
15821578
new ActivityResultContracts.StartActivityForResult(),
15831579
result -> {

0 commit comments

Comments
 (0)