新增富文本编辑功能和插入图片功能

mengcheng_branch
mc19 3 months ago
parent a560e67b48
commit 08f40ae287

@ -78,6 +78,7 @@ public class Notes {
public static class DataConstants {
public static final String NOTE = TextNote.CONTENT_ITEM_TYPE; //文本便签MIME类型
public static final String CALL_NOTE = CallNote.CONTENT_ITEM_TYPE; //通话备忘MIME类型
public static final String IMAGE = ImageData.CONTENT_ITEM_TYPE; //图片MIME类型
}
//七、基础URI
@ -196,6 +197,31 @@ public class Notes {
*/
public static final String GTASK_ID = "gtask_id";
/**
* Alert location latitude
* <P> Type: REAL </P>
*/
public static final String ALERT_LATITUDE = "alert_latitude";
/**
* Alert location longitude
* <P> Type: REAL </P>
*/
public static final String ALERT_LONGITUDE = "alert_longitude";
/**
* Alert location radius
* <P> Type: REAL </P>
*/
public static final String ALERT_RADIUS = "alert_radius";
/**
* Alert location name
* <P> Type: TEXT </P>
*/
public static final String ALERT_LOCATION_NAME = "alert_location_name";
/**
* The version code
* <P> Type : INTEGER (long) </P>
@ -281,6 +307,18 @@ public class Notes {
* <P> Type: TEXT </P>
*/
public static final String DATA5 = "data5";
/**
* Rich text format information for storing span information
* <P> Type: TEXT </P>
*/
public static final String RICH_TEXT_FORMAT = "rich_text_format";
/**
* Path to the image file for image data
* <P> Type: TEXT </P>
*/
public static final String IMAGE_PATH = "image_path";
}
@ -325,4 +363,21 @@ public class Notes {
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/call_note");
}
/**
*
*/
public static final class ImageData implements DataColumns {
/**
* Path to the image file
* <P> Type: TEXT </P>
*/
public static final String PATH = DATA3;
public static final String CONTENT_TYPE = "vnd.android.cursor.dir/image_data";
public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/image_data";
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/image_data");
}
}

@ -54,7 +54,8 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
*/
private static final String DB_NAME = "note.db";
private static final int DB_VERSION = 4;
private static final int DB_VERSION = 6;
/**表明常量接口*/
public interface TABLE {
@ -401,6 +402,16 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
oldVersion++;
}
if (oldVersion == 4) {
upgradeToV5(db);
oldVersion++;
}
if (oldVersion == 5) {
upgradeToV6(db);
oldVersion++;
}
if (reCreateTriggers) {
reCreateNoteTableTriggers(db);
reCreateDataTableTriggers(db);
@ -441,4 +452,15 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.VERSION
+ " INTEGER NOT NULL DEFAULT 0");
}
//v4到v5的升级为data表新增rich_text_format列用于存储富文本格式信息
private void upgradeToV5(SQLiteDatabase db) {
db.execSQL("ALTER TABLE " + TABLE.DATA + " ADD COLUMN rich_text_format TEXT NOT NULL DEFAULT ''");
}
//v5到v6的升级为data表新增用于存储图片路径的列
private void upgradeToV6(SQLiteDatabase db) {
// 为data表添加一个专门存储图片路径的列
db.execSQL("ALTER TABLE " + TABLE.DATA + " ADD COLUMN image_path TEXT NOT NULL DEFAULT ''");
}
}

