mirror of
				https://github.com/SimpleMobileTools/Simple-Clock.git
				synced 2025-06-05 22:19:17 +02:00 
			
		
		
		
	Clock - Add labels to timers
This commit is contained in:
		| @@ -43,6 +43,7 @@ class TimerFragment : Fragment() { | ||||
|             val textColor = config.textColor | ||||
|  | ||||
|             timer_time.text = config.timerSeconds.getFormattedDuration() | ||||
|             timer_label.setText(config.timerLabel) | ||||
|  | ||||
|             requiredActivity.updateTextColors(timer_fragment) | ||||
|             timer_play_pause.background = resources.getColoredDrawableWithColor(R.drawable.circle_background_filled, context!!.getAdjustedPrimaryColor()) | ||||
| @@ -109,6 +110,10 @@ class TimerFragment : Fragment() { | ||||
|                             context.checkAlarmsWithDeletedSoundUri(sound.uri) | ||||
|                         }) | ||||
|             } | ||||
|  | ||||
|             timer_label.onTextChangeListener { text -> | ||||
|                 config.timerLabel = text | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return view | ||||
|   | ||||
| @@ -53,6 +53,10 @@ class Config(context: Context) : BaseConfig(context) { | ||||
|         get() = prefs.getInt(TIMER_MAX_REMINDER_SECS, DEFAULT_MAX_TIMER_REMINDER_SECS) | ||||
|         set(timerMaxReminderSecs) = prefs.edit().putInt(TIMER_MAX_REMINDER_SECS, timerMaxReminderSecs).apply() | ||||
|  | ||||
|     var timerLabel: String? | ||||
|         get() = prefs.getString(TIMER_LABEL, null) | ||||
|         set(label) = prefs.edit().putString(TIMER_LABEL, label).apply() | ||||
|  | ||||
|     var alarmMaxReminderSecs: Int | ||||
|         get() = prefs.getInt(ALARM_MAX_REMINDER_SECS, DEFAULT_MAX_ALARM_REMINDER_SECS) | ||||
|         set(alarmMaxReminderSecs) = prefs.edit().putInt(ALARM_MAX_REMINDER_SECS, alarmMaxReminderSecs).apply() | ||||
|   | ||||
| @@ -13,6 +13,7 @@ const val TIMER_STATE = "timer_state" | ||||
| const val TIMER_VIBRATE = "timer_vibrate" | ||||
| const val TIMER_SOUND_URI = "timer_sound_uri" | ||||
| const val TIMER_SOUND_TITLE = "timer_sound_title" | ||||
| const val TIMER_LABEL = "timer_label" | ||||
| 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" | ||||
|   | ||||
| @@ -1,6 +1,5 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <androidx.constraintlayout.widget.ConstraintLayout | ||||
|     xmlns:android="http://schemas.android.com/apk/res/android" | ||||
| <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|     xmlns:tools="http://schemas.android.com/tools" | ||||
|     android:id="@+id/timer_fragment" | ||||
| @@ -67,6 +66,37 @@ | ||||
|         app:layout_constraintTop_toBottomOf="@+id/timer_vibrate_holder" | ||||
|         tools:text="Default alarm" /> | ||||
|  | ||||
|     <LinearLayout | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="wrap_content" | ||||
|         android:gravity="center_vertical" | ||||
|         android:orientation="horizontal" | ||||
|         android:paddingStart="@dimen/activity_margin" | ||||
|         android:paddingTop="@dimen/medium_margin" | ||||
|         android:paddingEnd="@dimen/activity_margin" | ||||
|         android:paddingBottom="@dimen/medium_margin" | ||||
|         app:layout_constraintEnd_toEndOf="parent" | ||||
|         app:layout_constraintStart_toStartOf="parent" | ||||
|         app:layout_constraintTop_toBottomOf="@+id/timer_sound"> | ||||
|  | ||||
|         <ImageView | ||||
|             android:id="@+id/timer_label_image" | ||||
|             android:layout_width="wrap_content" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:src="@drawable/ic_label_vector" /> | ||||
|  | ||||
|         <com.simplemobiletools.commons.views.MyEditText | ||||
|             android:id="@+id/timer_label" | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:layout_marginStart="10dp" | ||||
|             android:hint="@string/label" | ||||
|             android:maxLines="1" | ||||
|             android:singleLine="true" | ||||
|             android:textCursorDrawable="@null" | ||||
|             android:textSize="@dimen/normal_text_size" /> | ||||
|     </LinearLayout> | ||||
|  | ||||
|     <ImageView | ||||
|         android:id="@+id/timer_play_pause" | ||||
|         android:layout_width="@dimen/stopwatch_button_size" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Pavol Franek
					Pavol Franek