Skip to content

Commit

Permalink
Refactor: Re-Enabled 3 fonts that was not working.
Browse files Browse the repository at this point in the history
  • Loading branch information
CreativeCodeCat committed Dec 4, 2024
1 parent 2d49a8b commit 8ae80d3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import com.github.droidworksstudio.launcher.utils.Constants
class FontAdapter(
context: Context,
private val items: Array<Constants.Fonts>,
private val itemStrings: Array<String>
private val itemStrings: Array<String>,
) : ArrayAdapter<String>(context, android.R.layout.simple_list_item_1, itemStrings) {

override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@ 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) {
val packageManager = context.packageManager
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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,13 @@ object Constants {
Bitter,
Dotness,
DroidSans,
GreatVibes,
Lato,
Lobster,
Merriweather,
Montserrat,
OpenSans,
Pacifico,
Quicksand,
Raleway,
Roboto,
Expand All @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/nontranslatable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<string name="settings_font_bitter" translatable="false">Bitter</string>
<string name="settings_font_dotness" translatable="false">Dotness</string>
<string name="settings_font_droidsans" translatable="false">Droid Sans</string>
<string name="settings_font_greatvibes" translatable="false">Great Vibes</string>
<string name="settings_font_great_vibes" translatable="false">Great Vibes</string>
<string name="settings_font_lato" translatable="false">Lato</string>
<string name="settings_font_lobster" translatable="false">Lobster</string>
<string name="settings_font_merriweather" translatable="false">Merriweather</string>
Expand Down

0 comments on commit 8ae80d3

Please sign in to comment.