set the timer to 5 minutes by default

This commit is contained in:
tibbi 2018-03-08 19:32:17 +01:00
parent c995e79a1a
commit a7c915b4fd
4 changed files with 29 additions and 2 deletions

View File

@ -6,14 +6,19 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.simplemobiletools.clock.R
import com.simplemobiletools.clock.extensions.config
import com.simplemobiletools.commons.extensions.getFormattedDuration
import com.simplemobiletools.commons.extensions.updateTextColors
import kotlinx.android.synthetic.main.fragment_timer.*
import kotlinx.android.synthetic.main.fragment_timer.view.*
class TimerFragment : Fragment() {
lateinit var view: ViewGroup
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
view = inflater.inflate(R.layout.fragment_timer, container, false) as ViewGroup
view = (inflater.inflate(R.layout.fragment_timer, container, false) as ViewGroup).apply {
timer_time.text = context!!.config.lastTimerSeconds.getFormattedDuration()
}
return view
}
@ -26,6 +31,7 @@ class TimerFragment : Fragment() {
view.apply {
context!!.updateTextColors(timer_fragment)
}
setupTimer()
}
private fun setupTimer() {

View File

@ -23,4 +23,8 @@ class Config(context: Context) : BaseConfig(context) {
var editedTimeZoneTitles: Set<String>
get() = prefs.getStringSet(EDITED_TIME_ZONE_TITLES, HashSet())
set(editedTimeZoneTitles) = prefs.edit().putStringSet(EDITED_TIME_ZONE_TITLES, editedTimeZoneTitles).apply()
var lastTimerSeconds: Int
get() = prefs.getInt(LAST_TIMER_SECONDS, 300)
set(lastTimerSeconds) = prefs.edit().putInt(LAST_TIMER_SECONDS, lastTimerSeconds).apply()
}

View File

@ -7,6 +7,7 @@ const val SHOW_SECONDS = "show_seconds"
const val DISPLAY_OTHER_TIME_ZONES = "display_other_time_zones"
const val SELECTED_TIME_ZONES = "selected_time_zones"
const val EDITED_TIME_ZONE_TITLES = "edited_time_zone_titles"
const val LAST_TIMER_SECONDS = "last_timer_seconds"
const val TABS_COUNT = 4
const val EDITED_TIME_ZONE_SEPARATOR = ":"

View File

@ -1,8 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/timer_time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/normal_margin"
android:background="?attr/selectableItemBackground"
android:gravity="center_horizontal"
android:padding="@dimen/small_margin"
android:textSize="@dimen/stopwatch_text_size"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="00:00"/>
</android.support.design.widget.CoordinatorLayout>