diff --git a/.gitignore b/.gitignore index 75b1fd5..4ffcb90 100644 Binary files a/.gitignore and b/.gitignore differ diff --git a/src/Notesmaster/app/src/main/AndroidManifest.xml b/src/Notesmaster/app/src/main/AndroidManifest.xml index db4380f..a08a1f3 100644 --- a/src/Notesmaster/app/src/main/AndroidManifest.xml +++ b/src/Notesmaster/app/src/main/AndroidManifest.xml @@ -101,6 +101,19 @@ android:windowSoftInputMode="stateVisible|adjustResize" android:exported="false" /> + + + + + + Type : TEXT

*/ public static final String TITLE = "title"; + + /** + * Task Priority: 0=Low/None, 1=Medium, 2=High + *

Type : INTEGER

+ */ + public static final String GTASK_PRIORITY = "gtask_priority"; + + /** + * Task Due Date (Timestamp) + *

Type : INTEGER (long)

+ */ + public static final String GTASK_DUE_DATE = "gtask_due_date"; + + /** + * Task Status: 0=Active, 1=Completed + *

Type : INTEGER

+ */ + public static final String GTASK_STATUS = "gtask_status"; + + /** + * Task Finished Time (Timestamp) + *

Type : INTEGER (long)

+ */ + public static final String GTASK_FINISHED_TIME = "gtask_finished_time"; } public interface DataColumns { diff --git a/src/Notesmaster/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java b/src/Notesmaster/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java index 9c2d7f9..8c6a8e6 100644 --- a/src/Notesmaster/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java +++ b/src/Notesmaster/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java @@ -70,7 +70,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { * 当数据库版本变更时,onUpgrade方法会被调用以执行升级逻辑。 *

*/ - private static final int DB_VERSION = 8; + private static final int DB_VERSION = 9; /** * 数据库表名常量接口 @@ -559,6 +559,12 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { oldVersion++; } + // 从V8升级到V9 + if (oldVersion == 8) { + upgradeToV9(db); + oldVersion++; + } + // 如果需要,重新创建触发器 if (reCreateTriggers) { reCreateNoteTableTriggers(db); @@ -630,6 +636,30 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { + " TEXT NOT NULL DEFAULT ''"); Log.i(TAG, "Fixed: Added missing TITLE column in onOpen"); } + + // Check for missing GTASK columns + boolean hasGTaskColumns = false; + if (cursor != null) { + if (cursor.getColumnIndex(NoteColumns.GTASK_PRIORITY) != -1) { + hasGTaskColumns = true; + } + } + + if (!hasGTaskColumns) { + try { + db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.GTASK_PRIORITY + + " INTEGER NOT NULL DEFAULT 0"); + db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.GTASK_DUE_DATE + + " INTEGER NOT NULL DEFAULT 0"); + db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.GTASK_STATUS + + " INTEGER NOT NULL DEFAULT 0"); + db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.GTASK_FINISHED_TIME + + " INTEGER NOT NULL DEFAULT 0"); + Log.i(TAG, "Fixed: Added missing GTASK columns in onOpen"); + } catch (Exception e) { + Log.e(TAG, "Failed to add GTASK columns in onOpen", e); + } + } if (cursor != null) { cursor.close(); @@ -760,4 +790,27 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { Log.e(TAG, "Failed to add TITLE column in V8 upgrade (it probably already exists)", e); } } + + /** + * 升级数据库到V9版本 + *

+ * 添加GTASK相关列:优先级、截止日期、状态、完成时间。 + *

+ * + * @param db SQLiteDatabase实例 + */ + private void upgradeToV9(SQLiteDatabase db) { + try { + db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.GTASK_PRIORITY + + " INTEGER NOT NULL DEFAULT 0"); + db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.GTASK_DUE_DATE + + " INTEGER NOT NULL DEFAULT 0"); + db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.GTASK_STATUS + + " INTEGER NOT NULL DEFAULT 0"); + db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.GTASK_FINISHED_TIME + + " INTEGER NOT NULL DEFAULT 0"); + } catch (Exception e) { + Log.e(TAG, "Failed to add GTASK columns in V9 upgrade", e); + } + } } diff --git a/src/Notesmaster/app/src/main/java/net/micode/notes/data/NotesRepository.java b/src/Notesmaster/app/src/main/java/net/micode/notes/data/NotesRepository.java index b07132d..2bf9f83 100644 --- a/src/Notesmaster/app/src/main/java/net/micode/notes/data/NotesRepository.java +++ b/src/Notesmaster/app/src/main/java/net/micode/notes/data/NotesRepository.java @@ -231,13 +231,13 @@ public class NotesRepository { String[] selectionArgs; if (folderId == Notes.ID_ROOT_FOLDER) { - // 根文件夹:显示所有文件夹和便签 - selection = "(" + NoteColumns.TYPE + "<>" + Notes.TYPE_SYSTEM + " AND " + NoteColumns.PARENT_ID + "=?) OR (" + + // 根文件夹:显示所有文件夹和便签 (排除系统文件夹和待办任务) + selection = "(" + NoteColumns.TYPE + "<>" + Notes.TYPE_SYSTEM + " AND " + NoteColumns.TYPE + "<>" + Notes.TYPE_TASK + " AND " + NoteColumns.PARENT_ID + "=?) OR (" + NoteColumns.ID + "=" + Notes.ID_CALL_RECORD_FOLDER + " AND " + NoteColumns.NOTES_COUNT + ">0)"; selectionArgs = new String[]{String.valueOf(Notes.ID_ROOT_FOLDER)}; } else { - // 子文件夹:显示该文件夹下的文件夹和便签 - selection = NoteColumns.PARENT_ID + "=? AND " + NoteColumns.TYPE + "<>" + Notes.TYPE_SYSTEM; + // 子文件夹:显示该文件夹下的文件夹和便签 (排除系统文件夹和待办任务) + selection = NoteColumns.PARENT_ID + "=? AND " + NoteColumns.TYPE + "<>" + Notes.TYPE_SYSTEM + " AND " + NoteColumns.TYPE + "<>" + Notes.TYPE_TASK; selectionArgs = new String[]{String.valueOf(folderId)}; } diff --git a/src/Notesmaster/app/src/main/java/net/micode/notes/tool/DataUtils.java b/src/Notesmaster/app/src/main/java/net/micode/notes/tool/DataUtils.java index d982351..d237122 100644 --- a/src/Notesmaster/app/src/main/java/net/micode/notes/tool/DataUtils.java +++ b/src/Notesmaster/app/src/main/java/net/micode/notes/tool/DataUtils.java @@ -1,19 +1,3 @@ -/* - * Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - package net.micode.notes.tool; import android.content.ContentProviderOperation; @@ -414,6 +398,32 @@ public class DataUtils { } throw new IllegalArgumentException("Note is not found with id: " + noteId); } + + /** + * 根据笔记 ID 获取类型 + * + * @param resolver ContentResolver 对象 + * @param noteId 笔记 ID + * @return 笔记类型 + * @throws IllegalArgumentException 如果笔记不存在 + */ + public static int getNoteTypeById(ContentResolver resolver, long noteId) { + Cursor cursor = resolver.query(Notes.CONTENT_NOTE_URI, + new String [] { NoteColumns.TYPE }, + NoteColumns.ID + "=?", + new String [] { String.valueOf(noteId)}, + null); + + if (cursor != null) { + int type = -1; + if (cursor.moveToFirst()) { + type = cursor.getInt(0); + } + cursor.close(); + return type; + } + throw new IllegalArgumentException("Note is not found with id: " + noteId); + } /** * 格式化摘要内容 diff --git a/src/Notesmaster/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java b/src/Notesmaster/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java index 09181bf..0ae8cab 100644 --- a/src/Notesmaster/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java +++ b/src/Notesmaster/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java @@ -63,6 +63,8 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD private static final int SNIPPET_PREW_MAX_LEN = 60; // 媒体播放器,用于播放闹钟声音 MediaPlayer mPlayer; + // 笔记类型 + private int mNoteType; /** * 活动创建时的初始化方法 @@ -102,6 +104,8 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD mNoteId = Long.valueOf(intent.getData().getPathSegments().get(1)); // 通过笔记ID获取笔记内容摘要 mSnippet = DataUtils.getSnippetById(this.getContentResolver(), mNoteId); + // 获取笔记类型 + mNoteType = DataUtils.getNoteTypeById(this.getContentResolver(), mNoteId); // 如果摘要超过最大长度,截取并添加省略号 mSnippet = mSnippet.length() > SNIPPET_PREW_MAX_LEN ? mSnippet.substring(0, SNIPPET_PREW_MAX_LEN) + getResources().getString(R.string.notelist_string_info) @@ -114,7 +118,7 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD // 初始化媒体播放器 mPlayer = new MediaPlayer(); // 检查笔记是否在数据库中存在且可见 - if (DataUtils.visibleInNoteDatabase(getContentResolver(), mNoteId, Notes.TYPE_NOTE)) { + if (DataUtils.visibleInNoteDatabase(getContentResolver(), mNoteId, mNoteType)) { // 显示操作对话框 showActionDialog(); // 播放闹钟声音 @@ -212,13 +216,20 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD switch (which) { // 如果点击了"查看笔记"按钮(负按钮) case DialogInterface.BUTTON_NEGATIVE: - // 创建跳转到笔记编辑活动的Intent - Intent intent = new Intent(this, NoteEditActivity.class); - // 设置动作为查看 - intent.setAction(Intent.ACTION_VIEW); - // 传递笔记ID - intent.putExtra(Intent.EXTRA_UID, mNoteId); - // 启动笔记编辑活动 + Intent intent; + if (mNoteType == Notes.TYPE_TASK) { + // 如果是待办任务,跳转到任务编辑活动 + intent = new Intent(this, TaskEditActivity.class); + intent.putExtra(Intent.EXTRA_UID, mNoteId); + } else { + // 创建跳转到笔记编辑活动的Intent + intent = new Intent(this, NoteEditActivity.class); + // 设置动作为查看 + intent.setAction(Intent.ACTION_VIEW); + // 传递笔记ID + intent.putExtra(Intent.EXTRA_UID, mNoteId); + } + // 启动活动 startActivity(intent); break; // 默认情况(点击"确定"按钮) diff --git a/src/Notesmaster/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java b/src/Notesmaster/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java index d7993be..7c25fdf 100644 --- a/src/Notesmaster/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java +++ b/src/Notesmaster/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java @@ -1572,7 +1572,7 @@ public class NoteEditActivity extends AppCompatActivity implements OnClickListen } @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { + protected3 void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_CODE_PICK_WALLPAPER && resultCode == RESULT_OK && data != null) { android.net.Uri uri = data.getData(); diff --git a/src/Notesmaster/app/src/main/java/net/micode/notes/ui/NotesListActivity.java b/src/Notesmaster/app/src/main/java/net/micode/notes/ui/NotesListActivity.java index da74a11..32a837c 100644 --- a/src/Notesmaster/app/src/main/java/net/micode/notes/ui/NotesListActivity.java +++ b/src/Notesmaster/app/src/main/java/net/micode/notes/ui/NotesListActivity.java @@ -745,6 +745,10 @@ public class NotesListActivity extends AppCompatActivity int itemId = item.getItemId(); switch (itemId) { + case R.id.menu_tasks: + startActivity(new Intent(this, TaskListActivity.class)); + overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left); + return true; case R.id.menu_search: Intent searchIntent = new Intent(this, NoteSearchActivity.class); startActivity(searchIntent); diff --git a/src/Notesmaster/app/src/main/res/menu/note_list.xml b/src/Notesmaster/app/src/main/res/menu/note_list.xml index 42ea736..95135a1 100644 --- a/src/Notesmaster/app/src/main/res/menu/note_list.xml +++ b/src/Notesmaster/app/src/main/res/menu/note_list.xml @@ -15,8 +15,15 @@ limitations under the License. --> - + + + + diff --git a/src/Notesmaster/app/src/main/res/values/colors.xml b/src/Notesmaster/app/src/main/res/values/colors.xml index 2495561..c07b5f2 100644 --- a/src/Notesmaster/app/src/main/res/values/colors.xml +++ b/src/Notesmaster/app/src/main/res/values/colors.xml @@ -17,6 +17,8 @@ #335b5b5b + #FFFFFF + #000000 #263238 #FFFFFF #E8E8E8 diff --git a/src/Notesmaster/app/src/main/res/values/themes.xml b/src/Notesmaster/app/src/main/res/values/themes.xml index ee1d329..d7df94f 100644 --- a/src/Notesmaster/app/src/main/res/values/themes.xml +++ b/src/Notesmaster/app/src/main/res/values/themes.xml @@ -4,6 +4,9 @@ @color/primary_color @color/on_primary_color @color/primary_color + + @color/background_color + @color/background_color @android:color/transparent