summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJorge Ruesga <jorge@ruesga.com>2015-10-23 22:02:45 (GMT)
committerJorge Ruesga <jorge@ruesga.com>2015-10-23 22:47:31 (GMT)
commite0fe49585371095e9942afa53819fc27b502a09e (patch)
tree28c1bd5afcf8498ec1e4ed58edc6a58fbb583420
parent9d7e6619afbe6f402ff86d395909f75448893713 (diff)
downloadandroid_packages_apps_Trebuchet-e0fe49585371095e9942afa53819fc27b502a09e.zip
android_packages_apps_Trebuchet-e0fe49585371095e9942afa53819fc27b502a09e.tar.gz
android_packages_apps_Trebuchet-e0fe49585371095e9942afa53819fc27b502a09e.tar.bz2
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 <jorge@ruesga.com>
-rw-r--r--src/com/android/launcher3/DeviceProfile.java7
-rw-r--r--src/com/android/launcher3/Launcher.java6
-rw-r--r--src/com/android/launcher3/SearchDropTargetBar.java14
-rw-r--r--src/com/android/launcher3/Workspace.java1
4 files changed, 26 insertions, 2 deletions
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 8bba13c..866e0ac 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 1dafd12..bada6ba 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 e17ac0e..8f5c5ec 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 ad045cc..71407b9 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);