Search in sources :

Example 1 with CreateAccountFunnel

use of org.wikipedia.analytics.CreateAccountFunnel in project apps-android-wikipedia by wikimedia.

the class CreateAccountActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_create_account);
    ButterKnife.bind(this);
    if (ReadingListSyncAdapter.isDisabledByRemoteConfig()) {
        onboardingContainer.setVisibility(View.GONE);
    }
    progressDialog = new ProgressDialog(this);
    progressDialog.setIndeterminate(true);
    progressDialog.setCancelable(false);
    progressDialog.setMessage(getString(R.string.dialog_create_account_checking_progress));
    errorView.setBackClickListener((v) -> onBackPressed());
    errorView.setRetryClickListener((v) -> errorView.setVisibility(View.GONE));
    wiki = WikipediaApp.getInstance().getWikiSite();
    createAccountInfoClient = new CreateAccountInfoClient();
    createAccountClient = new CreateAccountClient();
    captchaHandler = new CaptchaHandler(this, WikipediaApp.getInstance().getWikiSite(), progressDialog, primaryContainer, getString(R.string.create_account_activity_title), getString(R.string.create_account_button));
    // Don't allow user to submit registration unless they've put in a username and password
    new NonEmptyValidator((isValid) -> createAccountButton.setEnabled(isValid), usernameInput, passwordInput);
    // Don't allow user to continue when they're shown a captcha until they fill it in
    new NonEmptyValidator((isValid) -> createAccountButtonCaptcha.setEnabled(isValid), captchaText);
    // Add listener so that when the user taps enter, it submits the captcha
    captchaText.setOnKeyListener((v, keyCode, event) -> {
        if ((event.getAction() == KeyEvent.ACTION_UP) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
            validateThenCreateAccount();
            return true;
        }
        return false;
    });
    usernameInput.getEditText().addTextChangedListener(userNameTextWatcher);
    if (savedInstanceState != null && savedInstanceState.containsKey("result")) {
        createAccountResult = savedInstanceState.getParcelable("result");
    }
    funnel = new CreateAccountFunnel(WikipediaApp.getInstance(), getIntent().getStringExtra(LOGIN_REQUEST_SOURCE));
    // Only send the editing start log event if the activity is created for the first time
    if (savedInstanceState == null) {
        funnel.logStart(getIntent().getStringExtra(LOGIN_SESSION_TOKEN));
    }
    // Set default result to failed, so we can override if it did not
    setResult(RESULT_ACCOUNT_NOT_CREATED);
}
Also used : CreateAccountFunnel(org.wikipedia.analytics.CreateAccountFunnel) CaptchaHandler(org.wikipedia.captcha.CaptchaHandler) NonEmptyValidator(org.wikipedia.views.NonEmptyValidator) ProgressDialog(android.app.ProgressDialog)

Aggregations

ProgressDialog (android.app.ProgressDialog)1 CreateAccountFunnel (org.wikipedia.analytics.CreateAccountFunnel)1 CaptchaHandler (org.wikipedia.captcha.CaptchaHandler)1 NonEmptyValidator (org.wikipedia.views.NonEmptyValidator)1