@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.login_two_factor_auth);

    accountManager = AccountManager.get(this);

    ViewFinder finder = new ViewFinder(this);
    otpCodeText = finder.find(R.id.et_otp_code);

    final Intent intent = getIntent();
    username = intent.getStringExtra(PARAM_USERNAME);
    password = intent.getStringExtra(PARAM_PASSWORD);

    TextView signupText = finder.find(R.id.tv_signup);
    signupText.setMovementMethod(LinkMovementMethod.getInstance());
    signupText.setText(Html.fromHtml(getString(R.string.signup_link_two_factor_auth)));

    TextWatcher watcher =
        new TextWatcherAdapter() {

          @Override
          public void afterTextChanged(Editable gitDirEditText) {
            updateEnablement();
          }
        };
    otpCodeText.addTextChangedListener(watcher);

    otpCodeText.setOnKeyListener(
        new View.OnKeyListener() {

          @Override
          public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (event != null
                && ACTION_DOWN == event.getAction()
                && keyCode == KEYCODE_ENTER
                && loginEnabled()) {
              handleLogin();
              return true;
            } else return false;
          }
        });

    otpCodeText.setOnEditorActionListener(
        new TextView.OnEditorActionListener() {

          @Override
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == IME_ACTION_DONE && loginEnabled()) {
              handleLogin();
              return true;
            }
            return false;
          }
        });
  }
예제 #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    finder = new ViewFinder(this);
  }
 @Override
 protected void onResume() {
   super.onResume();
   updateEnablement();
 }