@ -110,6 +110,15 @@ public class Note {
mNoteData.setCallData(key, value);
}
public void setRichTextFormat(String formatInfo) {
mNoteData.setRichTextFormat(formatInfo);
}
// 设置图片数据
public void setImageData(String key, String value) {
mNoteData.setImageData(key, value);
}
//是否有本地修改
public boolean isLocalModified() {
return mNoteDiffValues.size() > 0 || mNoteData.isLocalModified();
@ -157,6 +166,10 @@ public class Note {
private ContentValues mTextDataValues; // 存储文本数据的变化
private ContentValues mRichTextFormatValues; // 存储富文本格式信息
private ContentValues mImageDataValues; // 存储图片数据的变化
private long mCallDataId; // 通话记录数据在数据库中的ID0表示未创建
private ContentValues mCallDataValues; // 存储通话数据的变化(如号码更新)
@ -165,13 +178,15 @@ public class Note {
public NoteData() {
mTextDataValues = new ContentValues();
mRichTextFormatValues = new ContentValues();
mImageDataValues = new ContentValues();
mCallDataValues = new ContentValues();
mTextDataId = 0;
mCallDataId = 0;
}
boolean isLocalModified() {
return mTextDataValues.size() > 0 || mCallDataValues.size() > 0;
return mTextDataValues.size() > 0 || mCallDataValues.size() > 0 || mImageDataValues.size() > 0;
}
void setTextDataId(long id) {
@ -200,6 +215,18 @@ public class Note {
mNoteDiffValues.put(NoteColumns.MODIFIED_DATE, System.currentTimeMillis());
}
void setRichTextFormat(String formatInfo) {
mRichTextFormatValues.put(DataColumns.RICH_TEXT_FORMAT, formatInfo);
mNoteDiffValues.put(NoteColumns.LOCAL_MODIFIED, 1);
mNoteDiffValues.put(NoteColumns.MODIFIED_DATE, System.currentTimeMillis());
}
void setImageData(String key, String value) {
mImageDataValues.put(key, value);
mNoteDiffValues.put(NoteColumns.LOCAL_MODIFIED, 1);
mNoteDiffValues.put(NoteColumns.MODIFIED_DATE, System.currentTimeMillis());
}
/**
* /
* ID=0ID>0
@ -221,22 +248,27 @@ public class Note {
ContentProviderOperation.Builder builder = null;
//处理文本数据同步
if(mTextDataValues.size() > 0) {
if(mTextDataValues.size() > 0 || mRichTextFormatValues.size() > 0) {
// 关联文本数据到当前笔记
mTextDataValues.put(DataColumns.NOTE_ID, noteId);
//合并文本数据和富文本格式信息
ContentValues combinedValues = new ContentValues(mTextDataValues);
combinedValues.putAll(mRichTextFormatValues);
//文本数据未创建
if (mTextDataId == 0) {
// 插入数据到ContentProvider获取返回的Uri
mTextDataValues.put(DataColumns.MIME_TYPE, TextNote.CONTENT_ITEM_TYPE);
combinedValues.put(DataColumns.MIME_TYPE, TextNote.CONTENT_ITEM_TYPE);
Uri uri = context.getContentResolver().insert(Notes.CONTENT_DATA_URI,
mTextDataValues);
combinedValues);
try {
// 从Uri解析新插入的文本数据ID并存储
setTextDataId(Long.valueOf(uri.getPathSegments().get(1)));
} catch (NumberFormatException e) {
Log.e(TAG, "Insert new text data fail with noteId" + noteId);
mTextDataValues.clear();
mRichTextFormatValues.clear();
return null;
}
} else {
@ -244,10 +276,42 @@ public class Note {
// 构建更新操作指定数据ID对应的Uri
builder = ContentProviderOperation.newUpdate(ContentUris.withAppendedId(
Notes.CONTENT_DATA_URI, mTextDataId));
builder.withValues(mTextDataValues); // 设置要更新的内容
builder.withValues(combinedValues); // 设置要更新的内容
operationList.add(builder.build()); // 添加到批量操作列表
}
mTextDataValues.clear();
mRichTextFormatValues.clear();
}
//处理图片数据同步
if(mImageDataValues.size() > 0) {
mImageDataValues.put(DataColumns.NOTE_ID, noteId);
if (mTextDataId == 0) { // 使用文本数据ID作为参考因为图片通常与文本数据一起存储
mImageDataValues.put(DataColumns.MIME_TYPE, Notes.DataConstants.IMAGE);
Uri uri = context.getContentResolver().insert(Notes.CONTENT_DATA_URI,
mImageDataValues);
try {
// 图片数据ID可能需要单独处理这里简化处理
Log.d(TAG, "Inserting image data");
} catch (Exception e) {
Log.e(TAG, "Insert new image data fail with noteId" + noteId);
mImageDataValues.clear();
return null;
}
} else {
// 如果文本数据已存在,我们需要为图片数据创建新的记录
mImageDataValues.put(DataColumns.MIME_TYPE, Notes.DataConstants.IMAGE);
Uri uri = context.getContentResolver().insert(Notes.CONTENT_DATA_URI,
mImageDataValues);
try {
Log.d(TAG, "Inserting additional image data");
} catch (Exception e) {
Log.e(TAG, "Insert additional image data fail with noteId" + noteId);
mImageDataValues.clear();
return null;
}
}
mImageDataValues.clear();
}
//处理通话数据同步(逻辑同处理文本数据同步)

@ -28,6 +28,7 @@ import net.micode.notes.data.Notes.CallNote;
import net.micode.notes.data.Notes.DataColumns;
import net.micode.notes.data.Notes.DataConstants;
import net.micode.notes.data.Notes.NoteColumns;
import net.micode.notes.data.Notes;
import net.micode.notes.data.Notes.TextNote;
import net.micode.notes.tool.ResourceParser.NoteBgResources;
@ -46,6 +47,10 @@ public class WorkingNote {
private int mMode;
private long mAlertDate;
private double mAlertLatitude;
private double mAlertLongitude;
private float mAlertRadius;
private String mAlertLocationName;
private long mModifiedDate;
@ -64,6 +69,7 @@ public class WorkingNote {
private boolean mIsDeleted;
private NoteSettingChangedListener mNoteSettingStatusListener;
private String mRichTextFormatInfo;
//指定查询Data表时需要返回的字段
public static final String[] DATA_PROJECTION = new String[] {
@ -74,6 +80,9 @@ public class WorkingNote {
DataColumns.DATA2,
DataColumns.DATA3,
DataColumns.DATA4,
DataColumns.DATA5,
DataColumns.RICH_TEXT_FORMAT,
DataColumns.IMAGE_PATH,
};
//指定查询Note表时需要返回的字段
@ -83,7 +92,11 @@ public class WorkingNote {
NoteColumns.BG_COLOR_ID,
NoteColumns.WIDGET_ID,
NoteColumns.WIDGET_TYPE,
NoteColumns.MODIFIED_DATE
NoteColumns.MODIFIED_DATE,
NoteColumns.ALERT_LATITUDE,
NoteColumns.ALERT_LONGITUDE,
NoteColumns.ALERT_RADIUS,
NoteColumns.ALERT_LOCATION_NAME
};
private static final int DATA_ID_COLUMN = 0;
@ -94,6 +107,10 @@ public class WorkingNote {
private static final int DATA_MODE_COLUMN = 3;
private static final int DATA_RICH_TEXT_FORMAT_COLUMN = 8;
private static final int DATA_IMAGE_PATH_COLUMN = 9;
private static final int NOTE_PARENT_ID_COLUMN = 0;
private static final int NOTE_ALERTED_DATE_COLUMN = 1;
@ -105,11 +122,19 @@ public class WorkingNote {
private static final int NOTE_WIDGET_TYPE_COLUMN = 4;
private static final int NOTE_MODIFIED_DATE_COLUMN = 5;
private static final int NOTE_ALERT_LATITUDE_COLUMN = 6;
private static final int NOTE_ALERT_LONGITUDE_COLUMN = 7;
private static final int NOTE_ALERT_RADIUS_COLUMN = 8;
private static final int NOTE_ALERT_LOCATION_NAME_COLUMN = 9;
// New note construct
private WorkingNote(Context context, long folderId) {
mContext = context;
mAlertDate = 0;
mAlertLatitude = 0;
mAlertLongitude = 0;
mAlertRadius = 0;
mAlertLocationName = "";
mModifiedDate = System.currentTimeMillis();
mFolderId = folderId;
mNote = new Note();
@ -147,6 +172,14 @@ public class WorkingNote {
mWidgetType = cursor.getInt(NOTE_WIDGET_TYPE_COLUMN);
mAlertDate = cursor.getLong(NOTE_ALERTED_DATE_COLUMN);
mModifiedDate = cursor.getLong(NOTE_MODIFIED_DATE_COLUMN);
// 经纬度和提醒位置
mAlertLatitude = cursor.getDouble(NOTE_ALERT_LATITUDE_COLUMN);
mAlertLongitude = cursor.getDouble(NOTE_ALERT_LONGITUDE_COLUMN);
mAlertRadius = cursor.getFloat(NOTE_ALERT_RADIUS_COLUMN);
mAlertLocationName = cursor.getString(NOTE_ALERT_LOCATION_NAME_COLUMN);
// 加载富文本格式信息
mRichTextFormatInfo = cursor.getString(DATA_RICH_TEXT_FORMAT_COLUMN);
}
cursor.close();
} else {
@ -173,8 +206,15 @@ public class WorkingNote {
mContent = cursor.getString(DATA_CONTENT_COLUMN);
mMode = cursor.getInt(DATA_MODE_COLUMN);
mNote.setTextDataId(cursor.getLong(DATA_ID_COLUMN));
// 加载富文本格式信息
mRichTextFormatInfo = cursor.getString(DATA_RICH_TEXT_FORMAT_COLUMN);
}
//如果是图片类型
else if (DataConstants.IMAGE.equals(type)) {
// 图片数据目前我们只是加载数据实际图片显示在UI层处理
String imagePath = cursor.getString(DATA_IMAGE_PATH_COLUMN);
Log.d(TAG, "Loaded image data: " + imagePath);
}
//如果是通话记录类型
else if (DataConstants.CALL_NOTE.equals(type)) {
mNote.setCallDataId(cursor.getLong(DATA_ID_COLUMN));
@ -323,6 +363,18 @@ public class WorkingNote {
}
}
//设置富文本格式
public void setRichTextFormat(String formatInfo) {
if (!TextUtils.equals(mRichTextFormatInfo, formatInfo)) {
mRichTextFormatInfo = formatInfo;
mNote.setRichTextFormat(formatInfo);
}
}
public String getRichTextFormat() {
return mRichTextFormatInfo;
}
// 将笔记转换为通话笔记(设置通话相关数据)
public void convertToCallNote(String phoneNumber, long callDate) {
mNote.setCallData(CallNote.CALL_DATE, String.valueOf(callDate));
@ -334,6 +386,47 @@ public class WorkingNote {
return (mAlertDate > 0 ? true : false);
}
public boolean hasLocationAlert() {
return (mAlertLatitude != 0 && mAlertLongitude != 0);
}
public void setAlertLocation(double latitude, double longitude, float radius, String locationName, boolean set) {
// 有位置变化才更新
if (latitude != mAlertLatitude || longitude != mAlertLongitude || radius != mAlertRadius || !locationName.equals(mAlertLocationName)) {
mAlertLatitude = latitude;
mAlertLongitude = longitude;
mAlertRadius = radius;
mAlertLocationName = locationName;
mNote.setNoteValue(NoteColumns.ALERT_LATITUDE, String.valueOf(mAlertLatitude));
mNote.setNoteValue(NoteColumns.ALERT_LONGITUDE, String.valueOf(mAlertLongitude));
mNote.setNoteValue(NoteColumns.ALERT_RADIUS, String.valueOf(mAlertRadius));
mNote.setNoteValue(NoteColumns.ALERT_LOCATION_NAME, mAlertLocationName);
}
// 若监听器不为空,触发位置提醒变更回调
if (mNoteSettingStatusListener != null) {
mNoteSettingStatusListener.onLocationAlertChanged(latitude, longitude, radius, locationName, set);
}
}
public double getAlertLatitude() {
return mAlertLatitude;
}
public double getAlertLongitude() {
return mAlertLongitude;
}
public float getAlertRadius() {
return mAlertRadius;
}
public String getAlertLocationName() {
return mAlertLocationName;
}
public String getContent() {
return mContent;
}
@ -378,6 +471,11 @@ public class WorkingNote {
return mWidgetType;
}
public Note getNote() {
return mNote;
}
// 笔记设置变更监听器接口(定义属性变化时的回调方法)
public interface NoteSettingChangedListener {
/**
@ -390,6 +488,12 @@ public class WorkingNote {
*/
void onClockAlertChanged(long date, boolean set);
/**
* Called when user set location alert
*/
void onLocationAlertChanged(double latitude, double longitude, float radius, String locationName, boolean set);
/**
* Call when user create note from widget
*/

@ -313,7 +313,7 @@ public class BackupUtils {
Notes.CONTENT_NOTE_URI,
NOTE_PROJECTION,
"(" + NoteColumns.TYPE + "=" + Notes.TYPE_FOLDER + " AND "
+ NoteColumns.PARENT_ID + "<>" + Notes.ID_TRASH_FOLER + ") OR "
+ NoteColumns.PARENT_ID + "<>" + Notes.ID_TRASH_FOLDER + ") OR "
+ NoteColumns.ID + "=" + Notes.ID_CALL_RECORD_FOLDER, null, null);
if (folderCursor != null) {

@ -158,7 +158,7 @@ public class DataUtils {
Cursor cursor =resolver.query(Notes.CONTENT_NOTE_URI,
new String[] { "COUNT(*)" },
NoteColumns.TYPE + "=? AND " + NoteColumns.PARENT_ID + "<>?",
new String[] { String.valueOf(Notes.TYPE_FOLDER), String.valueOf(Notes.ID_TRASH_FOLER)},
new String[] { String.valueOf(Notes.TYPE_FOLDER), String.valueOf(Notes.ID_TRASH_FOLDER)},
null);
int count = 0;
@ -186,7 +186,7 @@ public class DataUtils {
public static boolean visibleInNoteDatabase(ContentResolver resolver, long noteId, int type) {
Cursor cursor = resolver.query(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId),
null,
NoteColumns.TYPE + "=? AND " + NoteColumns.PARENT_ID + "<>" + Notes.ID_TRASH_FOLER,
NoteColumns.TYPE + "=? AND " + NoteColumns.PARENT_ID + "<>" + Notes.ID_TRASH_FOLDER,
new String [] {String.valueOf(type)},
null);
@ -249,7 +249,7 @@ public class DataUtils {
public static boolean checkVisibleFolderName(ContentResolver resolver, String name) {
Cursor cursor = resolver.query(Notes.CONTENT_NOTE_URI, null,
NoteColumns.TYPE + "=" + Notes.TYPE_FOLDER +
" AND " + NoteColumns.PARENT_ID + "<>" + Notes.ID_TRASH_FOLER +
" AND " + NoteColumns.PARENT_ID + "<>" + Notes.ID_TRASH_FOLDER +
" AND " + NoteColumns.SNIPPET + "=?",
new String[] { name }, null);
boolean exist = false;

@ -0,0 +1,103 @@
/*
* 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.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.style.ImageSpan;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
/**
* SpanSpannable
*/
public class ImageSpanUtils {
/**
* SpannableJSON
*
* @param spannable Spannable
* @param content
* @return JSON
*/
public static String serializeImageInfo(Spannable spannable, String content) {
JSONArray jsonArray = new JSONArray();
// 获取所有图片Span
ImageSpan[] imageSpans = spannable.getSpans(0, spannable.length(), ImageSpan.class);
for (ImageSpan span : imageSpans) {
JSONObject spanObj = new JSONObject();
try {
int start = spannable.getSpanStart(span);
int end = spannable.getSpanEnd(span);
// 获取图片URI如果有的话
Drawable drawable = span.getDrawable();
if (drawable != null) {
// 这里我们假设图片信息已经在其他地方存储,只需记录位置和路径
// 在实际实现中,你可能需要将图片保存到特定位置并记录路径
spanObj.put("type", "image");
spanObj.put("start", start);
spanObj.put("end", end);
// 注意ImageSpan通常不直接存储URI需要额外的机制来跟踪图片路径
// 这里仅为示例,实际实现需要根据具体情况调整
}
} catch (JSONException e) {
e.printStackTrace();
}
}
return jsonArray.toString();
}
/**
* JSON
*
* @param context
* @param text
* @param imageJson JSON
* @return SpannableStringBuilder
*/
public static SpannableStringBuilder deserializeImageInfo(Context context, String text, String imageJson) {
SpannableStringBuilder spannable = new SpannableStringBuilder(text);
if (imageJson == null || imageJson.isEmpty()) {
return spannable;
}
try {
// 这里需要根据实际的图片存储机制来实现
// 因为图片通常需要特殊处理,这里暂时返回原始文本
// 实际实现需要考虑如何存储和检索图片
return spannable;
} catch (Exception e) {
e.printStackTrace();
}
return spannable;
}
}

@ -0,0 +1,116 @@
package net.micode.notes.tool;
import android.text.Editable;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.style.StyleSpan;
import android.text.style.UnderlineSpan;
import android.text.style.StrikethroughSpan;
import android.graphics.Typeface;
import android.text.ParcelableSpan;
import android.text.style.CharacterStyle;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
/**
* Spannable
*/
public class RichTextFormatUtils {
/**
* SpannableJSON
*
* @param spannable Spannable
* @return JSON
*/
public static String serializeFormatInfo(Spannable spannable) {
JSONArray jsonArray = new JSONArray();
// 获取所有字符样式Span
CharacterStyle[] spans = spannable.getSpans(0, spannable.length(), CharacterStyle.class);
for (CharacterStyle span : spans) {
JSONObject spanObj = new JSONObject();
try {
int start = spannable.getSpanStart(span);
int end = spannable.getSpanEnd(span);
int flags = spannable.getSpanFlags(span);
// 识别Span类型并保存相关信息
if (span instanceof StyleSpan) {
StyleSpan styleSpan = (StyleSpan) span;
spanObj.put("type", "style");
spanObj.put("style", styleSpan.getStyle());
} else if (span instanceof UnderlineSpan) {
spanObj.put("type", "underline");
} else if (span instanceof StrikethroughSpan) {
spanObj.put("type", "strikethrough");
} else {
continue; // 不支持的Span类型跳过
}
spanObj.put("start", start);
spanObj.put("end", end);
spanObj.put("flags", flags);
jsonArray.put(spanObj);
} catch (JSONException e) {
e.printStackTrace();
}
}
return jsonArray.toString();
}
/**
* JSON
*
* @param text
* @param formatJson JSON
* @return SpannableStringBuilder
*/
public static SpannableStringBuilder deserializeFormatInfo(String text, String formatJson) {
SpannableStringBuilder spannable = new SpannableStringBuilder(text);
if (formatJson == null || formatJson.isEmpty()) {
return spannable;
}
try {
JSONArray jsonArray = new JSONArray(formatJson);
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject spanObj = jsonArray.getJSONObject(i);
int start = spanObj.getInt("start");
int end = spanObj.getInt("end");
int flags = spanObj.getInt("flags");
String type = spanObj.getString("type");
CharacterStyle span = null;
if ("style".equals(type)) {
int style = spanObj.getInt("style");
span = new StyleSpan(style);
} else if ("underline".equals(type)) {
span = new UnderlineSpan();
} else if ("strikethrough".equals(type)) {
span = new StrikethroughSpan();
}
if (span != null && start >= 0 && end <= text.length() && start < end) {
spannable.setSpan(span, start, end, flags);
}
}
} catch (JSONException e) {
e.printStackTrace();
}
return spannable;
}
}

File diff suppressed because it is too large Load Diff

@ -41,7 +41,7 @@ import java.util.Map;
*
*
*/
public class NoteEditText extends EditText {
public class NoteEditText extends androidx.appcompat.widget.AppCompatEditText {
private static final String TAG = "NoteEditText";
private int mIndex; // 当前编辑框在清单列表中的索引位置
private int mSelectionStartBeforeDelete; // 记录删除操作前光标起始位置
@ -64,6 +64,8 @@ public class NoteEditText extends EditText {
* NoteEditActivity
*/
public interface OnTextViewChangeListener {
void onBackPressedDispatcher();
/**
*
* @param index

@ -599,7 +599,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
} else {
// 同步模式:将笔记移动到垃圾箱文件夹(而不是直接删除)
if (!DataUtils.batchMoveToFolder(mContentResolver, mNotesListAdapter
.getSelectedItemIds(), Notes.ID_TRASH_FOLER)) {
.getSelectedItemIds(), Notes.ID_TRASH_FOLDER)) {
Log.e(TAG, "Move notes to trash folder error, should not happens");
}
}
@ -643,7 +643,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
DataUtils.batchDeleteNotes(mContentResolver, ids);
} else {
// 同步模式:将文件夹移动到垃圾箱
DataUtils.batchMoveToFolder(mContentResolver, ids, Notes.ID_TRASH_FOLER);
DataUtils.batchMoveToFolder(mContentResolver, ids, Notes.ID_TRASH_FOLDER);
}
// 更新关联的小部件
if (widgets != null) {
@ -730,7 +730,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
// 加载对话框布局
View view = LayoutInflater.from(this).inflate(R.layout.dialog_edit_text, null);
final EditText etName = (EditText) view.findViewById(R.id.et_foler_name);
final EditText etName = (EditText) view.findViewById(R.id.et_folder_name);
showSoftInput(); // 显示软键盘
// 根据是创建还是修改设置不同的初始文本和标题
if (!create) {
@ -1146,7 +1146,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
selection,
new String[] {
String.valueOf(Notes.TYPE_FOLDER), // 类型:文件夹
String.valueOf(Notes.ID_TRASH_FOLER), // 排除垃圾箱
String.valueOf(Notes.ID_TRASH_FOLDER), // 排除垃圾箱
String.valueOf(mCurrentFolderId) // 排除当前文件夹
},
NoteColumns.MODIFIED_DATE + " DESC"); // 按修改日期降序排序

@ -27,6 +27,7 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
@ -42,6 +43,8 @@ import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.RequiresApi;
import net.micode.notes.R;
import net.micode.notes.data.Notes;
import net.micode.notes.data.Notes.NoteColumns;
@ -74,6 +77,7 @@ public class NotesPreferenceActivity extends PreferenceActivity {
/**
* Activity
*/
@RequiresApi(api = Build.VERSION_CODES.TIRAMISU)
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
@ -89,7 +93,7 @@ public class NotesPreferenceActivity extends PreferenceActivity {
mReceiver = new GTaskReceiver();
IntentFilter filter = new IntentFilter();
filter.addAction(GTaskSyncService.GTASK_SERVICE_BROADCAST_NAME);
registerReceiver(mReceiver, filter);
registerReceiver(mReceiver, filter, Context.RECEIVER_EXPORTED);
mOriAccounts = null;
// 加载设置页面的自定义头部布局

@ -94,7 +94,7 @@ public abstract class NoteWidgetProvider extends AppWidgetProvider {
return context.getContentResolver().query(Notes.CONTENT_NOTE_URI,
PROJECTION, // 查询的列
NoteColumns.WIDGET_ID + "=? AND " + NoteColumns.PARENT_ID + "<>?", // 查询条件
new String[] { String.valueOf(widgetId), String.valueOf(Notes.ID_TRASH_FOLER) },
new String[] { String.valueOf(widgetId), String.valueOf(Notes.ID_TRASH_FOLDER) },
null); // 排序方式(无)
}

Loading…
Cancel
Save