From f22be7262be1174a9512f11de863556e30e218fa Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Fri, 7 Jun 2019 13:27:48 +1000 Subject: [PATCH] Hook up conversation screen --- res/layout/activity_key_pair.xml | 1 - res/values/strings.xml | 4 +++- .../securesms/ApplicationPreferencesActivity.java | 2 +- .../securesms/NewConversationActivity.java | 11 ++++++++++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/res/layout/activity_key_pair.xml b/res/layout/activity_key_pair.xml index e6e9d1d2f9..ebcb2aedb6 100644 --- a/res/layout/activity_key_pair.xml +++ b/res/layout/activity_key_pair.xml @@ -51,7 +51,6 @@ android:layout_width="match_parent" android:layout_height="50dp" android:layout_marginTop="20dp" - android:layout_gravity="center_horizontal" android:background="@color/white" android:textColor="@color/signal_primary" android:text="@string/activity_key_pair_copy_button_title" diff --git a/res/values/strings.xml b/res/values/strings.xml index 5317bb89b4..74c6850295 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1534,9 +1534,11 @@ Show Seed Your Seed Copy - Cancel + OK Copied to Clipboard Search by name or public key + + Invalid Public Key diff --git a/src/org/thoughtcrime/securesms/ApplicationPreferencesActivity.java b/src/org/thoughtcrime/securesms/ApplicationPreferencesActivity.java index 0fd9345bcd..ddd0871c2a 100644 --- a/src/org/thoughtcrime/securesms/ApplicationPreferencesActivity.java +++ b/src/org/thoughtcrime/securesms/ApplicationPreferencesActivity.java @@ -305,7 +305,7 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA clipboard.setPrimaryClip(clip); Toast.makeText(getContext(), R.string.activity_settings_seed_copied_message, Toast.LENGTH_SHORT).show(); }) - .setNeutralButton(R.string.activity_settings_seed_dialog_cancel_button_title, null) + .setNeutralButton(R.string.activity_settings_seed_dialog_ok_button_title, null) .show(); break; default: diff --git a/src/org/thoughtcrime/securesms/NewConversationActivity.java b/src/org/thoughtcrime/securesms/NewConversationActivity.java index 4f44d3a73b..abe1e811a5 100644 --- a/src/org/thoughtcrime/securesms/NewConversationActivity.java +++ b/src/org/thoughtcrime/securesms/NewConversationActivity.java @@ -19,12 +19,14 @@ package org.thoughtcrime.securesms; import android.content.Intent; import android.os.Bundle; import android.view.MenuItem; +import android.widget.Toast; import org.thoughtcrime.securesms.conversation.ConversationActivity; import org.thoughtcrime.securesms.database.Address; import org.thoughtcrime.securesms.database.DatabaseFactory; import org.thoughtcrime.securesms.database.ThreadDatabase; import org.thoughtcrime.securesms.recipients.Recipient; +import org.whispersystems.signalservice.loki.utilities.PublicKeyValidation; /** * Activity container for starting a new conversation. @@ -46,7 +48,14 @@ public class NewConversationActivity extends ContactSelectionActivity { @Override public void onContactSelected(String number) { - Recipient recipient = Recipient.from(this, Address.fromExternal(this, number), true); + boolean isValid = PublicKeyValidation.isValid(number); + + if (!isValid) { + Toast.makeText(this, R.string.activity_new_conversation_invalid_public_key_message, Toast.LENGTH_SHORT).show(); + return; + } + + Recipient recipient = Recipient.from(this, Address.fromSerialized(number), true); Intent intent = new Intent(this, ConversationActivity.class); intent.putExtra(ConversationActivity.ADDRESS_EXTRA, recipient.getAddress());