|
67 | 67 | import com.nextcloud.operations.PostMethod; |
68 | 68 | import com.nextcloud.utils.extensions.BundleExtensionsKt; |
69 | 69 | import com.nextcloud.utils.mdm.MDMConfig; |
70 | | -import com.owncloud.android.BuildConfig; |
71 | 70 | import com.owncloud.android.MainApp; |
72 | 71 | import com.owncloud.android.R; |
73 | 72 | import com.owncloud.android.databinding.AccountSetupBinding; |
|
128 | 127 | import androidx.annotation.Nullable; |
129 | 128 | import androidx.annotation.VisibleForTesting; |
130 | 129 | import androidx.appcompat.app.ActionBar; |
| 130 | +import androidx.browser.auth.AuthTabIntent; |
| 131 | +import androidx.core.content.ContextCompat; |
131 | 132 | import androidx.core.graphics.Insets; |
132 | 133 | import androidx.core.view.ViewCompat; |
133 | 134 | import androidx.core.view.WindowInsetsCompat; |
@@ -492,20 +493,30 @@ private void launchDefaultWebBrowser(String url) { |
492 | 493 | return; |
493 | 494 | } |
494 | 495 |
|
| 496 | + Uri uri = Uri.parse(url); |
| 497 | + String loginScheme = getString(R.string.login_data_own_scheme); |
| 498 | + |
495 | 499 | try { |
496 | | - Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); |
497 | | - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
498 | | - PackageManager packageManager = getPackageManager(); |
| 500 | + int toolbarColor = ContextCompat.getColor(this, R.color.primary); |
| 501 | + AuthTabIntent authTabIntent = new AuthTabIntent.Builder().setColorScheme(toolbarColor).build(); |
| 502 | + authTabIntent.launch(authTabResultLauncher, uri, loginScheme); |
| 503 | + return; |
| 504 | + } catch (Exception e) { |
| 505 | + Log_OC.e(TAG, "Auth Tab login URL launch failed: " + e); |
| 506 | + } |
499 | 507 |
|
| 508 | + try { |
| 509 | + Intent intent = new Intent(Intent.ACTION_VIEW, uri); |
| 510 | + PackageManager packageManager = getPackageManager(); |
500 | 511 | if (intent.resolveActivity(packageManager) != null) { |
501 | 512 | startActivity(intent); |
502 | | - } else { |
503 | | - DisplayUtils.showSnackMessage(this, R.string.authenticator_activity_no_web_browser_found); |
| 513 | + return; |
504 | 514 | } |
505 | 515 | } catch (Exception e) { |
506 | | - Log_OC.e(TAG, "Exception launchDefaultWebBrowser: " + e); |
507 | | - DisplayUtils.showSnackMessage(this, R.string.authenticator_activity_login_error); |
| 516 | + Log_OC.e(TAG, "External browser launch failed: " + e); |
508 | 517 | } |
| 518 | + |
| 519 | + DisplayUtils.showSnackMessage(this, R.string.authenticator_activity_no_web_browser_found); |
509 | 520 | } |
510 | 521 |
|
511 | 522 | private Pair<String, String> extractPollUrlAndToken() { |
@@ -1558,6 +1569,11 @@ private void startQRScanner() { |
1558 | 1569 | qrScanResultLauncher.launch(intent); |
1559 | 1570 | } |
1560 | 1571 |
|
| 1572 | + private final ActivityResultLauncher<Intent> authTabResultLauncher = AuthTabIntent.registerActivityResultLauncher( |
| 1573 | + this, |
| 1574 | + result -> Log_OC.d(TAG, "Auth Tab result code: " + result.resultCode) |
| 1575 | + ); |
| 1576 | + |
1561 | 1577 | private final ActivityResultLauncher<Intent> qrScanResultLauncher = registerForActivityResult( |
1562 | 1578 | new ActivityResultContracts.StartActivityForResult(), |
1563 | 1579 | result -> { |
|
0 commit comments