标签:unlock void extra index which security string boolean 应用
徐姣美:增加了忘记密码,移除密码的功能,进行密保验证。
代码:
@SuppressLint("CommitPrefEdits")
private void updatePassword (String passwordText, String questionText, String answerText) {
if (passwordText == null) {
if (prefs.getString(PREF_PASSWORD, "").length() == 0) {
Crouton.makeText(mActivity, R.string.password_not_set, ONStyle.WARN, croutonHandle).show();
return;
}
new MaterialDialog.Builder(mActivity)
.content(R.string.agree_unlocking_all_notes)
.positiveText(R.string.ok)
.onPositive((dialog, which) -> PasswordHelper.removePassword()).build().show();
} else if (passwordText.length() == 0) {
Crouton.makeText(mActivity, R.string.empty_password, ONStyle.WARN, croutonHandle).show();
} else {
Observable
.from(DbHelper.getInstance().getNotesWithLock(true))
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.doOnSubscribe(() -> prefs.edit()
.putString(PREF_PASSWORD, Security.md5(passwordText))
.putString(PREF_PASSWORD_QUESTION, questionText)
.putString(PREF_PASSWORD_ANSWER, Security.md5(answerText))
.commit())
.doOnNext(note -> DbHelper.getInstance().updateNote(note, false))
.doOnCompleted(() -> {
Crouton crouton = Crouton.makeText(mActivity, R.string.password_successfully_changed, ONStyle
.CONFIRM, croutonHandle);
crouton.setLifecycleCallback(new LifecycleCallback() {
@Override
public void onDisplayed () {
// Does nothing!
}
@Override
public void onRemoved () {
onBackPressed();
}
});
crouton.show();
})
.subscribe();
}
}
/**
* Checks correctness of form data
*/
private boolean checkData () {
boolean res = true;
if (password.getText().length() == passwordCheck.getText().length()
&& passwordCheck.getText().length() == 0) {
return true;
}
boolean passwordOk = password.getText().toString().length() > 0;
boolean passwordCheckOk = passwordCheck.getText().toString().length() > 0 && password.getText().toString()
.equals(
passwordCheck.getText().toString());
boolean questionOk = question.getText().toString().length() > 0;
boolean answerOk = answer.getText().toString().length() > 0;
boolean answerCheckOk = answerCheck.getText().toString().length() > 0 && answer.getText().toString().equals
(answerCheck.getText().toString());
if (!passwordOk || !passwordCheckOk || !questionOk || !answerOk || !answerCheckOk) {
res = false;
if (!passwordOk) {
password.setError(getString(R.string.settings_password_not_matching));
}
if (!passwordCheckOk) {
passwordCheck.setError(getString(R.string.settings_password_not_matching));
}
if (!questionOk) {
question.setError(getString(R.string.settings_password_question));
}
if (!answerOk) {
answer.setError(getString(R.string.settings_answer_not_matching));
}
if (!answerCheckOk) {
answerCheck.setError(getString(R.string.settings_answer_not_matching));
}
}
return res;
}
申澳宇:今天增加并完善了关于分类的的功能,能够添加、修改、移除。
代码:
@OnClick(R.id.save) public void saveCategory () { if (title.getText().toString().length() == 0) { title.setError(getString(R.string.category_missing_title)); return; } Long id = category.getId() != null ? category.getId() : Calendar.getInstance().getTimeInMillis(); category.setId(id); category.setName(title.getText().toString()); category.setDescription(description.getText().toString()); if (selectedColor != 0 || category.getColor() == null) { category.setColor(String.valueOf(selectedColor)); } // Saved to DB and new ID or update result catched DbHelper db = DbHelper.getInstance(); category = db.updateCategory(category); // Sets result to show proper message getIntent().putExtra(INTENT_CATEGORY, category); setResult(RESULT_OK, getIntent()); finish(); } @OnClick(R.id.delete) public void deleteCategory () { new MaterialDialog.Builder(this) .title(R.string.delete_unused_category_confirmation) .content(R.string.delete_category_confirmation) .positiveText(R.string.confirm) .positiveColorRes(R.color.colorAccent) .onPositive((dialog, which) -> { // Changes navigation if actually are shown notes associated with this category SharedPreferences prefs = getSharedPreferences(PREFS_NAME, MODE_MULTI_PROCESS); String navNotes = getResources().getStringArray(R.array.navigation_list_codes)[0]; String navigation = prefs.getString(PREF_NAVIGATION, navNotes); if (String.valueOf(category.getId()).equals(navigation)) { prefs.edit().putString(PREF_NAVIGATION, navNotes).apply(); } // Removes category and edit notes associated with it DbHelper db = DbHelper.getInstance(); db.deleteCategory(category); EventBus.getDefault().post(new CategoriesUpdatedEvent()); BaseActivity.notifyAppWidgets(OmniNotes.getAppContext()); setResult(RESULT_FIRST_USER); finish(); }).build().show(); }
刘贺鑫:增加了应用内颜色设置的功能。
代码:
final ListPreference colorsApp = findPreference("settings_colors_app"); if (colorsApp != null) { int colorsAppIndex = colorsApp.findIndexOfValue(prefs.getString("settings_colors_app", PREF_COLORS_APP_DEFAULT)); String colorsAppString = getResources().getStringArray(R.array.colors_app)[colorsAppIndex]; colorsApp.setSummary(colorsAppString); colorsApp.setOnPreferenceChangeListener((preference, newValue) -> { int colorsAppIndex1 = colorsApp.findIndexOfValue(newValue.toString()); String colorsAppString1 = getResources().getStringArray(R.array.colors_app)[colorsAppIndex1]; colorsApp.setSummary(colorsAppString1); prefs.edit().putString("settings_colors_app", newValue.toString()).apply(); colorsApp.setValueIndex(colorsAppIndex1); return false; }); }
标签:unlock void extra index which security string boolean 应用
原文地址:https://www.cnblogs.com/cfypd/p/13060379.html