Search in sources :

Example 1 with TextInputLayout

use of com.google.android.material.textfield.TextInputLayout in project android by owncloud.

the class ReceiveExternalFilesActivity method showUploadTextDialog.

/**
 * Show a dialog where the user can enter a filename for the file he wants to place the text in.
 */
private void showUploadTextDialog() {
    final AlertDialog.Builder builder = new Builder(this);
    final View dialogView = getLayoutInflater().inflate(R.layout.dialog_upload_text, null);
    builder.setView(dialogView);
    builder.setTitle(R.string.uploader_upload_text_dialog_title);
    builder.setCancelable(false);
    builder.setPositiveButton(R.string.uploader_btn_upload_text, null);
    builder.setNegativeButton(android.R.string.cancel, null);
    final TextInputEditText input = dialogView.findViewById(R.id.inputFileName);
    final TextInputLayout inputLayout = dialogView.findViewById(R.id.inputTextLayout);
    input.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            inputLayout.setError(null);
            inputLayout.setErrorEnabled(false);
        }
    });
    final AlertDialog alertDialog = builder.create();
    setFileNameFromIntent(alertDialog, input);
    alertDialog.setOnShowListener(dialog -> {
        Button button = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
        button.setOnClickListener(view -> {
            String fileName = input.getText().toString();
            String error = null;
            if (fileName.length() > MAX_FILENAME_LENGTH) {
                error = String.format(getString(R.string.uploader_upload_text_dialog_filename_error_length_max), MAX_FILENAME_LENGTH);
            } else if (fileName.length() == 0) {
                error = getString(R.string.uploader_upload_text_dialog_filename_error_empty);
            } else {
                fileName += ".txt";
                Uri fileUri = savePlainTextToFile(fileName);
                mStreamsToUpload.clear();
                mStreamsToUpload.add(fileUri);
                uploadFiles();
            }
            inputLayout.setErrorEnabled(error != null);
            inputLayout.setError(error);
        });
    });
    alertDialog.show();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Builder(androidx.appcompat.app.AlertDialog.Builder) Builder(androidx.appcompat.app.AlertDialog.Builder) View(android.view.View) AdapterView(android.widget.AdapterView) SearchView(androidx.appcompat.widget.SearchView) TextView(android.widget.TextView) ListView(android.widget.ListView) SortOptionsView(com.owncloud.android.presentation.ui.files.SortOptionsView) Uri(android.net.Uri) Button(android.widget.Button) TextInputEditText(com.google.android.material.textfield.TextInputEditText) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) TextInputLayout(com.google.android.material.textfield.TextInputLayout)

Example 2 with TextInputLayout

use of com.google.android.material.textfield.TextInputLayout in project OneSignal-Android-SDK by OneSignal.

the class Dialog method createSendOutcomeAlertDialog.

