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

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

Kotlin 复制代码
    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
        */
    }
相关推荐
QuantumLeap丶28 分钟前
《Flutter全栈开发实战指南:从零到高级》- 25 -性能优化
android·flutter·ios
木易 士心2 小时前
MVC、MVP 与 MVVM:Android 架构演进之路
android·架构·mvc
百锦再2 小时前
国产数据库的平替亮点——关系型数据库架构适配
android·java·前端·数据库·sql·算法·数据库架构
走在路上的菜鸟2 小时前
Android学Dart学习笔记第十三节 注解
android·笔记·学习·flutter
介一安全3 小时前
【Frida Android】实战篇15:Frida检测与绕过——基于/proc/self/maps的攻防实战
android·网络安全·逆向·安全性测试·frida
hhy_smile3 小时前
Android 与 java 设计笔记
android·java·笔记
laocooon5238578863 小时前
C#二次开发中简单块的定义与应用
android·数据库·c#
似霰4 小时前
传统 Hal 开发笔记5 —— 添加硬件访问服务
android·framework·hal
恋猫de小郭4 小时前
Android 宣布 Runtime 编译速度史诗级提升:在编译时间上优化了 18%
android·前端·flutter
csj504 小时前
安卓基础之《(4)—Activity组件》
android