mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-23 10:20:25 +01:00
Add server-based localization of subscription names and badge information.
This commit is contained in:
committed by
Greyson Parrelli
parent
56c502c9bf
commit
70355aa70e
@@ -10,6 +10,7 @@ import org.whispersystems.signalservice.api.subscriptions.ActiveSubscription
|
||||
import org.whispersystems.signalservice.api.subscriptions.SubscriptionLevels
|
||||
import org.whispersystems.signalservice.internal.ServiceResponse
|
||||
import java.util.Currency
|
||||
import java.util.Locale
|
||||
|
||||
/**
|
||||
* Repository which can query for the user's active subscription as well as a list of available subscriptions,
|
||||
@@ -27,12 +28,13 @@ class SubscriptionsRepository(private val donationsService: DonationsService) {
|
||||
}
|
||||
}
|
||||
|
||||
fun getSubscriptions(currency: Currency): Single<List<Subscription>> = donationsService.subscriptionLevels
|
||||
fun getSubscriptions(currency: Currency): Single<List<Subscription>> = donationsService.getSubscriptionLevels(Locale.getDefault())
|
||||
.flatMap(ServiceResponse<SubscriptionLevels>::flattenResult)
|
||||
.map { subscriptionLevels ->
|
||||
subscriptionLevels.levels.map { (code, level) ->
|
||||
Subscription(
|
||||
id = code,
|
||||
name = level.name,
|
||||
badge = Badges.fromServiceBadge(level.badge),
|
||||
price = FiatMoney(level.currencies[currency.currencyCode]!!, currency),
|
||||
level = code.toInt()
|
||||
|
||||
@@ -56,7 +56,7 @@ class BoostFragment : DSLSettingsBottomSheetFragment(
|
||||
.append(" ")
|
||||
.append(
|
||||
SpanUtil.learnMore(requireContext(), ContextCompat.getColor(requireContext(), R.color.signal_accent_primary)) {
|
||||
CommunicationActions.openBrowserLink(requireContext(), R.string.sustainer_boost_and_badges)
|
||||
CommunicationActions.openBrowserLink(requireContext(), getString(R.string.sustainer_boost_and_badges))
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.whispersystems.signalservice.api.services.DonationsService
|
||||
import org.whispersystems.signalservice.internal.ServiceResponse
|
||||
import java.math.BigDecimal
|
||||
import java.util.Currency
|
||||
import java.util.Locale
|
||||
|
||||
class BoostRepository(private val donationsService: DonationsService) {
|
||||
|
||||
@@ -22,7 +23,7 @@ class BoostRepository(private val donationsService: DonationsService) {
|
||||
}
|
||||
|
||||
fun getBoostBadge(): Single<Badge> {
|
||||
return donationsService.boostBadge
|
||||
return donationsService.getBoostBadge(Locale.getDefault())
|
||||
.flatMap(ServiceResponse<SignalServiceProfile.Badge>::flattenResult)
|
||||
.map(Badges::fromServiceBadge)
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ object ActiveSubscriptionPreference {
|
||||
|
||||
override fun bind(model: Model) {
|
||||
badge.setBadge(model.subscription.badge)
|
||||
title.text = model.subscription.getTitle(context)
|
||||
title.text = model.subscription.name
|
||||
|
||||
price.text = context.getString(
|
||||
R.string.MySupportPreference__s_per_month,
|
||||
|
||||
@@ -199,7 +199,7 @@ class SubscribeViewModel(
|
||||
store.update { it.copy(stage = SubscribeState.Stage.TOKEN_REQUEST) }
|
||||
|
||||
subscriptionToPurchase = snapshot.selectedSubscription
|
||||
donationPaymentRepository.requestTokenFromGooglePay(snapshot.selectedSubscription.price, snapshot.selectedSubscription.getTitle(context), fetchTokenRequestCode)
|
||||
donationPaymentRepository.requestTokenFromGooglePay(snapshot.selectedSubscription.price, snapshot.selectedSubscription.name, fetchTokenRequestCode)
|
||||
}
|
||||
|
||||
fun setSelectedSubscription(subscription: Subscription) {
|
||||
|
||||
Reference in New Issue
Block a user