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
105b2fc1
Commit
105b2fc1
authored
Aug 19, 2020
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure SplashActivity is ran before MainActivity
parent
5ed4071f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
15 deletions
+26
-15
Hacks.kt
app/src/main/java/com/topjohnwu/magisk/core/Hacks.kt
+5
-0
SplashActivity.kt
...src/main/java/com/topjohnwu/magisk/core/SplashActivity.kt
+1
-13
MainActivity.kt
app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt
+20
-2
No files found.
app/src/main/java/com/topjohnwu/magisk/core/Hacks.kt
View file @
105b2fc1
...
...
@@ -3,6 +3,7 @@
package
com.topjohnwu.magisk.core
import
android.annotation.SuppressLint
import
android.app.Activity
import
android.app.job.JobInfo
import
android.app.job.JobScheduler
import
android.app.job.JobWorkItem
...
...
@@ -53,6 +54,10 @@ fun Class<*>.cmp(pkg: String): ComponentName {
return
ComponentName
(
pkg
,
Info
.
stub
?.
classToComponent
?.
get
(
name
)
?:
name
)
}
inline
fun
<
reified
T
>
Activity
.
redirect
()
=
Intent
(
intent
)
.
setComponent
(
T
::
class
.
java
.
cmp
(
packageName
))
.
setFlags
(
0
)
inline
fun
<
reified
T
>
Context
.
intent
()
=
Intent
().
setComponent
(
T
::
class
.
java
.
cmp
(
packageName
))
private
open
class
GlobalResContext
(
base
:
Context
)
:
ContextWrapper
(
base
)
{
...
...
app/src/main/java/com/topjohnwu/magisk/core/SplashActivity.kt
View file @
105b2fc1
...
...
@@ -2,8 +2,6 @@ package com.topjohnwu.magisk.core
import
android.app.Activity
import
android.content.Context
import
android.content.Intent
import
android.os.Build
import
android.os.Bundle
import
com.topjohnwu.magisk.BuildConfig
import
com.topjohnwu.magisk.R
...
...
@@ -61,21 +59,11 @@ open class SplashActivity : Activity() {
DONE
=
true
val
section
=
if
(
intent
.
action
==
ACTION_APPLICATION_PREFERENCES
)
Const
.
Nav
.
SETTINGS
else
intent
.
getStringExtra
(
Const
.
Key
.
OPEN_SECTION
)
intent
<
MainActivity
>()
.
putExtra
(
Const
.
Key
.
OPEN_SECTION
,
section
)
.
also
{
startActivity
(
it
)
}
redirect
<
MainActivity
>().
also
{
startActivity
(
it
)
}
finish
()
}
companion
object
{
private
val
ACTION_APPLICATION_PREFERENCES
get
()
=
if
(
Build
.
VERSION
.
SDK_INT
>=
24
)
Intent
.
ACTION_APPLICATION_PREFERENCES
else
"???"
var
DONE
=
false
}
}
app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.kt
View file @
105b2fc1
package
com.topjohnwu.magisk.ui
import
android.content.Intent
import
android.os.Build
import
android.os.Bundle
import
android.view.MenuItem
import
android.view.View
...
...
@@ -18,6 +20,8 @@ import com.topjohnwu.magisk.arch.BaseViewModel
import
com.topjohnwu.magisk.arch.ReselectionTarget
import
com.topjohnwu.magisk.core.Const
import
com.topjohnwu.magisk.core.Info
import
com.topjohnwu.magisk.core.SplashActivity
import
com.topjohnwu.magisk.core.redirect
import
com.topjohnwu.magisk.databinding.ActivityMainMd2Binding
import
com.topjohnwu.magisk.ktx.startAnimations
import
com.topjohnwu.magisk.ui.home.HomeFragmentDirections
...
...
@@ -49,6 +53,13 @@ open class MainActivity : BaseUIActivity<MainViewModel, ActivityMainMd2Binding>(
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
// Make sure Splash is always ran before us
if
(!
SplashActivity
.
DONE
)
{
redirect
<
SplashActivity
>().
also
{
startActivity
(
it
)
}
finish
()
return
}
if
(
Info
.
env
.
isUnsupported
)
{
MagiskDialog
(
this
)
.
applyTitle
(
R
.
string
.
unsupport_magisk_title
)
...
...
@@ -97,8 +108,9 @@ open class MainActivity : BaseUIActivity<MainViewModel, ActivityMainMd2Binding>(
binding
.
mainNavigation
.
viewTreeObserver
.
addOnGlobalLayoutListener
(
navObserver
)
if
(
intent
.
hasExtra
(
Const
.
Key
.
OPEN_SECTION
))
getScreen
(
intent
.
getStringExtra
(
Const
.
Key
.
OPEN_SECTION
))
?.
navigate
()
val
section
=
if
(
intent
.
action
==
ACTION_APPLICATION_PREFERENCES
)
Const
.
Nav
.
SETTINGS
else
intent
.
getStringExtra
(
Const
.
Key
.
OPEN_SECTION
)
getScreen
(
section
)
?.
navigate
()
if
(
savedInstanceState
!=
null
)
{
if
(!
isRootFragment
)
{
...
...
@@ -177,4 +189,10 @@ open class MainActivity : BaseUIActivity<MainViewModel, ActivityMainMd2Binding>(
}
}
companion
object
{
private
val
ACTION_APPLICATION_PREFERENCES
get
()
=
if
(
Build
.
VERSION
.
SDK_INT
>=
24
)
Intent
.
ACTION_APPLICATION_PREFERENCES
else
"???"
}
}
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