@@ -2,7 +2,8 @@ package io.github.samolego.canta.ui.dialog
22
33import android.content.Intent
44import android.content.pm.PackageManager
5- import android.net.Uri
5+ import android.os.Build
6+ import android.provider.Settings
67import androidx.compose.foundation.background
78import androidx.compose.foundation.layout.Arrangement
89import androidx.compose.foundation.layout.Column
@@ -32,6 +33,7 @@ import androidx.compose.ui.res.stringResource
3233import androidx.compose.ui.text.style.TextDecoration
3334import androidx.compose.ui.unit.dp
3435import androidx.compose.ui.window.DialogProperties
36+ import androidx.core.net.toUri
3537import io.github.samolego.canta.R
3638import io.github.samolego.canta.SHIZUKU_PACKAGE_NAME
3739import io.github.samolego.canta.ui.theme.GreenOk
@@ -41,6 +43,7 @@ import io.github.samolego.canta.util.shizuku.ShizukuStatus
4143
4244const val SHIZUKU_PLAY_STORE_URL =
4345 " https://play.google.com/store/apps/details?id=$SHIZUKU_PACKAGE_NAME "
46+ const val SHIZUKU_ANDROID_16_URL = " https://github.com/thedjchi/Shizuku/releases"
4447
4548@OptIn(ExperimentalMaterial3Api ::class )
4649@Composable
@@ -58,6 +61,16 @@ fun ShizukuRequirementDialog(
5861 }
5962 }
6063
64+ val isUsbDebuggingEnabled = try {
65+ Settings .Global .getInt(
66+ context.contentResolver,
67+ Settings .Global .ADB_ENABLED ,
68+ 0
69+ ) == 1
70+ } catch (e: Exception ) {
71+ false
72+ }
73+
6174
6275 BasicAlertDialog (
6376 modifier =
@@ -101,6 +114,19 @@ fun ShizukuRequirementDialog(
101114 modifier = Modifier .fillMaxWidth(),
102115 verticalArrangement = Arrangement .spacedBy(12 .dp)
103116 ) {
117+ // We want to also prompt
118+ // the user to enable USB debugging just
119+ // in case, if they'll need to rescue their device with
120+ // PC if sth goes wrong (#284)
121+ RequirementItem (
122+ text = stringResource(R .string.enable_usb_debugging),
123+ isCompleted = isUsbDebuggingEnabled,
124+ enabled = false ,
125+ onActionClick = {
126+ val intent = Intent (Settings .ACTION_APPLICATION_DEVELOPMENT_SETTINGS )
127+ context.startActivity(intent)
128+ }
129+ )
104130 // Install Shizuku
105131 RequirementItem (
106132 text = stringResource(R .string.install_shizuku),
@@ -110,7 +136,10 @@ fun ShizukuRequirementDialog(
110136 val intent =
111137 Intent (
112138 Intent .ACTION_VIEW ,
113- Uri .parse(SHIZUKU_PLAY_STORE_URL )
139+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .S )
140+ SHIZUKU_ANDROID_16_URL .toUri()
141+ else
142+ SHIZUKU_PLAY_STORE_URL .toUri()
114143 )
115144 context.startActivity(intent)
116145 }
0 commit comments