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
6b045ead
Commit
6b045ead
authored
Apr 14, 2019
by
Viktor De Pasquale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added env fix prompt
parent
14726482
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
11 deletions
+27
-11
ViewEvents.kt
...main/java/com/topjohnwu/magisk/model/events/ViewEvents.kt
+1
-0
HomeViewModel.kt
...c/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt
+20
-1
MagiskFragment.kt
.../main/java/com/topjohnwu/magisk/ui/home/MagiskFragment.kt
+6
-10
No files found.
app/src/main/java/com/topjohnwu/magisk/model/events/ViewEvents.kt
View file @
6b045ead
...
...
@@ -12,3 +12,4 @@ class ManagerChangelogEvent : ViewEvent()
class
MagiskChangelogEvent
:
ViewEvent
()
class
UninstallEvent
:
ViewEvent
()
class
EnvFixEvent
:
ViewEvent
()
app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt
View file @
6b045ead
...
...
@@ -10,6 +10,7 @@ import com.topjohnwu.magisk.ui.base.MagiskViewModel
import
com.topjohnwu.magisk.utils.Event
import
com.topjohnwu.magisk.utils.toggle
import
com.topjohnwu.net.Networking
import
com.topjohnwu.superuser.Shell
class
HomeViewModel
(
...
...
@@ -65,6 +66,7 @@ class HomeViewModel(
""
}
private
var
shownDialog
=
false
private
val
current
=
resources
.
getString
(
R
.
string
.
current_installed
)
private
val
latest
=
resources
.
getString
(
R
.
string
.
latest_version
)
...
...
@@ -73,7 +75,11 @@ class HomeViewModel(
refresh
()
}
override
fun
onEvent
(
event
:
Int
)
=
updateSelf
()
override
fun
onEvent
(
event
:
Int
)
{
updateSelf
()
ensureEnv
()
}
override
fun
getListeningEvents
():
IntArray
=
intArrayOf
(
Event
.
UPDATE_CHECK_DONE
)
fun
paypalPressed
()
=
OpenLinkEvent
(
Const
.
Url
.
PAYPAL_URL
).
publish
()
...
...
@@ -96,6 +102,7 @@ class HomeViewModel(
}
fun
refresh
()
{
shownDialog
=
false
state
=
State
.
LOADING
magiskState
.
value
=
MagiskState
.
LOADING
managerState
.
value
=
MagiskState
.
LOADING
...
...
@@ -139,6 +146,18 @@ class HomeViewModel(
.
let
{
latest
.
format
(
it
)
}
}
private
fun
ensureEnv
()
{
val
invalidStates
=
listOf
(
MagiskState
.
NOT_INSTALLED
,
MagiskState
.
NO_ROOT
,
MagiskState
.
LOADING
)
// Don't bother checking env when magisk is not installed, loading or already has been shown
if
(
invalidStates
.
any
{
it
==
magiskState
.
value
}
||
shownDialog
)
return
if
(!
Shell
.
su
(
"env_check"
).
exec
().
isSuccess
)
{
shownDialog
=
true
EnvFixEvent
().
publish
()
}
}
companion
object
{
private
const
val
version
=
"%s (%d)"
}
...
...
app/src/main/java/com/topjohnwu/magisk/ui/home/MagiskFragment.kt
View file @
6b045ead
...
...
@@ -7,6 +7,7 @@ import com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.model.events.*
import
com.topjohnwu.magisk.utils.Event
import
com.topjohnwu.magisk.view.MarkDownWindow
import
com.topjohnwu.magisk.view.dialogs.EnvFixDialog
import
com.topjohnwu.magisk.view.dialogs.ManagerInstallDialog
import
com.topjohnwu.magisk.view.dialogs.UninstallDialog
import
org.koin.androidx.viewmodel.ext.android.viewModel
...
...
@@ -61,6 +62,7 @@ class MagiskFragment : NewMagiskFragment<HomeViewModel, com.topjohnwu.magisk.dat
is
MagiskInstallEvent
->
installMagisk
()
is
UninstallEvent
->
uninstall
()
is
ManagerChangelogEvent
->
changelogManager
()
is
EnvFixEvent
->
fixEnv
()
}
}
...
...
@@ -75,17 +77,11 @@ class MagiskFragment : NewMagiskFragment<HomeViewModel, com.topjohnwu.magisk.dat
}
private
fun
installManager
()
=
ManagerInstallDialog
(
requireActivity
()).
show
()
private
fun
uninstall
()
=
UninstallDialog
(
requireActivity
()).
show
()
private
fun
fixEnv
()
=
EnvFixDialog
(
requireActivity
()).
show
()
private
fun
uninstall
()
{
UninstallDialog
(
requireActivity
()).
show
()
}
private
fun
changelogManager
()
{
MarkDownWindow
.
show
(
requireActivity
(),
null
,
resources
.
openRawResource
(
R
.
raw
.
changelog
)
)
}
private
fun
changelogManager
()
=
MarkDownWindow
.
show
(
requireActivity
(),
null
,
resources
.
openRawResource
(
R
.
raw
.
changelog
))
/*override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
...
...
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