Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ dependencies {

// region UI
implementation(libs.bundles.ui)
implementation(libs.browser)
// endregion

// region Worker
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@
<package android:name="at.bitfire.davdroid" />
<package android:name="org.fairscan.app" />

<intent>
<action android:name="android.support.customtabs.action.CustomTabsService" />
</intent>
<intent>
<action android:name="android.intent.action.VIEW" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.ActionBar;
import androidx.browser.customtabs.CustomTabColorSchemeParams;
import androidx.browser.customtabs.CustomTabsIntent;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
Expand Down Expand Up @@ -492,20 +495,37 @@ private void launchDefaultWebBrowser(String url) {
return;
}

Uri uri = Uri.parse(url);

try {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PackageManager packageManager = getPackageManager();
int toolbarColor = ContextCompat.getColor(this, R.color.primary);
CustomTabColorSchemeParams colorParams = new CustomTabColorSchemeParams.Builder()
.setToolbarColor(toolbarColor)
.build();
CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder()
.setDefaultColorSchemeParams(colorParams)
.setColorScheme(CustomTabsIntent.COLOR_SCHEME_SYSTEM)
.setShowTitle(true)
.setShareState(CustomTabsIntent.SHARE_STATE_OFF)
.build();
customTabsIntent.launchUrl(this, uri);
return;
} catch (Exception e) {
Log_OC.e(TAG, "Custom Tab login URL launch failed: " + e);
}

try {
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
PackageManager packageManager = getPackageManager();
if (intent.resolveActivity(packageManager) != null) {
startActivity(intent);
} else {
DisplayUtils.showSnackMessage(this, R.string.authenticator_activity_no_web_browser_found);
return;
}
} catch (Exception e) {
Log_OC.e(TAG, "Exception launchDefaultWebBrowser: " + e);
DisplayUtils.showSnackMessage(this, R.string.authenticator_activity_login_error);
Log_OC.e(TAG, "External browser launch failed: " + e);
}

DisplayUtils.showSnackMessage(this, R.string.authenticator_activity_no_web_browser_found);
}

private Pair<String, String> extractPollUrlAndToken() {
Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ androidxTestVersion = "1.7.0"
annotationVersion = "1.9.1"
annotationsVersion = "3.0.1u2"
appCompatVersion = "1.7.1"
browserVersion = "1.10.0"
bcpkixJdk18onVersion = "1.83"
cardviewVersion = "1.0.0"
checker = "3.21.2"
Expand Down Expand Up @@ -93,6 +94,7 @@ conscrypt-android = { module = "org.conscrypt:conscrypt-android", version.ref =
bcpkix-jdk18on = { module = "org.bouncycastle:bcpkix-jdk18on", version.ref = "bcpkixJdk18onVersion" }

# UI
browser = { module = "androidx.browser:browser", version.ref = "browserVersion" }
appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appCompatVersion" }
cardview = { module = "androidx.cardview:cardview", version.ref = "cardviewVersion" }
core-ktx = { module = "androidx.test:core-ktx", version.ref = "androidxTestVersion" }
Expand Down
1 change: 1 addition & 0 deletions gradle/verification-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<trusted-key id="0CDE80149711EB46DFF17AE421A24B3F8B0F594A" group="org.apache" name="apache" version="16"/>
<trusted-key id="0D35D3F60078655126908E8AF3D1600878E85A3D" group="io.netty"/>
<trusted-key id="0E225917414670F4442C250DFD533C07C264648F">
<trusting group="androidx.browser" name="browser" version="1.10.0"/>
<trusting group="androidx.core"/>
<trusting group="androidx.databinding"/>
<trusting group="androidx.media3"/>
Expand Down