Skip to content

Commit

Permalink
Auto-show keyboard for PIN entry.
Browse files Browse the repository at this point in the history
  • Loading branch information
greyson-signal committed Feb 5, 2020
1 parent 6b1e48e commit a1f0c19
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ private static void showReminder(@NonNull Context context, @NonNull Fragment fra
DisplayMetrics metrics = new DisplayMetrics();
display.getMetrics(metrics);

dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
dialog.show();
dialog.getWindow().setLayout((int)(metrics.widthPixels * .80), ViewGroup.LayoutParams.WRAP_CONTENT);

Expand All @@ -108,7 +107,11 @@ private static void showReminder(@NonNull Context context, @NonNull Fragment fra
SpannableString reminderText = new SpannableString(context.getString(R.string.KbsReminderDialog__to_help_you_memorize_your_pin));
SpannableString forgotText = new SpannableString(context.getString(R.string.KbsReminderDialog__forgot_pin));

pinEditText.requestFocus();
pinEditText.post(() -> {
if (pinEditText.requestFocus()) {
ServiceUtil.getInputMethodManager(pinEditText.getContext()).showSoftInput(pinEditText, 0);
}
});

switch (SignalStore.kbsValues().getKeyboardType()) {
case NUMERIC:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.TextView;
Expand All @@ -26,6 +27,7 @@
import org.thoughtcrime.securesms.registration.service.CodeVerificationRequest;
import org.thoughtcrime.securesms.registration.service.RegistrationService;
import org.thoughtcrime.securesms.registration.viewmodel.RegistrationViewModel;
import org.thoughtcrime.securesms.util.ServiceUtil;
import org.whispersystems.signalservice.internal.contacts.entities.TokenResponse;

import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -76,6 +78,11 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
return false;
});

pinEntry.setFocusable(true);
if (pinEntry.requestFocus()) {
ServiceUtil.getInputMethodManager(pinEntry.getContext()).showSoftInput(pinEntry, 0);
}

pinButton.setOnClickListener((v) -> {
hideKeyboard(requireContext(), pinEntry);
handlePinEntry();
Expand Down

0 comments on commit a1f0c19

Please sign in to comment.