Feat: Added support to toggle app icons.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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) }
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="left|center"
|
||||
android:text="@string/settings_appearance_statue_bar"
|
||||
android:text="@string/settings_appearance_status_bar"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
@@ -227,6 +227,38 @@
|
||||
tools:ignore="TouchTargetSizeCheck" />
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="20dp"
|
||||
android:orientation="horizontal"
|
||||
tools:ignore="MissingConstraints">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/appIcons_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="left|center"
|
||||
android:text="@string/settings_appearance_app_icons_word"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="RtlHardcoded"
|
||||
style="@style/TextDefaultStyle"/>
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/appIcons_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
|
||||
|
||||
@@ -2,25 +2,30 @@
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:id="@+id/linear_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
tools:ignore="MissingConstraints">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/appHome_icon"
|
||||
android:id="@+id/appHomeLeft_icon"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:visibility="visible"/>
|
||||
android:visibility="visible"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/linear_layout"/>
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
@@ -33,7 +38,15 @@
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/appHomeRight_icon"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginStart="16dp"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/linear_layout"/>
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<string name="settings_title_app_manager">App Manage</string>
|
||||
<string name="settings_title_gestures">Gestures</string>
|
||||
<string name="settings_title_others">Others</string>
|
||||
<string name="settings_appearance_statue_bar">Show Statue Bar</string>
|
||||
<string name="settings_appearance_status_bar">Show Status Bar</string>
|
||||
<string name="settings_appearance_date">Show Date</string>
|
||||
<string name="settings_appearance_time">Show Time</string>
|
||||
<string name="settings_appearance_battery">Show Battery</string>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<string name="settings_title_app_manager">App Manage</string>
|
||||
<string name="settings_title_gestures">Gestures</string>
|
||||
<string name="settings_title_others">Others</string>
|
||||
<string name="settings_appearance_statue_bar">Show Statue Bar</string>
|
||||
<string name="settings_appearance_status_bar">Show Status Bar</string>
|
||||
<string name="settings_appearance_date">Show Date</string>
|
||||
<string name="settings_appearance_time">Show Time</string>
|
||||
<string name="settings_appearance_battery">Show Battery</string>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<string name="settings_title_app_manager">App Manage</string>
|
||||
<string name="settings_title_gestures">Gestures</string>
|
||||
<string name="settings_title_others">Others</string>
|
||||
<string name="settings_appearance_statue_bar">Show Statue Bar</string>
|
||||
<string name="settings_appearance_status_bar">Show Status Bar</string>
|
||||
<string name="settings_appearance_date">Show Date</string>
|
||||
<string name="settings_appearance_time">Show Time</string>
|
||||
<string name="settings_appearance_battery">Show Battery</string>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<string name="settings_title_app_manager">App Manage</string>
|
||||
<string name="settings_title_gestures">Gestures</string>
|
||||
<string name="settings_title_others">Others</string>
|
||||
<string name="settings_appearance_statue_bar">Show Statue Bar</string>
|
||||
<string name="settings_appearance_status_bar">Show Status Bar</string>
|
||||
<string name="settings_appearance_date">Show Date</string>
|
||||
<string name="settings_appearance_time">Show Time</string>
|
||||
<string name="settings_appearance_battery">Show Battery</string>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<string name="settings_title_app_manager">App Manage</string>
|
||||
<string name="settings_title_gestures">Gestures</string>
|
||||
<string name="settings_title_others">Others</string>
|
||||
<string name="settings_appearance_statue_bar">Show Statue Bar</string>
|
||||
<string name="settings_appearance_status_bar">Show Status Bar</string>
|
||||
<string name="settings_appearance_date">Show Date</string>
|
||||
<string name="settings_appearance_time">Show Time</string>
|
||||
<string name="settings_appearance_battery">Show Battery</string>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<string name="settings_title_app_manager">App Manage</string>
|
||||
<string name="settings_title_gestures">Gestures</string>
|
||||
<string name="settings_title_others">Others</string>
|
||||
<string name="settings_appearance_statue_bar">Show Statue Bar</string>
|
||||
<string name="settings_appearance_status_bar">Show Status Bar</string>
|
||||
<string name="settings_appearance_date">Show Date</string>
|
||||
<string name="settings_appearance_time">Show Time</string>
|
||||
<string name="settings_appearance_battery">Show Battery</string>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<string name="settings_title_app_manager">App Manage</string>
|
||||
<string name="settings_title_gestures">Gestures</string>
|
||||
<string name="settings_title_others">Others</string>
|
||||
<string name="settings_appearance_statue_bar">Show Statue Bar</string>
|
||||
<string name="settings_appearance_status_bar">Show Status Bar</string>
|
||||
<string name="settings_appearance_date">Show Date</string>
|
||||
<string name="settings_appearance_time">Show Time</string>
|
||||
<string name="settings_appearance_battery">Show Battery</string>
|
||||
|
||||
@@ -31,11 +31,12 @@
|
||||
<string name="settings_title_gestures">Gestures</string>
|
||||
<string name="settings_title_others">Others</string>
|
||||
|
||||
<string name="settings_appearance_statue_bar">Show Statue Bar</string>
|
||||
<string name="settings_appearance_status_bar">Show Status Bar</string>
|
||||
<string name="settings_appearance_date">Show Date</string>
|
||||
<string name="settings_appearance_time">Show Time</string>
|
||||
<string name="settings_appearance_battery">Show Battery</string>
|
||||
<string name="settings_appearance_daily_word">Show Daily Word</string>
|
||||
<string name="settings_appearance_app_icons_word">Show App Icons</string>
|
||||
|
||||
<string name="settings_appearance_text_size_title">Size</string>
|
||||
<string name="settings_appearance_color_title">Color</string>
|
||||
|
||||
Reference in New Issue
Block a user