Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Temporarily use DEFAULT if SHIZUKU permissions are not granted #14

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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 {
Expand All @@ -63,5 +45,4 @@ class MainActivity : ComponentActivity() {
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could there be some kind of toast saying the permissions weren't granted?

InstallMethod.DEFAULT
} else {
prefs.installMethod
}

val installer: Installer = when (installMethod) {
InstallMethod.DEFAULT -> SessionInstaller(context)
InstallMethod.SHIZUKU -> ShizukuInstaller(context)
}
Expand Down
Loading