コード例 #1
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);

    MenuInflater inflate = getMenuInflater();
    inflate.inflate(R.menu.password, menu);

    return true;
  }
コード例 #2
0
  @Override
  protected void onResume() {
    super.onResume();

    // If the application was shutdown make sure to clear the password field, if it
    // was saved in the instance state
    if (App.isShutdown()) {
      TextView password = (TextView) findViewById(R.id.password);
      password.setText("");
    }

    // Clear the shutdown flag
    App.clearShutdown();
  }
コード例 #3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Intent i = getIntent();

    prefs = PreferenceManager.getDefaultSharedPreferences(this);
    mRememberKeyfile =
        prefs.getBoolean(
            getString(R.string.keyfile_key), getResources().getBoolean(R.bool.keyfile_default));
    setContentView(R.layout.password);

    new InitTask().execute(i);
  }
コード例 #4
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    switch (requestCode) {
      case KeePass.EXIT_NORMAL:
        setEditText(R.id.password, "");
        App.getDB().clear();
        break;

      case KeePass.EXIT_LOCK:
        setResult(KeePass.EXIT_LOCK);
        setEditText(R.id.password, "");
        finish();
        App.getDB().clear();
        break;
      case FILE_BROWSE:
        if (resultCode == RESULT_OK) {
          String filename = data.getDataString();
          if (filename != null) {
            if (filename.startsWith("file://")) {
              filename = filename.substring(7);
            }

            filename = URLDecoder.decode(filename);

            EditText fn = (EditText) findViewById(R.id.pass_keyfile);
            fn.setText(filename);
          }
        }
        break;
      case GET_CONTENT:
        if (resultCode == RESULT_OK) {
          if (data != null) {
            Uri uri = data.getData();
            if (uri != null) {
              String path = uri.getPath();
              if (path != null) {
                EditText fn = (EditText) findViewById(R.id.pass_keyfile);
                fn.setText(path);
              }
            }
          }
        }
        break;
    }
  }