Android13 Hotseat客制化--Hotseat修改布局、支持滑动、去掉开机弹动效果、禁止创建文件夹

news2024/9/21 1:49:27

需求如题,实现效果如下 :

固定Hotseat的padding位置、固定高度

step1 在FeatureFlags.java中添加flag,以兼容原生态代码

public static final boolean STATIC_HOTSEAT_PADDING = true;//hotseat area fixed

step2:在dimens.xml中添加padding值和高度值

<dimen name="hotseat_padding_left">0px</dimen>
    <dimen name="hotseat_padding_top">0px</dimen>
    <dimen name="hotseat_padding_right">0px</dimen>
    <dimen name="hotseat_padding_bottom">0px</dimen>
    <dimen name="hotseat_height">218px</dimen>

step3:Hotseat.java的public void setInsets(Rect insets)接口中,改为高度不通过计算,直接读取dimension

private final int mHotseatHeight;
    public Hotseat(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);

        mQsb = LayoutInflater.from(context).inflate(R.layout.search_container_hotseat, this, false);
        addView(mQsb);

        mQsbHeight = getResources().getDimensionPixelSize(R.dimen.qsb_widget_height);
        mHotseatHeight = getResources().getDimensionPixelSize(R.dimen.hotseat_height);//added by Kevin
    }
 
  public void setInsets(Rect insets){
      .....
    } else {
            mQsb.setVisibility(View.VISIBLE);
            lp.gravity = Gravity.BOTTOM;
            lp.width = ViewGroup.LayoutParams.MATCH_PARENT;
            //lp.width = ViewGroup.LayoutParams.WRAP_CONTENT;
            /*lp.height = grid.isTaskbarPresent
                    ? grid.workspacePadding.bottom
                    : grid.hotseatBarSizePx + insets.bottom;*/
            if(FeatureFlags.STATIC_HOTSEAT_PADDING)
                lp.height = mHotseatHeight;//Kevin.Ye added
            else
                lp.height = grid.isTaskbarPresent
                    ? grid.workspacePadding.bottom
                    : grid.hotseatBarSizePx + insets.bottom;
        }

        Rect padding = grid.getHotseatLayoutPadding(getContext());
        setPadding(padding.left, padding.top, padding.right, padding.bottom);
        setLayoutParams(lp);
        InsettableFrameLayout.dispatchInsets(this, insets);

step4:在DeviceProfile.java的public Rect getHotseatLayoutPadding(Context context)接口的最后添加代码,从dimens中读取padding值

} else {
            // We want the edges of the hotseat to line up with the edges of the workspace, but the
            // icons in the hotseat are a different size, and so don't line up perfectly. To account
            // for this, we pad the left and right of the hotseat with half of the difference of a
            // workspace cell vs a hotseat cell.
            float workspaceCellWidth = (float) widthPx / inv.numColumns;
            float hotseatCellWidth = (float) widthPx / numShownHotseatIcons;
            int hotseatAdjustment = Math.round((workspaceCellWidth - hotseatCellWidth) / 2);
            mHotseatPadding.set(hotseatAdjustment + workspacePadding.left + cellLayoutPaddingPx.left
                            + mInsets.left, hotseatBarTopPaddingPx,
                    hotseatAdjustment + workspacePadding.right + cellLayoutPaddingPx.right
                            + mInsets.right,
                    hotseatBarSizePx - hotseatCellHeightPx - hotseatBarTopPaddingPx
                            + mInsets.bottom);
        }
        if(FeatureFlags.STATIC_HOTSEAT_PADDING){//Modified by Kevin.Ye start
             Resources res = context.getResources();
             int hotseatPaddingLeft = res.getDimensionPixelSize(R.dimen.hotseat_padding_left);
             int hotseatPaddingTop = res.getDimensionPixelSize(R.dimen.hotseat_padding_top);
             int hotseatPaddingRight = res.getDimensionPixelSize(R.dimen.hotseat_padding_right);
             int hotseatPaddingBottom = res.getDimensionPixelSize(R.dimen.hotseat_padding_bottom);
             mHotseatPadding.set(hotseatPaddingLeft,hotseatPaddingTop,hotseatPaddingRight,hotseatPaddingBottom);
        }
        return mHotseatPadding;

