diff options
author | Tony Wickham <twickham@google.com> | 2015-09-11 09:27:58 -0700 |
---|---|---|
committer | Tony Wickham <twickham@google.com> | 2015-09-15 11:37:58 -0700 |
commit | 34d2c915c4762a073b60bb676a9e905392e9679c (patch) | |
tree | db5e660fbec645b2f8bc0cad4d6543e134d57f0c /src | |
parent | b54c4a3d864110a222e12683d88e6d46c27bf7a1 (diff) | |
download | android_packages_apps_Trebuchet-34d2c915c4762a073b60bb676a9e905392e9679c.tar.gz android_packages_apps_Trebuchet-34d2c915c4762a073b60bb676a9e905392e9679c.tar.bz2 android_packages_apps_Trebuchet-34d2c915c4762a073b60bb676a9e905392e9679c.zip |
Added AppInfoDropTargetBar to spring loaded workspace.
Change-Id: Ieedc68eba9a5934ab30d6d546d8a837274491064
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher3/AppInfoDropTargetBar.java | 74 | ||||
-rw-r--r-- | src/com/android/launcher3/DeviceProfile.java | 56 | ||||
-rw-r--r-- | src/com/android/launcher3/Folder.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher3/InfoDropTarget.java | 3 | ||||
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 13 | ||||
-rw-r--r-- | src/com/android/launcher3/Workspace.java | 7 | ||||
-rw-r--r-- | src/com/android/launcher3/WorkspaceStateTransitionAnimation.java | 9 | ||||
-rw-r--r-- | src/com/android/launcher3/dragndrop/DragLayer.java | 6 |
8 files changed, 141 insertions, 29 deletions
diff --git a/src/com/android/launcher3/AppInfoDropTargetBar.java b/src/com/android/launcher3/AppInfoDropTargetBar.java new file mode 100644 index 000000000..31ff42a7f --- /dev/null +++ b/src/com/android/launcher3/AppInfoDropTargetBar.java @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2011 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.content.Context; +import android.util.AttributeSet; + +import com.android.launcher3.dragndrop.DragController; + +public class AppInfoDropTargetBar extends BaseDropTargetBar { + private ButtonDropTarget mAppInfoDropTarget; + + public AppInfoDropTargetBar(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public AppInfoDropTargetBar(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + } + + @Override + protected void onFinishInflate() { + super.onFinishInflate(); + + // Get the individual components + mAppInfoDropTarget = (ButtonDropTarget) mDropTargetBar.findViewById(R.id.info_target_text); + + mAppInfoDropTarget.setDropTargetBar(this); + } + + @Override + public void setup(Launcher launcher, DragController dragController) { + dragController.addDragListener(this); + + dragController.addDragListener(mAppInfoDropTarget); + + dragController.addDropTarget(mAppInfoDropTarget); + + mAppInfoDropTarget.setLauncher(launcher); + } + + @Override + public void showDropTarget() { + animateDropTargetBarToAlpha(1f, DEFAULT_DRAG_FADE_DURATION); + } + + @Override + public void hideDropTarget() { + animateDropTargetBarToAlpha(0f, DEFAULT_DRAG_FADE_DURATION); + } + + private void animateDropTargetBarToAlpha(float alpha, int duration) { + animateViewAlpha(mDropTargetBarAnimator, mDropTargetBar, alpha,duration); + } + + @Override + public void enableAccessibleDrag(boolean enable) { + mAppInfoDropTarget.enableAccessibleDrag(enable); + } +} diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 6364d90c1..66cf2dfea 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -397,29 +397,15 @@ public class DeviceProfile { // Layout the search bar space View searchBar = launcher.getSearchDropTargetBar(); - lp = (FrameLayout.LayoutParams) searchBar.getLayoutParams(); - if (hasVerticalBarLayout) { - // Vertical search bar space -- The search bar is fixed in the layout to be on the left - // of the screen regardless of RTL - lp.gravity = Gravity.LEFT; - lp.width = searchBarSpaceHeightPx; - - LinearLayout targets = (LinearLayout) searchBar.findViewById(R.id.drag_target_bar); - targets.setOrientation(LinearLayout.VERTICAL); - FrameLayout.LayoutParams targetsLp = (FrameLayout.LayoutParams) targets.getLayoutParams(); - targetsLp.gravity = Gravity.TOP; - targetsLp.height = LayoutParams.WRAP_CONTENT; - - } else { - // Horizontal search bar space - lp.gravity = Gravity.TOP; - lp.height = searchBarSpaceHeightPx; - - LinearLayout targets = (LinearLayout) searchBar.findViewById(R.id.drag_target_bar); - targets.getLayoutParams().width = searchBarSpaceWidthPx; - } + lp = getDropTargetBarLayoutParams(hasVerticalBarLayout, searchBar, Gravity.TOP); searchBar.setLayoutParams(lp); + // Layout the app info bar space + View appInfoBar = launcher.getAppInfoDropTargetBar(); + lp = getDropTargetBarLayoutParams(hasVerticalBarLayout, appInfoBar, Gravity.BOTTOM); + lp.bottomMargin = hotseatBarHeightPx; + appInfoBar.setLayoutParams(lp); + // Layout the workspace PagedView workspace = (PagedView) launcher.findViewById(R.id.workspace); lp = (FrameLayout.LayoutParams) workspace.getLayoutParams(); @@ -478,7 +464,6 @@ public class DeviceProfile { // Layout the Overview Mode ViewGroup overviewMode = launcher.getOverviewPanel(); if (overviewMode != null) { - int overviewButtonBarHeight = getOverviewModeButtonBarHeight(); lp = (FrameLayout.LayoutParams) overviewMode.getLayoutParams(); lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM; @@ -487,7 +472,7 @@ public class DeviceProfile { int maxWidth = totalItemWidth + (visibleChildCount-1) * overviewModeBarSpacerWidthPx; lp.width = Math.min(availableWidthPx, maxWidth); - lp.height = overviewButtonBarHeight; + lp.height = getOverviewModeButtonBarHeight(); overviewMode.setLayoutParams(lp); if (lp.width > totalItemWidth && visibleChildCount > 1) { @@ -516,6 +501,31 @@ public class DeviceProfile { } } + private FrameLayout.LayoutParams getDropTargetBarLayoutParams(boolean hasVerticalBarLayout, + View dropTargetBar, int verticalGravity) { + FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) dropTargetBar.getLayoutParams(); + if (hasVerticalBarLayout) { + // Vertical drop target bar space -- The drop target bar is fixed in the layout to be on + // the left of the screen regardless of RTL + lp.gravity = Gravity.LEFT; + lp.width = searchBarSpaceHeightPx; + + LinearLayout targets = (LinearLayout) dropTargetBar.findViewById(R.id.drag_target_bar); + targets.setOrientation(LinearLayout.VERTICAL); + FrameLayout.LayoutParams targetsLp = (FrameLayout.LayoutParams) targets.getLayoutParams(); + targetsLp.gravity = verticalGravity; + targetsLp.height = LayoutParams.WRAP_CONTENT; + } else { + // Horizontal drop target bar space + lp.gravity = verticalGravity; + lp.height = searchBarSpaceHeightPx; + + LinearLayout targets = (LinearLayout) dropTargetBar.findViewById(R.id.drag_target_bar); + targets.getLayoutParams().width = searchBarSpaceWidthPx; + } + return lp; + } + private int getCurrentWidth() { return isLandscape ? Math.max(widthPx, heightPx) diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java index e85fce6ef..ff21be218 100644 --- a/src/com/android/launcher3/Folder.java +++ b/src/com/android/launcher3/Folder.java @@ -906,7 +906,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList @Override public boolean supportsAppInfoDropTarget() { - return false; + return true; } @Override diff --git a/src/com/android/launcher3/InfoDropTarget.java b/src/com/android/launcher3/InfoDropTarget.java index b4a144526..f5b7c5640 100644 --- a/src/com/android/launcher3/InfoDropTarget.java +++ b/src/com/android/launcher3/InfoDropTarget.java @@ -59,7 +59,8 @@ public class InfoDropTarget extends ButtonDropTarget { } public static boolean supportsDrop(Context context, ItemInfo info) { - return info instanceof AppInfo || info instanceof PendingAddItemInfo; + return info instanceof AppInfo || info instanceof ShortcutInfo + || info instanceof PendingAddItemInfo; } @Override diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 70a30c2ce..35d08baa4 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -247,6 +247,7 @@ public class Launcher extends Activity private View mWidgetsButton; private SearchDropTargetBar mSearchDropTargetBar; + private AppInfoDropTargetBar mAppInfoDropTargetBar; // Main container view for the all apps screen. @Thunk AllAppsContainerView mAppsView; @@ -1366,9 +1367,12 @@ public class Launcher extends Activity mWorkspace.setup(dragController); dragController.addDragListener(mWorkspace); - // Get the search/delete bar + // Get the search/delete/uninstall bar mSearchDropTargetBar = (SearchDropTargetBar) mDragLayer.findViewById(R.id.search_drop_target_bar); + // Get the app info bar + mAppInfoDropTargetBar = (AppInfoDropTargetBar) + mDragLayer.findViewById(R.id.app_info_drop_target_bar); // Setup Apps and Widgets mAppsView = (AllAppsContainerView) findViewById(R.id.apps_view); @@ -1387,6 +1391,9 @@ public class Launcher extends Activity mSearchDropTargetBar.setup(this, dragController); mSearchDropTargetBar.setQsbSearchBar(getOrCreateQsbBar()); } + if (mAppInfoDropTargetBar != null) { + mAppInfoDropTargetBar.setup(this, dragController); + } if (getResources().getBoolean(R.bool.debug_memory_enabled)) { Log.v(TAG, "adding WeightWatcher"); @@ -1773,6 +1780,10 @@ public class Launcher extends Activity return mSearchDropTargetBar; } + public AppInfoDropTargetBar getAppInfoDropTargetBar() { + return mAppInfoDropTargetBar; + } + public LauncherAppWidgetHost getAppWidgetHost() { return mAppWidgetHost; } diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index c5d323b73..0fe37deb3 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -1589,6 +1589,7 @@ public class Workspace extends PagedView setOnClickListener(mLauncher); } mLauncher.getSearchDropTargetBar().enableAccessibleDrag(enable); + mLauncher.getAppInfoDropTargetBar().enableAccessibleDrag(enable); mLauncher.getHotseat().getLayout() .enableAccessibleDrag(enable, CellLayout.WORKSPACE_ACCESSIBILITY_DRAG); } @@ -2013,6 +2014,10 @@ public class Workspace extends PagedView return -workspaceOffsetTopEdge + overviewOffsetTopEdge; } + int getSpringLoadedTranslationY() { + return getOverviewModeTranslationY(); + } + /** * Sets the current workspace {@link State}, returning an animation transitioning the workspace * to that new state. @@ -3825,7 +3830,7 @@ public class Workspace extends PagedView @Override public boolean supportsAppInfoDropTarget() { - return false; + return true; } @Override diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java index 011f4a2b1..d32ce7377 100644 --- a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java +++ b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java @@ -285,8 +285,13 @@ public class WorkspaceStateTransitionAnimation { float finalHotseatAndPageIndicatorAlpha = (states.stateIsNormal || states.stateIsSpringLoaded) ? 1f : 0f; float finalOverviewPanelAlpha = states.stateIsOverview ? 1f : 0f; - float finalWorkspaceTranslationY = states.stateIsOverview || states.stateIsOverviewHidden ? - mWorkspace.getOverviewModeTranslationY() : 0; + + float finalWorkspaceTranslationY = 0; + if (states.stateIsOverview || states.stateIsOverviewHidden) { + finalWorkspaceTranslationY = mWorkspace.getOverviewModeTranslationY(); + } else if (states.stateIsSpringLoaded) { + finalWorkspaceTranslationY = mWorkspace.getSpringLoadedTranslationY(); + } final int childCount = mWorkspace.getChildCount(); final int customPageCount = mWorkspace.numCustomPages(); diff --git a/src/com/android/launcher3/dragndrop/DragLayer.java b/src/com/android/launcher3/dragndrop/DragLayer.java index 6b6bef42f..adcc12cb6 100644 --- a/src/com/android/launcher3/dragndrop/DragLayer.java +++ b/src/com/android/launcher3/dragndrop/DragLayer.java @@ -165,6 +165,11 @@ public class DragLayer extends InsettableFrameLayout { if (mHitRect.contains((int) ev.getX(), (int) ev.getY())) { return true; } + + getDescendantRectRelativeToSelf(mLauncher.getAppInfoDropTargetBar(), mHitRect); + if (mHitRect.contains((int) ev.getX(), (int) ev.getY())) { + return true; + } return false; } @@ -324,6 +329,7 @@ public class DragLayer extends InsettableFrameLayout { if (isInAccessibleDrag()) { childrenForAccessibility.add(mLauncher.getSearchDropTargetBar()); + childrenForAccessibility.add(mLauncher.getAppInfoDropTargetBar()); } } else { super.addChildrenForAccessibility(childrenForAccessibility); |