From f03343434eea6dfd1c259757ef50cab00bb4af02 Mon Sep 17 00:00:00 2001 From: whale Date: Fri, 30 Jan 2026 08:44:42 +0800 Subject: [PATCH] =?UTF-8?q?UI=E7=95=8C=E9=9D=A2=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../net/micode/notes/ui/NoteEditActivity.java | 2 - .../micode/notes/ui/NotesListActivity.java | 106 +++-- src/main/res/anim/btn_add_note_elevation.xml | 17 + src/main/res/layout/note_edit.xml | 431 ++++++++++-------- src/main/res/layout/note_list.xml | 104 +++-- src/main/res/layout/todo_list.xml | 137 ------ src/main/res/values-night/themes.xml | 17 +- src/main/res/values/colors.xml | 30 +- src/main/res/values/themes.xml | 17 +- 9 files changed, 450 insertions(+), 411 deletions(-) create mode 100644 src/main/res/anim/btn_add_note_elevation.xml delete mode 100644 src/main/res/layout/todo_list.xml diff --git a/src/main/java/net/micode/notes/ui/NoteEditActivity.java b/src/main/java/net/micode/notes/ui/NoteEditActivity.java index 3b3b70f..57d7f3a 100644 --- a/src/main/java/net/micode/notes/ui/NoteEditActivity.java +++ b/src/main/java/net/micode/notes/ui/NoteEditActivity.java @@ -123,7 +123,6 @@ public class NoteEditActivity extends Activity implements OnClickListener, public ImageView ibSetBgColor; // 设置背景色按钮 public ImageButton ibInsertImage; // 插入图片按钮 public ImageButton ibExtractImage; // 提取图片内容按钮 - public TextView tvTitleHint; // 标题提示文字 public EditText etTitle; // 标题输入框 public TextView tvTitleCount; // 字符数提示 public View titleArea; // 标题区域 @@ -600,7 +599,6 @@ public class NoteEditActivity extends Activity implements OnClickListener, mNoteHeaderHolder.ibInsertImage.setOnClickListener(this); mNoteHeaderHolder.ibExtractImage = (ImageButton) findViewById(R.id.extract_img_btn); mNoteHeaderHolder.ibExtractImage.setOnClickListener(this); - mNoteHeaderHolder.tvTitleHint = (TextView) findViewById(R.id.tv_title_hint); mNoteHeaderHolder.etTitle = (EditText) findViewById(R.id.et_title); mNoteHeaderHolder.etTitle.addTextChangedListener(new TextWatcher() { @Override diff --git a/src/main/java/net/micode/notes/ui/NotesListActivity.java b/src/main/java/net/micode/notes/ui/NotesListActivity.java index f4c1511..29f4275 100644 --- a/src/main/java/net/micode/notes/ui/NotesListActivity.java +++ b/src/main/java/net/micode/notes/ui/NotesListActivity.java @@ -1049,12 +1049,14 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt } else { mState = ListEditState.SUB_FOLDER; } - if (data.getId() == Notes.ID_CALL_RECORD_FOLDER) { - mTitleBar.setText(R.string.call_record_folder_name); - } else { - mTitleBar.setText(data.getSnippet()); + if (mTitleBar != null) { + if (data.getId() == Notes.ID_CALL_RECORD_FOLDER) { + mTitleBar.setText(R.string.call_record_folder_name); + } else { + mTitleBar.setText(data.getSnippet()); + } + mTitleBar.setVisibility(View.VISIBLE); } - mTitleBar.setVisibility(View.VISIBLE); } public void onClick(View v) { @@ -1074,15 +1076,23 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt private void updatePrivacySpaceUI() { if (!TextUtils.isEmpty(mCurrentPrivacySpaceId)) { // 在隐私空间中,显示隐私空间名称 - mTitleBar.setText("隐私空间"); - mTitleBar.setVisibility(View.VISIBLE); + if (mTitleBar != null) { + mTitleBar.setText("隐私空间"); + mTitleBar.setVisibility(View.VISIBLE); + } // 显示隐私空间返回按钮 - mPrivacyBackButton.setVisibility(View.VISIBLE); + if (mPrivacyBackButton != null) { + mPrivacyBackButton.setVisibility(View.VISIBLE); + } } else { // 不在隐私空间中,隐藏标题栏或显示默认标题 - mTitleBar.setVisibility(View.GONE); + if (mTitleBar != null) { + mTitleBar.setVisibility(View.GONE); + } // 隐藏隐私空间返回按钮 - mPrivacyBackButton.setVisibility(View.GONE); + if (mPrivacyBackButton != null) { + mPrivacyBackButton.setVisibility(View.GONE); + } } } @@ -1189,33 +1199,61 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt switch (mState) { case SUB_FOLDER: // 查询当前文件夹的父文件夹ID - Cursor cursor = mContentResolver.query( - Notes.CONTENT_NOTE_URI, - new String[] { NoteColumns.PARENT_ID, NoteColumns.SNIPPET }, - NoteColumns.ID + "=?", - new String[] { String.valueOf(mCurrentFolderId) }, - null - ); - - if (cursor != null && cursor.moveToFirst()) { - long parentId = cursor.getLong(0); - String folderName = cursor.getString(1); - cursor.close(); + Cursor cursor = null; + try { + cursor = mContentResolver.query( + Notes.CONTENT_NOTE_URI, + new String[] { NoteColumns.PARENT_ID, NoteColumns.SNIPPET }, + NoteColumns.ID + "=?", + new String[] { String.valueOf(mCurrentFolderId) }, + null + ); - if (parentId == Notes.ID_ROOT_FOLDER) { - // 返回到根文件夹 + if (cursor != null && cursor.moveToFirst()) { + long parentId = cursor.getLong(0); + String folderName = cursor.getString(1); + + if (parentId == Notes.ID_ROOT_FOLDER) { + // 返回到根文件夹 + mCurrentFolderId = Notes.ID_ROOT_FOLDER; + mState = ListEditState.NOTE_LIST; + if (mTitleBar != null) { + mTitleBar.setVisibility(View.GONE); + } + } else { + // 返回到上一级文件夹 + mCurrentFolderId = parentId; + mState = ListEditState.SUB_FOLDER; + if (mTitleBar != null) { + mTitleBar.setText(folderName); + mTitleBar.setVisibility(View.VISIBLE); + } + } + } else { + // 如果查询失败,默认返回到根文件夹 mCurrentFolderId = Notes.ID_ROOT_FOLDER; mState = ListEditState.NOTE_LIST; + if (mTitleBar != null) { + mTitleBar.setVisibility(View.GONE); + } + } + } catch (Exception e) { + // 捕获异常,防止崩溃 + e.printStackTrace(); + // 发生异常时,默认返回到根文件夹 + mCurrentFolderId = Notes.ID_ROOT_FOLDER; + mState = ListEditState.NOTE_LIST; + if (mTitleBar != null) { mTitleBar.setVisibility(View.GONE); - } else { - // 返回到上一级文件夹 - mCurrentFolderId = parentId; - mState = ListEditState.SUB_FOLDER; - mTitleBar.setText(folderName); - mTitleBar.setVisibility(View.VISIBLE); } - } else if (cursor != null) { - cursor.close(); + } finally { + if (cursor != null) { + try { + cursor.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } } startAsyncNotesListQuery(); @@ -1224,7 +1262,9 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt mCurrentFolderId = Notes.ID_ROOT_FOLDER; mState = ListEditState.NOTE_LIST; mAddNewNote.setVisibility(View.VISIBLE); - mTitleBar.setVisibility(View.GONE); + if (mTitleBar != null) { + mTitleBar.setVisibility(View.GONE); + } startAsyncNotesListQuery(); break; case NOTE_LIST: diff --git a/src/main/res/anim/btn_add_note_elevation.xml b/src/main/res/anim/btn_add_note_elevation.xml new file mode 100644 index 0000000..3454cd1 --- /dev/null +++ b/src/main/res/anim/btn_add_note_elevation.xml @@ -0,0 +1,17 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/main/res/layout/note_edit.xml b/src/main/res/layout/note_edit.xml index 173dc28..06e55b5 100644 --- a/src/main/res/layout/note_edit.xml +++ b/src/main/res/layout/note_edit.xml @@ -16,22 +16,26 @@ --> + + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:background="@color/surface" + android:padding="8dp" + android:elevation="4dp" + android:gravity="center_vertical"> + android:src="@drawable/ic_undo" + android:tint="@color/onSurface" + android:alpha="0.8" /> + android:src="@drawable/ic_redo" + android:tint="@color/onSurface" + android:alpha="0.8" /> + android:background="@android:color/transparent" + android:padding="8dp" + android:contentDescription="设置背景颜色" + android:src="@drawable/ic_format_color_fill" + android:tint="@color/primary" /> + android:src="@android:drawable/ic_menu_camera" + android:tint="@color/onSurface" + android:alpha="0.8" /> + android:src="@android:drawable/ic_menu_camera" + android:tint="@color/onSurface" + android:alpha="0.8" /> + + android:padding="16dp" + android:background="@color/surface"> - + android:singleLine="true" + android:fontFamily="sans-serif-medium" /> + android:textSize="14sp" + android:textColor="@color/onSurface" + android:alpha="0.6" + android:layout_marginLeft="8dp" + android:gravity="center_vertical" /> + android:background="@color/divider_color" /> + android:padding="8dp" + android:background="@color/surface" + android:elevation="2dp"> + android:src="@drawable/ic_format_bold" + android:tint="@color/onSurface" /> + android:src="@drawable/ic_format_italic" + android:tint="@color/onSurface" /> + android:src="@drawable/ic_format_underlined" + android:tint="@color/onSurface" /> + android:src="@drawable/ic_format_color_text" + android:tint="@color/onSurface" /> + android:src="@drawable/ic_format_color_fill" + android:tint="@color/onSurface" /> - - + android:layout_gravity="left|top"> + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:background="@color/surface" + android:layout_margin="16dp" + android:layout_marginTop="8dp" + android:layout_marginBottom="8dp" + android:padding="24dp" + android:elevation="4dp" + android:radius="12dp"> + android:lineSpacingMultiplier="1.3" + android:textSize="16sp" /> - - - + + android:visibility="gone" + android:elevation="8dp" + android:padding="8dp" + android:radius="12dp"> + android:layout_width="48dp" + android:layout_height="48dp" + android:padding="4dp"> + android:layout_height="match_parent" + android:background="@color/note_bg_yellow" + android:radius="8dp" /> + android:src="@drawable/ic_done_circle" + android:tint="@color/primary" /> + android:layout_width="48dp" + android:layout_height="48dp" + android:padding="4dp"> + android:layout_height="match_parent" + android:background="@color/note_bg_blue" + android:radius="8dp" /> + android:src="@drawable/ic_done_circle" + android:tint="@color/primary" /> + android:layout_width="48dp" + android:layout_height="48dp" + android:padding="4dp"> + android:layout_height="match_parent" + android:background="@color/note_bg_white" + android:radius="8dp" + android:elevation="1dp" /> + android:src="@drawable/ic_done_circle" + android:tint="@color/primary" /> + android:layout_width="48dp" + android:layout_height="48dp" + android:padding="4dp"> + android:layout_height="match_parent" + android:background="@color/note_bg_green" + android:radius="8dp" /> + android:src="@drawable/ic_done_circle" + android:tint="@color/primary" /> + android:layout_width="48dp" + android:layout_height="48dp" + android:padding="4dp"> + android:layout_height="match_parent" + android:background="@color/note_bg_red" + android:radius="8dp" /> + android:src="@drawable/ic_done_circle" + android:tint="@color/primary" /> + + android:visibility="gone" + android:elevation="8dp" + android:padding="16dp" + android:radius="16dp" + android:layout_margin="16dp"> + android:layout_weight="1" + android:padding="8dp"> - + android:text="Aa" + android:textSize="14sp" + android:textColor="@color/onSurface" + android:layout_marginBottom="8dp" + android:fontFamily="sans-serif-medium" /> + android:text="小" + android:textSize="14sp" + android:textColor="@color/onSurface" + android:alpha="0.8" /> + android:src="@drawable/ic_done_circle" + android:tint="@color/primary" /> + android:layout_weight="1" + android:padding="8dp"> - + android:text="Aa" + android:textSize="16sp" + android:textColor="@color/onSurface" + android:layout_marginBottom="8dp" + android:fontFamily="sans-serif-medium" /> + android:text="标准" + android:textSize="14sp" + android:textColor="@color/onSurface" + android:alpha="0.8" /> + android:src="@drawable/ic_done_circle" + android:tint="@color/primary" /> + android:layout_weight="1" + android:padding="8dp"> - + android:text="Aa" + android:textSize="18sp" + android:textColor="@color/onSurface" + android:layout_marginBottom="8dp" + android:fontFamily="sans-serif-medium" /> + android:text="大" + android:textSize="14sp" + android:textColor="@color/onSurface" + android:alpha="0.8" /> + android:src="@drawable/ic_done_circle" + android:tint="@color/primary" /> + android:layout_weight="1" + android:padding="8dp"> - + android:text="Aa" + android:textSize="20sp" + android:textColor="@color/onSurface" + android:layout_marginBottom="8dp" + android:fontFamily="sans-serif-medium" /> + android:text="超大" + android:textSize="14sp" + android:textColor="@color/onSurface" + android:alpha="0.8" /> + android:src="@drawable/ic_done_circle" + android:tint="@color/primary" /> + + android:layout_marginRight="16dp" + android:background="@color/surface" + android:elevation="4dp" + android:radius="20dp"> + android:textSize="14sp" + android:textColor="@color/primary" + android:gravity="center_vertical" + android:fontFamily="sans-serif-medium" /> - + \ No newline at end of file diff --git a/src/main/res/layout/note_list.xml b/src/main/res/layout/note_list.xml index 1c850a5..636abff 100644 --- a/src/main/res/layout/note_list.xml +++ b/src/main/res/layout/note_list.xml @@ -18,46 +18,40 @@ + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@color/background" + android:fitsSystemWindows="true"> - - + android:gravity="center_vertical" + android:layout_margin="16dp" + android:layout_marginTop="16dp" + android:layout_marginBottom="8dp" + android:elevation="4dp" + android:radius="12dp"> + android:tint="@color/onSurface" + android:alpha="0.6" + android:layout_marginRight="12dp" /> + android:textColorHint="@color/onSurface" + android:alpha="0.6" + android:textColor="@color/onSurface" /> @@ -94,8 +91,8 @@ android:layout_width="24dp" android:layout_height="24dp" android:src="@android:drawable/ic_menu_search" - android:tint="#808080" - android:layout_marginLeft="8dp" + android:tint="@color/primary" + android:layout_marginLeft="12dp" android:clickable="true" android:focusable="true" android:contentDescription="搜索" /> @@ -103,12 +100,14 @@ @@ -116,13 +115,14 @@ + android:layout_alignParentBottom="true" + android:elevation="8dp"> + android:focusable="true" + android:fontFamily="sans-serif-medium" /> + android:focusable="true" + android:fontFamily="sans-serif-medium" /> @@ -160,8 +163,10 @@ android:focusable="false" android:layout_alignParentRight="true" android:layout_above="@+id/view_switcher" - android:layout_marginRight="16dp" - android:layout_marginBottom="16dp" /> + android:layout_marginRight="24dp" + android:layout_marginBottom="24dp" + android:elevation="8dp" + android:stateListAnimator="@anim/btn_add_note_elevation" />