improving the B&W theme

This commit is contained in:
tibbi 2020-04-04 13:19:36 +02:00
parent bd4269c3c9
commit 2ed255ae5d
4 changed files with 6 additions and 47 deletions

View file

@ -1,39 +0,0 @@
package com.simplemobiletools.smsmessenger.extensions
import android.content.Context
import android.text.format.DateFormat
import android.text.format.DateUtils
import android.text.format.Time
import com.simplemobiletools.commons.extensions.getTimeFormat
import java.util.*
// if the given date is today, we show only the time. Else we show only the date
fun Int.formatDateOrTime(context: Context, hideTimeAtOtherDays: Boolean): String {
val cal = Calendar.getInstance(Locale.ENGLISH)
cal.timeInMillis = this * 1000L
return if (DateUtils.isToday(this * 1000L)) {
DateFormat.format(context.getTimeFormat(), cal).toString()
} else {
var format = context.config.dateFormat
if (isThisYear()) {
format = format.replace("y", "").trim().trim('-').trim('.').trim('/')
}
if (!hideTimeAtOtherDays) {
format += ", ${context.getTimeFormat()}"
}
DateFormat.format(format, cal).toString()
}
}
fun Int.isThisYear(): Boolean {
val time = Time()
time.set(this * 1000L)
val thenYear = time.year
time.set(System.currentTimeMillis())
return (thenYear == time.year)
}