|
128 | 128 | import androidx.annotation.Nullable; |
129 | 129 | import androidx.annotation.VisibleForTesting; |
130 | 130 | import androidx.appcompat.app.ActionBar; |
| 131 | +import androidx.browser.auth.AuthTabIntent; |
131 | 132 | import androidx.browser.customtabs.CustomTabColorSchemeParams; |
132 | 133 | import androidx.browser.customtabs.CustomTabsIntent; |
133 | 134 | import androidx.core.content.ContextCompat; |
@@ -496,22 +497,15 @@ private void launchDefaultWebBrowser(String url) { |
496 | 497 | } |
497 | 498 |
|
498 | 499 | Uri uri = Uri.parse(url); |
| 500 | + String loginScheme = getString(R.string.login_data_own_scheme); |
499 | 501 |
|
500 | 502 | try { |
501 | 503 | 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); |
512 | 506 | return; |
513 | 507 | } 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); |
515 | 509 | } |
516 | 510 |
|
517 | 511 | try { |
@@ -1578,6 +1572,11 @@ private void startQRScanner() { |
1578 | 1572 | qrScanResultLauncher.launch(intent); |
1579 | 1573 | } |
1580 | 1574 |
|
| 1575 | + private final ActivityResultLauncher<Intent> authTabResultLauncher = AuthTabIntent.registerActivityResultLauncher( |
| 1576 | + this, |
| 1577 | + result -> Log_OC.d(TAG, "Auth Tab result code: " + result.resultCode) |
| 1578 | + ); |
| 1579 | + |
1581 | 1580 | private final ActivityResultLauncher<Intent> qrScanResultLauncher = registerForActivityResult( |
1582 | 1581 | new ActivityResultContracts.StartActivityForResult(), |
1583 | 1582 | result -> { |
|
0 commit comments