|
128 | 128 | import androidx.annotation.Nullable; |
129 | 129 | import androidx.annotation.VisibleForTesting; |
130 | 130 | import androidx.appcompat.app.ActionBar; |
| 131 | +import androidx.browser.customtabs.CustomTabColorSchemeParams; |
| 132 | +import androidx.browser.customtabs.CustomTabsIntent; |
| 133 | +import androidx.core.content.ContextCompat; |
131 | 134 | import androidx.core.graphics.Insets; |
132 | 135 | import androidx.core.view.ViewCompat; |
133 | 136 | import androidx.core.view.WindowInsetsCompat; |
@@ -492,20 +495,37 @@ private void launchDefaultWebBrowser(String url) { |
492 | 495 | return; |
493 | 496 | } |
494 | 497 |
|
| 498 | + Uri uri = Uri.parse(url); |
| 499 | + |
495 | 500 | try { |
496 | | - Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); |
497 | | - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
498 | | - PackageManager packageManager = getPackageManager(); |
| 501 | + 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); |
| 512 | + return; |
| 513 | + } catch (Exception e) { |
| 514 | + Log_OC.e(TAG, "Custom Tab login URL launch failed: " + e); |
| 515 | + } |
499 | 516 |
|
| 517 | + try { |
| 518 | + Intent intent = new Intent(Intent.ACTION_VIEW, uri); |
| 519 | + PackageManager packageManager = getPackageManager(); |
500 | 520 | if (intent.resolveActivity(packageManager) != null) { |
501 | 521 | startActivity(intent); |
502 | | - } else { |
503 | | - DisplayUtils.showSnackMessage(this, R.string.authenticator_activity_no_web_browser_found); |
| 522 | + return; |
504 | 523 | } |
505 | 524 | } catch (Exception e) { |
506 | | - Log_OC.e(TAG, "Exception launchDefaultWebBrowser: " + e); |
507 | | - DisplayUtils.showSnackMessage(this, R.string.authenticator_activity_login_error); |
| 525 | + Log_OC.e(TAG, "External browser launch failed: " + e); |
508 | 526 | } |
| 527 | + |
| 528 | + DisplayUtils.showSnackMessage(this, R.string.authenticator_activity_no_web_browser_found); |
509 | 529 | } |
510 | 530 |
|
511 | 531 | private Pair<String, String> extractPollUrlAndToken() { |
|
0 commit comments