Skip to content

Commit

Permalink
support for custom fonts and general improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
queuejw committed Oct 28, 2024
1 parent f3f0904 commit 5639f33
Show file tree
Hide file tree
Showing 59 changed files with 1,235 additions and 263 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ MPL is still in development, but it already includes a range of features you mig

🎨 A design closely mimicking the original Windows Phone.

🌀 Animations that are as similar as possible to Windows Phone animations.
🌀 Animations that are as similar as possible to Windows Phone animations (almost :) ).

🌈 20 different colors to make your device unique and stylish.

Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ android {
applicationId "ru.dimon6018.metrolauncher"
minSdk 21
targetSdk 35
versionCode 55
versionName "1.0 Pre-Alpha 5.1.2.4"
versionCode 57
versionName "Exp. 7789"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled false
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@
android:name="ru.dimon6018.metrolauncher.content.settings.activities.AnimationSettingsActivity"
android:exported="true">
</activity>
<activity
android:name="ru.dimon6018.metrolauncher.content.settings.activities.FontsSettingsActivity"
android:exported="true">
</activity>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
Expand Down
23 changes: 22 additions & 1 deletion app/src/main/java/ru/dimon6018/metrolauncher/Application.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ import android.annotation.SuppressLint
import android.app.Activity
import android.app.Application
import android.content.pm.ActivityInfo
import android.graphics.Typeface
import android.os.Bundle
import com.google.android.material.color.DynamicColors
import ru.dimon6018.metrolauncher.content.bsod.BsodDetector
import ru.dimon6018.metrolauncher.content.data.Prefs
import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.getCustomBoldFont
import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.getCustomFont
import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.getCustomLightFont
import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.launcherAccentTheme

class Application : Application() {
Expand All @@ -25,6 +29,9 @@ class Application : Application() {
if(PREFS.accentColor == 21 && DynamicColors.isDynamicColorAvailable()) {
DynamicColors.applyToActivitiesIfAvailable(this)
}
setupCustomFont()
setupCustomLightFont()
setupCustomBoldFont()
super.onCreate()
registerActivityLifecycleCallbacks(object : ActivityLifecycleCallbacks {
@SuppressLint("SourceLockedOrientationActivity")
Expand All @@ -51,9 +58,23 @@ class Application : Application() {
}
companion object {
lateinit var PREFS: Prefs
//var EXP_PREFS: ExperimentPrefs? = null
// var EXP_PREFS: ExperimentPrefs? = null
var isUpdateDownloading = false
var isAppOpened = false
var isStartMenuOpened = false

var customFont: Typeface? = null
var customLightFont: Typeface? = null
var customBoldFont: Typeface? = null

fun setupCustomFont() {
customFont = getCustomFont()
}
fun setupCustomLightFont() {
customLightFont = getCustomLightFont()
}
fun setupCustomBoldFont() {
customBoldFont = getCustomBoldFont()
}
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/ru/dimon6018/metrolauncher/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ import ru.dimon6018.metrolauncher.content.data.bsod.BSOD
import ru.dimon6018.metrolauncher.content.oobe.WelcomeActivity
import ru.dimon6018.metrolauncher.content.settings.SettingsActivity
import ru.dimon6018.metrolauncher.databinding.LauncherMainScreenBinding
import ru.dimon6018.metrolauncher.helpers.iconpack.IconPackManager
import ru.dimon6018.metrolauncher.helpers.disklru.CacheUtils.Companion.closeDiskCache
import ru.dimon6018.metrolauncher.helpers.disklru.CacheUtils.Companion.initDiskCache
import ru.dimon6018.metrolauncher.helpers.disklru.CacheUtils.Companion.loadIconFromDiskCache
import ru.dimon6018.metrolauncher.helpers.disklru.CacheUtils.Companion.saveIconToDiskCache
import ru.dimon6018.metrolauncher.helpers.disklru.DiskLruCache
import ru.dimon6018.metrolauncher.helpers.iconpack.IconPackManager
import ru.dimon6018.metrolauncher.helpers.receivers.PackageChangesReceiver
import ru.dimon6018.metrolauncher.helpers.ui.WPDialog
import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.VERSION_CODE
Expand Down
23 changes: 21 additions & 2 deletions app/src/main/java/ru/dimon6018/metrolauncher/content/AllApps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ import kotlinx.coroutines.withContext
import me.everything.android.ui.overscroll.IOverScrollDecor
import me.everything.android.ui.overscroll.OverScrollDecoratorHelper
import ru.dimon6018.metrolauncher.Application.Companion.PREFS
import ru.dimon6018.metrolauncher.Application.Companion.customFont
import ru.dimon6018.metrolauncher.Application.Companion.customLightFont
import ru.dimon6018.metrolauncher.Application.Companion.isAppOpened
import ru.dimon6018.metrolauncher.Application.Companion.isStartMenuOpened
import ru.dimon6018.metrolauncher.Main
Expand Down Expand Up @@ -116,6 +118,10 @@ class AllApps: Fragment() {
binding.searchBackBtn.setOnClickListener {
disableSearch()
}
if(PREFS.customFontInstalled) customFont?.let {
binding.searchTextview.typeface = it
binding.noResults.typeface = it
}
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
Expand Down Expand Up @@ -541,6 +547,7 @@ class AllApps: Fragment() {
itemView.setOnClickListener {
showAlphabet()
}
if(PREFS.customFontInstalled) customFont?.let { binding.abcLabel.typeface = it }
}
}
inner class AppHolder(val binding: AppBinding) : RecyclerView.ViewHolder(binding.root) {
Expand All @@ -560,6 +567,7 @@ class AllApps: Fragment() {
showPopupWindow(itemView, list[absoluteAdapterPosition])
true
}
if(PREFS.customFontInstalled) customFont?.let { binding.appLabel.typeface = it }
}
private fun visualFeedback(view: View?) {
if(view != null) {
Expand Down Expand Up @@ -629,6 +637,16 @@ class AllApps: Fragment() {
popupWindow?.animationStyle = R.style.enterStyle
popupView.pivotY = 1f

val pinLabel = popupView.findViewById<MaterialTextView>(R.id.pin_app_label)
val infoLabel = popupView.findViewById<MaterialTextView>(R.id.app_info_label)
val uninstallLabel = popupView.findViewById<MaterialTextView>(R.id.uninstall_label)

(if(PREFS.customLightFontPath != null) customLightFont else customFont).let {
pinLabel.typeface = it
infoLabel.typeface = it
uninstallLabel.typeface = it
}

val anim = ObjectAnimator.ofFloat(popupView, "scaleY", 0f, 0.01f)
val anim2 = ObjectAnimator.ofFloat(popupView, "scaleX", 0f, 1f)
val anim3 = ObjectAnimator.ofFloat(popupView, "scaleY", 0.01f, 1f)
Expand All @@ -647,9 +665,9 @@ class AllApps: Fragment() {
PopupWindowCompat.showAsDropDown(popupWindow!!, view, 0, 0, Gravity.CENTER)
isWindowVisible = true

val pin = popupView.findViewById<MaterialCardView>(R.id.pinApp)
val uninstall = popupView.findViewById<MaterialCardView>(R.id.uninstallApp)
val pin = popupView.findViewById<MaterialCardView>(R.id.pin_app)
val info = popupView.findViewById<MaterialCardView>(R.id.infoApp)
val uninstall = popupView.findViewById<MaterialCardView>(R.id.uninstallApp)

var isAppAlreadyPinned = false
lifecycleScope.launch(defaultDispatcher) {
Expand Down Expand Up @@ -923,6 +941,7 @@ class AllApps: Fragment() {

init {
itemView.layoutParams = params
if(PREFS.customFontInstalled) customFont?.let { textView.typeface = it }
}
}
}
22 changes: 21 additions & 1 deletion app/src/main/java/ru/dimon6018/metrolauncher/content/Start.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import com.arasthel.spannedgridlayoutmanager.SpannedGridLayoutManager
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.card.MaterialCardView
import com.google.android.material.textfield.TextInputLayout
import com.google.android.material.textview.MaterialTextView
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
Expand All @@ -49,6 +50,8 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import ru.dimon6018.metrolauncher.Application.Companion.PREFS
import ru.dimon6018.metrolauncher.Application.Companion.customFont
import ru.dimon6018.metrolauncher.Application.Companion.customLightFont
import ru.dimon6018.metrolauncher.Application.Companion.isAppOpened
import ru.dimon6018.metrolauncher.Application.Companion.isStartMenuOpened
import ru.dimon6018.metrolauncher.Main
Expand Down Expand Up @@ -728,7 +731,7 @@ class Start: Fragment(), OnStartDragListener {
}
fun showSettingsBottomSheet(item: Tile, position: Int) {
val bottomsheet = BottomSheetDialog(context)
bottomsheet.setContentView(R.layout.tile_settings_bottomsheet)
bottomsheet.setContentView(R.layout.start_tile_settings_bottomsheet)
bottomsheet.dismissWithAnimation = true
val bottomSheetInternal = bottomsheet.findViewById<View>(com.google.android.material.R.id.design_bottom_sheet)
BottomSheetBehavior.from<View?>(bottomSheetInternal!!).peekHeight = context.resources.getDimensionPixelSize(R.dimen.bottom_sheet_size)
Expand All @@ -740,13 +743,29 @@ class Start: Fragment(), OnStartDragListener {
val colorSub = bottomSheetInternal.findViewById<MaterialTextView>(R.id.chooseColorSub)
val removeColor = bottomSheetInternal.findViewById<MaterialTextView>(R.id.chooseColorRemove)
val uninstall = bottomSheetInternal.findViewById<MaterialCardView>(R.id.uninstallApp)
val uninstallLabel = bottomSheetInternal.findViewById<MaterialTextView>(R.id.uninstall_label)
val changeLabel = bottomSheetInternal.findViewById<MaterialCardView>(R.id.editAppLabel)
val changeColor = bottomSheetInternal.findViewById<MaterialCardView>(R.id.editTileColor)
val editor = bottomSheetInternal.findViewById<EditText>(R.id.textEdit)
val textFiled = bottomSheetInternal.findViewById<TextInputLayout>(R.id.textField)
val labelLayout = bottomSheetInternal.findViewById<LinearLayout>(R.id.changeLabelLayout)
val labelChangeBtn = bottomSheetInternal.findViewById<MaterialCardView>(R.id.labelChange)
val editLabelText = bottomSheetInternal.findViewById<MaterialTextView>(R.id.editAppLabelText)
val appInfo = bottomSheetInternal.findViewById<MaterialCardView>(R.id.appInfo)
val chooseTileColor = bottomSheetInternal.findViewById<MaterialTextView>(R.id.choose_tile_color)
val appInfoLabel = bottomSheetInternal.findViewById<MaterialTextView>(R.id.app_info_label)

(if(PREFS.customLightFontPath != null) customLightFont else customFont).let {
label.typeface = it
colorSub.typeface = it
removeColor.typeface = it
uninstallLabel.typeface = it
editor.typeface = it
editLabelText.typeface = it
chooseTileColor.typeface = it
appInfoLabel.typeface = it
textFiled.typeface = it
}
editLabelText.setOnClickListener {
labelLayout.visibility = View.VISIBLE
}
Expand Down Expand Up @@ -888,6 +907,7 @@ class Start: Fragment(), OnStartDragListener {
return@setOnTouchListener gestureDetector.onTouchEvent(event)
}
}
if(PREFS.customFontInstalled) customFont?.let { binding.tileLabel.typeface = it }
}
private fun handleClick() {
val item = list[absoluteAdapterPosition]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package ru.dimon6018.metrolauncher.content.data
import android.content.Context

class ExperimentPrefs(context: Context) {
// private val prefs: SharedPreferences = context.getSharedPreferences(FILE_NAME_EXP, 0)

//val expPrefs: SharedPreferences = context.getSharedPreferences(FILE_NAME_EXP, 0)

companion object {
// const val FILE_NAME_EXP = "ExperimentPrefs"
// const val FILE_NAME_EXP = "ExperimentPrefs"
}
}
35 changes: 35 additions & 0 deletions app/src/main/java/ru/dimon6018/metrolauncher/content/data/Prefs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ class Prefs(context: Context) {
private val keyboardAutoSearchPref = "showKeyboardWhenOpeningAllApps"
private val orientationPref = "orientation"
private val coloredStrokePref = "coloredStroke"
private val customFontPref = "isCustomFontChosen"
private val customFontNamePref = "customFontName"
private val customFontPathPref = "customFontPath"
private val customLightFontPathPref = "customLightFontPath"
private val customLightFontNamePref = "customLightFontName"
private val customBoldFontPathPref = "customBoldFontPath"
private val customBoldFontNamePref = "customBoldFontName"

init {
prefs = context.getSharedPreferences(fileName, 0)
Expand Down Expand Up @@ -248,4 +255,32 @@ class Prefs(context: Context) {
var coloredStroke: Boolean
get() = prefs.getBoolean(coloredStrokePref, false)
set(value) = prefs.edit().putBoolean(coloredStrokePref, value).apply()

var customFontInstalled: Boolean
get() = prefs.getBoolean(customFontPref, false)
set(value) = prefs.edit().putBoolean(customFontPref, value).apply()

var customFontPath: String?
get() = prefs.getString(customFontPathPref, null)
set(value) = prefs.edit().putString(customFontPathPref, value).apply()

var customFontName: String?
get() = prefs.getString(customFontNamePref, null)
set(value) = prefs.edit().putString(customFontNamePref, value).apply()

var customLightFontPath: String?
get() = prefs.getString(customLightFontPathPref, null)
set(value) = prefs.edit().putString(customLightFontPathPref, value).apply()

var customLightFontName: String?
get() = prefs.getString(customLightFontNamePref, null)
set(value) = prefs.edit().putString(customLightFontNamePref, value).apply()

var customBoldFontPath: String?
get() = prefs.getString(customBoldFontPathPref, null)
set(value) = prefs.edit().putString(customBoldFontPathPref, value).apply()

var customBoldFontName: String?
get() = prefs.getString(customBoldFontNamePref, null)
set(value) = prefs.edit().putString(customBoldFontNamePref, value).apply()
}
Loading

0 comments on commit 5639f33

Please sign in to comment.