修复
This commit is contained in:
@@ -33,7 +33,7 @@
|
|||||||
tools:ignore="AllowBackup,GoogleAppIndexingWarning,UnusedAttribute">
|
tools:ignore="AllowBackup,GoogleAppIndexingWarning,UnusedAttribute">
|
||||||
<!-- 图标1 -->
|
<!-- 图标1 -->
|
||||||
<activity-alias
|
<activity-alias
|
||||||
android:name=".ui.welcome.Launcher1"
|
android:name=".Launcher1"
|
||||||
android:enabled="false"
|
android:enabled="false"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:icon="@mipmap/launcher1"
|
android:icon="@mipmap/launcher1"
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
</activity-alias>
|
</activity-alias>
|
||||||
<!-- 图标2 -->
|
<!-- 图标2 -->
|
||||||
<activity-alias
|
<activity-alias
|
||||||
android:name=".ui.welcome.Launcher2"
|
android:name=".Launcher2"
|
||||||
android:enabled="false"
|
android:enabled="false"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:icon="@mipmap/launcher2"
|
android:icon="@mipmap/launcher2"
|
||||||
@@ -59,7 +59,7 @@
|
|||||||
</activity-alias>
|
</activity-alias>
|
||||||
<!-- 图标3 -->
|
<!-- 图标3 -->
|
||||||
<activity-alias
|
<activity-alias
|
||||||
android:name=".ui.welcome.Launcher3"
|
android:name=".Launcher3"
|
||||||
android:enabled="false"
|
android:enabled="false"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:icon="@mipmap/launcher3"
|
android:icon="@mipmap/launcher3"
|
||||||
@@ -72,7 +72,7 @@
|
|||||||
</activity-alias>
|
</activity-alias>
|
||||||
<!-- 图标4 -->
|
<!-- 图标4 -->
|
||||||
<activity-alias
|
<activity-alias
|
||||||
android:name=".ui.welcome.Launcher4"
|
android:name=".Launcher4"
|
||||||
android:enabled="false"
|
android:enabled="false"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:icon="@mipmap/launcher4"
|
android:icon="@mipmap/launcher4"
|
||||||
@@ -85,7 +85,7 @@
|
|||||||
</activity-alias>
|
</activity-alias>
|
||||||
<!-- 图标5 -->
|
<!-- 图标5 -->
|
||||||
<activity-alias
|
<activity-alias
|
||||||
android:name=".ui.welcome.Launcher5"
|
android:name=".Launcher5"
|
||||||
android:enabled="false"
|
android:enabled="false"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:icon="@mipmap/launcher5"
|
android:icon="@mipmap/launcher5"
|
||||||
@@ -98,7 +98,7 @@
|
|||||||
</activity-alias>
|
</activity-alias>
|
||||||
<!-- 图标6 -->
|
<!-- 图标6 -->
|
||||||
<activity-alias
|
<activity-alias
|
||||||
android:name=".ui.welcome.Launcher6"
|
android:name=".Launcher6"
|
||||||
android:enabled="false"
|
android:enabled="false"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:icon="@mipmap/launcher6"
|
android:icon="@mipmap/launcher6"
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ abstract class BaseActivity<VB : ViewBinding>(
|
|||||||
return super.onCreateView(parent, name, context, attrs)
|
return super.onCreateView(parent, name, context, attrs)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("ObsoleteSdkInt")
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
applyTheme()
|
applyTheme()
|
||||||
window.decorView.disableAutoFill()
|
window.decorView.disableAutoFill()
|
||||||
@@ -84,10 +84,8 @@ abstract class BaseActivity<VB : ViewBinding>(
|
|||||||
//setupSystemBar()
|
//setupSystemBar()
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
upBackgroundImage()
|
upBackgroundImage()
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
findViewById<AppBarLayout>(R.id.title_bar)
|
||||||
findViewById<AppBarLayout>(R.id.title_bar)
|
//?.onMultiWindowModeChanged(isInMultiWindowMode, fullScreen)
|
||||||
//?.onMultiWindowModeChanged(isInMultiWindowMode, fullScreen)
|
|
||||||
}
|
|
||||||
onBackPressedDispatcher.addCallback(this) {
|
onBackPressedDispatcher.addCallback(this) {
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
@@ -137,7 +135,10 @@ abstract class BaseActivity<VB : ViewBinding>(
|
|||||||
|
|
||||||
open fun applyTheme() {
|
open fun applyTheme() {
|
||||||
when (getPrefString("app_theme", "0")) {
|
when (getPrefString("app_theme", "0")) {
|
||||||
"0" -> DynamicColors.applyToActivitiesIfAvailable(application)
|
"0" ->
|
||||||
|
{
|
||||||
|
DynamicColors.applyToActivitiesIfAvailable(application)
|
||||||
|
}
|
||||||
"1" -> setTheme(R.style.Theme_Base_GR)
|
"1" -> setTheme(R.style.Theme_Base_GR)
|
||||||
"2" -> setTheme(R.style.Theme_Base_Lemon)
|
"2" -> setTheme(R.style.Theme_Base_Lemon)
|
||||||
"3" -> setTheme(R.style.Theme_Base_WH)
|
"3" -> setTheme(R.style.Theme_Base_WH)
|
||||||
|
|||||||
@@ -15,12 +15,18 @@ import splitties.init.appCtx
|
|||||||
object LauncherIconHelp {
|
object LauncherIconHelp {
|
||||||
private val packageManager: PackageManager = appCtx.packageManager
|
private val packageManager: PackageManager = appCtx.packageManager
|
||||||
private val componentNames = arrayListOf(
|
private val componentNames = arrayListOf(
|
||||||
ComponentName(appCtx, Launcher1::class.java.name),
|
ComponentName(appCtx.packageName, "${appCtx.packageName}.Launcher1"),
|
||||||
ComponentName(appCtx, Launcher2::class.java.name),
|
ComponentName(appCtx.packageName, "${appCtx.packageName}.Launcher2"),
|
||||||
ComponentName(appCtx, Launcher3::class.java.name),
|
ComponentName(appCtx.packageName, "${appCtx.packageName}.Launcher3"),
|
||||||
ComponentName(appCtx, Launcher4::class.java.name),
|
ComponentName(appCtx.packageName, "${appCtx.packageName}.Launcher4"),
|
||||||
ComponentName(appCtx, Launcher5::class.java.name),
|
ComponentName(appCtx.packageName, "${appCtx.packageName}.Launcher5"),
|
||||||
ComponentName(appCtx, Launcher6::class.java.name)
|
ComponentName(appCtx.packageName, "${appCtx.packageName}.Launcher6")
|
||||||
|
)
|
||||||
|
|
||||||
|
// 主Activity的ComponentName
|
||||||
|
private val mainActivity = ComponentName(
|
||||||
|
appCtx.packageName,
|
||||||
|
"${appCtx.packageName}.ui.main.MainActivity"
|
||||||
)
|
)
|
||||||
|
|
||||||
fun changeIcon(icon: String?) {
|
fun changeIcon(icon: String?) {
|
||||||
@@ -29,37 +35,79 @@ object LauncherIconHelp {
|
|||||||
appCtx.toastOnUi(R.string.change_icon_error)
|
appCtx.toastOnUi(R.string.change_icon_error)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var hasEnabled = false
|
|
||||||
componentNames.forEach {
|
try {
|
||||||
if (icon.equals(it.className.substringAfterLast("."), true)) {
|
// 首先禁用主Activity的启动器intent
|
||||||
hasEnabled = true
|
disableMainActivityLauncher()
|
||||||
//启用
|
|
||||||
|
// 然后处理所有别名
|
||||||
|
var matched = false
|
||||||
|
componentNames.forEach {
|
||||||
|
val aliasName = it.className.substringAfterLast(".")
|
||||||
|
if (icon.equals(aliasName, ignoreCase = true)) {
|
||||||
|
matched = true
|
||||||
|
packageManager.setComponentEnabledSetting(
|
||||||
|
it,
|
||||||
|
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
|
||||||
|
PackageManager.DONT_KILL_APP
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
packageManager.setComponentEnabledSetting(
|
||||||
|
it,
|
||||||
|
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
|
||||||
|
PackageManager.DONT_KILL_APP
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!matched) {
|
||||||
|
enableMainActivityLauncher()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 通知用户图标已更改
|
||||||
|
appCtx.toastOnUi(R.string.change_icon_success)
|
||||||
|
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
|
appCtx.toastOnUi(R.string.change_icon_error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 禁用主Activity的启动器功能
|
||||||
|
private fun disableMainActivityLauncher() {
|
||||||
|
try {
|
||||||
|
// 获取当前组件状态
|
||||||
|
val state = packageManager.getComponentEnabledSetting(mainActivity)
|
||||||
|
|
||||||
|
// 如果已经禁用,不需要再次操作
|
||||||
|
if (state != PackageManager.COMPONENT_ENABLED_STATE_DISABLED) {
|
||||||
packageManager.setComponentEnabledSetting(
|
packageManager.setComponentEnabledSetting(
|
||||||
it,
|
mainActivity,
|
||||||
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
|
|
||||||
PackageManager.DONT_KILL_APP
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
//禁用
|
|
||||||
packageManager.setComponentEnabledSetting(
|
|
||||||
it,
|
|
||||||
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
|
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
|
||||||
PackageManager.DONT_KILL_APP
|
PackageManager.DONT_KILL_APP
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
if (hasEnabled) {
|
}
|
||||||
packageManager.setComponentEnabledSetting(
|
|
||||||
ComponentName(appCtx, WelcomeActivity::class.java.name),
|
// 启用主Activity的启动器功能
|
||||||
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
|
private fun enableMainActivityLauncher() {
|
||||||
PackageManager.DONT_KILL_APP
|
try {
|
||||||
)
|
// 获取当前组件状态
|
||||||
} else {
|
val state = packageManager.getComponentEnabledSetting(mainActivity)
|
||||||
packageManager.setComponentEnabledSetting(
|
|
||||||
ComponentName(appCtx, WelcomeActivity::class.java.name),
|
// 如果已经启用,不需要再次操作
|
||||||
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
|
if (state != PackageManager.COMPONENT_ENABLED_STATE_ENABLED) {
|
||||||
PackageManager.DONT_KILL_APP
|
packageManager.setComponentEnabledSetting(
|
||||||
)
|
mainActivity,
|
||||||
|
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
|
||||||
|
PackageManager.DONT_KILL_APP
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,7 +88,7 @@ class ThemeCardPreference(context: Context, attrs: AttributeSet) : Preference(co
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val themeResIdMap = mapOf(
|
private val themeResIdMap = mapOf(
|
||||||
"0" to R.style.Base_AppTheme,
|
"0" to R.style.Theme_Base_Dycolors,
|
||||||
"1" to R.style.Theme_Base_GR,
|
"1" to R.style.Theme_Base_GR,
|
||||||
"2" to R.style.Theme_Base_Lemon,
|
"2" to R.style.Theme_Base_Lemon,
|
||||||
"3" to R.style.Theme_Base_WH,
|
"3" to R.style.Theme_Base_WH,
|
||||||
@@ -106,7 +106,7 @@ class ThemeCardPreference(context: Context, attrs: AttributeSet) : Preference(co
|
|||||||
com.google.android.material.R.attr.colorPrimary,
|
com.google.android.material.R.attr.colorPrimary,
|
||||||
com.google.android.material.R.attr.colorOnSurfaceVariant,
|
com.google.android.material.R.attr.colorOnSurfaceVariant,
|
||||||
com.google.android.material.R.attr.colorSurface,
|
com.google.android.material.R.attr.colorSurface,
|
||||||
com.google.android.material.R.attr.colorPrimaryFixed,
|
com.google.android.material.R.attr.colorSecondaryContainer,
|
||||||
)
|
)
|
||||||
|
|
||||||
val ta = themedContext.obtainStyledAttributes(attrs)
|
val ta = themedContext.obtainStyledAttributes(attrs)
|
||||||
|
|||||||
@@ -83,7 +83,6 @@ class TxtTocRuleDialog() : BaseDialogFragment(R.layout.dialog_toc_regex),
|
|||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
setLayout(0.9f, 0.8f)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ import splitties.views.bottomPadding
|
|||||||
import kotlin.coroutines.resume
|
import kotlin.coroutines.resume
|
||||||
import kotlin.coroutines.suspendCoroutine
|
import kotlin.coroutines.suspendCoroutine
|
||||||
import androidx.core.view.get
|
import androidx.core.view.get
|
||||||
|
import io.legato.kazusa.ui.welcome.WelcomeActivity
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 主界面
|
* 主界面
|
||||||
@@ -413,7 +414,7 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
private inner class TabFragmentPageAdapter(fm: FragmentManager) :
|
private inner class TabFragmentPageAdapter(fm: FragmentManager) :
|
||||||
FragmentStatePagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {
|
FragmentStatePagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {
|
||||||
|
|
||||||
|
|||||||
@@ -19,5 +19,4 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:menu="@menu/main_bnv" />
|
app:menu="@menu/main_bnv" />
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@@ -36,7 +36,6 @@
|
|||||||
android:layout_marginRight="16dp"
|
android:layout_marginRight="16dp"
|
||||||
android:padding="12dp"
|
android:padding="12dp"
|
||||||
android:text="@string/cancel"
|
android:text="@string/cancel"
|
||||||
android:textColor="@color/secondaryText"
|
|
||||||
tools:ignore="RtlHardcoded" />
|
tools:ignore="RtlHardcoded" />
|
||||||
|
|
||||||
<io.legato.kazusa.ui.widget.text.AccentTextView
|
<io.legato.kazusa.ui.widget.text.AccentTextView
|
||||||
|
|||||||
@@ -3,8 +3,7 @@
|
|||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content">
|
||||||
android:padding="16dp">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
@@ -1217,4 +1217,5 @@
|
|||||||
<string name="manga_color_filter">滤镜</string>
|
<string name="manga_color_filter">滤镜</string>
|
||||||
<string name="hide_manga_title">隐藏漫画列表标题</string>
|
<string name="hide_manga_title">隐藏漫画列表标题</string>
|
||||||
<string name="refresh_explore">刷新发现</string>
|
<string name="refresh_explore">刷新发现</string>
|
||||||
|
<string name="change_icon_success">图标已修改</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1220,4 +1220,5 @@
|
|||||||
<string name="refresh_explore">刷新发现</string>
|
<string name="refresh_explore">刷新发现</string>
|
||||||
<string name="ungroup">未分组</string>
|
<string name="ungroup">未分组</string>
|
||||||
<string name="dynamic_colors">动态取色</string>
|
<string name="dynamic_colors">动态取色</string>
|
||||||
|
<string name="change_icon_success">图标已修改</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -31,6 +31,10 @@
|
|||||||
<item name="alertDialogTheme">@style/AppTheme.AlertDialog</item>
|
<item name="alertDialogTheme">@style/AppTheme.AlertDialog</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="Theme.Base.Dycolors" parent="Theme.Material3.DynamicColors.DayNight.NoActionBar">
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="Theme.Base.GR" parent="Base.AppTheme">
|
<style name="Theme.Base.GR" parent="Base.AppTheme">
|
||||||
<item name="colorPrimary">@color/md_theme_primary</item>
|
<item name="colorPrimary">@color/md_theme_primary</item>
|
||||||
<item name="colorOnPrimary">@color/md_theme_onPrimary</item>
|
<item name="colorOnPrimary">@color/md_theme_onPrimary</item>
|
||||||
@@ -49,6 +53,7 @@
|
|||||||
<item name="colorErrorContainer">@color/md_theme_errorContainer</item>
|
<item name="colorErrorContainer">@color/md_theme_errorContainer</item>
|
||||||
<item name="colorOnErrorContainer">@color/md_theme_onErrorContainer</item>
|
<item name="colorOnErrorContainer">@color/md_theme_onErrorContainer</item>
|
||||||
<item name="android:colorBackground">@color/md_theme_background</item>
|
<item name="android:colorBackground">@color/md_theme_background</item>
|
||||||
|
<item name="android:textColor">@color/md_theme_onSurface</item>
|
||||||
<item name="colorOnBackground">@color/md_theme_onBackground</item>
|
<item name="colorOnBackground">@color/md_theme_onBackground</item>
|
||||||
<item name="colorSurface">@color/md_theme_surface</item>
|
<item name="colorSurface">@color/md_theme_surface</item>
|
||||||
<item name="colorOnSurface">@color/md_theme_onSurface</item>
|
<item name="colorOnSurface">@color/md_theme_onSurface</item>
|
||||||
@@ -98,6 +103,7 @@
|
|||||||
<item name="colorErrorContainer">@color/wh_theme_errorContainer</item>
|
<item name="colorErrorContainer">@color/wh_theme_errorContainer</item>
|
||||||
<item name="colorOnErrorContainer">@color/wh_theme_onErrorContainer</item>
|
<item name="colorOnErrorContainer">@color/wh_theme_onErrorContainer</item>
|
||||||
<item name="android:colorBackground">@color/wh_theme_background</item>
|
<item name="android:colorBackground">@color/wh_theme_background</item>
|
||||||
|
<item name="android:textColor">@color/wh_theme_onSurface</item>
|
||||||
<item name="colorOnBackground">@color/wh_theme_onBackground</item>
|
<item name="colorOnBackground">@color/wh_theme_onBackground</item>
|
||||||
<item name="colorSurface">@color/wh_theme_surface</item>
|
<item name="colorSurface">@color/wh_theme_surface</item>
|
||||||
<item name="colorOnSurface">@color/wh_theme_onSurface</item>
|
<item name="colorOnSurface">@color/wh_theme_onSurface</item>
|
||||||
@@ -147,6 +153,7 @@
|
|||||||
<item name="colorErrorContainer">@color/lemon_theme_errorContainer</item>
|
<item name="colorErrorContainer">@color/lemon_theme_errorContainer</item>
|
||||||
<item name="colorOnErrorContainer">@color/lemon_theme_onErrorContainer</item>
|
<item name="colorOnErrorContainer">@color/lemon_theme_onErrorContainer</item>
|
||||||
<item name="android:colorBackground">@color/lemon_theme_background</item>
|
<item name="android:colorBackground">@color/lemon_theme_background</item>
|
||||||
|
<item name="android:textColor">@color/lemon_theme_onSurface</item>
|
||||||
<item name="colorOnBackground">@color/lemon_theme_onBackground</item>
|
<item name="colorOnBackground">@color/lemon_theme_onBackground</item>
|
||||||
<item name="colorSurface">@color/lemon_theme_surface</item>
|
<item name="colorSurface">@color/lemon_theme_surface</item>
|
||||||
<item name="colorOnSurface">@color/lemon_theme_onSurface</item>
|
<item name="colorOnSurface">@color/lemon_theme_onSurface</item>
|
||||||
|
|||||||
Reference in New Issue
Block a user