From 8ae80d36d6e8ce73b6162ca3db2c3e346f7f523e Mon Sep 17 00:00:00 2001 From: HeCodes2Much Date: Wed, 4 Dec 2024 13:16:06 +0000 Subject: [PATCH] Refactor: Re-Enabled 3 fonts that was not working. --- .../launcher/adapter/font/FontAdapter.kt | 8 ++++---- .../droidworksstudio/launcher/helper/AppReloader.kt | 10 ++++++---- .../launcher/ui/settings/SettingsLookFeelFragment.kt | 6 +----- .../droidworksstudio/launcher/utils/Constants.kt | 9 +++++++++ app/src/main/res/values/nontranslatable.xml | 2 +- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/adapter/font/FontAdapter.kt b/app/src/main/java/com/github/droidworksstudio/launcher/adapter/font/FontAdapter.kt index aa4b2bc3..7668022a 100644 --- a/app/src/main/java/com/github/droidworksstudio/launcher/adapter/font/FontAdapter.kt +++ b/app/src/main/java/com/github/droidworksstudio/launcher/adapter/font/FontAdapter.kt @@ -14,7 +14,7 @@ import com.github.droidworksstudio.launcher.utils.Constants class FontAdapter( context: Context, private val items: Array, - private val itemStrings: Array + private val itemStrings: Array, ) : ArrayAdapter(context, android.R.layout.simple_list_item_1, itemStrings) { override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { @@ -35,13 +35,13 @@ class FontAdapter( Constants.Fonts.Bitter -> ResourcesCompat.getFont(context, R.font.bitter) Constants.Fonts.Dotness -> ResourcesCompat.getFont(context, R.font.dotness) Constants.Fonts.DroidSans -> ResourcesCompat.getFont(context, R.font.open_sans) -// Constants.Fonts.GreatVibes -> ResourcesCompat.getFont(context, R.font.great_vibes) + Constants.Fonts.GreatVibes -> ResourcesCompat.getFont(context, R.font.great_vibes) Constants.Fonts.Lato -> ResourcesCompat.getFont(context, R.font.lato) -// Constants.Fonts.Lobster -> ResourcesCompat.getFont(context, R.font.lobster) + Constants.Fonts.Lobster -> ResourcesCompat.getFont(context, R.font.lobster) Constants.Fonts.Merriweather -> ResourcesCompat.getFont(context, R.font.merriweather) Constants.Fonts.Montserrat -> ResourcesCompat.getFont(context, R.font.montserrat) Constants.Fonts.OpenSans -> ResourcesCompat.getFont(context, R.font.open_sans) -// Constants.Fonts.Pacifico -> ResourcesCompat.getFont(context, R.font.pacifico) + Constants.Fonts.Pacifico -> ResourcesCompat.getFont(context, R.font.pacifico) Constants.Fonts.Quicksand -> ResourcesCompat.getFont(context, R.font.quicksand) Constants.Fonts.Raleway -> ResourcesCompat.getFont(context, R.font.raleway) Constants.Fonts.Roboto -> ResourcesCompat.getFont(context, R.font.roboto) diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/helper/AppReloader.kt b/app/src/main/java/com/github/droidworksstudio/launcher/helper/AppReloader.kt index f3c1d707..ec459864 100644 --- a/app/src/main/java/com/github/droidworksstudio/launcher/helper/AppReloader.kt +++ b/app/src/main/java/com/github/droidworksstudio/launcher/helper/AppReloader.kt @@ -4,6 +4,7 @@ import android.content.Context import android.content.Intent import android.os.Handler import android.os.Looper +import kotlin.system.exitProcess object AppReloader { fun restartApp(context: Context) { @@ -11,12 +12,13 @@ object AppReloader { val intent = packageManager.getLaunchIntentForPackage(context.packageName) val componentName = intent?.component val mainIntent = Intent.makeRestartActivityTask(componentName) - mainIntent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP - mainIntent.flags += Intent.FLAG_ACTIVITY_NEW_TASK - - // Delay the restart slightly to ensure all current activities are finished + + // Schedule the restart Handler(Looper.getMainLooper()).postDelayed({ context.startActivity(mainIntent) + // Kill the app process + android.os.Process.killProcess(android.os.Process.myPid()) + exitProcess(0) }, 250) } } \ No newline at end of file diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/ui/settings/SettingsLookFeelFragment.kt b/app/src/main/java/com/github/droidworksstudio/launcher/ui/settings/SettingsLookFeelFragment.kt index 78f6f507..8811d603 100644 --- a/app/src/main/java/com/github/droidworksstudio/launcher/ui/settings/SettingsLookFeelFragment.kt +++ b/app/src/main/java/com/github/droidworksstudio/launcher/ui/settings/SettingsLookFeelFragment.kt @@ -4,8 +4,6 @@ import android.content.Context import android.content.Intent import android.os.Build import android.os.Bundle -import android.os.Handler -import android.os.Looper import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -247,9 +245,7 @@ class SettingsLookFeelFragment : Fragment(), appHelper.triggerHapticFeedback(context, feedbackType) // Delay the restart slightly to ensure preferences are saved - Handler(Looper.getMainLooper()).postDelayed({ - AppReloader.restartApp(context) - }, 500) // Delay in milliseconds (e.g., 500ms) + AppReloader.restartApp(context) } // Assign the created dialog to launcherFontDialog diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/utils/Constants.kt b/app/src/main/java/com/github/droidworksstudio/launcher/utils/Constants.kt index a7a4d680..2a7d6321 100644 --- a/app/src/main/java/com/github/droidworksstudio/launcher/utils/Constants.kt +++ b/app/src/main/java/com/github/droidworksstudio/launcher/utils/Constants.kt @@ -229,10 +229,13 @@ object Constants { Bitter, Dotness, DroidSans, + GreatVibes, Lato, + Lobster, Merriweather, Montserrat, OpenSans, + Pacifico, Quicksand, Raleway, Roboto, @@ -244,10 +247,13 @@ object Constants { Bitter -> ResourcesCompat.getFont(context, R.font.bitter) Dotness -> ResourcesCompat.getFont(context, R.font.dotness) DroidSans -> ResourcesCompat.getFont(context, R.font.open_sans) + GreatVibes -> ResourcesCompat.getFont(context, R.font.great_vibes) Lato -> ResourcesCompat.getFont(context, R.font.lato) + Lobster -> ResourcesCompat.getFont(context, R.font.lobster) Merriweather -> ResourcesCompat.getFont(context, R.font.merriweather) Montserrat -> ResourcesCompat.getFont(context, R.font.montserrat) OpenSans -> ResourcesCompat.getFont(context, R.font.open_sans) + Pacifico -> ResourcesCompat.getFont(context, R.font.pacifico) Quicksand -> ResourcesCompat.getFont(context, R.font.quicksand) Raleway -> ResourcesCompat.getFont(context, R.font.raleway) Roboto -> ResourcesCompat.getFont(context, R.font.roboto) @@ -261,10 +267,13 @@ object Constants { Bitter -> context.getString(R.string.settings_font_bitter) Dotness -> context.getString(R.string.settings_font_dotness) DroidSans -> context.getString(R.string.settings_font_droidsans) + GreatVibes -> context.getString(R.string.settings_font_great_vibes) Lato -> context.getString(R.string.settings_font_lato) + Lobster -> context.getString(R.string.settings_font_lobster) Merriweather -> context.getString(R.string.settings_font_merriweather) Montserrat -> context.getString(R.string.settings_font_montserrat) OpenSans -> context.getString(R.string.settings_font_opensans) + Pacifico -> context.getString(R.string.settings_font_pacifico) Quicksand -> context.getString(R.string.settings_font_quicksand) Raleway -> context.getString(R.string.settings_font_raleway) Roboto -> context.getString(R.string.settings_font_roboto) diff --git a/app/src/main/res/values/nontranslatable.xml b/app/src/main/res/values/nontranslatable.xml index 57bef236..3e74c32c 100644 --- a/app/src/main/res/values/nontranslatable.xml +++ b/app/src/main/res/values/nontranslatable.xml @@ -31,7 +31,7 @@ Bitter Dotness Droid Sans - Great Vibes + Great Vibes Lato Lobster Merriweather