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
This commit is contained in:
parent
5f92956617
commit
77e1f47520
|
@ -0,0 +1 @@
|
|||
db_files
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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())) {
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue