@@ -25,7 +25,6 @@ import android.widget.TextView
2525import androidx.appcompat.widget.AppCompatImageButton
2626import androidx.core.content.ContextCompat
2727import androidx.core.graphics.toColorInt
28- import com.github.creativecodecat.components.views.FontBottomSheetDialogLocked
2928import com.github.codeworkscreativehub.common.getCpuBatteryInfo
3029import com.github.codeworkscreativehub.common.getLocalizedString
3130import com.github.codeworkscreativehub.common.getRamInfo
@@ -42,6 +41,7 @@ import com.github.codeworkscreativehub.mlauncher.helper.themeDownloadButton
4241import com.github.codeworkscreativehub.mlauncher.helper.utils.AppReloader
4342import com.github.codeworkscreativehub.mlauncher.helper.wordofthedayDownloadButton
4443import com.github.codeworkscreativehub.mlauncher.services.HapticFeedbackService
44+ import com.github.creativecodecat.components.views.FontBottomSheetDialogLocked
4545import com.google.android.material.dialog.MaterialAlertDialogBuilder
4646
4747class DialogManager (val context : Context , val activity : Activity ) {
@@ -106,6 +106,25 @@ class DialogManager(val context: Context, val activity: Activity) {
106106 backupRestoreBottomSheet?.show() // ✅ Correct method call
107107 }
108108
109+ // Function to handle the Clear Data action, with a confirmation dialog
110+ private fun confirmClearData () {
111+ MaterialAlertDialogBuilder (context)
112+ .setTitle(getLocalizedString(R .string.advanced_settings_backup_restore_clear_title))
113+ .setMessage(getLocalizedString(R .string.advanced_settings_backup_restore_clear_description))
114+ .setPositiveButton(getLocalizedString(R .string.advanced_settings_clear_yes)) { _, _ ->
115+ clearData()
116+ }
117+ .setNegativeButton(getLocalizedString(R .string.advanced_settings_clear_no), null )
118+ .show()
119+ }
120+
121+ private fun clearData () {
122+ prefs = Prefs (context)
123+ prefs.clear()
124+
125+ AppReloader .restartApp(context)
126+ }
127+
109128 var saveLoadThemeBottomSheet: FontBottomSheetDialogLocked ? = null
110129
111130 fun showSaveLoadThemeBottomSheet () {
@@ -157,13 +176,54 @@ class DialogManager(val context: Context, val activity: Activity) {
157176 (activity as MainActivity ).restoreThemeBackup()
158177 })
159178
179+ // Add Clear Option
180+ layout.addView(createItem(getLocalizedString(R .string.advanced_settings_theme_clear)) {
181+ confirmClearTheme()
182+ })
183+
160184 // Create and show the LockedBottomSheetDialog
161185 saveLoadThemeBottomSheet = FontBottomSheetDialogLocked (context).apply {
162186 setContentView(layout)
163187 }
164188 saveLoadThemeBottomSheet?.show()
165189 }
166190
191+ private fun confirmClearTheme () {
192+ MaterialAlertDialogBuilder (context)
193+ .setTitle(getLocalizedString(R .string.advanced_settings_theme_clear_title))
194+ .setMessage(getLocalizedString(R .string.advanced_settings_theme_clear_description))
195+ .setPositiveButton(getLocalizedString(R .string.advanced_settings_clear_yes)) { _, _ ->
196+ clearTheme()
197+ }
198+ .setNegativeButton(getLocalizedString(R .string.advanced_settings_clear_no), null )
199+ .show()
200+ }
201+
202+ fun clearTheme () {
203+ val prefs = Prefs (context)
204+ val keys = listOf (
205+ " BACKGROUND_COLOR" ,
206+ " APP_COLOR" ,
207+ " DATE_COLOR" ,
208+ " ALARM_CLOCK_COLOR" ,
209+ " CLOCK_COLOR" ,
210+ " BATTERY_COLOR" ,
211+ " DAILY_WORD_COLOR" ,
212+ " NOTES_BACKGROUND_COLOR" ,
213+ " BUBBLE_BACKGROUND_COLOR" ,
214+ " BUBBLE_MESSAGE_COLOR" ,
215+ " BUBBLE_TIMEDATE_COLOR" ,
216+ " BUBBLE_CATEGORY_COLOR" ,
217+ " INPUT_MESSAGE_COLOR" ,
218+ " INPUT_MESSAGEHINT_COLOR"
219+
220+ )
221+ keys.forEach { prefs.remove(it) }
222+ if (context is Activity ) {
223+ context.recreate()
224+ }
225+ }
226+
167227 var saveDownloadWOTDBottomSheet: FontBottomSheetDialogLocked ? = null
168228
169229 fun showSaveDownloadWOTDBottomSheet () {
@@ -211,31 +271,35 @@ class DialogManager(val context: Context, val activity: Activity) {
211271 (activity as MainActivity ).restoreWordsBackup()
212272 })
213273
274+ // Add Clear Option
275+ layout.addView(createItem(getLocalizedString(R .string.advanced_settings_wotd_clear)) {
276+ confirmClearWOTD()
277+ })
278+
214279 // Create and show the LockedBottomSheetDialog
215280 saveDownloadWOTDBottomSheet = FontBottomSheetDialogLocked (context).apply {
216281 setContentView(layout)
217282 }
218283 saveDownloadWOTDBottomSheet?.show()
219284 }
220285
221-
222- // Function to handle the Clear Data action, with a confirmation dialog
223- private fun confirmClearData () {
286+ private fun confirmClearWOTD () {
224287 MaterialAlertDialogBuilder (context)
225- .setTitle(getLocalizedString(R .string.advanced_settings_backup_restore_clear_title ))
226- .setMessage(getLocalizedString(R .string.advanced_settings_backup_restore_clear_description ))
227- .setPositiveButton(getLocalizedString(R .string.advanced_settings_backup_restore_clear_yes )) { _, _ ->
228- clearData ()
288+ .setTitle(getLocalizedString(R .string.advanced_settings_wotd_clear_title ))
289+ .setMessage(getLocalizedString(R .string.advanced_settings_wotd_clear_description ))
290+ .setPositiveButton(getLocalizedString(R .string.advanced_settings_clear_yes )) { _, _ ->
291+ clearWOTD ()
229292 }
230- .setNegativeButton(getLocalizedString(R .string.advanced_settings_backup_restore_clear_no ), null )
293+ .setNegativeButton(getLocalizedString(R .string.advanced_settings_clear_no ), null )
231294 .show()
232295 }
233296
234- private fun clearData () {
235- prefs = Prefs (context)
236- prefs.clear()
237-
238- AppReloader .restartApp(context)
297+ fun clearWOTD () {
298+ val prefs = Prefs (context)
299+ prefs.remove(" WORD_LIST" )
300+ if (context is Activity ) {
301+ context.recreate()
302+ }
239303 }
240304
241305 var sliderBottomSheet: FontBottomSheetDialogLocked ? = null
0 commit comments