use of cn.snowt.diary.service.DiaryService in project Diary by HibaraAi.
the class RecoveryDiaryActivity method findViewAndSetListener.
private void findViewAndSetListener() {
setSupportActionBar(findViewById(R.id.default_toolbar_inc));
ActionBar supportActionBar = getSupportActionBar();
if (null != supportActionBar) {
supportActionBar.setDisplayHomeAsUpEnabled(true);
supportActionBar.setTitle("恢复日记");
}
loadBackupBtn = findViewById(R.id.re_diary_btn_load_backup);
loadKeyBtn = findViewById(R.id.re_diary_btn_load_key);
saveBtn = findViewById(R.id.re_diary_btn_save);
tipView = findViewById(R.id.re_diary_tip);
pinKeyView = findViewById(R.id.re_diary_pin);
loadBackupBtn.setOnClickListener(v -> {
OpenFile(SELECT_BACKUP_FILE);
BaseUtils.longTipInCoast(RecoveryDiaryActivity.this, "请选择备份文件");
});
loadKeyBtn.setOnClickListener(v -> {
OpenFile(SELECT_KEY_FILE);
BaseUtils.longTipInCoast(this, "请选择密钥文件");
});
saveBtn.setOnClickListener(v -> {
String pinKey = pinKeyView.getText().toString();
if ("".equals(pinKey)) {
BaseUtils.shortTipInSnack(saveBtn, "没有输入口令,怎么验证? ORz");
} else {
// 校验口令
String pinInMap = (String) map.get(Constant.BACKUP_ARGS_NAME_PIN_KEY);
boolean isBadPin = (pinInMap == null || !pinInMap.equals(MD5Utils.encrypt(Constant.PASSWORD_PREFIX + pinKey)));
if (isBadPin) {
String tipStr = "你提供的口令是错误的呢";
BaseUtils.shortTipInSnack(tipView, "你提供的口令是错误的呢 QaQ");
tipView.setText(tipStr);
} else {
BaseUtils.longTipInCoast(this, "后台已经在执行恢复日记的后续操作,执行结果将在通知栏告知你");
new Thread(() -> {
DiaryService diaryService = new DiaryServiceImpl();
SimpleResult result = diaryService.recoveryDiary(pinKey, privateKey, map);
BaseUtils.longTextSysNotice(RecoveryDiaryActivity.this, result.getMsg());
}).start();
this.finish();
}
}
});
}
Aggregations