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>
private
fun
showInvalidStateMessage
()
{
runOnUiThread
{
MagiskDialog
(
this
)
.
apply
Title
(
R
.
string
.
unsupport_nonroot_stub_title
)
.
apply
Message
(
R
.
string
.
unsupport_nonroot_stub_msg
)
.
apply
Button
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
t
itleRes
=
R
.
string
.
install
MagiskDialog
(
this
)
.
apply
{
set
Title
(
R
.
string
.
unsupport_nonroot_stub_title
)
set
Message
(
R
.
string
.
unsupport_nonroot_stub_msg
)
set
Button
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
t
ext
=
R
.
string
.
install
onClick
{
HideAPK
.
restore
(
this
@BaseMainActivity
)
}
}
.
cancellable
(
false
)
.
reveal
()
setCancelable
(
false
)
show
()
}
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/events/dialog/DarkThemeDialog.kt
View file @
47545b45
package
com.topjohnwu.magisk.events.dialog
import
android.app.Activity
import
android.content.Context
import
android.content.ContextWrapper
import
androidx.appcompat.app.AppCompatDelegate
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.core.Config
...
...
@@ -11,31 +9,25 @@ import com.topjohnwu.magisk.view.MagiskDialog
class
DarkThemeDialog
:
DialogEvent
()
{
override
fun
build
(
dialog
:
MagiskDialog
)
{
val
activity
=
dialog
.
context
.
unwrap
()
dialog
.
applyTitle
(
R
.
string
.
settings_dark_mode_title
)
.
applyMessage
(
R
.
string
.
settings_dark_mode_message
)
.
applyButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
titleRes
=
R
.
string
.
settings_dark_mode_light
val
activity
=
dialog
.
ownerActivity
!!
dialog
.
apply
{
setTitle
(
R
.
string
.
settings_dark_mode_title
)
setMessage
(
R
.
string
.
settings_dark_mode_message
)
setButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
text
=
R
.
string
.
settings_dark_mode_light
icon
=
R
.
drawable
.
ic_day
onClick
{
selectTheme
(
AppCompatDelegate
.
MODE_NIGHT_NO
,
activity
)
}
}
.
apply
Button
(
MagiskDialog
.
ButtonType
.
NEUTRAL
)
{
t
itleRes
=
R
.
string
.
settings_dark_mode_system
set
Button
(
MagiskDialog
.
ButtonType
.
NEUTRAL
)
{
t
ext
=
R
.
string
.
settings_dark_mode_system
icon
=
R
.
drawable
.
ic_day_night
onClick
{
selectTheme
(
AppCompatDelegate
.
MODE_NIGHT_FOLLOW_SYSTEM
,
activity
)
}
}
.
apply
Button
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
t
itleRes
=
R
.
string
.
settings_dark_mode_dark
set
Button
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
t
ext
=
R
.
string
.
settings_dark_mode_dark
icon
=
R
.
drawable
.
ic_night
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
abstract
class
DialogEvent
:
ViewEvent
(),
ActivityExecutor
{
protected
lateinit
var
dialog
:
MagiskDialog
override
fun
invoke
(
activity
:
BaseUIActivity
<
*
,
*
>)
{
dialog
=
MagiskDialog
(
activity
)
MagiskDialog
(
activity
)
.
apply
{
setOwnerActivity
(
activity
)
}
.
apply
(
this
::
build
).
reveal
()
.
apply
(
this
::
build
).
show
()
}
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
class
EnvFixDialog
(
private
val
vm
:
HomeViewModel
)
:
DialogEvent
()
{
override
fun
build
(
dialog
:
MagiskDialog
)
{
dialog
.
applyTitle
(
R
.
string
.
env_fix_title
)
.
applyMessage
(
R
.
string
.
env_fix_msg
)
.
applyButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
titleRes
=
android
.
R
.
string
.
ok
preventDismiss
=
true
dialog
.
apply
{
setTitle
(
R
.
string
.
env_fix_title
)
setMessage
(
R
.
string
.
env_fix_msg
)
setButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
text
=
android
.
R
.
string
.
ok
doNotDismiss
=
true
onClick
{
dialog
.
applyTitle
(
R
.
string
.
setup_title
)
.
applyMessage
(
R
.
string
.
setup_msg
)
.
resetButtons
()
.
cancellable
(
false
)
dialog
.
apply
{
setTitle
(
R
.
string
.
setup_title
)
setMessage
(
R
.
string
.
setup_msg
)
resetButtons
()
setCancelable
(
false
)
}
(
dialog
.
ownerActivity
as
BaseActivity
).
lifecycleScope
.
launch
{
MagiskInstaller
.
FixEnv
{
dialog
.
dismiss
()
...
...
@@ -30,14 +33,15 @@ class EnvFixDialog(private val vm: HomeViewModel) : DialogEvent() {
}
}
}
.
apply
Button
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
t
itleRes
=
android
.
R
.
string
.
cancel
set
Button
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
t
ext
=
android
.
R
.
string
.
cancel
}
}
if
(
Info
.
env
.
versionCode
!=
BuildConfig
.
VERSION_CODE
||
Info
.
env
.
versionString
!=
BuildConfig
.
VERSION_NAME
)
{
dialog
.
apply
Button
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
t
itleRes
=
android
.
R
.
string
.
ok
dialog
.
set
Button
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
t
ext
=
android
.
R
.
string
.
ok
onClick
{
vm
.
onMagiskPressed
()
dialog
.
dismiss
()
...
...
app/src/main/java/com/topjohnwu/magisk/events/dialog/ManagerInstallDialog.kt
View file @
47545b45
...
...
@@ -25,14 +25,14 @@ class ManagerInstallDialog : MarkDownDialog() {
override
fun
build
(
dialog
:
MagiskDialog
)
{
super
.
build
(
dialog
)
with
(
dialog
)
{
dialog
.
apply
{
setCancelable
(
true
)
apply
Button
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
t
itleRes
=
R
.
string
.
install
set
Button
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
t
ext
=
R
.
string
.
install
onClick
{
DownloadService
.
start
(
context
,
Subject
.
Manager
())
}
}
apply
Button
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
t
itleRes
=
android
.
R
.
string
.
cancel
set
Button
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
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() {
override
fun
build
(
dialog
:
MagiskDialog
)
{
with
(
dialog
)
{
val
view
=
LayoutInflater
.
from
(
context
).
inflate
(
R
.
layout
.
markdown_window_md2
,
null
)
apply
View
(
view
)
set
View
(
view
)
(
ownerActivity
as
BaseActivity
).
lifecycleScope
.
launch
{
val
tv
=
view
.
findViewById
<
TextView
>(
R
.
id
.
md_txt
)
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
class
ModuleInstallDialog
(
private
val
item
:
OnlineModule
)
:
DialogEvent
()
{
override
fun
build
(
dialog
:
MagiskDialog
)
{
with
(
dialog
)
{
dialog
.
apply
{
fun
download
(
install
:
Boolean
)
{
val
action
=
if
(
install
)
Action
.
Flash
else
Action
.
Download
...
...
@@ -19,24 +19,22 @@ class ModuleInstallDialog(private val item: OnlineModule) : DialogEvent() {
DownloadService
.
start
(
context
,
subject
)
}
apply
Title
(
context
.
getString
(
R
.
string
.
repo_install_title
,
item
.
name
))
.
apply
Message
(
context
.
getString
(
R
.
string
.
repo_install_msg
,
item
.
downloadFilename
))
.
cancel
lable
(
true
)
.
apply
Button
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
titleRes
=
R
.
string
.
download
icon
=
R
.
drawable
.
ic_download_md2
onClick
{
download
(
false
)
}
}
set
Title
(
context
.
getString
(
R
.
string
.
repo_install_title
,
item
.
name
))
set
Message
(
context
.
getString
(
R
.
string
.
repo_install_msg
,
item
.
downloadFilename
))
setCance
lable
(
true
)
set
Button
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
text
=
R
.
string
.
download
icon
=
R
.
drawable
.
ic_download_md2
onClick
{
download
(
false
)
}
}
if
(
Info
.
env
.
isActive
)
{
apply
Button
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
t
itleRes
=
R
.
string
.
install
set
Button
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
t
ext
=
R
.
string
.
install
icon
=
R
.
drawable
.
ic_install
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
class
SecondSlotWarningDialog
:
DialogEvent
()
{
override
fun
build
(
dialog
:
MagiskDialog
)
{
dialog
.
applyTitle
(
android
.
R
.
string
.
dialog_alert_title
)
.
applyMessage
(
R
.
string
.
install_inactive_slot_msg
)
.
applyButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
titleRes
=
android
.
R
.
string
.
ok
dialog
.
apply
{
setTitle
(
android
.
R
.
string
.
dialog_alert_title
)
setMessage
(
R
.
string
.
install_inactive_slot_msg
)
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(
private
val
callbacks
=
Builder
().
apply
(
builder
)
override
fun
build
(
dialog
:
MagiskDialog
)
{
dialog
.
applyTitle
(
R
.
string
.
su_revoke_title
)
.
applyMessage
(
R
.
string
.
su_revoke_msg
,
callbacks
.
appName
)
.
applyButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
titleRes
=
android
.
R
.
string
.
ok
dialog
.
apply
{
setTitle
(
R
.
string
.
su_revoke_title
)
setMessage
(
R
.
string
.
su_revoke_msg
,
callbacks
.
appName
)
setButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
text
=
android
.
R
.
string
.
ok
onClick
{
callbacks
.
listenerOnSuccess
()
}
}
.
apply
Button
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
t
itleRes
=
android
.
R
.
string
.
cancel
set
Button
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
t
ext
=
android
.
R
.
string
.
cancel
}
}
}
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
import
android.app.ProgressDialog
import
android.content.Context
import
android.widget.Toast
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.arch.BaseUIActivity
...
...
@@ -12,22 +13,24 @@ import com.topjohnwu.superuser.Shell
class
UninstallDialog
:
DialogEvent
()
{
override
fun
build
(
dialog
:
MagiskDialog
)
{
dialog
.
applyTitle
(
R
.
string
.
uninstall_magisk_title
)
.
applyMessage
(
R
.
string
.
uninstall_magisk_msg
)
.
applyButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
titleRes
=
R
.
string
.
restore_img
onClick
{
restore
()
}
dialog
.
apply
{
setTitle
(
R
.
string
.
uninstall_magisk_title
)
setMessage
(
R
.
string
.
uninstall_magisk_msg
)
setButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
text
=
R
.
string
.
restore_img
onClick
{
restore
(
dialog
.
context
)
}
}
.
apply
Button
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
t
itleRes
=
R
.
string
.
complete_uninstall
onClick
{
completeUninstall
()
}
set
Button
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
t
ext
=
R
.
string
.
complete_uninstall
onClick
{
completeUninstall
(
dialog
)
}
}
}
}
@Suppress
(
"DEPRECATION"
)
private
fun
restore
()
{
val
dialog
=
ProgressDialog
(
dialog
.
context
).
apply
{
setMessage
(
dialog
.
context
.
getString
(
R
.
string
.
restore_img_msg
))
private
fun
restore
(
context
:
Context
)
{
val
dialog
=
ProgressDialog
(
context
).
apply
{
setMessage
(
context
.
getString
(
R
.
string
.
restore_img_msg
))
show
()
}
...
...
@@ -41,9 +44,9 @@ class UninstallDialog : DialogEvent() {
}
}
private
fun
completeUninstall
()
{
(
dialog
.
ownerActivity
as
?
BaseUIActivity
<*,
*>)
?
.
navigation
?.
navigate
(
FlashFragment
.
uninstall
())
private
fun
completeUninstall
(
dialog
:
MagiskDialog
)
{
(
dialog
.
ownerActivity
as
BaseUIActivity
<*,
*>)
.
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>() {
private
fun
showUnsupportedMessage
()
{
if
(
Info
.
env
.
isUnsupported
)
{
MagiskDialog
(
this
)
.
apply
Title
(
R
.
string
.
unsupport_magisk_title
)
.
apply
Message
(
R
.
string
.
unsupport_magisk_msg
,
Const
.
Version
.
MIN_VERSION
)
.
applyButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
titleRes
=
android
.
R
.
string
.
ok
}
.
cancel
lable
(
false
)
.
reveal
()
MagiskDialog
(
this
)
.
apply
{
set
Title
(
R
.
string
.
unsupport_magisk_title
)
set
Message
(
R
.
string
.
unsupport_magisk_msg
,
Const
.
Version
.
MIN_VERSION
)
setButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
text
=
android
.
R
.
string
.
ok
}
setCance
lable
(
false
)
}.
show
()
}
if
(!
Info
.
isEmulator
&&
Info
.
env
.
isActive
&&
System
.
getenv
(
"PATH"
)
?.
split
(
':'
)
?.
filterNot
{
File
(
"$it/magisk"
).
exists
()
}
?.
any
{
File
(
"$it/su"
).
exists
()
}
==
true
)
{
MagiskDialog
(
this
)
.
apply
Title
(
R
.
string
.
unsupport_general_title
)
.
apply
Message
(
R
.
string
.
unsupport_other_su_msg
)
.
applyButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
titleRes
=
android
.
R
.
string
.
ok
}
.
cancel
lable
(
false
)
.
reveal
()
MagiskDialog
(
this
)
.
apply
{
set
Title
(
R
.
string
.
unsupport_general_title
)
set
Message
(
R
.
string
.
unsupport_other_su_msg
)
setButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
text
=
android
.
R
.
string
.
ok
}
setCance
lable
(
false
)
}.
show
()
}
if
(
applicationInfo
.
flags
and
ApplicationInfo
.
FLAG_SYSTEM
!=
0
)
{
MagiskDialog
(
this
)
.
apply
Title
(
R
.
string
.
unsupport_general_title
)
.
apply
Message
(
R
.
string
.
unsupport_system_app_msg
)
.
applyButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
titleRes
=
android
.
R
.
string
.
ok
}
.
cancel
lable
(
false
)
.
reveal
()
MagiskDialog
(
this
)
.
apply
{
set
Title
(
R
.
string
.
unsupport_general_title
)
set
Message
(
R
.
string
.
unsupport_system_app_msg
)
setButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
text
=
android
.
R
.
string
.
ok
}
setCance
lable
(
false
)
}.
show
()
}
if
(
applicationInfo
.
flags
and
ApplicationInfo
.
FLAG_EXTERNAL_STORAGE
!=
0
)
{
MagiskDialog
(
this
)
.
apply
Title
(
R
.
string
.
unsupport_general_title
)
.
apply
Message
(
R
.
string
.
unsupport_external_storage_msg
)
.
applyButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
titleRes
=
android
.
R
.
string
.
ok
}
.
cancel
lable
(
false
)
.
reveal
()
MagiskDialog
(
this
)
.
apply
{
set
Title
(
R
.
string
.
unsupport_general_title
)
set
Message
(
R
.
string
.
unsupport_external_storage_msg
)
setButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
text
=
android
.
R
.
string
.
ok
}
setCance
lable
(
false
)
}.
show
()
}
}
...
...
@@ -190,18 +190,20 @@ class MainActivity : BaseMainActivity<MainViewModel, ActivityMainMd2Binding>() {
ShortcutManagerCompat
.
isRequestPinShortcutSupported
(
this
))
{
// Ask and show dialog
Config
.
askedHome
=
true
MagiskDialog
(
this
)
.
applyTitle
(
R
.
string
.
add_shortcut_title
)
.
applyMessage
(
R
.
string
.
add_shortcut_msg
)
.
applyButton
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
titleRes
=
android
.
R
.
string
.
cancel
}.
applyButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
titleRes
=
android
.
R
.
string
.
ok
MagiskDialog
(
this
).
apply
{
setTitle
(
R
.
string
.
add_shortcut_title
)
setMessage
(
R
.
string
.
add_shortcut_msg
)
setButton
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
text
=
android
.
R
.
string
.
cancel
}
setButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
text
=
android
.
R
.
string
.
ok
onClick
{
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() {
protected
abstract
val
inputResult
:
String
?
override
fun
onPressed
(
view
:
View
)
{
MagiskDialog
(
view
.
context
)
.
apply
Title
(
title
.
getText
(
view
.
resources
))
.
apply
View
(
getView
(
view
.
context
))
.
apply
Button
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
t
itleRes
=
android
.
R
.
string
.
ok
MagiskDialog
(
view
.
context
)
.
apply
{
set
Title
(
title
.
getText
(
view
.
resources
))
set
View
(
getView
(
view
.
context
))
set
Button
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
t
ext
=
android
.
R
.
string
.
ok
onClick
{
inputResult
?.
let
{
result
->
preven
tDismiss
=
false
doNo
tDismiss
=
false
value
=
result
it
.
dismiss
()
return
@onClick
}
preven
tDismiss
=
true
doNo
tDismiss
=
true
}
}
.
apply
Button
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
t
itleRes
=
android
.
R
.
string
.
cancel
set
Button
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
t
ext
=
android
.
R
.
string
.
cancel
}
.
reveal
()
}.
show
()
}
abstract
fun
getView
(
context
:
Context
):
View
...
...
@@ -151,15 +151,15 @@ sealed class BaseSettingsItem : ObservableRvItem() {
runCatching
{
getStringArray
(
id
)
}.
getOrDefault
(
emptyArray
())
override
fun
onPressed
(
view
:
View
)
{
MagiskDialog
(
view
.
context
)
.
apply
Title
(
title
.
getText
(
view
.
resources
))
.
apply
Button
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
t
itleRes
=
android
.
R
.
string
.
cancel
MagiskDialog
(
view
.
context
)
.
apply
{
set
Title
(
title
.
getText
(
view
.
resources
))
set
Button
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
t
ext
=
android
.
R
.
string
.
cancel
}
.
applyAdapter
(
entries
(
view
.
resources
))
{
setListItems
(
entries
(
view
.
resources
))
{
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 @@
app:layout_constraintEnd_toEndOf=
"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
android:id=
"@+id/dialog_base_button_2"
style=
"@style/WidgetFoundation.Button.Text"
gone=
"@{data.buttonNeutral.
icon == 0 && data.buttonNeutral.title.length == 0
}"
isEnabled=
"@{data.buttonNeutral.isEnabled
()
}"
gone=
"@{data.buttonNeutral.
gone
}"
isEnabled=
"@{data.buttonNeutral.isEnabled}"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:clickable=
"@{data.buttonNeutral.isEnabled
()
}"
android:focusable=
"@{data.buttonNeutral.isEnabled
()
}"
android:clickable=
"@{data.buttonNeutral.isEnabled}"
android:focusable=
"@{data.buttonNeutral.isEnabled}"
android:onClick=
"@{() -> data.buttonNeutral.clicked()}"
android:text=
"@{data.buttonNeutral.
titl
e}"
android:text=
"@{data.buttonNeutral.
messag
e}"
app:icon=
"@{data.buttonNeutral.icon}"
app:iconGravity=
"textStart"
tools:icon=
"@drawable/ic_bug_md2"
...
...
@@ -159,15 +143,15 @@
<Button
android:id=
"@+id/dialog_base_button_3"
style=
"@style/WidgetFoundation.Button.Text"
gone=
"@{data.buttonNegative.
icon == 0 && data.buttonNegative.title.length == 0
}"
isEnabled=
"@{data.buttonNegative.isEnabled
()
}"
gone=
"@{data.buttonNegative.
gone
}"
isEnabled=
"@{data.buttonNegative.isEnabled}"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:clickable=
"@{data.buttonNegative.isEnabled
()
}"
android:focusable=
"@{data.buttonNegative.isEnabled
()
}"
android:clickable=
"@{data.buttonNegative.isEnabled}"
android:focusable=
"@{data.buttonNegative.isEnabled}"
android:onClick=
"@{() -> data.buttonNegative.clicked()}"
android:text=
"@{data.buttonNegative.
titl
e}"
android:text=
"@{data.buttonNegative.
messag
e}"
app:icon=
"@{data.buttonNegative.icon}"
tools:icon=
"@drawable/ic_bug_md2"
tools:text=
"Button 1"
/>
...
...
@@ -175,15 +159,15 @@
<Button
android:id=
"@+id/dialog_base_button_1"
style=
"@style/WidgetFoundation.Button.Text"
gone=
"@{data.buttonPositive.
icon == 0 && data.buttonPositive.title.length == 0
}"
isEnabled=
"@{data.buttonPositive.isEnabled
()
}"
gone=
"@{data.buttonPositive.
gone
}"
isEnabled=
"@{data.buttonPositive.isEnabled}"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:clickable=
"@{data.buttonPositive.isEnabled
()
}"
android:focusable=
"@{data.buttonPositive.isEnabled
()
}"
android:clickable=
"@{data.buttonPositive.isEnabled}"
android:focusable=
"@{data.buttonPositive.isEnabled}"
android:onClick=
"@{() -> data.buttonPositive.clicked()}"
android:text=
"@{data.buttonPositive.
titl
e}"
android:text=
"@{data.buttonPositive.
messag
e}"
app:icon=
"@{data.buttonPositive.icon}"
app:iconGravity=
"textStart"
tools:icon=
"@drawable/ic_bug_md2"
...
...
app/src/main/res/layout/item_list_single_line.xml
View file @
47545b45
...
...
@@ -10,7 +10,7 @@
<variable
name=
"listener"
type=
"com.topjohnwu.magisk.view.MagiskDialog.
ActualOn
DialogClickListener"
/>
type=
"com.topjohnwu.magisk.view.MagiskDialog.DialogClickListener"
/>
</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