Skip to content

Commit 11e56f1

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

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

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

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
import androidx.annotation.Nullable;
129129
import androidx.annotation.VisibleForTesting;
130130
import androidx.appcompat.app.ActionBar;
131+
import androidx.browser.auth.AuthTabIntent;
131132
import androidx.browser.customtabs.CustomTabColorSchemeParams;
132133
import androidx.browser.customtabs.CustomTabsIntent;
133134
import androidx.core.content.ContextCompat;
@@ -496,22 +497,15 @@ private void launchDefaultWebBrowser(String url) {
496497
}
497498

498499
Uri uri = Uri.parse(url);
500+
String loginScheme = getString(R.string.login_data_own_scheme);
499501

500502
try {
501503
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);
504+
AuthTabIntent authTabIntent = new AuthTabIntent.Builder().setColorScheme(toolbarColor).build();
505+
authTabIntent.launch(authTabResultLauncher, uri, loginScheme);
512506
return;
513507
} catch (Exception e) {
514-
Log_OC.e(TAG, "Custom Tab login URL launch failed: " + e);
508+
Log_OC.e(TAG, "Auth Tab login URL launch failed: " + e);
515509
}
516510

517511
try {
@@ -1578,6 +1572,11 @@ private void startQRScanner() {
15781572
qrScanResultLauncher.launch(intent);
15791573
}
15801574

1575+
private final ActivityResultLauncher<Intent> authTabResultLauncher = AuthTabIntent.registerActivityResultLauncher(
1576+
this,
1577+
result -> Log_OC.d(TAG, "Auth Tab result code: " + result.resultCode)
1578+
);
1579+
15811580
private final ActivityResultLauncher<Intent> qrScanResultLauncher = registerForActivityResult(
15821581
new ActivityResultContracts.StartActivityForResult(),
15831582
result -> {

0 commit comments

Comments
 (0)