Skip to content

Commit

Permalink
Magisk WhiteList/KernelSU SU Permission Toast
Browse files Browse the repository at this point in the history
  • Loading branch information
hosizoraru committed May 23, 2023
1 parent 68a3095 commit f87c2b6
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 29 deletions.
100 changes: 71 additions & 29 deletions app/src/main/kotlin/star/sky/voyager/activity/pages/MenuPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,24 @@ class MenuPage : BasePage() {
dismiss()
}
setRButton(R.string.done) {
PACKAGE_NAME_HOOKED.forEach {
if (it != "android") Terminal.exec("killall $it")
try {
PACKAGE_NAME_HOOKED.forEach {
if (it != "android") Terminal.exec("killall $it")
}
Toast.makeText(
activity,
getString(R.string.finished),
Toast.LENGTH_SHORT
).show()
dismiss()
} catch (_: Throwable) {
Toast.makeText(
activity,
getString(R.string.su_permission),
Toast.LENGTH_LONG
).show()
dismiss()
}
Toast.makeText(
activity,
getString(R.string.finished),
Toast.LENGTH_SHORT
).show()
dismiss()
}
}.show()
}
Expand All @@ -70,13 +79,22 @@ class MenuPage : BasePage() {
dismiss()
}
setRButton(R.string.done) {
Terminal.exec("killall com.android.systemui")
Toast.makeText(
activity,
getString(R.string.finished),
Toast.LENGTH_SHORT
).show()
dismiss()
try {
Terminal.exec("killall com.android.systemui")
Toast.makeText(
activity,
getString(R.string.finished),
Toast.LENGTH_SHORT
).show()
dismiss()
} catch (_: Throwable) {
Toast.makeText(
activity,
getString(R.string.su_permission),
Toast.LENGTH_LONG
).show()
dismiss()
}
}
}.show()
}
Expand All @@ -92,34 +110,58 @@ class MenuPage : BasePage() {
dismiss()
}
setRButton(R.string.done) {
Terminal.exec("killall com.miui.home")
Toast.makeText(
activity,
getString(R.string.finished),
Toast.LENGTH_SHORT
).show()
dismiss()
try {
Terminal.exec("killall com.miui.home")
Toast.makeText(
activity,
getString(R.string.finished),
Toast.LENGTH_SHORT
).show()
dismiss()
} catch (_: Throwable) {
Toast.makeText(
activity,
getString(R.string.su_permission),
Toast.LENGTH_LONG
).show()
dismiss()
}
}
}.show()
}
)
Line()
TextSummaryWithArrow(TextSummaryV(
textId = R.string.backup, onClickListener = {
BackupUtils.backup(activity, activity.createDeviceProtectedStorageContext().getSharedPreferences("voyager_config", Context.MODE_WORLD_READABLE))
}))
TextSummaryWithArrow(
TextSummaryV(
textId = R.string.backup, onClickListener = {
BackupUtils.backup(
activity,
activity.createDeviceProtectedStorageContext()
.getSharedPreferences("voyager_config", Context.MODE_WORLD_READABLE)
)
})
)

TextSummaryWithArrow(TextSummaryV(textId = R.string.recovery, onClickListener = {
BackupUtils.recovery(activity, activity.createDeviceProtectedStorageContext().getSharedPreferences("voyager_config", Context.MODE_WORLD_READABLE))
BackupUtils.recovery(
activity,
activity.createDeviceProtectedStorageContext()
.getSharedPreferences("voyager_config", Context.MODE_WORLD_READABLE)
)
}))

TextWithArrow(TextV(textId = R.string.ResetModule, onClickListener = {
MIUIDialog(activity) {
setTitle(R.string.ResetModuleDialog)
setMessage(R.string.ResetModuleDialogTips)
setLButton(R.string.done) {
activity.getSharedPreferences("voyager_config", Activity.MODE_WORLD_READABLE).edit().clear().apply()
Toast.makeText(activity, activity.getString(R.string.ResetSuccess), Toast.LENGTH_LONG).show()
activity.getSharedPreferences("voyager_config", Activity.MODE_WORLD_READABLE)
.edit().clear().apply()
Toast.makeText(
activity,
activity.getString(R.string.ResetSuccess),
Toast.LENGTH_LONG
).show()
}
setRButton(R.string.cancel)
finally { dismiss() }
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<string name="restart_scope_miui_home_tips">确定重启系统桌面?</string>

<string name="main_switch">模块总开关</string>
<string name="su_permission">请给予本模块Su/Root权限</string>
<string name="about">关于</string>
<string name="about_module">关于模块</string>
<string name="about_module_summary">查看模块相关信息</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<string name="restart_scope_miui_home_tips">Are you sure to restart MiuiHome?</string>

<string name="main_switch">Module main switch</string>
<string name="su_permission">Please give this module Su/Root permission</string>
<string name="about">About</string>
<string name="about_module">About Module</string>
<string name="about_module_summary">View module related information</string>
Expand Down

0 comments on commit f87c2b6

Please sign in to comment.