为了在 Android 14 的下拉菜单中增加自动亮度调节按钮,可以按照以下步骤进行代码修改。
1. 添加图标资源
在 SystemUI
资源文件夹中添加自动亮度图标:
文件路径:
frameworks/base/packages/SystemUI/res/drawable/ic_settings_display_white.xml
文件内容:
<vector xmlns:android="http://schemas.android.com/apk/res/android"android:width="24dp"android:height="24dp"android:viewportWidth="24.0"android:viewportHeight="24.0"><pathandroid:pathData="M20.31,9V4.31H15.62L12.31,1L9,4.31H4.31V9L1,12.31L4.31,15.62V20.31H9L12.31,23.62L15.62,20.31H20.31V15.62L23.62,12.31L20.31,9ZM18.31,14.79V18.31H14.79L12.31,20.79L9.83,18.31H6.31V14.79L3.83,12.31L6.31,9.83V6.31H9.83L12.31,3.83L14.79,6.31H18.31V9.83L20.79,12.31L18.31,14.79ZM17.31,12.31C17.31,15.07 15.07,17.31 12.31,17.31V7.31C15.07,7.31 17.31,9.55 17.31,12.31Z"android:fillType="evenOdd"android:fillColor="?android:attr/colorPrimary"/>
</vector>
2. 更新字符串资源
在 strings.xml
中添加自动亮度调节的标题:
文件路径:
frameworks/base/packages/SystemUI/res/values/strings.xml
frameworks/base/packages/SystemUI/res/values-zh-rCN/strings.xml
在 strings.xml
中新增:
<string name="autobrightness_title">AutoBrightness</string>
在 strings.xml (zh-rCN)
中新增:
<string name="autobrightness_title">自动亮度调节</string>
3. 配置快速设置中的自动亮度 Tile
在 config.xml
中将自动亮度添加到快速设置面板的默认项目中:
文件路径:
frameworks/base/packages/SystemUI/res/values/config.xml
修改内容:
<st