Skip to content

Commit a30285f

Browse files
thisisAcidickavishdevar
authored andcommitted
android: add popup toggles (#561)
* android: add toggles to disable bottom sheet and dynamic island popups * android: translations for popup customization (de, es, fr, pt)
1 parent 4e12d87 commit a30285f

8 files changed

Lines changed: 91 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
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation">
2+
<string name="popup_animations">Popup-Animationen</string>
3+
<string name="show_bottom_sheet_popup">Popup unten</string>
4+
<string name="show_bottom_sheet_popup_description">Zeigt das Popup im iOS-Stil unten an, wenn AirPods sich verbinden.</string>
5+
<string name="show_island_popup">Dynamic Island Popup</string>
6+
<string name="show_island_popup_description">Zeigt das Popup im Dynamic-Island-Stil oben für Verbindungs- und Übergabe-Ereignisse.</string>
7+
</resources>

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,4 +210,9 @@
210210
<string name="listening_mode_transparency_description">Deja entrar los sonidos externos</string>
211211
<string name="listening_mode_adaptive_description">Ajuste dinámico del ruido externo</string>
212212
<string name="listening_mode_noise_cancellation_description">Bloquea los sonidos externos</string>
213+
<string name="popup_animations">Animaciones emergentes</string>
214+
<string name="show_bottom_sheet_popup">Ventana emergente inferior</string>
215+
<string name="show_bottom_sheet_popup_description">Muestra la ventana emergente estilo iOS en la parte inferior cuando los AirPods se conectan.</string>
216+
<string name="show_island_popup">Ventana emergente Dynamic Island</string>
217+
<string name="show_island_popup_description">Muestra la ventana emergente estilo Dynamic Island en la parte superior para eventos de conexión y traspaso.</string>
213218
</resources>

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,4 +210,9 @@
210210
<string name="listening_mode_transparency_description">Laisser entrer les sons extérieurs</string>
211211
<string name="listening_mode_adaptive_description">Ajuster dynamiquement les sons extérieurs</string>
212212
<string name="listening_mode_noise_cancellation_description">Bloquer les sons extérieurs</string>
213+
<string name="popup_animations">Animations contextuelles</string>
214+
<string name="show_bottom_sheet_popup">Fenêtre contextuelle en bas</string>
215+
<string name="show_bottom_sheet_popup_description">Afficher la fenêtre contextuelle de style iOS en bas de l\'écran lors de la connexion des AirPods.</string>
216+
<string name="show_island_popup">Fenêtre Dynamic Island</string>
217+
<string name="show_island_popup_description">Afficher la fenêtre de style Dynamic Island en haut de l\'écran pour les événements de connexion et de transfert.</string>
213218
</resources>

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,4 +210,9 @@
210210
<string name="listening_mode_transparency_description">Permite sons externos</string>
211211
<string name="listening_mode_adaptive_description">Ajusta dinamicamente o ruído externo</string>
212212
<string name="listening_mode_noise_cancellation_description">Bloqueia sons externos</string>
213+
<string name="popup_animations">Animações de pop-up</string>
214+
<string name="show_bottom_sheet_popup">Pop-up inferior</string>
215+
<string name="show_bottom_sheet_popup_description">Exibe o pop-up estilo iOS na parte inferior quando os AirPods se conectam.</string>
216+
<string name="show_island_popup">Pop-up Dynamic Island</string>
217+
<string name="show_island_popup_description">Exibe o pop-up estilo Dynamic Island no topo da tela em eventos de conexão e transferência.</string>
213218
</resources>

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)