Skip to content

Commit aae40e9

Browse files
authored
[auth] Add Android Quick Settings tile to launch the app (#7831)
Users can now add a Quick Settings tile to quickly launch the app. This provides a convenient shortcut to access 2FA codes without searching for the app on the home screen or app drawer. Changes: - Android: Added QuickTileService to the manifest. - Android: Implemented QuickTileService, the tile launches the main activity. - Android: Included a monochrome icon for the tile. ## Description This PR introduces a Quick Settings tile on Android to launch the Ente Auth app. The following changes have been made: - **AndroidManifest.xml** Registered the new QuickTileService. - **QuickTileService.kt** Implemented the service that handles the tile's onClick event, which launches the MainActivity. The implementation handles the deprecated startActivityAndCollapse for backward compatibility. - **drawable/ic_qs_monochrome.xml** Added a monochrome icon for the tile, as required for the Quick Settings panel. Related discussion #1026 ## Tests Physical Device and emulator on Android 16 (SDK 36) Result: The tile is correctly displayed and launches the app successfully. Emulator: Android 5.0 (SDK 21) Result: This test was performed to ensure backward compatibility on Android versions below API 24 (which do not support Quick Settings tiles). The app runs without any crashes or issues. The new code is correctly bypassed on older versions. https://github.com/user-attachments/assets/1b804753-907d-4b0f-a978-b66d1fa97f64
2 parents 48c7f02 + 5121693 commit aae40e9

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

mobile/apps/auth/android/app/src/main/AndroidManifest.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,22 @@
4343

4444
</activity>
4545

46+
<service
47+
android:name=".QuickTileService"
48+
android:icon="@drawable/ic_qs_monochrome"
49+
android:label="Ente Auth"
50+
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
51+
android:exported="true"
52+
tools:targetApi="24">
53+
54+
<meta-data android:name="android.service.quicksettings.TOGGLEABLE_TILE"
55+
android:value="true" />
56+
57+
<intent-filter>
58+
<action android:name="android.service.quicksettings.action.QS_TILE" />
59+
</intent-filter>
60+
</service>
61+
4662
<!-- Don't delete the meta-data below.
4763
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
4864
<meta-data android:name="flutterEmbedding" android:value="2"/>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package io.ente.auth
2+
3+
import android.annotation.SuppressLint
4+
import android.app.PendingIntent
5+
import android.content.Intent
6+
import android.os.Build
7+
import android.service.quicksettings.TileService
8+
import androidx.annotation.RequiresApi
9+
10+
@RequiresApi(Build.VERSION_CODES.N)
11+
class QuickTileService : TileService() {
12+
13+
override fun onStartListening() {
14+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) return
15+
val tile = qsTile
16+
tile.subtitle = "Open Ente Auth"
17+
tile.updateTile()
18+
}
19+
20+
@SuppressLint("StartActivityAndCollapseDeprecated")
21+
override fun onClick() {
22+
val intent = Intent(applicationContext, MainActivity::class.java).apply {
23+
flags = Intent.FLAG_ACTIVITY_NEW_TASK
24+
}
25+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
26+
startActivityAndCollapse(
27+
PendingIntent.getActivity(
28+
this,
29+
0,
30+
intent,
31+
PendingIntent.FLAG_IMMUTABLE,
32+
),
33+
)
34+
} else {
35+
startActivityAndCollapse(intent)
36+
}
37+
}
38+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="23.892136dp" android:viewportHeight="443" android:viewportWidth="445" android:width="24dp">
2+
3+
<path android:fillColor="#ffffff" android:pathData="M75,0C75.13,27.13 74.91,54.24 74.43,81.36 74.03,103.58 73.87,125.78 74,148L77,148C80.78,125.81 81.89,103.25 83.86,80.83 84.64,72.02 85.42,63.21 86.2,54.39 87.8,36.26 89.4,18.13 91,0 114.42,8.23 137.04,18.57 160,28 159.89,38.19 159.78,48.38 159.66,58.57 159.4,96.95 163.49,123.22 136.76,155.25 124.19,167.1 84.27,193.2 73.89,191.52 44.77,176.87 11.65,152.27 1,121 -1.19,109.29 3.38,41.25 6,22 23.05,16.33 40.08,10.64 57.11,4.91 63.02,3.04 68.87,1.17 75,0ZM358.42,288.55c-22.31,0.71 -44.64,0.63 -66.96,0.7 -35.9,0.19 -71.81,0.11 -107.71,0.36C161.91,287.93 162.4,313.46 201,329c85.04,31.22 128.65,-29.84 172,-20 33.05,12.62 59.9,66.54 -2,104 -37.71,23.12 -168.2,68.25 -271,-31 -71.25,-65.59 -59.73,-173.26 -56,-193 6.38,0.78 11.86,4.31 17.29,7.47 3.49,2.03 6.97,4.06 10.38,6.22C77.66,206.78 117.34,187.8 146,162 174.02,138.61 170.35,101.91 170.75,68.96 170.9,56.26 171.19,47.47 172,38 386.64,-54.82 556.88,282.51 358.42,288.55ZM167,182c1.34,3.55 2.48,4.69 5.74,6.61 6.62,2.68 14.04,1.76 21.05,1.79 10.33,0.04 0.13,-0.02 23.13,0 32.71,-0.03 65.43,-0 98.14,-0.03 3.53,-0.45 5.91,-1.54 8.94,-3.38 2.54,-3.82 2.79,-6.6 2,-11 -26.59,-72.58 -155.6,-51.22 -159,6z"/>
4+
5+
</vector>

0 commit comments

Comments
 (0)