Skip to content

Commit 9b950e1

Browse files
committed
android: add a (very important) support dialog
to not be invasive, this only shows up once, and never again.
1 parent 55768be commit 9b950e1

File tree

3 files changed

+48
-3
lines changed

3 files changed

+48
-3
lines changed

android/app/src/main/java/me/kavishdevar/librepods/composables/ConfirmationDialog.kt

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,13 @@ fun ConfirmationDialog(
180180
.background(if (leftPressed) pressedColor else Color.Transparent),
181181
contentAlignment = Alignment.Center
182182
) {
183-
Text(dismissText, color = accentColor)
183+
Text(
184+
text = dismissText,
185+
style = TextStyle(
186+
color = accentColor,
187+
fontFamily = FontFamily(Font(R.font.sf_pro))
188+
)
189+
)
184190
}
185191
Box(
186192
modifier = Modifier
@@ -195,11 +201,17 @@ fun ConfirmationDialog(
195201
.background(if (rightPressed) pressedColor else Color.Transparent),
196202
contentAlignment = Alignment.Center
197203
) {
198-
Text(confirmText, color = accentColor)
204+
Text(
205+
text = confirmText,
206+
style = TextStyle(
207+
color = accentColor,
208+
fontFamily = FontFamily(Font(R.font.sf_pro))
209+
)
210+
)
199211
}
200212
}
201213
}
202214
}
203215
}
204216
}
205-
}
217+
}

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,14 @@ import androidx.compose.ui.text.style.TextAlign
6565
import androidx.compose.ui.tooling.preview.Preview
6666
import androidx.compose.ui.unit.dp
6767
import androidx.compose.ui.unit.sp
68+
import androidx.core.content.edit
69+
import androidx.core.net.toUri
6870
import androidx.navigation.NavController
6971
import androidx.navigation.compose.rememberNavController
7072
import com.kyant.backdrop.backdrops.rememberLayerBackdrop
7173
import com.kyant.backdrop.drawBackdrop
7274
import com.kyant.backdrop.highlight.Highlight
75+
import dev.chrisbanes.haze.HazeState
7376
import dev.chrisbanes.haze.hazeSource
7477
import dev.chrisbanes.haze.materials.ExperimentalHazeMaterialsApi
7578
import kotlinx.coroutines.launch
@@ -78,6 +81,7 @@ import me.kavishdevar.librepods.composables.AboutCard
7881
import me.kavishdevar.librepods.composables.AudioSettings
7982
import me.kavishdevar.librepods.composables.BatteryView
8083
import me.kavishdevar.librepods.composables.CallControlSettings
84+
import me.kavishdevar.librepods.composables.ConfirmationDialog
8185
import me.kavishdevar.librepods.composables.ConnectionSettings
8286
import me.kavishdevar.librepods.composables.HearingHealthSettings
8387
import me.kavishdevar.librepods.composables.MicrophoneSettings
@@ -212,6 +216,10 @@ fun AirPodsSettingsScreen(dev: BluetoothDevice?, service: AirPodsService,
212216
}
213217

214218
val darkMode = isSystemInDarkTheme()
219+
val hazeStateS = remember { mutableStateOf(HazeState()) }
220+
221+
val showDialog = remember { mutableStateOf(!sharedPreferences.getBoolean("donationDialogShown", false)) }
222+
215223
StyledScaffold(
216224
title = deviceName.text,
217225
actionButtons = listOf(
@@ -226,6 +234,7 @@ fun AirPodsSettingsScreen(dev: BluetoothDevice?, service: AirPodsService,
226234
),
227235
snackbarHostState = snackbarHostState
228236
) { spacerHeight, hazeState ->
237+
hazeStateS.value = hazeState
229238
if (isLocallyConnected || isRemotelyConnected) {
230239
val instance = service.airpodsInstance
231240
if (instance == null) {
@@ -339,6 +348,7 @@ fun AirPodsSettingsScreen(dev: BluetoothDevice?, service: AirPodsService,
339348
Highlight.Ambient.copy(alpha = 0f)
340349
}
341350
)
351+
.hazeSource(hazeState)
342352
.padding(horizontal = 8.dp),
343353
horizontalAlignment = Alignment.CenterHorizontally,
344354
verticalArrangement = Arrangement.Center
@@ -405,6 +415,25 @@ fun AirPodsSettingsScreen(dev: BluetoothDevice?, service: AirPodsService,
405415
}
406416
}
407417
}
418+
ConfirmationDialog(
419+
showDialog = showDialog,
420+
title = stringResource(R.string.support_librepods),
421+
message = stringResource(R.string.support_dialog_description),
422+
confirmText = stringResource(R.string.support_me) + " \uDBC0\uDEB5",
423+
dismissText = stringResource(R.string.never_show_again),
424+
onConfirm = {
425+
val browserIntent = Intent(
426+
Intent.ACTION_VIEW,
427+
"https://github.com/sponsors/kavishdevar".toUri()
428+
)
429+
context.startActivity(browserIntent)
430+
sharedPreferences.edit { putBoolean("donationDialogShown", true) }
431+
},
432+
onDismiss = {
433+
sharedPreferences.edit { putBoolean("donationDialogShown", true) }
434+
},
435+
hazeState = hazeStateS.value,
436+
)
408437
}
409438

410439
@Preview

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,4 +206,8 @@
206206
<string name="environmental_noise">Environmental Noise</string>
207207
<string name="reconnect_to_last_device">Reconnect to last connected device</string>
208208
<string name="disconnect">Disconnect</string>
209+
<string name="support_me">Support me</string>
210+
<string name="never_show_again">Never show again</string>
211+
<string name="support_dialog_description">I recently lost my left AirPod. If you\'ve found LibrePods useful, consider supporting me on GitHub Sponsors so I can buy a replacement and continue working on this project- even a little amount goes a long way. Thank you for your support!</string>
212+
<string name="support_librepods">Support LibrePods</string>
209213
</resources>

0 commit comments

Comments
 (0)