|
|
|
@ -405,15 +405,20 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//TODO add comments of this method
|
|
|
|
|
/**
|
|
|
|
|
* @Method startAsyncNotesListQuery
|
|
|
|
|
* @Date 2023/12/19 8:34
|
|
|
|
|
* @Author lenovo
|
|
|
|
|
* @Return void
|
|
|
|
|
* @Description 开始异步查询便签列表
|
|
|
|
|
*/
|
|
|
|
|
private void startAsyncNotesListQuery() {
|
|
|
|
|
String selection = (mCurrentFolderId == Notes.ID_ROOT_FOLDER) ? ROOT_FOLDER_SELECTION
|
|
|
|
|
: NORMAL_SELECTION;
|
|
|
|
|
mBackgroundQueryHandler.startQuery(FOLDER_NOTE_LIST_QUERY_TOKEN, null,
|
|
|
|
|
Notes.CONTENT_NOTE_URI, NoteItemData.PROJECTION, selection, new String[] {
|
|
|
|
|
String.valueOf(mCurrentFolderId)
|
|
|
|
|
}, NoteColumns.TYPE + " DESC," + NoteColumns.MODIFIED_DATE + " DESC");
|
|
|
|
|
}, NoteColumns.TYPE + " DESC," + NoteColumns.MODIFIED_DATE + " DESC"); // DESC 降序
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private final class BackgroundQueryHandler extends AsyncQueryHandler {
|
|
|
|
@ -505,7 +510,14 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
|
}.execute();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO add comments of this method
|
|
|
|
|
/**
|
|
|
|
|
* @Method deleteFolder
|
|
|
|
|
* @Date 2023/12/19 8:37
|
|
|
|
|
* @param folderId
|
|
|
|
|
* @Author lenovo
|
|
|
|
|
* @Return void
|
|
|
|
|
* @Description 删除文件夹 (sync mode 会删除进回收站)
|
|
|
|
|
*/
|
|
|
|
|
private void deleteFolder(long folderId) {
|
|
|
|
|
if (folderId == Notes.ID_ROOT_FOLDER) {
|
|
|
|
|
Log.e(TAG, "Wrong folder id, should not happen " + folderId);
|
|
|
|
@ -514,6 +526,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
|
|
|
|
|
|
HashSet<Long> ids = new HashSet<Long>();
|
|
|
|
|
ids.add(folderId);
|
|
|
|
|
// 所有与要删除文件夹相关的 widgets
|
|
|
|
|
HashSet<AppWidgetAttribute> widgets = DataUtils.getFolderNoteWidget(mContentResolver,
|
|
|
|
|
folderId);
|
|
|
|
|
if (!isSyncMode()) {
|
|
|
|
@ -523,6 +536,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
|
// in sync mode, we'll move the deleted folder into the trash folder
|
|
|
|
|
DataUtils.batchMoveToFolder(mContentResolver, ids, Notes.ID_TRASH_FOLER);
|
|
|
|
|
}
|
|
|
|
|
// 更新 widgets
|
|
|
|
|
if (widgets != null) {
|
|
|
|
|
for (AppWidgetAttribute widget : widgets) {
|
|
|
|
|
if (widget.widgetId != AppWidgetManager.INVALID_APPWIDGET_ID
|
|
|
|
@ -540,19 +554,29 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
|
this.startActivityForResult(intent, REQUEST_CODE_OPEN_NODE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO add comments of this method
|
|
|
|
|
/**
|
|
|
|
|
* @Method openFolder
|
|
|
|
|
* @Date 2023/12/19 7:55
|
|
|
|
|
* @param data
|
|
|
|
|
* @Author lenovo
|
|
|
|
|
* @Return void
|
|
|
|
|
* @Description 打开文件夹
|
|
|
|
|
*/
|
|
|
|
|
private void openFolder(NoteItemData data) {
|
|
|
|
|
mCurrentFolderId = data.getId();
|
|
|
|
|
startAsyncNotesListQuery();
|
|
|
|
|
if (data.getId() == Notes.ID_CALL_RECORD_FOLDER) {
|
|
|
|
|
// TODO store all records 暂时没太搞明白这个代表什么
|
|
|
|
|
mState = ListEditState.CALL_RECORD_FOLDER;
|
|
|
|
|
mAddNewNote.setVisibility(View.GONE);
|
|
|
|
|
} else {
|
|
|
|
|
// 正常打开文件夹
|
|
|
|
|
mState = ListEditState.SUB_FOLDER;
|
|
|
|
|
}
|
|
|
|
|
if (data.getId() == Notes.ID_CALL_RECORD_FOLDER) {
|
|
|
|
|
mTitleBar.setText(R.string.call_record_folder_name);
|
|
|
|
|
} else {
|
|
|
|
|
// 将顶部栏设置为 data.getSnippet 文件夹名称
|
|
|
|
|
mTitleBar.setText(data.getSnippet());
|
|
|
|
|
}
|
|
|
|
|
mTitleBar.setVisibility(View.VISIBLE);
|
|
|
|
@ -635,6 +659,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
|
etName.setSelection(0, etName.length()); //全选输入文件名(准备修改/删除)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 更新数据库中文件夹名称 插入/修改
|
|
|
|
|
if (!create) {
|
|
|
|
|
if (!TextUtils.isEmpty(name)) {
|
|
|
|
|
ContentValues values = new ContentValues();
|
|
|
|
@ -652,6 +677,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
|
values.put(NoteColumns.TYPE, Notes.TYPE_FOLDER);
|
|
|
|
|
mContentResolver.insert(Notes.CONTENT_NOTE_URI, values);
|
|
|
|
|
}
|
|
|
|
|
//关闭对话框
|
|
|
|
|
dialog.dismiss();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
@ -766,7 +792,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
|
case MENU_FOLDER_DELETE:
|
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
|
|
|
|
builder.setTitle(getString(R.string.alert_title_delete));
|
|
|
|
|
builder.setIcon(android.R.drawable.ic_dialog_alert);
|
|
|
|
|
builder.setIcon(android.R.drawable.divider_horizontal_dark);
|
|
|
|
|
builder.setMessage(getString(R.string.alert_message_delete_folder));
|
|
|
|
|
builder.setPositiveButton(android.R.string.ok,
|
|
|
|
|
new DialogInterface.OnClickListener() {
|
|
|
|
@ -840,26 +866,46 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//TODO add comments of this method
|
|
|
|
|
@Override
|
|
|
|
|
/**
|
|
|
|
|
* @Method onSearchRequested
|
|
|
|
|
* @Date 2023/12/19 8:53
|
|
|
|
|
* @Author lenovo
|
|
|
|
|
* @Return boolean
|
|
|
|
|
* @Description 打开搜索小部件
|
|
|
|
|
*/
|
|
|
|
|
public boolean onSearchRequested() {
|
|
|
|
|
startSearch(null, false, null /* appData */, false);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//TODO add comments of this method
|
|
|
|
|
/**
|
|
|
|
|
* @Method exportNoteToText
|
|
|
|
|
* @Date 2023/12/19 8:44
|
|
|
|
|
* @Author lenovo
|
|
|
|
|
* @Return void
|
|
|
|
|
* @Description 将便签导出成文本
|
|
|
|
|
*/
|
|
|
|
|
private void exportNoteToText() {
|
|
|
|
|
final BackupUtils backup = BackupUtils.getInstance(NotesListActivity.this);
|
|
|
|
|
/**
|
|
|
|
|
* 启用异步 UI 线程
|
|
|
|
|
* Warning: deprecated in API level 30
|
|
|
|
|
* would cause Context leaks, missed callbacks, or crashes on configuration changes.
|
|
|
|
|
* lenovo 2023/12/19 9:04
|
|
|
|
|
*/
|
|
|
|
|
new AsyncTask<Void, Void, Integer>() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
// 后台运行导出文本
|
|
|
|
|
protected Integer doInBackground(Void... unused) {
|
|
|
|
|
return backup.exportToText();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
// 线程运行结束后的结果处理程序
|
|
|
|
|
protected void onPostExecute(Integer result) {
|
|
|
|
|
if (result == BackupUtils.STATE_SD_CARD_UNMOUONTED) {
|
|
|
|
|
if (result == BackupUtils.STATE_SD_CARD_UNMOUONTED) { // 没插 SD 卡
|
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(NotesListActivity.this);
|
|
|
|
|
builder.setTitle(NotesListActivity.this
|
|
|
|
|
.getString(R.string.failed_sdcard_export));
|
|
|
|
@ -941,7 +987,13 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO add comments of this method
|
|
|
|
|
/**
|
|
|
|
|
* @Method startQueryDestinationFolders
|
|
|
|
|
* @Date 2023/12/19 8:59
|
|
|
|
|
* @Author lenovo
|
|
|
|
|
* @Return void
|
|
|
|
|
* @Description 查询目标文件
|
|
|
|
|
*/
|
|
|
|
|
private void startQueryDestinationFolders() {
|
|
|
|
|
String selection = NoteColumns.TYPE + "=? AND " + NoteColumns.PARENT_ID + "<>? AND " + NoteColumns.ID + "<>?";
|
|
|
|
|
selection = (mState == ListEditState.NOTE_LIST) ? selection:
|
|
|
|
|