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_unblock">Unblock</string>
<string name="RecipientPreferenceActivity_enabled">Enabled</string> <string name="RecipientPreferenceActivity_enabled">Enabled</string>
<string name="RecipientPreferenceActivity_disabled">Disabled</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 --> <!-- RedPhone -->
<string name="RedPhone_answering">Answering</string> <string name="RedPhone_answering">Answering</string>

View File

@ -1026,6 +1026,8 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
public void onClick(View v) { public void onClick(View v) {
Intent intent = new Intent(ConversationActivity.this, RecipientPreferenceActivity.class); Intent intent = new Intent(ConversationActivity.this, RecipientPreferenceActivity.class);
intent.putExtra(RecipientPreferenceActivity.RECIPIENTS_EXTRA, recipients.getIds()); 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"); startActivitySceneTransition(intent, titleView.findViewById(R.id.title), "recipient_name");
} }

View File

@ -55,7 +55,8 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
{ {
private static final String TAG = RecipientPreferenceActivity.class.getSimpleName(); private static final String TAG = RecipientPreferenceActivity.class.getSimpleName();
public static final String RECIPIENTS_EXTRA = "recipient_ids"; 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_MUTED = "pref_key_recipient_mute";
private static final String PREFERENCE_TONE = "pref_key_recipient_ringtone"; private static final String PREFERENCE_TONE = "pref_key_recipient_ringtone";
@ -192,6 +193,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
private Recipients recipients; private Recipients recipients;
private BroadcastReceiver staleReceiver; private BroadcastReceiver staleReceiver;
private MasterSecret masterSecret; private MasterSecret masterSecret;
private boolean canHaveSafetyNumber;
@Override @Override
public void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
@ -200,7 +202,9 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
addPreferencesFromResource(R.xml.recipient_preferences); addPreferencesFromResource(R.xml.recipient_preferences);
initializeRecipients(); initializeRecipients();
this.masterSecret = getArguments().getParcelable("master_secret"); this.masterSecret = getArguments().getParcelable("master_secret");
this.canHaveSafetyNumber = getActivity().getIntent()
.getBooleanExtra(RecipientPreferenceActivity.CAN_HAVE_SAFETY_NUMBER_EXTRA, false);
this.findPreference(PREFERENCE_TONE) this.findPreference(PREFERENCE_TONE)
.setOnPreferenceChangeListener(new RingtoneChangeListener()); .setOnPreferenceChangeListener(new RingtoneChangeListener());
@ -299,6 +303,9 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
if (result.isPresent()) { if (result.isPresent()) {
if (identityPreference != null) identityPreference.setOnPreferenceClickListener(new IdentityClickedListener(result.get())); if (identityPreference != null) identityPreference.setOnPreferenceClickListener(new IdentityClickedListener(result.get()));
if (identityPreference != null) identityPreference.setEnabled(true); 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 { } else {
if (identityPreference != null) getPreferenceScreen().removePreference(identityPreference); if (identityPreference != null) getPreferenceScreen().removePreference(identityPreference);
} }