|
|
@ -78,6 +78,11 @@ import java.io.InputStream;
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.HashSet;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 负责显示笔记和文件夹的列表
|
|
|
|
|
|
|
|
* 管理列表活动的用户界面和用户交互
|
|
|
|
|
|
|
|
* 为查询列表定义了多个变量
|
|
|
|
|
|
|
|
*/
|
|
|
|
public class NotesListActivity extends Activity implements OnClickListener, OnItemLongClickListener {
|
|
|
|
public class NotesListActivity extends Activity implements OnClickListener, OnItemLongClickListener {
|
|
|
|
private static final int FOLDER_NOTE_LIST_QUERY_TOKEN = 0;
|
|
|
|
private static final int FOLDER_NOTE_LIST_QUERY_TOKEN = 0;
|
|
|
|
|
|
|
|
|
|
|
@ -126,7 +131,9 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
private NoteItemData mFocusNoteDataItem;
|
|
|
|
private NoteItemData mFocusNoteDataItem;
|
|
|
|
|
|
|
|
|
|
|
|
private static final String NORMAL_SELECTION = NoteColumns.PARENT_ID + "=?";
|
|
|
|
private static final String NORMAL_SELECTION = NoteColumns.PARENT_ID + "=?";
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 根文件夹的选择
|
|
|
|
|
|
|
|
*/
|
|
|
|
private static final String ROOT_FOLDER_SELECTION = "(" + NoteColumns.TYPE + "<>"
|
|
|
|
private static final String ROOT_FOLDER_SELECTION = "(" + NoteColumns.TYPE + "<>"
|
|
|
|
+ Notes.TYPE_SYSTEM + " AND " + NoteColumns.PARENT_ID + "=?)" + " OR ("
|
|
|
|
+ Notes.TYPE_SYSTEM + " AND " + NoteColumns.PARENT_ID + "=?)" + " OR ("
|
|
|
|
+ NoteColumns.ID + "=" + Notes.ID_CALL_RECORD_FOLDER + " AND "
|
|
|
|
+ NoteColumns.ID + "=" + Notes.ID_CALL_RECORD_FOLDER + " AND "
|
|
|
@ -142,11 +149,16 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
initResources();
|
|
|
|
initResources();
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Insert an introduction when user firstly use this application
|
|
|
|
* 首次使用时插入介绍
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
setAppInfoFromRawRes();
|
|
|
|
setAppInfoFromRawRes();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 检查结果是否正常
|
|
|
|
|
|
|
|
* 正常则重新加载数据
|
|
|
|
|
|
|
|
* 否则调用结果函数
|
|
|
|
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
|
if (resultCode == RESULT_OK
|
|
|
|
if (resultCode == RESULT_OK
|
|
|
@ -157,6 +169,12 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 检查布尔值是否为错误
|
|
|
|
|
|
|
|
* 如果遇到错误,记录错误信息并返回
|
|
|
|
|
|
|
|
* 在首次运行时将文本保存到程序中
|
|
|
|
|
|
|
|
* 在后续运行中不重复保存
|
|
|
|
|
|
|
|
*/
|
|
|
|
private void setAppInfoFromRawRes() {
|
|
|
|
private void setAppInfoFromRawRes() {
|
|
|
|
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
|
|
|
|
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
|
|
|
|
if (!sp.getBoolean(PREFERENCE_ADD_INTRODUCTION, false)) {
|
|
|
|
if (!sp.getBoolean(PREFERENCE_ADD_INTRODUCTION, false)) {
|
|
|
@ -184,7 +202,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
in.close();
|
|
|
|
in.close();
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (IOException e) {
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
// 自动生成的catch块
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -269,6 +287,9 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 用于更新下拉菜单的显示内容,根据选择的笔记数量更新菜单标题和选项状态
|
|
|
|
|
|
|
|
*/
|
|
|
|
private void updateMenu() {
|
|
|
|
private void updateMenu() {
|
|
|
|
int selectedCount = mNotesListAdapter.getSelectedCount();
|
|
|
|
int selectedCount = mNotesListAdapter.getSelectedCount();
|
|
|
|
// Update dropdown menu
|
|
|
|
// Update dropdown menu
|
|
|
@ -286,32 +307,46 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 与操作模式相关的回调方法,用于处理操作模式的准备和点击事件。
|
|
|
|
|
|
|
|
*/
|
|
|
|
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
|
|
|
|
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
// 自动生成的方法存根
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
|
|
|
|
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 在操作模式销毁时被调用,用于恢复界面状态。
|
|
|
|
|
|
|
|
*/
|
|
|
|
public void onDestroyActionMode(ActionMode mode) {
|
|
|
|
public void onDestroyActionMode(ActionMode mode) {
|
|
|
|
mNotesListAdapter.setChoiceMode(false);
|
|
|
|
mNotesListAdapter.setChoiceMode(false);
|
|
|
|
mNotesListView.setLongClickable(true);
|
|
|
|
mNotesListView.setLongClickable(true);
|
|
|
|
mAddNewNote.setVisibility(View.VISIBLE);
|
|
|
|
mAddNewNote.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void finishActionMode() {
|
|
|
|
public void finishActionMode() {//用于结束操作模式。
|
|
|
|
mActionMode.finish();
|
|
|
|
mActionMode.finish();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 处理笔记项选中状态改变的事件,并更新菜单。
|
|
|
|
|
|
|
|
*/
|
|
|
|
public void onItemCheckedStateChanged(ActionMode mode, int position, long id,
|
|
|
|
public void onItemCheckedStateChanged(ActionMode mode, int position, long id,
|
|
|
|
boolean checked) {
|
|
|
|
boolean checked) {
|
|
|
|
mNotesListAdapter.setCheckedItem(position, checked);
|
|
|
|
mNotesListAdapter.setCheckedItem(position, checked);
|
|
|
|
updateMenu();
|
|
|
|
updateMenu();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
*处理菜单项点击事件
|
|
|
|
|
|
|
|
* 根据点击的菜单项执行相应的操作
|
|
|
|
|
|
|
|
* 比如删除或移动笔记。
|
|
|
|
|
|
|
|
*/
|
|
|
|
public boolean onMenuItemClick(MenuItem item) {
|
|
|
|
public boolean onMenuItemClick(MenuItem item) {
|
|
|
|
if (mNotesListAdapter.getSelectedCount() == 0) {
|
|
|
|
if (mNotesListAdapter.getSelectedCount() == 0) {
|
|
|
|
Toast.makeText(NotesListActivity.this, getString(R.string.menu_select_none),
|
|
|
|
Toast.makeText(NotesListActivity.this, getString(R.string.menu_select_none),
|
|
|
@ -346,6 +381,11 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 实现了一个触摸监听器
|
|
|
|
|
|
|
|
* 处理了新建笔记按钮的触摸事件
|
|
|
|
|
|
|
|
* 包括点击透明部分时将事件传递
|
|
|
|
|
|
|
|
*/
|
|
|
|
private class NewNoteOnTouchListener implements OnTouchListener {
|
|
|
|
private class NewNoteOnTouchListener implements OnTouchListener {
|
|
|
|
|
|
|
|
|
|
|
|
public boolean onTouch(View v, MotionEvent event) {
|
|
|
|
public boolean onTouch(View v, MotionEvent event) {
|
|
|
@ -408,6 +448,11 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 用于开始异步笔记列表查询
|
|
|
|
|
|
|
|
* 根据当前文件夹的不同选择不同的查询条件
|
|
|
|
|
|
|
|
* 并使用后台查询处理程序执行查询操作。
|
|
|
|
|
|
|
|
*/
|
|
|
|
private void startAsyncNotesListQuery() {
|
|
|
|
private void startAsyncNotesListQuery() {
|
|
|
|
String selection = (mCurrentFolderId == Notes.ID_ROOT_FOLDER) ? ROOT_FOLDER_SELECTION
|
|
|
|
String selection = (mCurrentFolderId == Notes.ID_ROOT_FOLDER) ? ROOT_FOLDER_SELECTION
|
|
|
|
: NORMAL_SELECTION;
|
|
|
|
: NORMAL_SELECTION;
|
|
|
@ -417,6 +462,12 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
}, NoteColumns.TYPE + " DESC," + NoteColumns.MODIFIED_DATE + " DESC");
|
|
|
|
}, NoteColumns.TYPE + " DESC," + NoteColumns.MODIFIED_DATE + " DESC");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 类继承自 AsyncQueryHandler
|
|
|
|
|
|
|
|
* 用于处理后台查询的结果
|
|
|
|
|
|
|
|
* 根据查询的不同类型执行相应的操作
|
|
|
|
|
|
|
|
* 比如更新笔记列表或显示文件夹菜单。
|
|
|
|
|
|
|
|
*/
|
|
|
|
private final class BackgroundQueryHandler extends AsyncQueryHandler {
|
|
|
|
private final class BackgroundQueryHandler extends AsyncQueryHandler {
|
|
|
|
public BackgroundQueryHandler(ContentResolver contentResolver) {
|
|
|
|
public BackgroundQueryHandler(ContentResolver contentResolver) {
|
|
|
|
super(contentResolver);
|
|
|
|
super(contentResolver);
|
|
|
@ -441,6 +492,9 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 用于显示文件夹列表菜单,根据传入的游标数据构建对话框,并处理用户选择文件夹的操作。
|
|
|
|
|
|
|
|
*/
|
|
|
|
private void showFolderListMenu(Cursor cursor) {
|
|
|
|
private void showFolderListMenu(Cursor cursor) {
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(NotesListActivity.this);
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(NotesListActivity.this);
|
|
|
|
builder.setTitle(R.string.menu_title_select_folder);
|
|
|
|
builder.setTitle(R.string.menu_title_select_folder);
|
|
|
@ -462,6 +516,10 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
builder.show();
|
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 用于创建新的笔记,构建一个新的笔记编辑界面
|
|
|
|
|
|
|
|
* 并传递文件夹 ID 及请求码进行处理。
|
|
|
|
|
|
|
|
*/
|
|
|
|
private void createNewNote() {
|
|
|
|
private void createNewNote() {
|
|
|
|
Intent intent = new Intent(this, NoteEditActivity.class);
|
|
|
|
Intent intent = new Intent(this, NoteEditActivity.class);
|
|
|
|
intent.setAction(Intent.ACTION_INSERT_OR_EDIT);
|
|
|
|
intent.setAction(Intent.ACTION_INSERT_OR_EDIT);
|
|
|
@ -469,6 +527,11 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
this.startActivityForResult(intent, REQUEST_CODE_NEW_NODE);
|
|
|
|
this.startActivityForResult(intent, REQUEST_CODE_NEW_NODE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 用于批量删除笔记
|
|
|
|
|
|
|
|
* 根据同步模式的不同执行直接删除或移动到垃圾箱
|
|
|
|
|
|
|
|
* 并在后台执行异步任务。
|
|
|
|
|
|
|
|
*/
|
|
|
|
private void batchDelete() {
|
|
|
|
private void batchDelete() {
|
|
|
|
new AsyncTask<Void, Void, HashSet<AppWidgetAttribute>>() {
|
|
|
|
new AsyncTask<Void, Void, HashSet<AppWidgetAttribute>>() {
|
|
|
|
protected HashSet<AppWidgetAttribute> doInBackground(Void... unused) {
|
|
|
|
protected HashSet<AppWidgetAttribute> doInBackground(Void... unused) {
|
|
|
@ -506,6 +569,9 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
}.execute();
|
|
|
|
}.execute();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 用于删除文件夹,根据同步模式的不同执行直接删除或移动到垃圾箱,并更新相关的小部件。
|
|
|
|
|
|
|
|
*/
|
|
|
|
private void deleteFolder(long folderId) {
|
|
|
|
private void deleteFolder(long folderId) {
|
|
|
|
if (folderId == Notes.ID_ROOT_FOLDER) {
|
|
|
|
if (folderId == Notes.ID_ROOT_FOLDER) {
|
|
|
|
Log.e(TAG, "Wrong folder id, should not happen " + folderId);
|
|
|
|
Log.e(TAG, "Wrong folder id, should not happen " + folderId);
|
|
|
@ -533,13 +599,20 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 用于打开笔记,构建一个笔记查看界面
|
|
|
|
|
|
|
|
* 并传递笔记 ID 进行处理。
|
|
|
|
|
|
|
|
*/
|
|
|
|
private void openNode(NoteItemData data) {
|
|
|
|
private void openNode(NoteItemData data) {
|
|
|
|
Intent intent = new Intent(this, NoteEditActivity.class);
|
|
|
|
Intent intent = new Intent(this, NoteEditActivity.class);
|
|
|
|
intent.setAction(Intent.ACTION_VIEW);
|
|
|
|
intent.setAction(Intent.ACTION_VIEW);
|
|
|
|
intent.putExtra(Intent.EXTRA_UID, data.getId());
|
|
|
|
intent.putExtra(Intent.EXTRA_UID, data.getId());
|
|
|
|
this.startActivityForResult(intent, REQUEST_CODE_OPEN_NODE);
|
|
|
|
this.startActivityForResult(intent, REQUEST_CODE_OPEN_NODE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 用于打开文件夹,根据文件夹的不同执行异步笔记列表查询
|
|
|
|
|
|
|
|
* 并更新界面状态和标题栏的显示。
|
|
|
|
|
|
|
|
*/
|
|
|
|
private void openFolder(NoteItemData data) {
|
|
|
|
private void openFolder(NoteItemData data) {
|
|
|
|
mCurrentFolderId = data.getId();
|
|
|
|
mCurrentFolderId = data.getId();
|
|
|
|
startAsyncNotesListQuery();
|
|
|
|
startAsyncNotesListQuery();
|
|
|
@ -567,6 +640,10 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 显示软键盘
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
private void showSoftInput() {
|
|
|
|
private void showSoftInput() {
|
|
|
|
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
|
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
|
if (inputMethodManager != null) {
|
|
|
|
if (inputMethodManager != null) {
|
|
|
@ -574,11 +651,20 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 隐藏软键盘
|
|
|
|
|
|
|
|
*/
|
|
|
|
private void hideSoftInput(View view) {
|
|
|
|
private void hideSoftInput(View view) {
|
|
|
|
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
|
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
|
inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
|
|
|
inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 用于显示创建或修改文件夹的对话框
|
|
|
|
|
|
|
|
* 根据传入的布尔值决定是创建还是修改文件夹
|
|
|
|
|
|
|
|
* 对话框中包含了编辑文本框和确认/取消按钮
|
|
|
|
|
|
|
|
* 并根据用户输入进行相应的操作。
|
|
|
|
|
|
|
|
*/
|
|
|
|
private void showCreateOrModifyFolderDialog(final boolean create) {
|
|
|
|
private void showCreateOrModifyFolderDialog(final boolean create) {
|
|
|
|
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
|
|
|
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
|
|
|
View view = LayoutInflater.from(this).inflate(R.layout.dialog_edit_text, null);
|
|
|
|
View view = LayoutInflater.from(this).inflate(R.layout.dialog_edit_text, null);
|
|
|
@ -664,6 +750,10 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 用于处理返回按钮的操作,根据当前状态执行不同的操作
|
|
|
|
|
|
|
|
* 包括返回上一级文件夹、返回笔记列表或者执行默认的返回操作。
|
|
|
|
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onBackPressed() {
|
|
|
|
public void onBackPressed() {
|
|
|
|
switch (mState) {
|
|
|
|
switch (mState) {
|
|
|
@ -688,6 +778,9 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 用于更新小部件,根据传入的小部件 ID 和小部件类型创建相应的意图,并发送广播来更新小部件。
|
|
|
|
|
|
|
|
*/
|
|
|
|
private void updateWidget(int appWidgetId, int appWidgetType) {
|
|
|
|
private void updateWidget(int appWidgetId, int appWidgetType) {
|
|
|
|
Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
|
|
|
|
Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
|
|
|
|
if (appWidgetType == Notes.TYPE_WIDGET_2X) {
|
|
|
|
if (appWidgetType == Notes.TYPE_WIDGET_2X) {
|
|
|
@ -707,6 +800,10 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
setResult(RESULT_OK, intent);
|
|
|
|
setResult(RESULT_OK, intent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 是一个上下文菜单的创建监听器,用于创建文件夹的上下文菜单
|
|
|
|
|
|
|
|
* 包括查看文件夹、删除文件夹和修改文件夹名称等选项。
|
|
|
|
|
|
|
|
*/
|
|
|
|
private final OnCreateContextMenuListener mFolderOnCreateContextMenuListener = new OnCreateContextMenuListener() {
|
|
|
|
private final OnCreateContextMenuListener mFolderOnCreateContextMenuListener = new OnCreateContextMenuListener() {
|
|
|
|
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
|
|
|
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
|
|
|
if (mFocusNoteDataItem != null) {
|
|
|
|
if (mFocusNoteDataItem != null) {
|
|
|
@ -718,6 +815,10 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 用于在上下文菜单关闭时执行操作
|
|
|
|
|
|
|
|
* 它会在菜单关闭时将上下文菜单的创建监听器设置为null。
|
|
|
|
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onContextMenuClosed(Menu menu) {
|
|
|
|
public void onContextMenuClosed(Menu menu) {
|
|
|
|
if (mNotesListView != null) {
|
|
|
|
if (mNotesListView != null) {
|
|
|
@ -726,6 +827,10 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
super.onContextMenuClosed(menu);
|
|
|
|
super.onContextMenuClosed(menu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 用于处理上下文菜单中的菜单项选择操作,根据用户选择执行相应的操作
|
|
|
|
|
|
|
|
* 包括打开文件夹、删除文件夹和修改文件夹名称等。
|
|
|
|
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean onContextItemSelected(MenuItem item) {
|
|
|
|
public boolean onContextItemSelected(MenuItem item) {
|
|
|
|
if (mFocusNoteDataItem == null) {
|
|
|
|
if (mFocusNoteDataItem == null) {
|
|
|
@ -760,6 +865,10 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 用于准备选项菜单,根据当前状态加载不同的菜单项
|
|
|
|
|
|
|
|
* 包括笔记列表、子文件夹、通话记录文件夹等状态下的菜单项。
|
|
|
|
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean onPrepareOptionsMenu(Menu menu) {
|
|
|
|
public boolean onPrepareOptionsMenu(Menu menu) {
|
|
|
|
menu.clear();
|
|
|
|
menu.clear();
|
|
|
@ -778,6 +887,10 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 用于处理选项菜单中的菜单项选择操作,根据用户选择执行相应的操作
|
|
|
|
|
|
|
|
* 包括创建新文件夹、导出笔记到文本、同步、设置、创建新笔记和搜索等。
|
|
|
|
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
|
switch (item.getItemId()) {
|
|
|
|
switch (item.getItemId()) {
|
|
|
@ -818,12 +931,18 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 用于处理搜索请求,启动搜索功能。
|
|
|
|
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean onSearchRequested() {
|
|
|
|
public boolean onSearchRequested() {
|
|
|
|
startSearch(null, false, null /* appData */, false);
|
|
|
|
startSearch(null, false, null /* appData */, false);
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 用于将笔记导出为文本文件,在后台执行导出操作
|
|
|
|
|
|
|
|
*/
|
|
|
|
private void exportNoteToText() {
|
|
|
|
private void exportNoteToText() {
|
|
|
|
final BackupUtils backup = BackupUtils.getInstance(NotesListActivity.this);
|
|
|
|
final BackupUtils backup = BackupUtils.getInstance(NotesListActivity.this);
|
|
|
|
new AsyncTask<Void, Void, Integer>() {
|
|
|
|
new AsyncTask<Void, Void, Integer>() {
|
|
|
@ -866,16 +985,25 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
}.execute();
|
|
|
|
}.execute();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 用于检查是否处于同步模式,它会获取同步账户名称并检查其长度是否大于0,如果大于0则表示处于同步模式。
|
|
|
|
|
|
|
|
*/
|
|
|
|
private boolean isSyncMode() {
|
|
|
|
private boolean isSyncMode() {
|
|
|
|
return NotesPreferenceActivity.getSyncAccountName(this).trim().length() > 0;
|
|
|
|
return NotesPreferenceActivity.getSyncAccountName(this).trim().length() > 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 用于启动偏好设置活动,它会创建一个意图并启动偏好设置活动。
|
|
|
|
|
|
|
|
*/
|
|
|
|
private void startPreferenceActivity() {
|
|
|
|
private void startPreferenceActivity() {
|
|
|
|
Activity from = getParent() != null ? getParent() : this;
|
|
|
|
Activity from = getParent() != null ? getParent() : this;
|
|
|
|
Intent intent = new Intent(from, NotesPreferenceActivity.class);
|
|
|
|
Intent intent = new Intent(from, NotesPreferenceActivity.class);
|
|
|
|
from.startActivityIfNeeded(intent, -1);
|
|
|
|
from.startActivityIfNeeded(intent, -1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 用于处理列表项的点击操作。根据当前状态和列表项的类型执行相应的操作,包括打开文件夹、打开笔记等。
|
|
|
|
|
|
|
|
*/
|
|
|
|
private class OnListItemClickListener implements OnItemClickListener {
|
|
|
|
private class OnListItemClickListener implements OnItemClickListener {
|
|
|
|
|
|
|
|
|
|
|
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
@ -917,6 +1045,9 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 用于开始查询目标文件夹,它构建了查询条件并使用后台查询处理程序执行查询操作
|
|
|
|
|
|
|
|
*/
|
|
|
|
private void startQueryDestinationFolders() {
|
|
|
|
private void startQueryDestinationFolders() {
|
|
|
|
String selection = NoteColumns.TYPE + "=? AND " + NoteColumns.PARENT_ID + "<>? AND " + NoteColumns.ID + "<>?";
|
|
|
|
String selection = NoteColumns.TYPE + "=? AND " + NoteColumns.PARENT_ID + "<>? AND " + NoteColumns.ID + "<>?";
|
|
|
|
selection = (mState == ListEditState.NOTE_LIST) ? selection:
|
|
|
|
selection = (mState == ListEditState.NOTE_LIST) ? selection:
|
|
|
@ -935,6 +1066,10 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
NoteColumns.MODIFIED_DATE + " DESC");
|
|
|
|
NoteColumns.MODIFIED_DATE + " DESC");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 用于处理列表项的长按操作,根据列表项的类型执行相应的操作,包括进入选择模式、执行长按操作等。
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
|
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
|
if (view instanceof NotesListItem) {
|
|
|
|
if (view instanceof NotesListItem) {
|
|
|
|
mFocusNoteDataItem = ((NotesListItem) view).getItemData();
|
|
|
|
mFocusNoteDataItem = ((NotesListItem) view).getItemData();
|
|
|
|