step5:想要hotseat可以左右滑动,在launcher.xml中为hotseat添加一个HorizontalScrollView

<!--Kevin.Ye added start-->
         <HorizontalScrollView
            android:id="@+id/hotseat_container"
            android:layout_width="match_parent"
            android:layout_height="309px"
            android:layout_gravity="bottom"
            android:scrollbars="none">
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:orientation="horizontal">
                <include
                    android:id="@+id/hotseat"
                    layout="@layout/hotseat"
                    android:visibility="gone"/>
            </LinearLayout>
        </HorizontalScrollView>
       <!--Kevin.Ye added end-->

step6:需要定义hotseat的边距还可以在hotseat.xml中定义,可以摆放hotseat里图标数量在device_profile.xml中修改

这里图标宽度 258 间隔27,因此总宽度是 (258+27)x9-27=2538

如果摆放9个icon,那hotseat.xml的定义应该是这样

<com.android.launcher3.Hotseat
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:launcher="http://schemas.android.com/apk/res-auto"
    android:id="@+id/hotseat"
    android:layout_width="2538px"
    android:layout_height="match_parent"
    android:layout_gravity="bottom"
    android:layout_marginLeft="40px"
    android:layout_marginRight="40px"
    android:layout_marginBottom="92px"
    android:theme="@style/HomeScreenElementTheme"
    android:importantForAccessibility="no"
    launcher:containerType="hotseat"/>

如果摆放6个图标,宽度应该是  (258+27)x6-27=1683,  marginLeft/Right (1920-1683)/2=118.5

<com.android.launcher3.Hotseat
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:launcher="http://schemas.android.com/apk/res-auto"
    android:id="@+id/hotseat"
    android:layout_width="1683px"
    android:layout_height="match_parent"
    android:layout_gravity="bottom"
    android:layout_marginLeft="118.5px"
    android:layout_marginRight="118.5px"
    android:layout_marginBottom="92px"
    android:theme="@style/HomeScreenElementTheme"
    android:importantForAccessibility="no"
    launcher:containerType="hotseat"/>

重启开机,hotseat会弹动6下,其实是显示操作提示,类似帮助引导

功能是在DiscoveryBounce.java中实现的,Launcher.java中调用,去掉调用即可实现

step1:修改Launcher.java

 @CallSuper
    protected void onDeferredResumed() {
        logStopAndResume(true /* isResume */);

        // Process any items that were added while Launcher was away.
        ItemInstallQueue.INSTANCE.get(this)
                .resumeModelPush(FLAG_ACTIVITY_PAUSED);

        // Refresh shortcuts if the permission changed.
        mModel.validateModelDataOnResume();

        // Set the notification listener and fetch updated notifications when we resume
        NotificationListener.addNotificationsChangedListener(mPopupDataProvider);

        //DiscoveryBounce.showForHomeIfNeeded(this);//Kevin.Ye added for not showing DiscoveryBounce
        mAppWidgetHost.setActivityResumed(true);
    }

禁止在hotseat中形成图标文件夹

step1:FeatureFlags.java添加flag

public static final boolean HOTSEAT_FOLDER = false;//Kevin.Ye added for not creating folder on hotseat

step2:Workspace.java中添加判断即可

