新增待办事项功能

pull/28/head
蒋天翔 4 weeks ago
parent 3277d60c33
commit dce63cb3f1

BIN
.gitignore vendored

Binary file not shown.

@ -101,6 +101,19 @@
android:windowSoftInputMode="stateVisible|adjustResize"
android:exported="false" />
<!-- ==================== 待办任务列表活动 ==================== -->
<activity
android:name=".ui.TaskListActivity"
android:label="Tasks"
android:theme="@style/Theme.Notesmaster" />
<!-- ==================== 待办任务编辑活动 ==================== -->
<activity
android:name=".ui.TaskEditActivity"
android:label="Edit Task"
android:theme="@style/Theme.Notesmaster"
android:windowSoftInputMode="stateVisible|adjustResize" />
<!-- ==================== 内容提供者 ==================== -->
<!-- 提供笔记数据的访问接口,允许其他应用访问笔记数据 -->
<provider

@ -57,6 +57,10 @@ public class Notes {
*
*/
public static final int TYPE_SYSTEM = 2;
/**
*
*/
public static final int TYPE_TASK = 3;
/**
* ID
@ -253,6 +257,30 @@ public class Notes {
* <P> Type : TEXT </P>
*/
public static final String TITLE = "title";
/**
* Task Priority: 0=Low/None, 1=Medium, 2=High
* <P> Type : INTEGER </P>
*/
public static final String GTASK_PRIORITY = "gtask_priority";
/**
* Task Due Date (Timestamp)
* <P> Type : INTEGER (long) </P>
*/
public static final String GTASK_DUE_DATE = "gtask_due_date";
/**
* Task Status: 0=Active, 1=Completed
* <P> Type : INTEGER </P>
*/
public static final String GTASK_STATUS = "gtask_status";
/**
* Task Finished Time (Timestamp)
* <P> Type : INTEGER (long) </P>
*/
public static final String GTASK_FINISHED_TIME = "gtask_finished_time";
}
public interface DataColumns {

@ -70,7 +70,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
* onUpgrade
* </p>
*/
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
* <p>
* GTASK
* </p>
*
* @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);
}
}
}

@ -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)};
}

@ -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);
}
/**
*

@ -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;
// 默认情况(点击"确定"按钮)

@ -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();

@ -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);

@ -15,8 +15,15 @@
limitations under the License.
-->
<menu
xmlns:android="http://schemas.android.com/apk/res/android">
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_tasks"
android:title="TASKS"
android:icon="@drawable/ic_menu_tasks"
app:showAsAction="always" />
<item
android:id="@+id/menu_new_folder"
android:title="@string/menu_create_folder"/>

@ -17,6 +17,8 @@
<resources>
<color name="user_query_highlight">#335b5b5b</color>
<color name="white">#FFFFFF</color>
<color name="black">#000000</color>
<color name="primary_color">#263238</color>
<color name="on_primary_color">#FFFFFF</color>
<color name="background_color">#E8E8E8</color>

@ -4,6 +4,9 @@
<item name="colorPrimary">@color/primary_color</item>
<item name="colorOnPrimary">@color/on_primary_color</item>
<item name="android:statusBarColor">@color/primary_color</item>
<!-- 强制背景为白色,防止深色模式下黑屏 -->
<item name="android:colorBackground">@color/background_color</item>
<item name="android:windowBackground">@color/background_color</item>
<!-- 透明导航栏支持edge-to-edge显示 -->
<item name="android:navigationBarColor">@android:color/transparent</item>
<!-- 根据内容自动调整状态栏图标颜色(深色背景=浅色图标) -->

Loading…
Cancel
Save