From e0fe49585371095e9942afa53819fc27b502a09e Mon Sep 17 00:00:00 2001 From: Jorge Ruesga Date: Sat, 24 Oct 2015 00:02:45 +0200 Subject: trebuchet: ensure not overlaping shorcuts and drop items when searchbar is invisible If searchbar is hidden (via settings) in portrait mode in no tablets devices, the first row of shortcuts overlaps the drop target view, which made impossible to positioning the drag shorcut in the same cell because is ocuppied by the remove drop target. This change, in the conditions described previously, animates the workspace to ensure the drop search bar has enough space without overlapping the workspace layout. Also give an extra padding (edgeMarginPx) to the workspace when searchbar is present. Actually, the search bar and the first row of shortcut icons are too much closed. Change-Id: I9bc5e42852b83a5445beb01bd3bdece9f82074b5 Signed-off-by: Jorge Ruesga --- src/com/android/launcher3/DeviceProfile.java | 7 ++++++- src/com/android/launcher3/Launcher.java | 6 ++++++ src/com/android/launcher3/SearchDropTargetBar.java | 14 +++++++++++++- src/com/android/launcher3/Workspace.java | 1 + 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 8bba13c9d..866e0ac90 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -614,12 +614,17 @@ public class DeviceProfile { bounds.set(desiredWorkspaceLeftRightMarginPx - defaultWidgetPadding.left, getSearchBarTopOffset(), availableWidthPx - (desiredWorkspaceLeftRightMarginPx - - defaultWidgetPadding.right), searchBarVisible ? searchBarSpaceHeightPx : edgeMarginPx); + defaultWidgetPadding.right), + edgeMarginPx + (searchBarVisible ? searchBarSpaceHeightPx : 0)); } } return bounds; } + boolean shouldAnimQSBWithWorkspace() { + return !isLandscape && !isTablet(); + } + /** Returns the bounds of the workspace page indicators. */ Rect getWorkspacePageIndicatorBounds(Rect insets) { Rect workspacePadding = getWorkspacePadding(); diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 1dafd1245..bada6ba13 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -5250,6 +5250,12 @@ public class Launcher extends Activity mGrid.layoutSearchBar(this); } + public void bindSearchBar() { + if (mSearchDropTargetBar != null) { + mSearchDropTargetBar.setQsbSearchBar(getQsbBar()); + } + } + /** * Add the icons for all apps. * diff --git a/src/com/android/launcher3/SearchDropTargetBar.java b/src/com/android/launcher3/SearchDropTargetBar.java index e17ac0e3d..8f5c5ec2f 100644 --- a/src/com/android/launcher3/SearchDropTargetBar.java +++ b/src/com/android/launcher3/SearchDropTargetBar.java @@ -21,6 +21,7 @@ import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.ValueAnimator; import android.content.Context; +import android.content.res.Resources; import android.graphics.Rect; import android.util.AttributeSet; import android.view.View; @@ -59,6 +60,10 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D public SearchDropTargetBar(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); + + // Ensure a minimal height while view is finishing to inflate + final Resources res = context.getResources(); + mBarHeight = res.getDimensionPixelSize(R.dimen.dynamic_grid_search_bar_height); } public void setup(Launcher launcher, DragController dragController) { @@ -86,11 +91,18 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D alpha = mQSBSearchBar.getAlpha(); visibility = mQSBSearchBar.getVisibility(); } + if (mQSBSearchBarAnim != null) { + // Revert the current animation before swap it + mQSBSearchBarAnim.reverse(); + } mQSBSearchBar = qsb; if (mQSBSearchBar != null) { mQSBSearchBar.setAlpha(alpha); mQSBSearchBar.setVisibility(visibility); - if (mEnableDropDownDropTargets) { + if (!mLauncher.isSearchBarEnabled() && mLauncher.mGrid.shouldAnimQSBWithWorkspace()) { + mQSBSearchBarAnim = LauncherAnimUtils.ofFloat(mLauncher.getWorkspace(), + "translationY", 0, mBarHeight); + } else if (mEnableDropDownDropTargets) { mQSBSearchBarAnim = LauncherAnimUtils.ofFloat(mQSBSearchBar, "translationY", 0, -mBarHeight); } else { diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index ad045ccf4..71407b9fc 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -2256,6 +2256,7 @@ public class Workspace extends SmoothPagedView State finalState = Workspace.State.OVERVIEW; if (!enable) { finalState = Workspace.State.NORMAL; + mLauncher.bindSearchBar(); } Animator workspaceAnim = getChangeStateAnimation(finalState, animated, 0, snapPage); -- cgit v1.2.3