mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-12-29 02:48:46 +00:00
Added redesign base
... also basic switching to redesign was added, haha
This commit is contained in:
7
app/src/main/java/a/i.java
Normal file
7
app/src/main/java/a/i.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package a;
|
||||
|
||||
import com.topjohnwu.magisk.redesign.MainActivity;
|
||||
|
||||
public class i extends MainActivity {
|
||||
/* stub */
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import com.topjohnwu.magisk.ui.MainActivity
|
||||
import com.topjohnwu.magisk.ui.SplashActivity
|
||||
import com.topjohnwu.magisk.ui.flash.FlashActivity
|
||||
import com.topjohnwu.magisk.ui.surequest.SuRequestActivity
|
||||
import com.topjohnwu.magisk.redesign.MainActivity as RedesignActivity
|
||||
|
||||
object ClassMap {
|
||||
private val map = mapOf(
|
||||
@@ -17,7 +18,9 @@ object ClassMap {
|
||||
UpdateCheckService::class.java to a.g::class.java,
|
||||
GeneralReceiver::class.java to a.h::class.java,
|
||||
DownloadService::class.java to a.j::class.java,
|
||||
SuRequestActivity::class.java to a.m::class.java
|
||||
SuRequestActivity::class.java to a.m::class.java,
|
||||
//redesign
|
||||
RedesignActivity::class.java to a.i::class.java
|
||||
)
|
||||
|
||||
operator fun <T : Class<*>>get(c: Class<*>): T {
|
||||
|
||||
@@ -48,6 +48,7 @@ object Config : PreferenceModel, DBConfig {
|
||||
const val REPO_ORDER = "repo_order"
|
||||
const val SHOW_SYSTEM_APP = "show_system"
|
||||
const val DOWNLOAD_PATH = "download_path"
|
||||
const val REDESIGN = "redesign"
|
||||
|
||||
// system state
|
||||
const val MAGISKHIDE = "magiskhide"
|
||||
@@ -108,6 +109,7 @@ object Config : PreferenceModel, DBConfig {
|
||||
var suNotification by preferenceStrInt(Key.SU_NOTIFICATION, Value.NOTIFICATION_TOAST)
|
||||
var updateChannel by preferenceStrInt(Key.UPDATE_CHANNEL, defaultChannel)
|
||||
|
||||
var redesign by preference(Key.REDESIGN, false)
|
||||
var darkTheme by preference(Key.DARK_THEME, true)
|
||||
var suReAuth by preference(Key.SU_REAUTH, false)
|
||||
var checkUpdate by preference(Key.CHECK_UPDATES, true)
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.topjohnwu.magisk.ui.superuser.SuperuserViewModel
|
||||
import com.topjohnwu.magisk.ui.surequest.SuRequestViewModel
|
||||
import org.koin.androidx.viewmodel.dsl.viewModel
|
||||
import org.koin.dsl.module
|
||||
import com.topjohnwu.magisk.redesign.MainViewModel as RedesignViewModel
|
||||
|
||||
|
||||
val viewModelModules = module {
|
||||
@@ -24,4 +25,8 @@ val viewModelModules = module {
|
||||
FlashViewModel(action, file, additional, get())
|
||||
}
|
||||
viewModel { SuRequestViewModel(get(), get(), get(SUTimeout), get()) }
|
||||
|
||||
// redesign
|
||||
|
||||
viewModel { RedesignViewModel() }
|
||||
}
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package com.topjohnwu.magisk.model.navigation
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.topjohnwu.magisk.ClassMap
|
||||
import com.topjohnwu.magisk.Config
|
||||
import com.topjohnwu.magisk.Const
|
||||
import com.topjohnwu.magisk.ui.MainActivity
|
||||
import com.topjohnwu.magisk.ui.hide.MagiskHideFragment
|
||||
import com.topjohnwu.magisk.ui.home.HomeFragment
|
||||
import com.topjohnwu.magisk.ui.log.LogFragment
|
||||
@@ -7,7 +13,7 @@ import com.topjohnwu.magisk.ui.module.ModulesFragment
|
||||
import com.topjohnwu.magisk.ui.module.ReposFragment
|
||||
import com.topjohnwu.magisk.ui.settings.SettingsFragment
|
||||
import com.topjohnwu.magisk.ui.superuser.SuperuserFragment
|
||||
|
||||
import com.topjohnwu.magisk.redesign.MainActivity as RedesignActivity
|
||||
|
||||
object Navigation {
|
||||
|
||||
@@ -50,6 +56,17 @@ object Navigation {
|
||||
else -> home()
|
||||
}
|
||||
|
||||
// redesign starts here
|
||||
|
||||
fun start(launchIntent: Intent, context: Context) {
|
||||
val destination = when {
|
||||
Config.redesign -> RedesignActivity::class.java
|
||||
else -> MainActivity::class.java
|
||||
}
|
||||
val intent = Intent(context, ClassMap[destination])
|
||||
intent.putExtra(Const.Key.OPEN_SECTION, launchIntent.getStringExtra(Const.Key.OPEN_SECTION))
|
||||
context.startActivity(intent)
|
||||
}
|
||||
|
||||
object Main {
|
||||
const val OPEN_NAV = 1
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.topjohnwu.magisk.redesign
|
||||
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.databinding.ActivityMainMd2Binding
|
||||
import com.topjohnwu.magisk.ui.base.MagiskActivity
|
||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||
|
||||
open class MainActivity : MagiskActivity<MainViewModel, ActivityMainMd2Binding>() {
|
||||
|
||||
override val layoutRes = R.layout.activity_main_md2
|
||||
override val viewModel by viewModel<MainViewModel>()
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.topjohnwu.magisk.redesign
|
||||
|
||||
import com.topjohnwu.magisk.ui.base.MagiskViewModel
|
||||
|
||||
class MainViewModel : MagiskViewModel()
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.topjohnwu.magisk.ui
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.topjohnwu.magisk.*
|
||||
import com.topjohnwu.magisk.model.navigation.Navigation
|
||||
import com.topjohnwu.magisk.utils.Utils
|
||||
import com.topjohnwu.magisk.view.Notifications
|
||||
import com.topjohnwu.magisk.view.Shortcuts
|
||||
@@ -56,10 +56,8 @@ open class SplashActivity : AppCompatActivity() {
|
||||
// Setup shortcuts
|
||||
Shortcuts.setup(this)
|
||||
|
||||
val intent = Intent(this, ClassMap[MainActivity::class.java])
|
||||
intent.putExtra(Const.Key.OPEN_SECTION, getIntent().getStringExtra(Const.Key.OPEN_SECTION))
|
||||
DONE = true
|
||||
startActivity(intent)
|
||||
Navigation.start(intent, this)
|
||||
finish()
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,8 @@ class SettingsFragment : BasePreferenceFragment() {
|
||||
preferenceManager.setStorageDeviceProtected()
|
||||
setPreferencesFromResource(R.xml.app_settings, rootKey)
|
||||
|
||||
findPreference<PreferenceCategory>("redesign_cat")?.isVisible = BuildConfig.DEBUG
|
||||
|
||||
updateChannel = findPreference(Config.Key.UPDATE_CHANNEL)!!
|
||||
rootConfig = findPreference(Config.Key.ROOT_ACCESS)!!
|
||||
autoRes = findPreference(Config.Key.SU_AUTO_RESPONSE)!!
|
||||
@@ -227,26 +229,26 @@ class SettingsFragment : BasePreferenceFragment() {
|
||||
private fun setLocalePreference(lp: ListPreference) {
|
||||
lp.isEnabled = false
|
||||
availableLocales.map {
|
||||
val names = mutableListOf<String>()
|
||||
val values = mutableListOf<String>()
|
||||
val names = mutableListOf<String>()
|
||||
val values = mutableListOf<String>()
|
||||
|
||||
names.add(
|
||||
LocaleManager.getString(defaultLocale, R.string.system_default)
|
||||
)
|
||||
values.add("")
|
||||
names.add(
|
||||
LocaleManager.getString(defaultLocale, R.string.system_default)
|
||||
)
|
||||
values.add("")
|
||||
|
||||
it.forEach { locale ->
|
||||
names.add(locale.getDisplayName(locale))
|
||||
values.add(locale.toLangTag())
|
||||
}
|
||||
|
||||
Pair(names.toTypedArray(), values.toTypedArray())
|
||||
}.subscribeK { (names, values) ->
|
||||
lp.isEnabled = true
|
||||
lp.entries = names
|
||||
lp.entryValues = values
|
||||
lp.summary = currentLocale.getDisplayName(currentLocale)
|
||||
it.forEach { locale ->
|
||||
names.add(locale.getDisplayName(locale))
|
||||
values.add(locale.toLangTag())
|
||||
}
|
||||
|
||||
Pair(names.toTypedArray(), values.toTypedArray())
|
||||
}.subscribeK { (names, values) ->
|
||||
lp.isEnabled = true
|
||||
lp.entries = names
|
||||
lp.entryValues = values
|
||||
lp.summary = currentLocale.getDisplayName(currentLocale)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setSummary(key: String) {
|
||||
|
||||
Reference in New Issue
Block a user