public void createSendOutcomeAlertDialog(final String content) {
    final View sendOutcomeAlertDialogView = layoutInflater.inflate(R.layout.send_outcome_alert_dialog_layout, null, false);
    final CardView sendOutcomeDialogTitleCardView = sendOutcomeAlertDialogView.findViewById(R.id.send_outcome_alert_dialog_selection_card_view);
    final RelativeLayout sendOutcomeDialogTitleRelativeLayout = sendOutcomeAlertDialogView.findViewById(R.id.send_outcome_alert_dialog_selection_relative_layout);
    final TextView sendOutcomeDialogTitleTextView = sendOutcomeAlertDialogView.findViewById(R.id.send_outcome_alert_dialog_selection_text_view);
    final ImageView sendOutcomeDialogTitleArrowImageView = sendOutcomeAlertDialogView.findViewById(R.id.send_outcome_alert_dialog_selection_arrow_image_view);
    final RecyclerView sendOutcomeDialogSelectionRecyclerView = sendOutcomeAlertDialogView.findViewById(R.id.send_outcome_alert_dialog_selection_recycler_view);
    final LinearLayout sendOutcomeDialogSelectionContentLinearLayout = sendOutcomeAlertDialogView.findViewById(R.id.send_outcome_alert_dialog_content_linear_layout);
    final TextInputLayout sendOutcomeDialogNameTextInputLayout = sendOutcomeAlertDialogView.findViewById(R.id.send_outcome_alert_dialog_name_text_input_layout);
    final EditText sendOutcomeDialogNameEditText = sendOutcomeAlertDialogView.findViewById(R.id.send_outcome_alert_dialog_name_edit_text);
    final TextInputLayout sendOutcomeDialogValueTextInputLayout = sendOutcomeAlertDialogView.findViewById(R.id.send_outcome_alert_dialog_value_text_input_layout);
    final EditText sendOutcomeDialogValueEditText = sendOutcomeAlertDialogView.findViewById(R.id.send_outcome_alert_dialog_value_edit_text);
    final ProgressBar sendOutcomeDialogProgressBar = sendOutcomeAlertDialogView.findViewById(R.id.send_outcome_alert_dialog_progress_bar);
    sendOutcomeDialogNameTextInputLayout.setHint("Name");
    sendOutcomeDialogValueTextInputLayout.setHint("Value");
    sendOutcomeDialogTitleTextView.setText(content);
    font.applyFont(sendOutcomeDialogTitleTextView, font.saralaBold);
    font.applyFont(sendOutcomeDialogNameTextInputLayout, font.saralaBold);
    font.applyFont(sendOutcomeDialogValueTextInputLayout, font.saralaBold);
    sendOutcomeDialogTitleCardView.setCardElevation(8f);
    recyclerViewBuilder.setupRecyclerView(sendOutcomeDialogSelectionRecyclerView, 3, false, true);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context);
    sendOutcomeDialogSelectionRecyclerView.setLayoutManager(linearLayoutManager);
    EnumSelectionRecyclerViewAdapter enumSelectionRecyclerViewAdapter = new EnumSelectionRecyclerViewAdapter(context, OutcomeEvent.values(), new EnumSelectionCallback() {

        @Override
        public void onSelection(String title) {
            int nameVisibility = View.GONE;
            int valueVisibility = View.GONE;
            OutcomeEvent outcomeEvent = OutcomeEvent.enumFromTitleString(title);
            if (outcomeEvent == null) {
                Drawable arrow = context.getResources().getDrawable(R.drawable.ic_chevron_down_white_48dp);
                sendOutcomeDialogTitleArrowImageView.setImageDrawable(arrow);
                sendOutcomeDialogTitleCardView.setCardElevation(0f);
                sendOutcomeDialogSelectionRecyclerView.setVisibility(View.GONE);
                sendOutcomeDialogSelectionContentLinearLayout.setVisibility(View.GONE);
                sendOutcomeDialogNameEditText.setVisibility(nameVisibility);
                sendOutcomeDialogValueTextInputLayout.setVisibility(valueVisibility);
                return;
            }
            switch(outcomeEvent) {
                case OUTCOME:
                case UNIQUE_OUTCOME:
                    nameVisibility = View.VISIBLE;
                    break;
                case OUTCOME_WITH_VALUE:
                    nameVisibility = View.VISIBLE;
                    valueVisibility = View.VISIBLE;
                    break;
            }
            sendOutcomeDialogTitleTextView.setText(outcomeEvent.getTitle());
            Drawable arrow = context.getResources().getDrawable(R.drawable.ic_chevron_down_white_48dp);
            sendOutcomeDialogTitleArrowImageView.setImageDrawable(arrow);
            sendOutcomeDialogTitleCardView.setCardElevation(0f);
            sendOutcomeDialogSelectionRecyclerView.setVisibility(View.GONE);
            sendOutcomeDialogSelectionContentLinearLayout.setVisibility(View.VISIBLE);
            sendOutcomeDialogNameTextInputLayout.setVisibility(nameVisibility);
            sendOutcomeDialogNameEditText.setVisibility(nameVisibility);
            sendOutcomeDialogValueTextInputLayout.setVisibility(valueVisibility);
            sendOutcomeDialogValueEditText.setVisibility(valueVisibility);
        }
    });
    sendOutcomeDialogSelectionRecyclerView.setAdapter(enumSelectionRecyclerViewAdapter);
    sendOutcomeDialogTitleRelativeLayout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean showMenu = sendOutcomeDialogSelectionRecyclerView.getVisibility() == View.GONE;
            Drawable arrow = context.getResources().getDrawable(showMenu ? R.drawable.ic_chevron_up_white_48dp : R.drawable.ic_chevron_down_white_48dp);
            int menuVisibility = showMenu ? View.VISIBLE : View.GONE;
            int contentVisibility = showMenu ? View.GONE : View.VISIBLE;
            float shadow = showMenu ? 8f : 0f;
            sendOutcomeDialogTitleArrowImageView.setImageDrawable(arrow);
            sendOutcomeDialogTitleCardView.setCardElevation(shadow);
            sendOutcomeDialogSelectionRecyclerView.setVisibility(menuVisibility);
            sendOutcomeDialogSelectionContentLinearLayout.setVisibility(contentVisibility);
            int nameVisibility = View.GONE;
            int valueVisibility = View.GONE;
            String selectedTitle = sendOutcomeDialogTitleTextView.getText().toString();
            OutcomeEvent outcomeEvent = OutcomeEvent.enumFromTitleString(selectedTitle);
            if (outcomeEvent == null) {
                sendOutcomeDialogSelectionContentLinearLayout.setVisibility(View.GONE);
                return;
            }
            if (!showMenu) {
                switch(outcomeEvent) {
                    case OUTCOME:
                    case UNIQUE_OUTCOME:
                        nameVisibility = View.VISIBLE;
                        break;
                    case OUTCOME_WITH_VALUE:
                        nameVisibility = View.VISIBLE;
                        valueVisibility = View.VISIBLE;
                        break;
                }
            }
            sendOutcomeDialogSelectionContentLinearLayout.setVisibility(nameVisibility);
            sendOutcomeDialogNameEditText.setVisibility(nameVisibility);
            sendOutcomeDialogValueTextInputLayout.setVisibility(valueVisibility);
            sendOutcomeDialogValueEditText.setVisibility(valueVisibility);
        }
    });
    final CustomAlertDialogBuilder sendOutcomeAlertDialog = new CustomAlertDialogBuilder(context, sendOutcomeAlertDialogView);
    sendOutcomeAlertDialog.setView(sendOutcomeAlertDialogView);
    sendOutcomeAlertDialog.setIsCancelable(true);
    sendOutcomeAlertDialog.setCanceledOnTouchOutside(false);
    sendOutcomeAlertDialog.setPositiveButton(Text.BUTTON_SEND, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(final DialogInterface dialog, int which) {
            toggleUpdateAlertDialogAttributes(true);
            String selectedTitle = sendOutcomeDialogTitleTextView.getText().toString();
            OutcomeEvent outcomeEvent = OutcomeEvent.enumFromTitleString(selectedTitle);
            if (outcomeEvent == null) {
                toaster.makeCustomViewToast("Please select an outcome type!", ToastType.ERROR);
                toggleUpdateAlertDialogAttributes(false);
                return;
            }
            String name = sendOutcomeDialogNameEditText.getText().toString().trim();
            String value = sendOutcomeDialogValueEditText.getText().toString().trim();
            if (name.isEmpty()) {
                toaster.makeCustomViewToast("Please enter an outcome name!", ToastType.ERROR);
                toggleUpdateAlertDialogAttributes(false);
                return;
            }
            switch(outcomeEvent) {
                case OUTCOME:
                    OneSignal.sendOutcome(name, new OneSignal.OutcomeCallback() {

                        @Override
                        public void onSuccess(@Nullable OSOutcomeEvent outcomeEvent) {
                            ((Activity) context).runOnUiThread(new Runnable() {

                                @Override
                                public void run() {
                                    toggleUpdateAlertDialogAttributes(false);
                                    dialog.dismiss();
                                }
                            });
                        }
                    });
                    break;
                case UNIQUE_OUTCOME:
                    OneSignal.sendUniqueOutcome(name, new OneSignal.OutcomeCallback() {

                        @Override
                        public void onSuccess(@Nullable OSOutcomeEvent outcomeEvent) {
                            ((Activity) context).runOnUiThread(new Runnable() {

                                @Override
                                public void run() {
                                    toggleUpdateAlertDialogAttributes(false);
                                    dialog.dismiss();
                                }
                            });
                        }
                    });
                    break;
                case OUTCOME_WITH_VALUE:
                    if (value.isEmpty()) {
                        toaster.makeCustomViewToast("Please enter an outcome value!", ToastType.ERROR);
                        toggleUpdateAlertDialogAttributes(false);
                        return;
                    }
                    OneSignal.sendOutcomeWithValue(name, Float.parseFloat(value), new OneSignal.OutcomeCallback() {

                        @Override
                        public void onSuccess(@Nullable OSOutcomeEvent outcomeEvent) {
                            ((Activity) context).runOnUiThread(new Runnable() {

                                @Override
                                public void run() {
                                    toggleUpdateAlertDialogAttributes(false);
                                    dialog.dismiss();
                                }
                            });
                        }
                    });
                    break;
            }
            InterfaceUtil.hideKeyboardFrom(context, sendOutcomeAlertDialogView);
        }

        private void toggleUpdateAlertDialogAttributes(boolean disableAttributes) {
            int progressVisibility = disableAttributes ? View.VISIBLE : View.GONE;
            sendOutcomeDialogProgressBar.setVisibility(progressVisibility);
            int buttonVisibility = disableAttributes ? View.GONE : View.VISIBLE;
            sendOutcomeAlertDialog.getPositiveButtonElement().setVisibility(buttonVisibility);
            sendOutcomeAlertDialog.getNegativeButtonElement().setVisibility(buttonVisibility);
            sendOutcomeAlertDialog.getPositiveButtonElement().setEnabled(!disableAttributes);
            sendOutcomeAlertDialog.getNegativeButtonElement().setEnabled(!disableAttributes);
            sendOutcomeAlertDialog.setIsCancelable(!disableAttributes);
        }
    }).setNegativeButton(Text.BUTTON_CANCEL, null);
    sendOutcomeAlertDialog.show();
}
Also used : OneSignal(com.onesignal.OneSignal) DialogInterface(android.content.DialogInterface) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) OutcomeEvent(com.onesignal.sdktest.type.OutcomeEvent) OSOutcomeEvent(com.onesignal.OSOutcomeEvent) TextView(android.widget.TextView) CustomAlertDialogBuilder(com.onesignal.sdktest.ui.CustomAlertDialogBuilder) ImageView(android.widget.ImageView) TextInputLayout(com.google.android.material.textfield.TextInputLayout) ProgressBar(android.widget.ProgressBar) EditText(android.widget.EditText) OSOutcomeEvent(com.onesignal.OSOutcomeEvent) CardView(androidx.cardview.widget.CardView) Drawable(android.graphics.drawable.Drawable) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) CardView(androidx.cardview.widget.CardView) TextView(android.widget.TextView) EnumSelectionCallback(com.onesignal.sdktest.callback.EnumSelectionCallback) RelativeLayout(android.widget.RelativeLayout) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayout(android.widget.LinearLayout) EnumSelectionRecyclerViewAdapter(com.onesignal.sdktest.adapter.EnumSelectionRecyclerViewAdapter)

