Update badge copy with new strings.

This commit is contained in:
Alex Hart
2021-10-28 15:49:25 -03:00
committed by Greyson Parrelli
parent 755ec672c0
commit 6c7d837964
21 changed files with 273 additions and 43 deletions

View File

@@ -36,7 +36,7 @@ data class Badge(
val visible: Boolean,
) : Parcelable, Key {
fun isExpired(): Boolean = expirationTimestamp < System.currentTimeMillis()
fun isExpired(): Boolean = expirationTimestamp < System.currentTimeMillis() && expirationTimestamp > 0
fun isBoost(): Boolean = id == BOOST_BADGE_ID
override fun updateDiskCacheKey(messageDigest: MessageDigest) {

View File

@@ -35,7 +35,7 @@ class ExpiredBadgeBottomSheetDialogFragment : DSLSettingsBottomSheetFragment(
if (badge.isBoost()) {
R.string.ExpiredBadgeBottomSheetDialogFragment__your_badge_has_expired
} else {
R.string.ExpiredBadgeBottomSheetDialogFragment__your_subscription_was_cancelled
R.string.ExpiredBadgeBottomSheetDialogFragment__subscription_cancelled
}
)
@@ -44,9 +44,9 @@ class ExpiredBadgeBottomSheetDialogFragment : DSLSettingsBottomSheetFragment(
noPadTextPref(
DSLSettingsText.from(
if (badge.isBoost()) {
getString(R.string.ExpiredBadgeBottomSheetDialogFragment__your_s_badge_has_expired, badge.name)
R.string.ExpiredBadgeBottomSheetDialogFragment__your_boost_badge_has_expired
} else {
getString(R.string.ExpiredBadgeBottomSheetDialogFragment__because)
R.string.ExpiredBadgeBottomSheetDialogFragment__your_sustainer
},
DSLSettingsText.CenterModifier
)
@@ -57,9 +57,9 @@ class ExpiredBadgeBottomSheetDialogFragment : DSLSettingsBottomSheetFragment(
noPadTextPref(
DSLSettingsText.from(
if (badge.isBoost()) {
R.string.ExpiredBadgeBottomSheetDialogFragment__to_continue_supporting
R.string.ExpiredBadgeBottomSheetDialogFragment__to_continue_supporting_technology
} else {
R.string.ExpiredBadgeBottomSheetDialogFragment__to_continue_supporting_signal
R.string.ExpiredBadgeBottomSheetDialogFragment__you_can
},
DSLSettingsText.CenterModifier
)
@@ -70,7 +70,7 @@ class ExpiredBadgeBottomSheetDialogFragment : DSLSettingsBottomSheetFragment(
primaryButton(
text = DSLSettingsText.from(
if (badge.isBoost()) {
R.string.ExpiredBadgeBottomSheetDialogFragment__become_a_subscriber
R.string.ExpiredBadgeBottomSheetDialogFragment__become_a_sustainer
} else {
R.string.ExpiredBadgeBottomSheetDialogFragment__renew_subscription
}

View File

@@ -62,7 +62,6 @@ sealed class DSLSettingsText {
}
object Title2BoldModifier : TextAppearanceModifier(R.style.TextAppearance_Signal_Title2_Bold)
object Body1Modifier : TextAppearanceModifier(R.style.Signal_Text_Body)
object Body1BoldModifier : TextAppearanceModifier(R.style.TextAppearance_Signal_Body1_Bold)
open class TextAppearanceModifier(@StyleRes private val textAppearance: Int) : Modifier {

View File

@@ -147,7 +147,13 @@ class AppSettingsFragment : DSLSettingsFragment(R.string.text_secure_normal__men
if (FeatureFlags.donorBadges() && PlayServicesUtil.getPlayServicesStatus(requireContext()) == PlayServicesUtil.PlayServicesStatus.SUCCESS) {
customPref(
SubscriptionPreference(
title = DSLSettingsText.from(R.string.preferences__subscription),
title = DSLSettingsText.from(
if (state.hasActiveSubscription) {
R.string.preferences__subscription
} else {
R.string.preferences__become_a_signal_sustainer
}
),
icon = DSLSettingsIcon.from(R.drawable.ic_heart_24),
isActive = state.hasActiveSubscription,
onClick = { isActive ->
@@ -159,10 +165,9 @@ class AppSettingsFragment : DSLSettingsFragment(R.string.text_secure_normal__men
}
)
)
// TODO [alex] -- clap
clickPref(
title = DSLSettingsText.from(R.string.preferences__signal_boost),
icon = DSLSettingsIcon.from(R.drawable.ic_heart_24),
icon = DSLSettingsIcon.from(R.drawable.ic_boost_24),
onClick = {
findNavController().navigate(R.id.action_appSettingsFragment_to_boostsFragment)
}
@@ -199,6 +204,7 @@ class AppSettingsFragment : DSLSettingsFragment(R.string.text_secure_normal__men
override fun areItemsTheSame(newItem: SubscriptionPreference): Boolean {
return true
}
override fun areContentsTheSame(newItem: SubscriptionPreference): Boolean {
return super.areContentsTheSame(newItem) && isActive == newItem.isActive
}

View File

@@ -31,7 +31,6 @@ class SubscriptionsRepository(private val donationsService: DonationsService) {
subscriptionLevels.levels.map { (code, level) ->
Subscription(
id = code,
title = level.badge.name,
badge = Badges.fromServiceBadge(level.badge),
price = FiatMoney(level.currencies[currency.currencyCode]!!, currency),
level = code.toInt()

View File

@@ -139,7 +139,7 @@ data class Boost(
class MoneyFilter(val currency: Currency, private val onCustomAmountChanged: (String) -> Unit = {}) : DigitsKeyListener(), TextWatcher {
val separatorCount = min(1, currency.defaultFractionDigits)
val prefix: String = "${currency.getSymbol(Locale.getDefault())} "
val prefix: String = currency.getSymbol(Locale.getDefault())
val pattern: Pattern = "[0-9]*([.,]){0,$separatorCount}[0-9]{0,${currency.defaultFractionDigits}}".toPattern()
override fun filter(

View File

@@ -45,7 +45,7 @@ object ActiveSubscriptionPreference {
override fun bind(model: Model) {
badge.setBadge(model.subscription.badge)
title.text = model.subscription.title
title.text = model.subscription.getTitle(context)
price.text = context.getString(
R.string.MySupportPreference__s_per_month,

View File

@@ -24,12 +24,11 @@ import org.thoughtcrime.securesms.components.settings.app.subscription.DonationE
import org.thoughtcrime.securesms.components.settings.app.subscription.models.CurrencySelection
import org.thoughtcrime.securesms.components.settings.app.subscription.models.GooglePayButton
import org.thoughtcrime.securesms.components.settings.configure
import org.thoughtcrime.securesms.payments.FiatMoneyUtil
import org.thoughtcrime.securesms.subscription.Subscription
import org.thoughtcrime.securesms.util.DateUtils
import org.thoughtcrime.securesms.util.LifecycleDisposable
import org.thoughtcrime.securesms.util.SpanUtil
import java.util.Calendar
import java.util.Locale
import java.util.concurrent.TimeUnit
/**
@@ -44,10 +43,10 @@ class SubscribeFragment : DSLSettingsFragment(
private val lifecycleDisposable = LifecycleDisposable()
private val supportTechSummary: CharSequence by lazy {
SpannableStringBuilder(requireContext().getString(R.string.SubscribeFragment__support_technology_that_is_built_for_you))
SpannableStringBuilder(requireContext().getString(R.string.SubscribeFragment__support_technology_that_is_built_for_you_not))
.append(" ")
.append(
SpanUtil.learnMore(requireContext(), ContextCompat.getColor(requireContext(), R.color.signal_accent_primary)) {
SpanUtil.readMore(requireContext(), ContextCompat.getColor(requireContext(), R.color.signal_accent_primary)) {
findNavController().navigate(SubscribeFragmentDirections.actionSubscribeFragmentToSubscribeLearnMoreBottomSheetDialog())
}
)
@@ -152,14 +151,20 @@ class SubscribeFragment : DSLSettingsFragment(
text = DSLSettingsText.from(R.string.SubscribeFragment__update_subscription),
isEnabled = areFieldsEnabled && (!activeAndSameLevel || isExpiring),
onClick = {
val price = viewModel.state.value?.selectedSubscription?.price ?: return@primaryButton
val calendar = Calendar.getInstance()
calendar.add(Calendar.MONTH, 1)
MaterialAlertDialogBuilder(requireContext())
.setTitle(R.string.SubscribeFragment__update_subscription_question)
.setMessage(
getString(
R.string.SubscribeFragment__you_will_be_charged_the_full_amount,
DateUtils.formatDateWithYear(Locale.getDefault(), calendar.timeInMillis)
R.string.SubscribeFragment__you_will_be_charged_the_full_amount_s_of,
FiatMoneyUtil.format(
requireContext().resources,
price,
FiatMoneyUtil.formatOptions().trimZerosAfterDecimal()
)
)
)
.setPositiveButton(R.string.SubscribeFragment__update) { dialog, _ ->
@@ -214,7 +219,7 @@ class SubscribeFragment : DSLSettingsFragment(
}
private fun onGooglePayButtonClicked() {
viewModel.requestTokenFromGooglePay()
viewModel.requestTokenFromGooglePay(requireContext())
}
private fun onPaymentConfirmed(badge: Badge) {

View File

@@ -1,5 +1,6 @@
package org.thoughtcrime.securesms.components.settings.app.subscription.subscribe
import android.content.Context
import android.content.Intent
import androidx.lifecycle.LiveData
import androidx.lifecycle.ViewModel
@@ -170,7 +171,7 @@ class SubscribeViewModel(
)
}
fun requestTokenFromGooglePay() {
fun requestTokenFromGooglePay(context: Context) {
val snapshot = store.state
if (snapshot.selectedSubscription == null) {
return
@@ -179,7 +180,7 @@ class SubscribeViewModel(
store.update { it.copy(stage = SubscribeState.Stage.TOKEN_REQUEST) }
subscriptionToPurchase = snapshot.selectedSubscription
donationPaymentRepository.requestTokenFromGooglePay(snapshot.selectedSubscription.price, snapshot.selectedSubscription.title, fetchTokenRequestCode)
donationPaymentRepository.requestTokenFromGooglePay(snapshot.selectedSubscription.price, snapshot.selectedSubscription.getTitle(context), fetchTokenRequestCode)
}
fun setSelectedSubscription(subscription: Subscription) {

View File

@@ -3,10 +3,12 @@ package org.thoughtcrime.securesms.components.settings.app.subscription.thanks
import android.animation.Animator
import android.content.DialogInterface
import android.os.Bundle
import android.text.SpannableStringBuilder
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.navigation.fragment.findNavController
import com.airbnb.lottie.LottieAnimationView
import com.airbnb.lottie.LottieDrawable
@@ -19,6 +21,7 @@ import org.thoughtcrime.securesms.badges.BadgeRepository
import org.thoughtcrime.securesms.components.FixedRoundedCornerBottomSheetDialogFragment
import org.thoughtcrime.securesms.components.settings.app.AppSettingsActivity
import org.thoughtcrime.securesms.recipients.Recipient
import org.thoughtcrime.securesms.util.SpanUtil
import org.thoughtcrime.securesms.util.visible
class ThanksForYourSupportBottomSheetDialogFragment : FixedRoundedCornerBottomSheetDialogFragment() {
@@ -49,6 +52,7 @@ class ThanksForYourSupportBottomSheetDialogFragment : FixedRoundedCornerBottomSh
val done: MaterialButton = view.findViewById(R.id.thanks_bottom_sheet_done)
val controlText: TextView = view.findViewById(R.id.thanks_bottom_sheet_control_text)
val controlNote: View = view.findViewById(R.id.thanks_bottom_sheet_featured_note)
val subhead: TextView = view.findViewById(R.id.thanks_bottom_sheet_subhead)
heading = view.findViewById(R.id.thanks_bottom_sheet_heading)
switch = view.findViewById(R.id.thanks_bottom_sheet_switch)
@@ -58,6 +62,27 @@ class ThanksForYourSupportBottomSheetDialogFragment : FixedRoundedCornerBottomSh
badgeView.setBadge(args.badge)
badgeName.text = args.badge.name
if (args.badge.isBoost()) {
if (Recipient.self().badges.any { !it.isBoost() }) {
subhead.setText(R.string.SubscribeThanksForYourSupportBottomSheetDialogFragment__youve_earned_a_boost_badge_help_signal)
} else {
subhead.text = SpannableStringBuilder(getString(R.string.SubscribeThanksForYourSupportBottomSheetDialogFragment__youve_earned_a_boost_badge_help_signal))
.append(" ")
.append(getString(R.string.SubscribeThanksForYourSupportBottomSheetDialogFragment__you_can_also))
.append(
SpanUtil.clickable(
getString(R.string.SubscribeThanksForYourSupportBottomSheetDialogFragment__become_a_montly_sustainer),
ContextCompat.getColor(requireContext(), R.color.signal_accent_primary),
) {
requireActivity().finish()
requireActivity().startActivity(AppSettingsActivity.subscriptions(requireContext()))
}
)
}
} else {
subhead.text = getString(R.string.SubscribeThanksForYourSupportBottomSheetDialogFragment__youve_earned_s_badge_help_signal, args.badge.name)
}
val otherBadges = Recipient.self().badges.filterNot { it.id == args.badge.id }
val hasOtherBadges = otherBadges.isNotEmpty()
val displayingBadges = otherBadges.all { it.visible }

View File

@@ -488,6 +488,12 @@ class ConversationSettingsFragment : DSLSettingsFragment(
sectionHeaderPref(R.string.ManageProfileFragment_badges)
displayBadges(requireContext(), state.recipient.badges)
textPref(
summary = DSLSettingsText.from(
R.string.ConversationSettingsFragment__get_badges
)
)
}
if (recipientSettingsState.selfHasGroups) {

View File

@@ -348,7 +348,7 @@ public final class Megaphones {
.setTitle(R.string.BecomeASustainerMegaphone__become_a_sustainer)
.setImage(R.drawable.ic_become_a_sustainer_megaphone)
.setBody(R.string.BecomeASustainerMegaphone__signal_is_powered)
.setActionButton(R.string.BecomeASustainerMegaphone__donate, (megaphone, listener) -> {
.setActionButton(R.string.BecomeASustainerMegaphone__contribute, (megaphone, listener) -> {
listener.onMegaphoneNavigationRequested(AppSettingsActivity.subscriptions(context));
listener.onMegaphoneCompleted(Event.BECOME_A_SUSTAINER);
})

View File

@@ -1,5 +1,6 @@
package org.thoughtcrime.securesms.subscription
import android.content.Context
import android.view.View
import android.widget.ImageView
import android.widget.TextView
@@ -20,12 +21,20 @@ import java.util.Locale
*/
data class Subscription(
val id: String,
val title: String,
val badge: Badge,
val price: FiatMoney,
val level: Int,
) {
fun getTitle(context: Context): String {
return when (level) {
500 -> context.getString(R.string.SubscribeFragment__sustainer_i)
1000 -> context.getString(R.string.SubscribeFragment__sustainer_ii)
2000 -> context.getString(R.string.SubscribeFragment__sustainer_iii)
else -> ""
}
}
companion object {
fun register(adapter: MappingAdapter) {
adapter.registerFactory(Model::class.java, MappingAdapter.LayoutFactory({ ViewHolder(it) }, R.layout.subscription_preference))
@@ -81,7 +90,7 @@ data class Subscription(
badge.setBadge(model.subscription.badge)
}
title.text = model.subscription.title
title.text = model.subscription.getTitle(context)
tagline.text = context.getString(R.string.Subscription__earn_a_s_badge, model.subscription.badge.name)
val formattedPrice = FiatMoneyUtil.format(

View File

@@ -136,6 +136,21 @@ public final class SpanUtil {
return clickSubstring(learnMore, learnMore, onLearnMoreClicked, color);
}
public static CharSequence readMore(@NonNull Context context,
@ColorInt int color,
@NonNull View.OnClickListener onLearnMoreClicked)
{
String readMore = context.getString(R.string.SpanUtil__read_more);
return clickSubstring(readMore, readMore, onLearnMoreClicked, color);
}
public static CharSequence clickable(@NonNull CharSequence text,
@ColorInt int color,
@NonNull View.OnClickListener onLearnMoreClicked)
{
return clickSubstring(text, text, onLearnMoreClicked, color);
}
/**
* Takes two resources:
* - one resource that has a single string placeholder