do not allow toggling between 12/24 time format in the app itself
This commit is contained in:
parent
7743225df8
commit
bf807d7ca9
7 changed files with 13 additions and 32 deletions
|
@ -14,7 +14,10 @@ import com.simplemobiletools.clock.extensions.getNextAlarm
|
|||
import com.simplemobiletools.clock.extensions.rescheduleEnabledAlarms
|
||||
import com.simplemobiletools.clock.helpers.*
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.*
|
||||
import com.simplemobiletools.commons.helpers.LICENSE_NUMBER_PICKER
|
||||
import com.simplemobiletools.commons.helpers.LICENSE_RTL
|
||||
import com.simplemobiletools.commons.helpers.LICENSE_STETHO
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.commons.models.FAQItem
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@ class SettingsActivity : SimpleActivity() {
|
|||
setupCustomizeColors()
|
||||
setupUseEnglish()
|
||||
setupPreventPhoneFromSleeping()
|
||||
setupHourFormat()
|
||||
setupSundayFirst()
|
||||
setupShowSeconds()
|
||||
setupAlarmMaxReminder()
|
||||
|
@ -104,15 +103,6 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun setupHourFormat() {
|
||||
settings_hour_format.isChecked = config.use24HourFormat
|
||||
settings_hour_format_holder.setOnClickListener {
|
||||
settings_hour_format.toggle()
|
||||
config.use24HourFormat = settings_hour_format.isChecked
|
||||
updateWidgets()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupSundayFirst() {
|
||||
settings_sunday_first.isChecked = config.isSundayFirst
|
||||
settings_sunday_first_holder.setOnClickListener {
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.app.TimePickerDialog
|
|||
import android.graphics.drawable.Drawable
|
||||
import android.media.AudioManager
|
||||
import android.media.RingtoneManager
|
||||
import android.text.format.DateFormat
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.simplemobiletools.clock.R
|
||||
|
@ -36,7 +37,7 @@ class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callba
|
|||
timeSetListener,
|
||||
alarm.timeInMinutes / 60,
|
||||
alarm.timeInMinutes % 60,
|
||||
context.config.use24HourFormat
|
||||
DateFormat.is24HourFormat(activity)
|
||||
).show()
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import android.media.RingtoneManager
|
|||
import android.net.Uri
|
||||
import android.os.PowerManager
|
||||
import android.text.SpannableString
|
||||
import android.text.format.DateFormat
|
||||
import android.text.style.RelativeSizeSpan
|
||||
import android.widget.Toast
|
||||
import androidx.core.app.AlarmManagerCompat
|
||||
|
@ -189,7 +190,7 @@ fun Context.updateWidgets() {
|
|||
}
|
||||
|
||||
fun Context.getFormattedTime(passedSeconds: Int, showSeconds: Boolean, makeAmPmSmaller: Boolean): SpannableString {
|
||||
val use24HourFormat = config.use24HourFormat
|
||||
val use24HourFormat = DateFormat.is24HourFormat(this)
|
||||
val hours = (passedSeconds / 3600) % 24
|
||||
val minutes = (passedSeconds / 60) % 60
|
||||
val seconds = passedSeconds % 60
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.simplemobiletools.clock.fragments
|
|||
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.text.format.DateFormat
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
@ -83,7 +84,7 @@ class ClockFragment : Fragment() {
|
|||
val seconds = passedSeconds % 60
|
||||
view.clock_time.text = requireContext().getFormattedTime(passedSeconds, requireContext().config.showSeconds, true)
|
||||
|
||||
if (!requireContext().config.use24HourFormat) {
|
||||
if (!DateFormat.is24HourFormat(requireContext())) {
|
||||
view.clock_time.textSize = resources.getDimension(R.dimen.clock_text_size_smaller) / resources.displayMetrics.density
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import android.content.Context
|
|||
import android.content.Intent
|
||||
import android.graphics.*
|
||||
import android.os.Bundle
|
||||
import android.text.format.DateFormat
|
||||
import android.widget.RemoteViews
|
||||
import com.simplemobiletools.clock.R
|
||||
import com.simplemobiletools.clock.activities.SplashActivity
|
||||
|
@ -78,7 +79,7 @@ class MyWidgetDateTimeProvider : AppWidgetProvider() {
|
|||
|
||||
val isIn24HoursFormat = !nextAlarm.endsWith(".")
|
||||
return when {
|
||||
context.config.use24HourFormat && !isIn24HoursFormat -> {
|
||||
DateFormat.is24HourFormat(context) && !isIn24HoursFormat -> {
|
||||
val dayTime = nextAlarm.split(" ")
|
||||
val times = dayTime[1].split(":")
|
||||
val hours = times[0].toInt()
|
||||
|
@ -93,7 +94,7 @@ class MyWidgetDateTimeProvider : AppWidgetProvider() {
|
|||
}
|
||||
formatTime(false, true, newHours, minutes, seconds)
|
||||
}
|
||||
!context.config.use24HourFormat && isIn24HoursFormat -> {
|
||||
!DateFormat.is24HourFormat(context) && isIn24HoursFormat -> {
|
||||
val times = nextAlarm.split(" ")[1].split(":")
|
||||
val hours = times[0].toInt()
|
||||
val minutes = times[1].toInt()
|
||||
|
|
|
@ -122,22 +122,6 @@
|
|||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_hour_format_holder"
|
||||
style="@style/SettingsHolderCheckboxStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/ripple_background">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
||||
android:id="@+id/settings_hour_format"
|
||||
style="@style/SettingsCheckboxStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/use_24_hour_time_format" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_sunday_first_holder"
|
||||
style="@style/SettingsHolderCheckboxStyle"
|
||||
|
|
Loading…
Reference in a new issue