allow customizing the default max timer reminder duration
This commit is contained in:
parent
afa4599f5e
commit
3fed41e03b
|
@ -4,6 +4,7 @@ import android.os.Bundle
|
|||
import com.simplemobiletools.clock.R
|
||||
import com.simplemobiletools.clock.extensions.config
|
||||
import com.simplemobiletools.clock.helpers.DEFAULT_MAX_ALARM_REMINDER_SECS
|
||||
import com.simplemobiletools.clock.helpers.DEFAULT_MAX_TIMER_REMINDER_SECS
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.MINUTE_SECONDS
|
||||
import kotlinx.android.synthetic.main.activity_settings.*
|
||||
|
@ -28,13 +29,14 @@ class SettingsActivity : SimpleActivity() {
|
|||
setupUseSameSnooze()
|
||||
setupSnoozeTime()
|
||||
setupVibrate()
|
||||
setupTimerMaxReminder()
|
||||
updateTextColors(settings_holder)
|
||||
setupSectionColors()
|
||||
}
|
||||
|
||||
private fun setupSectionColors() {
|
||||
val adjustedPrimaryColor = getAdjustedPrimaryColor()
|
||||
arrayListOf(clock_tab_label, alarm_tab_label, stopwatch_tab_label).forEach {
|
||||
arrayListOf(clock_tab_label, alarm_tab_label, stopwatch_tab_label, timer_tab_label).forEach {
|
||||
it.setTextColor(adjustedPrimaryColor)
|
||||
}
|
||||
}
|
||||
|
@ -125,11 +127,25 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun updateAlarmMaxReminderText() {
|
||||
settings_alarm_max_reminder.text = formatSecondsToTimeString(config.alarmMaxReminderSecs)
|
||||
private fun setupTimerMaxReminder() {
|
||||
updateTimerMaxReminderText()
|
||||
settings_timer_max_reminder_holder.setOnClickListener {
|
||||
showPickSecondsDialog(config.timerMaxReminderSecs, true, true) {
|
||||
config.timerMaxReminderSecs = if (it != 0) it else DEFAULT_MAX_TIMER_REMINDER_SECS
|
||||
updateTimerMaxReminderText()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateSnoozeText() {
|
||||
settings_snooze_time.text = formatMinutesToTimeString(config.snoozeTime)
|
||||
}
|
||||
|
||||
private fun updateAlarmMaxReminderText() {
|
||||
settings_alarm_max_reminder.text = formatSecondsToTimeString(config.alarmMaxReminderSecs)
|
||||
}
|
||||
|
||||
private fun updateTimerMaxReminderText() {
|
||||
settings_timer_max_reminder.text = formatSecondsToTimeString(config.timerMaxReminderSecs)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import com.simplemobiletools.clock.dialogs.MyTimePickerDialogDialog
|
|||
import com.simplemobiletools.clock.dialogs.SelectAlarmSoundDialog
|
||||
import com.simplemobiletools.clock.extensions.colorLeftDrawable
|
||||
import com.simplemobiletools.clock.extensions.config
|
||||
import com.simplemobiletools.clock.extensions.hideNotification
|
||||
import com.simplemobiletools.clock.helpers.TIMER_NOTIF_ID
|
||||
import com.simplemobiletools.clock.receivers.TimerReceiver
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
|
@ -184,6 +185,10 @@ class TimerFragment : Fragment() {
|
|||
val notification = getNotification(context!!, pendingIntent)
|
||||
val notificationManager = context!!.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
notificationManager.notify(TIMER_NOTIF_ID, notification)
|
||||
|
||||
Handler().postDelayed({
|
||||
context!!.hideNotification(TIMER_NOTIF_ID)
|
||||
}, context!!.config.timerMaxReminderSecs * 1000L)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -42,6 +42,10 @@ class Config(context: Context) : BaseConfig(context) {
|
|||
get() = prefs.getString(TIMER_SOUND_TITLE, context.getDefaultAlarmTitle())
|
||||
set(timerSoundTitle) = prefs.edit().putString(TIMER_SOUND_TITLE, timerSoundTitle).apply()
|
||||
|
||||
var timerMaxReminderSecs: Int
|
||||
get() = prefs.getInt(TIMER_MAX_REMINDER_SECS, DEFAULT_MAX_TIMER_REMINDER_SECS)
|
||||
set(timerMaxReminderSecs) = prefs.edit().putInt(TIMER_MAX_REMINDER_SECS, timerMaxReminderSecs).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()
|
||||
|
|
|
@ -11,6 +11,7 @@ const val TIMER_SECONDS = "timer_seconds"
|
|||
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_MAX_REMINDER_SECS = "timer_max_reminder_secs"
|
||||
const val ALARM_MAX_REMINDER_SECS = "alarm_max_reminder_secs"
|
||||
|
||||
const val TABS_COUNT = 4
|
||||
|
@ -20,6 +21,7 @@ const val DEFAULT_ALARM_MINUTES = 480
|
|||
const val DAY_MINUTES = 1440
|
||||
const val TIMER_NOTIF_ID = 9999
|
||||
const val DEFAULT_MAX_ALARM_REMINDER_SECS = 300
|
||||
const val DEFAULT_MAX_TIMER_REMINDER_SECS = 60
|
||||
|
||||
const val SORT_BY_LAP = 1
|
||||
const val SORT_BY_LAP_TIME = 2
|
||||
|
|
|
@ -316,5 +316,58 @@
|
|||
android:paddingStart="@dimen/medium_margin"
|
||||
android:text="@string/vibrate_on_button_press"/>
|
||||
</RelativeLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/timer_tab_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1px"
|
||||
android:background="@color/divider_grey"
|
||||
android:importantForAccessibility="no"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/timer_tab_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/bigger_margin"
|
||||
android:layout_marginStart="@dimen/bigger_margin"
|
||||
android:layout_marginTop="@dimen/activity_margin"
|
||||
android:text="@string/timer_tab"
|
||||
android:textAllCaps="true"
|
||||
android:textSize="@dimen/smaller_text_size"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_timer_max_reminder_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/medium_margin"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingBottom="@dimen/bigger_margin"
|
||||
android:paddingLeft="@dimen/normal_margin"
|
||||
android:paddingRight="@dimen/normal_margin"
|
||||
android:paddingTop="@dimen/bigger_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/settings_timer_max_reminder_label"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toLeftOf="@+id/settings_timer_max_reminder"
|
||||
android:layout_toStartOf="@+id/settings_timer_max_reminder"
|
||||
android:paddingLeft="@dimen/medium_margin"
|
||||
android:paddingRight="@dimen/medium_margin"
|
||||
android:text="@string/max_reminder_length"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/settings_timer_max_reminder"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginEnd="@dimen/small_margin"
|
||||
android:layout_marginRight="@dimen/small_margin"
|
||||
android:background="@null"
|
||||
android:clickable="false"/>
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
|
Loading…
Reference in New Issue