mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-02-17 04:00:35 +01:00
Remove humanised datetime formatting
Year is not shown if it's same as the current year.
This commit is contained in:
parent
203f10618f
commit
f721754785
@ -19,6 +19,10 @@ import android.telephony.SmsManager
|
||||
import android.telephony.SmsMessage
|
||||
import android.telephony.SubscriptionInfo
|
||||
import android.text.TextUtils
|
||||
import android.text.format.DateUtils
|
||||
import android.text.format.DateUtils.FORMAT_NO_YEAR
|
||||
import android.text.format.DateUtils.FORMAT_SHOW_DATE
|
||||
import android.text.format.DateUtils.FORMAT_SHOW_TIME
|
||||
import android.util.TypedValue
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
@ -66,6 +70,7 @@ import java.io.File
|
||||
import java.io.InputStream
|
||||
import java.io.OutputStream
|
||||
|
||||
|
||||
class ThreadActivity : SimpleActivity() {
|
||||
private val MIN_DATE_TIME_DIFF_SECS = 300
|
||||
private val PICK_ATTACHMENT_INTENT = 1
|
||||
@ -1304,7 +1309,15 @@ class ThreadActivity : SimpleActivity() {
|
||||
isScheduledMessage = true
|
||||
updateSendButtonDrawable()
|
||||
scheduled_message_holder.beVisible()
|
||||
scheduled_message_button.text = scheduledDateTime.humanize(this)
|
||||
|
||||
val dt = scheduledDateTime
|
||||
val millis = dt.millis
|
||||
scheduled_message_button.text = if (dt.yearOfCentury().get() > DateTime.now().yearOfCentury().get()) {
|
||||
millis.formatDate(this)
|
||||
} else {
|
||||
val flags = FORMAT_SHOW_TIME or FORMAT_SHOW_DATE or FORMAT_NO_YEAR
|
||||
DateUtils.formatDateTime(this, millis, flags)
|
||||
}
|
||||
}
|
||||
|
||||
private fun hideScheduleSendUi() {
|
||||
|
@ -1,19 +1,8 @@
|
||||
package com.simplemobiletools.smsmessenger.extensions
|
||||
|
||||
import android.content.Context
|
||||
import android.text.format.DateFormat
|
||||
import android.text.format.DateUtils
|
||||
import org.joda.time.DateTime
|
||||
import java.util.*
|
||||
|
||||
fun Date.format(pattern: String): String {
|
||||
return DateFormat.format(pattern, this).toString()
|
||||
}
|
||||
|
||||
fun DateTime.humanize(context: Context, now: DateTime = DateTime.now(), pattern: String = "EEE, MMM dd, YYYY, hh:mm a"): String {
|
||||
return if (yearOfCentury().get() > now.yearOfCentury().get()) {
|
||||
toString(pattern)
|
||||
} else {
|
||||
DateUtils.getRelativeDateTimeString(context, millis, DateUtils.SECOND_IN_MILLIS, DateUtils.DAY_IN_MILLIS, 0).toString()
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user