update wallpaper ui, update color picker ui, update intents and add custom logger for the widget

This commit is contained in:
Tommaso Berlose
2020-05-07 12:34:48 +02:00
parent 37cb43dc80
commit 5ca06e817e
28 changed files with 313 additions and 165 deletions

View File

@ -106,9 +106,7 @@ class ClockSettingsFragment : Fragment() {
})
viewModel.showNextAlarm.observe(viewLifecycleOwner, Observer {
maintainScrollPosition {
show_next_alarm_label?.text = if (it) getString(R.string.settings_visible) else getString(R.string.settings_not_visible)
}
updateNextAlarmWarningUi()
})
viewModel.clockAppName.observe(viewLifecycleOwner, Observer {
@ -168,17 +166,20 @@ class ClockSettingsFragment : Fragment() {
}
private fun updateNextAlarmWarningUi() {
show_next_alarm_warning.isVisible = AlarmHelper.isAlarmProbablyWrong(requireContext())
with(requireContext().getSystemService(Context.ALARM_SERVICE) as AlarmManager) {
val alarm = nextAlarmClock
if (alarm != null) {
if (AlarmHelper.isAlarmProbablyWrong(requireContext()) && alarm != null && alarm.showIntent != null) {
val pm = requireContext().packageManager as PackageManager
val appNameOrPackage = try {
pm.getApplicationLabel(pm.getApplicationInfo(nextAlarmClock.showIntent.creatorPackage ?: "", 0))
pm.getApplicationLabel(pm.getApplicationInfo(alarm.showIntent?.creatorPackage ?: "", 0))
} catch (e: Exception) {
nextAlarmClock.showIntent.creatorPackage
alarm.showIntent?.creatorPackage ?: ""
}
show_next_alarm_warning.text = getString(R.string.next_alarm_warning).format(appNameOrPackage)
} else {
maintainScrollPosition {
show_next_alarm_label?.text = if (Preferences.showNextAlarm) getString(R.string.settings_visible) else getString(R.string.settings_not_visible)
}
}
}
}

View File

@ -184,7 +184,7 @@ class GeneralSettingsFragment : Fragment() {
BottomSheetColorPicker(requireContext(),
colors = colors,
header = getString(R.string.settings_font_color_title),
selected = ColorHelper.getFontColor(),
getSelected = ColorHelper::getFontColorRgb,
onColorSelected = { color: Int ->
val colorString = Integer.toHexString(color)
Preferences.textGlobalColor = "#" + if (colorString.length > 6) colorString.substring(2) else colorString
@ -201,7 +201,7 @@ class GeneralSettingsFragment : Fragment() {
BottomSheetColorPicker(requireContext(),
colors = colors,
header = getString(R.string.settings_background_color_title),
selected = ColorHelper.getBackgroundColor(),
getSelected = { ColorHelper.getBackgroundColorRgb() },
onColorSelected = { color: Int ->
val colorString = Integer.toHexString(color)
Preferences.backgroundCardColor = "#" + if (colorString.length > 6) colorString.substring(2) else colorString