Example #1
0
  public void actionLogin(View button) {

    final EditText txtpass = (EditText) findViewById(R.id.txtpass);
    if (txtpass.getText().toString().length() < 1) {
      txtpass.setError(getResources().getString(R.string.login_passwd_err));
      return;
    }

    if (firstlogin) {

      final CheckBox chkBoxpass = (CheckBox) findViewById(R.id.chkPass);

      SharedPreferences.Editor editor = preferences.edit();
      editor.putBoolean("firstlogin", false);
      editor.putBoolean("checkpass", chkBoxpass.isChecked());
      editor.putString("dbpassword", StringEncoder.encode(this, txtpass.getText().toString()));
      editor.putString("currency", "€");
      editor.putLong("currency_id", 1);
      editor.commit();

      MyExApp app = (MyExApp) getApplication();
      app.reloadPreferences();
      app.reloadDataManager();
      app.initData();

    } else {

      String password = StringEncoder.decode(this, preferences.getString("dbpassword", ""));
      if (!password.equals(txtpass.getText().toString())) {
        txtpass.setError(getResources().getString(R.string.login_passwd_err2));
        return;
      }
    }
    startMainFragment();
  }