diff --git a/app/src/main/java/dev/beefers/vendetta/manager/installer/step/installing/InstallStep.kt b/app/src/main/java/dev/beefers/vendetta/manager/installer/step/installing/InstallStep.kt index dc353de3..f552e7ca 100644 --- a/app/src/main/java/dev/beefers/vendetta/manager/installer/step/installing/InstallStep.kt +++ b/app/src/main/java/dev/beefers/vendetta/manager/installer/step/installing/InstallStep.kt @@ -7,6 +7,7 @@ import dev.beefers.vendetta.manager.domain.manager.PreferenceManager import dev.beefers.vendetta.manager.installer.Installer import dev.beefers.vendetta.manager.installer.session.SessionInstaller import dev.beefers.vendetta.manager.installer.shizuku.ShizukuInstaller +import dev.beefers.vendetta.manager.installer.shizuku.ShizukuPermissions import dev.beefers.vendetta.manager.installer.step.Step import dev.beefers.vendetta.manager.installer.step.StepGroup import dev.beefers.vendetta.manager.installer.step.StepRunner @@ -38,7 +39,14 @@ class InstallStep( ?.takeIf { it.isNotEmpty() } ?: throw Error("Missing APKs from LSPatch step; failure likely") - val installer: Installer = when (preferences.installMethod) { + val installMethod = if (preferences.installMethod == InstallMethod.SHIZUKU && !ShizukuPermissions.waitShizukuPermissions()) { + // Temporarily use DEFAULT if SHIZUKU permissions are not granted + InstallMethod.DEFAULT + } else { + preferences.installMethod + } + + val installer: Installer = when (installMethod) { InstallMethod.DEFAULT -> SessionInstaller(context) InstallMethod.SHIZUKU -> ShizukuInstaller(context) } diff --git a/app/src/main/java/dev/beefers/vendetta/manager/ui/activity/MainActivity.kt b/app/src/main/java/dev/beefers/vendetta/manager/ui/activity/MainActivity.kt index 7d98d57b..62641cdf 100644 --- a/app/src/main/java/dev/beefers/vendetta/manager/ui/activity/MainActivity.kt +++ b/app/src/main/java/dev/beefers/vendetta/manager/ui/activity/MainActivity.kt @@ -6,27 +6,17 @@ import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge -import androidx.compose.animation.ExperimentalAnimationApi import androidx.core.app.ActivityCompat import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen -import androidx.lifecycle.lifecycleScope import cafe.adriel.voyager.navigator.Navigator import cafe.adriel.voyager.transitions.SlideTransition -import dev.beefers.vendetta.manager.domain.manager.InstallMethod -import dev.beefers.vendetta.manager.domain.manager.PreferenceManager -import dev.beefers.vendetta.manager.installer.shizuku.ShizukuPermissions import dev.beefers.vendetta.manager.ui.screen.home.HomeScreen import dev.beefers.vendetta.manager.ui.screen.installer.InstallerScreen import dev.beefers.vendetta.manager.ui.theme.VendettaManagerTheme import dev.beefers.vendetta.manager.utils.DiscordVersion import dev.beefers.vendetta.manager.utils.Intents -import kotlinx.coroutines.launch -import org.koin.android.ext.android.inject class MainActivity : ComponentActivity() { - - private val preferences: PreferenceManager by inject() - override fun onCreate(savedInstanceState: Bundle?) { installSplashScreen() enableEdgeToEdge() @@ -41,14 +31,6 @@ class MainActivity : ComponentActivity() { ) } - if (preferences.installMethod == InstallMethod.SHIZUKU) { - lifecycleScope.launch { - if (!ShizukuPermissions.waitShizukuPermissions()) { - preferences.installMethod = InstallMethod.DEFAULT - } - } - } - val screen = if (intent.action == Intents.Actions.INSTALL && version != null) { InstallerScreen(DiscordVersion.fromVersionCode(version)!!) } else { @@ -63,5 +45,4 @@ class MainActivity : ComponentActivity() { } } } - } diff --git a/app/src/main/java/dev/beefers/vendetta/manager/ui/viewmodel/home/HomeViewModel.kt b/app/src/main/java/dev/beefers/vendetta/manager/ui/viewmodel/home/HomeViewModel.kt index c335a212..b7ee6eae 100644 --- a/app/src/main/java/dev/beefers/vendetta/manager/ui/viewmodel/home/HomeViewModel.kt +++ b/app/src/main/java/dev/beefers/vendetta/manager/ui/viewmodel/home/HomeViewModel.kt @@ -22,6 +22,7 @@ import dev.beefers.vendetta.manager.domain.repository.RestRepository import dev.beefers.vendetta.manager.installer.Installer import dev.beefers.vendetta.manager.installer.session.SessionInstaller import dev.beefers.vendetta.manager.installer.shizuku.ShizukuInstaller +import dev.beefers.vendetta.manager.installer.shizuku.ShizukuPermissions import dev.beefers.vendetta.manager.network.dto.Release import dev.beefers.vendetta.manager.network.utils.CommitsPagingSource import dev.beefers.vendetta.manager.network.utils.dataOrNull @@ -129,7 +130,14 @@ class HomeViewModel( downloadManager.downloadUpdate(update) isUpdating = false - val installer: Installer = when (prefs.installMethod) { + val installMethod = if (prefs.installMethod == InstallMethod.SHIZUKU && !ShizukuPermissions.waitShizukuPermissions()) { + // Temporarily use DEFAULT if SHIZUKU permissions are not granted + InstallMethod.DEFAULT + } else { + prefs.installMethod + } + + val installer: Installer = when (installMethod) { InstallMethod.DEFAULT -> SessionInstaller(context) InstallMethod.SHIZUKU -> ShizukuInstaller(context) }