|
|
|
@ -85,6 +85,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
|
|
|
|
|
|
private static final String PREFERENCE_ADD_INTRODUCTION = "net.micode.notes.introduction";
|
|
|
|
|
|
|
|
|
|
/**三个状态,主页面,文件夹,通话记录文件夹*/
|
|
|
|
|
private enum ListEditState {
|
|
|
|
|
NOTE_LIST, SUB_FOLDER, CALL_RECORD_FOLDER
|
|
|
|
|
};
|
|
|
|
@ -100,6 +101,8 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
|
private Button mAddNewNote;
|
|
|
|
|
|
|
|
|
|
private boolean mDispatch;
|
|
|
|
|
// 控制背景颜色,初始为亮
|
|
|
|
|
private int mBackgroundColor = 1;
|
|
|
|
|
|
|
|
|
|
private int mOriginY;
|
|
|
|
|
|
|
|
|
@ -117,6 +120,9 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
|
|
|
|
|
|
public static final int NOTES_LISTVIEW_SCROLL_RATE = 30;
|
|
|
|
|
|
|
|
|
|
/** 私密模式,初始为 0 开启为 1*/
|
|
|
|
|
public static int mSecretMode = 0;
|
|
|
|
|
|
|
|
|
|
private NoteItemData mFocusNoteDataItem;
|
|
|
|
|
|
|
|
|
|
private static final String NORMAL_SELECTION = NoteColumns.PARENT_ID + "=?";
|
|
|
|
@ -140,6 +146,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
|
protected void onCreate(final Bundle savedInstanceState) {
|
|
|
|
|
super.onCreate(savedInstanceState); // 调用父类的onCreate函数
|
|
|
|
|
setContentView(R.layout.note_list);
|
|
|
|
|
getWindow().setBackgroundDrawableResource(R.drawable.bg_light);
|
|
|
|
|
initResources();
|
|
|
|
|
setAppInfoFromRawRes();
|
|
|
|
|
}
|
|
|
|
@ -463,10 +470,12 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private void startAsyncNotesListQuery() {
|
|
|
|
|
String selection = (mCurrentFolderId == Notes.ID_ROOT_FOLDER) ? ROOT_FOLDER_SELECTION : NORMAL_SELECTION;
|
|
|
|
|
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");
|
|
|
|
|
Notes.CONTENT_NOTE_URI, NoteItemData.PROJECTION, selection, new String[]{
|
|
|
|
|
String.valueOf(mCurrentFolderId)
|
|
|
|
|
}, NoteColumns.TYPE + " DESC," + NoteColumns.MODIFIED_DATE + " DESC");
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* @Package: net.micode.notes.ui
|
|
|
|
@ -530,6 +539,98 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
|
});
|
|
|
|
|
builder.show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @method switchBackground
|
|
|
|
|
* @description 用以切换背景颜色
|
|
|
|
|
* @date: 1/3/2024 3:41 PM
|
|
|
|
|
* @author: YangYizhe
|
|
|
|
|
*/
|
|
|
|
|
private void switchBackground(){
|
|
|
|
|
mBackgroundColor = (mBackgroundColor + 1) % 2;
|
|
|
|
|
View frameLayout = findViewById(R.id.frame_layout_id);
|
|
|
|
|
if (mBackgroundColor == 1){
|
|
|
|
|
frameLayout.setBackgroundResource(R.drawable.bg_light);
|
|
|
|
|
} else{
|
|
|
|
|
frameLayout.setBackgroundResource(R.drawable.bg_dark);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean isSecretMode(){
|
|
|
|
|
if(mSecretMode == 1){
|
|
|
|
|
return true;
|
|
|
|
|
}else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @method enterSecertMode
|
|
|
|
|
* @description 实现进入隐私模式的功能
|
|
|
|
|
* @date: 1/2/2024 8:18 PM
|
|
|
|
|
* @author: YangYizhe
|
|
|
|
|
*/
|
|
|
|
|
private void enterSecretMode(){
|
|
|
|
|
AlertDialog.Builder dialog = new AlertDialog.Builder(NotesListActivity.this);
|
|
|
|
|
dialog.setTitle("重要提醒");
|
|
|
|
|
dialog.setMessage("您确认进入隐私模式吗?");
|
|
|
|
|
dialog.setCancelable(false);
|
|
|
|
|
dialog.setPositiveButton("确认", new DialogInterface.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
mSecretMode = 1;
|
|
|
|
|
startAsyncNotesListQuery();
|
|
|
|
|
Toast.makeText(NotesListActivity.this,"您已进入隐私模式",Toast.LENGTH_SHORT).show();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(DialogInterface dialog, int which){}
|
|
|
|
|
});
|
|
|
|
|
dialog.show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @method quitSecretMode
|
|
|
|
|
* @description 实现退出隐私模式的功能
|
|
|
|
|
* @date: 1/2/2024 8:20 PM
|
|
|
|
|
* @author: YangYizhe
|
|
|
|
|
*/
|
|
|
|
|
private void quitSecretMode(){
|
|
|
|
|
AlertDialog.Builder dialog = new AlertDialog.Builder(NotesListActivity.this);
|
|
|
|
|
dialog.setTitle("重要提醒");
|
|
|
|
|
dialog.setMessage("您确认退出隐私模式吗?");
|
|
|
|
|
dialog.setCancelable(false);
|
|
|
|
|
dialog.setPositiveButton("确认", new DialogInterface.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
mSecretMode = 0;
|
|
|
|
|
startAsyncNotesListQuery();
|
|
|
|
|
Toast.makeText(NotesListActivity.this,"您已退出隐私模式",Toast.LENGTH_SHORT).show();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(DialogInterface dialog, int which){}
|
|
|
|
|
});
|
|
|
|
|
dialog.show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @method restoreDeletedNodes
|
|
|
|
|
* @description 进入回收站
|
|
|
|
|
* @date: 1/3/2024 8:11 PM
|
|
|
|
|
* @author: YangYizhe
|
|
|
|
|
*/
|
|
|
|
|
private void restoreDeletedNodes(){
|
|
|
|
|
mState = ListEditState.SUB_FOLDER;
|
|
|
|
|
mCurrentFolderId = Notes.ID_TRASH_FOLER;
|
|
|
|
|
startAsyncNotesListQuery();
|
|
|
|
|
mTitleBar.setText("回收站");
|
|
|
|
|
mTitleBar.setVisibility(View.VISIBLE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @method createNewNote
|
|
|
|
|
* @description 创建便签
|
|
|
|
@ -544,6 +645,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
|
intent.putExtra(Notes.INTENT_EXTRA_FOLDER_ID, mCurrentFolderId);
|
|
|
|
|
this.startActivityForResult(intent, REQUEST_CODE_NEW_NODE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @method batchDelete
|
|
|
|
|
* @description:
|
|
|
|
@ -558,15 +660,15 @@ 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 (mCurrentFolderId == Notes.ID_TRASH_FOLER) {
|
|
|
|
|
if (DataUtils.batchDeleteNotes(mContentResolver, mNotesListAdapter
|
|
|
|
|
.getSelectedItemIds())) {
|
|
|
|
|
} else {
|
|
|
|
|
Log.e(TAG, "Delete notes error, should not happens");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//已同步,将删除的便签移到垃圾桶
|
|
|
|
|
// 将删除的便签移到回收站
|
|
|
|
|
else {
|
|
|
|
|
if (!DataUtils.batchMoveToFolder(mContentResolver, mNotesListAdapter
|
|
|
|
|
.getSelectedItemIds(), Notes.ID_TRASH_FOLER)) {
|
|
|
|
@ -891,6 +993,14 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
/**
|
|
|
|
|
* @method onPrepareOptionsMenu
|
|
|
|
|
* @description 准备菜单选项的回调方法,menu是Android自带的对象
|
|
|
|
|
* @date: 1/2/2024 7:40 PM
|
|
|
|
|
* @author: YangYizhe
|
|
|
|
|
* @param [menu] 菜单对象
|
|
|
|
|
* @return boolean 返回值指示是否处理了菜单创建事件
|
|
|
|
|
*/
|
|
|
|
|
public boolean onPrepareOptionsMenu(Menu menu) {
|
|
|
|
|
menu.clear();
|
|
|
|
|
if (mState == ListEditState.NOTE_LIST) {
|
|
|
|
@ -905,10 +1015,29 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
|
} else {
|
|
|
|
|
Log.e(TAG, "Wrong state:" + mState);
|
|
|
|
|
}
|
|
|
|
|
// 若在隐私模式之中,则不显示进入隐私模式的选项,不在隐私模式之中,则不显示退出隐私模式选项
|
|
|
|
|
if(isSecretMode()){
|
|
|
|
|
menu.findItem(R.id.menu_secret).setVisible(false);
|
|
|
|
|
} else {
|
|
|
|
|
menu.findItem(R.id.menu_quit_secret).setVisible(false);
|
|
|
|
|
}
|
|
|
|
|
if(mBackgroundColor==1) {
|
|
|
|
|
menu.findItem(R.id.menu_light_mode).setVisible(false);
|
|
|
|
|
} else {
|
|
|
|
|
menu.findItem(R.id.menu_dark_mode).setVisible(false);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
/**
|
|
|
|
|
* @method onOptionsItemSelected
|
|
|
|
|
* @description 处理菜单选项的选择事件。根据被选择的菜单项不同,该方法会触发不同的操作。
|
|
|
|
|
* @date: 1/2/2024 7:41 PM
|
|
|
|
|
* @author: YangYizhe
|
|
|
|
|
* @param [item] 被选择的菜单项
|
|
|
|
|
* @return boolean 返回值指示是否处理了菜单选择事件
|
|
|
|
|
*/
|
|
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
|
|
int itemId = item.getItemId();
|
|
|
|
|
if (itemId == R.id.menu_new_folder) {
|
|
|
|
@ -931,6 +1060,16 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
|
|
|
|
|
createNewNote();
|
|
|
|
|
} else if (itemId == R.id.menu_search) {
|
|
|
|
|
onSearchRequested();
|
|
|
|
|
} else if (itemId == R.id.menu_secret) {
|
|
|
|
|
enterSecretMode();
|
|
|
|
|
} else if (itemId == R.id.menu_quit_secret){
|
|
|
|
|
quitSecretMode();
|
|
|
|
|
} else if(itemId == R.id.menu_light_mode) {
|
|
|
|
|
switchBackground();
|
|
|
|
|
} else if(itemId == R.id.menu_dark_mode) {
|
|
|
|
|
switchBackground();
|
|
|
|
|
} else if (itemId == R.id.menu_restore) {
|
|
|
|
|
restoreDeletedNodes();
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|