Disable verify button if no message was exchanged

Fixes #5878
Closes #5951
// FREEBIE
This commit is contained in:
FeuRenard 2016-12-11 19:04:57 +01:00 committed by Moxie Marlinspike
parent e5fcc465c9
commit bd819d7d10
3 changed files with 12 additions and 2 deletions

View file

@ -451,6 +451,7 @@
<string name="RecipientPreferenceActivity_unblock">Unblock</string>
<string name="RecipientPreferenceActivity_enabled">Enabled</string>
<string name="RecipientPreferenceActivity_disabled">Disabled</string>
<string name="RecipientPreferenceActivity_available_once_a_message_has_been_sent_or_received">Available once a message has been sent or received.</string>
<!-- RedPhone -->
<string name="RedPhone_answering">Answering</string>

View file

@ -1026,6 +1026,8 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
public void onClick(View v) {
Intent intent = new Intent(ConversationActivity.this, RecipientPreferenceActivity.class);
intent.putExtra(RecipientPreferenceActivity.RECIPIENTS_EXTRA, recipients.getIds());
intent.putExtra(RecipientPreferenceActivity.CAN_HAVE_SAFETY_NUMBER_EXTRA,
isSecureText && !isSelfConversation());
startActivitySceneTransition(intent, titleView.findViewById(R.id.title), "recipient_name");
}

View file

@ -56,6 +56,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
private static final String TAG = RecipientPreferenceActivity.class.getSimpleName();
public static final String RECIPIENTS_EXTRA = "recipient_ids";
public static final String CAN_HAVE_SAFETY_NUMBER_EXTRA = "can_have_safety_number";
private static final String PREFERENCE_MUTED = "pref_key_recipient_mute";
private static final String PREFERENCE_TONE = "pref_key_recipient_ringtone";
@ -192,6 +193,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
private Recipients recipients;
private BroadcastReceiver staleReceiver;
private MasterSecret masterSecret;
private boolean canHaveSafetyNumber;
@Override
public void onCreate(Bundle icicle) {
@ -201,6 +203,8 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
initializeRecipients();
this.masterSecret = getArguments().getParcelable("master_secret");
this.canHaveSafetyNumber = getActivity().getIntent()
.getBooleanExtra(RecipientPreferenceActivity.CAN_HAVE_SAFETY_NUMBER_EXTRA, false);
this.findPreference(PREFERENCE_TONE)
.setOnPreferenceChangeListener(new RingtoneChangeListener());
@ -299,6 +303,9 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
if (result.isPresent()) {
if (identityPreference != null) identityPreference.setOnPreferenceClickListener(new IdentityClickedListener(result.get()));
if (identityPreference != null) identityPreference.setEnabled(true);
} else if (canHaveSafetyNumber) {
if (identityPreference != null) identityPreference.setSummary(R.string.RecipientPreferenceActivity_available_once_a_message_has_been_sent_or_received);
if (identityPreference != null) identityPreference.setEnabled(false);
} else {
if (identityPreference != null) getPreferenceScreen().removePreference(identityPreference);
}