android: add a (very important) support dialog

to not be invasive, this only shows up once, and never again.
This commit is contained in:
Kavish Devar
2025-10-26 20:48:23 +05:30
parent 55768beb7c
commit 9b950e13d6
3 changed files with 48 additions and 3 deletions

View File

@@ -180,7 +180,13 @@ fun ConfirmationDialog(
.background(if (leftPressed) pressedColor else Color.Transparent), .background(if (leftPressed) pressedColor else Color.Transparent),
contentAlignment = Alignment.Center contentAlignment = Alignment.Center
) { ) {
Text(dismissText, color = accentColor) Text(
text = dismissText,
style = TextStyle(
color = accentColor,
fontFamily = FontFamily(Font(R.font.sf_pro))
)
)
} }
Box( Box(
modifier = Modifier modifier = Modifier
@@ -195,11 +201,17 @@ fun ConfirmationDialog(
.background(if (rightPressed) pressedColor else Color.Transparent), .background(if (rightPressed) pressedColor else Color.Transparent),
contentAlignment = Alignment.Center contentAlignment = Alignment.Center
) { ) {
Text(confirmText, color = accentColor) Text(
text = confirmText,
style = TextStyle(
color = accentColor,
fontFamily = FontFamily(Font(R.font.sf_pro))
)
)
} }
} }
} }
} }
} }
} }
} }

View File

@@ -65,11 +65,14 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import androidx.core.content.edit
import androidx.core.net.toUri
import androidx.navigation.NavController import androidx.navigation.NavController
import androidx.navigation.compose.rememberNavController import androidx.navigation.compose.rememberNavController
import com.kyant.backdrop.backdrops.rememberLayerBackdrop import com.kyant.backdrop.backdrops.rememberLayerBackdrop
import com.kyant.backdrop.drawBackdrop import com.kyant.backdrop.drawBackdrop
import com.kyant.backdrop.highlight.Highlight import com.kyant.backdrop.highlight.Highlight
import dev.chrisbanes.haze.HazeState
import dev.chrisbanes.haze.hazeSource import dev.chrisbanes.haze.hazeSource
import dev.chrisbanes.haze.materials.ExperimentalHazeMaterialsApi import dev.chrisbanes.haze.materials.ExperimentalHazeMaterialsApi
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@@ -78,6 +81,7 @@ import me.kavishdevar.librepods.composables.AboutCard
import me.kavishdevar.librepods.composables.AudioSettings import me.kavishdevar.librepods.composables.AudioSettings
import me.kavishdevar.librepods.composables.BatteryView import me.kavishdevar.librepods.composables.BatteryView
import me.kavishdevar.librepods.composables.CallControlSettings import me.kavishdevar.librepods.composables.CallControlSettings
import me.kavishdevar.librepods.composables.ConfirmationDialog
import me.kavishdevar.librepods.composables.ConnectionSettings import me.kavishdevar.librepods.composables.ConnectionSettings
import me.kavishdevar.librepods.composables.HearingHealthSettings import me.kavishdevar.librepods.composables.HearingHealthSettings
import me.kavishdevar.librepods.composables.MicrophoneSettings import me.kavishdevar.librepods.composables.MicrophoneSettings
@@ -212,6 +216,10 @@ fun AirPodsSettingsScreen(dev: BluetoothDevice?, service: AirPodsService,
} }
val darkMode = isSystemInDarkTheme() val darkMode = isSystemInDarkTheme()
val hazeStateS = remember { mutableStateOf(HazeState()) }
val showDialog = remember { mutableStateOf(!sharedPreferences.getBoolean("donationDialogShown", false)) }
StyledScaffold( StyledScaffold(
title = deviceName.text, title = deviceName.text,
actionButtons = listOf( actionButtons = listOf(
@@ -226,6 +234,7 @@ fun AirPodsSettingsScreen(dev: BluetoothDevice?, service: AirPodsService,
), ),
snackbarHostState = snackbarHostState snackbarHostState = snackbarHostState
) { spacerHeight, hazeState -> ) { spacerHeight, hazeState ->
hazeStateS.value = hazeState
if (isLocallyConnected || isRemotelyConnected) { if (isLocallyConnected || isRemotelyConnected) {
val instance = service.airpodsInstance val instance = service.airpodsInstance
if (instance == null) { if (instance == null) {
@@ -339,6 +348,7 @@ fun AirPodsSettingsScreen(dev: BluetoothDevice?, service: AirPodsService,
Highlight.Ambient.copy(alpha = 0f) Highlight.Ambient.copy(alpha = 0f)
} }
) )
.hazeSource(hazeState)
.padding(horizontal = 8.dp), .padding(horizontal = 8.dp),
horizontalAlignment = Alignment.CenterHorizontally, horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center verticalArrangement = Arrangement.Center
@@ -405,6 +415,25 @@ fun AirPodsSettingsScreen(dev: BluetoothDevice?, service: AirPodsService,
} }
} }
} }
ConfirmationDialog(
showDialog = showDialog,
title = stringResource(R.string.support_librepods),
message = stringResource(R.string.support_dialog_description),
confirmText = stringResource(R.string.support_me) + " \uDBC0\uDEB5",
dismissText = stringResource(R.string.never_show_again),
onConfirm = {
val browserIntent = Intent(
Intent.ACTION_VIEW,
"https://github.com/sponsors/kavishdevar".toUri()
)
context.startActivity(browserIntent)
sharedPreferences.edit { putBoolean("donationDialogShown", true) }
},
onDismiss = {
sharedPreferences.edit { putBoolean("donationDialogShown", true) }
},
hazeState = hazeStateS.value,
)
} }
@Preview @Preview

View File

@@ -206,4 +206,8 @@
<string name="environmental_noise">Environmental Noise</string> <string name="environmental_noise">Environmental Noise</string>
<string name="reconnect_to_last_device">Reconnect to last connected device</string> <string name="reconnect_to_last_device">Reconnect to last connected device</string>
<string name="disconnect">Disconnect</string> <string name="disconnect">Disconnect</string>
<string name="support_me">Support me</string>
<string name="never_show_again">Never show again</string>
<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>
<string name="support_librepods">Support LibrePods</string>
</resources> </resources>