diff --git a/README.md b/README.md index 1f39b6c..4490cf1 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,14 @@ -seminote +# 2023年秋软件工程实践任务一--1 -zkp加入 +小组成员:郑鲲鹏,李泽锴,周柯杏 + +实践内容:小米便签代码的阅读、标注和分析 + +实践时间:2023.11.20- + +实践记录: + +1. 2023.11.23 zkp加入分支管理 +2. 2023.11.23 18:37 OK all of us are in the correct project +3. 2023.11.26 22:30 creat new zhengkunpeng_branch +4. 2023.11.27 9:19 creat new zhoukexing_branch diff --git a/doc/实践模板-开源软件泛读、标注和维护报告文档.docx b/doc/实践模板-开源软件泛读、标注和维护报告文档.docx index f307642..3e73494 100644 Binary files a/doc/实践模板-开源软件泛读、标注和维护报告文档.docx and b/doc/实践模板-开源软件泛读、标注和维护报告文档.docx differ diff --git a/src/README.md b/src/README.md deleted file mode 100644 index 97e7de9..0000000 --- a/src/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# 2023年秋软件工程实践任务一--1 - -小组成员:郑鲲鹏,李泽锴,周柯杏 - -实践内容:小米便签代码的阅读、标注和分析 - -实践时间:2023.11.20- - -实践记录: - -1. 2023.11.23 zkp加入分支管理 \ No newline at end of file diff --git a/src/doc/实践模板-开源软件泛读、标注和维护报告文档.docx b/src/doc/实践模板-开源软件泛读、标注和维护报告文档.docx deleted file mode 100644 index f307642..0000000 Binary files a/src/doc/实践模板-开源软件泛读、标注和维护报告文档.docx and /dev/null differ diff --git a/src/main/java/net/micode/notes/data/NotesProvider.java b/src/main/java/net/micode/notes/data/NotesProvider.java index f8a2cc5..6f95a92 100644 --- a/src/main/java/net/micode/notes/data/NotesProvider.java +++ b/src/main/java/net/micode/notes/data/NotesProvider.java @@ -48,6 +48,7 @@ public class NotesProvider extends ContentProvider { private static final int URI_DATA_ITEM = 4; private static final int URI_SEARCH = 5; + private static final int URI_SEARCH_SUGGEST = 6; static { diff --git a/src/main/java/net/micode/notes/gtask/exception/NetworkFailureException.java b/src/main/java/net/micode/notes/gtask/exception/NetworkFailureException.java index 4bdd6c6..d28af4d 100644 --- a/src/main/java/net/micode/notes/gtask/exception/NetworkFailureException.java +++ b/src/main/java/net/micode/notes/gtask/exception/NetworkFailureException.java @@ -15,7 +15,6 @@ */ package net.micode.notes.gtask.exception; - public class NetworkFailureException extends Exception { private static final long serialVersionUID = 2107610287180234136L; @@ -26,8 +25,7 @@ public class NetworkFailureException extends Exception { public NetworkFailureException(String paramString) { super(paramString); } - public NetworkFailureException(String paramString, Throwable paramThrowable) { super(paramString, paramThrowable); } -} +} \ No newline at end of file diff --git a/src/main/java/net/micode/notes/model/WorkingNote.java b/src/main/java/net/micode/notes/model/WorkingNote.java index 6b83f06..4e5a4e7 100644 --- a/src/main/java/net/micode/notes/model/WorkingNote.java +++ b/src/main/java/net/micode/notes/model/WorkingNote.java @@ -229,11 +229,22 @@ public class WorkingNote { mNoteSettingStatusListener = l; } + /** + * @Method setAlertDate + * @Date 2023/12/13 11:43 + * @param date 提醒日期 + * @param set 动作(关闭或开启) + * @Author lenovo + * @Return void + * @Description 设置一个提醒时间 + */ public void setAlertDate(long date, boolean set) { + // 更新便签项中的提醒日期 if (date != mAlertDate) { mAlertDate = date; mNote.setNoteValue(NoteColumns.ALERTED_DATE, String.valueOf(mAlertDate)); } + // 设置提醒的监听事件 if (mNoteSettingStatusListener != null) { mNoteSettingStatusListener.onClockAlertChanged(date, set); } diff --git a/src/main/java/net/micode/notes/tool/DataUtils.java b/src/main/java/net/micode/notes/tool/DataUtils.java index e918390..7ef3485 100644 --- a/src/main/java/net/micode/notes/tool/DataUtils.java +++ b/src/main/java/net/micode/notes/tool/DataUtils.java @@ -135,8 +135,22 @@ public class DataUtils { } return count; } - + /** + * @Method visibleInNoteDatabase + * @Date 2023/12/13 9:08 + * @param resolver + * @param noteId + * @param type + * @Author lenovo + * @Return boolean + * @Description 访问数据库中是否有 noteId 对应的便签 + */ public static boolean visibleInNoteDatabase(ContentResolver resolver, long noteId, int type) { + /** + * withAppendedId 将 URI 和 ID 连接成一个新的URI + * query 返回 Uri 中符合 selection 的表格 + * lenovo 2023/12/13 9:06 + */ Cursor cursor = resolver.query(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId), null, NoteColumns.TYPE + "=? AND " + NoteColumns.PARENT_ID + "<>" + Notes.ID_TRASH_FOLER, diff --git a/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java b/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java index 8ad2de7..156cc8a 100644 --- a/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java +++ b/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java @@ -47,13 +47,28 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD MediaPlayer mPlayer; @Override + /** + * @Method onCreate + * @Date 2023/12/13 8:15 + * @param savedInstanceState + * @Author lenovo + * @Return void + * @Description + */ protected void onCreate(Bundle savedInstanceState) { + /** + * Bundel 类似于 map,key-value存储 + * super 代表父类, 调用 onCreate 用于恢复上次结束的状态 + * lenovo 2023/12/13 8:39 + */ super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); final Window win = getWindow(); + // 在屏幕锁定时显示 win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); + // 锁屏时到闹钟提示时间后,点亮屏幕 if (!isScreenOn()) { win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON @@ -66,6 +81,7 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD try { mNoteId = Long.valueOf(intent.getData().getPathSegments().get(1)); mSnippet = DataUtils.getSnippetById(this.getContentResolver(), mNoteId); + // 超出长度则变为 substr + "..." mSnippet = mSnippet.length() > SNIPPET_PREW_MAX_LEN ? mSnippet.substring(0, SNIPPET_PREW_MAX_LEN) + getResources().getString(R.string.notelist_string_info) : mSnippet; @@ -75,6 +91,7 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD } mPlayer = new MediaPlayer(); + // 查找数据库中有没有 mNoteId 的便签, 如果有则激发对话框 + 闹钟提示音 if (DataUtils.visibleInNoteDatabase(getContentResolver(), mNoteId, Notes.TYPE_NOTE)) { showActionDialog(); playAlarmSound(); diff --git a/src/main/java/net/micode/notes/ui/NoteEditActivity.java b/src/main/java/net/micode/notes/ui/NoteEditActivity.java index 3e0ead6..420a690 100644 --- a/src/main/java/net/micode/notes/ui/NoteEditActivity.java +++ b/src/main/java/net/micode/notes/ui/NoteEditActivity.java @@ -295,15 +295,32 @@ public class NoteEditActivity extends Activity implements OnClickListener, showAlertHeader(); } + /** + * @Method showAlertHeader + * @Date 2023/12/13 11:32 + * @Author lenovo + * @Return void + * @Description 在便签页面的上方栏显示提醒信息 + */ private void showAlertHeader() { if (mWorkingNote.hasClockAlert()) { long time = System.currentTimeMillis(); if (time > mWorkingNote.getAlertDate()) { + // 闹钟时间大于当前时间, 显示 "Expired", 闹钟失效 mNoteHeaderHolder.tvAlertDate.setText(R.string.note_alert_expired); } else { + // 显示正常闹钟信息 mNoteHeaderHolder.tvAlertDate.setText(DateUtils.getRelativeTimeSpanString( mWorkingNote.getAlertDate(), time, DateUtils.MINUTE_IN_MILLIS)); } + /** + * setVisibility() + * 用于设置空间的可见性 + * VISIBLE 可见 + * INVISIBLE 不可见,但是占用一个位置 + * GNONE 不可见且不占用位置 + * lenovo 2023/12/13 11:28 + */ mNoteHeaderHolder.tvAlertDate.setVisibility(View.VISIBLE); mNoteHeaderHolder.ivAlertIcon.setVisibility(View.VISIBLE); } else { @@ -543,8 +560,16 @@ public class NoteEditActivity extends Activity implements OnClickListener, return true; } + /** + * @Method setReminder + * @Date 2023/12/13 12:52 + * @Author lenovo + * @Return void + * @Description 显示时间选择器,默认时间为当前时间 + */ private void setReminder() { DateTimePickerDialog d = new DateTimePickerDialog(this, System.currentTimeMillis()); + // 设置时间选择器的监听事件,当选中 date 之后调用 setAlertDate 设置提醒时间 d.setOnDateTimeSetListener(new OnDateTimeSetListener() { public void OnDateTimeSet(AlertDialog dialog, long date) { mWorkingNote.setAlertDate(date , true); @@ -602,6 +627,15 @@ public class NoteEditActivity extends Activity implements OnClickListener, return NotesPreferenceActivity.getSyncAccountName(this).trim().length() > 0; } + /** + * @Method onClockAlertChanged + * @Date 2023/12/13 9:52 + * @param date + * @param set 0 取消 1 设置 + * @Author lenovo + * @Return void + * @Description 设置提醒的监听事件 + */ public void onClockAlertChanged(long date, boolean set) { /** * User could set clock to an unsaved note, so before setting the @@ -617,8 +651,10 @@ public class NoteEditActivity extends Activity implements OnClickListener, AlarmManager alarmManager = ((AlarmManager) getSystemService(ALARM_SERVICE)); showAlertHeader(); if(!set) { + // 取消监听事件 alarmManager.cancel(pendingIntent); } else { + // 设置监听事件,到时间启动提醒 alarmManager.set(AlarmManager.RTC_WAKEUP, date, pendingIntent); } } else { diff --git a/src/main/java/net/micode/notes/ui/NotesListActivity.java b/src/main/java/net/micode/notes/ui/NotesListActivity.java index 77ade5a..f7eacd3 100644 --- a/src/main/java/net/micode/notes/ui/NotesListActivity.java +++ b/src/main/java/net/micode/notes/ui/NotesListActivity.java @@ -406,6 +406,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt }; + //TODO add comments of this method private void startAsyncNotesListQuery() { String selection = (mCurrentFolderId == Notes.ID_ROOT_FOLDER) ? ROOT_FOLDER_SELECTION : NORMAL_SELECTION; @@ -504,6 +505,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt }.execute(); } + // TODO add comments of this method private void deleteFolder(long folderId) { if (folderId == Notes.ID_ROOT_FOLDER) { Log.e(TAG, "Wrong folder id, should not happen " + folderId); @@ -538,6 +540,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt this.startActivityForResult(intent, REQUEST_CODE_OPEN_NODE); } + // TODO add comments of this method private void openFolder(NoteItemData data) { mCurrentFolderId = data.getId(); startAsyncNotesListQuery(); @@ -573,6 +576,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0); } + // TODO add comments of this method private void showCreateOrModifyFolderDialog(final boolean create) { final AlertDialog.Builder builder = new AlertDialog.Builder(this); View view = LayoutInflater.from(this).inflate(R.layout.dialog_edit_text, null); @@ -799,12 +803,14 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt return true; } + //TODO add comments of this method @Override public boolean onSearchRequested() { startSearch(null, false, null /* appData */, false); return true; } + //TODO add comments of this method private void exportNoteToText() { final BackupUtils backup = BackupUtils.getInstance(NotesListActivity.this); new AsyncTask() { @@ -898,6 +904,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt } + // TODO add comments of this method private void startQueryDestinationFolders() { String selection = NoteColumns.TYPE + "=? AND " + NoteColumns.PARENT_ID + "<>? AND " + NoteColumns.ID + "<>?"; selection = (mState == ListEditState.NOTE_LIST) ? selection: diff --git a/src/main/res/values/styles.xml b/src/main/res/values/styles.xml index dc09a33..21e7620 100644 --- a/src/main/res/values/styles.xml +++ b/src/main/res/values/styles.xml @@ -63,7 +63,7 @@ \ No newline at end of file