Feature: Added setting for icon packs.
This commit is contained in:
@@ -95,10 +95,6 @@ class PreferenceHelper @Inject constructor(@ApplicationContext context: Context)
|
||||
get() = prefs.getBoolean(Constants.SHOW_APP_ICON, false)
|
||||
set(value) = prefs.edit().putBoolean(Constants.SHOW_APP_ICON, value).apply()
|
||||
|
||||
var showAppIconAsDots: Boolean
|
||||
get() = prefs.getBoolean(Constants.SHOW_APP_ICON_DOTS, false)
|
||||
set(value) = prefs.edit().putBoolean(Constants.SHOW_APP_ICON_DOTS, value).apply()
|
||||
|
||||
var locationDenied: Boolean
|
||||
get() = prefs.getBoolean(Constants.LOCATION_DENIED, false)
|
||||
set(value) = prefs.edit().putBoolean(Constants.LOCATION_DENIED, value).apply()
|
||||
@@ -198,6 +194,21 @@ class PreferenceHelper @Inject constructor(@ApplicationContext context: Context)
|
||||
}
|
||||
set(value) = prefs.edit().putString(Constants.SEARCH_ENGINE, value.name).apply()
|
||||
|
||||
var iconPack: Constants.IconPacks
|
||||
get() {
|
||||
return try {
|
||||
Constants.IconPacks.valueOf(
|
||||
prefs.getString(
|
||||
Constants.ICONS_PACK,
|
||||
Constants.IconPacks.System.name
|
||||
).toString()
|
||||
)
|
||||
} catch (_: Exception) {
|
||||
Constants.IconPacks.System
|
||||
}
|
||||
}
|
||||
set(value) = prefs.edit().putString(Constants.ICONS_PACK, value.name).apply()
|
||||
|
||||
var launcherFont: Constants.Fonts
|
||||
get() {
|
||||
return try {
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.github.droidworksstudio.launcher.data.entities.AppInfo
|
||||
import com.github.droidworksstudio.launcher.databinding.ItemDrawBinding
|
||||
import com.github.droidworksstudio.launcher.helper.PreferenceHelper
|
||||
import com.github.droidworksstudio.launcher.listener.OnItemClickedListener
|
||||
import com.github.droidworksstudio.launcher.utils.Constants
|
||||
|
||||
class DrawViewHolder(
|
||||
private val binding: ItemDrawBinding,
|
||||
@@ -44,11 +45,16 @@ class DrawViewHolder(
|
||||
if (preferenceHelper.showAppIcon) {
|
||||
val pm: PackageManager = binding.root.context.packageManager
|
||||
val appIcon = pm.getApplicationIcon(appInfo.packageName)
|
||||
val appIconSize = (preferenceHelper.appTextSize * if (preferenceHelper.showAppIconAsDots) 1.1f else 2f).toInt()
|
||||
val appIconSize = (preferenceHelper.appTextSize * if (preferenceHelper.iconPack == Constants.IconPacks.System) 2f else 1.1f).toInt()
|
||||
|
||||
val layoutParams = LinearLayoutCompat.LayoutParams(appIconSize, appIconSize)
|
||||
val appNewIcon: Drawable? = if (preferenceHelper.showAppIconAsDots) {
|
||||
val newIcon = ContextCompat.getDrawable(itemView.context, R.drawable.app_dot_icon)!!
|
||||
val appNewIcon: Drawable? = if (preferenceHelper.iconPack == Constants.IconPacks.EasyDots) {
|
||||
val newIcon = ContextCompat.getDrawable(itemView.context, R.drawable.app_easy_dot_icon)!!
|
||||
val bitmap = ColorIconsExtensions.drawableToBitmap(appIcon)
|
||||
val dominantColor = ColorIconsExtensions.getDominantColor(bitmap)
|
||||
ColorIconsExtensions.recolorDrawable(newIcon, dominantColor)
|
||||
} else if (preferenceHelper.iconPack == Constants.IconPacks.NiagaraDots) {
|
||||
val newIcon = ContextCompat.getDrawable(itemView.context, R.drawable.app_niagara_dot_icon)!!
|
||||
val bitmap = ColorIconsExtensions.drawableToBitmap(appIcon)
|
||||
val dominantColor = ColorIconsExtensions.getDominantColor(bitmap)
|
||||
ColorIconsExtensions.recolorDrawable(newIcon, dominantColor)
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.github.droidworksstudio.launcher.data.entities.AppInfo
|
||||
import com.github.droidworksstudio.launcher.databinding.ItemHomeBinding
|
||||
import com.github.droidworksstudio.launcher.helper.PreferenceHelper
|
||||
import com.github.droidworksstudio.launcher.listener.OnItemClickedListener
|
||||
import com.github.droidworksstudio.launcher.utils.Constants
|
||||
import javax.inject.Inject
|
||||
|
||||
class HomeViewHolder @Inject constructor(
|
||||
@@ -44,11 +45,16 @@ class HomeViewHolder @Inject constructor(
|
||||
if (preferenceHelper.showAppIcon) {
|
||||
val pm: PackageManager = binding.root.context.packageManager
|
||||
val appIcon = pm.getApplicationIcon(appInfo.packageName)
|
||||
val appIconSize = (preferenceHelper.appTextSize * if (preferenceHelper.showAppIconAsDots) 1.1f else 2f).toInt()
|
||||
val appIconSize = (preferenceHelper.appTextSize * if (preferenceHelper.iconPack == Constants.IconPacks.System) 2f else 1.1f).toInt()
|
||||
|
||||
val layoutParams = LinearLayoutCompat.LayoutParams(appIconSize, appIconSize)
|
||||
val appNewIcon: Drawable? = if (preferenceHelper.showAppIconAsDots) {
|
||||
val newIcon = ContextCompat.getDrawable(itemView.context, R.drawable.app_dot_icon)!!
|
||||
val appNewIcon: Drawable? = if (preferenceHelper.iconPack == Constants.IconPacks.EasyDots) {
|
||||
val newIcon = ContextCompat.getDrawable(itemView.context, R.drawable.app_easy_dot_icon)!!
|
||||
val bitmap = ColorIconsExtensions.drawableToBitmap(appIcon)
|
||||
val dominantColor = ColorIconsExtensions.getDominantColor(bitmap)
|
||||
ColorIconsExtensions.recolorDrawable(newIcon, dominantColor)
|
||||
} else if (preferenceHelper.iconPack == Constants.IconPacks.NiagaraDots) {
|
||||
val newIcon = ContextCompat.getDrawable(itemView.context, R.drawable.app_niagara_dot_icon)!!
|
||||
val bitmap = ColorIconsExtensions.drawableToBitmap(appIcon)
|
||||
val dominantColor = ColorIconsExtensions.getDominantColor(bitmap)
|
||||
ColorIconsExtensions.recolorDrawable(newIcon, dominantColor)
|
||||
|
||||
@@ -77,6 +77,7 @@ class SettingsLookFeelFragment : Fragment(),
|
||||
|
||||
binding.apply {
|
||||
miscellaneousLauncherFontsControl.text = preferenceHelper.launcherFont.getString(context)
|
||||
miscellaneousIconsControl.text = preferenceHelper.iconPack.name
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,15 +98,6 @@ class SettingsLookFeelFragment : Fragment(),
|
||||
alarmClockSwitchCompat.isChecked = preferenceHelper.showAlarmClock
|
||||
dailyWordSwitchCompat.isChecked = preferenceHelper.showDailyWord
|
||||
appIconsSwitchCompat.isChecked = preferenceHelper.showAppIcon
|
||||
appIconDotsSwitchCompat.isChecked = preferenceHelper.showAppIconAsDots
|
||||
}
|
||||
|
||||
if (!binding.appIconsSwitchCompat.isChecked) {
|
||||
// Disable and gray out the other setting if appIconsSwitchCompat is checked
|
||||
binding.appIconDotsSwitchCompat.apply {
|
||||
isEnabled = binding.appIconsSwitchCompat.isChecked
|
||||
isChecked = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,6 +131,10 @@ class SettingsLookFeelFragment : Fragment(),
|
||||
startActivity(Intent.createChooser(intent, "Select Wallpaper"))
|
||||
}
|
||||
|
||||
miscellaneousIconsControl.setOnClickListener {
|
||||
showIconsDialog()
|
||||
}
|
||||
|
||||
miscellaneousLauncherFontsControl.setOnClickListener {
|
||||
showLauncherFontDialog()
|
||||
}
|
||||
@@ -188,19 +184,38 @@ class SettingsLookFeelFragment : Fragment(),
|
||||
preferenceViewModel.setShowAppIcons(isChecked)
|
||||
val feedbackType = if (isChecked) "on" else "off"
|
||||
appHelper.triggerHapticFeedback(context, feedbackType)
|
||||
|
||||
// Disable and gray out the other setting if appIconsSwitchCompat is checked
|
||||
binding.appIconDotsSwitchCompat.isEnabled = isChecked
|
||||
binding.appIconDotsSwitchCompat.isChecked = false
|
||||
}
|
||||
}
|
||||
|
||||
appIconDotsSwitchCompat.setOnCheckedChangeListener { _, isChecked ->
|
||||
preferenceViewModel.setShowAppIconDots(isChecked)
|
||||
val feedbackType = if (isChecked) "on" else "off"
|
||||
}
|
||||
|
||||
private var iconsDialog: AlertDialog? = null
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.Q)
|
||||
private fun showIconsDialog() {
|
||||
// Dismiss any existing dialog to prevent multiple dialogs open simultaneously
|
||||
iconsDialog?.dismiss()
|
||||
// Get the array of SearchEngines enum values
|
||||
val items = Constants.IconPacks.entries.toTypedArray()
|
||||
|
||||
// Map the enum values to their string representations
|
||||
val itemStrings = items.map { it.getString(context) }.toTypedArray()
|
||||
|
||||
val dialogBuilder = MaterialAlertDialogBuilder(context).apply {
|
||||
setTitle(getString(R.string.settings_select_icons))
|
||||
setItems(itemStrings) { _, which ->
|
||||
val selectedItem = items[which]
|
||||
preferenceViewModel.setIconsPack(selectedItem)
|
||||
binding.miscellaneousIconsControl.text = preferenceHelper.iconPack.name
|
||||
|
||||
val feedbackType = "select"
|
||||
appHelper.triggerHapticFeedback(context, feedbackType)
|
||||
}
|
||||
}
|
||||
|
||||
// Assign the created dialog to launcherFontDialog
|
||||
iconsDialog = dialogBuilder.create()
|
||||
iconsDialog?.show()
|
||||
}
|
||||
|
||||
private var launcherFontDialog: AlertDialog? = null
|
||||
@@ -238,6 +253,7 @@ class SettingsLookFeelFragment : Fragment(),
|
||||
}
|
||||
|
||||
private fun dismissDialogs() {
|
||||
iconsDialog?.dismiss()
|
||||
launcherFontDialog?.dismiss()
|
||||
}
|
||||
}
|
||||
@@ -89,6 +89,7 @@ object Constants {
|
||||
const val URL_GOOGLE_PLAY_STORE = "https://play.google.com/store/search?c=apps&q"
|
||||
const val APP_GOOGLE_PLAY_STORE = "market://search?c=apps&q"
|
||||
|
||||
const val ICONS_PACK = "ICONS_PACK"
|
||||
const val LAUNCHER_FONT = "LAUNCHER_FONT"
|
||||
|
||||
const val REQUEST_INSTALL_PERMISSION = 123
|
||||
@@ -196,6 +197,20 @@ object Constants {
|
||||
}
|
||||
}
|
||||
|
||||
enum class IconPacks {
|
||||
System,
|
||||
EasyDots,
|
||||
NiagaraDots;
|
||||
|
||||
fun getString(context: Context): String {
|
||||
return when (this) {
|
||||
System -> context.getString(R.string.settings_system)
|
||||
EasyDots -> context.getString(R.string.settings_icons_easy_dots)
|
||||
NiagaraDots -> context.getString(R.string.settings_icons_niagara_dots)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum class Fonts {
|
||||
System,
|
||||
Bitter,
|
||||
@@ -229,7 +244,7 @@ object Constants {
|
||||
|
||||
fun getString(context: Context): String {
|
||||
return when (this) {
|
||||
System -> context.getString(R.string.settings_font_system)
|
||||
System -> context.getString(R.string.settings_system)
|
||||
Bitter -> context.getString(R.string.settings_font_bitter)
|
||||
Dotness -> context.getString(R.string.settings_font_dotness)
|
||||
DroidSans -> context.getString(R.string.settings_font_droidsans)
|
||||
@@ -261,7 +276,7 @@ object Constants {
|
||||
|
||||
fun string(context: Context): String {
|
||||
return when (this) {
|
||||
System -> context.getString(R.string.app_system_language)
|
||||
System -> context.getString(R.string.settings_system)
|
||||
Czech -> "Czech"
|
||||
Danish -> "Danish"
|
||||
Dutch -> "Dutch"
|
||||
|
||||
@@ -23,7 +23,6 @@ class PreferenceViewModel @Inject constructor(
|
||||
private val showWeatherWidgetSunSetRiseLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||
private val showBatteryWidgetLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||
private val showAppIconLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||
private val showAppIconAsDotsLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||
private val homeAppAlignmentLiveData: MutableLiveData<Int> = MutableLiveData()
|
||||
private val homeDateAlignmentLiveData: MutableLiveData<Int> = MutableLiveData()
|
||||
private val homeTimeAlignmentLiveData: MutableLiveData<Int> = MutableLiveData()
|
||||
@@ -56,6 +55,7 @@ class PreferenceViewModel @Inject constructor(
|
||||
|
||||
private val appLanguageLiveData: MutableLiveData<Constants.Language> = MutableLiveData()
|
||||
private val searchEngineLiveData: MutableLiveData<Constants.SearchEngines> = MutableLiveData()
|
||||
private val iconPackLiveData: MutableLiveData<Constants.IconPacks> = MutableLiveData()
|
||||
private val launcherFontLiveData: MutableLiveData<Constants.Fonts> = MutableLiveData()
|
||||
private val doubleTapActionLiveData: MutableLiveData<Constants.Action> = MutableLiveData()
|
||||
private val swipeUpActionLiveData: MutableLiveData<Constants.Action> = MutableLiveData()
|
||||
@@ -103,11 +103,6 @@ class PreferenceViewModel @Inject constructor(
|
||||
showAppIconLiveData.postValue(preferenceHelper.showAppIcon)
|
||||
}
|
||||
|
||||
fun setShowAppIconDots(showAppIconAsDots: Boolean) {
|
||||
preferenceHelper.showAppIconAsDots = showAppIconAsDots
|
||||
showAppIconAsDotsLiveData.postValue(preferenceHelper.showAppIconAsDots)
|
||||
}
|
||||
|
||||
fun setAlarmClockColor(alarmClockColor: Int) {
|
||||
preferenceHelper.alarmClockColor = alarmClockColor
|
||||
alarmClockColorLiveData.postValue(preferenceHelper.alarmClockColor)
|
||||
@@ -293,6 +288,11 @@ class PreferenceViewModel @Inject constructor(
|
||||
searchEngineLiveData.postValue((preferenceHelper.searchEngines))
|
||||
}
|
||||
|
||||
fun setIconsPack(iconPack: Constants.IconPacks) {
|
||||
preferenceHelper.iconPack = iconPack
|
||||
iconPackLiveData.postValue((preferenceHelper.iconPack))
|
||||
}
|
||||
|
||||
fun setFilterStrength(filterStrength: Int) {
|
||||
preferenceHelper.filterStrength = filterStrength
|
||||
filterStrengthLiveData.postValue((preferenceHelper.filterStrength))
|
||||
|
||||
@@ -276,37 +276,6 @@
|
||||
tools:ignore="TouchTargetSizeCheck" />
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
tools:ignore="MissingConstraints">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/appIconDots_text"
|
||||
style="@style/TextDefaultStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="left|center"
|
||||
android:text="@string/settings_display_app_icon_dots"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="RtlHardcoded" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/appIconDots_switchCompat"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleX="0.7"
|
||||
android:scaleY="0.8"
|
||||
android:thumb="@drawable/shape_switch_thumb"
|
||||
app:track="@drawable/selector_switch"
|
||||
tools:ignore="TouchTargetSizeCheck" />
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
@@ -430,6 +399,38 @@
|
||||
tools:ignore="RtlHardcoded" />
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginVertical="10dp"
|
||||
android:orientation="horizontal"
|
||||
tools:ignore="MissingConstraints">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/miscellaneous_icons_text"
|
||||
style="@style/TextDefaultStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="left|center"
|
||||
android:text="@string/settings_icons"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="RtlHardcoded" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/miscellaneous_icons_control"
|
||||
style="@style/TextDefaultStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="left|center"
|
||||
android:text="@string/settings_system"
|
||||
android:textSize="@dimen/text_large"
|
||||
tools:ignore="RtlHardcoded" />
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -456,7 +457,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="left|center"
|
||||
android:text="@string/settings_font_system"
|
||||
android:text="@string/settings_system"
|
||||
android:textSize="@dimen/text_large"
|
||||
tools:ignore="RtlHardcoded" />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user