mirror of
				https://github.com/SimpleMobileTools/Simple-Clock.git
				synced 2025-06-05 22:19:17 +02:00 
			
		
		
		
	make the view compound drawable coloring more reliable
This commit is contained in:
		| @@ -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() | ||||
|             } | ||||
|  | ||||
|             edit_alarm_sound.colorLeftDrawable(textColor) | ||||
|             edit_alarm_sound.colorCompoundDrawable(textColor) | ||||
|             edit_alarm_sound.text = alarm.soundTitle | ||||
|             edit_alarm_sound.setOnClickListener { | ||||
|                 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_holder.setOnClickListener { | ||||
|                 edit_alarm_vibrate.toggle() | ||||
|   | ||||
| @@ -23,14 +23,14 @@ class EditTimerDialog(val activity: SimpleActivity, val timer: Timer, val callba | ||||
|  | ||||
|         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.setTextColor(textColor) | ||||
|             edit_timer_initial_time.setOnClickListener { | ||||
|                 changeDuration(timer) | ||||
|             } | ||||
|  | ||||
|             edit_timer_vibrate.colorLeftDrawable(textColor) | ||||
|             edit_timer_vibrate.colorCompoundDrawable(textColor) | ||||
|             edit_timer_vibrate.isChecked = timer.vibrate | ||||
|             edit_timer_vibrate.setTextColor(textColor) | ||||
|             edit_timer_vibrate_holder.setOnClickListener { | ||||
| @@ -39,7 +39,7 @@ class EditTimerDialog(val activity: SimpleActivity, val timer: Timer, val callba | ||||
|                 timer.channelId = null | ||||
|             } | ||||
|  | ||||
|             edit_timer_sound.colorLeftDrawable(textColor) | ||||
|             edit_timer_sound.colorCompoundDrawable(textColor) | ||||
|             edit_timer_sound.text = timer.soundTitle | ||||
|             edit_timer_sound.setOnClickListener { | ||||
|                 SelectAlarmSoundDialog(activity, timer.soundUri, AudioManager.STREAM_ALARM, PICK_AUDIO_FILE_INTENT_ID, | ||||
|   | ||||
| @@ -3,8 +3,9 @@ package com.simplemobiletools.clock.extensions | ||||
| import android.widget.TextView | ||||
| import com.simplemobiletools.commons.extensions.applyColorFilter | ||||
|  | ||||
| fun TextView.colorLeftDrawable(color: Int) { | ||||
|     val leftImage = compoundDrawables.first() | ||||
|     leftImage.applyColorFilter(color) | ||||
|     setCompoundDrawables(leftImage, null, null, null) | ||||
| fun TextView.colorCompoundDrawable(color: Int) { | ||||
|     compoundDrawables.filterNotNull().forEach { drawable -> | ||||
|         drawable.applyColorFilter(color) | ||||
|         setCompoundDrawables(drawable, null, null, null) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -112,7 +112,7 @@ class ClockFragment : Fragment() { | ||||
|             val nextAlarm = requireContext().getNextAlarm() | ||||
|             clock_alarm.beVisibleIf(nextAlarm.isNotEmpty()) | ||||
|             clock_alarm.text = nextAlarm | ||||
|             clock_alarm.colorLeftDrawable(requireContext().config.textColor) | ||||
|             clock_alarm.colorCompoundDrawable(requireContext().config.textColor) | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user