介绍
因为当前项目的设置已被加密,客户不希望通过下拉窗口的设置图标进入设置,决定去掉该图标。
效果展示
分析
这里首先想到在SystemUI寻找这个图标的资源文件,找到资源文件后寻找对应控件调用的地方,根据id寻找控件代码即可。
修改
首先找到了对应的资源文件
路径:vendor/mediatek/proprietary/packages/apps/SystemUI/res/drawable/ic_settings.xml
通过搜索我们发现是在如下路径调用,这里我按钮是在容器中的,我们直接搜索容器ID的绑定代码。
路径:vendor/mediatek/proprietary/packages/apps/SystemUI/res-keyguard/layout/footer_actions.xml
<com.android.systemui.statusbar.AlphaOptimizedFrameLayout
android:id="@+id/settings_button_container"
android:layout_width="@dimen/qs_footer_action_button_size"
android:layout_height="@dimen/qs_footer_action_button_size"
android:background="@drawable/qs_footer_action_circle"
android:clipChildren="false"
android:clipToPadding="false">
<com.android.systemui.statusbar.phone.SettingsButton
android:id="@+id/settings_button"
android:layout_width="@dimen/qs_footer_icon_size"
android:layout_height="@dimen/qs_footer_icon_size"
android:layout_gravity="center"
android:background="@android:color/transparent"
android:focusable="false"
android:clickable="false"
android:importantForAccessibility="yes"
android:contentDescription="@string/accessibility_quick_settings_settings"
android:scaleType="centerInside"
android:src="@drawable/ic_settings"
android:tint="?android:attr/textColorPrimary" />
</com.android.systemui.statusbar.AlphaOptimizedFrameLayout>
控件是在onFinishInflate中完成绑定的,接着往下看,在updateVisibilities中更新了控件的显示状态,那只需在最后设置显示状态为GONE即可,代码如下
路径:vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/qs/FooterActionsView.kt
override fun onFinishInflate() {
super.onFinishInflate()
settingsContainer = findViewById(R.id.settings_button_container)
multiUserSwitch = findViewById(R.id.multi_user_switch)
multiUserAvatar = multiUserSwitch.findViewById(R.id.multi_user_avatar)
// RenderThread is doing more harm than good when touching the header (to expand quick
// settings), so disable it for this view
if (settingsContainer.background is RippleDrawable) {
(settingsContainer.background as RippleDrawable).setForceSoftware(true)
}
importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_YES
}
private fun updateVisibilities(
multiUserEnabled: Boolean
) {
settingsContainer.visibility = if (qsDisabled) GONE else VISIBLE
multiUserSwitch.visibility = if (multiUserEnabled) VISIBLE else GONE
val isDemo = UserManager.isDeviceInDemoMode(context)
//*/soda water.20240109 Remove the drop-down Settings entry
settingsContainer.visibility = GONE
/*
settingsContainer.visibility = if (isDemo) INVISIBLE else VISIBLE
*/
}