Dough Git

commit

Hmm

commit
ae195534157e4a348c62d08423900b231dbcc264
author
Clove Twilight <[email protected]>
date
2026-10-24 23:23

diff --git a/email/src/main/AndroidManifest.xml b/email/src/main/AndroidManifest.xml
index ac116c7..fa10b98 100644
--- a/email/src/main/AndroidManifest.xml
+++ b/email/src/main/AndroidManifest.xml
@@ -5,6 +5,11 @@
 
     <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
 
+    <!-- So LauncherActivity can tell whether Chrome is installed. -->
+    <queries>
+        <package android:name="com.android.chrome" />
+    </queries>
+
     <application
         android:allowBackup="true"
         android:icon="@mipmap/ic_launcher"
@@ -16,7 +21,7 @@
             android:resource="@string/asset_statements" />
 
         <activity
-            android:name="com.google.androidbrowserhelper.trusted.LauncherActivity"
+            android:name=".LauncherActivity"
             android:exported="true"
             android:label="@string/app_name">
             <meta-data
diff --git a/email/src/main/java/gay/doughmination/mail/LauncherActivity.java b/email/src/main/java/gay/doughmination/mail/LauncherActivity.java
new file mode 100644
index 0000000..a6a103a
--- /dev/null
+++ b/email/src/main/java/gay/doughmination/mail/LauncherActivity.java
@@ -0,0 +1,29 @@
+package gay.doughmination.mail;
+
+import android.content.pm.PackageManager;
+
+import com.google.androidbrowserhelper.trusted.TwaLauncher;
+
+/**
+ * Opens the site in Chrome even when another browser is the default. The
+ * library would otherwise pick the default browser, and browsers other than
+ * Chrome tend to show it as a custom tab with an address bar. Without Chrome
+ * installed, it falls back to the library's own choice.
+ */
+public class LauncherActivity extends com.google.androidbrowserhelper.trusted.LauncherActivity {
+    private static final String CHROME = "com.android.chrome";
+
+    @Override
+    protected TwaLauncher createTwaLauncher() {
+        return new TwaLauncher(this, isInstalled(CHROME) ? CHROME : null);
+    }
+
+    private boolean isInstalled(String pkg) {
+        try {
+            PackageManager pm = getPackageManager();
+            return pm.getApplicationInfo(pkg, 0).enabled;
+        } catch (PackageManager.NameNotFoundException e) {
+            return false;
+        }
+    }
+}