summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Spurlock <jspurlock@google.com>2013-09-11 10:09:51 -0400
committerJohn Spurlock <jspurlock@google.com>2013-09-11 16:29:34 -0400
commit77e1f47520958edd7ec04e203db65b932537bd1c (patch)
tree220895b80a6d2ca8a005df732736134228131d85
parent5f929566179a7d0f323c8a3a09bac734286e2980 (diff)
downloadandroid_packages_apps_Trebuchet-77e1f47520958edd7ec04e203db65b932537bd1c.zip
android_packages_apps_Trebuchet-77e1f47520958edd7ec04e203db65b932537bd1c.tar.gz
android_packages_apps_Trebuchet-77e1f47520958edd7ec04e203db65b932537bd1c.tar.bz2
Add system window inset support to DragLayer and children.
Instead of fitting system windows as before, DragLayer now lays out under the system windows. DragLayer will simply add the system window insets to each child's layout margins by default. e.g. for Hotseat, Page Indicators, QSB, Search Overlay. Children that want to use the full viewport can declare so by implementing a new Insettable interface. System window insets will be passed to Insettable#setInsets(insets) and the child can do what it wants with them. Currently, two of DragLayer's children implement Insettable: 1) Workspace (for the -1 screen). Full screen pages are given the entire viewport, paged view offsets modified to end up in the right place now that the viewport is larger (the full screen height). Non-full screen pages like the normal icon pages simply apply the insets to end up in the same place they did before. NowClientCardsView uses the full viewport, applying the insets as padding. Will want to better take advantage of this new real estate in a future CL. 2) All Apps (AppsCustomizeTabHost). Applies the insets as layout margin one level down, so that the bar area is opaque during the transition, but visually the content lands in the same place. (Also add db_files to .gitignore to ignore the output of the db tool) Bug:10687177 Bug:10652189 Change-Id: I80b25d63884d244fcf704b24dad9497ee0d8b453
-rw-r--r--.gitignore1
-rw-r--r--res/layout-port/launcher.xml3
-rw-r--r--src/com/android/launcher3/AppsCustomizeTabHost.java15
-rw-r--r--src/com/android/launcher3/DragLayer.java22
-rw-r--r--src/com/android/launcher3/Insettable.java24
-rw-r--r--src/com/android/launcher3/Launcher.java3
-rw-r--r--src/com/android/launcher3/PagedView.java10
-rw-r--r--src/com/android/launcher3/Workspace.java11
8 files changed, 79 insertions, 10 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..f830c66
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+db_files
diff --git a/res/layout-port/launcher.xml b/res/layout-port/launcher.xml
index dd3ad47..9844a37 100644
--- a/res/layout-port/launcher.xml
+++ b/res/layout-port/launcher.xml
@@ -27,8 +27,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">
<!-- The workspace contains 5 screens of cells -->
<com.android.launcher3.Workspace
diff --git a/src/com/android/launcher3/AppsCustomizeTabHost.java b/src/com/android/launcher3/AppsCustomizeTabHost.java
index 71219cd..8aef864 100644
--- a/src/com/android/launcher3/AppsCustomizeTabHost.java
+++ b/src/com/android/launcher3/AppsCustomizeTabHost.java
@@ -22,6 +22,7 @@ import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.res.Resources;
+import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.MotionEvent;
@@ -36,7 +37,7 @@ import android.widget.TextView;
import java.util.ArrayList;
public class AppsCustomizeTabHost extends TabHost implements LauncherTransitionable,
- TabHost.OnTabChangeListener {
+ TabHost.OnTabChangeListener, Insettable {
static final String LOG_TAG = "AppsCustomizeTabHost";
private static final String APPS_TAB_TAG = "APPS";
@@ -53,6 +54,7 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
private boolean mTransitioningToWorkspace;
private boolean mResetAfterTransition;
private Runnable mRelayoutAndMakeVisible;
+ private final Rect mInsets = new Rect();
public AppsCustomizeTabHost(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -86,6 +88,17 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
setContentTypeImmediate(AppsCustomizePagedView.ContentType.Widgets);
}
+ @Override
+ public void setInsets(Rect insets) {
+ mInsets.set(insets);
+ FrameLayout.LayoutParams flp = (LayoutParams) mContent.getLayoutParams();
+ flp.topMargin = insets.top;
+ flp.bottomMargin = insets.bottom;
+ flp.leftMargin = insets.left;
+ flp.rightMargin = insets.right;
+ mContent.setLayoutParams(flp);
+ }
+
/**
* Setup the tab host and create all necessary tabs.
*/
diff --git a/src/com/android/launcher3/DragLayer.java b/src/com/android/launcher3/DragLayer.java
index be0d47b..9c649ed 100644
--- a/src/com/android/launcher3/DragLayer.java
+++ b/src/com/android/launcher3/DragLayer.java
@@ -69,6 +69,8 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang
public static final int ANIMATION_END_FADE_OUT = 1;
public static final int ANIMATION_END_REMAIN_VISIBLE = 2;
+ private final Rect mInsets = new Rect();
+
/**
* Used to create a new DragLayer from XML.
*
@@ -97,6 +99,26 @@ 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);
+ final FrameLayout.LayoutParams flp = (FrameLayout.LayoutParams) child.getLayoutParams();
+ if (child instanceof Insettable) {
+ ((Insettable)child).setInsets(insets);
+ } else {
+ flp.topMargin += (insets.top - mInsets.top);
+ flp.leftMargin += (insets.left - mInsets.left);
+ flp.rightMargin += (insets.right - mInsets.right);
+ flp.bottomMargin += (insets.bottom - mInsets.bottom);
+ }
+ child.setLayoutParams(flp);
+ }
+ mInsets.set(insets);
+ return true; // I'll take it from here
+ }
+
private boolean isEventOverFolderTextRegion(Folder folder, MotionEvent ev) {
getDescendantRectRelativeToSelf(folder.getEditTextRegion(), mHitRect);
if (mHitRect.contains((int) ev.getX(), (int) ev.getY())) {
diff --git a/src/com/android/launcher3/Insettable.java b/src/com/android/launcher3/Insettable.java
new file mode 100644
index 0000000..1d2356c
--- /dev/null
+++ b/src/com/android/launcher3/Insettable.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.launcher3;
+
+import android.graphics.Rect;
+
+public interface Insettable {
+
+ void setInsets(Rect insets);
+} \ No newline at end of file
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index bdd9add..29c4e3e 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -1103,7 +1103,8 @@ public class Launcher extends Activity
mDragLayer = (DragLayer) findViewById(R.id.drag_layer);
mWorkspace = (Workspace) mDragLayer.findViewById(R.id.workspace);
- mLauncherView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
+ mLauncherView.setSystemUiVisibility(
+ View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
mWorkspaceBackgroundDrawable = getResources().getDrawable(R.drawable.workspace_bg);
// Setup the drag layer
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 76c9a32..bdb0d58 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -260,6 +260,8 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
// Bouncer
private boolean mTopAlignPageWhenShrinkingForBouncer = false;
+ protected final Rect mInsets = new Rect();
+
public interface PageSwitchListener {
void onPageSwitch(View newPage, int newPageIndex);
}
@@ -798,7 +800,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
}
childWidth = widthSize - horizontalPadding;
- childHeight = heightSize - verticalPadding;
+ childHeight = heightSize - verticalPadding - mInsets.top - mInsets.bottom;
} else {
childWidthMode = MeasureSpec.EXACTLY;
@@ -873,17 +875,15 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
}
for (int i = startIndex; i != endIndex; i += delta) {
-
final View child = getPageAt(i);
LayoutParams lp = (LayoutParams) child.getLayoutParams();
int childTop;
-
if (lp.isFullScreenPage) {
childTop = offsetY;
} else {
- childTop = offsetY + getPaddingTop();
+ childTop = offsetY + getPaddingTop() + mInsets.top;
if (mCenterPagesVertically) {
- childTop += ((getViewportHeight() - verticalPadding) - child.getMeasuredHeight()) / 2;
+ childTop += (getViewportHeight() - mInsets.top - mInsets.bottom - verticalPadding - child.getMeasuredHeight()) / 2;
}
}
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index a8ca36b..3f63d74 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -71,7 +71,8 @@ import java.util.Iterator;
*/
public class Workspace extends SmoothPagedView
implements DropTarget, DragSource, DragScroller, View.OnTouchListener,
- DragController.DragListener, LauncherTransitionable, ViewGroup.OnHierarchyChangeListener {
+ DragController.DragListener, LauncherTransitionable, ViewGroup.OnHierarchyChangeListener,
+ Insettable {
private static final String TAG = "Launcher.Workspace";
// Y rotation to apply to the workspace screens
@@ -318,6 +319,11 @@ public class Workspace extends SmoothPagedView
}
}
+ @Override
+ public void setInsets(Rect insets) {
+ mInsets.set(insets);
+ }
+
// estimate the size of a widget with spans hSpan, vSpan. return MAX_VALUE for each
// dimension if unsuccessful
public int[] estimateItemSize(int hSpan, int vSpan,
@@ -525,6 +531,9 @@ public class Workspace extends SmoothPagedView
CellLayout.LayoutParams lp = new CellLayout.LayoutParams(0, 0, spanX, spanY);
lp.canReorder = false;
lp.isFullscreen = true;
+ if (customContent instanceof Insettable) {
+ ((Insettable)customContent).setInsets(mInsets);
+ }
customScreen.addViewToCellLayout(customContent, 0, 0, lp, true);
mCustomContentCallbacks = callbacks;