diff --git a/Notes-master2/.gradle/7.5/executionHistory/executionHistory.bin b/Notes-master2/.gradle/7.5/executionHistory/executionHistory.bin index a6577f1..72a6c5a 100644 Binary files a/Notes-master2/.gradle/7.5/executionHistory/executionHistory.bin and b/Notes-master2/.gradle/7.5/executionHistory/executionHistory.bin differ diff --git a/Notes-master2/.gradle/7.5/executionHistory/executionHistory.lock b/Notes-master2/.gradle/7.5/executionHistory/executionHistory.lock index 2892664..d29b333 100644 Binary files a/Notes-master2/.gradle/7.5/executionHistory/executionHistory.lock and b/Notes-master2/.gradle/7.5/executionHistory/executionHistory.lock differ diff --git a/Notes-master2/.gradle/7.5/fileHashes/fileHashes.bin b/Notes-master2/.gradle/7.5/fileHashes/fileHashes.bin index f8dbb34..4e495bc 100644 Binary files a/Notes-master2/.gradle/7.5/fileHashes/fileHashes.bin and b/Notes-master2/.gradle/7.5/fileHashes/fileHashes.bin differ diff --git a/Notes-master2/.gradle/7.5/fileHashes/fileHashes.lock b/Notes-master2/.gradle/7.5/fileHashes/fileHashes.lock index 91e2322..a7f7607 100644 Binary files a/Notes-master2/.gradle/7.5/fileHashes/fileHashes.lock and b/Notes-master2/.gradle/7.5/fileHashes/fileHashes.lock differ diff --git a/Notes-master2/.gradle/7.5/fileHashes/resourceHashesCache.bin b/Notes-master2/.gradle/7.5/fileHashes/resourceHashesCache.bin index a4f8ba5..5efbc34 100644 Binary files a/Notes-master2/.gradle/7.5/fileHashes/resourceHashesCache.bin and b/Notes-master2/.gradle/7.5/fileHashes/resourceHashesCache.bin differ diff --git a/Notes-master2/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/Notes-master2/.gradle/buildOutputCleanup/buildOutputCleanup.lock index aa0667e..643d742 100644 Binary files a/Notes-master2/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/Notes-master2/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/Notes-master2/.gradle/file-system.probe b/Notes-master2/.gradle/file-system.probe index 0029ddc..9f1e1aa 100644 Binary files a/Notes-master2/.gradle/file-system.probe and b/Notes-master2/.gradle/file-system.probe differ diff --git a/Notes-master2/.idea/.gitignore b/Notes-master2/.idea/.gitignore deleted file mode 100644 index 26d3352..0000000 --- a/Notes-master2/.idea/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml diff --git a/Notes-master2/.idea/compiler.xml b/Notes-master2/.idea/compiler.xml deleted file mode 100644 index b589d56..0000000 --- a/Notes-master2/.idea/compiler.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Notes-master2/.idea/gradle.xml b/Notes-master2/.idea/gradle.xml deleted file mode 100644 index 4e64ab1..0000000 --- a/Notes-master2/.idea/gradle.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/Notes-master2/.idea/jarRepositories.xml b/Notes-master2/.idea/jarRepositories.xml deleted file mode 100644 index a5f05cd..0000000 --- a/Notes-master2/.idea/jarRepositories.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/Notes-master2/.idea/misc.xml b/Notes-master2/.idea/misc.xml deleted file mode 100644 index 8ddd1c7..0000000 --- a/Notes-master2/.idea/misc.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/Notes-master2/app/build/intermediates/apk/debug/app-debug.apk b/Notes-master2/app/build/intermediates/apk/debug/app-debug.apk index 40bbbf5..7bc15ce 100644 Binary files a/Notes-master2/app/build/intermediates/apk/debug/app-debug.apk and b/Notes-master2/app/build/intermediates/apk/debug/app-debug.apk differ diff --git a/Notes-master2/app/build/intermediates/dex/debug/mergeDexDebug/classes.dex b/Notes-master2/app/build/intermediates/dex/debug/mergeDexDebug/classes.dex index 3f9f008..0929139 100644 Binary files a/Notes-master2/app/build/intermediates/dex/debug/mergeDexDebug/classes.dex and b/Notes-master2/app/build/intermediates/dex/debug/mergeDexDebug/classes.dex differ diff --git a/Notes-master2/app/build/intermediates/incremental/packageDebug/tmp/debug/dex-renamer-state.txt b/Notes-master2/app/build/intermediates/incremental/packageDebug/tmp/debug/dex-renamer-state.txt index 2e74251..74b458e 100644 --- a/Notes-master2/app/build/intermediates/incremental/packageDebug/tmp/debug/dex-renamer-state.txt +++ b/Notes-master2/app/build/intermediates/incremental/packageDebug/tmp/debug/dex-renamer-state.txt @@ -1,4 +1,4 @@ -#Fri Apr 14 09:05:03 CST 2023 +#Wed Apr 19 22:32:26 CST 2023 base.0=D\:\\SoftEngineering\\MiNotesPlusDemo\\Notes-master2\\app\\build\\intermediates\\dex\\debug\\mergeDexDebug\\classes.dex renamed.0=classes.dex path.0=classes.dex diff --git a/Notes-master2/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$8.class b/Notes-master2/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$8.class index 81b90b8..a50607a 100644 Binary files a/Notes-master2/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$8.class and b/Notes-master2/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$8.class differ diff --git a/Notes-master2/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$OnListItemClickListener.class b/Notes-master2/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$OnListItemClickListener.class index aa750e3..dc77c5e 100644 Binary files a/Notes-master2/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$OnListItemClickListener.class and b/Notes-master2/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$OnListItemClickListener.class differ diff --git a/Notes-master2/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity.class b/Notes-master2/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity.class index 26f0ffe..38309dd 100644 Binary files a/Notes-master2/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity.class and b/Notes-master2/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity.class differ diff --git a/Notes-master2/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$8.dex b/Notes-master2/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$8.dex index 5fa2922..a89aa2d 100644 Binary files a/Notes-master2/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$8.dex and b/Notes-master2/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$8.dex differ diff --git a/Notes-master2/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$OnListItemClickListener.dex b/Notes-master2/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$OnListItemClickListener.dex index 9b20419..1d5ae52 100644 Binary files a/Notes-master2/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$OnListItemClickListener.dex and b/Notes-master2/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$OnListItemClickListener.dex differ diff --git a/Notes-master2/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity.dex b/Notes-master2/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity.dex index d45f055..f5f98f2 100644 Binary files a/Notes-master2/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity.dex and b/Notes-master2/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity.dex differ diff --git a/Notes-master2/app/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin b/Notes-master2/app/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin index adf8c66..eb1e648 100644 Binary files a/Notes-master2/app/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin and b/Notes-master2/app/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin differ diff --git a/Notes-master2/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java b/Notes-master2/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java index 85723be..13ba1b5 100644 --- a/Notes-master2/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java +++ b/Notes-master2/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java @@ -39,13 +39,19 @@ import net.micode.notes.tool.DataUtils; import java.io.IOException; - +/** + * 报警提示活动 + */ public class AlarmAlertActivity extends Activity implements OnClickListener, OnDismissListener { - private long mNoteId; - private String mSnippet; + private long mNoteId;//文本在数据库中的id号 + private String mSnippet;//闹钟提示时显示的文字 private static final int SNIPPET_PREW_MAX_LEN = 60; MediaPlayer mPlayer; + /** + * 能从onCreate的参数savedInsanceState中获得状态数据 + * @param savedInstanceState saveInstanceState方法是用来保存Activity的状态的 + */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -56,19 +62,27 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD if (!isScreenOn()) { win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON + //保持窗体显示 | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON + //将窗体显示 | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON + //允许窗体显示时锁屏 | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR); - } + }//在手机锁屏后如果到了闹钟提示时间,显示屏幕 Intent intent = getIntent(); try { - mNoteId = Long.valueOf(intent.getData().getPathSegments().get(1)); + //将Long.valueOf升级为Long.parseLong + //在字符串转换为long类型的数据时,如果只需要转换为基础类型,用Long.parseLong性能较好;如果需要获得Long对象,并且数值在-128到127之间,Long.valueOf性能比较好 + mNoteId = Long.parseLong(intent.getData().getPathSegments().get(1)); mSnippet = DataUtils.getSnippetById(this.getContentResolver(), mNoteId); + //根据ID从数据库中获取标签的内容; + //getContentResolver() 是实现数据共享,实例存储。 mSnippet = mSnippet.length() > SNIPPET_PREW_MAX_LEN ? mSnippet.substring(0, SNIPPET_PREW_MAX_LEN) + getResources().getString(R.string.notelist_string_info) : mSnippet; + //判断标签片段是否达到符合长度 } catch (IllegalArgumentException e) { e.printStackTrace(); return; @@ -77,19 +91,25 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD mPlayer = new MediaPlayer(); if (DataUtils.visibleInNoteDatabase(getContentResolver(), mNoteId, Notes.TYPE_NOTE)) { showActionDialog(); + //弹出对话框 playAlarmSound(); + //闹钟提示音激发 } else { finish(); + //完成闹钟动作 } } private boolean isScreenOn() { + //判断屏幕是否锁屏,调用系统函数判断,最后返回值是布尔类型 PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); return pm.isScreenOn(); } private void playAlarmSound() { + //闹钟提示音激发 Uri url = RingtoneManager.getActualDefaultRingtoneUri(this, RingtoneManager.TYPE_ALARM); + //调用系统的铃声管理URI,得到闹钟提示音 int silentModeStreams = Settings.System.getInt(getContentResolver(), Settings.System.MODE_RINGER_STREAMS_AFFECTED, 0); @@ -100,9 +120,13 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD mPlayer.setAudioStreamType(AudioManager.STREAM_ALARM); } try { + //得到播放资源 mPlayer.setDataSource(this, url); + //播放准备 mPlayer.prepare(); + //设置是否循环播放 mPlayer.setLooping(true); + //播放开始 mPlayer.start(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block @@ -120,9 +144,13 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD } private void showActionDialog() { + //AlertDialog的构造方法是Protected,所以不能直接通过new一个AlertDialog来创建出一个AlertDialog AlertDialog.Builder dialog = new AlertDialog.Builder(this); + //为对话框设置标题 dialog.setTitle(R.string.app_name); + //设置消息 dialog.setMessage(mSnippet); + //设置活动按钮 dialog.setPositiveButton(R.string.notealert_ok, this); if (isScreenOn()) { dialog.setNegativeButton(R.string.notealert_enter, this); @@ -130,6 +158,11 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD dialog.show().setOnDismissListener(this); } + /** + * 点击按钮 + * @param dialog 对话框 + * @param which 按钮选择 + */ public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_NEGATIVE: @@ -143,11 +176,18 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD } } + /** + * 停止闹钟 + * @param dialog 对话 + */ public void onDismiss(DialogInterface dialog) { stopAlarmSound(); finish(); } + /** + * 停止闹钟声音 + */ private void stopAlarmSound() { if (mPlayer != null) { mPlayer.stop();