重构日志窗口UI主题颜色系统,统一使用toolbarTextColor和toolbarBackgroundColor

【主要变更】

1. 新增主题颜色属性
   - 新增 toolbarTextColor 属性定义(普通模式:黑色, 深色模式:#E0E0E0)
   - 新增 toolbarBackgroundColor 属性定义(普通模式:绿色, 深色模式:深蓝色)

2. 移除废弃颜色属性
   - 移除 buttonTextColor 属性定义
   - 移除 buttonBackgroundColor 属性定义

3. 更新布局文件(普通模式+深色模式)
   - view_log.xml: TextView(LV:)、CheckBox(Selectable/ALL) 使用 toolbarTextColor
   - view_log.xml: Button(Clean/Copy) 使用 toolbarBackgroundColor
   - item_logtag.xml: CheckBox 使用 toolbarTextColor
   - activity_main.xml: 所有Button使用 toolbarBackgroundColor
   - activity_crash_test.xml: 所有Button使用 toolbarBackgroundColor
   - activity_nfc_rsa_operate.xml: Button使用 toolbarBackgroundColor
   - dialog_winboll_host.xml: Button使用 toolbarBackgroundColor

4. 更新Java代码
   - LogView.java: CheckBox和TextView使用主题属性获取 toolbarTextColor
   - LogTagSpinner.java: 下拉框文本颜色使用 toolbarTextColor

5. 更新样式定义
   - styles.xml: 主题属性引用新的 toolbarTextColor/toolbarBackgroundColor
   - attrs.xml: 移除废弃属性,保留 toolbarTextColor/toolbarBackgroundColor
   - colors.xml: 添加新的颜色定义

【适配说明】
- 统一普通模式和深色模式的颜色管理
- 确保日志窗口所有控件颜色与主窗口保持一致
This commit is contained in:
2026-05-12 09:13:16 +08:00
parent 43da2bc03a
commit fe0b2f97ea
23 changed files with 86 additions and 67 deletions

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Mon May 11 20:29:55 HKT 2026
#Tue May 12 09:06:52 CST 2026
stageCount=9
libraryProject=libappbase
baseVersion=15.20
publishVersion=15.20.8
buildCount=0
buildCount=22
baseBetaVersion=15.20.9

View File

@@ -8,6 +8,7 @@ package cc.winboll.studio.libappbase;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Handler;
import android.os.Message;
import android.text.Editable;
@@ -248,7 +249,10 @@ public class LogView extends RelativeLayout {
}
mSelectAllTAGCheckBox.setLayoutParams(layoutParams2);
//mSelectAllTAGCheckBox.setPadding(0,0,0,0);
mSelectAllTAGCheckBox.setTextColor(mContext.getResources().getColor(R.color.white));
TypedArray ta1 = mContext.obtainStyledAttributes(new int[] { R.attr.toolbarTextColor });
int toolbarTextColor1 = ta1.getColor(0, mContext.getResources().getColor(R.color.white));
ta1.recycle();
mSelectAllTAGCheckBox.setTextColor(toolbarTextColor1);
mSelectAllTAGCheckBox.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
@@ -502,10 +506,17 @@ public class LogView extends RelativeLayout {
}
holder.tvText.setLayoutParams(layoutParams);
holder.tvText.setPadding(0,0,0,0);
holder.tvText.setTextColor(mContext.getResources().getColor(R.color.white));
TypedArray ta2 = mContext.obtainStyledAttributes(new int[] { R.attr.toolbarTextColor });
int toolbarTextColor2 = ta2.getColor(0, mContext.getResources().getColor(R.color.white));
ta2.recycle();
holder.tvText.setTextColor(toolbarTextColor2);
holder.cbChecked.setChecked(item.isChecked());
holder.cbChecked.setLayoutParams(layoutParams);
holder.cbChecked.setPadding(0,0,0,0);
TypedArray ta3 = mContext.obtainStyledAttributes(new int[] { R.attr.toolbarTextColor });
int toolbarTextColor3 = ta3.getColor(0, mContext.getResources().getColor(R.color.white));
ta3.recycle();
holder.cbChecked.setTextColor(toolbarTextColor3);
holder.cbChecked.setOnClickListener(new View.OnClickListener(){
@Override

View File

@@ -3,6 +3,7 @@ package cc.winboll.studio.libappbase.widget;
import android.content.Context;
import android.graphics.Color;
import android.text.TextUtils;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.View;
@@ -153,9 +154,12 @@ public class LogTagSpinner extends Spinner {
itemTv.setPadding(mTextPadding, 0, mTextPadding, 0);
// 4. 文字对齐(垂直居中+靠左,符合常规 UI 设计)
//itemTv.setGravity(View.GRAVITY_CENTER_VERTICAL | View.GRAVITY_START);
// 5. 文字颜色(统一深色,可改为项目颜色资源
itemTv.setTextColor(this.mContext.getColor(R.color.white));
itemTv.setBackgroundColor(this.mContext.getColor(R.color.btn_gray_normal));
// 5. 文字颜色(使用主题属性 ?attr/toolbarTextColor
TypedArray ta = mContext.obtainStyledAttributes(new int[] { R.attr.toolbarTextColor });
int toolbarTextColor = ta.getColor(0, mContext.getResources().getColor(R.color.white));
ta.recycle();
itemTv.setTextColor(toolbarTextColor);
itemTv.setBackgroundColor(this.mContext.getResources().getColor(R.color.btn_gray_normal));
// 6. 文字溢出处理(最多 2 行,超出省略,避免长标签换行过多)
itemTv.setSingleLine(false);
itemTv.setMaxLines(2);

View File

@@ -50,8 +50,8 @@
android:layout_height="wrap_content"
android:text="功能按钮待激活"
android:textSize="16sp"
android:textColor="?attr/buttonTextColor"
android:backgroundTint="?attr/buttonBackgroundColor"
android:textColor="?attr/toolbarTextColor"
android:backgroundTint="?attr/toolbarBackgroundColor"
android:padding="14dp"
android:enabled="false"/>

View File

@@ -53,8 +53,8 @@
android:layout_height="wrap_content"
android:text="确认"
android:textSize="14sp"
android:backgroundTint="?attr/buttonBackgroundColor"
android:textColor="?attr/buttonTextColor"/>
android:backgroundTint="?attr/toolbarBackgroundColor"
android:textColor="?attr/toolbarTextColor"/>
</LinearLayout>

View File

@@ -18,6 +18,7 @@
android:layout_width="wrap_content"
android:layout_height="@dimen/log_button_height"
android:textSize="@dimen/log_text_size"
android:textColor="?attr/toolbarTextColor"
android:id="@+id/viewlogtagCheckBox1"/>
</LinearLayout>

View File

@@ -21,7 +21,7 @@
android:textSize="@dimen/log_text_size"
android:text="Clean"
android:textColor="?attr/activityTextColor"
android:background="?attr/buttonBackgroundColor"
android:background="?attr/toolbarBackgroundColor"
android:layout_centerVertical="true"
android:id="@+id/viewlogButtonClean"
android:layout_marginLeft="5dp"/>
@@ -36,7 +36,7 @@
android:layout_centerVertical="true"
android:id="@+id/viewlogTextView1"
android:background="?attr/colorTittleBackgound"
android:textColor="?attr/colorText"/>
android:textColor="?attr/toolbarTextColor"/>
<cc.winboll.studio.libappbase.widget.LogTagSpinner
android:layout_width="wrap_content"
@@ -56,14 +56,14 @@
android:background="?attr/colorTittleBackgound"
android:id="@+id/viewlogCheckBoxSelectable"
android:padding="@dimen/log_text_padding"
android:textColor="?attr/colorText"/>
android:textColor="?attr/toolbarTextColor"/>
<Button
android:layout_width="@dimen/log_button_width"
android:layout_height="@dimen/log_button_height"
android:textSize="@dimen/log_text_size"
android:textColor="?attr/activityTextColor"
android:background="?attr/buttonBackgroundColor"
android:background="?attr/toolbarBackgroundColor"
android:text="Copy"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
@@ -89,7 +89,7 @@
android:padding="2dp"
android:id="@+id/viewlogCheckBox1"
android:background="?attr/colorTittleBackgound"
android:textColor="?attr/colorText"
android:textColor="?attr/toolbarTextColor"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"/>

View File

@@ -50,8 +50,8 @@
android:layout_height="wrap_content"
android:text="功能按钮待激活"
android:textSize="16sp"
android:textColor="?attr/buttonTextColor"
android:backgroundTint="?attr/buttonBackgroundColor"
android:textColor="?attr/toolbarTextColor"
android:backgroundTint="?attr/toolbarBackgroundColor"
android:padding="14dp"
android:enabled="false"/>

View File

@@ -53,8 +53,8 @@
android:layout_height="wrap_content"
android:text="确认"
android:textSize="14sp"
android:backgroundTint="?attr/buttonBackgroundColor"
android:textColor="?attr/buttonTextColor"/>
android:backgroundTint="?attr/toolbarBackgroundColor"
android:textColor="?attr/toolbarTextColor"/>
</LinearLayout>

View File

@@ -18,6 +18,7 @@
android:layout_width="wrap_content"
android:layout_height="@dimen/log_button_height"
android:textSize="@dimen/log_text_size"
android:textColor="?attr/toolbarTextColor"
android:id="@+id/viewlogtagCheckBox1"/>
</LinearLayout>

View File

@@ -21,7 +21,7 @@
android:textSize="@dimen/log_text_size"
android:text="Clean"
android:textColor="?attr/activityTextColor"
android:background="?attr/buttonBackgroundColor"
android:background="?attr/toolbarBackgroundColor"
android:layout_centerVertical="true"
android:id="@+id/viewlogButtonClean"
android:layout_marginLeft="5dp"/>
@@ -36,7 +36,7 @@
android:layout_centerVertical="true"
android:id="@+id/viewlogTextView1"
android:background="?attr/colorTittleBackgound"
android:textColor="?attr/colorText"/>
android:textColor="?attr/toolbarTextColor"/>
<cc.winboll.studio.libappbase.widget.LogTagSpinner
android:layout_width="wrap_content"
@@ -56,14 +56,14 @@
android:background="?attr/colorTittleBackgound"
android:id="@+id/viewlogCheckBoxSelectable"
android:padding="@dimen/log_text_padding"
android:textColor="?attr/colorText"/>
android:textColor="?attr/toolbarTextColor"/>
<Button
android:layout_width="@dimen/log_button_width"
android:layout_height="@dimen/log_button_height"
android:textSize="@dimen/log_text_size"
android:textColor="?attr/activityTextColor"
android:background="?attr/buttonBackgroundColor"
android:background="?attr/toolbarBackgroundColor"
android:text="Copy"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
@@ -89,7 +89,7 @@
android:padding="2dp"
android:id="@+id/viewlogCheckBox1"
android:background="?attr/colorTittleBackgound"
android:textColor="?attr/colorText"
android:textColor="?attr/toolbarTextColor"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"/>

View File

@@ -20,11 +20,7 @@
<attr name="aboutViewDividerColor" format="color" />
</declare-styleable>
<!-- ButtonStyle 样式属性 -->
<declare-styleable name="ButtonStyle">
<attr name="buttonBackgroundColor" format="color" />
<attr name="buttonTextColor" format="color" />
</declare-styleable>
<!-- DialogStyle 样式属性 -->
<declare-styleable name="DialogStyle">

View File

@@ -63,7 +63,9 @@
<!-- ============== 主题颜色 ============== -->
<color name="mainWindowBackgroundColor">#FF0D1B2A</color>
<color name="mainWindowTextColor">#FFE0E0E0</color>
<color name="buttonBackgroundColor">#FF1E3A5F</color>
<color name="toolbarTextColor">#FFE0E0E0</color>
<color name="toolbarBackgroundColor">#FF1E3A5F</color>
<color name="debugTextColor">#FF00FF00</color>
</resources>

View File

@@ -8,12 +8,12 @@
<item name="aboutViewTextColor">?attr/mainWindowDarkTextColor</item>
<item name="aboutViewTitleColor">?attr/mainWindowDarkTextColor</item>
<item name="aboutViewDividerColor">?attr/mainWindowTextColor</item>
<item name="buttonBackgroundColor">@color/buttonBackgroundColor</item>
<item name="buttonTextColor">?attr/mainWindowDarkTextColor</item>
<item name="dialogBackgroundColor">?attr/mainWindowDarkBackgroundColor</item>
<item name="dialogTextColor">?attr/mainWindowDarkTextColor</item>
<item name="toolbarBackgroundColor">?attr/buttonBackgroundColor</item>
<item name="toolbarTextColor">?attr/mainWindowDarkTextColor</item>
<item name="toolbarBackgroundColor">@color/toolbarBackgroundColor</item>
<item name="toolbarTextColor">@color/toolbarTextColor</item>
<item name="textViewBackgroundColor">?attr/mainWindowDarkBackgroundColor</item>
<item name="textViewTextColor">?attr/mainWindowDarkTextColor</item>
<item name="editTextBackgroundColor">?attr/mainWindowDarkBackgroundColor</item>
@@ -29,12 +29,14 @@
<!-- DebugActivityTheme 深色模式样式 -->
<style name="DebugActivityTheme" parent="@android:style/Theme.DeviceDefault.NoActionBar">
<item name="android:statusBarColor">@color/mainWindowBackgroundColor</item>
<item name="android:statusBarColor">@color/toolbarBackgroundColor</item>
<item name="colorTittle">?attr/mainWindowDarkTextColor</item>
<item name="colorTittleBackgound">@color/buttonBackgroundColor</item>
<item name="colorTittleBackgound">@color/toolbarBackgroundColor</item>
<item name="colorText">?attr/debugTextColor</item>
<item name="colorTextBackgound">?attr/mainWindowDarkBackgroundColor</item>
<item name="debugTextColor">@color/debugTextColor</item>
<item name="toolbarTextColor">@color/toolbarTextColor</item>
</style>
<!-- DialogStyle 对话框样式 -->

View File

@@ -26,11 +26,7 @@
<attr name="aboutViewDividerColor" format="color" />
</declare-styleable>
<!-- ButtonStyle 样式属性 -->
<declare-styleable name="ButtonStyle">
<attr name="buttonBackgroundColor" format="color" />
<attr name="buttonTextColor" format="color" />
</declare-styleable>
<!-- DialogStyle 样式属性 -->
<declare-styleable name="DialogStyle">

View File

@@ -63,7 +63,9 @@
<!-- ============== 主题颜色 ============== -->
<color name="mainWindowBackgroundColor">#FFF5F5F5</color>
<color name="mainWindowTextColor">#FF000000</color>
<color name="buttonBackgroundColor">#FF00B322</color>
<color name="toolbarTextColor">#FF000000</color>
<color name="toolbarBackgroundColor">#FF00B322</color>
<color name="debugTextColor">#FF808080</color>
</resources>

View File

@@ -8,12 +8,12 @@
<item name="aboutViewTextColor">?attr/mainWindowTextColor</item>
<item name="aboutViewTitleColor">?attr/mainWindowTextColor</item>
<item name="aboutViewDividerColor">?attr/mainWindowDarkTextColor</item>
<item name="buttonBackgroundColor">@color/buttonBackgroundColor</item>
<item name="buttonTextColor">?attr/mainWindowTextColor</item>
<item name="dialogBackgroundColor">?attr/mainWindowBackgroundColor</item>
<item name="dialogTextColor">?attr/mainWindowTextColor</item>
<item name="toolbarBackgroundColor">?attr/buttonBackgroundColor</item>
<item name="toolbarTextColor">?attr/mainWindowTextColor</item>
<item name="toolbarBackgroundColor">@color/toolbarBackgroundColor</item>
<item name="toolbarTextColor">@color/toolbarTextColor</item>
<item name="textViewBackgroundColor">?attr/mainWindowBackgroundColor</item>
<item name="textViewTextColor">?attr/mainWindowTextColor</item>
<item name="editTextBackgroundColor">?attr/mainWindowBackgroundColor</item>
@@ -29,12 +29,14 @@
<!-- DebugActivityTheme 普通模式样式 -->
<style name="DebugActivityTheme" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar">
<item name="android:statusBarColor">@color/buttonBackgroundColor</item>
<item name="android:statusBarColor">@color/toolbarBackgroundColor</item>
<item name="colorTittle">?attr/mainWindowTextColor</item>
<item name="colorTittleBackgound">@color/buttonBackgroundColor</item>
<item name="colorTittleBackgound">@color/toolbarBackgroundColor</item>
<item name="colorText">?attr/debugTextColor</item>
<item name="colorTextBackgound">?attr/mainWindowBackgroundColor</item>
<item name="debugTextColor">@color/debugTextColor</item>
<item name="toolbarTextColor">@color/toolbarTextColor</item>
</style>
<!-- DialogStyle 对话框样式 -->