android: add confirmation step for unsupported devices

This commit is contained in:
Kavish Devar
2026-04-23 03:13:06 +05:30
parent 1804e80cba
commit ae174bc9ea
4 changed files with 30 additions and 51 deletions

View File

@@ -28,7 +28,7 @@ android {
applicationId = "me.kavishdevar.librepods" applicationId = "me.kavishdevar.librepods"
minSdk = 33 minSdk = 33
targetSdk = 37 targetSdk = 37
versionCode = 28 versionCode = 30
versionName = "0.2.0" versionName = "0.2.0"
} }
buildTypes { buildTypes {

View File

@@ -128,6 +128,7 @@ import me.kavishdevar.librepods.billing.BillingProviderFactory
import me.kavishdevar.librepods.data.AirPodsNotifications import me.kavishdevar.librepods.data.AirPodsNotifications
import me.kavishdevar.librepods.data.ControlCommandRepository import me.kavishdevar.librepods.data.ControlCommandRepository
import me.kavishdevar.librepods.presentation.components.ConfirmationDialog import me.kavishdevar.librepods.presentation.components.ConfirmationDialog
import me.kavishdevar.librepods.presentation.components.StyledButton
import me.kavishdevar.librepods.presentation.components.StyledIconButton import me.kavishdevar.librepods.presentation.components.StyledIconButton
import me.kavishdevar.librepods.presentation.screens.AccessibilitySettingsScreen import me.kavishdevar.librepods.presentation.screens.AccessibilitySettingsScreen
import me.kavishdevar.librepods.presentation.screens.AdaptiveStrengthScreen import me.kavishdevar.librepods.presentation.screens.AdaptiveStrengthScreen
@@ -221,20 +222,11 @@ class MainActivity : ComponentActivity() {
fun Main() { fun Main() {
val context = LocalContext.current val context = LocalContext.current
val sharedPreferences = context.getSharedPreferences("settings", MODE_PRIVATE) val sharedPreferences = context.getSharedPreferences("settings", MODE_PRIVATE)
if (false) { // !isSupported(sharedPreferences) && BuildConfig.PLAY_BUILD == true) { if (!isSupported(sharedPreferences)) {
val showDialog = remember { mutableStateOf(false) } val showDialog = remember { mutableStateOf(false) }
val blockTouches = remember { mutableStateOf(false) }
val tapCount = remember { mutableIntStateOf(0) }
val lastTapTime = remember { mutableLongStateOf(0L) }
val hazeState = rememberHazeState() val hazeState = rememberHazeState()
LaunchedEffect(blockTouches) {
if (blockTouches.value) {
delay(500)
blockTouches.value = false
}
}
Box( Box(
modifier = Modifier modifier = Modifier
.fillMaxSize() .fillMaxSize()
@@ -245,26 +237,12 @@ fun Main() {
Box ( Box (
modifier = Modifier modifier = Modifier
.fillMaxSize() .fillMaxSize()
.then(
if (blockTouches.value)
{
Modifier.pointerInput(Unit) {
awaitPointerEventScope {
while (true) {
val event = awaitPointerEvent(PointerEventPass.Initial)
event.changes.forEach { it.consume() }
}
}
}
}
else Modifier
)
) )
Column ( Column (
verticalArrangement = Arrangement.spacedBy(8.dp) verticalArrangement = Arrangement.spacedBy(8.dp)
) { ) {
Text( Text(
text = "Not supported", text = stringResource(R.string.not_supported),
style = TextStyle( style = TextStyle(
fontFamily = FontFamily(Font(R.font.sf_pro)), fontFamily = FontFamily(Font(R.font.sf_pro)),
fontWeight = FontWeight.SemiBold, fontWeight = FontWeight.SemiBold,
@@ -275,25 +253,7 @@ fun Main() {
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth()
) )
Row ( Row (
modifier = Modifier.fillMaxWidth().pointerInput(Unit) { modifier = Modifier.fillMaxWidth(),
detectTapGestures(
onTap = {
val now = System.currentTimeMillis()
if (now - lastTapTime.longValue > 400) {
tapCount.intValue = 0
}
tapCount.intValue++
lastTapTime.longValue = now
if (tapCount.intValue >= 7) {
showDialog.value = true
blockTouches.value = true
}
}
)
},
horizontalArrangement = Arrangement.Center horizontalArrangement = Arrangement.Center
) { ) {
Text( Text(
@@ -323,7 +283,7 @@ fun Main() {
) )
} }
Text( Text(
text = "Check the repository for more info.", text = stringResource(R.string.check_the_repository_for_more_info),
style = TextStyle( style = TextStyle(
fontFamily = FontFamily(Font(R.font.sf_pro)), fontFamily = FontFamily(Font(R.font.sf_pro)),
fontWeight = FontWeight.Medium, fontWeight = FontWeight.Medium,
@@ -333,19 +293,35 @@ fun Main() {
textAlign = TextAlign.Center, textAlign = TextAlign.Center,
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth()
) )
StyledButton(
onClick = { showDialog.value = true },
backdrop = rememberLayerBackdrop(),
modifier = Modifier
.fillMaxWidth()
.padding(8.dp)
) {
Text(
text = stringResource(R.string.bypass_compatibility_check),
style = TextStyle(
fontFamily = FontFamily(Font(R.font.sf_pro)),
fontWeight = FontWeight.Medium,
color = if (isSystemInDarkTheme()) Color.White else Color.Black,
fontSize = 16.sp
),
)
}
} }
} }
ConfirmationDialog( ConfirmationDialog(
showDialog = showDialog, showDialog = showDialog,
title = "Confirm device check bypass?", title = stringResource(R.string.bypass_compatibility_check),
message = "Are you sure your device is supported with LibrePods?", message = stringResource(R.string.bypass_compatiblity_check_confirmation),
confirmText = "Yes", confirmText = "Yes",
dismissText = "No", dismissText = "No",
onConfirm = { onConfirm = {
showDialog.value = false showDialog.value = false
sharedPreferences.edit { sharedPreferences.edit {
tapCount.intValue = 0
putBoolean("bypass_device_check", true) putBoolean("bypass_device_check", true)
val intent = Intent(context, MainActivity::class.java) val intent = Intent(context, MainActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK) intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)

View File

@@ -39,6 +39,5 @@ fun isSupported(sharedPreferences: SharedPreferences): Boolean {
} else if (isOppoOrOnePlus) { } else if (isOppoOrOnePlus) {
return true return true
} }
return if (BuildConfig.FLAVOR == "xposed") true return sharedPreferences.getBoolean("bypass_device_check", false)
else sharedPreferences.getBoolean("bypass_device_check", false)
} }

View File

@@ -236,4 +236,8 @@
<string name="yes">Yes</string> <string name="yes">Yes</string>
<string name="settings">Settings</string> <string name="settings">Settings</string>
<string name="requires_xposed">requires xposed</string> <string name="requires_xposed">requires xposed</string>
<string name="bypass_compatibility_check">Bypass compatibility check</string>
<string name="bypass_compatiblity_check_confirmation">Are you sure your device is supported natively/you have Xposed module enabled?</string>
<string name="not_supported">Not supported</string>
<string name="check_the_repository_for_more_info">Check the repository for more info.</string>
</resources> </resources>