修复主题应用
This commit is contained in:
1 parent
32e7e78c69
commit
9c3f185fa7
10 files changed
+59
-78
No files matched your search
@@ -40,12 +40,4 @@ class ConfigActivity : VMBaseActivity<ActivityConfigBinding, ConfigViewModel>()
|
||||
.replace(R.id.configFrameLayout, configFragment, configTag)
|
||||
.commit()
|
||||
}
|
||||
|
||||
override fun observeLiveBus() {
|
||||
super.observeLiveBus()
|
||||
observeEvent<String>(EventBus.RECREATE) {
|
||||
recreate()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.legato.kazusa.ui.config
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
@@ -74,11 +75,11 @@ class ThemeConfigFragment : PreferenceFragmentCompat(),
|
||||
if (Build.VERSION.SDK_INT < 26) {
|
||||
preferenceScreen.removePreferenceRecursively(PreferKey.launcherIcon)
|
||||
}
|
||||
upPreferenceSummary(PreferKey.themePref)
|
||||
|
||||
upPreferenceSummary(PreferKey.bgImage, getPrefString(PreferKey.bgImage))
|
||||
upPreferenceSummary(PreferKey.bgImageN, getPrefString(PreferKey.bgImageN))
|
||||
//upPreferenceSummary(PreferKey.barElevation, AppConfig.elevation.toString())
|
||||
upPreferenceSummary(PreferKey.fontScale)
|
||||
|
||||
findPreference<ColorPreference>(PreferKey.cBackground)?.let {
|
||||
it.onSaveColor = { color ->
|
||||
if (!ColorUtils.isColorLight(color)) {
|
||||
@@ -89,6 +90,7 @@ class ThemeConfigFragment : PreferenceFragmentCompat(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
findPreference<ColorPreference>(PreferKey.cNBackground)?.let {
|
||||
it.onSaveColor = { color ->
|
||||
if (ColorUtils.isColorLight(color)) {
|
||||
@@ -99,17 +101,15 @@ class ThemeConfigFragment : PreferenceFragmentCompat(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
findPreference<ThemeModePreference>(PreferKey.themeMode)?.let {
|
||||
it.setOnPreferenceChangeListener { _, _ ->
|
||||
ThemeConfig.applyDayNight(requireContext())
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
findPreference<ThemeCardPreference>(PreferKey.themePref)?.let {
|
||||
it.setOnPreferenceChangeListener { _, _ ->
|
||||
val intent = requireActivity().intent
|
||||
requireActivity().finish()
|
||||
startActivity(intent)
|
||||
true
|
||||
}
|
||||
}
|
||||
@@ -138,11 +138,12 @@ class ThemeConfigFragment : PreferenceFragmentCompat(),
|
||||
PreferKey.launcherIcon -> LauncherIconHelp.changeIcon(getPrefString(key))
|
||||
//PreferKey.transparentStatusBar -> recreateActivities()
|
||||
//PreferKey.immNavigationBar -> recreateActivities()
|
||||
|
||||
PreferKey.themePref -> {
|
||||
val intent = requireActivity().intent
|
||||
requireActivity().finish()
|
||||
startActivity(intent)
|
||||
ThemeConfig.applyDayNight(requireContext())
|
||||
recreateActivities()
|
||||
}
|
||||
|
||||
PreferKey.cPrimary,
|
||||
PreferKey.cAccent,
|
||||
PreferKey.cBackground,
|
||||
@@ -158,7 +159,7 @@ class ThemeConfigFragment : PreferenceFragmentCompat(),
|
||||
}
|
||||
|
||||
PreferKey.themeMode -> {
|
||||
ThemeConfig.applyDayNight(requireContext())
|
||||
recreateActivities()
|
||||
}
|
||||
|
||||
PreferKey.bgImage,
|
||||
@@ -291,7 +292,7 @@ class ThemeConfigFragment : PreferenceFragmentCompat(),
|
||||
private fun upTheme(isNightTheme: Boolean) {
|
||||
if (AppConfig.isNightTheme == isNightTheme) {
|
||||
listView.post {
|
||||
ThemeConfig.applyTheme(requireContext())
|
||||
//ThemeConfig.applyTheme(requireContext())
|
||||
recreateActivities()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ import kotlinx.coroutines.withContext
|
||||
import splitties.views.bottomPadding
|
||||
import kotlin.coroutines.resume
|
||||
import kotlin.coroutines.suspendCoroutine
|
||||
import androidx.core.view.get
|
||||
|
||||
/**
|
||||
* 主界面
|
||||
@@ -197,9 +198,6 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
|
||||
//bottomNavigationView.elevation = elevation
|
||||
bottomNavigationView.setOnNavigationItemSelectedListener(this@MainActivity)
|
||||
bottomNavigationView.setOnNavigationItemReselectedListener(this@MainActivity)
|
||||
if (AppConfig.isEInkMode) {
|
||||
bottomNavigationView.setBackgroundResource(R.drawable.bg_eink_border_top)
|
||||
}
|
||||
bottomNavigationView.setOnApplyWindowInsetsListenerCompat { view, windowInsets ->
|
||||
val height = windowInsets.navigationBarHeight
|
||||
view.bottomPadding = height
|
||||
@@ -411,10 +409,8 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
|
||||
|
||||
override fun onPageSelected(position: Int) {
|
||||
pagePosition = position
|
||||
binding.bottomNavigationView.menu
|
||||
.getItem(realPositions[position]).isChecked = true
|
||||
binding.bottomNavigationView.menu[realPositions[position]].isChecked = true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
|
||||
Reference in new issue
Block a user