mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-25 03:11:10 +01:00
Remove gradient support from api 19.
This commit is contained in:
committed by
Cody Henthorne
parent
35930fb23a
commit
273e5f9168
@@ -3506,8 +3506,7 @@ public class ConversationActivity extends PassphraseRequiredActivity
|
||||
messageRecord.getDateSent(),
|
||||
author,
|
||||
body,
|
||||
slideDeck,
|
||||
fragment.getColorizer());
|
||||
slideDeck);
|
||||
|
||||
} else if (messageRecord.isMms() && !((MmsMessageRecord) messageRecord).getLinkPreviews().isEmpty()) {
|
||||
LinkPreview linkPreview = ((MmsMessageRecord) messageRecord).getLinkPreviews().get(0);
|
||||
@@ -3521,8 +3520,7 @@ public class ConversationActivity extends PassphraseRequiredActivity
|
||||
messageRecord.getDateSent(),
|
||||
author,
|
||||
conversationMessage.getDisplayBody(this),
|
||||
slideDeck,
|
||||
fragment.getColorizer());
|
||||
slideDeck);
|
||||
} else {
|
||||
SlideDeck slideDeck = messageRecord.isMms() ? ((MmsMessageRecord) messageRecord).getSlideDeck() : new SlideDeck();
|
||||
|
||||
@@ -3536,8 +3534,7 @@ public class ConversationActivity extends PassphraseRequiredActivity
|
||||
messageRecord.getDateSent(),
|
||||
author,
|
||||
conversationMessage.getDisplayBody(this),
|
||||
slideDeck,
|
||||
fragment.getColorizer());
|
||||
slideDeck);
|
||||
}
|
||||
|
||||
inputPanel.clickOnComposeInput();
|
||||
|
||||
@@ -80,6 +80,7 @@ import org.thoughtcrime.securesms.components.SharedContactView;
|
||||
import org.thoughtcrime.securesms.components.emoji.EmojiTextView;
|
||||
import org.thoughtcrime.securesms.components.mention.MentionAnnotation;
|
||||
import org.thoughtcrime.securesms.contactshare.Contact;
|
||||
import org.thoughtcrime.securesms.conversation.colors.ChatColors;
|
||||
import org.thoughtcrime.securesms.conversation.colors.Colorizer;
|
||||
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
@@ -316,7 +317,7 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
|
||||
setGroupMessageStatus(messageRecord, recipient.get());
|
||||
setGroupAuthorColor(messageRecord, hasWallpaper, colorizer);
|
||||
setAuthor(messageRecord, previousMessageRecord, nextMessageRecord, groupThread, hasWallpaper);
|
||||
setQuote(messageRecord, previousMessageRecord, nextMessageRecord, groupThread, colorizer);
|
||||
setQuote(messageRecord, previousMessageRecord, nextMessageRecord, groupThread, messageRecord.getRecipient().getChatColors());
|
||||
setMessageSpacing(context, messageRecord, previousMessageRecord, nextMessageRecord, groupThread);
|
||||
setReactions(messageRecord);
|
||||
setFooter(messageRecord, nextMessageRecord, locale, groupThread, hasWallpaper);
|
||||
@@ -1095,14 +1096,14 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
|
||||
}
|
||||
}
|
||||
|
||||
private void setQuote(@NonNull MessageRecord current, @NonNull Optional<MessageRecord> previous, @NonNull Optional<MessageRecord> next, boolean isGroupThread, @NonNull Colorizer colorizer) {
|
||||
private void setQuote(@NonNull MessageRecord current, @NonNull Optional<MessageRecord> previous, @NonNull Optional<MessageRecord> next, boolean isGroupThread, @NonNull ChatColors chatColors) {
|
||||
if (current.isMms() && !current.isMmsNotification() && ((MediaMmsMessageRecord)current).getQuote() != null) {
|
||||
if (quoteView == null) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
Quote quote = ((MediaMmsMessageRecord)current).getQuote();
|
||||
//noinspection ConstantConditions
|
||||
quoteView.setQuote(glideRequests, quote.getId(), Recipient.live(quote.getAuthor()).get(), quote.getDisplayText(), quote.isOriginalMissing(), quote.getAttachment(), colorizer);
|
||||
quoteView.setQuote(glideRequests, quote.getId(), Recipient.live(quote.getAuthor()).get(), quote.getDisplayText(), quote.isOriginalMissing(), quote.getAttachment(), chatColors);
|
||||
quoteView.setVisibility(View.VISIBLE);
|
||||
quoteView.getLayoutParams().width = ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||
|
||||
|
||||
@@ -7,6 +7,9 @@ import android.graphics.PorterDuff
|
||||
import android.graphics.PorterDuffColorFilter
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.graphics.drawable.ShapeDrawable
|
||||
import android.graphics.drawable.shapes.OvalShape
|
||||
import android.os.Build
|
||||
import androidx.annotation.ColorInt
|
||||
import com.google.common.base.Objects
|
||||
import org.signal.core.util.ColorUtil
|
||||
@@ -32,18 +35,32 @@ class ChatColors private constructor(
|
||||
* Returns the Drawable to render the linear gradient, or null if this ChatColors is a single color.
|
||||
*/
|
||||
val chatBubbleMask: Drawable
|
||||
get() = linearGradient?.let {
|
||||
RotatableGradientDrawable(
|
||||
it.degrees,
|
||||
it.colors,
|
||||
it.positions
|
||||
)
|
||||
} ?: ColorDrawable(asSingleColor())
|
||||
get() {
|
||||
return when {
|
||||
Build.VERSION.SDK_INT < 21 -> {
|
||||
ColorDrawable(Color.TRANSPARENT)
|
||||
}
|
||||
linearGradient != null -> {
|
||||
RotatableGradientDrawable(
|
||||
linearGradient.degrees,
|
||||
linearGradient.colors,
|
||||
linearGradient.positions
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
ColorDrawable(asSingleColor())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ColorFilter to apply to a conversation bubble or other relevant piece of UI.
|
||||
*/
|
||||
val chatBubbleColorFilter: ColorFilter = PorterDuffColorFilter(Color.TRANSPARENT, PorterDuff.Mode.SRC_IN)
|
||||
val chatBubbleColorFilter: ColorFilter = if (Build.VERSION.SDK_INT >= 21) {
|
||||
PorterDuffColorFilter(Color.TRANSPARENT, PorterDuff.Mode.SRC_IN)
|
||||
} else {
|
||||
PorterDuffColorFilter(asSingleColor(), PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
fun asSingleColor(): Int {
|
||||
@@ -94,6 +111,12 @@ class ChatColors private constructor(
|
||||
}
|
||||
|
||||
fun asCircle(): Drawable {
|
||||
if (Build.VERSION.SDK_INT < 21) {
|
||||
return ShapeDrawable(OvalShape()).apply {
|
||||
paint.color = asSingleColor()
|
||||
}
|
||||
}
|
||||
|
||||
val toWrap: Drawable = chatBubbleMask
|
||||
val path = Path()
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.conversation.colors
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.os.Build
|
||||
import android.view.View
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.core.content.ContextCompat
|
||||
@@ -64,6 +65,10 @@ class Colorizer(private val colorizerView: ColorizerView) : RecyclerView.OnScrol
|
||||
}
|
||||
|
||||
fun applyClipPathsToMaskedGradient(recyclerView: RecyclerView) {
|
||||
if (Build.VERSION.SDK_INT < 21) {
|
||||
return
|
||||
}
|
||||
|
||||
val layoutManager = recyclerView.layoutManager as LinearLayoutManager
|
||||
|
||||
val firstVisibleItemPosition: Int = layoutManager.findFirstVisibleItemPosition()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.thoughtcrime.securesms.conversation.colors.ui
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Path
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
@@ -9,7 +8,8 @@ import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.conversation.colors.ChatColors
|
||||
import org.thoughtcrime.securesms.util.MappingAdapter
|
||||
import org.thoughtcrime.securesms.util.MappingViewHolder
|
||||
import org.thoughtcrime.securesms.util.customizeOnDraw
|
||||
import org.thoughtcrime.securesms.util.ViewUtil
|
||||
import org.thoughtcrime.securesms.util.withFixedSize
|
||||
|
||||
class ChatColorSelectionAdapter(
|
||||
context: Context,
|
||||
@@ -81,24 +81,8 @@ class ChatColorSelectionAdapter(
|
||||
preview.isLongClickable = false
|
||||
}
|
||||
|
||||
val mask = model.chatColors.chatBubbleMask
|
||||
preview.setImageDrawable(
|
||||
mask.customizeOnDraw { wrapped, canvas ->
|
||||
val circlePath = Path()
|
||||
val bounds = canvas.clipBounds
|
||||
circlePath.addCircle(
|
||||
bounds.width() / 2f,
|
||||
bounds.height() / 2f,
|
||||
bounds.width() / 2f,
|
||||
Path.Direction.CW
|
||||
)
|
||||
|
||||
canvas.save()
|
||||
canvas.clipPath(circlePath)
|
||||
wrapped.draw(canvas)
|
||||
canvas.restore()
|
||||
}
|
||||
)
|
||||
val mask = model.chatColors.asCircle()
|
||||
preview.setImageDrawable(mask.withFixedSize(ViewUtil.dpToPx(56)))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.thoughtcrime.securesms.conversation.colors.ui.custom
|
||||
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
@@ -33,7 +34,12 @@ class CustomChatColorCreatorFragment : Fragment(R.layout.custom_chat_color_creat
|
||||
|
||||
pager.isUserInputEnabled = false
|
||||
pager.adapter = adapter
|
||||
tabLayoutMediator.attach()
|
||||
|
||||
if (Build.VERSION.SDK_INT < 21) {
|
||||
tabLayout.visibility = View.GONE
|
||||
} else {
|
||||
tabLayoutMediator.attach()
|
||||
}
|
||||
|
||||
val startPage = CustomChatColorCreatorFragmentArgs.fromBundle(requireArguments()).startPage
|
||||
pager.setCurrentItem(startPage, false)
|
||||
|
||||
Reference in New Issue
Block a user