Feature: Added a new App Group Padding setting
This commit is contained in:
@@ -123,6 +123,10 @@ class PreferenceHelper @Inject constructor(@ApplicationContext context: Context)
|
||||
get() = prefs.getInt(Constants.HOME_APP_ALIGNMENT, Gravity.START)
|
||||
set(value) = prefs.edit().putInt(Constants.HOME_APP_ALIGNMENT, value).apply()
|
||||
|
||||
var homeAppsPadding: Float
|
||||
get() = prefs.getFloat(Constants.APPS_PADDING, 128f)
|
||||
set(value) = prefs.edit().putFloat(Constants.APPS_PADDING, value).apply()
|
||||
|
||||
var homeAppPadding: Float
|
||||
get() = prefs.getFloat(Constants.APP_TEXT_PADDING, 10f)
|
||||
set(value) = prefs.edit().putFloat(Constants.APP_TEXT_PADDING, value).apply()
|
||||
|
||||
@@ -62,52 +62,57 @@ class AlignmentBottomSheetDialogFragment : BottomSheetDialogFragment() {
|
||||
private fun initView() {
|
||||
bottomDialogHelper.setupDialogStyle(dialog)
|
||||
|
||||
binding.selectDateTextSize.apply {
|
||||
text = appHelper.gravityToString(preferenceHelper.homeDateAlignment)
|
||||
binding.apply {
|
||||
selectDateTextSize.apply {
|
||||
text = appHelper.gravityToString(preferenceHelper.homeDateAlignment)
|
||||
}
|
||||
|
||||
selectTimeTextSize.apply {
|
||||
text = appHelper.gravityToString(preferenceHelper.homeTimeAlignment)
|
||||
}
|
||||
|
||||
selectAppTextSize.apply {
|
||||
text = appHelper.gravityToString(preferenceHelper.homeAppAlignment)
|
||||
}
|
||||
|
||||
selectWordTextSize.apply {
|
||||
text = appHelper.gravityToString(preferenceHelper.homeDailyWordAlignment)
|
||||
}
|
||||
|
||||
selectAlarmClockTextSize.apply {
|
||||
text = appHelper.gravityToString(preferenceHelper.homeAlarmClockAlignment)
|
||||
}
|
||||
}
|
||||
|
||||
binding.selectTimeTextSize.apply {
|
||||
text = appHelper.gravityToString(preferenceHelper.homeTimeAlignment)
|
||||
}
|
||||
|
||||
binding.selectAppTextSize.apply {
|
||||
text = appHelper.gravityToString(preferenceHelper.homeAppAlignment)
|
||||
}
|
||||
|
||||
binding.selectWordTextSize.apply {
|
||||
text = appHelper.gravityToString(preferenceHelper.homeDailyWordAlignment)
|
||||
}
|
||||
|
||||
binding.selectAlarmClockTextSize.apply {
|
||||
text = appHelper.gravityToString(preferenceHelper.homeAlarmClockAlignment)
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.Q)
|
||||
private fun observeClickListener() {
|
||||
binding.bottomAlignmentDateView.setOnClickListener {
|
||||
selectedAlignment = REQUEST_KEY_DATE_ALIGNMENT
|
||||
showListDialog(selectedAlignment)
|
||||
}
|
||||
binding.apply {
|
||||
bottomAlignmentDateView.setOnClickListener {
|
||||
selectedAlignment = REQUEST_KEY_DATE_ALIGNMENT
|
||||
showListDialog(selectedAlignment)
|
||||
}
|
||||
|
||||
binding.bottomAlignmentTimeView.setOnClickListener {
|
||||
selectedAlignment = REQUEST_KEY_TIME_ALIGNMENT
|
||||
showListDialog(selectedAlignment)
|
||||
}
|
||||
bottomAlignmentTimeView.setOnClickListener {
|
||||
selectedAlignment = REQUEST_KEY_TIME_ALIGNMENT
|
||||
showListDialog(selectedAlignment)
|
||||
}
|
||||
|
||||
binding.bottomAlignmentAppView.setOnClickListener {
|
||||
selectedAlignment = REQUEST_KEY_APP_ALIGNMENT
|
||||
showListDialog(selectedAlignment)
|
||||
}
|
||||
bottomAlignmentAppView.setOnClickListener {
|
||||
selectedAlignment = REQUEST_KEY_APP_ALIGNMENT
|
||||
showListDialog(selectedAlignment)
|
||||
}
|
||||
|
||||
binding.bottomAlignmentWordView.setOnClickListener {
|
||||
selectedAlignment = REQUEST_KEY_WORD_ALIGNMENT
|
||||
showListDialog(selectedAlignment)
|
||||
}
|
||||
bottomAlignmentWordView.setOnClickListener {
|
||||
selectedAlignment = REQUEST_KEY_WORD_ALIGNMENT
|
||||
showListDialog(selectedAlignment)
|
||||
}
|
||||
|
||||
binding.bottomAlignmentAlarmClockView.setOnClickListener {
|
||||
selectedAlignment = REQUEST_KEY_ALARM_CLOCK_ALIGNMENT
|
||||
showListDialog(selectedAlignment)
|
||||
bottomAlignmentAlarmClockView.setOnClickListener {
|
||||
selectedAlignment = REQUEST_KEY_ALARM_CLOCK_ALIGNMENT
|
||||
showListDialog(selectedAlignment)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,45 +128,47 @@ class AlignmentBottomSheetDialogFragment : BottomSheetDialogFragment() {
|
||||
val selectedItem = index
|
||||
val gravity = appHelper.getGravityFromSelectedItem(selectedItem)
|
||||
|
||||
when (selectedAlignment) {
|
||||
REQUEST_KEY_APP_ALIGNMENT -> {
|
||||
setAlignment(
|
||||
selectedAlignment,
|
||||
gravity,
|
||||
binding.selectAppTextSize
|
||||
)
|
||||
}
|
||||
binding.apply {
|
||||
when (selectedAlignment) {
|
||||
REQUEST_KEY_APP_ALIGNMENT -> {
|
||||
setAlignment(
|
||||
selectedAlignment,
|
||||
gravity,
|
||||
selectAppTextSize
|
||||
)
|
||||
}
|
||||
|
||||
REQUEST_KEY_TIME_ALIGNMENT -> {
|
||||
setAlignment(
|
||||
selectedAlignment,
|
||||
gravity,
|
||||
binding.selectTimeTextSize
|
||||
)
|
||||
}
|
||||
REQUEST_KEY_TIME_ALIGNMENT -> {
|
||||
setAlignment(
|
||||
selectedAlignment,
|
||||
gravity,
|
||||
selectTimeTextSize
|
||||
)
|
||||
}
|
||||
|
||||
REQUEST_KEY_DATE_ALIGNMENT -> {
|
||||
setAlignment(
|
||||
selectedAlignment,
|
||||
gravity,
|
||||
binding.selectDateTextSize
|
||||
)
|
||||
}
|
||||
REQUEST_KEY_DATE_ALIGNMENT -> {
|
||||
setAlignment(
|
||||
selectedAlignment,
|
||||
gravity,
|
||||
selectDateTextSize
|
||||
)
|
||||
}
|
||||
|
||||
REQUEST_KEY_WORD_ALIGNMENT -> {
|
||||
setAlignment(
|
||||
selectedAlignment,
|
||||
gravity,
|
||||
binding.selectWordTextSize
|
||||
)
|
||||
}
|
||||
REQUEST_KEY_WORD_ALIGNMENT -> {
|
||||
setAlignment(
|
||||
selectedAlignment,
|
||||
gravity,
|
||||
selectWordTextSize
|
||||
)
|
||||
}
|
||||
|
||||
REQUEST_KEY_ALARM_CLOCK_ALIGNMENT -> {
|
||||
setAlignment(
|
||||
selectedAlignment,
|
||||
gravity,
|
||||
binding.selectAlarmClockTextSize
|
||||
)
|
||||
REQUEST_KEY_ALARM_CLOCK_ALIGNMENT -> {
|
||||
setAlignment(
|
||||
selectedAlignment,
|
||||
gravity,
|
||||
selectAlarmClockTextSize
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,64 +97,77 @@ class AppInfoBottomSheetFragment(private val appInfo: AppInfo) : BottomSheetDial
|
||||
val applicationInfo = packageManager?.getApplicationInfo(packageName, 0)
|
||||
val appName = applicationInfo?.let { packageManager.getApplicationLabel(it).toString() }
|
||||
|
||||
binding.bottomSheetFavHidden.setOnClickListener {
|
||||
appStateClickListener?.onAppStateClicked(appInfo)
|
||||
binding.apply {
|
||||
bottomSheetFavHidden.setOnClickListener {
|
||||
appStateClickListener?.onAppStateClicked(appInfo)
|
||||
|
||||
appInfo.favorite = !appInfo.favorite
|
||||
appInfo.favorite = !appInfo.favorite
|
||||
|
||||
viewModel.updateAppInfoFavorite(appInfo)
|
||||
viewModel.updateAppInfoFavorite(appInfo)
|
||||
|
||||
Log.d("Tag", "${appInfo.appName} : Bottom Favorite: ${appInfo.favorite}")
|
||||
Log.d("Tag", "${appInfo.appName} : Bottom Order: ${appInfo.appOrder}")
|
||||
Log.d("Tag", "${appInfo.appName} : Bottom Favorite: ${appInfo.favorite}")
|
||||
Log.d("Tag", "${appInfo.appName} : Bottom Order: ${appInfo.appOrder}")
|
||||
|
||||
dismiss()
|
||||
}
|
||||
|
||||
binding.bottomSheetRename.addTextChangedListener(object : TextWatcher {
|
||||
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||
dismiss()
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
appInfo.appName = s.toString()
|
||||
bottomSheetRename.addTextChangedListener(object : TextWatcher {
|
||||
|
||||
if (s.isNullOrEmpty()) {
|
||||
viewModel.updateAppInfoAppName(appInfo, appName.toString())
|
||||
} else {
|
||||
viewModel.updateAppInfoAppName(appInfo, s.toString())
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||
}
|
||||
}
|
||||
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
if (s.isNullOrEmpty()) {
|
||||
binding.bottomSheetRename.setHintTextColor(
|
||||
ContextCompat.getColor(
|
||||
requireContext(),
|
||||
R.color.white
|
||||
)
|
||||
)
|
||||
binding.bottomSheetRename.hint = appName
|
||||
appInfo.appName = appName ?: ""
|
||||
} else {
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
appInfo.appName = s.toString()
|
||||
|
||||
if (s.isNullOrEmpty()) {
|
||||
viewModel.updateAppInfoAppName(appInfo, appName.toString())
|
||||
} else {
|
||||
viewModel.updateAppInfoAppName(appInfo, s.toString())
|
||||
}
|
||||
}
|
||||
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
if (s.isNullOrEmpty()) {
|
||||
bottomSheetRename.setHintTextColor(
|
||||
ContextCompat.getColor(
|
||||
requireContext(),
|
||||
R.color.white
|
||||
)
|
||||
)
|
||||
binding.bottomSheetRename.hint = appName
|
||||
appInfo.appName = appName ?: ""
|
||||
} else {
|
||||
appInfo.appName = s.toString()
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
bottomSheetRenameDone.setOnClickListener {
|
||||
appStateClickListener?.onAppStateClicked(appInfo)
|
||||
viewModel.updateAppInfoAppName(appInfo, appInfo.appName)
|
||||
dismiss()
|
||||
Log.d("Tag", "${appInfo.appName} Bottom State: ${appInfo.appName}")
|
||||
}
|
||||
})
|
||||
|
||||
binding.bottomSheetRenameDone.setOnClickListener {
|
||||
appStateClickListener?.onAppStateClicked(appInfo)
|
||||
viewModel.updateAppInfoAppName(appInfo, appInfo.appName)
|
||||
dismiss()
|
||||
Log.d("Tag", "${appInfo.appName} Bottom State: ${appInfo.appName}")
|
||||
}
|
||||
bottomSheetHidden.setOnClickListener {
|
||||
appStateClickListener?.onAppStateClicked(appInfo)
|
||||
appInfo.hidden = !appInfo.hidden
|
||||
|
||||
binding.bottomSheetHidden.setOnClickListener {
|
||||
appStateClickListener?.onAppStateClicked(appInfo)
|
||||
appInfo.hidden = !appInfo.hidden
|
||||
viewModel.updateAppHidden(appInfo, appInfo.hidden)
|
||||
dismiss()
|
||||
}
|
||||
|
||||
viewModel.updateAppHidden(appInfo, appInfo.hidden)
|
||||
dismiss()
|
||||
bottomSheetUninstall.setOnClickListener {
|
||||
appStateClickListener?.onAppStateClicked(appInfo)
|
||||
requireContext().unInstallApp(appInfo)
|
||||
dismiss()
|
||||
}
|
||||
|
||||
bottomSheetInfo.setOnClickListener {
|
||||
requireContext().appInfo(appInfo)
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
binding.bottomSheetLock.setOnClickListener {
|
||||
@@ -166,17 +179,6 @@ class AppInfoBottomSheetFragment(private val appInfo: AppInfo) : BottomSheetDial
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
binding.bottomSheetUninstall.setOnClickListener {
|
||||
appStateClickListener?.onAppStateClicked(appInfo)
|
||||
requireContext().unInstallApp(appInfo)
|
||||
dismiss()
|
||||
}
|
||||
|
||||
binding.bottomSheetInfo.setOnClickListener {
|
||||
requireContext().appInfo(appInfo)
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAuthenticationSucceeded(appInfo: AppInfo) {
|
||||
|
||||
@@ -64,112 +64,116 @@ class ColorBottomSheetDialogFragment : BottomSheetDialogFragment() {
|
||||
private fun initView() {
|
||||
bottomDialogHelper.setupDialogStyle(dialog)
|
||||
|
||||
binding.selectDateTextColor.apply {
|
||||
text = bottomDialogHelper.getColorText(preferenceHelper.dateColor)
|
||||
setTextColor(preferenceHelper.dateColor)
|
||||
}
|
||||
binding.apply {
|
||||
selectDateTextColor.apply {
|
||||
text = bottomDialogHelper.getColorText(preferenceHelper.dateColor)
|
||||
setTextColor(preferenceHelper.dateColor)
|
||||
}
|
||||
|
||||
binding.selectTimeTextColor.apply {
|
||||
text = bottomDialogHelper.getColorText(preferenceHelper.timeColor)
|
||||
setTextColor(preferenceHelper.timeColor)
|
||||
}
|
||||
selectTimeTextColor.apply {
|
||||
text = bottomDialogHelper.getColorText(preferenceHelper.timeColor)
|
||||
setTextColor(preferenceHelper.timeColor)
|
||||
}
|
||||
|
||||
binding.selectAppTextColor.apply {
|
||||
text = bottomDialogHelper.getColorText(preferenceHelper.appColor)
|
||||
setTextColor(preferenceHelper.appColor)
|
||||
}
|
||||
selectAppTextColor.apply {
|
||||
text = bottomDialogHelper.getColorText(preferenceHelper.appColor)
|
||||
setTextColor(preferenceHelper.appColor)
|
||||
}
|
||||
|
||||
binding.selectBatteryTextColor.apply {
|
||||
text = bottomDialogHelper.getColorText(preferenceHelper.batteryColor)
|
||||
setTextColor(preferenceHelper.batteryColor)
|
||||
}
|
||||
selectBatteryTextColor.apply {
|
||||
text = bottomDialogHelper.getColorText(preferenceHelper.batteryColor)
|
||||
setTextColor(preferenceHelper.batteryColor)
|
||||
}
|
||||
|
||||
binding.selectAlarmClockTextColor.apply {
|
||||
text = bottomDialogHelper.getColorText(preferenceHelper.alarmClockColor)
|
||||
setTextColor(preferenceHelper.alarmClockColor)
|
||||
}
|
||||
selectAlarmClockTextColor.apply {
|
||||
text = bottomDialogHelper.getColorText(preferenceHelper.alarmClockColor)
|
||||
setTextColor(preferenceHelper.alarmClockColor)
|
||||
}
|
||||
|
||||
binding.selectWordTextColor.apply {
|
||||
text = bottomDialogHelper.getColorText(preferenceHelper.dailyWordColor)
|
||||
setTextColor(preferenceHelper.dailyWordColor)
|
||||
}
|
||||
selectWordTextColor.apply {
|
||||
text = bottomDialogHelper.getColorText(preferenceHelper.dailyWordColor)
|
||||
setTextColor(preferenceHelper.dailyWordColor)
|
||||
}
|
||||
|
||||
binding.selectWidgetBackgroundColor.apply {
|
||||
text = bottomDialogHelper.getColorText(preferenceHelper.widgetBackgroundColor)
|
||||
setTextColor(preferenceHelper.widgetBackgroundColor)
|
||||
}
|
||||
selectWidgetBackgroundColor.apply {
|
||||
text = bottomDialogHelper.getColorText(preferenceHelper.widgetBackgroundColor)
|
||||
setTextColor(preferenceHelper.widgetBackgroundColor)
|
||||
}
|
||||
|
||||
binding.selectWidgetTextColor.apply {
|
||||
text = bottomDialogHelper.getColorText(preferenceHelper.widgetTextColor)
|
||||
setTextColor(preferenceHelper.widgetTextColor)
|
||||
selectWidgetTextColor.apply {
|
||||
text = bottomDialogHelper.getColorText(preferenceHelper.widgetTextColor)
|
||||
setTextColor(preferenceHelper.widgetTextColor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.Q)
|
||||
private fun observeClickListener() {
|
||||
binding.bottomColorDateView.setOnClickListener {
|
||||
showColorPickerDialog(
|
||||
binding.selectDateTextColor,
|
||||
REQUEST_KEY_DATE_COLOR,
|
||||
preferenceHelper.dateColor
|
||||
)
|
||||
}
|
||||
binding.apply {
|
||||
bottomColorDateView.setOnClickListener {
|
||||
showColorPickerDialog(
|
||||
binding.selectDateTextColor,
|
||||
REQUEST_KEY_DATE_COLOR,
|
||||
preferenceHelper.dateColor
|
||||
)
|
||||
}
|
||||
|
||||
binding.bottomColorTimeView.setOnClickListener {
|
||||
showColorPickerDialog(
|
||||
binding.selectTimeTextColor,
|
||||
REQUEST_KEY_TIME_COLOR,
|
||||
preferenceHelper.timeColor
|
||||
)
|
||||
}
|
||||
bottomColorTimeView.setOnClickListener {
|
||||
showColorPickerDialog(
|
||||
binding.selectTimeTextColor,
|
||||
REQUEST_KEY_TIME_COLOR,
|
||||
preferenceHelper.timeColor
|
||||
)
|
||||
}
|
||||
|
||||
binding.bottomColorAppView.setOnClickListener {
|
||||
showColorPickerDialog(
|
||||
binding.selectAppTextColor,
|
||||
REQUEST_KEY_APP_COLOR,
|
||||
preferenceHelper.appColor
|
||||
)
|
||||
}
|
||||
bottomColorAppView.setOnClickListener {
|
||||
showColorPickerDialog(
|
||||
binding.selectAppTextColor,
|
||||
REQUEST_KEY_APP_COLOR,
|
||||
preferenceHelper.appColor
|
||||
)
|
||||
}
|
||||
|
||||
binding.bottomColorBatteryView.setOnClickListener {
|
||||
showColorPickerDialog(
|
||||
binding.selectBatteryTextColor,
|
||||
REQUEST_KEY_BATTERY_COLOR,
|
||||
preferenceHelper.batteryColor
|
||||
)
|
||||
}
|
||||
bottomColorBatteryView.setOnClickListener {
|
||||
showColorPickerDialog(
|
||||
binding.selectBatteryTextColor,
|
||||
REQUEST_KEY_BATTERY_COLOR,
|
||||
preferenceHelper.batteryColor
|
||||
)
|
||||
}
|
||||
|
||||
binding.bottomColorWordView.setOnClickListener {
|
||||
showColorPickerDialog(
|
||||
binding.selectWordTextColor,
|
||||
REQUEST_KEY_DAILY_WORD_COLOR,
|
||||
preferenceHelper.dailyWordColor
|
||||
)
|
||||
}
|
||||
bottomColorWordView.setOnClickListener {
|
||||
showColorPickerDialog(
|
||||
binding.selectWordTextColor,
|
||||
REQUEST_KEY_DAILY_WORD_COLOR,
|
||||
preferenceHelper.dailyWordColor
|
||||
)
|
||||
}
|
||||
|
||||
binding.bottomColorAlarmClockView.setOnClickListener {
|
||||
showColorPickerDialog(
|
||||
binding.selectAlarmClockTextColor,
|
||||
REQUEST_KEY_DAILY_ALARM_CLOCK_COLOR,
|
||||
preferenceHelper.alarmClockColor
|
||||
)
|
||||
}
|
||||
bottomColorAlarmClockView.setOnClickListener {
|
||||
showColorPickerDialog(
|
||||
binding.selectAlarmClockTextColor,
|
||||
REQUEST_KEY_DAILY_ALARM_CLOCK_COLOR,
|
||||
preferenceHelper.alarmClockColor
|
||||
)
|
||||
}
|
||||
|
||||
binding.bottomColorWidgetBackgroundView.setOnClickListener {
|
||||
showColorPickerDialog(
|
||||
binding.selectWidgetBackgroundColor,
|
||||
REQUEST_KEY_WIDGET_BACKGROUND_COLOR,
|
||||
preferenceHelper.widgetBackgroundColor
|
||||
)
|
||||
}
|
||||
bottomColorWidgetBackgroundView.setOnClickListener {
|
||||
showColorPickerDialog(
|
||||
binding.selectWidgetBackgroundColor,
|
||||
REQUEST_KEY_WIDGET_BACKGROUND_COLOR,
|
||||
preferenceHelper.widgetBackgroundColor
|
||||
)
|
||||
}
|
||||
|
||||
binding.bottomColorWidgetTextView.setOnClickListener {
|
||||
showColorPickerDialog(
|
||||
binding.selectWidgetTextColor,
|
||||
REQUEST_KEY_WIDGET_TEXT_COLOR,
|
||||
preferenceHelper.widgetTextColor
|
||||
)
|
||||
bottomColorWidgetTextView.setOnClickListener {
|
||||
showColorPickerDialog(
|
||||
binding.selectWidgetTextColor,
|
||||
REQUEST_KEY_WIDGET_TEXT_COLOR,
|
||||
preferenceHelper.widgetTextColor
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,15 +3,19 @@ package com.github.droidworksstudio.launcher.ui.bottomsheetdialog
|
||||
import android.content.DialogInterface
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.appcompat.widget.AppCompatEditText
|
||||
import androidx.fragment.app.viewModels
|
||||
import com.github.droidworksstudio.launcher.databinding.BottomsheetdialogPaddingSettingsBinding
|
||||
import com.github.droidworksstudio.launcher.helper.AppHelper
|
||||
import com.github.droidworksstudio.launcher.helper.BottomDialogHelper
|
||||
import com.github.droidworksstudio.launcher.helper.PreferenceHelper
|
||||
import com.github.droidworksstudio.launcher.utils.Constants
|
||||
import com.github.droidworksstudio.launcher.viewmodel.PreferenceViewModel
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
@@ -57,19 +61,78 @@ class PaddingBottomSheetDialogFragment : BottomSheetDialogFragment() {
|
||||
private fun initView() {
|
||||
bottomDialogHelper.setupDialogStyle(dialog)
|
||||
|
||||
binding.selectAppPaddingSize.setText("${preferenceHelper.homeAppPadding}")
|
||||
binding.apply {
|
||||
selectAppPaddingSize.setText("${preferenceHelper.homeAppPadding}")
|
||||
selectAppGroupPaddingSize.setText("${preferenceHelper.homeAppsPadding}")
|
||||
|
||||
addMinMaxConstraint(selectAppPaddingSize, Constants.APP_PADDING_MIN, Constants.APP_PADDING_MAX)
|
||||
addMinMaxConstraint(selectAppGroupPaddingSize, Constants.APP_GROUP_PADDING_MIN, Constants.APP_GROUP_PADDING_MAX)
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.Q)
|
||||
private fun observeValueChange() {
|
||||
val appValue = binding.selectAppPaddingSize.text.toString()
|
||||
binding.apply {
|
||||
val appPaddingValue = selectAppPaddingSize.text.toString()
|
||||
val appGroupPaddingValue = selectAppGroupPaddingSize.text.toString()
|
||||
|
||||
val appFloatValue = parseFloatValue(appValue, preferenceHelper.homeAppPadding)
|
||||
dismiss()
|
||||
val appPaddingFloatValue = parseFloatValue(appPaddingValue, preferenceHelper.homeAppPadding)
|
||||
val appGroupPaddingFloatValue = parseFloatValue(appGroupPaddingValue, preferenceHelper.homeAppsPadding)
|
||||
dismiss()
|
||||
|
||||
preferenceViewModel.setAppPaddingSize(appFloatValue)
|
||||
val feedbackType = "select"
|
||||
appHelper.triggerHapticFeedback(context, feedbackType)
|
||||
preferenceViewModel.setAppPaddingSize(appPaddingFloatValue)
|
||||
preferenceViewModel.setAppGroupPaddingSize(appGroupPaddingFloatValue)
|
||||
|
||||
val feedbackType = "select"
|
||||
appHelper.triggerHapticFeedback(context, feedbackType)
|
||||
}
|
||||
}
|
||||
|
||||
fun addMinMaxConstraint(
|
||||
editText: AppCompatEditText,
|
||||
minValue: Double,
|
||||
maxValue: Double
|
||||
) {
|
||||
editText.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||
// No action needed here
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
try {
|
||||
val input = s.toString()
|
||||
if (input.isNotEmpty()) {
|
||||
val value = input.toDouble()
|
||||
|
||||
// Check if the value is out of bounds
|
||||
when {
|
||||
value < minValue -> {
|
||||
editText.setText(formatValue(minValue))
|
||||
editText.setSelection(editText.text?.length ?: 0)
|
||||
}
|
||||
|
||||
value > maxValue -> {
|
||||
editText.setText(formatValue(maxValue))
|
||||
editText.setSelection(editText.text?.length ?: 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (_: NumberFormatException) {
|
||||
}
|
||||
}
|
||||
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
// No action needed here
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun formatValue(value: Double): String {
|
||||
return if (value % 1 == 0.0) {
|
||||
value.toInt().toString() // Convert to Int if no decimal part
|
||||
} else {
|
||||
value.toString() // Keep as Double if there's a decimal part
|
||||
}
|
||||
}
|
||||
|
||||
private fun parseFloatValue(text: String, defaultValue: Float): Float {
|
||||
|
||||
@@ -57,37 +57,41 @@ class TextBottomSheetDialogFragment : BottomSheetDialogFragment() {
|
||||
private fun initView() {
|
||||
bottomDialogHelper.setupDialogStyle(dialog)
|
||||
|
||||
binding.selectDateTextSize.setText("${preferenceHelper.dateTextSize}")
|
||||
binding.selectTimeTextSize.setText("${preferenceHelper.timeTextSize}")
|
||||
binding.selectAppTextSize.setText("${preferenceHelper.appTextSize}")
|
||||
binding.selectBatteryTextSize.setText("${preferenceHelper.batteryTextSize}")
|
||||
binding.selectAlarmClockTextSize.setText("${preferenceHelper.alarmClockTextSize}")
|
||||
binding.selectDailyWordTextSize.setText("${preferenceHelper.dailyWordTextSize}")
|
||||
binding.apply {
|
||||
selectDateTextSize.setText("${preferenceHelper.dateTextSize}")
|
||||
selectTimeTextSize.setText("${preferenceHelper.timeTextSize}")
|
||||
selectAppTextSize.setText("${preferenceHelper.appTextSize}")
|
||||
selectBatteryTextSize.setText("${preferenceHelper.batteryTextSize}")
|
||||
selectAlarmClockTextSize.setText("${preferenceHelper.alarmClockTextSize}")
|
||||
selectDailyWordTextSize.setText("${preferenceHelper.dailyWordTextSize}")
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.Q)
|
||||
private fun observeValueChange() {
|
||||
val dateValue = binding.selectDateTextSize.text.toString()
|
||||
val timeValue = binding.selectTimeTextSize.text.toString()
|
||||
val appValue = binding.selectAppTextSize.text.toString()
|
||||
val batteryValue = binding.selectBatteryTextSize.text.toString()
|
||||
val alarmValue = binding.selectAlarmClockTextSize.text.toString()
|
||||
val wordValue = binding.selectDailyWordTextSize.text.toString()
|
||||
binding.apply {
|
||||
val dateValue = selectDateTextSize.text.toString()
|
||||
val timeValue = selectTimeTextSize.text.toString()
|
||||
val appValue = selectAppTextSize.text.toString()
|
||||
val batteryValue = selectBatteryTextSize.text.toString()
|
||||
val alarmValue = selectAlarmClockTextSize.text.toString()
|
||||
val wordValue = selectDailyWordTextSize.text.toString()
|
||||
|
||||
val dateFloatValue = parseFloatValue(dateValue, preferenceHelper.dateTextSize)
|
||||
val timeFloatValue = parseFloatValue(timeValue, preferenceHelper.timeTextSize)
|
||||
val appFloatValue = parseFloatValue(appValue, preferenceHelper.appTextSize)
|
||||
val batteryFloatValue = parseFloatValue(batteryValue, preferenceHelper.batteryTextSize)
|
||||
val alarmFloatValue = parseFloatValue(alarmValue, preferenceHelper.alarmClockTextSize)
|
||||
val wordFloatValue = parseFloatValue(wordValue, preferenceHelper.dailyWordTextSize)
|
||||
dismiss()
|
||||
val dateFloatValue = parseFloatValue(dateValue, preferenceHelper.dateTextSize)
|
||||
val timeFloatValue = parseFloatValue(timeValue, preferenceHelper.timeTextSize)
|
||||
val appFloatValue = parseFloatValue(appValue, preferenceHelper.appTextSize)
|
||||
val batteryFloatValue = parseFloatValue(batteryValue, preferenceHelper.batteryTextSize)
|
||||
val alarmFloatValue = parseFloatValue(alarmValue, preferenceHelper.alarmClockTextSize)
|
||||
val wordFloatValue = parseFloatValue(wordValue, preferenceHelper.dailyWordTextSize)
|
||||
dismiss()
|
||||
|
||||
preferenceViewModel.setDateTextSize(dateFloatValue)
|
||||
preferenceViewModel.setTimeTextSize(timeFloatValue)
|
||||
preferenceViewModel.setAppTextSize(appFloatValue)
|
||||
preferenceViewModel.setBatteryTextSize(batteryFloatValue)
|
||||
preferenceViewModel.setAlarmClockTextSize(alarmFloatValue)
|
||||
preferenceViewModel.setDailyWordTextSize(wordFloatValue)
|
||||
preferenceViewModel.setDateTextSize(dateFloatValue)
|
||||
preferenceViewModel.setTimeTextSize(timeFloatValue)
|
||||
preferenceViewModel.setAppTextSize(appFloatValue)
|
||||
preferenceViewModel.setBatteryTextSize(batteryFloatValue)
|
||||
preferenceViewModel.setAlarmClockTextSize(alarmFloatValue)
|
||||
preferenceViewModel.setDailyWordTextSize(wordFloatValue)
|
||||
}
|
||||
|
||||
val feedbackType = "save"
|
||||
appHelper.triggerHapticFeedback(context, feedbackType)
|
||||
|
||||
@@ -182,7 +182,7 @@ class HomeFragment : Fragment(),
|
||||
}
|
||||
|
||||
private fun setupRecyclerView() {
|
||||
val marginInPixels = 128
|
||||
val marginInPixels = preferenceHelper.homeAppsPadding
|
||||
|
||||
// Ensure correct type for layout params
|
||||
val layoutParams = (binding.appListAdapter.layoutParams as? LinearLayout.LayoutParams)
|
||||
@@ -192,8 +192,7 @@ class HomeFragment : Fragment(),
|
||||
)
|
||||
|
||||
// Set the bottom margin instead of top
|
||||
layoutParams.bottomMargin = marginInPixels
|
||||
layoutParams.topMargin = marginInPixels
|
||||
layoutParams.topMargin = marginInPixels.toInt()
|
||||
|
||||
// Set gravity to align RecyclerView to the bottom
|
||||
layoutParams.gravity = when (preferenceHelper.homeAppAlignment) {
|
||||
|
||||
@@ -53,6 +53,7 @@ object Constants {
|
||||
const val ALARM_CLOCK_TEXT_SIZE = "ALARM_CLOCK_TEXT_SIZE"
|
||||
const val DAILY_WORD_TEXT_SIZE = "DAILY_WORD_TEXT_SIZE"
|
||||
|
||||
const val APPS_PADDING = "APPS_PADDING"
|
||||
const val APP_TEXT_PADDING = "APP_TEXT_PADDING"
|
||||
|
||||
const val SHOW_APP_ICON = "SHOW_APP_ICON"
|
||||
@@ -96,6 +97,12 @@ object Constants {
|
||||
const val FILTER_STRENGTH_MIN = 0
|
||||
const val FILTER_STRENGTH_MAX = 100
|
||||
|
||||
const val APP_GROUP_PADDING_MIN = 0.0
|
||||
const val APP_GROUP_PADDING_MAX = 1000.0
|
||||
|
||||
const val APP_PADDING_MIN = 0.0
|
||||
const val APP_PADDING_MAX = 100.0
|
||||
|
||||
const val BACKUP_WRITE = 987
|
||||
const val BACKUP_READ = 876
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ class PreferenceViewModel @Inject constructor(
|
||||
private val searchFromStartLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||
private val autoKeyboardLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||
private val lockSettingsLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||
private val appGroupPaddingSizeLiveData: MutableLiveData<Float> = MutableLiveData()
|
||||
private val appPaddingSizeLiveData: MutableLiveData<Float> = MutableLiveData()
|
||||
|
||||
private val weatherOrderNumberLiveData: MutableLiveData<Int> = MutableLiveData()
|
||||
@@ -232,6 +233,11 @@ class PreferenceViewModel @Inject constructor(
|
||||
appPaddingSizeLiveData.postValue(preferenceHelper.homeAppPadding)
|
||||
}
|
||||
|
||||
fun setAppGroupPaddingSize(appPaddingSize: Float) {
|
||||
preferenceHelper.homeAppsPadding = appPaddingSize
|
||||
appGroupPaddingSizeLiveData.postValue(preferenceHelper.homeAppsPadding)
|
||||
}
|
||||
|
||||
fun setDoubleTap(action: Constants.Action) {
|
||||
preferenceHelper.doubleTapAction = action
|
||||
doubleTapActionLiveData.postValue((preferenceHelper.doubleTapAction))
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
android:layout_marginVertical="20dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="left|center"
|
||||
android:inputType="number"
|
||||
android:text="@string/appearance_bottom_dialog_desc_date"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
@@ -75,7 +74,6 @@
|
||||
android:layout_marginVertical="20dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="left|center"
|
||||
android:inputType="number"
|
||||
android:text="@string/appearance_bottom_dialog_desc_time"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
@@ -111,7 +109,6 @@
|
||||
android:layout_marginVertical="20dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="left|center"
|
||||
android:inputType="number"
|
||||
android:text="@string/appearance_bottom_dialog_desc_app"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
@@ -147,7 +144,6 @@
|
||||
android:layout_marginVertical="20dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="left|center"
|
||||
android:inputType="number"
|
||||
android:text="@string/appearance_bottom_dialog_desc_alarm"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
@@ -183,7 +179,6 @@
|
||||
android:layout_marginVertical="20dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="left|center"
|
||||
android:inputType="number"
|
||||
android:text="@string/appearance_bottom_dialog_desc_word"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
android:layout_marginVertical="20dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="left|center"
|
||||
android:inputType="number"
|
||||
android:text="@string/appearance_bottom_dialog_desc_date"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
@@ -75,7 +74,6 @@
|
||||
android:layout_marginVertical="20dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="left|center"
|
||||
android:inputType="number"
|
||||
android:text="@string/appearance_bottom_dialog_desc_time"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
@@ -111,7 +109,6 @@
|
||||
android:layout_marginVertical="20dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="left|center"
|
||||
android:inputType="number"
|
||||
android:text="@string/appearance_bottom_dialog_desc_app"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
@@ -147,7 +144,6 @@
|
||||
android:layout_marginVertical="20dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="left|center"
|
||||
android:inputType="number"
|
||||
android:text="@string/appearance_bottom_dialog_desc_battery"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
@@ -183,7 +179,6 @@
|
||||
android:layout_marginVertical="20dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="left|center"
|
||||
android:inputType="number"
|
||||
android:text="@string/appearance_bottom_dialog_desc_alarm"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
@@ -219,7 +214,6 @@
|
||||
android:layout_marginVertical="20dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="left|center"
|
||||
android:inputType="number"
|
||||
android:text="@string/appearance_bottom_dialog_desc_word"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
@@ -255,7 +249,6 @@
|
||||
android:layout_marginVertical="20dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="left|center"
|
||||
android:inputType="number"
|
||||
android:text="@string/appearance_bottom_dialog_desc_widget_background"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
@@ -291,7 +284,6 @@
|
||||
android:layout_marginVertical="20dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="left|center"
|
||||
android:inputType="number"
|
||||
android:text="@string/appearance_bottom_dialog_desc_widget_text"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
||||
@@ -25,6 +25,41 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/select_app_group_title"
|
||||
style="@style/TextDefaultStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginVertical="20dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="left|center"
|
||||
android:text="@string/appearance_bottom_dialog_desc_app_group"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="RtlHardcoded,TouchTargetSizeCheck" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatEditText
|
||||
android:id="@+id/select_app_group_padding_size"
|
||||
style="@style/TextDefaultStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginVertical="20dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="left|center"
|
||||
android:inputType="numberDecimal"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="RtlHardcoded,SpeakableTextPresentCheck,TouchTargetSizeCheck,VisualLintTextFieldSize" />
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -38,7 +73,6 @@
|
||||
android:layout_marginVertical="20dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="left|center"
|
||||
android:inputType="numberDecimal"
|
||||
android:text="@string/appearance_bottom_dialog_desc_app"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
android:layout_marginVertical="20dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="left|center"
|
||||
android:inputType="numberDecimal"
|
||||
android:text="@string/appearance_bottom_dialog_desc_date"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
@@ -75,7 +74,6 @@
|
||||
android:layout_marginVertical="20dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="left|center"
|
||||
android:inputType="numberDecimal"
|
||||
android:text="@string/appearance_bottom_dialog_desc_time"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
@@ -111,7 +109,6 @@
|
||||
android:layout_marginVertical="20dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="left|center"
|
||||
android:inputType="numberDecimal"
|
||||
android:text="@string/appearance_bottom_dialog_desc_app"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
@@ -147,7 +144,6 @@
|
||||
android:layout_marginVertical="20dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="left|center"
|
||||
android:inputType="numberDecimal"
|
||||
android:text="@string/appearance_bottom_dialog_desc_battery"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
@@ -183,7 +179,6 @@
|
||||
android:layout_marginVertical="20dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="left|center"
|
||||
android:inputType="numberDecimal"
|
||||
android:text="@string/appearance_bottom_dialog_desc_word"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
@@ -219,7 +214,6 @@
|
||||
android:layout_marginVertical="20dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="left|center"
|
||||
android:inputType="numberDecimal"
|
||||
android:text="@string/appearance_bottom_dialog_desc_alarm"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
||||
@@ -116,7 +116,8 @@
|
||||
<string name="appearance_bottom_dialog_alignment_title">Alignment</string>
|
||||
<string name="appearance_bottom_dialog_desc_date">Date\u0020:\u0020</string>
|
||||
<string name="appearance_bottom_dialog_desc_time">Time\u0020:\u0020 </string>
|
||||
<string name="appearance_bottom_dialog_desc_app">App\u0020:\u0020</string>
|
||||
<string name="appearance_bottom_dialog_desc_app">Apps\u0020:\u0020</string>
|
||||
<string name="appearance_bottom_dialog_desc_app_group">Apps Group\u0020:\u0020</string>
|
||||
<string name="appearance_bottom_dialog_desc_alarm">Alarm\u0020:\u0020</string>
|
||||
<string name="appearance_bottom_dialog_desc_word">Word\u0020:\u0020</string>
|
||||
<string name="appearance_bottom_dialog_desc_battery">Battery\u0020:\u0020 </string>
|
||||
|
||||
Reference in New Issue
Block a user