feat: 设置中启用新 UI(实验性特性)
This commit is contained in:
parent
c81241bdc4
commit
40d7218755
|
|
@ -38,6 +38,7 @@ import com.huanchengfly.tieba.post.utils.AccountUtil
|
|||
import com.huanchengfly.tieba.post.utils.AppIconUtil
|
||||
import com.huanchengfly.tieba.post.utils.ClientUtils
|
||||
import com.huanchengfly.tieba.post.utils.EmoticonManager
|
||||
import com.huanchengfly.tieba.post.utils.Icons
|
||||
import com.huanchengfly.tieba.post.utils.SharedPreferencesUtil
|
||||
import com.huanchengfly.tieba.post.utils.ThemeUtil
|
||||
import com.huanchengfly.tieba.post.utils.TiebaUtil
|
||||
|
|
@ -93,6 +94,11 @@ class App : Application(), IApp, IGetter, SketchFactory {
|
|||
return null
|
||||
}
|
||||
|
||||
fun refreshIcon(enableNewUi: Boolean = applicationMetaData.getBoolean("enable_new_ui") || appPreferences.enableNewUi) {
|
||||
if (enableNewUi) AppIconUtil.setIcon()
|
||||
else AppIconUtil.setIcon(Icons.DISABLE)
|
||||
}
|
||||
|
||||
override fun onCreate() {
|
||||
INSTANCE = this
|
||||
super.onCreate()
|
||||
|
|
@ -103,7 +109,6 @@ class App : Application(), IApp, IGetter, SketchFactory {
|
|||
setWebViewPath(this)
|
||||
}
|
||||
val isSelfBuild = applicationMetaData.getBoolean("is_self_build")
|
||||
val enableNewUi = applicationMetaData.getBoolean("enable_new_ui")
|
||||
if (!isSelfBuild) {
|
||||
Distribute.setUpdateTrack(if (appPreferences.checkCIUpdate) UpdateTrack.PRIVATE else UpdateTrack.PUBLIC)
|
||||
Distribute.setListener(MyDistributeListener())
|
||||
|
|
@ -112,9 +117,9 @@ class App : Application(), IApp, IGetter, SketchFactory {
|
|||
Analytics::class.java, Crashes::class.java, Distribute::class.java
|
||||
)
|
||||
}
|
||||
refreshIcon()
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
|
||||
ThemeUtils.init(ThemeDelegate)
|
||||
if (enableNewUi) AppIconUtil.setIcon()
|
||||
registerActivityLifecycleCallbacks(ClipBoardLinkDetector)
|
||||
PluginManager.init(this)
|
||||
CoroutineScope(Dispatchers.IO).apply {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import androidx.preference.ListPreference
|
|||
import androidx.preference.Preference
|
||||
import androidx.preference.SwitchPreference
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.huanchengfly.tieba.post.App
|
||||
import com.huanchengfly.tieba.post.BuildConfig
|
||||
import com.huanchengfly.tieba.post.DataStorePreference
|
||||
import com.huanchengfly.tieba.post.R
|
||||
|
|
@ -257,6 +258,10 @@ class PreferencesFragment : PreferencesFragment() {
|
|||
aboutPreference!!.summary =
|
||||
getString(R.string.tip_about, BuildConfig.VERSION_NAME)
|
||||
refresh()
|
||||
findPreference<SwitchPreference>("enableNewUi")?.setOnPreferenceChangeListener { _, newValue ->
|
||||
App.INSTANCE.refreshIcon(newValue == true)
|
||||
true
|
||||
}
|
||||
/*
|
||||
try {
|
||||
val preferenceGroupClazz = PreferenceGroup::class.java
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import androidx.compose.foundation.layout.padding
|
|||
import androidx.compose.material.ExperimentalMaterialApi
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.BugReport
|
||||
import androidx.compose.material.icons.outlined.FiberNew
|
||||
import androidx.compose.material.icons.outlined.Info
|
||||
import androidx.compose.material.icons.outlined.OfflineBolt
|
||||
import androidx.compose.runtime.*
|
||||
|
|
@ -78,6 +79,23 @@ fun MoreSettingsPage(
|
|||
summary = stringResource(id = R.string.tip_check_ci_update)
|
||||
)
|
||||
}
|
||||
prefsItem {
|
||||
SwitchPref(
|
||||
leadingIcon = {
|
||||
LeadingIcon {
|
||||
AvatarIcon(
|
||||
icon = Icons.Outlined.FiberNew,
|
||||
size = Sizes.Small,
|
||||
contentDescription = null,
|
||||
)
|
||||
}
|
||||
},
|
||||
key = "enableNewUi",
|
||||
title = stringResource(id = R.string.title_enable_new_ui),
|
||||
defaultChecked = false,
|
||||
summary = stringResource(id = R.string.summary_enable_new_ui)
|
||||
)
|
||||
}
|
||||
prefsItem {
|
||||
SwitchPref(
|
||||
leadingIcon = {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ object Icons {
|
|||
const val NEW_ICON = "com.huanchengfly.tieba.post.MainActivityV2"
|
||||
const val NEW_ICON_INVERT = "com.huanchengfly.tieba.post.MainActivityIconInvert"
|
||||
const val OLD_ICON = "com.huanchengfly.tieba.post.MainActivityIconOld"
|
||||
const val DISABLE = "com.huanchengfly.tieba.post.MainActivityV2Disabled"
|
||||
|
||||
const val DEFAULT_ICON = NEW_ICON
|
||||
|
||||
|
|
|
|||
|
|
@ -72,6 +72,8 @@ open class AppPreferencesUtils(context: Context) {
|
|||
|
||||
var darkTheme by DataStoreDelegates.string(key = "dark_theme", defaultValue = "grey_dark")
|
||||
|
||||
var enableNewUi by DataStoreDelegates.boolean(defaultValue = false)
|
||||
|
||||
var followSystemNight by DataStoreDelegates.boolean(
|
||||
defaultValue = true,
|
||||
key = "follow_system_night"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="#000000"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M20,4L4,4c-1.11,0 -1.99,0.89 -1.99,2L2,18c0,1.11 0.89,2 2,2h16c1.11,0 2,-0.89 2,-2L22,6c0,-1.11 -0.89,-2 -2,-2zM8.5,14.21c0,0.43 -0.36,0.79 -0.79,0.79 -0.25,0 -0.49,-0.12 -0.64,-0.33L4.75,11.5v2.88c0,0.35 -0.28,0.62 -0.62,0.62s-0.63,-0.28 -0.63,-0.62L3.5,9.79c0,-0.43 0.36,-0.79 0.79,-0.79h0.05c0.26,0 0.5,0.12 0.65,0.33l2.26,3.17L7.25,9.62c0,-0.34 0.28,-0.62 0.63,-0.62s0.62,0.28 0.62,0.62v4.59zM13.5,9.64c0,0.35 -0.28,0.62 -0.62,0.62L11,10.26v1.12h1.88c0.35,0 0.62,0.28 0.62,0.62v0.01c0,0.35 -0.28,0.62 -0.62,0.62L11,12.63v1.11h1.88c0.35,0 0.62,0.28 0.62,0.62 0,0.35 -0.28,0.62 -0.62,0.62h-2.53c-0.47,0 -0.85,-0.38 -0.85,-0.85v-4.3c0,-0.45 0.38,-0.83 0.85,-0.83h2.53c0.35,0 0.62,0.28 0.62,0.62v0.02zM20.5,14c0,0.55 -0.45,1 -1,1h-4c-0.55,0 -1,-0.45 -1,-1L14.5,9.62c0,-0.34 0.28,-0.62 0.62,-0.62s0.62,0.28 0.62,0.62v3.89h1.13v-2.9c0,-0.35 0.28,-0.62 0.62,-0.62s0.62,0.28 0.62,0.62v2.89h1.12L19.23,9.62c0,-0.35 0.28,-0.62 0.62,-0.62s0.62,0.28 0.62,0.62L20.47,14z" />
|
||||
</vector>
|
||||
|
|
@ -20,6 +20,7 @@
|
|||
<string-array name="experimental_features">
|
||||
<item>oksign_use_official_oksign</item>
|
||||
<item>checkCIUpdate</item>
|
||||
<item>enableNewUi</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="image_load_type_entries">
|
||||
|
|
|
|||
|
|
@ -635,4 +635,6 @@
|
|||
<string name="insert_voice">语音</string>
|
||||
<string name="emoticon_default">表情</string>
|
||||
<string name="emoticon">表情 %s</string>
|
||||
<string name="summary_enable_new_ui">(实验性特性)启用新版 UI。仅少部分页面完成,BUG 可能较多,仅供尝鲜使用!</string>
|
||||
<string name="title_enable_new_ui">启用新版 UI</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -259,6 +259,13 @@
|
|||
android:summary="@string/tip_check_ci_update"
|
||||
android:title="@string/title_check_ci_update" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:icon="@drawable/ic_round_fiber_new"
|
||||
android:key="enableNewUi"
|
||||
android:summary="@string/summary_enable_new_ui"
|
||||
android:title="@string/title_enable_new_ui" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:icon="@drawable/ic_chrome"
|
||||
|
|
|
|||
Loading…
Reference in New Issue