diff --git a/app/src/main/java/org/thoughtcrime/securesms/PassphrasePromptActivity.java b/app/src/main/java/org/thoughtcrime/securesms/PassphrasePromptActivity.java index c4dcddbe4a..c566fbd5eb 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/PassphrasePromptActivity.java +++ b/app/src/main/java/org/thoughtcrime/securesms/PassphrasePromptActivity.java @@ -27,6 +27,7 @@ import android.text.Spanned; import android.text.style.RelativeSizeSpan; import android.text.style.TypefaceSpan; +import android.view.KeyEvent; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; @@ -152,7 +153,7 @@ private static Intent chainIntents(@NonNull Intent sourceIntent, @Nullable Inten return sourceIntent; } - private void onOkClicked(View view) { + private void unlock() { char[] passphrase = getEnteredPassphrase(passphraseInput); if (passphrase.length > 0) { setInputEnabled(false); @@ -201,6 +202,18 @@ public boolean onNotEnrolled(@NonNull CharSequence errString) { } } + private void onOkClicked(View view) { + unlock(); + } + + private boolean onEditorActionTriggered(View view, int actionId, KeyEvent event) { + if (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) { + unlock(); + return true; + } + return false; + } + private void handlePassphrase(char[] passphrase) { SetMasterSecretTask task = new SetMasterSecretTask(passphrase); task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); @@ -229,6 +242,7 @@ private void initializeResources() { hint.setSpan(new TypefaceSpan("sans-serif-light"), 0, hint.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); passphraseInput.setHint(hint); + passphraseInput.setOnEditorActionListener(this::onEditorActionTriggered); okButton.setOnClickListener(this::onOkClicked); }