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