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
12a9792c
Commit
12a9792c
authored
Jan 22, 2020
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove old install dialog
parent
c5e5b70e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
131 deletions
+0
-131
MagiskInstallDialog.kt
...pjohnwu/magisk/model/events/dialog/MagiskInstallDialog.kt
+0
-131
No files found.
app/src/main/java/com/topjohnwu/magisk/model/events/dialog/MagiskInstallDialog.kt
deleted
100644 → 0
View file @
c5e5b70e
package
com.topjohnwu.magisk.model.events.dialog
import
android.Manifest
import
android.net.Uri
import
android.view.LayoutInflater
import
android.widget.Toast
import
com.topjohnwu.magisk.core.Info
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.core.download.DownloadService
import
com.topjohnwu.magisk.databinding.IncludeInstallOptionsBinding
import
com.topjohnwu.magisk.extensions.hasPermissions
import
com.topjohnwu.magisk.extensions.res
import
com.topjohnwu.magisk.model.entity.internal.Configuration
import
com.topjohnwu.magisk.model.entity.internal.DownloadSubject
import
com.topjohnwu.magisk.model.events.OpenInappLinkEvent
import
com.topjohnwu.magisk.core.utils.Utils
import
com.topjohnwu.magisk.view.MagiskDialog
import
com.topjohnwu.magisk.view.MarkDownWindow
import
com.topjohnwu.superuser.Shell
import
com.topjohnwu.superuser.ShellUtils
class
MagiskInstallDialog
:
DialogEvent
()
{
override
fun
build
(
dialog
:
MagiskDialog
)
{
with
(
dialog
)
{
val
filename
=
"Magisk v%s (%d)"
.
format
(
Info
.
remote
.
magisk
.
version
,
Info
.
remote
.
magisk
.
versionCode
)
applyTitle
(
R
.
string
.
repo_install_title
.
res
(
R
.
string
.
magisk
.
res
()))
applyMessage
(
R
.
string
.
repo_install_msg
.
res
(
filename
))
setCancelable
(
true
)
applyButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
titleRes
=
R
.
string
.
install
preventDismiss
=
true
onClick
{
updateForInstallMethod
(
dialog
.
reset
())
}
}
if
(
Info
.
remote
.
magisk
.
note
.
isEmpty
())
return
applyButton
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
titleRes
=
R
.
string
.
release_notes
onClick
{
if
(
Info
.
remote
.
magisk
.
note
.
contains
(
"forum.xda-developers"
))
{
OpenInappLinkEvent
(
Info
.
remote
.
magisk
.
note
).
invoke
(
context
)
}
else
{
MarkDownWindow
.
show
(
context
,
null
,
Info
.
remote
.
magisk
.
note
)
}
}
}
}
}
private
fun
updateForInstallMethod
(
dialog
:
MagiskDialog
)
{
with
(
dialog
)
{
applyTitle
(
R
.
string
.
select_method
)
applyView
(
IncludeInstallOptionsBinding
.
inflate
(
LayoutInflater
.
from
(
dialog
.
context
)))
applyButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
titleRes
=
R
.
string
.
download_zip_only
onClick
{
preventDismiss
=
false
download
()
}
}
applyButton
(
MagiskDialog
.
ButtonType
.
NEUTRAL
)
{
isEnabled
=
false
titleRes
=
R
.
string
.
select_patch_file
// todo maybe leverage rxbus for this?
onClick
{
Utils
.
toast
(
"This is not currently possible"
,
Toast
.
LENGTH_LONG
)
}
}
if
(!
Shell
.
rootAccess
())
return
applyButton
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
titleRes
=
R
.
string
.
direct_install
onClick
{
flash
()
}
}
if
(!
isABDevice
())
return
applyButton
(
MagiskDialog
.
ButtonType
.
IDGAF
)
{
titleRes
=
R
.
string
.
install_inactive_slot
preventDismiss
=
true
onClick
{
inactiveSlotDialog
(
dialog
.
reset
())
}
}
}
}
private
fun
inactiveSlotDialog
(
dialog
:
MagiskDialog
)
{
dialog
.
applyTitle
(
R
.
string
.
warning
)
.
applyMessage
(
R
.
string
.
install_inactive_slot_msg
)
.
applyButton
(
MagiskDialog
.
ButtonType
.
POSITIVE
)
{
titleRes
=
R
.
string
.
yes
onClick
{
flash
(
Configuration
.
Flash
.
Secondary
)
}
}
.
applyButton
(
MagiskDialog
.
ButtonType
.
NEGATIVE
)
{
titleRes
=
android
.
R
.
string
.
no
}
}
// ---
private
fun
hasPermissions
()
=
dialog
.
context
.
hasPermissions
(
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
)
private
fun
patch
(
data
:
Uri
)
=
download
(
DownloadSubject
.
Magisk
(
Configuration
.
Patch
(
data
)))
private
fun
flash
(
type
:
Configuration
.
Flash
=
Configuration
.
Flash
.
Primary
)
=
download
(
DownloadSubject
.
Magisk
(
type
))
private
fun
download
(
type
:
DownloadSubject
.
Magisk
=
DownloadSubject
.
Magisk
(
Configuration
.
Download
)
)
{
if
(!
hasPermissions
())
{
Utils
.
toast
(
"Storage permissions are required for this action"
,
Toast
.
LENGTH_LONG
)
return
}
DownloadService
(
dialog
.
context
)
{
subject
=
type
}
}
// ---
private
fun
isABDevice
()
=
ShellUtils
.
fastCmd
(
"grep_prop ro.build.ab_update"
)
.
let
{
it
.
isNotEmpty
()
&&
it
.
toBoolean
()
}
}
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