Example 3 with TextInputLayout

use of com.google.android.material.textfield.TextInputLayout in project ETSMobile-Android2 by ApplETS.

the class BandwidthFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View v = inflater.inflate(R.layout.fragment_bandwith, container, false);
    textInputLayoutPhase = v.findViewById(R.id.text_input_layout_phase);
    editTextPhase = v.findViewById(R.id.bandwidth_editText_phase);
    phaseSpinner = v.findViewById(R.id.bandwidth_phase_spinner);
    textInputLayoutApp = v.findViewById(R.id.text_input_layout_app);
    editTextApp = v.findViewById(R.id.bandwidth_editText_app);
    textInputLayoutChambre = v.findViewById(R.id.text_input_layout_chambre);
    editTextChambre = v.findViewById(R.id.bandwidth_editText_chambre);
    // grid = v.findViewById(R.id.bandwith_grid);
    progressBar = v.findViewById(R.id.bandwidth_progress);
    progressBarTv = v.findViewById(R.id.bandwidth_progress_tv);
    loadProgressBar = v.findViewById(R.id.progressBarLoad);
    progressLayout = v.findViewById(R.id.bandwidth_progress_layout);
    chart = v.findViewById(R.id.chart);
    chart.setVisibility(View.INVISIBLE);
    progressLayout.setVisibility(View.GONE);
    SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
    phase = defaultSharedPreferences.getString(PHASE_PREF_KEY, "");
    app = defaultSharedPreferences.getString(APP_PREF_KEY, "");
    chambre = defaultSharedPreferences.getString(CHAMBRE_PREF_KEY, "");
    if (chambre.length() > 0)
        editTextChambre.setText(chambre);
    else
        editTextChambre.setText(UNE_SEULE_CHAMBRE);
    if (phase.length() > 0 && app.length() > 0) {
        editTextApp.setText(app);
        phaseSpinner.setSelection(Integer.parseInt(phase) - 1);
        getBandwidth(phase, app, chambre);
    }
    editTextPhase.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            phaseSpinner.performClick();
        }
    });
    phaseSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            int phase = position + 1;
            editTextPhase.setText(String.valueOf(phase));
            if (phase == 3) {
                displayPhase3Dialog();
            }
            verifyInputsAndGetBandwidth();
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    TextWatcher textWatcher = new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence cS, int start, int before, int count) {
        }

        @Override
        public void onTextChanged(CharSequence cS, int start, int before, int count) {
            verifyInputsAndGetBandwidth();
        }

        @Override
        public void afterTextChanged(Editable editable) {
        }
    };
    editTextApp.addTextChangedListener(textWatcher);
    editTextChambre.addTextChangedListener(textWatcher);
    OnFocusChangeListener editTextFocusChangeListener = new OnFocusChangeListener() {

        @Override
        public void onFocusChange(View view, boolean hasFocus) {
            EditText editText = (EditText) view;
            TextInputLayout textInputLayout = null;
            switch(view.getId()) {
                case R.id.bandwidth_editText_phase:
                    textInputLayout = textInputLayoutPhase;
                    break;
                case R.id.bandwidth_editText_app:
                    textInputLayout = textInputLayoutApp;
                    break;
            }
            if (textInputLayout != null) {
                if (!hasFocus && editText.getText().toString().length() == 0)
                    textInputLayout.setError(getString(R.string.error_field_required));
                else
                    textInputLayout.setError(null);
            }
        }
    };
    editTextPhase.setOnFocusChangeListener(editTextFocusChangeListener);
    editTextApp.setOnFocusChangeListener(editTextFocusChangeListener);
    return v;
}
Also used : EditText(android.widget.EditText) OnFocusChangeListener(android.view.View.OnFocusChangeListener) SharedPreferences(android.content.SharedPreferences) View(android.view.View) PieChartView(lecho.lib.hellocharts.view.PieChartView) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) AdapterView(android.widget.AdapterView) TextInputLayout(com.google.android.material.textfield.TextInputLayout)

