8541E Android10-Launcher3 去掉hotseat

简介: 笔记
diff --git a/res/layout/launcher.xml b/res/layout/launcher.xml
old mode 100644
new mode 100755
index 7d3f09adbc..85573ae818
--- a/res/layout/launcher.xml
+++ b/res/layout/launcher.xml
@@ -43,7 +43,8 @@
         <!-- DO NOT CHANGE THE ID -->
         <include
             android:id="@+id/hotseat"
-            layout="@layout/hotseat" />
+            layout="@layout/hotseat" 
+           android:visibility="gone" />
         <include
             android:id="@+id/overview_panel"
diff --git a/res/xml/device_profiles.xml b/res/xml/device_profiles.xml
old mode 100644
new mode 100755
index c05c442259..53e176e25a
--- a/res/xml/device_profiles.xml
+++ b/res/xml/device_profiles.xml
@@ -23,7 +23,7 @@
         launcher:numColumns="3"
         launcher:numFolderRows="2"
         launcher:numFolderColumns="3"
-        launcher:numHotseatIcons="3"
+        launcher:numHotseatIcons="0"
         launcher:defaultLayoutId="@xml/default_workspace_3x3" >
         <display-option
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
old mode 100644
new mode 100755
index ce32dc80e4..068a2d6752
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -108,11 +108,11 @@ public class DeviceProfile {
     public int hotseatCellHeightPx;
     // In portrait: size = height, in landscape: size = width
     public int hotseatBarSizePx;
-    public final int hotseatBarTopPaddingPx;
-    public int hotseatBarBottomPaddingPx;
+    public final int hotseatBarTopPaddingPx = 0;
+    public int hotseatBarBottomPaddingPx = 0;
     // Start is the side next to the nav bar, end is the side next to the workspace
-    public final int hotseatBarSidePaddingStartPx;
-    public final int hotseatBarSidePaddingEndPx;
+    public final int hotseatBarSidePaddingStartPx = 0;
+    public final int hotseatBarSidePaddingEndPx = 0;
     // All apps
     public int allAppsCellHeightPx;
@@ -205,19 +205,19 @@ public class DeviceProfile {
         workspaceCellPaddingXPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_cell_padding_x);
-        hotseatBarTopPaddingPx =
-                res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_top_padding);
-        hotseatBarBottomPaddingPx = (isTallDevice ? 0
-                : res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_bottom_non_tall_padding))
-                + res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_bottom_padding);
-        hotseatBarSidePaddingEndPx =
-                res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_side_padding);
+//        hotseatBarTopPaddingPx =
+//                res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_top_padding);
+//        hotseatBarBottomPaddingPx = (isTallDevice ? 0
+//                : res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_bottom_non_tall_padding))
+//                + res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_bottom_padding);
+//        hotseatBarSidePaddingEndPx =
+//                res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_side_padding);
         // Add a bit of space between nav bar and hotseat in vertical bar layout.
-        hotseatBarSidePaddingStartPx = isVerticalBarLayout() ? verticalDragHandleSizePx : 0;
-        hotseatBarSizePx = ResourceUtils.pxFromDp(inv.iconSize, dm) + (isVerticalBarLayout()
-                ? (hotseatBarSidePaddingStartPx + hotseatBarSidePaddingEndPx)
-                : (res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_extra_vertical_size)
-                        + hotseatBarTopPaddingPx + hotseatBarBottomPaddingPx));
+//        hotseatBarSidePaddingStartPx = isVerticalBarLayout() ? verticalDragHandleSizePx : 0;
+//        hotseatBarSizePx = ResourceUtils.pxFromDp(inv.iconSize, dm) + (isVerticalBarLayout()
+//                ? (hotseatBarSidePaddingStartPx + hotseatBarSidePaddingEndPx)
+//                : (res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_extra_vertical_size)
+//                        + hotseatBarTopPaddingPx + hotseatBarBottomPaddingPx));
         // Calculate all of the remaining variables.
         updateAvailableDimensions(dm, res);
