diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/helper/PreferenceHelper.kt b/app/src/main/java/com/github/droidworksstudio/launcher/helper/PreferenceHelper.kt index 62a95ad2..4fa617b2 100644 --- a/app/src/main/java/com/github/droidworksstudio/launcher/helper/PreferenceHelper.kt +++ b/app/src/main/java/com/github/droidworksstudio/launcher/helper/PreferenceHelper.kt @@ -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() diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/ui/bottomsheetdialog/AlignmentBottomSheetDialogFragment.kt b/app/src/main/java/com/github/droidworksstudio/launcher/ui/bottomsheetdialog/AlignmentBottomSheetDialogFragment.kt index 4b02c5d2..78b63122 100644 --- a/app/src/main/java/com/github/droidworksstudio/launcher/ui/bottomsheetdialog/AlignmentBottomSheetDialogFragment.kt +++ b/app/src/main/java/com/github/droidworksstudio/launcher/ui/bottomsheetdialog/AlignmentBottomSheetDialogFragment.kt @@ -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) + } - binding.selectTimeTextSize.apply { - text = appHelper.gravityToString(preferenceHelper.homeTimeAlignment) - } + selectTimeTextSize.apply { + text = appHelper.gravityToString(preferenceHelper.homeTimeAlignment) + } - binding.selectAppTextSize.apply { - text = appHelper.gravityToString(preferenceHelper.homeAppAlignment) - } + selectAppTextSize.apply { + text = appHelper.gravityToString(preferenceHelper.homeAppAlignment) + } - binding.selectWordTextSize.apply { - text = appHelper.gravityToString(preferenceHelper.homeDailyWordAlignment) - } + selectWordTextSize.apply { + text = appHelper.gravityToString(preferenceHelper.homeDailyWordAlignment) + } - binding.selectAlarmClockTextSize.apply { - text = appHelper.gravityToString(preferenceHelper.homeAlarmClockAlignment) + 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 - ) - } - - REQUEST_KEY_TIME_ALIGNMENT -> { - setAlignment( - selectedAlignment, - gravity, - binding.selectTimeTextSize - ) - } - - REQUEST_KEY_DATE_ALIGNMENT -> { - setAlignment( - selectedAlignment, - gravity, - binding.selectDateTextSize - ) - } - - REQUEST_KEY_WORD_ALIGNMENT -> { - setAlignment( - selectedAlignment, - gravity, - binding.selectWordTextSize - ) - } - - REQUEST_KEY_ALARM_CLOCK_ALIGNMENT -> { - setAlignment( - selectedAlignment, - gravity, - binding.selectAlarmClockTextSize - ) + binding.apply { + when (selectedAlignment) { + REQUEST_KEY_APP_ALIGNMENT -> { + setAlignment( + selectedAlignment, + gravity, + selectAppTextSize + ) + } + + REQUEST_KEY_TIME_ALIGNMENT -> { + setAlignment( + selectedAlignment, + gravity, + selectTimeTextSize + ) + } + + REQUEST_KEY_DATE_ALIGNMENT -> { + setAlignment( + selectedAlignment, + gravity, + selectDateTextSize + ) + } + + REQUEST_KEY_WORD_ALIGNMENT -> { + setAlignment( + selectedAlignment, + gravity, + selectWordTextSize + ) + } + + REQUEST_KEY_ALARM_CLOCK_ALIGNMENT -> { + setAlignment( + selectedAlignment, + gravity, + selectAlarmClockTextSize + ) + } } } } diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/ui/bottomsheetdialog/AppInfoBottomSheetFragment.kt b/app/src/main/java/com/github/droidworksstudio/launcher/ui/bottomsheetdialog/AppInfoBottomSheetFragment.kt index 5117ecc1..bc01b855 100644 --- a/app/src/main/java/com/github/droidworksstudio/launcher/ui/bottomsheetdialog/AppInfoBottomSheetFragment.kt +++ b/app/src/main/java/com/github/droidworksstudio/launcher/ui/bottomsheetdialog/AppInfoBottomSheetFragment.kt @@ -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() - } + dismiss() + } - binding.bottomSheetRename.addTextChangedListener(object : TextWatcher { + bottomSheetRename.addTextChangedListener(object : TextWatcher { - override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) { - } + override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) { + } - override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) { - appInfo.appName = s.toString() + 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()) + if (s.isNullOrEmpty()) { + viewModel.updateAppInfoAppName(appInfo, appName.toString()) + } else { + viewModel.updateAppInfoAppName(appInfo, s.toString()) + } } - } - override fun afterTextChanged(s: Editable?) { - if (s.isNullOrEmpty()) { - binding.bottomSheetRename.setHintTextColor( - ContextCompat.getColor( - requireContext(), - R.color.white + 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() + 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() + } + + bottomSheetUninstall.setOnClickListener { + appStateClickListener?.onAppStateClicked(appInfo) + requireContext().unInstallApp(appInfo) + dismiss() + } - viewModel.updateAppHidden(appInfo, appInfo.hidden) - 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) { diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/ui/bottomsheetdialog/ColorBottomSheetDialogFragment.kt b/app/src/main/java/com/github/droidworksstudio/launcher/ui/bottomsheetdialog/ColorBottomSheetDialogFragment.kt index 9f38867a..24b2626e 100644 --- a/app/src/main/java/com/github/droidworksstudio/launcher/ui/bottomsheetdialog/ColorBottomSheetDialogFragment.kt +++ b/app/src/main/java/com/github/droidworksstudio/launcher/ui/bottomsheetdialog/ColorBottomSheetDialogFragment.kt @@ -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 + ) + } } } diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/ui/bottomsheetdialog/PaddingBottomSheetDialogFragment.kt b/app/src/main/java/com/github/droidworksstudio/launcher/ui/bottomsheetdialog/PaddingBottomSheetDialogFragment.kt index db797ac7..6bdf86bf 100644 --- a/app/src/main/java/com/github/droidworksstudio/launcher/ui/bottomsheetdialog/PaddingBottomSheetDialogFragment.kt +++ b/app/src/main/java/com/github/droidworksstudio/launcher/ui/bottomsheetdialog/PaddingBottomSheetDialogFragment.kt @@ -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 appPaddingFloatValue = parseFloatValue(appPaddingValue, preferenceHelper.homeAppPadding) + val appGroupPaddingFloatValue = parseFloatValue(appGroupPaddingValue, preferenceHelper.homeAppsPadding) + dismiss() - val appFloatValue = parseFloatValue(appValue, preferenceHelper.homeAppPadding) - dismiss() + preferenceViewModel.setAppPaddingSize(appPaddingFloatValue) + preferenceViewModel.setAppGroupPaddingSize(appGroupPaddingFloatValue) - preferenceViewModel.setAppPaddingSize(appFloatValue) - val feedbackType = "select" - appHelper.triggerHapticFeedback(context, feedbackType) + 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 { diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/ui/bottomsheetdialog/TextBottomSheetDialogFragment.kt b/app/src/main/java/com/github/droidworksstudio/launcher/ui/bottomsheetdialog/TextBottomSheetDialogFragment.kt index b74ea8d6..df9468ec 100644 --- a/app/src/main/java/com/github/droidworksstudio/launcher/ui/bottomsheetdialog/TextBottomSheetDialogFragment.kt +++ b/app/src/main/java/com/github/droidworksstudio/launcher/ui/bottomsheetdialog/TextBottomSheetDialogFragment.kt @@ -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() - - 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) + 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() + + 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) diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/ui/home/HomeFragment.kt b/app/src/main/java/com/github/droidworksstudio/launcher/ui/home/HomeFragment.kt index 1f42c5c3..9787d98b 100644 --- a/app/src/main/java/com/github/droidworksstudio/launcher/ui/home/HomeFragment.kt +++ b/app/src/main/java/com/github/droidworksstudio/launcher/ui/home/HomeFragment.kt @@ -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) { diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/utils/Constants.kt b/app/src/main/java/com/github/droidworksstudio/launcher/utils/Constants.kt index ee6ef5ea..f4849c12 100644 --- a/app/src/main/java/com/github/droidworksstudio/launcher/utils/Constants.kt +++ b/app/src/main/java/com/github/droidworksstudio/launcher/utils/Constants.kt @@ -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 diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/viewmodel/PreferenceViewModel.kt b/app/src/main/java/com/github/droidworksstudio/launcher/viewmodel/PreferenceViewModel.kt index ecc0c43e..f9e3eb38 100644 --- a/app/src/main/java/com/github/droidworksstudio/launcher/viewmodel/PreferenceViewModel.kt +++ b/app/src/main/java/com/github/droidworksstudio/launcher/viewmodel/PreferenceViewModel.kt @@ -47,6 +47,7 @@ class PreferenceViewModel @Inject constructor( private val searchFromStartLiveData: MutableLiveData = MutableLiveData() private val autoKeyboardLiveData: MutableLiveData = MutableLiveData() private val lockSettingsLiveData: MutableLiveData = MutableLiveData() + private val appGroupPaddingSizeLiveData: MutableLiveData = MutableLiveData() private val appPaddingSizeLiveData: MutableLiveData = MutableLiveData() private val weatherOrderNumberLiveData: MutableLiveData = 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)) diff --git a/app/src/main/res/layout/bottomsheetdialog_alignment_settings.xml b/app/src/main/res/layout/bottomsheetdialog_alignment_settings.xml index b4645884..4df4799d 100644 --- a/app/src/main/res/layout/bottomsheetdialog_alignment_settings.xml +++ b/app/src/main/res/layout/bottomsheetdialog_alignment_settings.xml @@ -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" diff --git a/app/src/main/res/layout/bottomsheetdialog_color_settings.xml b/app/src/main/res/layout/bottomsheetdialog_color_settings.xml index 290b54d7..dec22485 100644 --- a/app/src/main/res/layout/bottomsheetdialog_color_settings.xml +++ b/app/src/main/res/layout/bottomsheetdialog_color_settings.xml @@ -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" diff --git a/app/src/main/res/layout/bottomsheetdialog_padding_settings.xml b/app/src/main/res/layout/bottomsheetdialog_padding_settings.xml index c57bbc44..605a7c26 100644 --- a/app/src/main/res/layout/bottomsheetdialog_padding_settings.xml +++ b/app/src/main/res/layout/bottomsheetdialog_padding_settings.xml @@ -31,14 +31,48 @@ android:orientation="horizontal"> + + + + + + + + Alignment Date\u0020:\u0020 Time\u0020:\u0020 - App\u0020:\u0020 + Apps\u0020:\u0020 + Apps Group\u0020:\u0020 Alarm\u0020:\u0020 Word\u0020:\u0020 Battery\u0020:\u0020