本文主要是介绍Android 13 移除下拉栏中的设置入口,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
介绍
因为当前项目的设置已被加密,客户不希望通过下拉窗口的设置图标进入设置,决定去掉该图标。
效果展示
分析
这里首先想到在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.AlphaOptimizedFrameLayoutandroid: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.SettingsButtonandroid: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 viewif (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 VISIBLEmultiUserSwitch.visibility = if (multiUserEnabled) VISIBLE else GONEval isDemo = UserManager.isDeviceInDemoMode(context)//*/soda water.20240109 Remove the drop-down Settings entrysettingsContainer.visibility = GONE/*settingsContainer.visibility = if (isDemo) INVISIBLE else VISIBLE*/}
这篇关于Android 13 移除下拉栏中的设置入口的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!