use 12 hour formatting on other places when appropriate too

This commit is contained in:
tibbi 2018-03-12 22:31:44 +01:00
parent 2243e9561f
commit e17ca5920b
5 changed files with 7 additions and 17 deletions

View File

@ -8,7 +8,7 @@ import com.simplemobiletools.clock.R
import com.simplemobiletools.clock.activities.SimpleActivity
import com.simplemobiletools.clock.extensions.config
import com.simplemobiletools.clock.extensions.dbHelper
import com.simplemobiletools.clock.extensions.formatAlarmTime
import com.simplemobiletools.clock.extensions.getFormattedTime
import com.simplemobiletools.clock.interfaces.ToggleAlarmInterface
import com.simplemobiletools.clock.models.Alarm
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
@ -78,7 +78,7 @@ class AlarmsAdapter(activity: SimpleActivity, var alarms: ArrayList<Alarm>, val
private fun setupView(view: View, alarm: Alarm) {
view.apply {
alarm_time.text = alarm.timeInMinutes.formatAlarmTime()
alarm_time.text = activity.getFormattedTime(alarm.timeInMinutes * 60, false, true)
alarm_time.setTextColor(textColor)
alarm_days.text = activity.getSelectedDaysString(alarm.days)

View File

@ -7,6 +7,7 @@ import com.simplemobiletools.clock.R
import com.simplemobiletools.clock.activities.SimpleActivity
import com.simplemobiletools.clock.extensions.config
import com.simplemobiletools.clock.extensions.getFormattedDate
import com.simplemobiletools.clock.extensions.getFormattedTime
import com.simplemobiletools.clock.models.MyTimeZone
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
import com.simplemobiletools.commons.extensions.beGone
@ -85,10 +86,7 @@ class TimeZonesAdapter(activity: SimpleActivity, var timeZones: ArrayList<MyTime
val calendar = Calendar.getInstance(TimeZone.getTimeZone(timeZone.zoneName))
val offset = calendar.timeZone.rawOffset
val passedSeconds = ((calendar.timeInMillis + offset) / 1000).toInt()
val hours = (passedSeconds / 3600) % 24
val minutes = (passedSeconds / 60) % 60
val format = "%02d:%02d"
val formattedTime = String.format(format, hours, minutes)
val formattedTime = activity.getFormattedTime(passedSeconds, false, false)
val formattedDate = activity.getFormattedDate(calendar)
view.apply {

View File

@ -10,7 +10,7 @@ import com.simplemobiletools.clock.activities.SimpleActivity
import com.simplemobiletools.clock.extensions.colorLeftDrawable
import com.simplemobiletools.clock.extensions.config
import com.simplemobiletools.clock.extensions.dbHelper
import com.simplemobiletools.clock.extensions.formatAlarmTime
import com.simplemobiletools.clock.extensions.getFormattedTime
import com.simplemobiletools.clock.models.Alarm
import com.simplemobiletools.commons.extensions.*
import kotlinx.android.synthetic.main.dialog_edit_alarm.view.*
@ -90,7 +90,7 @@ class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callba
}
private fun updateAlarmTime() {
view.edit_alarm_time.text = alarm.timeInMinutes.formatAlarmTime()
view.edit_alarm_time.text = activity.getFormattedTime(alarm.timeInMinutes * 60, false, true)
}
private fun dialogConfirmed() {

View File

@ -1,8 +0,0 @@
package com.simplemobiletools.clock.extensions
fun Int.formatAlarmTime(): String {
val hours = this / 60
val minutes = this % 60
val format = "%02d:%02d"
return String.format(format, hours, minutes)
}

View File

@ -58,7 +58,7 @@ class AlarmReceiver : BroadcastReceiver() {
val builder = NotificationCompat.Builder(context)
.setContentTitle(context.getString(R.string.alarm))
.setContentText(alarm.timeInMinutes.formatAlarmTime())
.setContentText(context.getFormattedTime(alarm.timeInMinutes * 60, false, false))
.setSmallIcon(R.drawable.ic_alarm)
.setContentIntent(pendingIntent)
.setPriority(Notification.PRIORITY_HIGH)