summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2014-10-24 00:28:30 (GMT)
committerDanesh M <daneshm90@gmail.com>2015-09-28 01:55:56 (GMT)
commitbf18c372cd9abf7c24495fd94c535fd850539060 (patch)
treea1e8fa8ebfb21b62d8a6d451b9326c1f2752bdf1
parente8e3e71f40ba9154fafafb59e93babaddd0e512b (diff)
downloadandroid_packages_apps_Trebuchet-bf18c372cd9abf7c24495fd94c535fd850539060.zip
android_packages_apps_Trebuchet-bf18c372cd9abf7c24495fd94c535fd850539060.tar.gz
android_packages_apps_Trebuchet-bf18c372cd9abf7c24495fd94c535fd850539060.tar.bz2
Allow LauncherOverlay to access and manage insets
Change-Id: Ib9faf37eb22ad2a0b18c076978ec9f2fd8864c0c
-rw-r--r--res/layout-land/launcher.xml10
-rw-r--r--res/layout-port/launcher.xml7
-rw-r--r--res/layout-sw720dp/launcher.xml10
-rw-r--r--res/layout/app_drawer_container.xml4
-rw-r--r--res/layout/launcher_overlay.xml4
-rw-r--r--res/layout/launcher_overlay_example.xml8
-rw-r--r--res/layout/overview_panel.xml4
-rw-r--r--src/com/android/launcher3/AppDrawerContainer.java32
-rw-r--r--src/com/android/launcher3/DragLayer.java68
-rw-r--r--src/com/android/launcher3/InsettableFrameLayout.java52
-rw-r--r--src/com/android/launcher3/Launcher.java8
-rw-r--r--src/com/android/launcher3/LauncherCallbacks.java4
-rw-r--r--src/com/android/launcher3/LauncherExtension.java8
-rw-r--r--src/com/android/launcher3/LauncherRootView.java17
-rw-r--r--src/com/android/launcher3/OverviewPanel.java33
15 files changed, 171 insertions, 98 deletions
diff --git a/res/layout-land/launcher.xml b/res/layout-land/launcher.xml
index d2088d8..9afb8ca 100644
--- a/res/layout-land/launcher.xml
+++ b/res/layout-land/launcher.xml
@@ -15,14 +15,15 @@
-->
<!-- Full screen view projects under the status bar and contains the background -->
-<FrameLayout
+<com.android.launcher3.LauncherRootView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:launcher="http://schemas.android.com/apk/res-auto/com.android.launcher3"
android:id="@+id/launcher"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="@drawable/workspace_bg">
+ android:background="@drawable/workspace_bg"
+ android:fitsSystemWindows="true">
<FrameLayout
android:id="@+id/reveal_fake_page_container"
@@ -43,8 +44,7 @@
<com.android.launcher3.DragLayer
android:id="@+id/drag_layer"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:fitsSystemWindows="true">
+ android:layout_height="match_parent">
<com.android.launcher3.FocusIndicatorView
android:id="@+id/focus_indicator"
@@ -92,4 +92,4 @@
android:layout_height="match_parent"
android:inflatedId="@+id/launcher_overlay"
android:layout="@layout/launcher_overlay" />
-</FrameLayout>
+</com.android.launcher3.LauncherRootView>
diff --git a/res/layout-port/launcher.xml b/res/layout-port/launcher.xml
index a057072..9e8775b 100644
--- a/res/layout-port/launcher.xml
+++ b/res/layout-port/launcher.xml
@@ -15,14 +15,15 @@
-->
<!-- Full screen view projects under the status bar and contains the background -->
-<FrameLayout
+<com.android.launcher3.LauncherRootView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:launcher="http://schemas.android.com/apk/res-auto/com.android.launcher3"
android:id="@+id/launcher"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="@drawable/workspace_bg">
+ android:background="@drawable/workspace_bg"
+ android:fitsSystemWindows="true">
<FrameLayout
android:id="@+id/reveal_fake_page_container"
@@ -112,4 +113,4 @@
android:layout_height="match_parent"
android:inflatedId="@+id/launcher_overlay"
android:layout="@layout/launcher_overlay" />
-</FrameLayout>
+</com.android.launcher3.LauncherRootView>
diff --git a/res/layout-sw720dp/launcher.xml b/res/layout-sw720dp/launcher.xml
index 36e76dd..582a782 100644
--- a/res/layout-sw720dp/launcher.xml
+++ b/res/layout-sw720dp/launcher.xml
@@ -15,14 +15,15 @@
-->
<!-- Full screen view projects under the status bar and contains the background -->
-<FrameLayout
+<com.android.launcher3.LauncherRootView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:launcher="http://schemas.android.com/apk/res-auto/com.android.launcher3"
android:id="@+id/launcher"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="@drawable/workspace_bg">
+ android:background="@drawable/workspace_bg"
+ android:fitsSystemWindows="true">
<FrameLayout
android:id="@+id/reveal_fake_page_container"
@@ -43,8 +44,7 @@
<com.android.launcher3.DragLayer
android:id="@+id/drag_layer"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:fitsSystemWindows="true">
+ android:layout_height="match_parent">
<com.android.launcher3.FocusIndicatorView
android:id="@+id/focus_indicator"
@@ -112,4 +112,4 @@
android:inflatedId="@+id/launcher_overlay"
android:layout="@layout/launcher_overlay" />
-</FrameLayout>
+</com.android.launcher3.LauncherRootView>
diff --git a/res/layout/app_drawer_container.xml b/res/layout/app_drawer_container.xml
index 1469066..9633f95 100644
--- a/res/layout/app_drawer_container.xml
+++ b/res/layout/app_drawer_container.xml
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<com.android.launcher3.AppDrawerContainer xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
@@ -82,4 +82,4 @@
android:visibility="invisible"
android:layout_height="100dp" />
</RelativeLayout>
-</FrameLayout>
+</com.android.launcher3.AppDrawerContainer>
diff --git a/res/layout/launcher_overlay.xml b/res/layout/launcher_overlay.xml
index 9ef0c9a..b35a2d8 100644
--- a/res/layout/launcher_overlay.xml
+++ b/res/layout/launcher_overlay.xml
@@ -14,7 +14,7 @@
limitations under the License.
-->
-<FrameLayout
+<com.android.launcher3.InsettableFrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="match_parent" /> \ No newline at end of file
+ android:layout_height="match_parent" />
diff --git a/res/layout/launcher_overlay_example.xml b/res/layout/launcher_overlay_example.xml
index 422f281..8735d14 100644
--- a/res/layout/launcher_overlay_example.xml
+++ b/res/layout/launcher_overlay_example.xml
@@ -14,19 +14,19 @@
limitations under the License.
-->
-<FrameLayout
+<com.android.launcher3.InsettableFrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
- <FrameLayout
+ <com.android.launcher3.InsettableFrameLayout
android:id="@+id/search_overlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ff00ff00"
android:visibility="invisible" />
- <FrameLayout
+ <com.android.launcher3.InsettableFrameLayout
android:id="@+id/search_box"
android:layout_width="match_parent"
android:layout_height="48dp"
@@ -34,4 +34,4 @@
android:layout_marginRight="8dp"
android:layout_marginTop="36dp"
android:background="#ffff0000" />
-</FrameLayout>
+</com.android.launcher3.InsettableFrameLayout>
diff --git a/res/layout/overview_panel.xml b/res/layout/overview_panel.xml
index 9b0bb77..a0a60ab 100644
--- a/res/layout/overview_panel.xml
+++ b/res/layout/overview_panel.xml
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<com.android.launcher3.SlidingUpPanelLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<com.android.launcher3.OverviewPanel xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:slidingpanel="http://schemas.android.com/apk/res/com.android.launcher3"
android:id="@+id/sliding_layout"
android:layout_width="match_parent"
@@ -45,4 +45,4 @@
<include layout="@layout/settings_pane" />
-</com.android.launcher3.SlidingUpPanelLayout>
+</com.android.launcher3.OverviewPanel>
diff --git a/src/com/android/launcher3/AppDrawerContainer.java b/src/com/android/launcher3/AppDrawerContainer.java
new file mode 100644
index 0000000..ed001fe
--- /dev/null
+++ b/src/com/android/launcher3/AppDrawerContainer.java
@@ -0,0 +1,32 @@
+package com.android.launcher3;
+
+import android.content.Context;
+import android.graphics.Rect;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.FrameLayout;
+import android.widget.LinearLayout;
+
+public class AppDrawerContainer extends InsettableFrameLayout {
+ public AppDrawerContainer(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ public void setInsets(Rect insets) {
+ // List view
+ View view = findViewById(R.id.app_drawer_recyclerview);
+ FrameLayout.LayoutParams lp =
+ (FrameLayout.LayoutParams) view.getLayoutParams();
+ int paddingBottom = view.getPaddingBottom() + insets.bottom - mInsets.bottom;
+ int paddingTop = view.getPaddingTop() + insets.top - mInsets.top;
+ view.setLayoutParams(lp);
+ view.setPadding(view.getPaddingLeft(), paddingTop, view.getPaddingRight(), paddingBottom);
+
+ // Scrubber
+ view = findViewById(R.id.app_drawer_scrubber_container);
+ LinearLayout.LayoutParams llp = (LinearLayout.LayoutParams) view.getLayoutParams();
+ llp.bottomMargin += insets.bottom - mInsets.bottom;
+ view.setLayoutParams(llp);
+ }
+}
diff --git a/src/com/android/launcher3/DragLayer.java b/src/com/android/launcher3/DragLayer.java
index 1ded030..156df7d 100644
--- a/src/com/android/launcher3/DragLayer.java
+++ b/src/com/android/launcher3/DragLayer.java
@@ -44,7 +44,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];
@@ -72,8 +72,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;
@@ -104,7 +102,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);
@@ -126,56 +123,9 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang
@Override
protected boolean fitSystemWindows(Rect insets) {
- final int n = getChildCount();
- for (int i = 0; i < n; i++) {
- final View child = getChildAt(i);
- if (child.getId() == R.id.overview_panel) {
- LinearLayout layout = (LinearLayout)
- child.findViewById(R.id.settings_container);
- FrameLayout.LayoutParams lp =
- (FrameLayout.LayoutParams) layout.getLayoutParams();
- lp.bottomMargin += insets.bottom - mInsets.bottom;
- layout.setLayoutParams(lp);
- continue;
- } else if (child.getId() == R.id.app_drawer_container) {
- setAppDrawerInsets(child, insets);
-
- continue;
- }
- setInsets(child, insets, mInsets);
- if (child.getId() == R.id.search_drop_target_bar) {
- continue;
- }
- }
- mInsets.set(insets);
- return true; // I'll take it from here
- }
-
- private void setAppDrawerInsets(View child, Rect insets) {
- // List view
- View view = child.findViewById(R.id.app_drawer_recyclerview);
- FrameLayout.LayoutParams lp =
- (FrameLayout.LayoutParams) view.getLayoutParams();
- int paddingBottom = view.getPaddingBottom() + insets.bottom - mInsets.bottom;
- int paddingTop = view.getPaddingTop() + insets.top - mInsets.top;
- view.setLayoutParams(lp);
- view.setPadding(view.getPaddingLeft(), paddingTop, view.getPaddingRight(), paddingBottom);
-
- // Scrubber
- view = child.findViewById(R.id.app_drawer_scrubber_container);
- LinearLayout.LayoutParams llp = (LinearLayout.LayoutParams) view.getLayoutParams();
- llp.bottomMargin += insets.bottom - mInsets.bottom;
- view.setLayoutParams(llp);
- }
- 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());
+ return super.fitSystemWindows(insets);
}
public void showOverlayView(View overlayView) {
@@ -192,19 +142,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())) {
@@ -849,6 +786,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.
diff --git a/src/com/android/launcher3/InsettableFrameLayout.java b/src/com/android/launcher3/InsettableFrameLayout.java
new file mode 100644
index 0000000..4ba9c88
--- /dev/null
+++ b/src/com/android/launcher3/InsettableFrameLayout.java
@@ -0,0 +1,52 @@
+package com.android.launcher3;
+
+import android.content.Context;
+import android.graphics.Rect;
+import android.util.AttributeSet;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.FrameLayout;
+
+public class InsettableFrameLayout extends FrameLayout implements
+ ViewGroup.OnHierarchyChangeListener, Insettable {
+
+ protected Rect mInsets = new Rect();
+
+ public InsettableFrameLayout(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ setOnHierarchyChangeListener(this);
+ }
+
+ public void setFrameLayoutChildInsets(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);
+ }
+
+ @Override
+ public void setInsets(Rect insets) {
+ final int n = getChildCount();
+ for (int i = 0; i < n; i++) {
+ final View child = getChildAt(i);
+ setFrameLayoutChildInsets(child, insets, mInsets);
+ }
+ mInsets.set(insets);
+ }
+
+ @Override
+ public void onChildViewAdded(View parent, View child) {
+ setFrameLayoutChildInsets(child, mInsets, new Rect());
+ }
+
+ @Override
+ public void onChildViewRemoved(View parent, View child) {
+ }
+
+}
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 58a09a4..f8891a0 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -266,7 +266,7 @@ public class Launcher extends Activity
LauncherOverlayCallbacks mLauncherOverlayCallbacks = new LauncherOverlayCallbacksImpl();
LauncherOverlay mLauncherOverlay;
- ViewGroup mLauncherOverlayView;
+ InsettableFrameLayout mLauncherOverlayContainer;
static final int APPWIDGET_HOST_ID = 1024;
public static final int EXIT_SPRINGLOADED_MODE_SHORT_TIMEOUT = 300;
@@ -589,9 +589,9 @@ public class Launcher extends Activity
mLauncherCallbacks.onCreate(savedInstanceState);
if (mLauncherCallbacks.hasLauncherOverlay()) {
ViewStub stub = (ViewStub) findViewById(R.id.launcher_overlay_stub);
- mLauncherOverlayView = (ViewGroup) stub.inflate();
- mLauncherOverlay = mLauncherCallbacks.setLauncherOverlayView(mLauncherOverlayView,
- mLauncherOverlayCallbacks);
+ mLauncherOverlayContainer = (InsettableFrameLayout) stub.inflate();
+ mLauncherOverlay = mLauncherCallbacks.setLauncherOverlayView(
+ mLauncherOverlayContainer, mLauncherOverlayCallbacks);
mWorkspace.setLauncherOverlay(mLauncherOverlay);
}
}
diff --git a/src/com/android/launcher3/LauncherCallbacks.java b/src/com/android/launcher3/LauncherCallbacks.java
index e0cfa27..a1f4e0b 100644
--- a/src/com/android/launcher3/LauncherCallbacks.java
+++ b/src/com/android/launcher3/LauncherCallbacks.java
@@ -98,11 +98,11 @@ public interface LauncherCallbacks {
/**
* Handshake to establish an overlay relationship
*
- * @param overlayView Full screen overlay ViewGroup into which custom views can be placed.
+ * @param container Full screen overlay ViewGroup into which custom views can be placed.
* @param callbacks A set of callbacks provided by Launcher in relation to the overlay
* @return an interface used to make requests and notify the Launcher in relation to the overlay
*/
- public Launcher.LauncherOverlay setLauncherOverlayView(ViewGroup overlayView,
+ public Launcher.LauncherOverlay setLauncherOverlayView(InsettableFrameLayout container,
Launcher.LauncherOverlayCallbacks callbacks);
}
diff --git a/src/com/android/launcher3/LauncherExtension.java b/src/com/android/launcher3/LauncherExtension.java
index 10bbd35..b264042 100644
--- a/src/com/android/launcher3/LauncherExtension.java
+++ b/src/com/android/launcher3/LauncherExtension.java
@@ -252,11 +252,11 @@ public class LauncherExtension extends Launcher {
}
@Override
- public LauncherOverlay setLauncherOverlayView(ViewGroup overlayView,
+ public LauncherOverlay setLauncherOverlayView(InsettableFrameLayout container,
LauncherOverlayCallbacks callbacks) {
mLauncherOverlay.setOverlayCallbacks(callbacks);
- mLauncherOverlay.setOverlayView(overlayView);
+ mLauncherOverlay.setOverlayContainer(container);
return mLauncherOverlay;
}
@@ -335,9 +335,9 @@ public class LauncherExtension extends Launcher {
hideOverlayPanel();
}
- public void setOverlayView(ViewGroup overlayView) {
+ public void setOverlayContainer(InsettableFrameLayout container) {
mOverlayView = (ViewGroup) getLayoutInflater().inflate(
- R.layout.launcher_overlay_example, overlayView);
+ R.layout.launcher_overlay_example, container);
mSearchOverlay = mOverlayView.findViewById(R.id.search_overlay);
mSearchBox = mOverlayView.findViewById(R.id.search_box);
}
diff --git a/src/com/android/launcher3/LauncherRootView.java b/src/com/android/launcher3/LauncherRootView.java
new file mode 100644
index 0000000..e8c11c4
--- /dev/null
+++ b/src/com/android/launcher3/LauncherRootView.java
@@ -0,0 +1,17 @@
+package com.android.launcher3;
+
+import android.content.Context;
+import android.graphics.Rect;
+import android.util.AttributeSet;
+
+public class LauncherRootView extends InsettableFrameLayout {
+ public LauncherRootView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ protected boolean fitSystemWindows(Rect insets) {
+ setInsets(insets);
+ return true; // I'll take it from here
+ }
+} \ No newline at end of file
diff --git a/src/com/android/launcher3/OverviewPanel.java b/src/com/android/launcher3/OverviewPanel.java
new file mode 100644
index 0000000..83603d8
--- /dev/null
+++ b/src/com/android/launcher3/OverviewPanel.java
@@ -0,0 +1,33 @@
+package com.android.launcher3;
+
+import android.content.Context;
+import android.graphics.Rect;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.FrameLayout;
+import android.widget.LinearLayout;
+
+public class OverviewPanel extends SlidingUpPanelLayout implements Insettable {
+ public OverviewPanel(Context context) {
+ super(context);
+ }
+
+ public OverviewPanel(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public OverviewPanel(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+
+ @Override
+ public void setInsets(Rect insets) {
+ LinearLayout layout = (LinearLayout)
+ findViewById(R.id.settings_container);
+ FrameLayout.LayoutParams lp =
+ (FrameLayout.LayoutParams) layout.getLayoutParams();
+ lp.bottomMargin += insets.bottom - insets.bottom;
+ layout.setLayoutParams(lp);
+ }
+}