From b032ddf29288dbc3e8ba1ccd26211e38229c7ba4 Mon Sep 17 00:00:00 2001 From: darken Date: Sun, 24 Sep 2023 21:42:27 +0200 Subject: [PATCH] Setup: Show Shizuku card even if Shizuku app is not detected This makes the behavior analog to the root setup card and also makes users that are not yet using Shizuku, aware of the option being possible. Closes #641 --- app/src/main/java/eu/darken/sdmse/setup/SetupViewModel.kt | 1 + .../eu/darken/sdmse/setup/shizuku/ShizukuSetupCardVH.kt | 3 +-- .../eu/darken/sdmse/setup/shizuku/ShizukuSetupModule.kt | 6 ++---- app/src/main/res/values/strings.xml | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/darken/sdmse/setup/SetupViewModel.kt b/app/src/main/java/eu/darken/sdmse/setup/SetupViewModel.kt index 25a718bf1..661d9c5f0 100644 --- a/app/src/main/java/eu/darken/sdmse/setup/SetupViewModel.kt +++ b/app/src/main/java/eu/darken/sdmse/setup/SetupViewModel.kt @@ -232,6 +232,7 @@ class SetupViewModel @Inject constructor( SAFSetupCardVH.Item::class, UsageStatsSetupCardVH.Item::class, AutomationSetupCardVH.Item::class, + ShizukuSetupCardVH.Item::class, RootSetupCardVH.Item::class, ) private val TAG = logTag("Setup", "ViewModel") diff --git a/app/src/main/java/eu/darken/sdmse/setup/shizuku/ShizukuSetupCardVH.kt b/app/src/main/java/eu/darken/sdmse/setup/shizuku/ShizukuSetupCardVH.kt index 88eda2361..fdbc5a80b 100644 --- a/app/src/main/java/eu/darken/sdmse/setup/shizuku/ShizukuSetupCardVH.kt +++ b/app/src/main/java/eu/darken/sdmse/setup/shizuku/ShizukuSetupCardVH.kt @@ -34,10 +34,9 @@ class ShizukuSetupCardVH(parent: ViewGroup) : item.onToggleUseShizuku(selection) } } - allowShizukuOptionsEnable.isEnabled = item.state.isInstalled shizukuState.apply { - isVisible = item.state.isInstalled && item.state.isEnabled == true + isVisible = item.state.isEnabled == true text = getString( if (item.state.ourService) R.string.setup_shizuku_state_ready_label else R.string.setup_shizuku_state_waiting_label diff --git a/app/src/main/java/eu/darken/sdmse/setup/shizuku/ShizukuSetupModule.kt b/app/src/main/java/eu/darken/sdmse/setup/shizuku/ShizukuSetupModule.kt index 9af7b6679..f442b5503 100644 --- a/app/src/main/java/eu/darken/sdmse/setup/shizuku/ShizukuSetupModule.kt +++ b/app/src/main/java/eu/darken/sdmse/setup/shizuku/ShizukuSetupModule.kt @@ -47,11 +47,10 @@ class ShizukuSetupModule @Inject constructor( val baseState = State( isEnabled = isEnabled, - isInstalled = shizukuManager.isInstalled(), isCompatible = shizukuManager.isCompatible(), ) - if (isEnabled != true || !baseState.isInstalled) return@combine flowOf(baseState) + if (isEnabled != true) return@combine flowOf(baseState) combine( shizukuManager.shizukuBinder.onStart { emit(null) }, @@ -100,14 +99,13 @@ class ShizukuSetupModule @Inject constructor( data class State( val isEnabled: Boolean?, - val isInstalled: Boolean, val isCompatible: Boolean = false, val basicService: Boolean = false, val ourService: Boolean = false, ) : SetupModule.State { override val isComplete: Boolean = - isEnabled == false || !isCompatible || !isInstalled || (ourService && isEnabled == true) + isEnabled == false || !isCompatible || (ourService && isEnabled == true) } @Module @InstallIn(SingletonComponent::class) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0d756d435..a8dc77a5f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -127,7 +127,7 @@ This setting has no effect if the Shizuku app is not set up on your device. Shizuku link is ready. Waiting for link with Shizuku. - Use Shizuku + Use Shizuku if available Don\'t use Shizuku You can find the setup screen again via the settings menu.