Search in sources :

Example 6 with Nullable

use of io.reactivex.rxjava3.annotations.Nullable in project Signal-Android by signalapp.

the class BaseRegistrationLockFragment method onViewCreated.

@Override
@CallSuper
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    setDebugLogSubmitMultiTapView(view.findViewById(R.id.kbs_lock_pin_title));
    pinEntry = view.findViewById(R.id.kbs_lock_pin_input);
    pinButton = view.findViewById(R.id.kbs_lock_pin_confirm);
    errorLabel = view.findViewById(R.id.kbs_lock_pin_input_label);
    keyboardToggle = view.findViewById(R.id.kbs_lock_keyboard_toggle);
    forgotPin = view.findViewById(R.id.kbs_lock_forgot_pin);
    RegistrationLockFragmentArgs args = RegistrationLockFragmentArgs.fromBundle(requireArguments());
    timeRemaining = args.getTimeRemaining();
    forgotPin.setVisibility(View.GONE);
    forgotPin.setOnClickListener(v -> handleForgottenPin(timeRemaining));
    pinEntry.setImeOptions(EditorInfo.IME_ACTION_DONE);
    pinEntry.setOnEditorActionListener((v, actionId, event) -> {
        if (actionId == EditorInfo.IME_ACTION_DONE) {
            ViewUtil.hideKeyboard(requireContext(), v);
            handlePinEntry();
            return true;
        }
        return false;
    });
    enableAndFocusPinEntry();
    pinButton.setOnClickListener((v) -> {
        ViewUtil.hideKeyboard(requireContext(), pinEntry);
        handlePinEntry();
    });
    keyboardToggle.setOnClickListener((v) -> {
        PinKeyboardType keyboardType = getPinEntryKeyboardType();
        updateKeyboard(keyboardType.getOther());
        keyboardToggle.setText(resolveKeyboardToggleText(keyboardType));
    });
    PinKeyboardType keyboardType = getPinEntryKeyboardType().getOther();
    keyboardToggle.setText(resolveKeyboardToggleText(keyboardType));
    disposables.bindTo(getViewLifecycleOwner().getLifecycle());
    viewModel = getViewModel();
    viewModel.getLockedTimeRemaining().observe(getViewLifecycleOwner(), t -> timeRemaining = t);
    TokenData keyBackupCurrentToken = viewModel.getKeyBackupCurrentToken();
    if (keyBackupCurrentToken != null) {
        int triesRemaining = keyBackupCurrentToken.getTriesRemaining();
        if (triesRemaining <= 3) {
            int daysRemaining = getLockoutDays(timeRemaining);
            new MaterialAlertDialogBuilder(requireContext()).setTitle(R.string.RegistrationLockFragment__not_many_tries_left).setMessage(getTriesRemainingDialogMessage(triesRemaining, daysRemaining)).setPositiveButton(android.R.string.ok, null).setNeutralButton(R.string.PinRestoreEntryFragment_contact_support, (dialog, which) -> sendEmailToSupport()).show();
        }
        if (triesRemaining < 5) {
            errorLabel.setText(requireContext().getResources().getQuantityString(R.plurals.RegistrationLockFragment__d_attempts_remaining, triesRemaining, triesRemaining));
        }
    }
}
Also used : CircularProgressButtonUtil.setSpinning(org.thoughtcrime.securesms.util.CircularProgressButtonUtil.setSpinning) Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) LifecycleDisposable(org.thoughtcrime.securesms.util.LifecycleDisposable) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) ViewUtil(org.thoughtcrime.securesms.util.ViewUtil) R(org.thoughtcrime.securesms.R) Toast(android.widget.Toast) View(android.view.View) ServiceUtil(org.thoughtcrime.securesms.util.ServiceUtil) CircularProgressButton(com.dd.CircularProgressButton) CircularProgressButtonUtil.cancelSpinning(org.thoughtcrime.securesms.util.CircularProgressButtonUtil.cancelSpinning) PinKeyboardType(org.thoughtcrime.securesms.lock.v2.PinKeyboardType) RegistrationViewDelegate.setDebugLogSubmitMultiTapView(org.thoughtcrime.securesms.registration.fragments.RegistrationViewDelegate.setDebugLogSubmitMultiTapView) InputType(android.text.InputType) BaseRegistrationViewModel(org.thoughtcrime.securesms.registration.viewmodel.BaseRegistrationViewModel) CallSuper(androidx.annotation.CallSuper) TokenData(org.thoughtcrime.securesms.pin.TokenData) TimeUnit(java.util.concurrent.TimeUnit) Log(org.signal.core.util.logging.Log) AndroidSchedulers(io.reactivex.rxjava3.android.schedulers.AndroidSchedulers) StringRes(androidx.annotation.StringRes) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) Disposable(io.reactivex.rxjava3.disposables.Disposable) LoggingFragment(org.thoughtcrime.securesms.LoggingFragment) EditorInfo(android.view.inputmethod.EditorInfo) EditText(android.widget.EditText) Resources(android.content.res.Resources) PinKeyboardType(org.thoughtcrime.securesms.lock.v2.PinKeyboardType) TokenData(org.thoughtcrime.securesms.pin.TokenData) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) CallSuper(androidx.annotation.CallSuper)

Aggregations

NonNull (androidx.annotation.NonNull)4 Nullable (androidx.annotation.Nullable)4 TimeUnit (java.util.concurrent.TimeUnit)4 Bundle (android.os.Bundle)3 View (android.view.View)3 AndroidSchedulers (io.reactivex.rxjava3.android.schedulers.AndroidSchedulers)3 Disposable (io.reactivex.rxjava3.disposables.Disposable)3 Context (android.content.Context)2 Resources (android.content.res.Resources)2 InputType (android.text.InputType)2 Log (android.util.Log)2 EditorInfo (android.view.inputmethod.EditorInfo)2 EditText (android.widget.EditText)2 TextView (android.widget.TextView)2 Toast (android.widget.Toast)2 CallSuper (androidx.annotation.CallSuper)2 CompositeDisposable (io.reactivex.rxjava3.disposables.CompositeDisposable)2 List (java.util.List)2 Activity (android.app.Activity)1 ComponentName (android.content.ComponentName)1