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
        */
    }
相关推荐
码农coding20 分钟前
android12 InputManagerService分析之输入事件如何回到应用层
android
zhangguojia71 小时前
从一个窗口覆盖问题出发,理解 Android Window 的层级与权限
android
古法安卓3 小时前
Android-SELinux 策略调试实战:从 AVC 日志到策略修复
android·java·android studio
Dovis(誓平步青云)4 小时前
DevEco Studio 6.1.1 Windows 安装实录:从下载校验到首次启动
android·开发语言·数据库·人工智能·windows·harmonyos
Zender Han4 小时前
Flutter 自适应(Adaptive)与响应式(Responsive)设计实践:官方推荐方案详解
android·flutter·ios
我命由我123455 小时前
Android 开发问题:TopAppBar 和 topAppBarColors API is experimental...
android·java·java-ee·kotlin·android studio·android jetpack·android-studio
造火箭5 小时前
Android UI自动化测试可行性评估SKILL
android·功能测试·ui
hunterandroid7 小时前
[Android 从零到一] ViewPager2 与 Fragment 生命周期协同:从预加载到状态一致性
android·前端
mmsx7 小时前
一个黑边 Bug 修了两版:自己算矩阵直接黑屏,借库重建只用了一行 setZoom
android·前端
枢影Kernel8 小时前
Android CLI 与 Android Skills 最佳实践:把 AI Agent 接入可验证的 Android 开发流程
android