Skip to content

Commit

Permalink
Feature: Added a new App Group Padding setting
Browse files Browse the repository at this point in the history
  • Loading branch information
CreativeCodeCat committed Nov 26, 2024
1 parent 3468c40 commit a5397af
Show file tree
Hide file tree
Showing 14 changed files with 380 additions and 268 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}

Expand All @@ -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
)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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) {
Expand Down
Loading

0 comments on commit a5397af

Please sign in to comment.