Android 10.0移除settings的长按弹框

介绍

因之前客户需求将settings加密了但一些WiFi还有热点的功能开启还可以通过长按settings的入口添加,客户想要长按settings什么快捷方式也不弹。

这里我们分析Launcher3的SystemShortcutFactory.java可以看出长按图标时的弹框加载是在getEnabledShortcuts此方法中,那么我只要找出settings对应的viewID跳过即可不弹框

路径:packages/apps/Launcher3/src/com/android/launcher3/popup/SystemShortcutFactory.java
此处打log抓到settings的id为5

    public @NonNull List<SystemShortcut> getEnabledShortcuts(Launcher launcher, ItemInfo info) {
        List<SystemShortcut> systemShortcuts = new ArrayList<>();
        for (SystemShortcut systemShortcut : mAllShortcuts) {
            //*/soda water.20230917 Screen Settings long press the screen
            if(info.getViewId()==5){
            Log.d("soda water","systemShortcut = "+systemShortcut.toString());
            continue;
            }
            //*/
            if (systemShortcut.getOnClickListener(launcher, info) != null) {
                systemShortcuts.add(systemShortcut);
            }
        }
        return systemShortcuts;
    }

上面的代码执行完我们长按拖动图标时会发现图标加载出现了问题应该是拖拽后没刷新,我们接着看PopupContainerWithArrow里的populateAndShow,我们在其中限制快捷方式长度为零的执行下reorderAndShow即可

路径:packages/apps/Launcher3/src/com/android/launcher3/popup/PopupContainerWithArrow.java
上面将id为5的都跳过添加列表了  所以当找到列表为0的就是我们要屏蔽的 并且加上箭头标志否则长按后文本会消失

    @TargetApi(Build.VERSION_CODES.P)
    protected void populateAndShow(final BubbleTextView originalIcon, int shortcutCount,
            final List<NotificationKeyData> notificationKeys, List<SystemShortcut> systemShortcuts) {
        mNumNotifications = notificationKeys.size();
        mOriginalIcon = originalIcon;
        //*/soda water.20230917 Screen Settings long press the screen
        if(systemShortcuts.size() == 0){
        int viewsToFlip = getChildCount();
        reorderAndShow(viewsToFlip);
        return;
        }
        //*/
        // Add views
        if (mNumNotifications > 0) {
            // Add notification entries
            View.inflate(getContext(), R.layout.notification_content, this);
            mNotificationItemView = new NotificationItemView(this);
            if (mNumNotifications == 1) {
                mNotificationItemView.removeFooter();
            }
            updateNotificationHeader();
        }
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

不太正常的移动开发工程师

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值