为需要重启应用的选项提供引导
This commit is contained in:
5 files changed
+40
-13
No files matched your search
@@ -19,6 +19,7 @@ import com.google.android.material.card.MaterialCardView
|
|||||||
import io.legato.kazusa.R
|
import io.legato.kazusa.R
|
||||||
import io.legato.kazusa.constant.EventBus
|
import io.legato.kazusa.constant.EventBus
|
||||||
import io.legato.kazusa.constant.PreferKey
|
import io.legato.kazusa.constant.PreferKey
|
||||||
|
import io.legato.kazusa.lib.dialogs.alert
|
||||||
import io.legato.kazusa.utils.getPrefString
|
import io.legato.kazusa.utils.getPrefString
|
||||||
import io.legato.kazusa.utils.postEvent
|
import io.legato.kazusa.utils.postEvent
|
||||||
import io.legato.kazusa.utils.restart
|
import io.legato.kazusa.utils.restart
|
||||||
@@ -96,11 +97,20 @@ class ThemeCardPreference(context: Context, attrs: AttributeSet) : Preference(co
|
|||||||
val isDynamicSwitch = (oldValue == "11" || value == "11")
|
val isDynamicSwitch = (oldValue == "11" || value == "11")
|
||||||
Handler(Looper.getMainLooper()).postDelayed({
|
Handler(Looper.getMainLooper()).postDelayed({
|
||||||
if (isDynamicSwitch) {
|
if (isDynamicSwitch) {
|
||||||
context.restart()
|
context.alert(context.getString(R.string.restart_required_message)) {
|
||||||
|
okButton {
|
||||||
|
Handler(Looper.getMainLooper()).postDelayed({
|
||||||
|
context.restart()
|
||||||
|
}, 100)
|
||||||
|
}
|
||||||
|
cancelButton {
|
||||||
|
context.toastOnUi(R.string.restart_later_message)
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
postEvent(EventBus.RECREATE, "")
|
postEvent(EventBus.RECREATE, "")
|
||||||
}
|
}
|
||||||
}, 300)
|
}, 100)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -179,16 +179,12 @@ class ThemeConfigFragment : PreferenceFragmentCompat(),
|
|||||||
//recreateActivities()
|
//recreateActivities()
|
||||||
}
|
}
|
||||||
|
|
||||||
PreferKey.customMode -> {
|
PreferKey.customMode -> handleRestartRequired()
|
||||||
Handler(Looper.getMainLooper()).postDelayed({
|
|
||||||
requireContext().restart()
|
|
||||||
}, 300)
|
|
||||||
}
|
|
||||||
|
|
||||||
PreferKey.pureBlack -> {
|
PreferKey.pureBlack -> {
|
||||||
Handler(Looper.getMainLooper()).postDelayed({
|
Handler(Looper.getMainLooper()).postDelayed({
|
||||||
recreateActivities()
|
recreateActivities()
|
||||||
}, 300)
|
}, 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
PreferKey.cPrimary -> {
|
PreferKey.cPrimary -> {
|
||||||
@@ -201,7 +197,7 @@ class ThemeConfigFragment : PreferenceFragmentCompat(),
|
|||||||
.build())
|
.build())
|
||||||
Handler(Looper.getMainLooper()).postDelayed({
|
Handler(Looper.getMainLooper()).postDelayed({
|
||||||
recreateActivities()
|
recreateActivities()
|
||||||
}, 300)
|
}, 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
PreferKey.cBackground,
|
PreferKey.cBackground,
|
||||||
@@ -220,10 +216,7 @@ class ThemeConfigFragment : PreferenceFragmentCompat(),
|
|||||||
//recreateActivities()
|
//recreateActivities()
|
||||||
}
|
}
|
||||||
|
|
||||||
PreferKey.colorImage ->
|
PreferKey.colorImage -> handleRestartRequired()
|
||||||
Handler(Looper.getMainLooper()).postDelayed({
|
|
||||||
requireContext().restart()
|
|
||||||
}, 100)
|
|
||||||
|
|
||||||
PreferKey.bgImage,
|
PreferKey.bgImage,
|
||||||
PreferKey.bgImageN -> {
|
PreferKey.bgImageN -> {
|
||||||
@@ -346,6 +339,18 @@ class ThemeConfigFragment : PreferenceFragmentCompat(),
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun handleRestartRequired() {
|
||||||
|
alert(getString(R.string.restart_required_message)) {
|
||||||
|
okButton {
|
||||||
|
Handler(Looper.getMainLooper()).postDelayed({
|
||||||
|
requireContext().restart()
|
||||||
|
}, 100)
|
||||||
|
}
|
||||||
|
cancelButton {
|
||||||
|
toastOnUi(R.string.restart_later_message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun alertImageBlurring(preferKey: String, success: () -> Unit) {
|
private fun alertImageBlurring(preferKey: String, success: () -> Unit) {
|
||||||
alert(R.string.background_image_blurring) {
|
alert(R.string.background_image_blurring) {
|
||||||
|
|||||||
@@ -1296,4 +1296,7 @@
|
|||||||
<string name="seed_photo_summary">使用图片生成主题颜色</string>
|
<string name="seed_photo_summary">使用图片生成主题颜色</string>
|
||||||
<string name="seed_photo_alart">若需使用种子颜色,请取消种子图片选择</string>
|
<string name="seed_photo_alart">若需使用种子颜色,请取消种子图片选择</string>
|
||||||
<string name="click_to_delete">点击以删除或更改</string>
|
<string name="click_to_delete">点击以删除或更改</string>
|
||||||
|
<string name="tip_custom_mode">切换至自定义主题或调整自定义设置时,部分选项需要重启。</string>
|
||||||
|
<string name="restart_required_message">此更改需要重启应用才能生效,是否立即重启?</string>
|
||||||
|
<string name="restart_later_message">更改将在下次启动应用时生效</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -1297,4 +1297,7 @@
|
|||||||
<string name="seed_photo_summary">使用图片生成主题颜色</string>
|
<string name="seed_photo_summary">使用图片生成主题颜色</string>
|
||||||
<string name="seed_photo_alart">若需使用种子颜色,请取消种子图片选择</string>
|
<string name="seed_photo_alart">若需使用种子颜色,请取消种子图片选择</string>
|
||||||
<string name="click_to_delete">Click to delete or change</string>
|
<string name="click_to_delete">Click to delete or change</string>
|
||||||
|
<string name="tip_custom_mode">切换至自定义主题或调整自定义设置时,部分选项需要重启。</string>
|
||||||
|
<string name="restart_required_message">修改该选项需要重启</string>
|
||||||
|
<string name="restart_later_message">稍后重启</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -24,6 +24,12 @@
|
|||||||
android:entryValues="@array/themes_value"
|
android:entryValues="@array/themes_value"
|
||||||
android:defaultValue="0" />
|
android:defaultValue="0" />
|
||||||
|
|
||||||
|
<io.legato.kazusa.lib.prefs.TipPreference
|
||||||
|
android:key="tip"
|
||||||
|
android:selectable="false"
|
||||||
|
app:iconSpaceReserved="false"
|
||||||
|
app:tipText="@string/tip_custom_mode"/>
|
||||||
|
|
||||||
<io.legato.kazusa.lib.prefs.SwitchPreference
|
<io.legato.kazusa.lib.prefs.SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="pure_black"
|
android:key="pure_black"
|
||||||
|
|||||||
Reference in new issue
Block a user