diff options
author | Adam Cohen <adamcohen@google.com> | 2014-10-23 17:28:30 -0700 |
---|---|---|
committer | Adam Cohen <adamcohen@google.com> | 2014-10-24 11:47:30 -0700 |
commit | a6d0492e5f0dd4e1b43d4034a770241dc65f8f8c (patch) | |
tree | 7f9283954397d3b21703b849b5c70b17b553bb25 /src/com/android/launcher3/DragLayer.java | |
parent | 4a080dcadd532dd259de596729a1cd6e949bdae4 (diff) | |
download | android_packages_apps_Trebuchet-a6d0492e5f0dd4e1b43d4034a770241dc65f8f8c.tar.gz android_packages_apps_Trebuchet-a6d0492e5f0dd4e1b43d4034a770241dc65f8f8c.tar.bz2 android_packages_apps_Trebuchet-a6d0492e5f0dd4e1b43d4034a770241dc65f8f8c.zip |
Allow LauncherOverlay to access and manage insets
Change-Id: Ib9faf37eb22ad2a0b18c076978ec9f2fd8864c0c
Diffstat (limited to 'src/com/android/launcher3/DragLayer.java')
-rw-r--r-- | src/com/android/launcher3/DragLayer.java | 40 |
1 files changed, 2 insertions, 38 deletions
diff --git a/src/com/android/launcher3/DragLayer.java b/src/com/android/launcher3/DragLayer.java index ff9072ab4..79d42782c 100644 --- a/src/com/android/launcher3/DragLayer.java +++ b/src/com/android/launcher3/DragLayer.java @@ -43,7 +43,7 @@ import java.util.ArrayList; /** * A ViewGroup that coordinates dragging across its descendants */ -public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChangeListener { +public class DragLayer extends InsettableFrameLayout { private DragController mDragController; private int[] mTmpXY = new int[2]; @@ -71,8 +71,6 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang private TouchCompleteListener mTouchCompleteListener; - private final Rect mInsets = new Rect(); - private View mOverlayView; private int mTopViewIndex; private int mChildCountOnLastUpdate = -1; @@ -103,7 +101,6 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang // Disable multitouch across the workspace/all apps/customize tray setMotionEventSplittingEnabled(false); setChildrenDrawingOrderEnabled(true); - setOnHierarchyChangeListener(this); final Resources res = getResources(); mLeftHoverDrawable = res.getDrawable(R.drawable.page_hover_left); @@ -123,27 +120,6 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang return mDragController.dispatchKeyEvent(event) || super.dispatchKeyEvent(event); } - @Override - protected boolean fitSystemWindows(Rect insets) { - final int n = getChildCount(); - for (int i = 0; i < n; i++) { - final View child = getChildAt(i); - setInsets(child, insets, mInsets); - } - mInsets.set(insets); - return true; // I'll take it from here - } - - Rect getInsets() { - return mInsets; - } - - @Override - public void addView(View child, int index, android.view.ViewGroup.LayoutParams params) { - super.addView(child, index, params); - setInsets(child, mInsets, new Rect()); - } - public void showOverlayView(View overlayView) { LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); mOverlayView = overlayView; @@ -158,19 +134,6 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang removeView(mOverlayView); } - private void setInsets(View child, Rect newInsets, Rect oldInsets) { - final FrameLayout.LayoutParams flp = (FrameLayout.LayoutParams) child.getLayoutParams(); - if (child instanceof Insettable) { - ((Insettable) child).setInsets(newInsets); - } else { - flp.topMargin += (newInsets.top - oldInsets.top); - flp.leftMargin += (newInsets.left - oldInsets.left); - flp.rightMargin += (newInsets.right - oldInsets.right); - flp.bottomMargin += (newInsets.bottom - oldInsets.bottom); - } - child.setLayoutParams(flp); - } - private boolean isEventOverFolderTextRegion(Folder folder, MotionEvent ev) { getDescendantRectRelativeToSelf(folder.getEditTextRegion(), mHitRect); if (mHitRect.contains((int) ev.getX(), (int) ev.getY())) { @@ -815,6 +778,7 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang @Override public void onChildViewAdded(View parent, View child) { + super.onChildViewAdded(parent, child); if (mOverlayView != null) { // ensure that the overlay view stays on top. we can't use drawing order for this // because in API level 16 touch dispatch doesn't respect drawing order. |