mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-12-31 02:00:13 +00:00
@@ -23,7 +23,8 @@ object Const {
|
||||
val USER_ID = Process.myUid() / 100000
|
||||
|
||||
object Version {
|
||||
const val MIN_SUPPORT = 18000
|
||||
const val MIN_VERSION = "v18.0"
|
||||
const val MIN_VERCODE = 18000
|
||||
const val CONNECT_MODE = 20100
|
||||
}
|
||||
|
||||
|
||||
@@ -43,12 +43,17 @@ object Info {
|
||||
}.getOrElse { Env() }
|
||||
|
||||
class Env(
|
||||
val magiskVersionCode: Int = -1,
|
||||
code: Int = -1,
|
||||
val magiskVersionString: String = "",
|
||||
hide: Boolean = false,
|
||||
var connectionMode: Int = -1
|
||||
) {
|
||||
val magiskHide get() = Config.magiskHide
|
||||
val magiskVersionCode = when (code) {
|
||||
in Int.MIN_VALUE..Const.Version.MIN_VERCODE -> -1
|
||||
else -> code
|
||||
}
|
||||
val unsupported = code > 0 && code < Const.Version.MIN_VERCODE
|
||||
|
||||
init {
|
||||
Config.magiskHide = hide
|
||||
|
||||
@@ -2,11 +2,13 @@ package com.topjohnwu.magisk.ui
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.view.GravityCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentTransaction
|
||||
import com.ncapdevi.fragnav.FragNavController
|
||||
import com.ncapdevi.fragnav.FragNavTransactionOptions
|
||||
import com.topjohnwu.magisk.Const
|
||||
import com.topjohnwu.magisk.Const.Key.OPEN_SECTION
|
||||
import com.topjohnwu.magisk.Info
|
||||
import com.topjohnwu.magisk.R
|
||||
@@ -66,6 +68,15 @@ open class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(), Na
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
if (Info.env.unsupported && !viewModel.shownUnsupportedDialog) {
|
||||
viewModel.shownUnsupportedDialog = true
|
||||
AlertDialog.Builder(this)
|
||||
.setTitle(R.string.unsupport_magisk_title)
|
||||
.setMessage(getString(R.string.unsupport_magisk_msg, Const.Version.MIN_VERSION))
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.show()
|
||||
}
|
||||
|
||||
navigationController.apply {
|
||||
rootFragmentListener = this@MainActivity
|
||||
transactionListener = this@MainActivity
|
||||
|
||||
@@ -8,6 +8,8 @@ import com.topjohnwu.magisk.model.navigation.Navigation
|
||||
|
||||
class MainViewModel : BaseViewModel() {
|
||||
|
||||
var shownUnsupportedDialog = false
|
||||
|
||||
fun navPressed() = Navigation.Main.OPEN_NAV.publish()
|
||||
|
||||
fun navigationItemPressed(item: MenuItem): Boolean {
|
||||
|
||||
@@ -3,8 +3,6 @@ package com.topjohnwu.magisk.ui
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.topjohnwu.magisk.*
|
||||
import com.topjohnwu.magisk.utils.Utils
|
||||
import com.topjohnwu.magisk.view.Notifications
|
||||
@@ -19,19 +17,7 @@ open class SplashActivity : Activity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
Shell.getShell {
|
||||
if (Info.env.magiskVersionCode > 0 && Info.env.magiskVersionCode < Const.Version.MIN_SUPPORT) {
|
||||
AlertDialog.Builder(this)
|
||||
.setTitle(R.string.unsupport_magisk_title)
|
||||
.setMessage(R.string.unsupport_magisk_message)
|
||||
.setNegativeButton(android.R.string.ok, null)
|
||||
.setOnDismissListener { finish() }
|
||||
.show()
|
||||
} else {
|
||||
initAndStart()
|
||||
}
|
||||
}
|
||||
Shell.getShell { initAndStart() }
|
||||
}
|
||||
|
||||
private fun initAndStart() {
|
||||
|
||||
Reference in New Issue
Block a user