@@ -228,13 +228,13 @@ public class DeviceProfile {
             // ie. For a display with a large aspect ratio, we can keep the icons on the workspace
             // in portrait mode closer together by adding more height to the hotseat.
             // Note: This calculation was created after noticing a pattern in the design spec.
-            int extraSpace = getCellSize().y - iconSizePx - iconDrawablePaddingPx * 2
-                    - verticalDragHandleSizePx;
-            hotseatBarSizePx += extraSpace;
-            hotseatBarBottomPaddingPx += extraSpace;
+//            int extraSpace = getCellSize().y - iconSizePx - iconDrawablePaddingPx * 2
+//                   - verticalDragHandleSizePx;
+//            hotseatBarSizePx += extraSpace;
+//            hotseatBarBottomPaddingPx += extraSpace;
             // Recalculate the available dimensions using the new hotseat size.
-            updateAvailableDimensions(dm, res);
+//            updateAvailableDimensions(dm, res);
         }
         updateWorkspacePadding();
@@ -369,10 +369,11 @@ public class DeviceProfile {
         // Hotseat
         if (isVerticalLayout) {
-            hotseatBarSizePx = iconSizePx + hotseatBarSidePaddingStartPx
-                    + hotseatBarSidePaddingEndPx;
+//            hotseatBarSizePx = iconSizePx + hotseatBarSidePaddingStartPx
+//                    + hotseatBarSidePaddingEndPx;
         }
-        hotseatCellHeightPx = iconSizePx;
+//        hotseatCellHeightPx = iconSizePx;
+               hotseatCellHeightPx = 0;
         if (!isVerticalLayout) {
             int expectedWorkspaceHeight = availableHeightPx - hotseatBarSizePx
@@ -472,7 +473,7 @@ public class DeviceProfile {
         Rect padding = workspacePadding;
         if (isVerticalBarLayout()) {
             padding.top = 0;
-            padding.bottom = edgeMarginPx;
+//            padding.bottom = edgeMarginPx;
             int offset = 0;
             if (isMultiWindowMode) {
@@ -485,11 +486,11 @@ public class DeviceProfile {
                 }
             }
             if (isSeascape()) {
-                padding.left = hotseatBarSizePx;
-                padding.right = verticalDragHandleSizePx + offset;
+//                padding.left = hotseatBarSizePx;
+//                padding.right = verticalDragHandleSizePx + offset;
             } else {
-                padding.left = verticalDragHandleSizePx + offset;
-                padding.right = hotseatBarSizePx;
+//                padding.left = verticalDragHandleSizePx + offset;
+//                padding.right = hotseatBarSizePx;
             }
         } else {
             int paddingBottom = hotseatBarSizePx + verticalDragHandleSizePx
@@ -498,21 +499,21 @@ public class DeviceProfile {
                 // Pad the left and right of the workspace to ensure consistent spacing
                 // between all icons
                 // The amount of screen space available for left/right padding.
-                int availablePaddingX = Math.max(0, widthPx - ((inv.numColumns * cellWidthPx) +
-                        ((inv.numColumns - 1) * cellWidthPx)));
-                availablePaddingX = (int) Math.min(availablePaddingX,
-                        widthPx * MAX_HORIZONTAL_PADDING_PERCENT);
-                int availablePaddingY = Math.max(0, heightPx - edgeMarginPx - paddingBottom
-                        - (2 * inv.numRows * cellHeightPx) - hotseatBarTopPaddingPx
-                        - hotseatBarBottomPaddingPx);
-                padding.set(availablePaddingX / 2, edgeMarginPx + availablePaddingY / 2,
-                        availablePaddingX / 2, paddingBottom + availablePaddingY / 2);
+//                int availablePaddingX = Math.max(0, widthPx - ((inv.numColumns * cellWidthPx) +
+//                        ((inv.numColumns - 1) * cellWidthPx)));
+//                availablePaddingX = (int) Math.min(availablePaddingX,
+//                        widthPx * MAX_HORIZONTAL_PADDING_PERCENT);
+//                int availablePaddingY = Math.max(0, heightPx - edgeMarginPx - paddingBottom
+//                        - (2 * inv.numRows * cellHeightPx) - hotseatBarTopPaddingPx
+//                        - hotseatBarBottomPaddingPx);
+//                padding.set(availablePaddingX / 2, edgeMarginPx + availablePaddingY / 2,
+//                        availablePaddingX / 2, paddingBottom + availablePaddingY / 2);
             } else {
                 // Pad the top and bottom of the workspace with search/hotseat bar sizes
-                padding.set(desiredWorkspaceLeftRightMarginPx,
-                        edgeMarginPx,
-                        desiredWorkspaceLeftRightMarginPx,
-                        paddingBottom);
+//                padding.set(desiredWorkspaceLeftRightMarginPx,
+//                        edgeMarginPx,
+//                        desiredWorkspaceLeftRightMarginPx,
+//                        paddingBottom);
             }
         }
     }
@@ -520,11 +521,11 @@ public class DeviceProfile {
     public Rect getHotseatLayoutPadding() {
         if (isVerticalBarLayout()) {
             if (isSeascape()) {
-                mHotseatPadding.set(mInsets.left + hotseatBarSidePaddingStartPx,
-                        mInsets.top, hotseatBarSidePaddingEndPx, mInsets.bottom);
+//                mHotseatPadding.set(mInsets.left + hotseatBarSidePaddingStartPx,
+//                        mInsets.top, hotseatBarSidePaddingEndPx, mInsets.bottom);
             } else {
-                mHotseatPadding.set(hotseatBarSidePaddingEndPx, mInsets.top,
-                        mInsets.right + hotseatBarSidePaddingStartPx, mInsets.bottom);
+//               mHotseatPadding.set(hotseatBarSidePaddingEndPx, mInsets.top,
+//                        mInsets.right + hotseatBarSidePaddingStartPx, mInsets.bottom);
             }
         } else {
@@ -532,14 +533,14 @@ public class DeviceProfile {
             // 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 / inv.numHotseatIcons;
-            int hotseatAdjustment = Math.round((workspaceCellWidth - hotseatCellWidth) / 2);
-            mHotseatPadding.set(
-                    hotseatAdjustment + workspacePadding.left + cellLayoutPaddingLeftRightPx,
-                    hotseatBarTopPaddingPx,
-                    hotseatAdjustment + workspacePadding.right + cellLayoutPaddingLeftRightPx,
-                    hotseatBarBottomPaddingPx + mInsets.bottom + cellLayoutBottomPaddingPx);
+//            float workspaceCellWidth = (float) widthPx / inv.numColumns;
+//            float hotseatCellWidth = (float) widthPx / inv.numHotseatIcons;
+//            int hotseatAdjustment = Math.round((workspaceCellWidth - hotseatCellWidth) / 2);
+//            mHotseatPadding.set(
+//                    hotseatAdjustment + workspacePadding.left + cellLayoutPaddingLeftRightPx,
+//                    hotseatBarTopPaddingPx,
+//                    hotseatAdjustment + workspacePadding.right + cellLayoutPaddingLeftRightPx,
+//                    hotseatBarBottomPaddingPx + mInsets.bottom + cellLayoutBottomPaddingPx);
         }
         return mHotseatPadding;
     }
@@ -565,10 +566,12 @@ public class DeviceProfile {
     }
     public static int calculateCellWidth(int width, int countX) {
-        return width / countX;
+               if(countX==0) return 0;
+       return width / countX;
     }
     public static int calculateCellHeight(int height, int countY) {
-        return height / countY;
+               if(countY==0) return 0;
+       return height / countY;
     }
     /**
@@ -609,7 +612,7 @@ public class DeviceProfile {
             case CellLayout.FOLDER:
                 return folderCellHeightPx;
             case CellLayout.HOTSEAT:
-                return hotseatCellHeightPx;
+                return 0;
             default:
                 // ??
                 return 0;
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
old mode 100644
new mode 100755
index b58d7ef4c6..5e3c0f5021
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -71,9 +71,9 @@ public class Hotseat extends CellLayout implements LogContainerProvider, Insetta
         mHasVerticalHotseat = hasVerticalHotseat;
         InvariantDeviceProfile idp = mActivity.getDeviceProfile().inv;
         if (hasVerticalHotseat) {
-            setGridSize(1, idp.numHotseatIcons);
+//            setGridSize(1, idp.numHotseatIcons);
         } else {
-            setGridSize(idp.numHotseatIcons, 1);
+//            setGridSize(idp.numHotseatIcons, 1);
         }
     }
@@ -104,11 +104,11 @@ public class Hotseat extends CellLayout implements LogContainerProvider, Insetta
             lp.width = ViewGroup.LayoutParams.MATCH_PARENT;
             lp.height = grid.hotseatBarSizePx + insets.bottom;
         }
-        Rect padding = grid.getHotseatLayoutPadding();
-        setPadding(padding.left, padding.top, padding.right, padding.bottom);
+//        Rect padding = grid.getHotseatLayoutPadding();
+//        setPadding(padding.left, padding.top, padding.right, padding.bottom);
-        setLayoutParams(lp);
-        InsettableFrameLayout.dispatchInsets(this, insets);
+//        setLayoutParams(lp);
+//        InsettableFrameLayout.dispatchInsets(this, insets);
     }
     @Override
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
old mode 100644
new mode 100755
index 2c40aeb532..75efa827d7
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -146,7 +146,7 @@ public class InvariantDeviceProfile {
         iconShapePath = p.iconShapePath;
         landscapeIconSize = p.landscapeIconSize;
         iconTextSize = p.iconTextSize;
-        numHotseatIcons = p.numHotseatIcons;
+        numHotseatIcons = 0;
         defaultLayoutId = p.defaultLayoutId;
         demoModeLayoutId = p.demoModeLayoutId;
         mExtraAttrs = p.mExtraAttrs;
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
old mode 100644
new mode 100755
index e66fad67d9..1049f5be7c
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -1945,7 +1945,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
     boolean isHotseatLayout(View layout) {
         // TODO: Remove this method
-        return mHotseat != null && (layout == mHotseat);
+        return false;
     }
     /**
@@ -2045,9 +2045,9 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
         mWorkspace.removeAllWorkspaceScreens();
         mAppWidgetHost.clearViews();
-        if (mHotseat != null) {
-            mHotseat.resetLayout(getWallpaperDeviceProfile().isVerticalBarLayout());
-        }
+//        if (mHotseat != null) {
+//            mHotseat.resetLayout(getWallpaperDeviceProfile().isVerticalBarLayout());
+//        }
         TraceHelper.endSection("startBinding");
     }
目录
相关文章
|
6月前
|
Android开发
Android 如何将定制的Launcher成为系统中唯一的Launcher
Android 如何将定制的Launcher成为系统中唯一的Launcher
221 2
|
6月前
|
Android开发
Android中去掉ActionBar的几种方法
Android中去掉ActionBar的几种方法
151 0
|
存储 Android开发 开发者
#2,Android新建第一个程序 Hello Android 模拟手机
#2,Android新建第一个程序 Hello Android 模拟手机
|
XML 存储 搜索推荐
|
Android开发
android12.0(S) Launcher3 细节修改
android12.0(S) Launcher3 细节修改
372 0
|
机器学习/深度学习 Android开发 Java
android 修改默认Launcher
android 修改默认Launcher
588 0
|
API 数据库 Android开发
Android M Launcher3主流程源码浅析
背景 关于Launcher是啥的问题我想这里就没必要再强调了。由于一些原因迫使最近开始需要研究一下Launcher3源码,为了不再像以前那么傻逼(研究Settings等代码没作笔记),故这里赶紧将阶段性的感悟整理成文章,方便日后回看。
1621 0