Search in sources :

Example 11 with AfterTextChanged

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();
        }
    });
}
Also used : EditText(android.widget.EditText) AlertDialog(androidx.appcompat.app.AlertDialog) RequiresApi(androidx.annotation.RequiresApi) SignalStore(org.thoughtcrime.securesms.keyvalue.SignalStore) Context(android.content.Context) AlertDialog(androidx.appcompat.app.AlertDialog) Util(org.thoughtcrime.securesms.util.Util) NonNull(androidx.annotation.NonNull) Uri(android.net.Uri) Intent(android.content.Intent) R(org.thoughtcrime.securesms.R) LocalBackupListener(org.thoughtcrime.securesms.service.LocalBackupListener) ClipData(android.content.ClipData) TextSecurePreferences(org.thoughtcrime.securesms.util.TextSecurePreferences) CheckBox(android.widget.CheckBox) Toast(android.widget.Toast) Fragment(androidx.fragment.app.Fragment) ClipboardManager(android.content.ClipboardManager) View(android.view.View) Button(android.widget.Button) Build(android.os.Build) LayoutInflater(android.view.LayoutInflater) RestoreBackupFragment(org.thoughtcrime.securesms.registration.fragments.RestoreBackupFragment) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged) BackupUtil(org.thoughtcrime.securesms.util.BackupUtil) Log(org.signal.core.util.logging.Log) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) ActivityNotFoundException(android.content.ActivityNotFoundException) DocumentsContract(android.provider.DocumentsContract) EditText(android.widget.EditText) Button(android.widget.Button) RestoreBackupFragment(org.thoughtcrime.securesms.registration.fragments.RestoreBackupFragment) View(android.view.View) TextView(android.widget.TextView) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged)

Example 12 with AfterTextChanged

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());
    }
}
Also used : Context(android.content.Context) SignalDatabase(org.thoughtcrime.securesms.database.SignalDatabase) Bundle(android.os.Bundle) AlertDialog(androidx.appcompat.app.AlertDialog) MessageSender(org.thoughtcrime.securesms.sms.MessageSender) Util(org.thoughtcrime.securesms.util.Util) SelectionLimits(org.thoughtcrime.securesms.groups.SelectionLimits) AnimRes(androidx.annotation.AnimRes) FastOutSlowInInterpolator(androidx.interpolator.view.animation.FastOutSlowInInterpolator) Intent(android.content.Intent) ViewUtil(org.thoughtcrime.securesms.util.ViewUtil) ProgressDialogAsyncTask(org.thoughtcrime.securesms.util.task.ProgressDialogAsyncTask) AnimationUtils(android.view.animation.AnimationUtils) DynamicTheme(org.thoughtcrime.securesms.util.DynamicTheme) SuppressLint(android.annotation.SuppressLint) RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) DynamicNoActionBarInviteTheme(org.thoughtcrime.securesms.util.DynamicNoActionBarInviteTheme) Toast(android.widget.Toast) View(android.view.View) Button(android.widget.Button) Recipient(org.thoughtcrime.securesms.recipients.Recipient) Animation(android.view.animation.Animation) OutgoingTextMessage(org.thoughtcrime.securesms.sms.OutgoingTextMessage) ContactFilterView(org.thoughtcrime.securesms.components.ContactFilterView) AsyncTask(android.os.AsyncTask) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged) ViewGroup(android.view.ViewGroup) OnFilterChangedListener(org.thoughtcrime.securesms.components.ContactFilterView.OnFilterChangedListener) Optional(org.whispersystems.libsignal.util.guava.Optional) ExecutionException(java.util.concurrent.ExecutionException) Consumer(java.util.function.Consumer) TextView(android.widget.TextView) SelectedContact(org.thoughtcrime.securesms.contacts.SelectedContact) Toolbar(androidx.appcompat.widget.Toolbar) Listener(org.thoughtcrime.securesms.util.concurrent.ListenableFuture.Listener) EditText(android.widget.EditText) OnClickListener(android.view.View.OnClickListener) DisplayMode(org.thoughtcrime.securesms.contacts.ContactsCursorLoader.DisplayMode) Button(android.widget.Button) ContactFilterView(org.thoughtcrime.securesms.components.ContactFilterView) TextView(android.widget.TextView) View(android.view.View) ContactFilterView(org.thoughtcrime.securesms.components.ContactFilterView) TextView(android.widget.TextView) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged)

Example 13 with AfterTextChanged

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;
    });
}
Also used : LabeledEditText(org.thoughtcrime.securesms.components.LabeledEditText) EditText(android.widget.EditText) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged)

Example 14 with AfterTextChanged

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);
}
Also used : Spinner(android.widget.Spinner) View(android.view.View) TextView(android.widget.TextView) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged) ViewModelProvider(androidx.lifecycle.ViewModelProvider)

Example 15 with AfterTextChanged

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));
}
Also used : EditText(android.widget.EditText) RecyclerView(androidx.recyclerview.widget.RecyclerView) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged) Toolbar(androidx.appcompat.widget.Toolbar)

Aggregations

AfterTextChanged (org.thoughtcrime.securesms.util.text.AfterTextChanged)15 View (android.view.View)13 EditText (android.widget.EditText)12 Bundle (android.os.Bundle)11 NonNull (androidx.annotation.NonNull)11 Toolbar (androidx.appcompat.widget.Toolbar)11 R (org.thoughtcrime.securesms.R)11 Nullable (androidx.annotation.Nullable)10 TextView (android.widget.TextView)9 Toast (android.widget.Toast)8 ViewModelProviders (androidx.lifecycle.ViewModelProviders)8 Intent (android.content.Intent)7 LayoutInflater (android.view.LayoutInflater)7 ViewGroup (android.view.ViewGroup)7 Navigation (androidx.navigation.Navigation)7 Fragment (androidx.fragment.app.Fragment)6 CircularProgressButton (com.dd.CircularProgressButton)6 ViewUtil (org.thoughtcrime.securesms.util.ViewUtil)6 Context (android.content.Context)5 Recipient (org.thoughtcrime.securesms.recipients.Recipient)5