Replace old design with redesign (p1)

This commit is contained in:
topjohnwu 2020-01-12 15:00:49 +08:00
parent 0827044caf
commit df0a5b59f8
11 changed files with 33 additions and 103 deletions

View File

@ -29,11 +29,6 @@
<!-- Main -->
<activity android:name="a.b" />
<activity
android:name="a.i"
android:windowSoftInputMode="adjustResize"
android:exported="true" />
<!-- Flashing -->
<activity android:name="a.f" />

View File

@ -1,7 +0,0 @@
package a;
import com.topjohnwu.magisk.ui.MainActivity;
public class b extends MainActivity {
/* stub */
}

View File

@ -2,6 +2,4 @@ package a
import com.topjohnwu.magisk.redesign.MainActivity
class i : MainActivity() {
/* stub */
}
class b : MainActivity()

View File

@ -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

View File

@ -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 }

View File

@ -39,14 +39,7 @@ abstract class BaseActivity<ViewModel : BaseViewModel, Binding : ViewDataBinding
private val resultCallbacks by lazy { SparseArrayCompat<RequestCallback>() }
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)
}

View File

@ -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<RedesignActivity>()
else -> context.intent<MainActivity>()
}.putExtra(Const.Key.OPEN_SECTION, launchIntent.getStringExtra(Const.Key.OPEN_SECTION))
context.intent<MainActivity>()
.putExtra(Const.Key.OPEN_SECTION, launchIntent.getStringExtra(Const.Key.OPEN_SECTION))
.putExtra(
Const.Key.OPEN_SETTINGS,
launchIntent.action == ACTION_APPLICATION_PREFERENCES

View File

@ -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<MainViewModel, ActivityMainMd2Binding>(
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
setSupportActionBar(binding.mainToolbar)
binding.mainToolbarWrapper.updateLayoutParams<CoordinatorLayout.LayoutParams> {

View File

@ -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()

View File

@ -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<SettingsItem> { 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)

View File

@ -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<String>) {
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<TextView>(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
}
}
}