Example 4 with TextInputLayout

use of com.google.android.material.textfield.TextInputLayout in project AntennaPod by AntennaPod.

the class GpodderAuthenticationFragment method setupHostView.

private void setupHostView(View view) {
    final Button selectHost = view.findViewById(R.id.chooseHostButton);
    final RadioGroup serverRadioGroup = view.findViewById(R.id.serverRadioGroup);
    final EditText serverUrlText = view.findViewById(R.id.serverUrlText);
    if (!GpodnetService.DEFAULT_BASE_HOST.equals(SynchronizationCredentials.getHosturl())) {
        serverUrlText.setText(SynchronizationCredentials.getHosturl());
    }
    final TextInputLayout serverUrlTextInput = view.findViewById(R.id.serverUrlTextInput);
    serverRadioGroup.setOnCheckedChangeListener((group, checkedId) -> {
        serverUrlTextInput.setVisibility(checkedId == R.id.customServerRadio ? View.VISIBLE : View.GONE);
    });
    selectHost.setOnClickListener(v -> {
        SynchronizationCredentials.clear(getContext());
        if (serverRadioGroup.getCheckedRadioButtonId() == R.id.customServerRadio) {
            SynchronizationCredentials.setHosturl(serverUrlText.getText().toString());
        } else {
            SynchronizationCredentials.setHosturl(GpodnetService.DEFAULT_BASE_HOST);
        }
        service = new GpodnetService(AntennapodHttpClient.getHttpClient(), SynchronizationCredentials.getHosturl(), SynchronizationCredentials.getDeviceID(), SynchronizationCredentials.getUsername(), SynchronizationCredentials.getPassword());
        getDialog().setTitle(SynchronizationCredentials.getHosturl());
        advance();
    });
}
Also used : EditText(android.widget.EditText) GpodnetService(de.danoeh.antennapod.net.sync.gpoddernet.GpodnetService) RadioGroup(android.widget.RadioGroup) MaterialButton(com.google.android.material.button.MaterialButton) Button(android.widget.Button) TextInputLayout(com.google.android.material.textfield.TextInputLayout)

