团队冲刺第二阶段02
徐姣美:添加密码、修改、删除密码的具体操作相关内容
代码:
public static void requestPassword (final Activity mActivity, final PasswordValidator mPasswordValidator) { LayoutInflater inflater = mActivity.getLayoutInflater(); final View v = inflater.inflate(R.layout.password_request_dialog_layout, null); final EditText passwordEditText = v.findViewById(R.id.password_request); MaterialDialog dialog = new MaterialDialog.Builder(mActivity) .autoDismiss(false) .title(R.string.insert_security_password) .customView(v, false) .positiveText(R.string.ok) .positiveColorRes(R.color.colorPrimary) .onPositive((dialog12, which) -> { String oldPassword = mActivity.getSharedPreferences(PREFS_NAME, MODE_MULTI_PROCESS).getString(PREF_PASSWORD, ""); String password = passwordEditText.getText().toString(); boolean result = Security.md5(password).equals(oldPassword); if (result) { KeyboardUtils.hideKeyboard(passwordEditText); dialog12.dismiss(); mPasswordValidator.onPasswordValidated(PasswordValidator.Result.SUCCEED); } else { passwordEditText.setError(mActivity.getString(R.string.wrong_password)); } }) .neutralText(mActivity.getResources().getString(R.string.password_forgot)) .onNeutral((dialog13, which) -> { PasswordHelper.resetPassword(mActivity); mPasswordValidator.onPasswordValidated(PasswordValidator.Result.RESTORE); dialog13.dismiss(); }) .build(); dialog.setOnCancelListener(dialog1 -> { KeyboardUtils.hideKeyboard(passwordEditText); dialog1.dismiss(); mPasswordValidator.onPasswordValidated(PasswordValidator.Result.FAIL); }); passwordEditText.setOnEditorActionListener((textView, actionId, keyEvent) -> { if (actionId == EditorInfo.IME_ACTION_DONE) { dialog.getActionButton(DialogAction.POSITIVE).callOnClick(); return true; } return false; }); dialog.show(); new Handler().postDelayed(() -> KeyboardUtils.showKeyboard(passwordEditText), 100); } public static void resetPassword (final Activity mActivity) { View layout = mActivity.getLayoutInflater().inflate(R.layout.password_reset_dialog_layout, null); final EditText answerEditText = layout.findViewById(R.id.reset_password_answer); MaterialDialog dialog = new MaterialDialog.Builder(mActivity) .title(OmniNotes.getSharedPreferences().getString(PREF_PASSWORD_QUESTION, "")) .customView(layout, false) .autoDismiss(false) .contentColorRes(R.color.text_color) .positiveText(R.string.ok) .onPositive((dialogElement, which) -> { String oldAnswer = OmniNotes.getSharedPreferences().getString(PREF_PASSWORD_ANSWER, ""); String answer1 = answerEditText.getText().toString(); boolean result = Security.md5(answer1).equals(oldAnswer); if (result) { dialogElement.dismiss(); removePassword(); } else { answerEditText.setError(mActivity.getString(R.string.wrong_answer)); } }).build(); dialog.show(); answerEditText.setOnEditorActionListener((textView, actionId, keyEvent) -> { if (actionId == EditorInfo.IME_ACTION_DONE) { dialog.getActionButton(DialogAction.POSITIVE).callOnClick(); return true; } return false; }); new Handler().postDelayed(() -> KeyboardUtils.showKeyboard(answerEditText), 100); } public static void removePassword () { Observable .from(DbHelper.getInstance().getNotesWithLock(true)) .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) .doOnNext(note -> { note.setLocked(false); DbHelper.getInstance().updateNote(note, false); }) .doOnCompleted(() -> { OmniNotes.getSharedPreferences().edit() .remove(PREF_PASSWORD) .remove(PREF_PASSWORD_QUESTION) .remove(PREF_PASSWORD_ANSWER) .remove("settings_password_access") .apply(); EventBus.getDefault().post(new PasswordRemovedEvent()); }) .subscribe(); }
申澳宇:今天修改了分类的界面,在写好的便签中点击分类按钮,课进行分类的相关设置。
代码:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:pixlui="http://schemas.android.com/apk/com.neopixl.pixlui" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/icon_selector" android:gravity="center_vertical" android:orientation="horizontal" android:paddingLeft="@dimen/horizontal_margin" android:paddingStart="@dimen/horizontal_margin"> <ImageView android:layout_width="24dp" android:layout_height="24dp" android:padding="4dp" android:src="@drawable/ic_settings_black_36dp" /> <com.neopixl.pixlui.components.textview.TextView android:id="@+id/settings" android:layout_width="@dimen/navigation_drawer_width" android:layout_height="50dp" android:gravity="center_vertical" android:paddingLeft="@dimen/icon_text_margin" android:paddingStart="@dimen/icon_text_margin" android:text="@string/settings" android:textAllCaps="true" android:textAppearance="@style/Text.Normal" android:textColor="@color/drawer_text" pixlui:typeface="Roboto-Regular.ttf" /> </LinearLayout>
刘贺鑫:在主界面中点击三个按钮,分别执行相应操作。
代码:
private void initFab () { fab = new Fab(fabView, list, prefs.getBoolean(PREF_FAB_EXPANSION_BEHAVIOR, false)); fab.setOnFabItemClickedListener(id -> { View v = mainActivity.findViewById(id); switch (id) { case R.id.fab_expand_menu_button: editNote(new Note(), v); break; case R.id.fab_note: editNote(new Note(), v); break; case R.id.fab_camera: Intent i = mainActivity.getIntent(); i.setAction(ACTION_FAB_TAKE_PHOTO); mainActivity.setIntent(i); editNote(new Note(), v); break; case R.id.fab_checklist: Note note = new Note(); note.setChecklist(true); editNote(note, v); break; } }); }