mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 01:40:07 +01:00
Various UI adjustments to conversation updates.
This commit is contained in:
committed by
Cody Henthorne
parent
9743e3689a
commit
3f983a5c82
@@ -58,15 +58,22 @@ public final class LiveUpdateMessage {
|
||||
private static @NonNull Spannable toSpannable(@NonNull Context context, @NonNull UpdateDescription updateDescription, @NonNull String string) {
|
||||
boolean isDarkTheme = ThemeUtil.isDarkTheme(context);
|
||||
int drawableResource = isDarkTheme ? updateDescription.getDarkIconResource() : updateDescription.getLightIconResource();
|
||||
int tint = isDarkTheme ? updateDescription.getDarkTint() : updateDescription.getLightTint();
|
||||
|
||||
if (tint == 0) {
|
||||
tint = ThemeUtil.getThemedColor(context, R.attr.conversation_item_update_text_color);
|
||||
}
|
||||
|
||||
if (drawableResource == 0) {
|
||||
return new SpannableString(string);
|
||||
} else {
|
||||
Drawable drawable = ContextCompat.getDrawable(context, drawableResource);
|
||||
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
||||
drawable.setColorFilter(ThemeUtil.getThemedColor(context, R.attr.conversation_item_update_text_color), PorterDuff.Mode.SRC_ATOP);
|
||||
drawable.setColorFilter(tint, PorterDuff.Mode.SRC_ATOP);
|
||||
|
||||
return new SpannableStringBuilder().append(SpanUtil.buildImageSpan(drawable)).append(" ").append(string);
|
||||
Spannable stringWithImage = new SpannableStringBuilder().append(SpanUtil.buildImageSpan(drawable)).append(" ").append(string);
|
||||
|
||||
return new SpannableString(SpanUtil.color(tint, stringWithImage));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,14 +17,17 @@
|
||||
package org.thoughtcrime.securesms.database.model;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.style.RelativeSizeSpan;
|
||||
import android.text.style.StyleSpan;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import org.signal.storageservice.protos.groups.local.DecryptedGroup;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
@@ -138,11 +141,11 @@ public abstract class MessageRecord extends DisplayRecord {
|
||||
} else if (isGroupQuit()) {
|
||||
return fromRecipient(getIndividualRecipient(), r -> context.getString(R.string.ConversationItem_group_action_left, r.getDisplayName(context)), R.drawable.ic_update_group_leave_light_16, R.drawable.ic_update_group_leave_dark_16);
|
||||
} else if (isIncomingCall()) {
|
||||
return fromRecipient(getIndividualRecipient(), r -> context.getString(R.string.MessageRecord_s_called_you_date, r.getDisplayName(context), getCallDateString()), R.drawable.ic_update_audio_call_incoming_light_16, R.drawable.ic_update_audio_call_incoming_dark_16);
|
||||
return fromRecipient(getIndividualRecipient(), r -> context.getString(R.string.MessageRecord_s_called_you_date, r.getDisplayName(context), getCallDateString(context)), R.drawable.ic_update_audio_call_incoming_light_16, R.drawable.ic_update_audio_call_incoming_dark_16);
|
||||
} else if (isOutgoingCall()) {
|
||||
return staticUpdateDescription(context.getString(R.string.MessageRecord_you_called_date, getCallDateString()), R.drawable.ic_update_audio_call_outgoing_light_16, R.drawable.ic_update_audio_call_outgoing_dark_16);
|
||||
return staticUpdateDescription(context.getString(R.string.MessageRecord_you_called_date, getCallDateString(context)), R.drawable.ic_update_audio_call_outgoing_light_16, R.drawable.ic_update_audio_call_outgoing_dark_16);
|
||||
} else if (isMissedCall()) {
|
||||
return staticUpdateDescription(context.getString(R.string.MessageRecord_missed_call_date, getCallDateString()), R.drawable.ic_update_audio_call_missed_light_16, R.drawable.ic_update_audio_call_missed_dark_16);
|
||||
return staticUpdateDescription(context.getString(R.string.MessageRecord_missed_call_date, getCallDateString(context)), R.drawable.ic_update_audio_call_missed_light_16, R.drawable.ic_update_audio_call_missed_dark_16, ContextCompat.getColor(context, R.color.core_red_shade), ContextCompat.getColor(context, R.color.core_red));
|
||||
} else if (isJoined()) {
|
||||
return staticUpdateDescription(context.getString(R.string.MessageRecord_s_joined_signal, getIndividualRecipient().getDisplayName(context)), R.drawable.ic_update_group_add_light_16, R.drawable.ic_update_group_add_dark_16);
|
||||
} else if (isExpirationTimerUpdate()) {
|
||||
@@ -213,8 +216,8 @@ public abstract class MessageRecord extends DisplayRecord {
|
||||
}
|
||||
}
|
||||
|
||||
private @NonNull String getCallDateString() {
|
||||
return DateUtils.getBriefExactTimeString(Locale.getDefault(), getDateSent());
|
||||
private @NonNull String getCallDateString(@NonNull Context context) {
|
||||
return DateUtils.getExtendedRelativeTimeSpanString(context, Locale.getDefault(), getDateSent());
|
||||
}
|
||||
|
||||
private static @NonNull UpdateDescription fromRecipient(@NonNull Recipient recipient,
|
||||
@@ -235,6 +238,15 @@ public abstract class MessageRecord extends DisplayRecord {
|
||||
return UpdateDescription.staticDescription(string, lightIconResource, darkIconResource);
|
||||
}
|
||||
|
||||
private static @NonNull UpdateDescription staticUpdateDescription(@NonNull String string,
|
||||
@DrawableRes int lightIconResource,
|
||||
@DrawableRes int darkIconResource,
|
||||
@ColorInt int lightTint,
|
||||
@ColorInt int darkTint)
|
||||
{
|
||||
return UpdateDescription.staticDescription(string, lightIconResource, darkIconResource, lightTint, darkTint);
|
||||
}
|
||||
|
||||
private @NonNull String getProfileChangeDescription(@NonNull Context context) {
|
||||
try {
|
||||
byte[] decoded = Base64.decode(getBody());
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.thoughtcrime.securesms.database.model;
|
||||
|
||||
import androidx.annotation.AnyThread;
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -31,12 +32,16 @@ public final class UpdateDescription {
|
||||
private final String staticString;
|
||||
private final int lightIconResource;
|
||||
private final int darkIconResource;
|
||||
private final int lightTint;
|
||||
private final int darkTint;
|
||||
|
||||
private UpdateDescription(@NonNull Collection<UUID> mentioned,
|
||||
@Nullable StringFactory stringFactory,
|
||||
@Nullable String staticString,
|
||||
@DrawableRes int lightIconResource,
|
||||
@DrawableRes int darkIconResource)
|
||||
@DrawableRes int darkIconResource,
|
||||
@ColorInt int lightTint,
|
||||
@ColorInt int darkTint)
|
||||
{
|
||||
if (staticString == null && stringFactory == null) {
|
||||
throw new AssertionError();
|
||||
@@ -46,6 +51,8 @@ public final class UpdateDescription {
|
||||
this.staticString = staticString;
|
||||
this.lightIconResource = lightIconResource;
|
||||
this.darkIconResource = darkIconResource;
|
||||
this.lightTint = lightTint;
|
||||
this.darkTint = darkTint;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,7 +71,9 @@ public final class UpdateDescription {
|
||||
stringFactory,
|
||||
null,
|
||||
lightIconResource,
|
||||
darkIconResource);
|
||||
darkIconResource,
|
||||
0,
|
||||
0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,7 +83,19 @@ public final class UpdateDescription {
|
||||
@DrawableRes int lightIconResource,
|
||||
@DrawableRes int darkIconResource)
|
||||
{
|
||||
return new UpdateDescription(Collections.emptyList(), null, staticString, lightIconResource, darkIconResource);
|
||||
return new UpdateDescription(Collections.emptyList(), null, staticString, lightIconResource, darkIconResource, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an update description that's string value is fixed with a specific tint color.
|
||||
*/
|
||||
public static UpdateDescription staticDescription(@NonNull String staticString,
|
||||
@DrawableRes int lightIconResource,
|
||||
@DrawableRes int darkIconResource,
|
||||
@ColorInt int lightTint,
|
||||
@ColorInt int darkTint)
|
||||
{
|
||||
return new UpdateDescription(Collections.emptyList(), null, staticString, lightIconResource, darkIconResource, lightTint, darkTint);
|
||||
}
|
||||
|
||||
public boolean isStringStatic() {
|
||||
@@ -115,6 +136,14 @@ public final class UpdateDescription {
|
||||
return darkIconResource;
|
||||
}
|
||||
|
||||
public @ColorInt int getLightTint() {
|
||||
return lightTint;
|
||||
}
|
||||
|
||||
public @ColorInt int getDarkTint() {
|
||||
return darkTint;
|
||||
}
|
||||
|
||||
public static UpdateDescription concatWithNewLines(@NonNull List<UpdateDescription> updateDescriptions) {
|
||||
if (updateDescriptions.size() == 0) {
|
||||
throw new AssertionError();
|
||||
|
||||
Reference in New Issue
Block a user