staz 2 months ago
parent 93738b89ea
commit 353804a2b8

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

@ -17,6 +17,7 @@
package net.micode.notes.data;
import android.net.Uri;
import android.provider.BaseColumns;
/**
* Notes便
@ -30,8 +31,8 @@ public class Notes {
// 便签类型常量
public static final int TYPE_NOTE = 0; // 普通便签
public static final int TYPE_FOLDER = 1; // 文件夹
public static final int TYPE_SYSTEM = 2; // 系统便签
public static final int TYPE_FOLDER = 2; // 文件夹
public static final int TYPE_SYSTEM = 1; // 系统便签
/**
* ID
@ -80,7 +81,7 @@ public class Notes {
* 便
* 便
*/
public interface NoteColumns {
public static class NoteColumns implements BaseColumns {
/**
* ID
* <P> : INTEGER (long) </P>
@ -183,6 +184,18 @@ public class Notes {
* <P> : INTEGER (long) </P>
*/
public static final String VERSION = "version";
/**
*
* <P> : TEXT </P>
*/
public static final String FOLDER_NAME = "folder_name";
/**
* ID
* <P> : INTEGER (long) </P>
*/
public static final String PARENT_FOLDER_ID = "parent_folder_id";
}
/**

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

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

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.constraintlayout.widget.ConstraintLayout>
Loading…
Cancel
Save