Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
47545b45
Commit
47545b45
authored
Jan 21, 2022
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up MagiskDialog
parent
7c9908d9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
245 additions
and
325 deletions
+245
-325
BaseMainActivity.kt
...c/main/java/com/topjohnwu/magisk/arch/BaseMainActivity.kt
+8
-7
DarkThemeDialog.kt
...ava/com/topjohnwu/magisk/events/dialog/DarkThemeDialog.kt
+10
-18
DialogEvent.kt
...in/java/com/topjohnwu/magisk/events/dialog/DialogEvent.kt
+2
-4
EnvFixDialog.kt
...n/java/com/topjohnwu/magisk/events/dialog/EnvFixDialog.kt
+17
-13
ManagerInstallDialog.kt
...om/topjohnwu/magisk/events/dialog/ManagerInstallDialog.kt
+5
-5
MarkDownDialog.kt
...java/com/topjohnwu/magisk/events/dialog/MarkDownDialog.kt
+1
-1
ModuleInstallDialog.kt
...com/topjohnwu/magisk/events/dialog/ModuleInstallDialog.kt
+11
-13
SecondSlotWarningDialog.kt
...topjohnwu/magisk/events/dialog/SecondSlotWarningDialog.kt
+7
-5
SuperuserRevokeDialog.kt
...m/topjohnwu/magisk/events/dialog/SuperuserRevokeDialog.kt
+8
-6
UninstallDialog.kt
...ava/com/topjohnwu/magisk/events/dialog/UninstallDialog.kt
+17
-14
MainActivity.kt
app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt
+35
-33
BaseSettingsItem.kt
...java/com/topjohnwu/magisk/ui/settings/BaseSettingsItem.kt
+16
-16
MagiskDialog.kt
app/src/main/java/com/topjohnwu/magisk/view/MagiskDialog.kt
+92
-158
dialog_magisk_base.xml
app/src/main/res/layout/dialog_magisk_base.xml
+15
-31
item_list_single_line.xml
app/src/main/res/layout/item_list_single_line.xml
+1
-1
No files found.
app/src/main/java/com/topjohnwu/magisk/arch/BaseMainActivity.kt
View file @
47545b45
...
@@ -75,15 +75,16 @@ abstract class BaseMainActivity<VM : BaseViewModel, Binding : ViewDataBinding>
...
@@ -75,15 +75,16 @@ abstract class BaseMainActivity<VM : BaseViewModel, Binding : ViewDataBinding>
private
fun
showInvalidStateMessage
()
{
private
fun
showInvalidStateMessage
()
{
runOnUiThread
{
runOnUiThread
{
MagiskDialog
(
this
)
MagiskDialog
(
this
)
.
apply
{
.
apply
Title
(
R
.
string
.
unsupport_nonroot_stub_title
)
set
Title
(
R
.
string
.
unsupport_nonroot_stub_title
)
.
apply
Message
(
R
.
string
.
unsupport_nonroot_stub_msg
)
set
Message
(
R
.
string
.
unsupport_nonroot_stub_msg
)
.
apply
Button
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
set
Button
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
t
itleRes
=
R
.
string
.
install
t
ext
=
R
.
string
.
install
onClick
{
HideAPK
.
restore
(
this
@BaseMainActivity
)
}
onClick
{
HideAPK
.
restore
(
this
@BaseMainActivity
)
}
}
}
.
cancellable
(
false
)
setCancelable
(
false
)
.
reveal
()
show
()
}
}
}
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/events/dialog/DarkThemeDialog.kt
View file @
47545b45
package
com.topjohnwu.magisk.events.dialog
package
com.topjohnwu.magisk.events.dialog
import
android.app.Activity
import
android.app.Activity
import
android.content.Context
import
android.content.ContextWrapper
import
androidx.appcompat.app.AppCompatDelegate
import
androidx.appcompat.app.AppCompatDelegate
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.core.Config
import
com.topjohnwu.magisk.core.Config
...
@@ -11,31 +9,25 @@ import com.topjohnwu.magisk.view.MagiskDialog
...
@@ -11,31 +9,25 @@ import com.topjohnwu.magisk.view.MagiskDialog
class
DarkThemeDialog
:
DialogEvent
()
{
class
DarkThemeDialog
:
DialogEvent
()
{
override
fun
build
(
dialog
:
MagiskDialog
)
{
override
fun
build
(
dialog
:
MagiskDialog
)
{
val
activity
=
dialog
.
context
.
unwrap
()
val
activity
=
dialog
.
ownerActivity
!!
dialog
.
applyTitle
(
R
.
string
.
settings_dark_mode_title
)
dialog
.
apply
{
.
applyMessage
(
R
.
string
.
settings_dark_mode_message
)
setTitle
(
R
.
string
.
settings_dark_mode_title
)
.
applyButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
setMessage
(
R
.
string
.
settings_dark_mode_message
)
titleRes
=
R
.
string
.
settings_dark_mode_light
setButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
text
=
R
.
string
.
settings_dark_mode_light
icon
=
R
.
drawable
.
ic_day
icon
=
R
.
drawable
.
ic_day
onClick
{
selectTheme
(
AppCompatDelegate
.
MODE_NIGHT_NO
,
activity
)
}
onClick
{
selectTheme
(
AppCompatDelegate
.
MODE_NIGHT_NO
,
activity
)
}
}
}
.
apply
Button
(
MagiskDialog
.
ButtonType
.
NEUTRAL
)
{
set
Button
(
MagiskDialog
.
ButtonType
.
NEUTRAL
)
{
t
itleRes
=
R
.
string
.
settings_dark_mode_system
t
ext
=
R
.
string
.
settings_dark_mode_system
icon
=
R
.
drawable
.
ic_day_night
icon
=
R
.
drawable
.
ic_day_night
onClick
{
selectTheme
(
AppCompatDelegate
.
MODE_NIGHT_FOLLOW_SYSTEM
,
activity
)
}
onClick
{
selectTheme
(
AppCompatDelegate
.
MODE_NIGHT_FOLLOW_SYSTEM
,
activity
)
}
}
}
.
apply
Button
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
set
Button
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
t
itleRes
=
R
.
string
.
settings_dark_mode_dark
t
ext
=
R
.
string
.
settings_dark_mode_dark
icon
=
R
.
drawable
.
ic_night
icon
=
R
.
drawable
.
ic_night
onClick
{
selectTheme
(
AppCompatDelegate
.
MODE_NIGHT_YES
,
activity
)
}
onClick
{
selectTheme
(
AppCompatDelegate
.
MODE_NIGHT_YES
,
activity
)
}
}
}
}
private
fun
Context
.
unwrap
():
Activity
{
return
when
(
this
)
{
is
Activity
->
this
is
ContextWrapper
->
baseContext
.
unwrap
()
else
->
error
(
"Cannot happen"
)
}
}
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/events/dialog/DialogEvent.kt
View file @
47545b45
...
@@ -7,12 +7,10 @@ import com.topjohnwu.magisk.view.MagiskDialog
...
@@ -7,12 +7,10 @@ import com.topjohnwu.magisk.view.MagiskDialog
abstract
class
DialogEvent
:
ViewEvent
(),
ActivityExecutor
{
abstract
class
DialogEvent
:
ViewEvent
(),
ActivityExecutor
{
protected
lateinit
var
dialog
:
MagiskDialog
override
fun
invoke
(
activity
:
BaseUIActivity
<
*
,
*
>)
{
override
fun
invoke
(
activity
:
BaseUIActivity
<
*
,
*
>)
{
dialog
=
MagiskDialog
(
activity
)
MagiskDialog
(
activity
)
.
apply
{
setOwnerActivity
(
activity
)
}
.
apply
{
setOwnerActivity
(
activity
)
}
.
apply
(
this
::
build
).
reveal
()
.
apply
(
this
::
build
).
show
()
}
}
abstract
fun
build
(
dialog
:
MagiskDialog
)
abstract
fun
build
(
dialog
:
MagiskDialog
)
...
...
app/src/main/java/com/topjohnwu/magisk/events/dialog/EnvFixDialog.kt
View file @
47545b45
...
@@ -13,16 +13,19 @@ import kotlinx.coroutines.launch
...
@@ -13,16 +13,19 @@ import kotlinx.coroutines.launch
class
EnvFixDialog
(
private
val
vm
:
HomeViewModel
)
:
DialogEvent
()
{
class
EnvFixDialog
(
private
val
vm
:
HomeViewModel
)
:
DialogEvent
()
{
override
fun
build
(
dialog
:
MagiskDialog
)
{
override
fun
build
(
dialog
:
MagiskDialog
)
{
dialog
.
applyTitle
(
R
.
string
.
env_fix_title
)
dialog
.
apply
{
.
applyMessage
(
R
.
string
.
env_fix_msg
)
setTitle
(
R
.
string
.
env_fix_title
)
.
applyButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
setMessage
(
R
.
string
.
env_fix_msg
)
titleRes
=
android
.
R
.
string
.
ok
setButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
preventDismiss
=
true
text
=
android
.
R
.
string
.
ok
doNotDismiss
=
true
onClick
{
onClick
{
dialog
.
applyTitle
(
R
.
string
.
setup_title
)
dialog
.
apply
{
.
applyMessage
(
R
.
string
.
setup_msg
)
setTitle
(
R
.
string
.
setup_title
)
.
resetButtons
()
setMessage
(
R
.
string
.
setup_msg
)
.
cancellable
(
false
)
resetButtons
()
setCancelable
(
false
)
}
(
dialog
.
ownerActivity
as
BaseActivity
).
lifecycleScope
.
launch
{
(
dialog
.
ownerActivity
as
BaseActivity
).
lifecycleScope
.
launch
{
MagiskInstaller
.
FixEnv
{
MagiskInstaller
.
FixEnv
{
dialog
.
dismiss
()
dialog
.
dismiss
()
...
@@ -30,14 +33,15 @@ class EnvFixDialog(private val vm: HomeViewModel) : DialogEvent() {
...
@@ -30,14 +33,15 @@ class EnvFixDialog(private val vm: HomeViewModel) : DialogEvent() {
}
}
}
}
}
}
.
apply
Button
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
set
Button
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
t
itleRes
=
android
.
R
.
string
.
cancel
t
ext
=
android
.
R
.
string
.
cancel
}
}
}
if
(
Info
.
env
.
versionCode
!=
BuildConfig
.
VERSION_CODE
||
if
(
Info
.
env
.
versionCode
!=
BuildConfig
.
VERSION_CODE
||
Info
.
env
.
versionString
!=
BuildConfig
.
VERSION_NAME
)
{
Info
.
env
.
versionString
!=
BuildConfig
.
VERSION_NAME
)
{
dialog
.
apply
Button
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
dialog
.
set
Button
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
t
itleRes
=
android
.
R
.
string
.
ok
t
ext
=
android
.
R
.
string
.
ok
onClick
{
onClick
{
vm
.
onMagiskPressed
()
vm
.
onMagiskPressed
()
dialog
.
dismiss
()
dialog
.
dismiss
()
...
...
app/src/main/java/com/topjohnwu/magisk/events/dialog/ManagerInstallDialog.kt
View file @
47545b45
...
@@ -25,14 +25,14 @@ class ManagerInstallDialog : MarkDownDialog() {
...
@@ -25,14 +25,14 @@ class ManagerInstallDialog : MarkDownDialog() {
override
fun
build
(
dialog
:
MagiskDialog
)
{
override
fun
build
(
dialog
:
MagiskDialog
)
{
super
.
build
(
dialog
)
super
.
build
(
dialog
)
with
(
dialog
)
{
dialog
.
apply
{
setCancelable
(
true
)
setCancelable
(
true
)
apply
Button
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
set
Button
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
t
itleRes
=
R
.
string
.
install
t
ext
=
R
.
string
.
install
onClick
{
DownloadService
.
start
(
context
,
Subject
.
Manager
())
}
onClick
{
DownloadService
.
start
(
context
,
Subject
.
Manager
())
}
}
}
apply
Button
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
set
Button
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
t
itleRes
=
android
.
R
.
string
.
cancel
t
ext
=
android
.
R
.
string
.
cancel
}
}
}
}
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/events/dialog/MarkDownDialog.kt
View file @
47545b45
...
@@ -22,7 +22,7 @@ abstract class MarkDownDialog : DialogEvent() {
...
@@ -22,7 +22,7 @@ abstract class MarkDownDialog : DialogEvent() {
override
fun
build
(
dialog
:
MagiskDialog
)
{
override
fun
build
(
dialog
:
MagiskDialog
)
{
with
(
dialog
)
{
with
(
dialog
)
{
val
view
=
LayoutInflater
.
from
(
context
).
inflate
(
R
.
layout
.
markdown_window_md2
,
null
)
val
view
=
LayoutInflater
.
from
(
context
).
inflate
(
R
.
layout
.
markdown_window_md2
,
null
)
apply
View
(
view
)
set
View
(
view
)
(
ownerActivity
as
BaseActivity
).
lifecycleScope
.
launch
{
(
ownerActivity
as
BaseActivity
).
lifecycleScope
.
launch
{
val
tv
=
view
.
findViewById
<
TextView
>(
R
.
id
.
md_txt
)
val
tv
=
view
.
findViewById
<
TextView
>(
R
.
id
.
md_txt
)
withContext
(
Dispatchers
.
IO
)
{
withContext
(
Dispatchers
.
IO
)
{
...
...
app/src/main/java/com/topjohnwu/magisk/events/dialog/ModuleInstallDialog.kt
View file @
47545b45
...
@@ -11,7 +11,7 @@ import com.topjohnwu.magisk.view.MagiskDialog
...
@@ -11,7 +11,7 @@ import com.topjohnwu.magisk.view.MagiskDialog
class
ModuleInstallDialog
(
private
val
item
:
OnlineModule
)
:
DialogEvent
()
{
class
ModuleInstallDialog
(
private
val
item
:
OnlineModule
)
:
DialogEvent
()
{
override
fun
build
(
dialog
:
MagiskDialog
)
{
override
fun
build
(
dialog
:
MagiskDialog
)
{
with
(
dialog
)
{
dialog
.
apply
{
fun
download
(
install
:
Boolean
)
{
fun
download
(
install
:
Boolean
)
{
val
action
=
if
(
install
)
Action
.
Flash
else
Action
.
Download
val
action
=
if
(
install
)
Action
.
Flash
else
Action
.
Download
...
@@ -19,24 +19,22 @@ class ModuleInstallDialog(private val item: OnlineModule) : DialogEvent() {
...
@@ -19,24 +19,22 @@ class ModuleInstallDialog(private val item: OnlineModule) : DialogEvent() {
DownloadService
.
start
(
context
,
subject
)
DownloadService
.
start
(
context
,
subject
)
}
}
apply
Title
(
context
.
getString
(
R
.
string
.
repo_install_title
,
item
.
name
))
set
Title
(
context
.
getString
(
R
.
string
.
repo_install_title
,
item
.
name
))
.
apply
Message
(
context
.
getString
(
R
.
string
.
repo_install_msg
,
item
.
downloadFilename
))
set
Message
(
context
.
getString
(
R
.
string
.
repo_install_msg
,
item
.
downloadFilename
))
.
cancel
lable
(
true
)
setCance
lable
(
true
)
.
apply
Button
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
set
Button
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
titleRes
=
R
.
string
.
download
text
=
R
.
string
.
download
icon
=
R
.
drawable
.
ic_download_md2
icon
=
R
.
drawable
.
ic_download_md2
onClick
{
download
(
false
)
}
onClick
{
download
(
false
)
}
}
}
if
(
Info
.
env
.
isActive
)
{
if
(
Info
.
env
.
isActive
)
{
apply
Button
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
set
Button
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
t
itleRes
=
R
.
string
.
install
t
ext
=
R
.
string
.
install
icon
=
R
.
drawable
.
ic_install
icon
=
R
.
drawable
.
ic_install
onClick
{
download
(
true
)
}
onClick
{
download
(
true
)
}
}
}
}
}
reveal
()
}
}
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/events/dialog/SecondSlotWarningDialog.kt
View file @
47545b45
...
@@ -6,11 +6,13 @@ import com.topjohnwu.magisk.view.MagiskDialog
...
@@ -6,11 +6,13 @@ import com.topjohnwu.magisk.view.MagiskDialog
class
SecondSlotWarningDialog
:
DialogEvent
()
{
class
SecondSlotWarningDialog
:
DialogEvent
()
{
override
fun
build
(
dialog
:
MagiskDialog
)
{
override
fun
build
(
dialog
:
MagiskDialog
)
{
dialog
.
applyTitle
(
android
.
R
.
string
.
dialog_alert_title
)
dialog
.
apply
{
.
applyMessage
(
R
.
string
.
install_inactive_slot_msg
)
setTitle
(
android
.
R
.
string
.
dialog_alert_title
)
.
applyButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
setMessage
(
R
.
string
.
install_inactive_slot_msg
)
titleRes
=
android
.
R
.
string
.
ok
setButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
text
=
android
.
R
.
string
.
ok
}
}
.
cancellable
(
true
)
setCancelable
(
true
)
}
}
}
}
}
app/src/main/java/com/topjohnwu/magisk/events/dialog/SuperuserRevokeDialog.kt
View file @
47545b45
...
@@ -10,15 +10,17 @@ class SuperuserRevokeDialog(
...
@@ -10,15 +10,17 @@ class SuperuserRevokeDialog(
private
val
callbacks
=
Builder
().
apply
(
builder
)
private
val
callbacks
=
Builder
().
apply
(
builder
)
override
fun
build
(
dialog
:
MagiskDialog
)
{
override
fun
build
(
dialog
:
MagiskDialog
)
{
dialog
.
applyTitle
(
R
.
string
.
su_revoke_title
)
dialog
.
apply
{
.
applyMessage
(
R
.
string
.
su_revoke_msg
,
callbacks
.
appName
)
setTitle
(
R
.
string
.
su_revoke_title
)
.
applyButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
setMessage
(
R
.
string
.
su_revoke_msg
,
callbacks
.
appName
)
titleRes
=
android
.
R
.
string
.
ok
setButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
text
=
android
.
R
.
string
.
ok
onClick
{
callbacks
.
listenerOnSuccess
()
}
onClick
{
callbacks
.
listenerOnSuccess
()
}
}
}
.
apply
Button
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
set
Button
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
t
itleRes
=
android
.
R
.
string
.
cancel
t
ext
=
android
.
R
.
string
.
cancel
}
}
}
}
}
inner
class
Builder
internal
constructor
()
{
inner
class
Builder
internal
constructor
()
{
...
...
app/src/main/java/com/topjohnwu/magisk/events/dialog/UninstallDialog.kt
View file @
47545b45
package
com.topjohnwu.magisk.events.dialog
package
com.topjohnwu.magisk.events.dialog
import
android.app.ProgressDialog
import
android.app.ProgressDialog
import
android.content.Context
import
android.widget.Toast
import
android.widget.Toast
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.arch.BaseUIActivity
import
com.topjohnwu.magisk.arch.BaseUIActivity
...
@@ -12,22 +13,24 @@ import com.topjohnwu.superuser.Shell
...
@@ -12,22 +13,24 @@ import com.topjohnwu.superuser.Shell
class
UninstallDialog
:
DialogEvent
()
{
class
UninstallDialog
:
DialogEvent
()
{
override
fun
build
(
dialog
:
MagiskDialog
)
{
override
fun
build
(
dialog
:
MagiskDialog
)
{
dialog
.
applyTitle
(
R
.
string
.
uninstall_magisk_title
)
dialog
.
apply
{
.
applyMessage
(
R
.
string
.
uninstall_magisk_msg
)
setTitle
(
R
.
string
.
uninstall_magisk_title
)
.
applyButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
setMessage
(
R
.
string
.
uninstall_magisk_msg
)
titleRes
=
R
.
string
.
restore_img
setButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
onClick
{
restore
()
}
text
=
R
.
string
.
restore_img
onClick
{
restore
(
dialog
.
context
)
}
}
}
.
apply
Button
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
set
Button
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
t
itleRes
=
R
.
string
.
complete_uninstall
t
ext
=
R
.
string
.
complete_uninstall
onClick
{
completeUninstall
()
}
onClick
{
completeUninstall
(
dialog
)
}
}
}
}
}
}
@Suppress
(
"DEPRECATION"
)
@Suppress
(
"DEPRECATION"
)
private
fun
restore
()
{
private
fun
restore
(
context
:
Context
)
{
val
dialog
=
ProgressDialog
(
dialog
.
context
).
apply
{
val
dialog
=
ProgressDialog
(
context
).
apply
{
setMessage
(
dialog
.
context
.
getString
(
R
.
string
.
restore_img_msg
))
setMessage
(
context
.
getString
(
R
.
string
.
restore_img_msg
))
show
()
show
()
}
}
...
@@ -41,9 +44,9 @@ class UninstallDialog : DialogEvent() {
...
@@ -41,9 +44,9 @@ class UninstallDialog : DialogEvent() {
}
}
}
}
private
fun
completeUninstall
()
{
private
fun
completeUninstall
(
dialog
:
MagiskDialog
)
{
(
dialog
.
ownerActivity
as
?
BaseUIActivity
<*,
*>)
(
dialog
.
ownerActivity
as
BaseUIActivity
<*,
*>)
?
.
navigation
?.
navigate
(
FlashFragment
.
uninstall
())
.
navigation
?.
navigate
(
FlashFragment
.
uninstall
())
}
}
}
}
app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt
View file @
47545b45
...
@@ -146,42 +146,42 @@ class MainActivity : BaseMainActivity<MainViewModel, ActivityMainMd2Binding>() {
...
@@ -146,42 +146,42 @@ class MainActivity : BaseMainActivity<MainViewModel, ActivityMainMd2Binding>() {
private
fun
showUnsupportedMessage
()
{
private
fun
showUnsupportedMessage
()
{
if
(
Info
.
env
.
isUnsupported
)
{
if
(
Info
.
env
.
isUnsupported
)
{
MagiskDialog
(
this
)
MagiskDialog
(
this
)
.
apply
{
.
apply
Title
(
R
.
string
.
unsupport_magisk_title
)
set
Title
(
R
.
string
.
unsupport_magisk_title
)
.
apply
Message
(
R
.
string
.
unsupport_magisk_msg
,
Const
.
Version
.
MIN_VERSION
)
set
Message
(
R
.
string
.
unsupport_magisk_msg
,
Const
.
Version
.
MIN_VERSION
)
.
applyButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
titleRes
=
android
.
R
.
string
.
ok
}
setButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
text
=
android
.
R
.
string
.
ok
}
.
cancel
lable
(
false
)
setCance
lable
(
false
)
.
reveal
()
}.
show
()
}
}
if
(!
Info
.
isEmulator
&&
Info
.
env
.
isActive
&&
System
.
getenv
(
"PATH"
)
if
(!
Info
.
isEmulator
&&
Info
.
env
.
isActive
&&
System
.
getenv
(
"PATH"
)
?.
split
(
':'
)
?.
split
(
':'
)
?.
filterNot
{
File
(
"$it/magisk"
).
exists
()
}
?.
filterNot
{
File
(
"$it/magisk"
).
exists
()
}
?.
any
{
File
(
"$it/su"
).
exists
()
}
==
true
)
{
?.
any
{
File
(
"$it/su"
).
exists
()
}
==
true
)
{
MagiskDialog
(
this
)
MagiskDialog
(
this
)
.
apply
{
.
apply
Title
(
R
.
string
.
unsupport_general_title
)
set
Title
(
R
.
string
.
unsupport_general_title
)
.
apply
Message
(
R
.
string
.
unsupport_other_su_msg
)
set
Message
(
R
.
string
.
unsupport_other_su_msg
)
.
applyButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
titleRes
=
android
.
R
.
string
.
ok
}
setButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
text
=
android
.
R
.
string
.
ok
}
.
cancel
lable
(
false
)
setCance
lable
(
false
)
.
reveal
()
}.
show
()
}
}
if
(
applicationInfo
.
flags
and
ApplicationInfo
.
FLAG_SYSTEM
!=
0
)
{
if
(
applicationInfo
.
flags
and
ApplicationInfo
.
FLAG_SYSTEM
!=
0
)
{
MagiskDialog
(
this
)
MagiskDialog
(
this
)
.
apply
{
.
apply
Title
(
R
.
string
.
unsupport_general_title
)
set
Title
(
R
.
string
.
unsupport_general_title
)
.
apply
Message
(
R
.
string
.
unsupport_system_app_msg
)
set
Message
(
R
.
string
.
unsupport_system_app_msg
)
.
applyButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
titleRes
=
android
.
R
.
string
.
ok
}
setButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
text
=
android
.
R
.
string
.
ok
}
.
cancel
lable
(
false
)
setCance
lable
(
false
)
.
reveal
()
}.
show
()
}
}
if
(
applicationInfo
.
flags
and
ApplicationInfo
.
FLAG_EXTERNAL_STORAGE
!=
0
)
{
if
(
applicationInfo
.
flags
and
ApplicationInfo
.
FLAG_EXTERNAL_STORAGE
!=
0
)
{
MagiskDialog
(
this
)
MagiskDialog
(
this
)
.
apply
{
.
apply
Title
(
R
.
string
.
unsupport_general_title
)
set
Title
(
R
.
string
.
unsupport_general_title
)
.
apply
Message
(
R
.
string
.
unsupport_external_storage_msg
)
set
Message
(
R
.
string
.
unsupport_external_storage_msg
)
.
applyButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
titleRes
=
android
.
R
.
string
.
ok
}
setButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
text
=
android
.
R
.
string
.
ok
}
.
cancel
lable
(
false
)
setCance
lable
(
false
)
.
reveal
()
}.
show
()
}
}
}
}
...
@@ -190,18 +190,20 @@ class MainActivity : BaseMainActivity<MainViewModel, ActivityMainMd2Binding>() {
...
@@ -190,18 +190,20 @@ class MainActivity : BaseMainActivity<MainViewModel, ActivityMainMd2Binding>() {
ShortcutManagerCompat
.
isRequestPinShortcutSupported
(
this
))
{
ShortcutManagerCompat
.
isRequestPinShortcutSupported
(
this
))
{
// Ask and show dialog
// Ask and show dialog
Config
.
askedHome
=
true
Config
.
askedHome
=
true
MagiskDialog
(
this
)
MagiskDialog
(
this
).
apply
{
.
applyTitle
(
R
.
string
.
add_shortcut_title
)
setTitle
(
R
.
string
.
add_shortcut_title
)
.
applyMessage
(
R
.
string
.
add_shortcut_msg
)
setMessage
(
R
.
string
.
add_shortcut_msg
)
.
applyButton
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
setButton
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
titleRes
=
android
.
R
.
string
.
cancel
text
=
android
.
R
.
string
.
cancel
}.
applyButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
}
titleRes
=
android
.
R
.
string
.
ok
setButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
text
=
android
.
R
.
string
.
ok
onClick
{
onClick
{
Shortcuts
.
addHomeIcon
(
this
@MainActivity
)
Shortcuts
.
addHomeIcon
(
this
@MainActivity
)
}
}
}.
cancellable
(
true
)
}
.
reveal
()
setCancelable
(
true
)
}.
show
()
}
}
}
}
}
}
app/src/main/java/com/topjohnwu/magisk/ui/settings/BaseSettingsItem.kt
View file @
47545b45
...
@@ -110,25 +110,25 @@ sealed class BaseSettingsItem : ObservableRvItem() {
...
@@ -110,25 +110,25 @@ sealed class BaseSettingsItem : ObservableRvItem() {
protected
abstract
val
inputResult
:
String
?
protected
abstract
val
inputResult
:
String
?
override
fun
onPressed
(
view
:
View
)
{
override
fun
onPressed
(
view
:
View
)
{
MagiskDialog
(
view
.
context
)
MagiskDialog
(
view
.
context
)
.
apply
{
.
apply
Title
(
title
.
getText
(
view
.
resources
))
set
Title
(
title
.
getText
(
view
.
resources
))
.
apply
View
(
getView
(
view
.
context
))
set
View
(
getView
(
view
.
context
))
.
apply
Button
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
set
Button
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
t
itleRes
=
android
.
R
.
string
.
ok
t
ext
=
android
.
R
.
string
.
ok
onClick
{
onClick
{
inputResult
?.
let
{
result
->
inputResult
?.
let
{
result
->
preven
tDismiss
=
false
doNo
tDismiss
=
false
value
=
result
value
=
result
it
.
dismiss
()
it
.
dismiss
()
return
@onClick
return
@onClick
}
}
preven
tDismiss
=
true
doNo
tDismiss
=
true
}
}
}
}
.
apply
Button
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
set
Button
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
t
itleRes
=
android
.
R
.
string
.
cancel
t
ext
=
android
.
R
.
string
.
cancel
}
}
.
reveal
()
}.
show
()
}
}
abstract
fun
getView
(
context
:
Context
):
View
abstract
fun
getView
(
context
:
Context
):
View
...
@@ -151,15 +151,15 @@ sealed class BaseSettingsItem : ObservableRvItem() {
...
@@ -151,15 +151,15 @@ sealed class BaseSettingsItem : ObservableRvItem() {
runCatching
{
getStringArray
(
id
)
}.
getOrDefault
(
emptyArray
())
runCatching
{
getStringArray
(
id
)
}.
getOrDefault
(
emptyArray
())
override
fun
onPressed
(
view
:
View
)
{
override
fun
onPressed
(
view
:
View
)
{
MagiskDialog
(
view
.
context
)
MagiskDialog
(
view
.
context
)
.
apply
{
.
apply
Title
(
title
.
getText
(
view
.
resources
))
set
Title
(
title
.
getText
(
view
.
resources
))
.
apply
Button
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
set
Button
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
t
itleRes
=
android
.
R
.
string
.
cancel
t
ext
=
android
.
R
.
string
.
cancel
}
}
.
applyAdapter
(
entries
(
view
.
resources
))
{
setListItems
(
entries
(
view
.
resources
))
{
value
=
it
value
=
it
}
}
.
reveal
()
}.
show
()
}
}
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/view/MagiskDialog.kt
View file @
47545b45
This diff is collapsed.
Click to expand it.
app/src/main/res/layout/dialog_magisk_base.xml
View file @
47545b45
...
@@ -116,34 +116,18 @@
...
@@ -116,34 +116,18 @@
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
>
app:layout_constraintStart_toStartOf=
"parent"
>
<Button
android:id=
"@+id/dialog_base_button_4"
style=
"@style/WidgetFoundation.Button.Text"
gone=
"@{data.buttonIDGAF.icon == 0 && data.buttonIDGAF.title.length == 0}"
isEnabled=
"@{data.buttonIDGAF.isEnabled()}"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:clickable=
"@{data.buttonIDGAF.isEnabled()}"
android:focusable=
"@{data.buttonIDGAF.isEnabled()}"
android:onClick=
"@{() -> data.buttonIDGAF.clicked()}"
android:text=
"@{data.buttonIDGAF.title}"
app:icon=
"@{data.buttonIDGAF.icon}"
tools:icon=
"@drawable/ic_bug_md2"
tools:text=
"Button 1"
/>
<Button
<Button
android:id=
"@+id/dialog_base_button_2"
android:id=
"@+id/dialog_base_button_2"
style=
"@style/WidgetFoundation.Button.Text"
style=
"@style/WidgetFoundation.Button.Text"
gone=
"@{data.buttonNeutral.
icon == 0 && data.buttonNeutral.title.length == 0
}"
gone=
"@{data.buttonNeutral.
gone
}"
isEnabled=
"@{data.buttonNeutral.isEnabled
()
}"
isEnabled=
"@{data.buttonNeutral.isEnabled}"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_gravity=
"center_horizontal"
android:clickable=
"@{data.buttonNeutral.isEnabled
()
}"
android:clickable=
"@{data.buttonNeutral.isEnabled}"
android:focusable=
"@{data.buttonNeutral.isEnabled
()
}"
android:focusable=
"@{data.buttonNeutral.isEnabled}"
android:onClick=
"@{() -> data.buttonNeutral.clicked()}"
android:onClick=
"@{() -> data.buttonNeutral.clicked()}"
android:text=
"@{data.buttonNeutral.
titl
e}"
android:text=
"@{data.buttonNeutral.
messag
e}"
app:icon=
"@{data.buttonNeutral.icon}"
app:icon=
"@{data.buttonNeutral.icon}"
app:iconGravity=
"textStart"
app:iconGravity=
"textStart"
tools:icon=
"@drawable/ic_bug_md2"
tools:icon=
"@drawable/ic_bug_md2"
...
@@ -159,15 +143,15 @@
...
@@ -159,15 +143,15 @@
<Button
<Button
android:id=
"@+id/dialog_base_button_3"
android:id=
"@+id/dialog_base_button_3"
style=
"@style/WidgetFoundation.Button.Text"
style=
"@style/WidgetFoundation.Button.Text"
gone=
"@{data.buttonNegative.
icon == 0 && data.buttonNegative.title.length == 0
}"
gone=
"@{data.buttonNegative.
gone
}"
isEnabled=
"@{data.buttonNegative.isEnabled
()
}"
isEnabled=
"@{data.buttonNegative.isEnabled}"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_gravity=
"center_horizontal"
android:clickable=
"@{data.buttonNegative.isEnabled
()
}"
android:clickable=
"@{data.buttonNegative.isEnabled}"
android:focusable=
"@{data.buttonNegative.isEnabled
()
}"
android:focusable=
"@{data.buttonNegative.isEnabled}"
android:onClick=
"@{() -> data.buttonNegative.clicked()}"
android:onClick=
"@{() -> data.buttonNegative.clicked()}"
android:text=
"@{data.buttonNegative.
titl
e}"
android:text=
"@{data.buttonNegative.
messag
e}"
app:icon=
"@{data.buttonNegative.icon}"
app:icon=
"@{data.buttonNegative.icon}"
tools:icon=
"@drawable/ic_bug_md2"
tools:icon=
"@drawable/ic_bug_md2"
tools:text=
"Button 1"
/>
tools:text=
"Button 1"
/>
...
@@ -175,15 +159,15 @@
...
@@ -175,15 +159,15 @@
<Button
<Button
android:id=
"@+id/dialog_base_button_1"
android:id=
"@+id/dialog_base_button_1"
style=
"@style/WidgetFoundation.Button.Text"
style=
"@style/WidgetFoundation.Button.Text"
gone=
"@{data.buttonPositive.
icon == 0 && data.buttonPositive.title.length == 0
}"
gone=
"@{data.buttonPositive.
gone
}"
isEnabled=
"@{data.buttonPositive.isEnabled
()
}"
isEnabled=
"@{data.buttonPositive.isEnabled}"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_gravity=
"center_horizontal"
android:clickable=
"@{data.buttonPositive.isEnabled
()
}"
android:clickable=
"@{data.buttonPositive.isEnabled}"
android:focusable=
"@{data.buttonPositive.isEnabled
()
}"
android:focusable=
"@{data.buttonPositive.isEnabled}"
android:onClick=
"@{() -> data.buttonPositive.clicked()}"
android:onClick=
"@{() -> data.buttonPositive.clicked()}"
android:text=
"@{data.buttonPositive.
titl
e}"
android:text=
"@{data.buttonPositive.
messag
e}"
app:icon=
"@{data.buttonPositive.icon}"
app:icon=
"@{data.buttonPositive.icon}"
app:iconGravity=
"textStart"
app:iconGravity=
"textStart"
tools:icon=
"@drawable/ic_bug_md2"
tools:icon=
"@drawable/ic_bug_md2"
...
...
app/src/main/res/layout/item_list_single_line.xml
View file @
47545b45
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
<variable
<variable
name=
"listener"
name=
"listener"
type=
"com.topjohnwu.magisk.view.MagiskDialog.
ActualOn
DialogClickListener"
/>
type=
"com.topjohnwu.magisk.view.MagiskDialog.DialogClickListener"
/>
</data>
</data>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment