Feat: Added support to toggle app icons.

This commit is contained in:
HeCodes2Much
2024-05-09 23:11:37 +01:00
parent 5f9b1a4b6a
commit f2e80cad63
14 changed files with 93 additions and 23 deletions

View File

@@ -55,7 +55,7 @@ class PreferenceHelper @Inject constructor(@ApplicationContext context: Context)
set(value) = prefs.edit().putInt(Constants.APP_COLOR, value).apply()
var showAppIcon: Boolean
get() = prefs.getBoolean(Constants.SHOW_APP_ICON, true)
get() = prefs.getBoolean(Constants.SHOW_APP_ICON, false)
set(value) = prefs.edit().putBoolean(Constants.SHOW_APP_ICON, value).apply()
var automaticKeyboard: Boolean

View File

@@ -1,7 +1,7 @@
package com.github.droidworksstudio.launcher.ui.home
import android.content.Context
import android.util.Log
import android.view.Gravity
import android.view.View
import androidx.appcompat.widget.LinearLayoutCompat
import androidx.recyclerview.widget.RecyclerView
@@ -35,11 +35,24 @@ class HomeViewHolder @Inject constructor(
appHomeName.textSize = preferenceHelper.appTextSize
Log.d("Tag", "Home Adapter Color: ${preferenceHelper.appColor}")
val appIcon = binding.root.context.packageManager.getApplicationIcon(appInfo.packageName)
appHomeIcon.setImageDrawable(appIcon)
appHomeIcon.layoutParams.width = preferenceHelper.appTextSize.toInt() * 3
appHomeIcon.layoutParams.height = preferenceHelper.appTextSize.toInt() * 3
appHomeIcon.visibility = View.GONE
if (preferenceHelper.showAppIcon) {
val appIcon = binding.root.context.packageManager.getApplicationIcon(appInfo.packageName)
when (preferenceHelper.homeAppAlignment) {
Gravity.START -> {
appHomeLeftIcon.setImageDrawable(appIcon)
appHomeLeftIcon.layoutParams.width = preferenceHelper.appTextSize.toInt() * 3
appHomeLeftIcon.layoutParams.height = preferenceHelper.appTextSize.toInt() * 3
appHomeLeftIcon.visibility = View.VISIBLE
}
Gravity.END -> {
appHomeRightIcon.setImageDrawable(appIcon)
appHomeRightIcon.layoutParams.width = preferenceHelper.appTextSize.toInt() * 3
appHomeRightIcon.layoutParams.height = preferenceHelper.appTextSize.toInt() * 3
appHomeRightIcon.visibility = View.VISIBLE
}
}
}
}
itemView.setOnClickListener { onAppClickedListener.onAppClicked(appInfo) }

View File

@@ -76,6 +76,7 @@ class SettingsFragment : Fragment(), ScrollEventListener {
binding.dateSwitchCompat.isChecked = preferenceHelper.showDate
binding.batterySwitchCompat.isChecked = preferenceHelper.showBattery
binding.dailyWordSwitchCompat.isChecked = preferenceHelper.showDailyWord
binding.appIconsSwitchCompat.isChecked = preferenceHelper.showAppIcon
binding.gesturesLockSwitchCompat.isChecked = preferenceHelper.tapLockScreen
binding.gesturesNotificationSwitchCompat.isChecked = preferenceHelper.swipeNotification
binding.gesturesSearchSwitchCompat.isChecked = preferenceHelper.swipeSearch
@@ -156,6 +157,10 @@ class SettingsFragment : Fragment(), ScrollEventListener {
preferenceViewModel.setShowDailyWord(isChecked)
}
binding.appIconsSwitchCompat.setOnCheckedChangeListener { _, isChecked ->
preferenceViewModel.setShowAppIcons(isChecked)
}
binding.gesturesLockSwitchCompat.setOnCheckedChangeListener { _, isChecked ->
appHelper.enableAppAsAccessibilityService(requireContext(), preferenceHelper.tapLockScreen)
preferenceViewModel.setDoubleTapLock(isChecked)

View File

@@ -17,6 +17,7 @@ class PreferenceViewModel @Inject constructor(
val showDateLiveData: MutableLiveData<Boolean> = MutableLiveData()
val showDailyWordLiveData: MutableLiveData<Boolean> = MutableLiveData()
val showBatteryLiveData: MutableLiveData<Boolean> = MutableLiveData()
val showAppIconLiveData: MutableLiveData<Boolean> = MutableLiveData()
val homeAppAlignmentLiveData: MutableLiveData<Int> = MutableLiveData()
val homeDateAlignmentLiveData: MutableLiveData<Int> = MutableLiveData()
val homeTimeAlignmentLiveData: MutableLiveData<Int> = MutableLiveData()
@@ -65,6 +66,11 @@ class PreferenceViewModel @Inject constructor(
showDailyWordLiveData.postValue(preferenceHelper.showDailyWord)
}
fun setShowAppIcons(showAppIcons: Boolean) {
preferenceHelper.showAppIcon = showAppIcons
showAppIconLiveData.postValue(preferenceHelper.showAppIcon)
}
fun setDailyWordColor(dailyWordColor: Int) {
preferenceHelper.dailyWordColor = dailyWordColor
dailyWordColorLiveData.postValue(preferenceHelper.dailyWordColor)