From df0a5b59f8cc4df7345e09ea27620729f78ca2e2 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sun, 12 Jan 2020 15:00:49 +0800 Subject: [PATCH] Replace old design with redesign (p1) --- app/src/main/AndroidManifest.xml | 5 -- app/src/main/java/a/b.java | 7 --- app/src/main/java/a/{i.kt => b.kt} | 4 +- .../main/java/com/topjohnwu/magisk/Config.kt | 3 - .../main/java/com/topjohnwu/magisk/Hacks.kt | 2 +- .../com/topjohnwu/magisk/base/BaseActivity.kt | 9 +-- .../magisk/model/navigation/Navigation.kt | 61 +++++-------------- .../topjohnwu/magisk/redesign/MainActivity.kt | 3 + .../magisk/redesign/settings/SettingsItems.kt | 9 +-- .../redesign/settings/SettingsViewModel.kt | 6 +- .../topjohnwu/magisk/view/MarkDownWindow.kt | 27 +++----- 11 files changed, 33 insertions(+), 103 deletions(-) delete mode 100644 app/src/main/java/a/b.java rename app/src/main/java/a/{i.kt => b.kt} (59%) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f8512c230..033ceef1f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -29,11 +29,6 @@ - - diff --git a/app/src/main/java/a/b.java b/app/src/main/java/a/b.java deleted file mode 100644 index db9475e9c..000000000 --- a/app/src/main/java/a/b.java +++ /dev/null @@ -1,7 +0,0 @@ -package a; - -import com.topjohnwu.magisk.ui.MainActivity; - -public class b extends MainActivity { - /* stub */ -} diff --git a/app/src/main/java/a/i.kt b/app/src/main/java/a/b.kt similarity index 59% rename from app/src/main/java/a/i.kt rename to app/src/main/java/a/b.kt index b02385431..150f876fc 100644 --- a/app/src/main/java/a/i.kt +++ b/app/src/main/java/a/b.kt @@ -2,6 +2,4 @@ package a import com.topjohnwu.magisk.redesign.MainActivity -class i : MainActivity() { - /* stub */ -} \ No newline at end of file +class b : MainActivity() diff --git a/app/src/main/java/com/topjohnwu/magisk/Config.kt b/app/src/main/java/com/topjohnwu/magisk/Config.kt index 2cbb18d56..6134b4b45 100644 --- a/app/src/main/java/com/topjohnwu/magisk/Config.kt +++ b/app/src/main/java/com/topjohnwu/magisk/Config.kt @@ -123,9 +123,6 @@ object Config : PreferenceModel, DBConfig { var updateChannel by preferenceStrInt(Key.UPDATE_CHANNEL, defaultChannel) var safetyNotice by preference(Key.SAFETY, true) - var redesign by preference(Key.REDESIGN, false) - @Deprecated("Use extended dark theme") - var darkTheme by preference(Key.DARK_THEME, true) var darkThemeExtended by preference( Key.DARK_THEME_EXTENDED, AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM diff --git a/app/src/main/java/com/topjohnwu/magisk/Hacks.kt b/app/src/main/java/com/topjohnwu/magisk/Hacks.kt index d3a683760..18bdf85c7 100644 --- a/app/src/main/java/com/topjohnwu/magisk/Hacks.kt +++ b/app/src/main/java/com/topjohnwu/magisk/Hacks.kt @@ -151,7 +151,7 @@ object ClassMap { DownloadService::class.java to a.j::class.java, SuRequestActivity::class.java to a.m::class.java, ProcessPhoenix::class.java to a.r::class.java, - RedesignActivity::class.java to a.i::class.java + RedesignActivity::class.java to a.b::class.java ) operator fun get(c: Class<*>) = map.getOrElse(c) { c } diff --git a/app/src/main/java/com/topjohnwu/magisk/base/BaseActivity.kt b/app/src/main/java/com/topjohnwu/magisk/base/BaseActivity.kt index 2c4367bdf..667c39b62 100644 --- a/app/src/main/java/com/topjohnwu/magisk/base/BaseActivity.kt +++ b/app/src/main/java/com/topjohnwu/magisk/base/BaseActivity.kt @@ -39,14 +39,7 @@ abstract class BaseActivity() } init { - val theme = if (Config.redesign) { - Config.darkThemeExtended - } else { - when { - Config.darkTheme -> AppCompatDelegate.MODE_NIGHT_YES - else -> AppCompatDelegate.MODE_NIGHT_NO - } - } + val theme = Config.darkThemeExtended AppCompatDelegate.setDefaultNightMode(theme) } diff --git a/app/src/main/java/com/topjohnwu/magisk/model/navigation/Navigation.kt b/app/src/main/java/com/topjohnwu/magisk/model/navigation/Navigation.kt index dfa2da71b..11091b728 100644 --- a/app/src/main/java/com/topjohnwu/magisk/model/navigation/Navigation.kt +++ b/app/src/main/java/com/topjohnwu/magisk/model/navigation/Navigation.kt @@ -3,60 +3,40 @@ package com.topjohnwu.magisk.model.navigation import android.content.Context import android.content.Intent import android.os.Build -import com.topjohnwu.magisk.Config import com.topjohnwu.magisk.Const import com.topjohnwu.magisk.intent +import com.topjohnwu.magisk.redesign.MainActivity +import com.topjohnwu.magisk.redesign.hide.HideFragment +import com.topjohnwu.magisk.redesign.home.HomeFragment import com.topjohnwu.magisk.redesign.install.InstallFragment +import com.topjohnwu.magisk.redesign.log.LogFragment import com.topjohnwu.magisk.redesign.safetynet.SafetynetFragment +import com.topjohnwu.magisk.redesign.settings.SettingsFragment +import com.topjohnwu.magisk.redesign.superuser.SuperuserFragment import com.topjohnwu.magisk.redesign.theme.ThemeFragment -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 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 -import com.topjohnwu.magisk.redesign.hide.HideFragment as RedesignHideFragment -import com.topjohnwu.magisk.redesign.home.HomeFragment as RedesignHomeFragment -import com.topjohnwu.magisk.redesign.log.LogFragment as RedesignLogFragment -import com.topjohnwu.magisk.redesign.module.ModuleFragment as RedesignModulesFragment -import com.topjohnwu.magisk.redesign.settings.SettingsFragment as RedesignSettingsFragment -import com.topjohnwu.magisk.redesign.superuser.SuperuserFragment as RedesignSuperuserFragment object Navigation { fun home() = MagiskNavigationEvent { navDirections { - destination = when { - Config.redesign -> RedesignHomeFragment::class - else -> HomeFragment::class - } + destination = HomeFragment::class } navOptions { - popUpTo = when { - Config.redesign -> RedesignHomeFragment::class - else -> HomeFragment::class - } + popUpTo = HomeFragment::class } } fun superuser() = MagiskNavigationEvent { navDirections { - destination = when { - Config.redesign -> RedesignSuperuserFragment::class - else -> SuperuserFragment::class - } + destination = SuperuserFragment::class } } fun modules() = MagiskNavigationEvent { navDirections { - destination = when { - Config.redesign -> RedesignModulesFragment::class - else -> ModulesFragment::class - } + destination = ModulesFragment::class } } @@ -66,10 +46,7 @@ object Navigation { fun hide() = MagiskNavigationEvent { navDirections { - destination = when { - Config.redesign -> RedesignHideFragment::class - else -> MagiskHideFragment::class - } + destination = HideFragment::class } } @@ -79,19 +56,13 @@ object Navigation { fun log() = MagiskNavigationEvent { navDirections { - destination = when { - Config.redesign -> RedesignLogFragment::class - else -> LogFragment::class - } + destination = LogFragment::class } } fun settings() = MagiskNavigationEvent { navDirections { - destination = when { - Config.redesign -> RedesignSettingsFragment::class - else -> SettingsFragment::class - } + destination = SettingsFragment::class } } @@ -116,10 +87,8 @@ object Navigation { // redesign starts here fun start(launchIntent: Intent, context: Context) { - when { - Config.redesign -> context.intent() - else -> context.intent() - }.putExtra(Const.Key.OPEN_SECTION, launchIntent.getStringExtra(Const.Key.OPEN_SECTION)) + context.intent() + .putExtra(Const.Key.OPEN_SECTION, launchIntent.getStringExtra(Const.Key.OPEN_SECTION)) .putExtra( Const.Key.OPEN_SETTINGS, launchIntent.action == ACTION_APPLICATION_PREFERENCES diff --git a/app/src/main/java/com/topjohnwu/magisk/redesign/MainActivity.kt b/app/src/main/java/com/topjohnwu/magisk/redesign/MainActivity.kt index 2f2606cf7..fb4057ef3 100644 --- a/app/src/main/java/com/topjohnwu/magisk/redesign/MainActivity.kt +++ b/app/src/main/java/com/topjohnwu/magisk/redesign/MainActivity.kt @@ -4,6 +4,7 @@ import android.os.Bundle import android.view.MenuItem import android.view.View import android.view.ViewTreeObserver +import android.view.WindowManager import androidx.coordinatorlayout.widget.CoordinatorLayout import androidx.core.graphics.Insets import androidx.core.view.setPadding @@ -54,6 +55,8 @@ open class MainActivity : CompatActivity( override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE) + setSupportActionBar(binding.mainToolbar) binding.mainToolbarWrapper.updateLayoutParams { diff --git a/app/src/main/java/com/topjohnwu/magisk/redesign/settings/SettingsItems.kt b/app/src/main/java/com/topjohnwu/magisk/redesign/settings/SettingsItems.kt index 74ad13a29..c39be731e 100644 --- a/app/src/main/java/com/topjohnwu/magisk/redesign/settings/SettingsItems.kt +++ b/app/src/main/java/com/topjohnwu/magisk/redesign/settings/SettingsItems.kt @@ -42,13 +42,6 @@ object Language : SettingsItem.Selector() { } } -object Redesign : SettingsItem.Toggle() { - override val title = "Redesign".asTransitive() - override val description = - "Select this to disable redesign. App will automatically shut down".asTransitive() - override var value: Boolean by dataObservable(Config.redesign) { Config.redesign = it } -} - object Theme : SettingsItem.Blank() { override val icon = R.drawable.ic_paint override val title = R.string.section_theme.asTransitive() @@ -386,4 +379,4 @@ object SUNotification : SettingsItem.Selector() { override fun refresh() { isEnabled = Utils.showSuperUser() } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/topjohnwu/magisk/redesign/settings/SettingsViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/redesign/settings/SettingsViewModel.kt index eb8434cdc..db21a2a4a 100644 --- a/app/src/main/java/com/topjohnwu/magisk/redesign/settings/SettingsViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/redesign/settings/SettingsViewModel.kt @@ -11,7 +11,6 @@ import com.topjohnwu.magisk.model.download.DownloadService import com.topjohnwu.magisk.model.entity.internal.Configuration import com.topjohnwu.magisk.model.entity.internal.DownloadSubject import com.topjohnwu.magisk.model.entity.recycler.SettingsItem -import com.topjohnwu.magisk.model.events.DieEvent import com.topjohnwu.magisk.model.events.PermissionEvent import com.topjohnwu.magisk.model.events.RecreateEvent import com.topjohnwu.magisk.model.events.dialog.BiometricDialog @@ -35,7 +34,7 @@ class SettingsViewModel( val itemBinding = itemBindingOf { it.bindExtra(BR.callback, this) } val items = diffListOf( Customization, - Theme, Language, Redesign, DownloadPath, GridSize, + Theme, Language, DownloadPath, GridSize, Manager, UpdateChannel, UpdateChannelUrl, ClearRepoCache, HideOrRestore(), UpdateChecker, @@ -57,7 +56,6 @@ class SettingsViewModel( override fun onItemChanged(view: View, item: SettingsItem) = when (item) { // use only instances you want, don't declare everything is Theme -> Navigation.theme().publish() - is Redesign -> DieEvent().publish() is Language -> RecreateEvent().publish() is UpdateChannel -> openUrlIfNecessary(view) @@ -118,4 +116,4 @@ class SettingsViewModel( } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/topjohnwu/magisk/view/MarkDownWindow.kt b/app/src/main/java/com/topjohnwu/magisk/view/MarkDownWindow.kt index 6b323a34c..c2304f863 100644 --- a/app/src/main/java/com/topjohnwu/magisk/view/MarkDownWindow.kt +++ b/app/src/main/java/com/topjohnwu/magisk/view/MarkDownWindow.kt @@ -3,8 +3,6 @@ package com.topjohnwu.magisk.view import android.content.Context import android.view.LayoutInflater import android.widget.TextView -import androidx.appcompat.app.AlertDialog -import com.topjohnwu.magisk.Config import com.topjohnwu.magisk.R import com.topjohnwu.magisk.data.repository.StringRepository import com.topjohnwu.magisk.extensions.subscribeK @@ -35,7 +33,7 @@ object MarkDownWindow : KoinComponent { } fun show(activity: Context, title: String?, content: Single) { - val mdRes = if (Config.redesign) R.layout.markdown_window_md2 else R.layout.markdown_window + val mdRes = R.layout.markdown_window_md2 val mv = LayoutInflater.from(activity).inflate(mdRes, null) val tv = mv.findViewById(R.id.md_txt) @@ -47,21 +45,14 @@ object MarkDownWindow : KoinComponent { tv.setText(R.string.download_file_error) Completable.complete() }.subscribeK { - if (Config.redesign) { - MagiskDialog(activity) - .applyTitle(title ?: "") - .applyView(mv) - .applyButton(MagiskDialog.ButtonType.NEGATIVE) { - titleRes = android.R.string.cancel - } - .reveal() - return@subscribeK - } - AlertDialog.Builder(activity) - .setTitle(title) - .setView(mv) - .setNegativeButton(android.R.string.cancel) { dialog, _ -> dialog.dismiss() } - .show() + MagiskDialog(activity) + .applyTitle(title ?: "") + .applyView(mv) + .applyButton(MagiskDialog.ButtonType.NEGATIVE) { + titleRes = android.R.string.cancel + } + .reveal() + return@subscribeK } } }