diff --git a/src/main/java/net/micode/notes/ui/NotesListActivity.java b/src/main/java/net/micode/notes/ui/NotesListActivity.java index 8e0ca96..34ea7a3 100644 --- a/src/main/java/net/micode/notes/ui/NotesListActivity.java +++ b/src/main/java/net/micode/notes/ui/NotesListActivity.java @@ -79,6 +79,8 @@ import java.io.InputStreamReader; import java.util.HashSet; public class NotesListActivity extends Activity implements OnClickListener, OnItemLongClickListener { + //首页背景变换 + private int mode = -1; private static final int FOLDER_NOTE_LIST_QUERY_TOKEN = 0; private static final int FOLDER_LIST_QUERY_TOKEN = 1; @@ -95,28 +97,38 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt NOTE_LIST, SUB_FOLDER, CALL_RECORD_FOLDER }; - // 声明一些私有成员变量。 - private ListEditState mState; // 当前列表的编辑状态 - private BackgroundQueryHandler mBackgroundQueryHandler; // 用于在后台执行查询的处理程序 - private NotesListAdapter mNotesListAdapter; // 笔记列表的适配器 - private ListView mNotesListView; // 显示笔记列表的视图 - private Button mAddNewNote; // 添加新笔记的按钮 - private boolean mDispatch; // 一个标志,可能用于控制事件分发 - private int mOriginY; // 原始Y坐标,可能用于触摸事件处理 - private int mDispatchY; // 分发的Y坐标,也可能用于触摸事件处理 - private TextView mTitleBar; // 标题栏文本视图 - private long mCurrentFolderId; // 当前文件夹的ID - private ContentResolver mContentResolver; // 内容解析器,用于访问应用的数据 - private ModeCallback mModeCallBack; // 模式回调接口的实现,可能用于在不同的操作模式之间切换 + private ListEditState mState; + + private BackgroundQueryHandler mBackgroundQueryHandler; + + private NotesListAdapter mNotesListAdapter; + + private ListView mNotesListView; + + private Button mAddNewNote; + + private boolean mDispatch; + + private int mOriginY; + + private int mDispatchY; + + private TextView mTitleBar; + + private long mCurrentFolderId; + + private ContentResolver mContentResolver; + + private ModeCallback mModeCallBack; private static final String TAG = "NotesListActivity"; public static final int NOTES_LISTVIEW_SCROLL_RATE = 30; - //正在关注的笔记数据对象 + private NoteItemData mFocusNoteDataItem; private static final String NORMAL_SELECTION = NoteColumns.PARENT_ID + "=?"; - //拼接访问串 + private static final String ROOT_FOLDER_SELECTION = "(" + NoteColumns.TYPE + "<>" + Notes.TYPE_SYSTEM + " AND " + NoteColumns.PARENT_ID + "=?)" + " OR (" + NoteColumns.ID + "=" + Notes.ID_CALL_RECORD_FOLDER + " AND " @@ -124,22 +136,12 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt private final static int REQUEST_CODE_OPEN_NODE = 102; private final static int REQUEST_CODE_NEW_NODE = 103; - //表示是否在私密模式 - public static int secret_mode = 0; - - /** - * @classname: NotesListActivity - * @methodname onCreate - * @description:完成活动的初始化 - * @date: 2024/1/4 11:47 - * @author: Xia Yanbo - * @param:savedInstanceState保存的状态 - */ + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - //根据布局文件呈现菜单视图 setContentView(R.layout.note_list); + getWindow().setBackgroundDrawableResource(R.drawable.decade);//将decade作为初始背景 initResources(); /** @@ -147,25 +149,13 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt */ setAppInfoFromRawRes(); } - /** - * @classname: NotesListActivity - * @methodname onActivityResult - * @description:当从活动中得到返回调用,处理返回的结果 - * @date: 2024/1/4 11:49 - * @author: Xia Yanbo - * @param:requestCode请求码 - * @param:resultCode结果码 - * @param:data 意图的数据 - */ + @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { - // 根据请求的代码类型进行相应的处理 - if (resultCode == RESULT_OK // 如果返回的结果码是RESULT_OK,表示操作成功 - && (requestCode == REQUEST_CODE_OPEN_NODE || requestCode == REQUEST_CODE_NEW_NODE)) { // 并且请求码是打开节点或新建节点 - // 清空笔记列表的适配器游标(可能是在执行打开或新建节点操作后,刷新或重置列表) + if (resultCode == RESULT_OK + && (requestCode == REQUEST_CODE_OPEN_NODE || requestCode == REQUEST_CODE_NEW_NODE)) { mNotesListAdapter.changeCursor(null); - } else { // 其他情况 - // 调用父类的onActivityResult方法,将结果传递给上层处理。 + } else { super.onActivityResult(requestCode, resultCode, data); } } @@ -425,35 +415,10 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt private void startAsyncNotesListQuery() { String selection = (mCurrentFolderId == Notes.ID_ROOT_FOLDER) ? ROOT_FOLDER_SELECTION : NORMAL_SELECTION; - if(secret_mode == 0) { - 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"); - } - else{ - String str1 = "520"; - String [] PROJECTION = new String [] { //定义一个新的PROJECTION数组,只换掉SNIPPET - NoteColumns.ID, - NoteColumns.ALERTED_DATE, - NoteColumns.BG_COLOR_ID, - NoteColumns.CREATED_DATE, - NoteColumns.HAS_ATTACHMENT, - NoteColumns.MODIFIED_DATE, - NoteColumns.NOTES_COUNT, - NoteColumns.PARENT_ID, -// NoteColumns.SNIPPET, - str1, - NoteColumns.TYPE, - NoteColumns.WIDGET_ID, - NoteColumns.WIDGET_TYPE, - }; - mBackgroundQueryHandler.startQuery(FOLDER_NOTE_LIST_QUERY_TOKEN, null, - Notes.CONTENT_NOTE_URI, PROJECTION, selection, new String[]{ - String.valueOf(mCurrentFolderId) - }, NoteColumns.TYPE + " DESC," + NoteColumns.MODIFIED_DATE + " DESC"); - - } + 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"); } private final class BackgroundQueryHandler extends AsyncQueryHandler { @@ -810,16 +775,28 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt } else { Log.e(TAG, "Wrong state:" + mState); } - if(secret_mode == 1) - menu.findItem(R.id.menu_secret).setVisible(false); - else - menu.findItem(R.id.menu_quit_secret).setVisible(false); + + if(mode==-1){//decade + menu.findItem(R.id.menu_decade).setVisible(false); + } + else if(mode==1){//zio + menu.findItem(R.id.menu_zio).setVisible(false); + } + return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { - if(item.getItemId()==R.id.menu_new_folder){ + if(item.getItemId()==R.id.menu_decade){ + mode = -1; + getWindow().setBackgroundDrawableResource(R.drawable.decade); + } + else if(item.getItemId()==R.id.menu_zio){ + mode = 1; + getWindow().setBackgroundDrawableResource(R.drawable.zio); + } + else if(item.getItemId()==R.id.menu_new_folder){ showCreateOrModifyFolderDialog(true); } else if(item.getItemId()==R.id.menu_export_text ){ @@ -846,50 +823,6 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt else if(item.getItemId()==R.id.menu_search) { onSearchRequested(); } - else if(item.getItemId()==R.id.menu_secret) - {//进入私密模式 - secret_mode = 1; - 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) { - startAsyncNotesListQuery(); - Toast.makeText(NotesListActivity.this,"您已进入私密模式",Toast.LENGTH_SHORT).show(); - } - }); - dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which){} - }); - dialog.show(); - startAsyncNotesListQuery(); - Toast.makeText(this,"您已进入私密模式",Toast.LENGTH_SHORT).show(); - } - else if(item.getItemId()==R.id.menu_quit_secret) - { //退出私密模式 - secret_mode = 0; - 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) { - startAsyncNotesListQuery(); - Toast.makeText(NotesListActivity.this,"您已退出私密模式",Toast.LENGTH_SHORT).show(); - } - }); - dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which){} - }); - dialog.show(); - - } - return true; } @@ -1027,16 +960,4 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt } return false; } - - public static void setSecretMode() { - if(secret_mode==0) - { - secret_mode=1; - } - else{ - secret_mode=0; - } - } - } - diff --git a/src/main/res/layout/note_list.xml b/src/main/res/layout/note_list.xml index 6b25d38..50d3a00 100644 --- a/src/main/res/layout/note_list.xml +++ b/src/main/res/layout/note_list.xml @@ -18,8 +18,8 @@ + android:layout_height="fill_parent"> + - + android:id="@+id/menu_decade" + android:title="@string/menu_decade"/> + diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index c54b8ad..89b1e42 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -39,6 +39,11 @@ /MIUI/notes/ notes_%s.txt + + + Background: decade + Background: zio + (%d) New Folder Export text @@ -75,8 +80,6 @@ Confirm to delete the selected %d notes? Confirm to delete this note? Have moved selected %1$d notes to %2$s folder - secret model - quit secret model SD card busy, not available now Export failed, please check SD card