boolean createUserFolderIfNecessary(View newView, int container, CellLayout target,
            int[] targetCell, float distance, boolean external, DragObject d) {
        //added by Kevin.Ye start
        if(!FeatureFlags.HOTSEAT_FOLDER){
            if(mLauncher.isHotseatLayout(target)) return false;//
        }
        //add end
        if (distance > target.getFolderCreationRadius(targetCell)) return false;
        View v = target.getChildAt(targetCell[0], targetCell[1]);

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2109184.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

信息系统安全保障

关注这个证书的其他相关笔记&#xff1a;NISP 一级 —— 考证笔记合集-CSDN博客 0x01&#xff1a;信息系统 信息系统是具有集成性的系统&#xff0c;每一个组织中信息流动的综合构成一个信息系统。信息系统是根据一定的需要进行输入、系统控制、数据处理、数据存储与输出等活动…

职场关系课:职场上的基本原则(安全原则、进步原则、收益原则、逃生舱原则)

文章目录 引言安全原则进步原则收益原则逃生舱原则引言 职场上的王者,身体里都应该有三个灵魂: 一个文臣,谨小慎微,考虑风险; 一个武将,积极努力,谋求胜利; 一个商人,精打细算,心中有数。 安全原则 工作安全:保住自己的工作和位置信用安全:保住个人的信用,如果领…

《征服数据结构》差分数组

摘要&#xff1a; 1&#xff0c;差分数组的介绍 2&#xff0c;二维差分数组的介绍 1&#xff0c;差分数组的介绍 差分数组主要是操作区间的&#xff0c;关于区间操作的数据结构比较多&#xff0c;除了前面讲的《稀疏表》&#xff0c;还有树状数组&#xff0c;线段树&#xff0c…

高德地图SDK Android版开发 10 InfoWindow

高德地图SDK Android版开发 10 InfoWindow 前言相关类和方法默认样式Marker类AMap类AMap.OnInfoWindowClickListener 接口 自定义样式(视图)AMap 类AMap.ImageInfoWindowAdapter 接口 自定义样式(Image)AMap.ImageInfoWindowAdapter 接口 示例界面布局MapInfoWindow类常量成员变…

215篇【大模型医疗】论文合集(附PDF)

ChatGPT的横空出世引发了新一轮生成式大模型热潮&#xff0c;作为最新技术的"试验场"&#xff0c;医疗也成为众多大模型的热门首选。 我整理了215篇医疗和大模型的论文&#xff0c;供大家学习和参考。 领215篇医疗和大模型论文

欧拉下搭建第三方软件仓库—docker

1.创建新的文件内容 切换目录到etc底下的yum.repos.d目录&#xff0c;创建docker-ce.repo文件 [rootlocalhost yum.repos.d]# cd /etc/yum.repos.d/ [rootlocalhost yum.repos.d]# vim docker-ce.repo 编辑文件,使用阿里源镜像源&#xff0c;镜像源在编辑中需要单独复制 h…

vue3的学习(2)

属性绑定 1.将一个容器中的class和id使用vue用法赋上具体的值&#xff0c;这样就可以动态的给容器添加上自己想要给其添加的class或者id或者title。 2.关键语法&#xff0c;在容器中的class或者id或者title前面加上 "v-bind:"&#xff0c;当加上"v-bind关键语…

计算机网络基础 - 应用层(2)

计算机网络基础 应用层FTP 与 EMail文件传输协议 FTP电子邮件 EMail主要组成部分SMTP概述SMTP 与 HTTP1.1 邮件报文格式报文格式多媒体扩展 MIME 邮件访问协议概述POP3IMAP DNS概述域名结构工作机理集中式设计分布式、层次数据库根 DNS 服务器顶级域 DNS 服务器权威 DNS 服务器…

公司的企业画册如何制作?

企业画册是公司形象和产品服务展示的重要载体&#xff0c;一个制作精良的企业画册不仅能展示公司的实力&#xff0c;也能提升客户对公司专业度的认可。以下是制作企业画册的步骤和要点&#xff0c;帮助你的公司画册既美观又实用。 1.要制作电子杂志,首先需要选择一款适合自己的…

OpenCV结构分析与形状描述符(7)计算轮廓的面积的函数contourArea()的使用

操作系统&#xff1a;ubuntu22.04 OpenCV版本&#xff1a;OpenCV4.9 IDE:Visual Studio Code 编程语言&#xff1a;C11 算法描述 计算轮廓的面积。 该函数计算轮廓的面积。与 moments 类似&#xff0c;面积是使用格林公式计算的。因此&#xff0c;返回的面积与你使用 drawCo…

Mysql中的隐式COMMIT以及Savepoints的作用以及MySQL的Innodb分空间存储、设计优化、索引等几个小知识点整理

一、Mysql中的隐式COMMIT以及Savepoints的作用 Mysql默认是自动提交的&#xff0c;如果要开启使用事务&#xff0c;首先要关闭自动提交后START TRANSACTION 或者 BEGIN 来开始一个事务&#xff0c;使用ROLLBACK/COMMIT来结束一个事务。但即使如此&#xff0c;也并不是所有的操作…

零知识证明在BSV网络上的应用

​​发表时间&#xff1a;2023年6月15日 2024年7月19日&#xff0c;BSV区块链主网上成功通过使用零知识证明验证了一笔交易。 零知识证明是一种技术&#xff0c;它允许一方&#xff08;证明者&#xff09;在不透露任何秘密的情况下&#xff0c;向另一方&#xff08;验证者&…

TP-link-路由器上网设置(已有路由器再连接新的网线)

一、192.168.0.1进入管理界面&#xff0c;比如密码&#xff1a;D804D804。 二、这是设置连接账户和密码&#xff08;比如账户&#xff1a;TP-LINK_F56C 比如密码&#xff1a;D804D804&#xff09;登录后台管理、移动设备连接。比较固定。 三、 有的网络是分&#xff1a;&#…

JS面试真题 part1

JS面试真题 part1 1、说说JavaScript中的数据类型&#xff0c;储存上的差别2、说说你了解的js数据结构3、DOM常见的操作有哪些4、说说你对BOM的理解&#xff0c;常见的BOM对象你了解哪些5、 和 区别&#xff0c;分别在什么情况使用 1、说说JavaScript中的数据类型&#xff0c;…

K8s的Pv和Pvc就是为了pod数据持久化

一、 1.pv&#xff08;persistent volume&#xff09;&#xff1a;是k8s虚拟化的存储资源&#xff0c;实际上就是存储&#xff0c;列如本地的硬盘、网络文件系统&#xff08;Nfs&#xff09;、lvm、RAID、云存储。 2.pvc&#xff1a;pod对存储资源的请求&#xff0c;定义了需…

MyBatis:解决数据库字段和Java对象字段不匹配问题及占位符问题

MyBatis&#xff1a;解决数据库字段和Java对象字段不匹配问题及占位符问题 文章目录 MyBatis&#xff1a;解决数据库字段和Java对象字段不匹配问题及占位符问题一、数据库字段和Java对象字段不匹配问题1、问题描述2、解决方案2.1、方案12.2、方案22.3、方案3 二、占位符问题1、…

ELK在Linux上部署教程

Docker Compose搭建ELK Elasticsearch默认使用mmapfs目录来存储索引。操作系统默认的mmap计数太低可能导致内存不足&#xff0c;我们可以使用下面这条命令来增加内存 sysctl -w vm.max_map_count262144创建Elasticsearch数据挂载路径 mkdir -p /echola/elasticsearch/data对…

Day 3 - 5 :线性表 — 单链表

存储结构 将线性表中的各元素分布在存储器的不同存储块&#xff0c;称为结点。 结点的data域存放数据元素ai&#xff0c;而next域是一个指针&#xff0c;指向ai的直接后继ai1所在的结点。 如果要删除a1&#xff0c;只要修改a1前手元素指针的指向即可。 例如&#xff1a;需要找到…

案例——Mysql主从复制与读写分离

目录 一、为什么需要主从复制 二、主从复制原理 2.1复制类型 2.2mysql主从复制的工作过程 2.2.1mysql主从复制延迟 2.3mysql的三种同步方式 2.3.1异步复制 2.3.2同步复制 2.3.3半同步复制 2.4mysql应用场景 三、主从复制实验 3.1主从服务器事件同步 3.1.1master服务…

Web 地图服务 简介

网络地图服务 网络地图服务 由通过互联网托管的地理空间数据组成&#xff0c;其标准由开放地理空间联盟 (OGC) 制定。WMS 支持在 Web 浏览器中以地图或图像的形式交换空间信息并通过 Web 查看。 网络地图服务有很多种类型。例如&#xff0c;一些最常见的格式是 WMS、WFS、WCS…