mirror of
https://github.com/SimpleMobileTools/Simple-Clock.git
synced 2025-03-30 03:10:31 +02:00
show a time picker at pressing initial time at the timer tab
This commit is contained in:
parent
8b429a5006
commit
9fc8115f26
@ -44,6 +44,7 @@ dependencies {
|
||||
implementation 'com.simplemobiletools:commons:3.15.9'
|
||||
implementation 'com.facebook.stetho:stetho:1.5.0'
|
||||
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
|
||||
implementation 'com.shawnlin:number-picker:2.4.6'
|
||||
}
|
||||
|
||||
Properties props = new Properties()
|
||||
|
@ -0,0 +1,34 @@
|
||||
package com.simplemobiletools.clock.dialogs
|
||||
|
||||
import android.support.v7.app.AlertDialog
|
||||
import com.simplemobiletools.clock.R
|
||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
||||
import com.simplemobiletools.clock.extensions.config
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import kotlinx.android.synthetic.main.dialog_my_time_picker.view.*
|
||||
|
||||
class MyTimePickerDialogDialog(val activity: SimpleActivity, val initialSeconds: Int, private val callback: () -> Unit) {
|
||||
private var view = activity.layoutInflater.inflate(R.layout.dialog_my_time_picker, null)
|
||||
|
||||
init {
|
||||
view.apply {
|
||||
val textColor = activity.config.textColor
|
||||
arrayOf(my_time_picker_hours, my_time_picker_minutes, my_time_picker_seconds).forEach {
|
||||
it.textColor = textColor
|
||||
it.selectedTextColor = textColor
|
||||
it.dividerColor = textColor
|
||||
}
|
||||
}
|
||||
|
||||
AlertDialog.Builder(activity)
|
||||
.setPositiveButton(R.string.ok, { dialog, which -> dialogConfirmed() })
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this)
|
||||
}
|
||||
}
|
||||
|
||||
private fun dialogConfirmed() {
|
||||
callback()
|
||||
}
|
||||
}
|
@ -9,6 +9,8 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.simplemobiletools.clock.R
|
||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
||||
import com.simplemobiletools.clock.dialogs.MyTimePickerDialogDialog
|
||||
import com.simplemobiletools.clock.extensions.colorLeftDrawable
|
||||
import com.simplemobiletools.clock.extensions.config
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
@ -80,6 +82,11 @@ class TimerFragment : Fragment() {
|
||||
|
||||
timer_initial_time.text = config.timerSeconds.getFormattedDuration()
|
||||
timer_initial_time.colorLeftDrawable(textColor)
|
||||
timer_initial_time.setOnClickListener {
|
||||
MyTimePickerDialogDialog(activity as SimpleActivity, config.timerSeconds) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
timer_vibrate.isChecked = config.timerVibrate
|
||||
timer_vibrate.colorLeftDrawable(textColor)
|
||||
|
44
app/src/main/res/layout/dialog_my_time_picker.xml
Normal file
44
app/src/main/res/layout/dialog_my_time_picker.xml
Normal file
@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/my_time_picker_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:padding="@dimen/activity_margin">
|
||||
|
||||
<com.shawnlin.numberpicker.NumberPicker
|
||||
android:id="@+id/my_time_picker_hours"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/medium_margin"
|
||||
app:np_fadingEdgeEnabled="false"
|
||||
app:np_max="23"
|
||||
app:np_min="0"
|
||||
app:np_selectedTextSize="@dimen/big_text_size"
|
||||
app:np_textSize="@dimen/big_text_size"/>
|
||||
|
||||
<com.shawnlin.numberpicker.NumberPicker
|
||||
android:id="@+id/my_time_picker_minutes"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/medium_margin"
|
||||
app:np_fadingEdgeEnabled="false"
|
||||
app:np_max="59"
|
||||
app:np_min="0"
|
||||
app:np_selectedTextSize="@dimen/big_text_size"
|
||||
app:np_textSize="@dimen/big_text_size"/>
|
||||
|
||||
<com.shawnlin.numberpicker.NumberPicker
|
||||
android:id="@+id/my_time_picker_seconds"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/medium_margin"
|
||||
app:np_fadingEdgeEnabled="false"
|
||||
app:np_max="59"
|
||||
app:np_min="0"
|
||||
app:np_selectedTextSize="@dimen/big_text_size"
|
||||
app:np_textSize="@dimen/big_text_size"/>
|
||||
|
||||
</LinearLayout>
|
Loading…
x
Reference in New Issue
Block a user