use of org.thoughtcrime.securesms.contactshare.SimpleTextWatcher in project Signal-Android by WhisperSystems.
the class EditProxyFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
this.proxySwitch = view.findViewById(R.id.edit_proxy_switch);
this.proxyTitle = view.findViewById(R.id.edit_proxy_address_title);
this.proxyText = view.findViewById(R.id.edit_proxy_host);
this.proxyStatus = view.findViewById(R.id.edit_proxy_status);
this.saveButton = view.findViewById(R.id.edit_proxy_save);
this.shareButton = view.findViewById(R.id.edit_proxy_share);
proxyText.addTextChangedListener(new SimpleTextWatcher() {
@Override
public void onTextChanged(String text) {
onProxyTextChanged(text);
}
});
this.proxyText.setText(Optional.fromNullable(SignalStore.proxy().getProxy()).transform(SignalProxy::getHost).or(""));
this.proxySwitch.setChecked(SignalStore.proxy().isProxyEnabled());
initViewModel();
saveButton.setOnClickListener(v -> onSaveClicked());
shareButton.setOnClickListener(v -> onShareClicked());
proxySwitch.setOnCheckedChangeListener((buttonView, isChecked) -> viewModel.onToggleProxy(isChecked));
LearnMoreTextView description = view.findViewById(R.id.edit_proxy_switch_title_description);
description.setLearnMoreVisible(true);
description.setOnLinkClickListener(v -> CommunicationActions.openBrowserLink(requireContext(), "https://support.signal.org/hc/articles/360056052052"));
requireActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
}
use of org.thoughtcrime.securesms.contactshare.SimpleTextWatcher in project Signal-Android by WhisperSystems.
the class SignalPinReminderDialog method show.
public static void show(@NonNull Context context, @NonNull Launcher launcher, @NonNull Callback mainCallback) {
if (!SignalStore.kbsValues().hasPin()) {
throw new AssertionError("Must have a PIN!");
}
Log.i(TAG, "Showing PIN reminder dialog.");
AlertDialog dialog = new AlertDialog.Builder(context, ThemeUtil.isDarkTheme(context) ? R.style.Theme_Signal_AlertDialog_Dark_Cornered_ColoredAccent : R.style.Theme_Signal_AlertDialog_Light_Cornered_ColoredAccent).setView(R.layout.kbs_pin_reminder_view).setCancelable(false).setOnCancelListener(d -> RegistrationLockReminders.scheduleReminder(context, false)).create();
WindowManager windowManager = ServiceUtil.getWindowManager(context);
Display display = windowManager.getDefaultDisplay();
DisplayMetrics metrics = new DisplayMetrics();
display.getMetrics(metrics);
dialog.show();
dialog.getWindow().setLayout((int) (metrics.widthPixels * .80), ViewGroup.LayoutParams.WRAP_CONTENT);
EditText pinEditText = (EditText) DialogCompat.requireViewById(dialog, R.id.pin);
TextView pinStatus = (TextView) DialogCompat.requireViewById(dialog, R.id.pin_status);
TextView reminder = (TextView) DialogCompat.requireViewById(dialog, R.id.reminder);
View skip = DialogCompat.requireViewById(dialog, R.id.skip);
View submit = DialogCompat.requireViewById(dialog, R.id.submit);
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));
ViewUtil.focusAndShowKeyboard(pinEditText);
ViewCompat.setAutofillHints(pinEditText, HintConstants.AUTOFILL_HINT_PASSWORD);
switch(SignalStore.pinValues().getKeyboardType()) {
case NUMERIC:
pinEditText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD);
break;
case ALPHA_NUMERIC:
pinEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
break;
}
ClickableSpan clickableSpan = new ClickableSpan() {
@Override
public void onClick(@NonNull View widget) {
dialog.dismiss();
launcher.launch(CreateKbsPinActivity.getIntentForPinChangeFromForgotPin(context), CreateKbsPinActivity.REQUEST_NEW_PIN);
}
};
forgotText.setSpan(clickableSpan, 0, forgotText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
reminder.setText(new SpannableStringBuilder(reminderText).append(" ").append(forgotText));
reminder.setMovementMethod(LinkMovementMethod.getInstance());
PinVerifier.Callback callback = getPinWatcherCallback(context, dialog, pinEditText, pinStatus, mainCallback);
PinVerifier verifier = new V2PinVerifier();
skip.setOnClickListener(v -> {
dialog.dismiss();
mainCallback.onReminderDismissed(callback.hadWrongGuess());
});
submit.setEnabled(false);
submit.setOnClickListener(v -> {
Editable pinEditable = pinEditText.getText();
verifier.verifyPin(pinEditable == null ? null : pinEditable.toString(), callback);
});
pinEditText.addTextChangedListener(new SimpleTextWatcher() {
private final String localHash = Objects.requireNonNull(SignalStore.kbsValues().getLocalPinHash());
@Override
public void onTextChanged(String text) {
if (text.length() >= KbsConstants.MINIMUM_PIN_LENGTH) {
submit.setEnabled(true);
if (PinHashing.verifyLocalPinHash(localHash, text)) {
dialog.dismiss();
mainCallback.onReminderCompleted(text, callback.hadWrongGuess());
}
} else {
submit.setEnabled(false);
}
}
});
}
use of org.thoughtcrime.securesms.contactshare.SimpleTextWatcher in project Signal-Android by WhisperSystems.
the class UsernameEditFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
usernameInput = view.findViewById(R.id.username_text);
usernameSubtext = view.findViewById(R.id.username_subtext);
submitButton = view.findViewById(R.id.username_submit_button);
deleteButton = view.findViewById(R.id.username_delete_button);
view.<Toolbar>findViewById(R.id.toolbar).setNavigationOnClickListener(v -> Navigation.findNavController(view).popBackStack());
viewModel = ViewModelProviders.of(this, new UsernameEditViewModel.Factory()).get(UsernameEditViewModel.class);
viewModel.getUiState().observe(getViewLifecycleOwner(), this::onUiStateChanged);
viewModel.getEvents().observe(getViewLifecycleOwner(), this::onEvent);
submitButton.setOnClickListener(v -> viewModel.onUsernameSubmitted(usernameInput.getText().toString()));
deleteButton.setOnClickListener(v -> viewModel.onUsernameDeleted());
usernameInput.setText(Recipient.self().getUsername().orNull());
usernameInput.addTextChangedListener(new SimpleTextWatcher() {
@Override
public void onTextChanged(String text) {
viewModel.onUsernameUpdated(text);
}
});
usernameInput.setOnEditorActionListener((v, actionId, event) -> {
if (actionId == EditorInfo.IME_ACTION_DONE) {
viewModel.onUsernameSubmitted(usernameInput.getText().toString());
return true;
}
return false;
});
}
Aggregations