use of org.thoughtcrime.securesms.util.text.AfterTextChanged in project Signal-Android by WhisperSystems.
the class BackupDialog method showVerifyBackupPassphraseDialog.
public static void showVerifyBackupPassphraseDialog(@NonNull Context context) {
View view = LayoutInflater.from(context).inflate(R.layout.enter_backup_passphrase_dialog, null);
EditText prompt = view.findViewById(R.id.restore_passphrase_input);
AlertDialog dialog = new AlertDialog.Builder(context).setTitle(R.string.BackupDialog_enter_backup_passphrase_to_verify).setView(view).setPositiveButton(R.string.BackupDialog_verify, null).setNegativeButton(android.R.string.cancel, null).show();
Button positiveButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
positiveButton.setEnabled(false);
RestoreBackupFragment.PassphraseAsYouTypeFormatter formatter = new RestoreBackupFragment.PassphraseAsYouTypeFormatter();
prompt.addTextChangedListener(new AfterTextChanged(editable -> {
formatter.afterTextChanged(editable);
positiveButton.setEnabled(editable.length() == BackupUtil.PASSPHRASE_LENGTH);
}));
positiveButton.setOnClickListener(v -> {
String passphrase = prompt.getText().toString();
if (passphrase.equals(BackupPassphrase.get(context))) {
Toast.makeText(context, R.string.BackupDialog_you_successfully_entered_your_backup_passphrase, Toast.LENGTH_SHORT).show();
dialog.dismiss();
} else {
Toast.makeText(context, R.string.BackupDialog_passphrase_was_not_correct, Toast.LENGTH_SHORT).show();
}
});
}
use of org.thoughtcrime.securesms.util.text.AfterTextChanged in project Signal-Android by WhisperSystems.
the class InviteActivity method initializeResources.
private void initializeResources() {
slideInAnimation = loadAnimation(R.anim.slide_from_bottom);
slideOutAnimation = loadAnimation(R.anim.slide_to_bottom);
View shareButton = findViewById(R.id.share_button);
TextView shareText = findViewById(R.id.share_text);
View smsButton = findViewById(R.id.sms_button);
Button smsCancelButton = findViewById(R.id.cancel_sms_button);
ContactFilterView contactFilter = findViewById(R.id.contact_filter_edit_text);
inviteText = findViewById(R.id.invite_text);
smsSendFrame = findViewById(R.id.sms_send_frame);
smsSendButton = findViewById(R.id.send_sms_button);
contactsFragment = (ContactSelectionListFragment) getSupportFragmentManager().findFragmentById(R.id.contact_selection_list_fragment);
inviteText.setText(getString(R.string.InviteActivity_lets_switch_to_signal, getString(R.string.install_url)));
inviteText.addTextChangedListener(new AfterTextChanged(editable -> {
boolean isEnabled = editable.length() > 0;
smsButton.setEnabled(isEnabled);
shareButton.setEnabled(isEnabled);
smsButton.animate().alpha(isEnabled ? 1f : 0.5f);
shareButton.animate().alpha(isEnabled ? 1f : 0.5f);
}));
updateSmsButtonText(contactsFragment.getSelectedContacts().size());
smsCancelButton.setOnClickListener(new SmsCancelClickListener());
smsSendButton.setOnClickListener(new SmsSendClickListener());
contactFilter.setOnFilterChangedListener(new ContactFilterChangedListener());
if (Util.isDefaultSmsProvider(this)) {
shareButton.setOnClickListener(new ShareClickListener());
smsButton.setOnClickListener(new SmsClickListener());
} else {
smsButton.setVisibility(View.GONE);
shareText.setText(R.string.InviteActivity_share);
shareButton.setOnClickListener(new ShareClickListener());
}
}
use of org.thoughtcrime.securesms.util.text.AfterTextChanged in project Signal-Android by WhisperSystems.
the class DeleteAccountFragment method initializeNumberInput.
private void initializeNumberInput() {
EditText numberInput = number.getInput();
Long nationalNumber = viewModel.getNationalNumber();
if (nationalNumber != null) {
number.setText(String.valueOf(nationalNumber));
} else {
number.setText("");
}
numberInput.addTextChangedListener(new AfterTextChanged(this::afterNumberChanged));
numberInput.setImeOptions(EditorInfo.IME_ACTION_DONE);
numberInput.setOnEditorActionListener((v, actionId, event) -> {
if (actionId == EditorInfo.IME_ACTION_DONE) {
ViewUtil.hideKeyboard(requireContext(), v);
viewModel.submit();
return true;
}
return false;
});
}
use of org.thoughtcrime.securesms.util.text.AfterTextChanged in project Signal-Android by WhisperSystems.
the class DeleteAccountFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
Spinner countrySpinner = view.findViewById(R.id.delete_account_fragment_country_spinner);
View confirm = view.findViewById(R.id.delete_account_fragment_delete);
bullets = view.findViewById(R.id.delete_account_fragment_bullets);
countryCode = view.findViewById(R.id.delete_account_fragment_country_code);
number = view.findViewById(R.id.delete_account_fragment_number);
viewModel = new ViewModelProvider(requireActivity(), new DeleteAccountViewModel.Factory(new DeleteAccountRepository())).get(DeleteAccountViewModel.class);
viewModel.getCountryDisplayName().observe(getViewLifecycleOwner(), this::setCountryDisplay);
viewModel.getRegionCode().observe(getViewLifecycleOwner(), this::handleRegionUpdated);
viewModel.getEvents().observe(getViewLifecycleOwner(), this::handleEvent);
viewModel.getWalletBalance().observe(getViewLifecycleOwner(), this::updateBullets);
initializeNumberInput();
countryCode.getInput().addTextChangedListener(new AfterTextChanged(this::afterCountryCodeChanged));
countryCode.getInput().setImeOptions(EditorInfo.IME_ACTION_NEXT);
confirm.setOnClickListener(unused -> viewModel.submit());
initializeSpinner(countrySpinner);
}
use of org.thoughtcrime.securesms.util.text.AfterTextChanged in project Signal-Android by WhisperSystems.
the class DeleteAccountCountryPickerFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
Toolbar toolbar = view.findViewById(R.id.delete_account_country_picker_toolbar);
EditText searchFilter = view.findViewById(R.id.delete_account_country_picker_filter);
RecyclerView recycler = view.findViewById(R.id.delete_account_country_picker_recycler);
DeleteAccountCountryPickerAdapter adapter = new DeleteAccountCountryPickerAdapter(this::onCountryPicked);
recycler.setAdapter(adapter);
toolbar.setNavigationOnClickListener(unused -> dismiss());
viewModel = ViewModelProviders.of(requireActivity()).get(DeleteAccountViewModel.class);
viewModel.getFilteredCountries().observe(getViewLifecycleOwner(), adapter::submitList);
searchFilter.addTextChangedListener(new AfterTextChanged(this::onQueryChanged));
}
Aggregations