Compare commits
1 Commits
d34aa8e950
...
e756a2a3fc
| Author | SHA1 | Date | |
|---|---|---|---|
| e756a2a3fc |
@@ -385,10 +385,12 @@ class MainActivity : AppCompatActivity() {
|
||||
d.setView(dialogView)
|
||||
|
||||
val durationTextView = dialogView.findViewById<TextView>(R.id.dialog_date_duration)
|
||||
val durationPlus10Button = dialogView.findViewById<Button>(R.id.dialog_date_duration_plus10)
|
||||
val durationMinus10Button = dialogView.findViewById<Button>(R.id.dialog_date_duration_minus10)
|
||||
val durationNowButton = dialogView.findViewById<Button>(R.id.dialog_date_duration_now)
|
||||
val datePicker = dialogView.findViewById<TextView>(R.id.dialog_date_picker)
|
||||
val durationMinus15Button = dialogView.findViewById<Button>(R.id.dialog_date_duration_minus15)
|
||||
val durationMinus5Button = dialogView.findViewById<Button>(R.id.dialog_date_duration_minus5)
|
||||
val durationPlus15Button = dialogView.findViewById<Button>(R.id.dialog_date_duration_plus15)
|
||||
val durationPlus5Button = dialogView.findViewById<Button>(R.id.dialog_date_duration_plus5)
|
||||
|
||||
val currentDurationTextColor = durationTextView.currentTextColor
|
||||
val invalidDurationTextColor = ContextCompat.getColor(this, R.color.danger)
|
||||
@@ -418,25 +420,25 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
onDateChange(pickedDateTime.time.time / 1000)
|
||||
|
||||
durationPlus10Button.setOnClickListener {
|
||||
duration += 10 * 60
|
||||
onDateChange(pickedDateTime.time.time / 1000)
|
||||
}
|
||||
|
||||
durationMinus10Button.setOnClickListener {
|
||||
if (duration > 10 * 60) {
|
||||
duration -= 10 * 60
|
||||
} else {
|
||||
fun adjust(minutes: Int) {
|
||||
duration += minutes * 60
|
||||
if (duration < 0) {
|
||||
duration = 0
|
||||
}
|
||||
onDateChange(pickedDateTime.time.time / 1000)
|
||||
}
|
||||
|
||||
durationMinus15Button.setOnClickListener { adjust(-15) }
|
||||
durationMinus5Button.setOnClickListener { adjust(-5) }
|
||||
durationPlus5Button.setOnClickListener { adjust(5) }
|
||||
durationPlus15Button.setOnClickListener { adjust(15) }
|
||||
|
||||
durationNowButton.setOnClickListener {
|
||||
val now = Calendar.getInstance().time.time / 1000
|
||||
val start = pickedDateTime.time.time / 1000
|
||||
if (now > start) {
|
||||
duration = (now - start).toInt()
|
||||
duration -= duration % 60 // prevent printing of seconds
|
||||
onDateChange(pickedDateTime.time.time / 1000)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,38 +12,50 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="20sp"
|
||||
android:text="sleeping emoji"/>
|
||||
android:text="💤"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginHorizontal="10dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/dialog_date_duration_minus10"
|
||||
android:id="@+id/dialog_date_duration_minus15"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="10dp"
|
||||
android:layout_weight="1"
|
||||
android:text="-10"/>
|
||||
android:text="-15"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/dialog_date_duration_minus5"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="-5"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/dialog_date_duration_now"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="0dp"
|
||||
android:layout_weight="1"
|
||||
android:text="now"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/dialog_date_duration_plus10"
|
||||
android:id="@+id/dialog_date_duration_plus5"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="10dp"
|
||||
android:layout_weight="1"
|
||||
android:text="+10"/>
|
||||
android:text="+5"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/dialog_date_duration_plus15"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="+15"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user