Skip to content

Commit d0da597

Browse files
committed
android: add toggles to disable bottom sheet and dynamic island popups
1 parent a489829 commit d0da597

4 files changed

Lines changed: 69 additions & 2 deletions

File tree

android/app/src/main/java/me/kavishdevar/librepods/presentation/screens/AppSettingsScreen.kt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,48 @@ fun AppSettingsScreen(
157157
enabled = state.isPremium
158158
)
159159

160+
Text(
161+
text = stringResource(R.string.popup_animations), style = TextStyle(
162+
fontSize = 14.sp,
163+
fontWeight = FontWeight.Bold,
164+
color = textColor.copy(alpha = 0.6f),
165+
fontFamily = FontFamily(Font(R.font.sf_pro))
166+
), modifier = Modifier.padding(16.dp, bottom = 2.dp, top = 24.dp)
167+
)
168+
169+
Spacer(modifier = Modifier.height(2.dp))
170+
171+
Column(
172+
modifier = Modifier
173+
.fillMaxWidth()
174+
.background(
175+
backgroundColor, RoundedCornerShape(28.dp)
176+
)
177+
.padding(vertical = 4.dp)
178+
) {
179+
StyledToggle(
180+
label = stringResource(R.string.show_bottom_sheet_popup),
181+
description = stringResource(R.string.show_bottom_sheet_popup_description),
182+
checked = state.showBottomSheetPopup,
183+
onCheckedChange = viewModel::setShowBottomSheetPopup,
184+
independent = false
185+
)
186+
187+
HorizontalDivider(
188+
thickness = 1.dp,
189+
color = Color(0x40888888),
190+
modifier = Modifier.padding(horizontal = 12.dp)
191+
)
192+
193+
StyledToggle(
194+
label = stringResource(R.string.show_island_popup),
195+
description = stringResource(R.string.show_island_popup_description),
196+
checked = state.showIslandPopup,
197+
onCheckedChange = viewModel::setShowIslandPopup,
198+
independent = false
199+
)
200+
}
201+
160202
Text(
161203
text = stringResource(R.string.conversational_awareness), style = TextStyle(
162204
fontSize = 14.sp,

android/app/src/main/java/me/kavishdevar/librepods/presentation/viewmodel/AppSettingsViewModel.kt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ data class AppSettingsUiState(
3232
val cameraPackageError: String? = null,
3333
val vendorIdHook: Boolean = false,
3434
val isPremium: Boolean = false,
35-
val connectionSuccessful: Boolean = false
35+
val connectionSuccessful: Boolean = false,
36+
val showBottomSheetPopup: Boolean = true,
37+
val showIslandPopup: Boolean = true
3638
)
3739

3840
class AppSettingsViewModel(application: Application) : AndroidViewModel(application) {
@@ -86,7 +88,9 @@ class AppSettingsViewModel(application: Application) : AndroidViewModel(applicat
8688
conversationalAwarenessVolume = sharedPreferences.getInt("conversational_awareness_volume", 43).toFloat(),
8789
cameraPackageValue = sharedPreferences.getString("custom_camera_package", "") ?: "",
8890
vendorIdHook = xposedRemotePref.getBoolean("vendor_id_hook", false),
89-
connectionSuccessful = sharedPreferences.getBoolean("connection_successful", false)
91+
connectionSuccessful = sharedPreferences.getBoolean("connection_successful", false),
92+
showBottomSheetPopup = sharedPreferences.getBoolean("show_bottom_sheet_popup", true),
93+
showIslandPopup = sharedPreferences.getBoolean("show_island_popup", true)
9094
)
9195
}
9296
}
@@ -176,4 +180,14 @@ class AppSettingsViewModel(application: Application) : AndroidViewModel(applicat
176180
xposedRemotePref.putBoolean("vendor_id_hook", enabled)
177181
_uiState.update { it.copy(vendorIdHook = enabled) }
178182
}
183+
184+
fun setShowBottomSheetPopup(enabled: Boolean) {
185+
sharedPreferences.edit { putBoolean("show_bottom_sheet_popup", enabled) }
186+
_uiState.update { it.copy(showBottomSheetPopup = enabled) }
187+
}
188+
189+
fun setShowIslandPopup(enabled: Boolean) {
190+
sharedPreferences.edit { putBoolean("show_island_popup", enabled) }
191+
_uiState.update { it.copy(showIslandPopup = enabled) }
192+
}
179193
}

android/app/src/main/java/me/kavishdevar/librepods/services/AirPodsService.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,6 +1636,9 @@ class AirPodsService : Service(), SharedPreferences.OnSharedPreferenceChangeList
16361636

16371637
var popupShown = false
16381638
fun showPopup(service: Service, name: String) {
1639+
if (!sharedPreferences.getBoolean("show_bottom_sheet_popup", true)) {
1640+
return
1641+
}
16391642
if (!Settings.canDrawOverlays(service)) {
16401643
Log.d(TAG, "No permission for SYSTEM_ALERT_WINDOW")
16411644
return
@@ -1660,6 +1663,9 @@ class AirPodsService : Service(), SharedPreferences.OnSharedPreferenceChangeList
16601663
otherDeviceName: String? = null
16611664
) {
16621665
Log.d(TAG, "Showing island window")
1666+
if (!sharedPreferences.getBoolean("show_island_popup", true)) {
1667+
return
1668+
}
16631669
if (!Settings.canDrawOverlays(service)) {
16641670
Log.d(TAG, "No permission for SYSTEM_ALERT_WINDOW")
16651671
return

android/app/src/main/res/values/strings.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@
140140
<string name="widget">Widget</string>
141141
<string name="show_phone_battery_in_widget">Show phone battery in widget</string>
142142
<string name="show_phone_battery_in_widget_description">Display your phone\'s battery level in the widget alongside AirPods battery</string>
143+
<string name="popup_animations">Popup Animations</string>
144+
<string name="show_bottom_sheet_popup">Bottom sheet popup</string>
145+
<string name="show_bottom_sheet_popup_description">Show the iOS-style modal popup at the bottom when AirPods connect.</string>
146+
<string name="show_island_popup">Dynamic Island popup</string>
147+
<string name="show_island_popup_description">Show the Dynamic Island-style popup at the top for connection and takeover events.</string>
143148
<string name="conversational_awareness_volume">Conversational Awareness Volume</string>
144149
<string name="quick_settings_tile">Quick Settings Tile</string>
145150
<string name="open_dialog_for_controlling">Open dialog for controlling</string>

0 commit comments

Comments
 (0)