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 --> <!-- Main -->
<activity android:name="a.b" /> <activity android:name="a.b" />
<activity
android:name="a.i"
android:windowSoftInputMode="adjustResize"
android:exported="true" />
<!-- Flashing --> <!-- Flashing -->
<activity android:name="a.f" /> <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 import com.topjohnwu.magisk.redesign.MainActivity
class i : MainActivity() { class b : MainActivity()
/* stub */
}

View File

@ -123,9 +123,6 @@ object Config : PreferenceModel, DBConfig {
var updateChannel by preferenceStrInt(Key.UPDATE_CHANNEL, defaultChannel) var updateChannel by preferenceStrInt(Key.UPDATE_CHANNEL, defaultChannel)
var safetyNotice by preference(Key.SAFETY, true) 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( var darkThemeExtended by preference(
Key.DARK_THEME_EXTENDED, Key.DARK_THEME_EXTENDED,
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM

View File

@ -151,7 +151,7 @@ object ClassMap {
DownloadService::class.java to a.j::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,
ProcessPhoenix::class.java to a.r::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 } 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>() } private val resultCallbacks by lazy { SparseArrayCompat<RequestCallback>() }
init { init {
val theme = if (Config.redesign) { val theme = Config.darkThemeExtended
Config.darkThemeExtended
} else {
when {
Config.darkTheme -> AppCompatDelegate.MODE_NIGHT_YES
else -> AppCompatDelegate.MODE_NIGHT_NO
}
}
AppCompatDelegate.setDefaultNightMode(theme) AppCompatDelegate.setDefaultNightMode(theme)
} }

View File

@ -3,60 +3,40 @@ package com.topjohnwu.magisk.model.navigation
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Build import android.os.Build
import com.topjohnwu.magisk.Config
import com.topjohnwu.magisk.Const import com.topjohnwu.magisk.Const
import com.topjohnwu.magisk.intent 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.install.InstallFragment
import com.topjohnwu.magisk.redesign.log.LogFragment
import com.topjohnwu.magisk.redesign.safetynet.SafetynetFragment 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.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.ModulesFragment
import com.topjohnwu.magisk.ui.module.ReposFragment 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 { object Navigation {
fun home() = MagiskNavigationEvent { fun home() = MagiskNavigationEvent {
navDirections { navDirections {
destination = when { destination = HomeFragment::class
Config.redesign -> RedesignHomeFragment::class
else -> HomeFragment::class
}
} }
navOptions { navOptions {
popUpTo = when { popUpTo = HomeFragment::class
Config.redesign -> RedesignHomeFragment::class
else -> HomeFragment::class
}
} }
} }
fun superuser() = MagiskNavigationEvent { fun superuser() = MagiskNavigationEvent {
navDirections { navDirections {
destination = when { destination = SuperuserFragment::class
Config.redesign -> RedesignSuperuserFragment::class
else -> SuperuserFragment::class
}
} }
} }
fun modules() = MagiskNavigationEvent { fun modules() = MagiskNavigationEvent {
navDirections { navDirections {
destination = when { destination = ModulesFragment::class
Config.redesign -> RedesignModulesFragment::class
else -> ModulesFragment::class
}
} }
} }
@ -66,10 +46,7 @@ object Navigation {
fun hide() = MagiskNavigationEvent { fun hide() = MagiskNavigationEvent {
navDirections { navDirections {
destination = when { destination = HideFragment::class
Config.redesign -> RedesignHideFragment::class
else -> MagiskHideFragment::class
}
} }
} }
@ -79,19 +56,13 @@ object Navigation {
fun log() = MagiskNavigationEvent { fun log() = MagiskNavigationEvent {
navDirections { navDirections {
destination = when { destination = LogFragment::class
Config.redesign -> RedesignLogFragment::class
else -> LogFragment::class
}
} }
} }
fun settings() = MagiskNavigationEvent { fun settings() = MagiskNavigationEvent {
navDirections { navDirections {
destination = when { destination = SettingsFragment::class
Config.redesign -> RedesignSettingsFragment::class
else -> SettingsFragment::class
}
} }
} }
@ -116,10 +87,8 @@ object Navigation {
// redesign starts here // redesign starts here
fun start(launchIntent: Intent, context: Context) { fun start(launchIntent: Intent, context: Context) {
when { context.intent<MainActivity>()
Config.redesign -> context.intent<RedesignActivity>() .putExtra(Const.Key.OPEN_SECTION, launchIntent.getStringExtra(Const.Key.OPEN_SECTION))
else -> context.intent<MainActivity>()
}.putExtra(Const.Key.OPEN_SECTION, launchIntent.getStringExtra(Const.Key.OPEN_SECTION))
.putExtra( .putExtra(
Const.Key.OPEN_SETTINGS, Const.Key.OPEN_SETTINGS,
launchIntent.action == ACTION_APPLICATION_PREFERENCES launchIntent.action == ACTION_APPLICATION_PREFERENCES

View File

@ -4,6 +4,7 @@ import android.os.Bundle
import android.view.MenuItem import android.view.MenuItem
import android.view.View import android.view.View
import android.view.ViewTreeObserver import android.view.ViewTreeObserver
import android.view.WindowManager
import androidx.coordinatorlayout.widget.CoordinatorLayout import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.graphics.Insets import androidx.core.graphics.Insets
import androidx.core.view.setPadding import androidx.core.view.setPadding
@ -54,6 +55,8 @@ open class MainActivity : CompatActivity<MainViewModel, ActivityMainMd2Binding>(
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
setSupportActionBar(binding.mainToolbar) setSupportActionBar(binding.mainToolbar)
binding.mainToolbarWrapper.updateLayoutParams<CoordinatorLayout.LayoutParams> { 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() { object Theme : SettingsItem.Blank() {
override val icon = R.drawable.ic_paint override val icon = R.drawable.ic_paint
override val title = R.string.section_theme.asTransitive() 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.Configuration
import com.topjohnwu.magisk.model.entity.internal.DownloadSubject import com.topjohnwu.magisk.model.entity.internal.DownloadSubject
import com.topjohnwu.magisk.model.entity.recycler.SettingsItem 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.PermissionEvent
import com.topjohnwu.magisk.model.events.RecreateEvent import com.topjohnwu.magisk.model.events.RecreateEvent
import com.topjohnwu.magisk.model.events.dialog.BiometricDialog import com.topjohnwu.magisk.model.events.dialog.BiometricDialog
@ -35,7 +34,7 @@ class SettingsViewModel(
val itemBinding = itemBindingOf<SettingsItem> { it.bindExtra(BR.callback, this) } val itemBinding = itemBindingOf<SettingsItem> { it.bindExtra(BR.callback, this) }
val items = diffListOf( val items = diffListOf(
Customization, Customization,
Theme, Language, Redesign, DownloadPath, GridSize, Theme, Language, DownloadPath, GridSize,
Manager, Manager,
UpdateChannel, UpdateChannelUrl, ClearRepoCache, HideOrRestore(), UpdateChecker, UpdateChannel, UpdateChannelUrl, ClearRepoCache, HideOrRestore(), UpdateChecker,
@ -57,7 +56,6 @@ class SettingsViewModel(
override fun onItemChanged(view: View, item: SettingsItem) = when (item) { override fun onItemChanged(view: View, item: SettingsItem) = when (item) {
// use only instances you want, don't declare everything // use only instances you want, don't declare everything
is Theme -> Navigation.theme().publish() is Theme -> Navigation.theme().publish()
is Redesign -> DieEvent().publish()
is Language -> RecreateEvent().publish() is Language -> RecreateEvent().publish()
is UpdateChannel -> openUrlIfNecessary(view) is UpdateChannel -> openUrlIfNecessary(view)

View File

@ -3,8 +3,6 @@ package com.topjohnwu.magisk.view
import android.content.Context import android.content.Context
import android.view.LayoutInflater import android.view.LayoutInflater
import android.widget.TextView import android.widget.TextView
import androidx.appcompat.app.AlertDialog
import com.topjohnwu.magisk.Config
import com.topjohnwu.magisk.R import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.data.repository.StringRepository import com.topjohnwu.magisk.data.repository.StringRepository
import com.topjohnwu.magisk.extensions.subscribeK import com.topjohnwu.magisk.extensions.subscribeK
@ -35,7 +33,7 @@ object MarkDownWindow : KoinComponent {
} }
fun show(activity: Context, title: String?, content: Single<String>) { 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 mv = LayoutInflater.from(activity).inflate(mdRes, null)
val tv = mv.findViewById<TextView>(R.id.md_txt) val tv = mv.findViewById<TextView>(R.id.md_txt)
@ -47,21 +45,14 @@ object MarkDownWindow : KoinComponent {
tv.setText(R.string.download_file_error) tv.setText(R.string.download_file_error)
Completable.complete() Completable.complete()
}.subscribeK { }.subscribeK {
if (Config.redesign) { MagiskDialog(activity)
MagiskDialog(activity) .applyTitle(title ?: "")
.applyTitle(title ?: "") .applyView(mv)
.applyView(mv) .applyButton(MagiskDialog.ButtonType.NEGATIVE) {
.applyButton(MagiskDialog.ButtonType.NEGATIVE) { titleRes = android.R.string.cancel
titleRes = android.R.string.cancel }
} .reveal()
.reveal() return@subscribeK
return@subscribeK
}
AlertDialog.Builder(activity)
.setTitle(title)
.setView(mv)
.setNegativeButton(android.R.string.cancel) { dialog, _ -> dialog.dismiss() }
.show()
} }
} }
} }