Skip to content

Commit

Permalink
Open Shizuku website if launching Shizuku fails for some reason
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharee committed Feb 3, 2024
1 parent 3e6cc19 commit e073a8b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import androidx.core.view.WindowCompat
import com.zacharee1.systemuituner.R
import com.zacharee1.systemuituner.data.SettingsType
import com.zacharee1.systemuituner.util.launchUrl
import com.zacharee1.systemuituner.util.openShizuku
import com.zacharee1.systemuituner.util.openShizukuWebsite
import com.zacharee1.systemuituner.util.shizukuServiceManager
import dev.zwander.composeintroslider.IntroSlider
import dev.zwander.composeintroslider.SimpleIntroPage
Expand Down Expand Up @@ -77,16 +79,13 @@ class ReadSettingFailActivity : ComponentActivity() {

if (shizukuServiceManager.isShizukuInstalled) {
OutlinedButton(onClick = {
startActivity(Intent(Intent.ACTION_MAIN).apply {
addCategory(Intent.CATEGORY_LAUNCHER)
`package` = "moe.shizuku.privileged.api"
})
openShizuku()
}) {
Text(text = stringResource(id = R.string.open_shizuku))
}
} else {
OutlinedButton(onClick = {
launchUrl("https://shizuku.rikka.app")
openShizukuWebsite()
}) {
Text(text = stringResource(id = R.string.download_shizuku))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import androidx.core.view.WindowCompat
import com.zacharee1.systemuituner.R
import com.zacharee1.systemuituner.data.SettingsType
import com.zacharee1.systemuituner.util.launchUrl
import com.zacharee1.systemuituner.util.openShizuku
import com.zacharee1.systemuituner.util.openShizukuWebsite
import com.zacharee1.systemuituner.util.shizukuServiceManager
import dev.zwander.composeintroslider.IntroSlider
import dev.zwander.composeintroslider.SimpleIntroPage
Expand Down Expand Up @@ -80,16 +82,13 @@ class WriteSettingFailActivity : ComponentActivity() {

if (shizukuServiceManager.isShizukuInstalled) {
OutlinedButton(onClick = {
startActivity(Intent(Intent.ACTION_MAIN).apply {
addCategory(Intent.CATEGORY_LAUNCHER)
`package` = "moe.shizuku.privileged.api"
})
openShizuku()
}) {
Text(text = stringResource(id = R.string.open_shizuku))
}
} else {
OutlinedButton(onClick = {
launchUrl("https://shizuku.rikka.app")
openShizukuWebsite()
}) {
Text(text = stringResource(id = R.string.download_shizuku))
}
Expand Down
20 changes: 20 additions & 0 deletions app/src/main/java/com/zacharee1/systemuituner/util/ShizukuUtils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.zacharee1.systemuituner.util

import android.content.ActivityNotFoundException
import android.content.Context
import android.content.Intent

fun Context.openShizuku() {
try {
startActivity(Intent(Intent.ACTION_MAIN).apply {
addCategory(Intent.CATEGORY_LAUNCHER)
`package` = "moe.shizuku.privileged.api"
})
} catch (e: ActivityNotFoundException) {
openShizukuWebsite()
}
}

fun Context.openShizukuWebsite() {
launchUrl("https://shizuku.rikka.app")
}

0 comments on commit e073a8b

Please sign in to comment.