mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-23 16:37:30 +00:00
Always show the time of the received message.
This commit is contained in:
parent
0f9a6e6296
commit
c85a8bbb38
@ -1,11 +1,25 @@
|
||||
/**
|
||||
* Copyright (C) 2014 Open Whisper Systems
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.thoughtcrime.securesms.util;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
/**
|
||||
* Created by kaonashi on 1/6/14.
|
||||
* Utility methods to help display dates in a nice, easily readable way.
|
||||
*/
|
||||
public class DateUtils extends android.text.format.DateUtils {
|
||||
|
||||
@ -22,19 +36,16 @@ public class DateUtils extends android.text.format.DateUtils {
|
||||
}
|
||||
|
||||
public static String getBetterRelativeTimeSpanString(final Context c, final long millis) {
|
||||
final String prettyDate;
|
||||
if (isToday(millis)) {
|
||||
prettyDate = DateUtils.formatDateTime(c, millis, DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_ABBREV_TIME);
|
||||
} else if (isWithinWeek(millis)) {
|
||||
prettyDate = DateUtils.formatDateTime(c, millis,
|
||||
DateUtils.FORMAT_SHOW_WEEKDAY | DateUtils.FORMAT_ABBREV_WEEKDAY | DateUtils.FORMAT_SHOW_TIME);
|
||||
} else if (isWithinYear(millis)) {
|
||||
prettyDate = DateUtils.formatDateTime(c, millis,
|
||||
DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NO_YEAR | DateUtils.FORMAT_ABBREV_ALL);
|
||||
} else {
|
||||
prettyDate = DateUtils.formatDateTime(c, millis,
|
||||
DateUtils.FORMAT_NUMERIC_DATE);
|
||||
int formatFlags = DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_ABBREV_TIME;
|
||||
if (!isToday(millis)) {
|
||||
if (isWithinWeek(millis)) {
|
||||
formatFlags |= DateUtils.FORMAT_SHOW_WEEKDAY | DateUtils.FORMAT_ABBREV_WEEKDAY;
|
||||
} else if (isWithinYear(millis)) {
|
||||
formatFlags |= DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NO_YEAR | DateUtils.FORMAT_ABBREV_ALL;
|
||||
} else {
|
||||
formatFlags |= DateUtils.FORMAT_NUMERIC_DATE;
|
||||
}
|
||||
}
|
||||
return prettyDate;
|
||||
return DateUtils.formatDateTime(c, millis, formatFlags);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user