当前位置: 首页 > news >正文

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

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

 

1a7038cd77374b039d99b042cf2207d2.gif

固定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 addedelselp.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 startResources 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--><HorizontalScrollViewandroid:id="@+id/hotseat_container"android:layout_width="match_parent"android:layout_height="309px"android:layout_gravity="bottom"android:scrollbars="none"><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="match_parent"android:orientation="horizontal"><includeandroid: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.Hotseatxmlns: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.Hotseatxmlns: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

 @CallSuperprotected 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 resumeNotificationListener.addNotificationsChangedListener(mPopupDataProvider);//DiscoveryBounce.showForHomeIfNeeded(this);//Kevin.Ye added for not showing DiscoveryBouncemAppWidgetHost.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 startif(!FeatureFlags.HOTSEAT_FOLDER){if(mLauncher.isHotseatLayout(target)) return false;//}//add endif (distance > target.getFolderCreationRadius(targetCell)) return false;View v = target.getChildAt(targetCell[0], targetCell[1]);

 

 

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • GitHub图床
  • pytorch pyro 贝叶斯神经网络 bnn beyesean neure network svi ​定制SVI目标和培训循环,变更推理
  • 经验笔记:前端堆栈分配
  • 批量下载,控制并发(利用promise 做需求池队列)
  • 如何理解基于架构的软件设计(ABSD)
  • TMS320F28335芯片及使用介绍
  • 不到200行代码,一键写出简单贪吃蛇网页游戏!附详细代码!快来看看吧!
  • QML学习二:Qt启用qml文件实时预览编辑,以及打印日志到控制台
  • 【开源大模型生态5】解放大脑
  • 1034. 边界着色(JAVA)
  • SpringCloud之CircuitBreaker
  • 面试场景题
  • 使用 uni-app 开发微信小程序:深入教程与技巧
  • SpringCloud:Gateway
  • (Charles)如何抓取手机http的报文
  • 分享一款快速APP功能测试工具
  • 实现windows 窗体的自己画,网上摘抄的,学习了
  • 【腾讯Bugly干货分享】从0到1打造直播 App
  • ➹使用webpack配置多页面应用(MPA)
  • 2017前端实习生面试总结
  • HomeBrew常规使用教程
  • Median of Two Sorted Arrays
  • Octave 入门
  • OpenStack安装流程(juno版)- 添加网络服务(neutron)- controller节点
  • PHP 程序员也能做的 Java 开发 30分钟使用 netty 轻松打造一个高性能 websocket 服务...
  • RxJS 实现摩斯密码(Morse) 【内附脑图】
  • spring + angular 实现导出excel
  • vue:响应原理
  • 从输入URL到页面加载发生了什么
  • 官方新出的 Kotlin 扩展库 KTX,到底帮你干了什么?
  • 设计模式走一遍---观察者模式
  • 实现菜单下拉伸展折叠效果demo
  • 小程序、APP Store 需要的 SSL 证书是个什么东西?
  • 一天一个设计模式之JS实现——适配器模式
  • 原生JS动态加载JS、CSS文件及代码脚本
  • 源码之下无秘密 ── 做最好的 Netty 源码分析教程
  • 在Docker Swarm上部署Apache Storm:第1部分
  • 交换综合实验一
  • 微龛半导体获数千万Pre-A轮融资,投资方为国中创投 ...
  • ​HTTP与HTTPS:网络通信的安全卫士
  • ​queue --- 一个同步的队列类​
  • ​一些不规范的GTID使用场景
  • ![CDATA[ ]] 是什么东东
  • #Datawhale AI夏令营第4期#AIGC文生图方向复盘
  • (Redis使用系列) Springboot 使用redis实现接口幂等性拦截 十一
  • (vue)el-cascader级联选择器按勾选的顺序传值,摆脱层级约束
  • (八)Docker网络跨主机通讯vxlan和vlan
  • (八十八)VFL语言初步 - 实现布局
  • (附源码)计算机毕业设计SSM基于健身房管理系统
  • (力扣)循环队列的实现与详解(C语言)
  • (没学懂,待填坑)【动态规划】数位动态规划
  • (免费领源码)Python#MySQL图书馆管理系统071718-计算机毕业设计项目选题推荐
  • (三)centos7案例实战—vmware虚拟机硬盘挂载与卸载
  • (详细版)Vary: Scaling up the Vision Vocabulary for Large Vision-Language Models
  • (一)Dubbo快速入门、介绍、使用