use of org.wikipedia.views.NonEmptyValidator 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);
}
use of org.wikipedia.views.NonEmptyValidator in project apps-android-wikipedia by wikimedia.
the class LoginActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
ButterKnife.bind(this);
errorView.setBackClickListener((v) -> onBackPressed());
errorView.setRetryClickListener((v) -> errorView.setVisibility(View.GONE));
// Don't allow user to attempt login until they've put in a username and password
new NonEmptyValidator((isValid) -> loginButton.setEnabled(isValid), usernameInput, passwordInput);
passwordInput.getEditText().setOnEditorActionListener((textView, actionId, keyEvent) -> {
if (actionId == EditorInfo.IME_ACTION_DONE) {
validateThenLogin();
return true;
}
return false;
});
progressDialog = new ProgressDialog(this);
progressDialog.setMessage(getString(R.string.login_in_progress_dialog_message));
progressDialog.setCancelable(false);
funnel = new LoginFunnel(WikipediaApp.getInstance());
loginSource = getIntent().getStringExtra(LOGIN_REQUEST_SOURCE);
if (getIntent().getBooleanExtra(ACTION_CREATE_ACCOUNT, false)) {
wentStraightToCreateAccount = true;
startCreateAccountActivity();
} else if (savedInstanceState == null) {
// Only send the login start log event if the activity is created for the first time
logLoginStart();
}
// Assume no login by default
setResult(RESULT_LOGIN_FAIL);
}
Aggregations