diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
类型: INTEGER (long)
@@ -183,6 +184,18 @@ public class Notes { *类型 : INTEGER (long)
*/ public static final String VERSION = "version"; + + /** + * 文件夹名称 + *类型: TEXT
+ */ + public static final String FOLDER_NAME = "folder_name"; + + /** + * 父文件夹ID + *类型: INTEGER (long)
+ */ + public static final String PARENT_FOLDER_ID = "parent_folder_id"; } /** diff --git a/app/src/main/java/net/micode/notes/model/WorkingNote.java b/app/src/main/java/net/micode/notes/model/WorkingNote.java index be081e4..5f9734a 100644 --- a/app/src/main/java/net/micode/notes/model/WorkingNote.java +++ b/app/src/main/java/net/micode/notes/model/WorkingNote.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.model; import android.appwidget.AppWidgetManager; @@ -31,7 +15,6 @@ import net.micode.notes.data.Notes.NoteColumns; import net.micode.notes.data.Notes.TextNote; import net.micode.notes.tool.ResourceParser.NoteBgResources; - public class WorkingNote { // Note for the working note private Note mNote; @@ -62,6 +45,10 @@ public class WorkingNote { private NoteSettingChangedListener mNoteSettingStatusListener; + // 新增文件夹名称和父文件夹ID字段 + private String mFolderName; + private long mParentFolderId; + public static final String[] DATA_PROJECTION = new String[] { DataColumns.ID, DataColumns.CONTENT, @@ -72,13 +59,16 @@ public class WorkingNote { DataColumns.DATA4, }; + // 更新查询投影,包含文件夹相关字段 public static final String[] NOTE_PROJECTION = new String[] { NoteColumns.PARENT_ID, NoteColumns.ALERTED_DATE, NoteColumns.BG_COLOR_ID, NoteColumns.WIDGET_ID, NoteColumns.WIDGET_TYPE, - NoteColumns.MODIFIED_DATE + NoteColumns.MODIFIED_DATE, + NoteColumns.FOLDER_NAME, + NoteColumns.PARENT_FOLDER_ID }; private static final int DATA_ID_COLUMN = 0; @@ -101,6 +91,10 @@ public class WorkingNote { private static final int NOTE_MODIFIED_DATE_COLUMN = 5; + // 新增文件夹名称和父文件夹ID列索引 + private static final int NOTE_FOLDER_NAME_COLUMN = 6; + private static final int NOTE_PARENT_FOLDER_ID_COLUMN = 7; + // New note construct private WorkingNote(Context context, long folderId) { mContext = context; @@ -137,6 +131,9 @@ public class WorkingNote { mWidgetType = cursor.getInt(NOTE_WIDGET_TYPE_COLUMN); mAlertDate = cursor.getLong(NOTE_ALERTED_DATE_COLUMN); mModifiedDate = cursor.getLong(NOTE_MODIFIED_DATE_COLUMN); + // 加载文件夹名称和父文件夹ID + mFolderName = cursor.getString(NOTE_FOLDER_NAME_COLUMN); + mParentFolderId = cursor.getLong(NOTE_PARENT_FOLDER_ID_COLUMN); } cursor.close(); } else { @@ -149,7 +146,7 @@ public class WorkingNote { private void loadNoteData() { Cursor cursor = mContext.getContentResolver().query(Notes.CONTENT_DATA_URI, DATA_PROJECTION, DataColumns.NOTE_ID + "=?", new String[] { - String.valueOf(mNoteId) + String.valueOf(mNoteId) }, null); if (cursor != null) { @@ -175,7 +172,7 @@ public class WorkingNote { } public static WorkingNote createEmptyNote(Context context, long folderId, int widgetId, - int widgetType, int defaultBgColorId) { + int widgetType, int defaultBgColorId) { WorkingNote note = new WorkingNote(context, folderId); note.setBgColorId(defaultBgColorId); note.setWidgetId(widgetId); @@ -243,7 +240,7 @@ public class WorkingNote { mIsDeleted = mark; if (mWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID && mWidgetType != Notes.TYPE_WIDGET_INVALIDE && mNoteSettingStatusListener != null) { - mNoteSettingStatusListener.onWidgetChanged(); + mNoteSettingStatusListener.onWidgetChanged(); } } @@ -342,6 +339,15 @@ public class WorkingNote { return mWidgetType; } + // 新增获取文件夹名称和父文件夹ID的方法 + public String getFolderName() { + return mFolderName; + } + + public long getParentFolderId() { + return mParentFolderId; + } + public interface NoteSettingChangedListener { /** * Called when the background color of current note has just changed @@ -365,4 +371,4 @@ public class WorkingNote { */ void onCheckListModeChanged(int oldMode, int newMode); } -} +} \ No newline at end of file diff --git a/app/src/main/java/net/micode/notes/ui/NotesListAdapter.java b/app/src/main/java/net/micode/notes/ui/NotesListAdapter.java index 51c9cb9..0d67aba 100644 --- a/app/src/main/java/net/micode/notes/ui/NotesListAdapter.java +++ b/app/src/main/java/net/micode/notes/ui/NotesListAdapter.java @@ -172,12 +172,10 @@ public class NotesListAdapter extends CursorAdapter { for (int i = 0; i < getCount(); i++) { Cursor c = (Cursor) getItem(i); if (c != null) { - if (NoteItemData.getNoteType(c) == Notes.TYPE_NOTE) { + int type = NoteItemData.getNoteType(c); + if (type == Notes.TYPE_NOTE) { // 仅统计便签类型 mNotesCount++; } - } else { - Log.e(TAG, "Invalid cursor"); - return; } } } diff --git a/app/src/main/res/layout/item_folder.xml b/app/src/main/res/layout/item_folder.xml new file mode 100644 index 0000000..77d9ef6 --- /dev/null +++ b/app/src/main/res/layout/item_folder.xml @@ -0,0 +1,6 @@ + +