diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index a2d7c21..0897082 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -4,15 +4,15 @@
diff --git a/.idea/misc.xml b/.idea/misc.xml
index a781e70..8978d23 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,7 +1,6 @@
-
-
+
diff --git a/app/build.gradle b/app/build.gradle
index d707a27..1e03b81 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -35,6 +35,7 @@ android {
}
buildFeatures {
compose true
+ aidl true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.4.0"
diff --git a/app/src/main/java/dev/bluehouse/enablevolte/HomeActivity.kt b/app/src/main/java/dev/bluehouse/enablevolte/HomeActivity.kt
index 68e890f..c0974f9 100644
--- a/app/src/main/java/dev/bluehouse/enablevolte/HomeActivity.kt
+++ b/app/src/main/java/dev/bluehouse/enablevolte/HomeActivity.kt
@@ -11,6 +11,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.filled.Home
+import androidx.compose.material.icons.filled.Refresh
import androidx.compose.material.icons.filled.Settings
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
@@ -93,6 +94,14 @@ fun PixelIMSApp() {
})
}
+ fun generateInitialNavBuilder(): (NavGraphBuilder.() -> Unit) {
+ return {
+ composable("home", "Home") {
+ Home(navController)
+ }
+ }
+ }
+
fun generateNavBuilder(): (NavGraphBuilder.() -> Unit) {
return {
composable("home", "Home") {
@@ -114,14 +123,16 @@ fun PixelIMSApp() {
}
}
- OnLifecycleEvent { _, event ->
- if (event == Lifecycle.Event.ON_CREATE) {
- try {
- if (checkShizukuPermission(0)) {
+ fun loadApplication() {
+ val shizukuStatus = checkShizukuPermission(0)
+ try {
+ when (shizukuStatus) {
+ ShizukuStatus.GRANTED -> {
Log.d(dev.bluehouse.enablevolte.pages.TAG, "Shizuku granted")
subscriptions = carrierModer.subscriptions
navBuilder = generateNavBuilder()
- } else {
+ }
+ ShizukuStatus.NOT_GRANTED -> {
Shizuku.addRequestPermissionResultListener { _, grantResult ->
if (grantResult == PackageManager.PERMISSION_GRANTED) {
Log.d(dev.bluehouse.enablevolte.pages.TAG, "Shizuku granted")
@@ -130,8 +141,18 @@ fun PixelIMSApp() {
}
}
}
- } catch (_: IllegalStateException) {
+ else -> {
+ subscriptions = listOf()
+ navBuilder = generateInitialNavBuilder()
+ }
}
+ } catch (_: IllegalStateException) {
+ }
+ }
+
+ OnLifecycleEvent { _, event ->
+ if (event == Lifecycle.Event.ON_CREATE) {
+ loadApplication()
}
}
Scaffold(
@@ -145,7 +166,17 @@ fun PixelIMSApp() {
IconButton(onClick = { navController.popBackStack() }, colors = IconButtonDefaults.filledIconButtonColors(contentColor = MaterialTheme.colorScheme.onPrimary)) {
Icon(
imageVector = Icons.Filled.ArrowBack,
- contentDescription = "Localized description",
+ contentDescription = "Go back",
+ )
+ }
+ }
+ },
+ actions = {
+ if (currentBackStackEntry?.destination?.route == "home") {
+ IconButton(onClick = { loadApplication() }, colors = IconButtonDefaults.filledIconButtonColors(contentColor = MaterialTheme.colorScheme.onPrimary)) {
+ Icon(
+ imageVector = Icons.Filled.Refresh,
+ contentDescription = "Refresh contents",
)
}
}
diff --git a/app/src/main/java/dev/bluehouse/enablevolte/Utils.kt b/app/src/main/java/dev/bluehouse/enablevolte/Utils.kt
index fcef3a5..cee7991 100644
--- a/app/src/main/java/dev/bluehouse/enablevolte/Utils.kt
+++ b/app/src/main/java/dev/bluehouse/enablevolte/Utils.kt
@@ -14,14 +14,21 @@ import com.github.kittinunf.fuel.json.responseJson
import com.github.kittinunf.result.Result
import rikka.shizuku.Shizuku
-fun checkShizukuPermission(code: Int): Boolean {
- return if (Shizuku.checkSelfPermission() == PackageManager.PERMISSION_GRANTED) {
- true
- } else if (Shizuku.shouldShowRequestPermissionRationale()) {
- false
+enum class ShizukuStatus {
+ GRANTED, NOT_GRANTED, STOPPED
+}
+fun checkShizukuPermission(code: Int): ShizukuStatus {
+ return if (Shizuku.getBinder() != null) {
+ if (Shizuku.checkSelfPermission() == PackageManager.PERMISSION_GRANTED) {
+ ShizukuStatus.GRANTED
+ } else {
+ if (!Shizuku.shouldShowRequestPermissionRationale()) {
+ Shizuku.requestPermission(0)
+ }
+ ShizukuStatus.NOT_GRANTED
+ }
} else {
- Shizuku.requestPermission(code)
- false
+ ShizukuStatus.STOPPED
}
}
diff --git a/app/src/main/java/dev/bluehouse/enablevolte/pages/Config.kt b/app/src/main/java/dev/bluehouse/enablevolte/pages/Config.kt
index 66d5a14..ce3ae1e 100644
--- a/app/src/main/java/dev/bluehouse/enablevolte/pages/Config.kt
+++ b/app/src/main/java/dev/bluehouse/enablevolte/pages/Config.kt
@@ -27,6 +27,7 @@ import dev.bluehouse.enablevolte.HeaderText
import dev.bluehouse.enablevolte.InfiniteLoadingDialog
import dev.bluehouse.enablevolte.KeyValueEditView
import dev.bluehouse.enablevolte.R
+import dev.bluehouse.enablevolte.ShizukuStatus
import dev.bluehouse.enablevolte.SubscriptionModer
import dev.bluehouse.enablevolte.UserAgentPropertyView
import dev.bluehouse.enablevolte.ValueType
@@ -106,7 +107,7 @@ fun Config(navController: NavController, subId: Int) {
}
LaunchedEffect(true) {
- if (checkShizukuPermission(0)) {
+ if (checkShizukuPermission(0) == ShizukuStatus.GRANTED) {
if (carrierModer.deviceSupportsIMS && subId >= 0) {
configurable = try {
withContext(Dispatchers.Default) {
diff --git a/app/src/main/java/dev/bluehouse/enablevolte/pages/Home.kt b/app/src/main/java/dev/bluehouse/enablevolte/pages/Home.kt
index 6e8d143..76e6231 100644
--- a/app/src/main/java/dev/bluehouse/enablevolte/pages/Home.kt
+++ b/app/src/main/java/dev/bluehouse/enablevolte/pages/Home.kt
@@ -27,6 +27,7 @@ import dev.bluehouse.enablevolte.CarrierModer
import dev.bluehouse.enablevolte.ClickablePropertyView
import dev.bluehouse.enablevolte.HeaderText
import dev.bluehouse.enablevolte.R
+import dev.bluehouse.enablevolte.ShizukuStatus
import dev.bluehouse.enablevolte.StringPropertyView
import dev.bluehouse.enablevolte.SubscriptionModer
import dev.bluehouse.enablevolte.checkShizukuPermission
@@ -62,19 +63,26 @@ fun Home(navController: NavController) {
}
LaunchedEffect(Unit) {
- shizukuEnabled = try {
- if (checkShizukuPermission(0)) {
- loadFlags()
- } else {
- Shizuku.addRequestPermissionResultListener { _, grantResult ->
- if (grantResult == PackageManager.PERMISSION_GRANTED) {
- loadFlags()
+ try {
+ when (checkShizukuPermission(0)) {
+ ShizukuStatus.GRANTED -> {
+ shizukuEnabled = true
+ loadFlags()
+ }
+ ShizukuStatus.NOT_GRANTED -> {
+ shizukuEnabled = true
+ Shizuku.addRequestPermissionResultListener { _, grantResult ->
+ if (grantResult == PackageManager.PERMISSION_GRANTED) {
+ loadFlags()
+ }
}
}
+ else -> {
+ shizukuEnabled = false
+ }
}
- true
} catch (e: IllegalStateException) {
- false
+ shizukuEnabled = false
}
getLatestAppVersion {
Log.d(TAG, "Fetched version $it")
diff --git a/build.gradle b/build.gradle
index 7d21a18..6c073cd 100644
--- a/build.gradle
+++ b/build.gradle
@@ -4,7 +4,7 @@ buildscript {
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
- id 'com.android.application' version '7.4.1' apply false
- id 'com.android.library' version '7.4.1' apply false
+ id 'com.android.application' version '8.2.2' apply false
+ id 'com.android.library' version '8.2.2' apply false
id 'org.jetbrains.kotlin.android' version '1.8.0' apply false
}
\ No newline at end of file
diff --git a/gradle.properties b/gradle.properties
index 3c5031e..a2e90d8 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -20,4 +20,6 @@ kotlin.code.style=official
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
-android.nonTransitiveRClass=true
\ No newline at end of file
+android.nonTransitiveRClass=true
+android.defaults.buildfeatures.buildconfig=true
+android.nonFinalResIds=false
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 514f487..6d8d3c0 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
#Mon Feb 06 01:14:51 KST 2023
distributionBase=GRADLE_USER_HOME
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME