From 2c3235a3b55917056be14130cdfee84c961864da Mon Sep 17 00:00:00 2001 From: Julius Linus Date: Thu, 21 Sep 2023 08:53:14 -0500 Subject: [PATCH] bug fix, allows time picker to use 24hr format instead of default 12hr Signed-off-by: rapterjet2004 --- .../com/nextcloud/talk/ui/dialog/DateTimePickerFragment.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/DateTimePickerFragment.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/DateTimePickerFragment.kt index bc9e256b6e..886ef57f99 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/DateTimePickerFragment.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/DateTimePickerFragment.kt @@ -21,6 +21,7 @@ package com.nextcloud.talk.ui.dialog import android.app.Dialog import android.os.Bundle +import android.text.format.DateFormat import android.text.format.DateUtils import android.view.LayoutInflater import android.view.View @@ -32,6 +33,7 @@ import com.google.android.material.datepicker.DateValidatorPointForward import com.google.android.material.datepicker.MaterialDatePicker import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.timepicker.MaterialTimePicker +import com.google.android.material.timepicker.TimeFormat import com.nextcloud.android.common.ui.theme.utils.ColorRole import com.nextcloud.talk.R import com.nextcloud.talk.application.NextcloudTalkApplication @@ -229,9 +231,10 @@ class DateTimePickerFragment( } private fun setUpTimePicker(year: Int, month: Int, day: Int, weekInYear: Int) { - val timePicker = MaterialTimePicker - .Builder() + val locale = if (DateFormat.is24HourFormat(requireContext())) TimeFormat.CLOCK_24H else TimeFormat.CLOCK_12H + val timePicker = MaterialTimePicker.Builder() .setTitleText(R.string.nc_remind) + .setTimeFormat(locale) .build() timePicker.addOnPositiveButtonClickListener {