Implement further features for badges.

* Add Subscriptions API
* Add Accept-Language header to profile requests
* Fix several UI bugs, add error dialogs, etc.
This commit is contained in:
Alex Hart
2021-10-21 16:39:02 -03:00
committed by Greyson Parrelli
parent d88999d6d4
commit c1820459b7
91 changed files with 2765 additions and 696 deletions

View File

@@ -1,7 +1,20 @@
package org.thoughtcrime.securesms.util
import com.google.android.gms.wallet.WalletConstants
import org.signal.donations.GooglePayApi
import org.signal.donations.StripeApi
import org.thoughtcrime.securesms.BuildConfig
object Environment {
const val IS_STAGING: Boolean = BuildConfig.BUILD_ENVIRONMENT_TYPE == "Staging"
object Donations {
val GOOGLE_PAY_CONFIGURATION = GooglePayApi.Configuration(
walletEnvironment = if (IS_STAGING) WalletConstants.ENVIRONMENT_TEST else WalletConstants.ENVIRONMENT_PRODUCTION
)
val STRIPE_CONFIGURATION = StripeApi.Configuration(
publishableKey = BuildConfig.STRIPE_PUBLISHABLE_KEY
)
}
}

View File

@@ -397,12 +397,17 @@ public final class FeatureFlags {
return getBoolean(CHANGE_NUMBER_ENABLED, false);
}
/** Whether or not to show donor badges in the UI. */
/** Whether or not to show donor badges in the UI.
*
* WARNING: Donor Badges is an unfinished feature and should not be enabled in production builds.
* Enabling this flag in a custom build can result in crashes and could result in your Google Pay
* account being charged real money.
*/
public static boolean donorBadges() {
if (Environment.IS_STAGING) {
return true;
} else {
return getBoolean(DONOR_BADGES, false);
return getBoolean(DONOR_BADGES, false ) || SignalStore.donationsValues().getSubscriber() != null;
}
}

View File

@@ -44,6 +44,7 @@ import org.whispersystems.signalservice.internal.push.SignalServiceProtos;
import java.io.IOException;
import java.util.List;
import java.util.Locale;
import java.util.stream.Collectors;
import io.reactivex.rxjava3.core.Single;
@@ -100,7 +101,7 @@ public final class ProfileUtil {
Optional<ProfileKey> profileKey = ProfileKeyUtil.profileKeyOptional(recipient.getProfileKey());
return Single.fromCallable(() -> toSignalServiceAddress(context, recipient))
.flatMap(address -> profileService.getProfile(address, profileKey, unidentifiedAccess, requestType).map(p -> new Pair<>(recipient, p)))
.flatMap(address -> profileService.getProfile(address, profileKey, unidentifiedAccess, requestType, Locale.getDefault()).map(p -> new Pair<>(recipient, p)))
.onErrorReturn(t -> new Pair<>(recipient, ServiceResponse.forUnknownError(t)));
}

View File

@@ -16,6 +16,7 @@ import org.whispersystems.libsignal.util.guava.Optional;
import org.whispersystems.signalservice.api.profiles.SignalServiceProfile;
import java.io.IOException;
import java.util.Locale;
import java.util.UUID;
import java.util.regex.Pattern;
@@ -67,7 +68,7 @@ public class UsernameUtil {
try {
Log.d(TAG, "No local user with this username. Searching remotely.");
SignalServiceProfile profile = ApplicationDependencies.getSignalServiceMessageReceiver().retrieveProfileByUsername(username, Optional.absent());
SignalServiceProfile profile = ApplicationDependencies.getSignalServiceMessageReceiver().retrieveProfileByUsername(username, Optional.absent(), Locale.getDefault());
return Optional.fromNullable(profile.getUuid());
} catch (IOException e) {
return Optional.absent();