From e000607d7158e9feaea266325fe198a7e9094db8 Mon Sep 17 00:00:00 2001 From: LoveSy Date: Tue, 3 Mar 2026 12:57:47 +0800 Subject: [PATCH] Remove Theme screen and related dead code Theme selection is no longer needed with Compose theming. Remove ThemeFragment, ThemeViewModel, DarkThemeDialog, TappableHeadlineItem, and associated XML layouts. Remove theme navigation from Settings. Made-with: Cursor --- .../magisk/dialog/DarkThemeDialog.kt | 41 ---- .../magisk/ui/settings/SettingsScreen.kt | 5 - .../magisk/ui/settings/SettingsViewModel.kt | 4 - .../magisk/ui/theme/ThemeFragment.kt | 68 ------- .../magisk/ui/theme/ThemeViewModel.kt | 23 --- .../magisk/view/TappableHeadlineItem.kt | 30 --- .../main/res/layout/fragment_theme_md2.xml | 44 ----- .../res/layout/item_tappable_headline.xml | 67 ------- app/apk/src/main/res/layout/item_theme.xml | 183 ------------------ .../main/res/layout/item_theme_container.xml | 13 -- app/apk/src/main/res/navigation/main.xml | 14 -- 11 files changed, 492 deletions(-) delete mode 100644 app/apk/src/main/java/com/topjohnwu/magisk/dialog/DarkThemeDialog.kt delete mode 100644 app/apk/src/main/java/com/topjohnwu/magisk/ui/theme/ThemeFragment.kt delete mode 100644 app/apk/src/main/java/com/topjohnwu/magisk/ui/theme/ThemeViewModel.kt delete mode 100644 app/apk/src/main/java/com/topjohnwu/magisk/view/TappableHeadlineItem.kt delete mode 100644 app/apk/src/main/res/layout/fragment_theme_md2.xml delete mode 100644 app/apk/src/main/res/layout/item_tappable_headline.xml delete mode 100644 app/apk/src/main/res/layout/item_theme.xml delete mode 100644 app/apk/src/main/res/layout/item_theme_container.xml diff --git a/app/apk/src/main/java/com/topjohnwu/magisk/dialog/DarkThemeDialog.kt b/app/apk/src/main/java/com/topjohnwu/magisk/dialog/DarkThemeDialog.kt deleted file mode 100644 index 68e951486..000000000 --- a/app/apk/src/main/java/com/topjohnwu/magisk/dialog/DarkThemeDialog.kt +++ /dev/null @@ -1,41 +0,0 @@ -package com.topjohnwu.magisk.dialog - -import android.app.Activity -import androidx.appcompat.app.AppCompatDelegate -import com.topjohnwu.magisk.R -import com.topjohnwu.magisk.arch.UIActivity -import com.topjohnwu.magisk.core.Config -import com.topjohnwu.magisk.events.DialogBuilder -import com.topjohnwu.magisk.view.MagiskDialog -import com.topjohnwu.magisk.core.R as CoreR - -class DarkThemeDialog : DialogBuilder { - - override fun build(dialog: MagiskDialog) { - val activity = dialog.ownerActivity!! - dialog.apply { - setTitle(CoreR.string.settings_dark_mode_title) - setMessage(CoreR.string.settings_dark_mode_message) - setButton(MagiskDialog.ButtonType.POSITIVE) { - text = CoreR.string.settings_dark_mode_light - icon = R.drawable.ic_day - onClick { selectTheme(AppCompatDelegate.MODE_NIGHT_NO, activity) } - } - setButton(MagiskDialog.ButtonType.NEUTRAL) { - text = CoreR.string.settings_dark_mode_system - icon = R.drawable.ic_day_night - onClick { selectTheme(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM, activity) } - } - setButton(MagiskDialog.ButtonType.NEGATIVE) { - text = CoreR.string.settings_dark_mode_dark - icon = R.drawable.ic_night - onClick { selectTheme(AppCompatDelegate.MODE_NIGHT_YES, activity) } - } - } - } - - private fun selectTheme(mode: Int, activity: Activity) { - Config.darkTheme = mode - (activity as UIActivity<*>).delegate.localNightMode = mode - } -} diff --git a/app/apk/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsScreen.kt b/app/apk/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsScreen.kt index 5753639fc..d1369e8e2 100644 --- a/app/apk/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsScreen.kt +++ b/app/apk/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsScreen.kt @@ -78,11 +78,6 @@ private fun CustomizationSection(viewModel: SettingsViewModel) { SmallTitle(text = stringResource(CoreR.string.settings_customization)) Card(modifier = Modifier.fillMaxWidth()) { - SuperArrow( - title = stringResource(CoreR.string.section_theme), - onClick = { viewModel.navigateToTheme() } - ) - if (LocaleSetting.useLocaleManager) { val locale = LocaleSetting.instance.appLocale val summary = locale?.getDisplayName(locale) ?: stringResource(CoreR.string.system_default) diff --git a/app/apk/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsViewModel.kt b/app/apk/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsViewModel.kt index 054ecfa91..cc40ce5ba 100644 --- a/app/apk/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsViewModel.kt +++ b/app/apk/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsViewModel.kt @@ -27,10 +27,6 @@ class SettingsViewModel : BaseViewModel() { val zygiskMismatch get() = Config.zygisk != Info.isZygiskEnabled - fun navigateToTheme() { - SettingsFragmentDirections.actionSettingsFragmentToThemeFragment().navigate() - } - fun navigateToDenyList() { SettingsFragmentDirections.actionSettingsFragmentToDenyFragment().navigate() } diff --git a/app/apk/src/main/java/com/topjohnwu/magisk/ui/theme/ThemeFragment.kt b/app/apk/src/main/java/com/topjohnwu/magisk/ui/theme/ThemeFragment.kt deleted file mode 100644 index f66aad6bc..000000000 --- a/app/apk/src/main/java/com/topjohnwu/magisk/ui/theme/ThemeFragment.kt +++ /dev/null @@ -1,68 +0,0 @@ -package com.topjohnwu.magisk.ui.theme - -import android.os.Bundle -import android.view.ContextThemeWrapper -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.widget.FrameLayout -import com.topjohnwu.magisk.BR -import com.topjohnwu.magisk.R -import com.topjohnwu.magisk.arch.BaseFragment -import com.topjohnwu.magisk.arch.viewModel -import com.topjohnwu.magisk.databinding.FragmentThemeMd2Binding -import com.topjohnwu.magisk.databinding.ItemThemeBindingImpl -import com.topjohnwu.magisk.core.R as CoreR - -class ThemeFragment : BaseFragment() { - - override val layoutRes = R.layout.fragment_theme_md2 - override val viewModel by viewModel() - - private fun Array.paired(): List> { - val iterator = iterator() - if (!iterator.hasNext()) return emptyList() - val result = mutableListOf>() - while (iterator.hasNext()) { - val a = iterator.next() - val b = if (iterator.hasNext()) iterator.next() else null - result.add(a to b) - } - return result - } - - override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle? - ): View { - super.onCreateView(inflater, container, savedInstanceState) - - for ((a, b) in Theme.values().paired()) { - val c = inflater.inflate(R.layout.item_theme_container, null, false) - val left = c.findViewById(R.id.left) - val right = c.findViewById(R.id.right) - - for ((theme, view) in listOf(a to left, b to right)) { - theme ?: continue - val themed = ContextThemeWrapper(activity, theme.themeRes) - ItemThemeBindingImpl.inflate(LayoutInflater.from(themed), view, true).also { - it.setVariable(BR.viewModel, viewModel) - it.setVariable(BR.theme, theme) - it.lifecycleOwner = viewLifecycleOwner - } - } - - binding.themeContainer.addView(c) - } - - return binding.root - } - - override fun onStart() { - super.onStart() - - activity?.title = getString(CoreR.string.section_theme) - } - -} diff --git a/app/apk/src/main/java/com/topjohnwu/magisk/ui/theme/ThemeViewModel.kt b/app/apk/src/main/java/com/topjohnwu/magisk/ui/theme/ThemeViewModel.kt deleted file mode 100644 index 386099406..000000000 --- a/app/apk/src/main/java/com/topjohnwu/magisk/ui/theme/ThemeViewModel.kt +++ /dev/null @@ -1,23 +0,0 @@ -package com.topjohnwu.magisk.ui.theme - -import com.topjohnwu.magisk.arch.BaseViewModel -import com.topjohnwu.magisk.core.Config -import com.topjohnwu.magisk.dialog.DarkThemeDialog -import com.topjohnwu.magisk.events.RecreateEvent -import com.topjohnwu.magisk.view.TappableHeadlineItem - -class ThemeViewModel : BaseViewModel(), TappableHeadlineItem.Listener { - - val themeHeadline = TappableHeadlineItem.ThemeMode - - override fun onItemPressed(item: TappableHeadlineItem) = when (item) { - is TappableHeadlineItem.ThemeMode -> DarkThemeDialog().show() - } - - fun saveTheme(theme: Theme) { - if (!theme.isSelected) { - Config.themeOrdinal = theme.ordinal - RecreateEvent().publish() - } - } -} diff --git a/app/apk/src/main/java/com/topjohnwu/magisk/view/TappableHeadlineItem.kt b/app/apk/src/main/java/com/topjohnwu/magisk/view/TappableHeadlineItem.kt deleted file mode 100644 index 4fbd6d967..000000000 --- a/app/apk/src/main/java/com/topjohnwu/magisk/view/TappableHeadlineItem.kt +++ /dev/null @@ -1,30 +0,0 @@ -package com.topjohnwu.magisk.view - -import com.topjohnwu.magisk.R -import com.topjohnwu.magisk.databinding.DiffItem -import com.topjohnwu.magisk.databinding.RvItem -import com.topjohnwu.magisk.core.R as CoreR - -sealed class TappableHeadlineItem : RvItem(), DiffItem { - - abstract val title: Int - abstract val icon: Int - - override val layoutRes = R.layout.item_tappable_headline - - // --- listener - - interface Listener { - - fun onItemPressed(item: TappableHeadlineItem) - - } - - // --- objects - - object ThemeMode : TappableHeadlineItem() { - override val title = CoreR.string.settings_dark_mode_title - override val icon = R.drawable.ic_day_night - } - -} diff --git a/app/apk/src/main/res/layout/fragment_theme_md2.xml b/app/apk/src/main/res/layout/fragment_theme_md2.xml deleted file mode 100644 index bf4babb35..000000000 --- a/app/apk/src/main/res/layout/fragment_theme_md2.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/apk/src/main/res/layout/item_tappable_headline.xml b/app/apk/src/main/res/layout/item_tappable_headline.xml deleted file mode 100644 index caecf865c..000000000 --- a/app/apk/src/main/res/layout/item_tappable_headline.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/apk/src/main/res/layout/item_theme.xml b/app/apk/src/main/res/layout/item_theme.xml deleted file mode 100644 index 23ef7a1ba..000000000 --- a/app/apk/src/main/res/layout/item_theme.xml +++ /dev/null @@ -1,183 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/apk/src/main/res/layout/item_theme_container.xml b/app/apk/src/main/res/layout/item_theme_container.xml deleted file mode 100644 index 9f227400f..000000000 --- a/app/apk/src/main/res/layout/item_theme_container.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - diff --git a/app/apk/src/main/res/navigation/main.xml b/app/apk/src/main/res/navigation/main.xml index b9d6897ff..7ed357a57 100644 --- a/app/apk/src/main/res/navigation/main.xml +++ b/app/apk/src/main/res/navigation/main.xml @@ -76,14 +76,6 @@ android:name="com.topjohnwu.magisk.ui.settings.SettingsFragment" android:label="SettingsFragment"> - - - -