add<function>: trash folder

zhengkunpeng_branch
zkx 2 years ago
parent b410c0f012
commit 0f68594161

@ -93,7 +93,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
private enum ListEditState {
NOTE_LIST, SUB_FOLDER, CALL_RECORD_FOLDER
};
}; //NOTE: 三种编辑状态@zhoukexing 2024/1/2 19:31
private ListEditState mState;
@ -477,21 +477,30 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
new AsyncTask<Void, Void, HashSet<AppWidgetAttribute>>() {
protected HashSet<AppWidgetAttribute> doInBackground(Void... unused) {
HashSet<AppWidgetAttribute> widgets = mNotesListAdapter.getSelectedWidget();
if (!isSyncMode()) {
// if not synced, delete notes directly
if (DataUtils.batchDeleteNotes(mContentResolver, mNotesListAdapter
.getSelectedItemIds())) {
// if (!isSyncMode()) { //在AS的虚拟机里不能联网不在同步模式下
// // if not synced, delete notes directly
// if (DataUtils.batchDeleteNotes(mContentResolver, mNotesListAdapter
// .getSelectedItemIds())) {
// } else {
// Log.e(TAG, "Delete notes error, should not happens");
// }
// } else {
if (mCurrentFolderId == Notes.ID_TRASH_FOLER){
// if in trash, really delete notes
if (DataUtils.batchDeleteNotes(mContentResolver, mNotesListAdapter
.getSelectedItemIds())) {
} else {
Log.e(TAG, "Delete notes error, should not happens");
}
} else {
Log.e(TAG, "Delete notes error, should not happens");
}
} else {
// in sync mode, we'll move the deleted note into the trash
// folder
if (!DataUtils.batchMoveToFolder(mContentResolver, mNotesListAdapter
.getSelectedItemIds(), Notes.ID_TRASH_FOLER)) {
Log.e(TAG, "Move notes to trash folder error, should not happens");
// move notes to trash
if (!DataUtils.batchMoveToFolder(mContentResolver, mNotesListAdapter
.getSelectedItemIds(), Notes.ID_TRASH_FOLER)) {
Log.e(TAG, "Move notes to trash folder error, should not happens");
}
}
}
// }
return widgets;
}
@ -711,13 +720,12 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
@Override
public void onBackPressed() {
// 在list清单界面按回退键就会被捕捉到这里执行这个函数 @zhoukexing 2024/1/2 19:33
switch (mState) {
case SUB_FOLDER:
mCurrentFolderId = Notes.ID_ROOT_FOLDER;
mState = ListEditState.NOTE_LIST;
startAsyncNotesListQuery();
mTitleBar.setVisibility(View.GONE);
break;
case SUB_FOLDER: // 当前状态是子文件夹,要回退到主文件夹 @zkx
// 特殊情况子文件夹是“回收站”要显式地说明展示底部栏模仿下面的call_record_folder @zkx
// 添加mAddNewNote.setVisibility(View.VISIBLE);此行后,
// sub_folder 和 call_record_folder 两种情况无差别,无需分开处理
case CALL_RECORD_FOLDER:
mCurrentFolderId = Notes.ID_ROOT_FOLDER;
mState = ListEditState.NOTE_LIST;
@ -871,10 +879,32 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
createNewNote();
} else if (itemId == R.id.menu_search) {
onSearchRequested();
} else if (itemId == R.id.menu_trash) {
openTrashFolder();
}
return true;
}
/**
* @method: openTrashFolder
* @description: todo30
* @date: 2024/1/2 19:04
* @author: zhoukexing
* @param: []
* @return: void
*/
private void openTrashFolder() {
mCurrentFolderId = Notes.ID_TRASH_FOLER;
startAsyncNotesListQuery();
// 正常打开文件夹
mState = ListEditState.SUB_FOLDER;
// 将顶部栏设置为 data.getSnippet 文件夹名称
mTitleBar.setText(NotesListActivity.this
.getString(R.string.menu_trash));
// 不显示底部的“写便签” todoclosed:从子文件夹回到主页面时,展示底部栏
mAddNewNote.setVisibility(View.GONE);
mTitleBar.setVisibility(View.VISIBLE);
}
@Override
/**
* @Method onSearchRequested

@ -36,4 +36,8 @@
<item
android:id="@+id/menu_search"
android:title="@string/menu_search"/>
<item
android:id="@+id/menu_trash"
android:title="@string/menu_trash"/>
</menu>

@ -42,6 +42,7 @@
<string name="menu_sync_cancel">取消同步</string>
<string name="menu_setting">设置</string>
<string name="menu_search">搜索</string>
<string name="menu_trash">回收站</string>
<string name="menu_delete">删除</string>
<string name="menu_move">移动到文件夹</string>
<string name="menu_select_title">选中了 %d 项</string>

@ -43,6 +43,7 @@
<string name="menu_sync_cancel">取消同步</string>
<string name="menu_setting">設置</string>
<string name="menu_search">搜尋</string>
<string name="menu_trash">回收站</string>
<string name="menu_delete">刪除</string>
<string name="menu_move">移動到文件夾</string>
<string name="menu_select_title">選中了 %d 項</string>

@ -46,6 +46,7 @@
<string name="menu_sync_cancel">Cancel syncing</string>
<string name="menu_setting">Settings</string>
<string name="menu_search">Search</string>
<string name="menu_trash">Trash Folder</string>
<string name="menu_delete">Delete</string>
<string name="menu_move">Move to folder</string>
<string name="menu_select_title">%d selected</string>

Loading…
Cancel
Save