mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-24 03:35:58 +00:00
Add support for new story gradient fields and fallback.
This commit is contained in:
committed by
Greyson Parrelli
parent
2e2b31aa79
commit
f751f9afa8
@@ -5,90 +5,62 @@ import org.thoughtcrime.securesms.conversation.colors.ChatColors
|
||||
object TextStoryBackgroundColors {
|
||||
|
||||
private val backgroundColors: List<ChatColors> = listOf(
|
||||
ChatColors.forColor(
|
||||
id = ChatColors.Id.NotSet,
|
||||
color = 0xFF688BD4.toInt()
|
||||
),
|
||||
ChatColors.forColor(
|
||||
id = ChatColors.Id.NotSet,
|
||||
color = 0xFF8687C1.toInt()
|
||||
),
|
||||
ChatColors.forColor(
|
||||
id = ChatColors.Id.NotSet,
|
||||
color = 0xFFB47F8C.toInt()
|
||||
),
|
||||
ChatColors.forColor(
|
||||
id = ChatColors.Id.NotSet,
|
||||
color = 0xFF899188.toInt()
|
||||
),
|
||||
ChatColors.forColor(
|
||||
id = ChatColors.Id.NotSet,
|
||||
color = 0xFF539383.toInt()
|
||||
),
|
||||
ChatColors.forGradient(
|
||||
id = ChatColors.Id.NotSet,
|
||||
linearGradient = ChatColors.LinearGradient(
|
||||
degrees = 191.41f,
|
||||
colors = intArrayOf(0xFFF53844.toInt(), 0xFF42378F.toInt()),
|
||||
positions = floatArrayOf(0f, 1.0f)
|
||||
colors = intArrayOf(
|
||||
0xFF19A9FA.toInt(), 0xFF7097D7.toInt(), 0xFFD1998D.toInt(), 0xFFFFC369.toInt()
|
||||
),
|
||||
positions = floatArrayOf(
|
||||
0f, 0.33f, 0.66f, 1f
|
||||
),
|
||||
degrees = 180f
|
||||
)
|
||||
),
|
||||
ChatColors.forGradient(
|
||||
id = ChatColors.Id.NotSet,
|
||||
linearGradient = ChatColors.LinearGradient(
|
||||
degrees = 192.04f,
|
||||
colors = intArrayOf(0xFFF04CE6.toInt(), 0xFF0E2FDD.toInt()),
|
||||
positions = floatArrayOf(0.0f, 1.0f)
|
||||
),
|
||||
),
|
||||
ChatColors.forGradient(
|
||||
id = ChatColors.Id.NotSet,
|
||||
linearGradient = ChatColors.LinearGradient(
|
||||
degrees = 175.46f,
|
||||
colors = intArrayOf(0xFFFFC044.toInt(), 0xFFFE5C38.toInt()),
|
||||
positions = floatArrayOf(0f, 1f)
|
||||
colors = intArrayOf(
|
||||
0xFF4437D8.toInt(), 0xFF6B70DE.toInt(), 0xFFB774E0.toInt(), 0xFFFF8E8E.toInt()
|
||||
),
|
||||
positions = floatArrayOf(
|
||||
0f, 0.33f, 0.66f, 1f
|
||||
),
|
||||
degrees = 180f
|
||||
)
|
||||
),
|
||||
ChatColors.forGradient(
|
||||
id = ChatColors.Id.NotSet,
|
||||
linearGradient = ChatColors.LinearGradient(
|
||||
degrees = 180f,
|
||||
colors = intArrayOf(0xFF0093E9.toInt(), 0xFF80D0C7.toInt()),
|
||||
positions = floatArrayOf(0.0f, 1.0f)
|
||||
colors = intArrayOf(
|
||||
0xFF004044.toInt(), 0xFF2C5F45.toInt(), 0xFF648E52.toInt(), 0xFF93B864.toInt()
|
||||
),
|
||||
positions = floatArrayOf(
|
||||
0f, 0.33f, 0.66f, 1f
|
||||
),
|
||||
degrees = 180f
|
||||
)
|
||||
),
|
||||
ChatColors.forGradient(
|
||||
id = ChatColors.Id.NotSet,
|
||||
linearGradient = ChatColors.LinearGradient(
|
||||
degrees = 180f,
|
||||
colors = intArrayOf(0xFF65CDAC.toInt(), 0xFF0A995A.toInt()),
|
||||
positions = floatArrayOf(0.0f, 1.0f)
|
||||
)
|
||||
),
|
||||
ChatColors.forColor(
|
||||
id = ChatColors.Id.NotSet,
|
||||
color = 0xFFFFC153.toInt()
|
||||
),
|
||||
ChatColors.forColor(
|
||||
id = ChatColors.Id.NotSet,
|
||||
color = 0xFFCCBD33.toInt()
|
||||
),
|
||||
ChatColors.forColor(
|
||||
id = ChatColors.Id.NotSet,
|
||||
color = 0xFF84712E.toInt()
|
||||
),
|
||||
ChatColors.forColor(
|
||||
id = ChatColors.Id.NotSet,
|
||||
color = 0xFF09B37B.toInt()
|
||||
),
|
||||
ChatColors.forColor(
|
||||
id = ChatColors.Id.NotSet,
|
||||
color = 0xFF8B8BF9.toInt()
|
||||
),
|
||||
ChatColors.forColor(
|
||||
id = ChatColors.Id.NotSet,
|
||||
color = 0xFF5151F6.toInt()
|
||||
),
|
||||
ChatColors.forColor(
|
||||
id = ChatColors.Id.NotSet,
|
||||
color = 0xFFF76E6E.toInt()
|
||||
),
|
||||
ChatColors.forColor(
|
||||
id = ChatColors.Id.NotSet,
|
||||
color = 0xFFC84641.toInt()
|
||||
),
|
||||
ChatColors.forColor(
|
||||
id = ChatColors.Id.NotSet,
|
||||
color = 0xFFC6C4A5.toInt()
|
||||
),
|
||||
ChatColors.forColor(
|
||||
id = ChatColors.Id.NotSet,
|
||||
color = 0xFFA49595.toInt()
|
||||
),
|
||||
ChatColors.forColor(
|
||||
id = ChatColors.Id.NotSet,
|
||||
color = 0xFF292929.toInt()
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
fun getInitialBackgroundColor(): ChatColors = backgroundColors.first()
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.messages;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
|
||||
@@ -49,7 +50,6 @@ import org.thoughtcrime.securesms.database.SentStorySyncManifest;
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase;
|
||||
import org.thoughtcrime.securesms.database.StickerDatabase;
|
||||
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
||||
import org.thoughtcrime.securesms.database.model.DistributionListRecord;
|
||||
import org.thoughtcrime.securesms.database.model.Mention;
|
||||
import org.thoughtcrime.securesms.database.model.MessageId;
|
||||
import org.thoughtcrime.securesms.database.model.MessageLogEntry;
|
||||
@@ -1473,9 +1473,25 @@ public final class MessageContentProcessor {
|
||||
ChatColor.LinearGradient.Builder linearGradientBuilder = ChatColor.LinearGradient.newBuilder();
|
||||
|
||||
linearGradientBuilder.setRotation(gradient.getAngle().orElse(0).floatValue());
|
||||
linearGradientBuilder.addColors(gradient.getStartColor().get());
|
||||
linearGradientBuilder.addColors(gradient.getEndColor().get());
|
||||
linearGradientBuilder.addAllPositions(Arrays.asList(0f, 1f));
|
||||
|
||||
if (gradient.getPositions().size() > 1 && gradient.getColors().size() == gradient.getPositions().size()) {
|
||||
ArrayList<Float> positions = new ArrayList<>(gradient.getPositions());
|
||||
|
||||
positions.set(0, 0f);
|
||||
positions.set(positions.size() - 1, 1f);
|
||||
|
||||
linearGradientBuilder.addAllColors(new ArrayList<>(gradient.getColors()));
|
||||
linearGradientBuilder.addAllPositions(positions);
|
||||
} else if (!gradient.getColors().isEmpty()) {
|
||||
Log.w(TAG, "Incoming text story has color / position mismatch. Defaulting to start and end colors.");
|
||||
linearGradientBuilder.addColors(gradient.getColors().get(0));
|
||||
linearGradientBuilder.addColors(gradient.getColors().get(gradient.getColors().size() - 1));
|
||||
linearGradientBuilder.addAllPositions(Arrays.asList(0f, 1f));
|
||||
} else {
|
||||
Log.w(TAG, "Incoming text story did not have a valid linear gradient.");
|
||||
linearGradientBuilder.addAllColors(Arrays.asList(Color.BLACK, Color.BLACK));
|
||||
linearGradientBuilder.addAllPositions(Arrays.asList(0f, 1f));
|
||||
}
|
||||
|
||||
chatColorBuilder.setLinearGradient(linearGradientBuilder);
|
||||
}
|
||||
|
||||
@@ -28,9 +28,9 @@ object StorySendUtil {
|
||||
Optional.of(storyTextPost.textBackgroundColor),
|
||||
preview,
|
||||
SignalServiceTextAttachment.Gradient(
|
||||
Optional.of(storyTextPost.background.linearGradient.getColors(0)),
|
||||
Optional.of(storyTextPost.background.linearGradient.getColors(1)),
|
||||
Optional.of(storyTextPost.background.linearGradient.rotation.roundToInt())
|
||||
Optional.of(storyTextPost.background.linearGradient.rotation.roundToInt()),
|
||||
ArrayList(storyTextPost.background.linearGradient.colorsList),
|
||||
ArrayList(storyTextPost.background.linearGradient.positionsList)
|
||||
)
|
||||
)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user