protected void onCreate()

in auth/src/main/java/com/firebase/ui/auth/ui/email/WelcomeBackPasswordPrompt.java [77:146]


    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fui_welcome_back_password_prompt_layout);

        // Show keyboard
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);

        mIdpResponse = IdpResponse.fromResultIntent(getIntent());
        String email = mIdpResponse.getEmail();

        mDoneButton = findViewById(R.id.button_done);
        mProgressBar = findViewById(R.id.top_progress_bar);
        mPasswordLayout = findViewById(R.id.password_layout);
        mPasswordField = findViewById(R.id.password);

        ImeHelper.setImeOnDoneListener(mPasswordField, this);

        // Create welcome back text with email bolded.
        String bodyText =
                getString(R.string.fui_welcome_back_password_prompt_body, email);

        SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(bodyText);
        TextHelper.boldAllOccurencesOfText(spannableStringBuilder, bodyText, email);

        TextView bodyTextView = findViewById(R.id.welcome_back_password_body);
        bodyTextView.setText(spannableStringBuilder);

        // Click listeners
        mDoneButton.setOnClickListener(this);
        findViewById(R.id.trouble_signing_in).setOnClickListener(this);

        // Initialize ViewModel with arguments
        mHandler = new ViewModelProvider(this).get(WelcomeBackPasswordHandler.class);
        mHandler.init(getFlowParams());

        // Observe the state of the main auth operation
        mHandler.getOperation().observe(this, new ResourceObserver<IdpResponse>(
                this, R.string.fui_progress_dialog_signing_in) {
            @Override
            protected void onSuccess(@NonNull IdpResponse response) {
                startSaveCredentials(
                        mHandler.getCurrentUser(), response, mHandler.getPendingPassword());
            }

            @Override
            protected void onFailure(@NonNull Exception e) {
                if (e instanceof FirebaseAuthAnonymousUpgradeException) {
                    IdpResponse response = ((FirebaseAuthAnonymousUpgradeException) e).getResponse();
                    finish(ErrorCodes.ANONYMOUS_UPGRADE_MERGE_CONFLICT, response.toIntent());
                    return;
                }

                if (e instanceof FirebaseAuthException) {
                    FirebaseAuthException authEx = (FirebaseAuthException) e;
                    FirebaseAuthError error = FirebaseAuthError.fromException(authEx);
                    if (error == FirebaseAuthError.ERROR_USER_DISABLED) {
                        IdpResponse resp = IdpResponse.from(
                                new FirebaseUiException(ErrorCodes.ERROR_USER_DISABLED));
                        finish(RESULT_CANCELED, resp.toIntent());
                        return;
                    }
                }

                mPasswordLayout.setError(getString(getErrorMessage(e)));
            }
        });

        TextView footerText = findViewById(R.id.email_footer_tos_and_pp_text);
        PrivacyDisclosureUtils.setupTermsOfServiceFooter(this, getFlowParams(), footerText);
    }