cmt: edit & delete note 80%

zhengkunpeng_branch
zkx 2 years ago
parent d88a65106d
commit 2af601932e

@ -178,7 +178,7 @@ public class WorkingNote {
int widgetType, int defaultBgColorId) {
/**
* @method: createEmptyNote
* @description: 便
* @description: 便便
* @date: 2023/12/20 23:55
* @author: zhoukexing
* @param: [context, folderId, widgetId, widgetType, defaultBgColorId]
@ -241,7 +241,16 @@ public class WorkingNote {
}
}
/**
* @method: setOnSettingStatusChangedListener
* @description: NoteEditActivityNoteSettingChangedListener
* @date: 2023/12/21 0:10
* @author: zhoukexing
* @param: [l] NoteEditActivity
* @return: void
*/
public void setOnSettingStatusChangedListener(NoteSettingChangedListener l) {
//Q: 这里的l是怎么获取的。l是NoteEditActivity @zkx 2023/12/21
mNoteSettingStatusListener = l;
}
@ -265,7 +274,14 @@ public class WorkingNote {
mNoteSettingStatusListener.onClockAlertChanged(date, set);
}
}
/**
* @method: markDeleted
* @description:
* @date: 2023/12/21 0:50
* @author: zhoukexing
* @param: [mark]
* @return: void
*/
public void markDeleted(boolean mark) {
mIsDeleted = mark;
if (mWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID

@ -158,16 +158,17 @@ public class NoteEditActivity extends Activity //NOTE: extends--单继承,但
/**
* @zkx 2023/12/18 ActivityonCreate
*/
/**
* @method: onCreate
* @description: list便
* allinall
* @date: 2023/12/18 23:22
* @author: zhoukexing
* @param: [savedInstanceState]
* @return: void
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
/**
* @method: onCreate
* @description:
* @date: 2023/12/18 23:22
* @author: zhoukexing
* @param: [savedInstanceState]
* @return: void
*/
super.onCreate(savedInstanceState);
this.setContentView(R.layout.note_edit);
@ -212,6 +213,7 @@ public class NoteEditActivity extends Activity //NOTE: extends--单继承,但
*/
mWorkingNote = null;
if (TextUtils.equals(Intent.ACTION_VIEW, intent.getAction())) {
// 进入场景:点进一个已有便签 @zhoukexing 2023/12/21 0:14
long noteId = intent.getLongExtra(Intent.EXTRA_UID, 0);
mUserQuery = "";
@ -229,7 +231,7 @@ public class NoteEditActivity extends Activity //NOTE: extends--单继承,但
showToast(R.string.error_note_not_exist);
finish();
return false;
} else {
} else {// 如果在数据库里存在就根据noteId从数据库中加载到工作便签里来 @zhoukexing 2023/12/21 0:16
mWorkingNote = WorkingNote.load(this, noteId);
if (mWorkingNote == null) {
Log.e(TAG, "load note failed with note id" + noteId);
@ -237,20 +239,20 @@ public class NoteEditActivity extends Activity //NOTE: extends--单继承,但
return false;
}
}
getWindow().setSoftInputMode(
getWindow().setSoftInputMode(// 猜:平滑地展示便签内容 @zhoukexing 2023/12/21 0:18
WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN
| WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
} else if(TextUtils.equals(Intent.ACTION_INSERT_OR_EDIT, intent.getAction())) {
// New note
// 进入场景:一个New note
long folderId = intent.getLongExtra(Notes.INTENT_EXTRA_FOLDER_ID, 0);
int widgetId = intent.getIntExtra(Notes.INTENT_EXTRA_WIDGET_ID,
AppWidgetManager.INVALID_APPWIDGET_ID);
int widgetType = intent.getIntExtra(Notes.INTENT_EXTRA_WIDGET_TYPE,
Notes.TYPE_WIDGET_INVALIDE);
Notes.TYPE_WIDGET_INVALIDE); // widgetType=0: 新建的挂件,空的 @zhoukexing 2023/12/21 0:02
int bgResId = intent.getIntExtra(Notes.INTENT_EXTRA_BACKGROUND_ID,
ResourceParser.getDefaultBgId(this));
ResourceParser.getDefaultBgId(this));// TODO: 2023/12/21 背景色的设置
// Parse call-record note
// Parse call-record note todo
// 解析文档,看是否有号码存在,以便展示的时候渲染 @zhoukexing 2023/12/20 23:49
String phoneNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
long callDate = intent.getLongExtra(Notes.INTENT_EXTRA_CALL_DATE, 0);
@ -287,6 +289,7 @@ public class NoteEditActivity extends Activity //NOTE: extends--单继承,但
return false;
}
mWorkingNote.setOnSettingStatusChangedListener(this);
// this是WorkingNote @zhoukexing 2023/12/21 0:08
return true;
}
@ -573,12 +576,13 @@ public class NoteEditActivity extends Activity //NOTE: extends--单继承,但
if (itemId == R.id.menu_new_note) { // 从item到itemid用itemid导向对应的不同的动作 @zhoukexing 2023/12/19 23:38
createNewNote();
} else if (itemId == R.id.menu_delete) {
// 构建一个警告⚠对话框,让用户确认是否真的要删除便签 @zhoukexing 2023/12/21 0:41
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(getString(R.string.alert_title_delete));
builder.setIcon(android.R.drawable.ic_dialog_alert);
builder.setMessage(getString(R.string.alert_message_delete_note));
builder.setPositiveButton(android.R.string.ok,
new DialogInterface.OnClickListener() {
new DialogInterface.OnClickListener() {// TODO: 2023/12/21 传入了一个函数作为参数?
public void onClick(DialogInterface dialog, int which) {
deleteCurrentNote();
finish();
@ -655,7 +659,14 @@ public class NoteEditActivity extends Activity //NOTE: extends--单继承,但
intent.putExtra(Notes.INTENT_EXTRA_FOLDER_ID, mWorkingNote.getFolderId());
startActivity(intent);
}
/**
* @method: deleteCurrentNote
* @description: 便
* @date: 2023/12/21 0:48
* @author: zhoukexing
* @param: []
* @return: void
*/
private void deleteCurrentNote() {
if (mWorkingNote.existInDatabase()) {
HashSet<Long> ids = new HashSet<Long>();

@ -137,11 +137,19 @@ public class NoteEditText extends EditText {
}
return super.onKeyDown(keyCode, event);
}
/**
* @method: onKeyUp
* @description: deleteenter
* 退
* @date: 2023/12/21 0:28
* @author: zhoukexing
* @param: [keyCode, event]
* @return: boolean
*/
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
switch(keyCode) {
case KeyEvent.KEYCODE_DEL:
case KeyEvent.KEYCODE_DEL: // delete键的号为67 @zhoukexing 2023/12/21 0:31
if (mOnTextViewChangeListener != null) {
if (0 == mSelectionStartBeforeDelete && mIndex != 0) {
mOnTextViewChangeListener.onEditTextDelete(mIndex, getText().toString());
@ -151,7 +159,7 @@ public class NoteEditText extends EditText {
Log.d(TAG, "OnTextViewChangeListener was not seted");
}
break;
case KeyEvent.KEYCODE_ENTER:
case KeyEvent.KEYCODE_ENTER: // enter键的号为66 @zhoukexing 2023/12/21 0:31
if (mOnTextViewChangeListener != null) {
int selectionStart = getSelectionStart();
String text = getText().subSequence(selectionStart, length()).toString();

Loading…
Cancel
Save