make the view compound drawable coloring more reliable

This commit is contained in:
tibbi 2021-11-19 13:31:56 +01:00
parent c812483f13
commit 36f94c2ebd
4 changed files with 11 additions and 10 deletions

View File

@ -34,7 +34,7 @@ class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callba
TimePickerDialog(context, context.getDialogTheme(), timeSetListener, alarm.timeInMinutes / 60, alarm.timeInMinutes % 60, context.config.use24HourFormat).show() TimePickerDialog(context, context.getDialogTheme(), timeSetListener, alarm.timeInMinutes / 60, alarm.timeInMinutes % 60, context.config.use24HourFormat).show()
} }
edit_alarm_sound.colorLeftDrawable(textColor) edit_alarm_sound.colorCompoundDrawable(textColor)
edit_alarm_sound.text = alarm.soundTitle edit_alarm_sound.text = alarm.soundTitle
edit_alarm_sound.setOnClickListener { edit_alarm_sound.setOnClickListener {
SelectAlarmSoundDialog(activity, alarm.soundUri, AudioManager.STREAM_ALARM, PICK_AUDIO_FILE_INTENT_ID, RingtoneManager.TYPE_ALARM, true, SelectAlarmSoundDialog(activity, alarm.soundUri, AudioManager.STREAM_ALARM, PICK_AUDIO_FILE_INTENT_ID, RingtoneManager.TYPE_ALARM, true,
@ -51,7 +51,7 @@ class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callba
}) })
} }
edit_alarm_vibrate.colorLeftDrawable(textColor) edit_alarm_vibrate.colorCompoundDrawable(textColor)
edit_alarm_vibrate.isChecked = alarm.vibrate edit_alarm_vibrate.isChecked = alarm.vibrate
edit_alarm_vibrate_holder.setOnClickListener { edit_alarm_vibrate_holder.setOnClickListener {
edit_alarm_vibrate.toggle() edit_alarm_vibrate.toggle()

View File

@ -23,14 +23,14 @@ class EditTimerDialog(val activity: SimpleActivity, val timer: Timer, val callba
view.apply { view.apply {
edit_timer_initial_time.colorLeftDrawable(textColor) edit_timer_initial_time.colorCompoundDrawable(textColor)
edit_timer_initial_time.text = timer.seconds.getFormattedDuration() edit_timer_initial_time.text = timer.seconds.getFormattedDuration()
edit_timer_initial_time.setTextColor(textColor) edit_timer_initial_time.setTextColor(textColor)
edit_timer_initial_time.setOnClickListener { edit_timer_initial_time.setOnClickListener {
changeDuration(timer) changeDuration(timer)
} }
edit_timer_vibrate.colorLeftDrawable(textColor) edit_timer_vibrate.colorCompoundDrawable(textColor)
edit_timer_vibrate.isChecked = timer.vibrate edit_timer_vibrate.isChecked = timer.vibrate
edit_timer_vibrate.setTextColor(textColor) edit_timer_vibrate.setTextColor(textColor)
edit_timer_vibrate_holder.setOnClickListener { edit_timer_vibrate_holder.setOnClickListener {
@ -39,7 +39,7 @@ class EditTimerDialog(val activity: SimpleActivity, val timer: Timer, val callba
timer.channelId = null timer.channelId = null
} }
edit_timer_sound.colorLeftDrawable(textColor) edit_timer_sound.colorCompoundDrawable(textColor)
edit_timer_sound.text = timer.soundTitle edit_timer_sound.text = timer.soundTitle
edit_timer_sound.setOnClickListener { edit_timer_sound.setOnClickListener {
SelectAlarmSoundDialog(activity, timer.soundUri, AudioManager.STREAM_ALARM, PICK_AUDIO_FILE_INTENT_ID, SelectAlarmSoundDialog(activity, timer.soundUri, AudioManager.STREAM_ALARM, PICK_AUDIO_FILE_INTENT_ID,

View File

@ -3,8 +3,9 @@ package com.simplemobiletools.clock.extensions
import android.widget.TextView import android.widget.TextView
import com.simplemobiletools.commons.extensions.applyColorFilter import com.simplemobiletools.commons.extensions.applyColorFilter
fun TextView.colorLeftDrawable(color: Int) { fun TextView.colorCompoundDrawable(color: Int) {
val leftImage = compoundDrawables.first() compoundDrawables.filterNotNull().forEach { drawable ->
leftImage.applyColorFilter(color) drawable.applyColorFilter(color)
setCompoundDrawables(leftImage, null, null, null) setCompoundDrawables(drawable, null, null, null)
}
} }

View File

@ -112,7 +112,7 @@ class ClockFragment : Fragment() {
val nextAlarm = requireContext().getNextAlarm() val nextAlarm = requireContext().getNextAlarm()
clock_alarm.beVisibleIf(nextAlarm.isNotEmpty()) clock_alarm.beVisibleIf(nextAlarm.isNotEmpty())
clock_alarm.text = nextAlarm clock_alarm.text = nextAlarm
clock_alarm.colorLeftDrawable(requireContext().config.textColor) clock_alarm.colorCompoundDrawable(requireContext().config.textColor)
} }
} }