Skip to content

Commit

Permalink
Add TextView.OnEditorActionListener to passphrase input
Browse files Browse the repository at this point in the history
Closes #366
  • Loading branch information
ow9t committed Sep 21, 2024
1 parent 203a59f commit b7f1e11
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit b7f1e11

Please sign in to comment.