Improve conversation update message stylings.

This commit is contained in:
Greyson Parrelli
2020-10-22 10:59:23 -04:00
committed by Cody Henthorne
parent 90f20c36c5
commit 9c97cd8816
53 changed files with 757 additions and 369 deletions

View File

@@ -27,6 +27,7 @@ import androidx.annotation.Nullable;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.logging.Log;
import java.text.DateFormatSymbols;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
@@ -40,8 +41,9 @@ import java.util.concurrent.TimeUnit;
public class DateUtils extends android.text.format.DateUtils {
@SuppressWarnings("unused")
private static final String TAG = DateUtils.class.getSimpleName();
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyyMMdd");
private static final String TAG = DateUtils.class.getSimpleName();
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyyMMdd");
private static final SimpleDateFormat BRIEF_EXACT_FORMAT = new SimpleDateFormat();
private static boolean isWithin(final long millis, final long span, final TimeUnit unit) {
return System.currentTimeMillis() - millis <= unit.toMillis(span);
@@ -172,6 +174,16 @@ public class DateUtils extends android.text.format.DateUtils {
return getExtendedRelativeTimeSpanString(context, locale, t1).equals(getExtendedRelativeTimeSpanString(context, locale, t2));
}
public static String getBriefExactTimeString(@NonNull Locale locale, long timestamp) {
SimpleDateFormat format = new SimpleDateFormat(getLocalizedPattern("MMM dd, hh:mm a", locale), locale);
DateFormatSymbols symbols = new DateFormatSymbols(locale);
symbols.setAmPmStrings(new String[] { "am", "pm"});
format.setDateFormatSymbols(symbols);
return format.format(timestamp);
}
private static String getLocalizedPattern(String template, Locale locale) {
return DateFormat.getBestDateTimePattern(locale, template);
}

View File

@@ -1,11 +1,14 @@
package org.thoughtcrime.securesms.util;
import android.content.Context;
import android.graphics.PorterDuff;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.AbsoluteSizeSpan;
import android.text.style.DynamicDrawableSpan;
import android.text.style.ForegroundColorSpan;
import android.text.style.ImageSpan;
import android.text.style.RelativeSizeSpan;
@@ -14,6 +17,9 @@ import android.text.style.URLSpan;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import org.thoughtcrime.securesms.R;
public class SpanUtil {
@@ -50,4 +56,12 @@ public class SpanUtil {
spannable.setSpan(new ForegroundColorSpan(color), 0, sequence.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return spannable;
}
public static CharSequence buildImageSpan(@NonNull Drawable drawable) {
SpannableString imageSpan = new SpannableString(" ");
imageSpan.setSpan(new ImageSpan(drawable, DynamicDrawableSpan.ALIGN_CENTER), 0, imageSpan.length(), 0);
return imageSpan;
}
}