always use shadow at the widget text

This commit is contained in:
tibbi
2022-04-21 11:37:49 +02:00
parent 96068665dc
commit ee09b59cda
8 changed files with 14 additions and 161 deletions

View File

@ -35,7 +35,6 @@ class SettingsActivity : SimpleActivity() {
setupVibrate()
setupTimerMaxReminder()
setupIncreaseVolumeGradually()
setupUseTextShadow()
setupCustomizeWidgetColors()
updateTextColors(settings_holder)
@ -46,7 +45,6 @@ class SettingsActivity : SimpleActivity() {
settings_alarm_tab_label,
settings_stopwatch_tab_label,
settings_timer_tab_label,
settings_widgets_label
).forEach {
it.setTextColor(getProperPrimaryColor())
}
@ -58,7 +56,6 @@ class SettingsActivity : SimpleActivity() {
settings_alarm_tab_holder,
settings_stopwatch_tab_holder,
settings_timer_tab_holder,
settings_widgets_holder
).forEach {
it.background.applyColorFilter(getProperBackgroundColor().getContrastColor())
}
@ -200,15 +197,6 @@ class SettingsActivity : SimpleActivity() {
}
}
private fun setupUseTextShadow() {
settings_use_text_shadow.isChecked = config.useTextShadow
settings_use_text_shadow_holder.setOnClickListener {
settings_use_text_shadow.toggle()
config.useTextShadow = settings_use_text_shadow.isChecked
updateWidgets()
}
}
private fun updateSnoozeText() {
settings_snooze_time.text = formatMinutesToTimeString(config.snoozeTime)
}

View File

@ -73,11 +73,8 @@ class WidgetDateTimeConfigureActivity : SimpleActivity() {
val calendar = Calendar.getInstance()
config_time.text = getFormattedTime(getPassedSeconds(), false, false).toString()
config_date.text = getFormattedDate(calendar)
if (config.useTextShadow) {
config_time.setShadowLayer(1f, 0f, 1f, Color.BLACK)
config_date.setShadowLayer(1f, 0f, 1f, Color.BLACK)
}
config_time.setShadowLayer(1f, 0f, 1f, Color.BLACK)
config_date.setShadowLayer(1f, 0f, 1f, Color.BLACK)
}
private fun saveConfig() {

View File

@ -66,10 +66,6 @@ class Config(context: Context) : BaseConfig(context) {
get() = prefs.getInt(ALARM_MAX_REMINDER_SECS, DEFAULT_MAX_ALARM_REMINDER_SECS)
set(alarmMaxReminderSecs) = prefs.edit().putInt(ALARM_MAX_REMINDER_SECS, alarmMaxReminderSecs).apply()
var useTextShadow: Boolean
get() = prefs.getBoolean(USE_TEXT_SHADOW, true)
set(useTextShadow) = prefs.edit().putBoolean(USE_TEXT_SHADOW, useTextShadow).apply()
var increaseVolumeGradually: Boolean
get() = prefs.getBoolean(INCREASE_VOLUME_GRADUALLY, true)
set(increaseVolumeGradually) = prefs.edit().putBoolean(INCREASE_VOLUME_GRADUALLY, increaseVolumeGradually).apply()

View File

@ -21,7 +21,6 @@ const val TIMER_MAX_REMINDER_SECS = "timer_max_reminder_secs"
const val ALARM_MAX_REMINDER_SECS = "alarm_max_reminder_secs"
const val ALARM_LAST_CONFIG = "alarm_last_config"
const val TIMER_LAST_CONFIG = "timer_last_config"
const val USE_TEXT_SHADOW = "use_text_shadow"
const val INCREASE_VOLUME_GRADUALLY = "increase_volume_gradually"
const val ALARMS_SORT_BY = "alarms_sort_by"

View File

@ -31,7 +31,7 @@ class MyWidgetDateTimeProvider : AppWidgetProvider() {
private fun performUpdate(context: Context) {
val appWidgetManager = AppWidgetManager.getInstance(context) ?: return
appWidgetManager.getAppWidgetIds(getComponentName(context)).forEach {
RemoteViews(context.packageName, getProperLayout(context)).apply {
RemoteViews(context.packageName, R.layout.widget_date_time).apply {
updateTexts(context, this)
updateColors(context, this)
setupAppOpenIntent(context, this)
@ -40,12 +40,6 @@ class MyWidgetDateTimeProvider : AppWidgetProvider() {
}
}
private fun getProperLayout(context: Context) = if (context.config.useTextShadow) {
R.layout.widget_date_time_with_shadow
} else {
R.layout.widget_date_time
}
private fun updateTexts(context: Context, views: RemoteViews) {
val timeText = context.getFormattedTime(getPassedSeconds(), false, false).toString()
val nextAlarm = getFormattedNextAlarm(context)
@ -67,12 +61,8 @@ class MyWidgetDateTimeProvider : AppWidgetProvider() {
setTextColor(R.id.widget_date, widgetTextColor)
setTextColor(R.id.widget_next_alarm, widgetTextColor)
if (context.config.useTextShadow) {
val bitmap = getMultiplyColoredBitmap(R.drawable.ic_clock_shadowed, widgetTextColor, context)
setImageViewBitmap(R.id.widget_next_alarm_image, bitmap)
} else {
setImageViewBitmap(R.id.widget_next_alarm_image, context.resources.getColoredBitmap(R.drawable.ic_alarm_vector, widgetTextColor))
}
val bitmap = getMultiplyColoredBitmap(R.drawable.ic_clock_shadowed, widgetTextColor, context)
setImageViewBitmap(R.id.widget_next_alarm_image, bitmap)
}
}