Example #1
0
  private void onChangePassword(CharSequence old, CharSequence new1, CharSequence new2) {
    if (!new1.toString().equals(new2.toString())) {
      showMsg(R.string.pref_dialog_pwd_mismatch);
      return;
    }

    if (mModel.changePassword(old, new1)) {
      showMsg(R.string.pref_dialog_pwd_success);
      mModel.save();
    } else {
      showMsg(R.string.pref_dialog_pwd_incorrect);
    }
  }
Example #2
0
  private void onImportData(CharSequence password) {
    File input = new File(EXTERNAL_DIR, FILENAME);
    if (!input.exists()) {
      showMsg(super.getString(R.string.pref_dialog_import_data_fail) + input.getPath());
      return;
    }

    try {
      FileInputStream fis = new FileInputStream(input);
      List<Item> list = mModel.loadHelper(fis, password);
      if (list != null) {
        for (int i = 0; i < list.size(); i++) {
          mModel.addItem(list.get(i));
        }
        mModel.save();
        showMsg(super.getString(R.string.pref_dialog_done));
      } else {
        showMsg(super.getString(R.string.pref_dialog_import_data_fail));
      }
    } catch (Exception e) {
      showMsg("Exception occurred!");
      e.printStackTrace();
    }
  }