新增了自动删除空白便签的功能 #17

Merged
p7fulywfa merged 1 commits from tangbo_branch into master 1 month ago

@ -29,7 +29,9 @@ 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.TextNote;
import net.micode.notes.tool.DataUtils;
import net.micode.notes.tool.ResourceParser.NoteBgResources;
import java.util.HashSet;
/**
@ -331,6 +333,7 @@ public class WorkingNote {
* <p>
*
*
*
* </p>
*
* @return truefalse
@ -356,6 +359,15 @@ public class WorkingNote {
}
return true;
} else {
// 添加删除逻辑:如果笔记内容为空且已存在于数据库,则删除该笔记
if (existInDatabase() && TextUtils.isEmpty(mContent)) {
HashSet<Long> ids = new HashSet<Long>();
ids.add(mNoteId);
if (!DataUtils.batchDeleteNotes(mContext.getContentResolver(), ids)) {
Log.e(TAG, "Delete empty note error");
}
mIsDeleted = true;
}
return false;
}
}
@ -376,13 +388,13 @@ public class WorkingNote {
*
* <p>
*
*
*
* </p>
*
* @return truefalse
*/
private boolean isWorthSaving() {
if (mIsDeleted || (!existInDatabase() && TextUtils.isEmpty(mContent))
if (mIsDeleted || TextUtils.isEmpty(mContent)
|| (existInDatabase() && !mNote.isLocalModified())) {
return false;
} else {

@ -110,7 +110,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;
View header = LayoutInflater.from(this).inflate(R.layout.settings_header, null);

Loading…
Cancel
Save