Enable Change Number.

fork-5.53.8
Cody Henthorne 2022-01-21 15:57:08 -05:00 zatwierdzone przez Greyson Parrelli
rodzic 14886ce28e
commit 95cb80a93a
6 zmienionych plików z 45 dodań i 12 usunięć

Wyświetl plik

@ -1,6 +1,5 @@
package org.thoughtcrime.securesms; package org.thoughtcrime.securesms;
import org.thoughtcrime.securesms.util.FeatureFlags;
import org.whispersystems.signalservice.api.account.AccountAttributes; import org.whispersystems.signalservice.api.account.AccountAttributes;
public final class AppCapabilities { public final class AppCapabilities {
@ -13,12 +12,13 @@ public final class AppCapabilities {
private static final boolean GV1_MIGRATION = true; private static final boolean GV1_MIGRATION = true;
private static final boolean ANNOUNCEMENT_GROUPS = true; private static final boolean ANNOUNCEMENT_GROUPS = true;
private static final boolean SENDER_KEY = true; private static final boolean SENDER_KEY = true;
private static final boolean CHANGE_NUMBER = true;
/** /**
* @param storageCapable Whether or not the user can use storage service. This is another way of * @param storageCapable Whether or not the user can use storage service. This is another way of
* asking if the user has set a Signal PIN or not. * asking if the user has set a Signal PIN or not.
*/ */
public static AccountAttributes.Capabilities getCapabilities(boolean storageCapable) { public static AccountAttributes.Capabilities getCapabilities(boolean storageCapable) {
return new AccountAttributes.Capabilities(UUID_CAPABLE, GV2_CAPABLE, storageCapable, GV1_MIGRATION, SENDER_KEY, ANNOUNCEMENT_GROUPS, FeatureFlags.changeNumber()); return new AccountAttributes.Capabilities(UUID_CAPABLE, GV2_CAPABLE, storageCapable, GV1_MIGRATION, SENDER_KEY, ANNOUNCEMENT_GROUPS, CHANGE_NUMBER);
} }
} }

Wyświetl plik

@ -4,6 +4,7 @@ import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import androidx.navigation.NavDirections import androidx.navigation.NavDirections
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import io.reactivex.rxjava3.subjects.PublishSubject import io.reactivex.rxjava3.subjects.PublishSubject
import io.reactivex.rxjava3.subjects.Subject import io.reactivex.rxjava3.subjects.Subject
import org.thoughtcrime.securesms.MainActivity import org.thoughtcrime.securesms.MainActivity
@ -15,6 +16,8 @@ import org.thoughtcrime.securesms.components.settings.app.subscription.DonationP
import org.thoughtcrime.securesms.help.HelpFragment import org.thoughtcrime.securesms.help.HelpFragment
import org.thoughtcrime.securesms.keyvalue.SettingsValues import org.thoughtcrime.securesms.keyvalue.SettingsValues
import org.thoughtcrime.securesms.keyvalue.SignalStore import org.thoughtcrime.securesms.keyvalue.SignalStore
import org.thoughtcrime.securesms.phonenumbers.PhoneNumberFormatter
import org.thoughtcrime.securesms.recipients.Recipient
import org.thoughtcrime.securesms.service.KeyCachingService import org.thoughtcrime.securesms.service.KeyCachingService
import org.thoughtcrime.securesms.util.CachedInflater import org.thoughtcrime.securesms.util.CachedInflater
import org.thoughtcrime.securesms.util.DynamicTheme import org.thoughtcrime.securesms.util.DynamicTheme
@ -24,6 +27,7 @@ private const val START_LOCATION = "app.settings.start.location"
private const val START_ARGUMENTS = "app.settings.start.arguments" private const val START_ARGUMENTS = "app.settings.start.arguments"
private const val NOTIFICATION_CATEGORY = "android.intent.category.NOTIFICATION_PREFERENCES" private const val NOTIFICATION_CATEGORY = "android.intent.category.NOTIFICATION_PREFERENCES"
private const val STATE_WAS_CONFIGURATION_UPDATED = "app.settings.state.configuration.updated" private const val STATE_WAS_CONFIGURATION_UPDATED = "app.settings.state.configuration.updated"
private const val EXTRA_PERFORM_ACTION_ON_CREATE = "extra_perform_action_on_create"
class AppSettingsActivity : DSLSettingsActivity(), DonationPaymentComponent { class AppSettingsActivity : DSLSettingsActivity(), DonationPaymentComponent {
@ -82,6 +86,17 @@ class AppSettingsActivity : DSLSettingsActivity(), DonationPaymentComponent {
startService(intent) startService(intent)
} }
} }
if (savedInstanceState == null) {
when (intent.getStringExtra(EXTRA_PERFORM_ACTION_ON_CREATE)) {
ACTION_CHANGE_NUMBER_SUCCESS -> {
MaterialAlertDialogBuilder(this)
.setMessage(getString(R.string.ChangeNumber__your_phone_number_has_changed_to_s, PhoneNumberFormatter.prettyPrint(Recipient.self().requireE164())))
.setPositiveButton(R.string.ChangeNumber__okay, null)
.show()
}
}
}
} }
override fun onNewIntent(intent: Intent?) { override fun onNewIntent(intent: Intent?) {
@ -109,8 +124,14 @@ class AppSettingsActivity : DSLSettingsActivity(), DonationPaymentComponent {
} }
companion object { companion object {
const val ACTION_CHANGE_NUMBER_SUCCESS = "action_change_number_success"
@JvmStatic @JvmStatic
fun home(context: Context): Intent = getIntentForStartLocation(context, StartLocation.HOME) @JvmOverloads
fun home(context: Context, action: String? = null): Intent {
return getIntentForStartLocation(context, StartLocation.HOME)
.putExtra(EXTRA_PERFORM_ACTION_ON_CREATE, action)
}
@JvmStatic @JvmStatic
fun backups(context: Context): Intent = getIntentForStartLocation(context, StartLocation.BACKUPS) fun backups(context: Context): Intent = getIntentForStartLocation(context, StartLocation.BACKUPS)

Wyświetl plik

@ -1,15 +1,13 @@
package org.thoughtcrime.securesms.components.settings.app.changenumber package org.thoughtcrime.securesms.components.settings.app.changenumber
import android.os.Bundle import android.os.Bundle
import android.widget.Toast
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import androidx.navigation.fragment.NavHostFragment import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.fragment.findNavController
import org.thoughtcrime.securesms.R import org.thoughtcrime.securesms.R
import org.thoughtcrime.securesms.components.settings.app.AppSettingsActivity
import org.thoughtcrime.securesms.registration.fragments.CaptchaFragment import org.thoughtcrime.securesms.registration.fragments.CaptchaFragment
import org.thoughtcrime.securesms.registration.viewmodel.BaseRegistrationViewModel import org.thoughtcrime.securesms.registration.viewmodel.BaseRegistrationViewModel
import org.thoughtcrime.securesms.util.navigation.safeNavigate
/** /**
* Helpers for various aspects of the change number flow. * Helpers for various aspects of the change number flow.
@ -36,7 +34,7 @@ object ChangeNumberUtil {
} }
fun Fragment.changeNumberSuccess() { fun Fragment.changeNumberSuccess() {
findNavController().safeNavigate(R.id.action_pop_app_settings_change_number) requireActivity().finish()
Toast.makeText(requireContext(), R.string.ChangeNumber__your_phone_number_has_been_changed, Toast.LENGTH_SHORT).show() requireActivity().startActivity(AppSettingsActivity.home(requireContext(), AppSettingsActivity.ACTION_CHANGE_NUMBER_SUCCESS))
} }
} }

Wyświetl plik

@ -95,9 +95,10 @@ public class ApplicationMigrations {
static final int FIX_DEPRECATION = 51; // Only used to trigger clearing the 'client deprecated' flag static final int FIX_DEPRECATION = 51; // Only used to trigger clearing the 'client deprecated' flag
static final int JUMBOMOJI_DOWNLOAD = 52; static final int JUMBOMOJI_DOWNLOAD = 52;
static final int FIX_EMOJI_QUALITY = 53; static final int FIX_EMOJI_QUALITY = 53;
static final int CHANGE_NUMBER_CAPABILITY_4 = 54;
} }
public static final int CURRENT_VERSION = 53; public static final int CURRENT_VERSION = 54;
/** /**
* This *must* be called after the {@link JobManager} has been instantiated, but *before* the call * This *must* be called after the {@link JobManager} has been instantiated, but *before* the call
@ -411,6 +412,10 @@ public class ApplicationMigrations {
jobs.put(Version.FIX_EMOJI_QUALITY, new EmojiDownloadMigrationJob()); jobs.put(Version.FIX_EMOJI_QUALITY, new EmojiDownloadMigrationJob());
} }
if (lastSeenVersion < Version.CHANGE_NUMBER_CAPABILITY_4) {
jobs.put(Version.CHANGE_NUMBER_CAPABILITY_4, new AttributesMigrationJob());
}
return jobs; return jobs;
} }

Wyświetl plik

@ -84,7 +84,7 @@ public final class FeatureFlags {
private static final String SUGGEST_SMS_BLACKLIST = "android.suggestSmsBlacklist"; private static final String SUGGEST_SMS_BLACKLIST = "android.suggestSmsBlacklist";
private static final String MAX_GROUP_CALL_RING_SIZE = "global.calling.maxGroupCallRingSize"; private static final String MAX_GROUP_CALL_RING_SIZE = "global.calling.maxGroupCallRingSize";
private static final String GROUP_CALL_RINGING = "android.calling.groupCallRinging"; private static final String GROUP_CALL_RINGING = "android.calling.groupCallRinging";
private static final String CHANGE_NUMBER_ENABLED = "android.changeNumber"; private static final String CHANGE_NUMBER_ENABLED = "android.changeNumber.2";
private static final String DONOR_BADGES = "android.donorBadges.6"; private static final String DONOR_BADGES = "android.donorBadges.6";
private static final String DONOR_BADGES_DISPLAY = "android.donorBadges.display.4"; private static final String DONOR_BADGES_DISPLAY = "android.donorBadges.display.4";
private static final String CDSH = "android.cdsh"; private static final String CDSH = "android.cdsh";
@ -218,7 +218,6 @@ public final class FeatureFlags {
private static final Map<String, OnFlagChange> FLAG_CHANGE_LISTENERS = new HashMap<String, OnFlagChange>() {{ private static final Map<String, OnFlagChange> FLAG_CHANGE_LISTENERS = new HashMap<String, OnFlagChange>() {{
put(MESSAGE_PROCESSOR_ALARM_INTERVAL, change -> MessageProcessReceiver.startOrUpdateAlarm(ApplicationDependencies.getApplication())); put(MESSAGE_PROCESSOR_ALARM_INTERVAL, change -> MessageProcessReceiver.startOrUpdateAlarm(ApplicationDependencies.getApplication()));
put(SENDER_KEY, change -> ApplicationDependencies.getJobManager().add(new RefreshAttributesJob())); put(SENDER_KEY, change -> ApplicationDependencies.getJobManager().add(new RefreshAttributesJob()));
put(CHANGE_NUMBER_ENABLED, change -> ApplicationDependencies.getJobManager().add(new RefreshAttributesJob()));
}}; }};
private static final Map<String, Object> REMOTE_VALUES = new TreeMap<>(); private static final Map<String, Object> REMOTE_VALUES = new TreeMap<>();

Wyświetl plik

@ -3603,7 +3603,10 @@
<!-- ChangeNumberFragment --> <!-- ChangeNumberFragment -->
<string name="ChangeNumberFragment__use_this_to_change_your_current_phone_number_to_a_new_phone_number">Use this to change your current phone number to a new phone number. You cant undo this change.\n\nBefore continuing, make sure your new number can receive SMS or calls.</string> <string name="ChangeNumberFragment__use_this_to_change_your_current_phone_number_to_a_new_phone_number">Use this to change your current phone number to a new phone number. You cant undo this change.\n\nBefore continuing, make sure your new number can receive SMS or calls.</string>
<string name="ChangeNumberFragment__continue">Continue</string> <string name="ChangeNumberFragment__continue">Continue</string>
<string name="ChangeNumber__your_phone_number_has_been_changed">Your phone number has been changed.</string> <!-- Message shown on dialog after your number has been changed successfully. -->
<string name="ChangeNumber__your_phone_number_has_changed_to_s">Your phone number has been changed to %1$s</string>
<!-- Confirmation button to dismiss number changed dialog -->
<string name="ChangeNumber__okay">Okay</string>
<!-- ChangeNumberEnterPhoneNumberFragment --> <!-- ChangeNumberEnterPhoneNumberFragment -->
<string name="ChangeNumberEnterPhoneNumberFragment__change_number">Change Number</string> <string name="ChangeNumberEnterPhoneNumberFragment__change_number">Change Number</string>
@ -3638,12 +3641,19 @@
<string name="ChangeNumberPinDiffersFragment__keep_old_pin_question">Keep old pin?</string> <string name="ChangeNumberPinDiffersFragment__keep_old_pin_question">Keep old pin?</string>
<!-- ChangeNumberLockActivity --> <!-- ChangeNumberLockActivity -->
<!-- Info message shown to user if something crashed the app during the change number attempt and we were unable to confirm the change so we force them into this screen to check before letting them use the app -->
<string name="ChangeNumberLockActivity__it_looks_like_you_tried_to_change_your_number_but_we_were_unable_to_determine_if_it_was_successful_rechecking_now">It looks like you tried to change your number but we were unable to determine if it was successful.\n\nRechecking now…</string> <string name="ChangeNumberLockActivity__it_looks_like_you_tried_to_change_your_number_but_we_were_unable_to_determine_if_it_was_successful_rechecking_now">It looks like you tried to change your number but we were unable to determine if it was successful.\n\nRechecking now…</string>
<!-- Dialog title shown if we were able to confirm your change number status (meaning we now know what the server thinks our number is) after a crash during the regular flow -->
<string name="ChangeNumberLockActivity__change_status_confirmed">Change status confirmed</string> <string name="ChangeNumberLockActivity__change_status_confirmed">Change status confirmed</string>
<!-- Dialog message shown if we were able to confirm your change number status (meaning we now know what the server thinks our number is) after a crash during the regular flow -->
<string name="ChangeNumberLockActivity__your_number_has_been_confirmed_as_s">Your number has been confirmed as %1$s. If this is not your new number, please restart the change number process.</string> <string name="ChangeNumberLockActivity__your_number_has_been_confirmed_as_s">Your number has been confirmed as %1$s. If this is not your new number, please restart the change number process.</string>
<!-- Dialog title shown if we were not able to confirm your phone number with the server and thus cannot let leave the change flow yet after a crash during the regular flow -->
<string name="ChangeNumberLockActivity__change_status_unconfirmed">Change status unconfirmed</string> <string name="ChangeNumberLockActivity__change_status_unconfirmed">Change status unconfirmed</string>
<!-- Dialog message shown when we can't verify the phone number on the server, only shown if there was a network error communicating with the server after a crash during the regular flow -->
<string name="ChangeNumberLockActivity__we_could_not_determine_the_status_of_your_change_number_request">We could not determine the status of your change number request.\n\n(Error: %1$s)</string> <string name="ChangeNumberLockActivity__we_could_not_determine_the_status_of_your_change_number_request">We could not determine the status of your change number request.\n\n(Error: %1$s)</string>
<!-- Dialog button to retry confirming the number on the server -->
<string name="ChangeNumberLockActivity__retry">Retry</string> <string name="ChangeNumberLockActivity__retry">Retry</string>
<!-- Dialog button shown to leave the app when in the unconfirmed change status after a crash in the regular flow -->
<string name="ChangeNumberLockActivity__leave">Leave</string> <string name="ChangeNumberLockActivity__leave">Leave</string>
<string name="ChangeNumberLockActivity__submit_debug_log">Submit debug log</string> <string name="ChangeNumberLockActivity__submit_debug_log">Submit debug log</string>