kopia lustrzana https://github.com/ryukoposting/Signal-Android
Add thread display body and proper image for gift badges.
rodzic
1345413645
commit
158f77a634
|
@ -48,6 +48,7 @@ class GiftThanksSheet : DSLSettingsBottomSheetFragment() {
|
|||
override fun bindAdapter(adapter: DSLSettingsAdapter) {
|
||||
BadgePreview.register(adapter)
|
||||
|
||||
lifecycleDisposable.bindTo(viewLifecycleOwner)
|
||||
lifecycleDisposable += Recipient.observable(recipientId).subscribe {
|
||||
adapter.submitList(getConfiguration(it).toMappingModelList())
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import androidx.appcompat.app.AlertDialog
|
|||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.fragment.app.setFragmentResult
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.lifecycle.LiveDataReactiveStreams
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
||||
|
@ -105,7 +104,7 @@ class ViewReceivedGiftBottomSheet : DSLSettingsBottomSheetFragment() {
|
|||
onRedemptionError(donationError)
|
||||
}
|
||||
|
||||
LiveDataReactiveStreams.fromPublisher(viewModel.state).observe(viewLifecycleOwner) { state ->
|
||||
lifecycleDisposable += viewModel.state.subscribe { state ->
|
||||
adapter.submitList(getConfiguration(state).toMappingModelList())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package org.thoughtcrime.securesms.badges.gifts.viewgift.sent
|
|||
import android.os.Bundle
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.lifecycle.LiveDataReactiveStreams
|
||||
import org.signal.core.util.DimensionUnit
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.badges.gifts.viewgift.ViewGiftRepository
|
||||
|
@ -17,6 +16,7 @@ import org.thoughtcrime.securesms.database.model.MmsMessageRecord
|
|||
import org.thoughtcrime.securesms.database.model.databaseprotos.GiftBadge
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
import org.thoughtcrime.securesms.util.BottomSheetUtil
|
||||
import org.thoughtcrime.securesms.util.LifecycleDisposable
|
||||
|
||||
/**
|
||||
* Handles all interactions for received gift badges.
|
||||
|
@ -45,6 +45,8 @@ class ViewSentGiftBottomSheet : DSLSettingsBottomSheetFragment() {
|
|||
private val giftBadge: GiftBadge
|
||||
get() = GiftBadge.parseFrom(requireArguments().getByteArray(ARG_GIFT_BADGE))
|
||||
|
||||
private val lifecycleDisposable = LifecycleDisposable()
|
||||
|
||||
private val viewModel: ViewSentGiftViewModel by viewModels(
|
||||
factoryProducer = { ViewSentGiftViewModel.Factory(sentTo, giftBadge, ViewGiftRepository()) }
|
||||
)
|
||||
|
@ -52,7 +54,8 @@ class ViewSentGiftBottomSheet : DSLSettingsBottomSheetFragment() {
|
|||
override fun bindAdapter(adapter: DSLSettingsAdapter) {
|
||||
BadgeDisplay112.register(adapter)
|
||||
|
||||
LiveDataReactiveStreams.fromPublisher(viewModel.state).observe(viewLifecycleOwner) { state ->
|
||||
lifecycleDisposable.bindTo(viewLifecycleOwner)
|
||||
lifecycleDisposable += viewModel.state.subscribe { state ->
|
||||
adapter.submitList(getConfiguration(state).toMappingModelList())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,4 +8,5 @@ public final class EmojiStrings {
|
|||
public static final String AUDIO = "\uD83C\uDFA4";
|
||||
public static final String FILE = "\uD83D\uDCCE";
|
||||
public static final String STICKER = "\u2B50";
|
||||
public static final String GIFT = "\uD83C\uDF81";
|
||||
}
|
||||
|
|
|
@ -48,6 +48,8 @@ public final class ThreadBodyUtil {
|
|||
} else if (MessageRecordUtil.hasSticker(record)) {
|
||||
String emoji = getStickerEmoji(record);
|
||||
return format(context, record, emoji, R.string.ThreadRecord_sticker);
|
||||
} else if (MessageRecordUtil.hasGiftBadge(record)) {
|
||||
return String.format("%s %s", EmojiStrings.GIFT, getGiftSummary(context, record));
|
||||
}
|
||||
|
||||
boolean hasImage = false;
|
||||
|
@ -72,6 +74,16 @@ public final class ThreadBodyUtil {
|
|||
return getBody(context, record);
|
||||
}
|
||||
}
|
||||
|
||||
private static @NonNull String getGiftSummary(@NonNull Context context, @NonNull MessageRecord messageRecord) {
|
||||
if (messageRecord.isOutgoing()) {
|
||||
return context.getString(R.string.ThreadRecord__you_sent_a_gift);
|
||||
} else if (messageRecord.getViewedReceiptCount() > 0) {
|
||||
return context.getString(R.string.ThreadRecord__you_redeemed_a_gift_badge);
|
||||
} else {
|
||||
return context.getString(R.string.ThreadRecord__you_received_a_gift);
|
||||
}
|
||||
}
|
||||
|
||||
private static @NonNull String format(@NonNull Context context, @NonNull MessageRecord record, @NonNull String emoji, @StringRes int defaultStringRes) {
|
||||
return String.format("%s %s", emoji, getBodyOrDefault(context, record, defaultStringRes));
|
||||
|
|
|
@ -44,6 +44,7 @@ data class GiftBadgeModel(val giftBadge: GiftBadge) : Key {
|
|||
}
|
||||
|
||||
override fun updateDiskCacheKey(messageDigest: MessageDigest) {
|
||||
messageDigest.update(giftBadge.toByteArray())
|
||||
}
|
||||
|
||||
class Fetcher(
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.thoughtcrime.securesms.service.KeyCachingService
|
|||
import org.thoughtcrime.securesms.util.MediaUtil
|
||||
import org.thoughtcrime.securesms.util.SpanUtil
|
||||
import org.thoughtcrime.securesms.util.Util
|
||||
import org.thoughtcrime.securesms.util.hasGiftBadge
|
||||
import org.thoughtcrime.securesms.util.hasSharedContact
|
||||
import org.thoughtcrime.securesms.util.hasSticker
|
||||
import org.thoughtcrime.securesms.util.isMediaMessage
|
||||
|
@ -186,6 +187,8 @@ class MessageNotification(threadRecipient: Recipient, record: MessageRecord) : N
|
|||
ThreadBodyUtil.getFormattedBodyFor(context, record)
|
||||
} else if (record.isGroupCall) {
|
||||
MessageRecord.getGroupCallUpdateDescription(context, record.body, false).spannable
|
||||
} else if (record.hasGiftBadge()) {
|
||||
ThreadBodyUtil.getFormattedBodyFor(context, record)
|
||||
} else {
|
||||
MentionUtil.updateBodyWithDisplayNames(context, record)
|
||||
}
|
||||
|
|
|
@ -1769,6 +1769,12 @@
|
|||
<string name="ThreadRecord_file">File</string>
|
||||
<string name="ThreadRecord_video">Video</string>
|
||||
<string name="ThreadRecord_chat_session_refreshed">Chat session refreshed</string>
|
||||
<!-- Displayed in the notification when the user is sent a gift -->
|
||||
<string name="ThreadRecord__you_received_a_gift">You received a gift</string>
|
||||
<!-- Displayed in the notification when the user sends a gift -->
|
||||
<string name="ThreadRecord__you_sent_a_gift">You sent a gift</string>
|
||||
<!-- Displayed in the notification when the user has opened a received gift -->
|
||||
<string name="ThreadRecord__you_redeemed_a_gift_badge">You redeemed a gift badge</string>
|
||||
|
||||
<!-- UpdateApkReadyListener -->
|
||||
<string name="UpdateApkReadyListener_Signal_update">Signal update</string>
|
||||
|
|
Ładowanie…
Reference in New Issue