Example 5 with TextInputLayout

use of com.google.android.material.textfield.TextInputLayout in project Signal-Android by WhisperSystems.

the class PaymentsRecoveryPhraseConfirmFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    Toolbar toolbar = view.findViewById(R.id.payments_recovery_phrase_confirm_fragment_toolbar);
    EditText word1 = view.findViewById(R.id.payments_recovery_phrase_confirm_fragment_word_1);
    EditText word2 = view.findViewById(R.id.payments_recovery_phrase_confirm_fragment_word_2);
    View seePhraseAgain = view.findViewById(R.id.payments_recovery_phrase_confirm_fragment_see_again);
    View done = view.findViewById(R.id.payments_recovery_phrase_confirm_fragment_done);
    TextInputLayout wordWrapper1 = view.findViewById(R.id.payments_recovery_phrase_confirm_fragment_word1_wrapper);
    TextInputLayout wordWrapper2 = view.findViewById(R.id.payments_recovery_phrase_confirm_fragment_word2_wrapper);
    PaymentsRecoveryPhraseConfirmFragmentArgs args = PaymentsRecoveryPhraseConfirmFragmentArgs.fromBundle(requireArguments());
    validWordCheckMark = AppCompatResources.getDrawable(requireContext(), R.drawable.ic_check_circle_24);
    invalidWordX = AppCompatResources.getDrawable(requireContext(), R.drawable.ic_circle_x_24);
    DrawableCompat.setTint(validWordCheckMark, ContextCompat.getColor(requireContext(), R.color.signal_accent_green));
    DrawableCompat.setTint(invalidWordX, ContextCompat.getColor(requireContext(), R.color.signal_alert_primary));
    PaymentsRecoveryPhraseConfirmViewModel viewModel = ViewModelProviders.of(requireActivity()).get(PaymentsRecoveryPhraseConfirmViewModel.class);
    toolbar.setNavigationOnClickListener(v -> Navigation.findNavController(requireView()).popBackStack());
    word1.addTextChangedListener(new AfterTextChanged(e -> viewModel.validateWord1(e.toString())));
    word2.addTextChangedListener(new AfterTextChanged(e -> viewModel.validateWord2(e.toString())));
    seePhraseAgain.setOnClickListener(v -> Navigation.findNavController(requireView()).popBackStack());
    done.setOnClickListener(v -> {
        SignalStore.paymentsValues().setUserConfirmedMnemonic(true);
        ViewUtil.hideKeyboard(requireContext(), view);
        Toast.makeText(requireContext(), R.string.PaymentRecoveryPhraseConfirmFragment__recovery_phrase_confirmed, Toast.LENGTH_SHORT).show();
        if (args.getFinishOnConfirm()) {
            requireActivity().setResult(Activity.RESULT_OK);
            requireActivity().finish();
        } else {
            Navigation.findNavController(view).popBackStack(R.id.paymentsHome, false);
        }
    });
    viewModel.getViewState().observe(getViewLifecycleOwner(), viewState -> {
        updateValidity(word1, viewState.isWord1Valid());
        updateValidity(word2, viewState.isWord2Valid());
        done.setEnabled(viewState.areAllWordsValid());
        String hint1 = getString(R.string.PaymentRecoveryPhraseConfirmFragment__word_d, viewState.getWord1Index() + 1);
        String hint2 = getString(R.string.PaymentRecoveryPhraseConfirmFragment__word_d, viewState.getWord2Index() + 1);
        wordWrapper1.setHint(hint1);
        wordWrapper2.setHint(hint2);
    });
    viewModel.updateRandomIndices();
}
Also used : EditText(android.widget.EditText) SignalStore(org.thoughtcrime.securesms.keyvalue.SignalStore) Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) AppCompatResources(androidx.appcompat.content.res.AppCompatResources) TextInputLayout(com.google.android.material.textfield.TextInputLayout) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged) ViewUtil(org.thoughtcrime.securesms.util.ViewUtil) DrawableCompat(androidx.core.graphics.drawable.DrawableCompat) Drawable(android.graphics.drawable.Drawable) R(org.thoughtcrime.securesms.R) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) Toast(android.widget.Toast) Fragment(androidx.fragment.app.Fragment) View(android.view.View) Toolbar(androidx.appcompat.widget.Toolbar) ViewModelProviders(androidx.lifecycle.ViewModelProviders) Navigation(androidx.navigation.Navigation) Activity(android.app.Activity) ContextCompat(androidx.core.content.ContextCompat) EditText(android.widget.EditText) TextInputLayout(com.google.android.material.textfield.TextInputLayout) TextView(android.widget.TextView) View(android.view.View) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged) Toolbar(androidx.appcompat.widget.Toolbar)

Aggregations

TextInputLayout (com.google.android.material.textfield.TextInputLayout)21 TextView (android.widget.TextView)13 View (android.view.View)12 EditText (android.widget.EditText)10 Bundle (android.os.Bundle)5 ImageView (android.widget.ImageView)5 NonNull (androidx.annotation.NonNull)5 DialogInterface (android.content.DialogInterface)4 Nullable (androidx.annotation.Nullable)4 AlertDialog (androidx.appcompat.app.AlertDialog)4 Toolbar (androidx.appcompat.widget.Toolbar)4 Fragment (androidx.fragment.app.Fragment)4 ViewModelProviders (androidx.lifecycle.ViewModelProviders)4 Navigation (androidx.navigation.Navigation)4 R (org.thoughtcrime.securesms.R)4 AfterTextChanged (org.thoughtcrime.securesms.util.text.AfterTextChanged)4 Activity (android.app.Activity)3 Drawable (android.graphics.drawable.Drawable)3 TextUtils (android.text.TextUtils)3 Button (android.widget.Button)3