diff --git a/app/build.gradle b/app/build.gradle index 31283be8..9c692f26 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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() diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/dialogs/MyTimePickerDialogDialog.kt b/app/src/main/kotlin/com/simplemobiletools/clock/dialogs/MyTimePickerDialogDialog.kt new file mode 100644 index 00000000..74466993 --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/clock/dialogs/MyTimePickerDialogDialog.kt @@ -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() + } +} diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/fragments/TimerFragment.kt b/app/src/main/kotlin/com/simplemobiletools/clock/fragments/TimerFragment.kt index 97552f3c..aded815e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/clock/fragments/TimerFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/clock/fragments/TimerFragment.kt @@ -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) diff --git a/app/src/main/res/layout/dialog_my_time_picker.xml b/app/src/main/res/layout/dialog_my_time_picker.xml new file mode 100644 index 00000000..0e19b25d --- /dev/null +++ b/app/src/main/res/layout/dialog_my_time_picker.xml @@ -0,0 +1,44 @@ + + + + + + + + + +