diff options
author | Winson Chung <winsonc@google.com> | 2011-07-08 15:34:52 -0700 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2011-07-11 11:38:24 -0700 |
commit | 557d6ed50cc6560163440aa134870ef0bb11415b (patch) | |
tree | 9abf7ad514d60f696d902a97f937cc356dd47ee6 | |
parent | a71cb1778dc0c7e76132d21296c58da777183e26 (diff) | |
download | android_packages_apps_Trebuchet-557d6ed50cc6560163440aa134870ef0bb11415b.tar.gz android_packages_apps_Trebuchet-557d6ed50cc6560163440aa134870ef0bb11415b.tar.bz2 android_packages_apps_Trebuchet-557d6ed50cc6560163440aa134870ef0bb11415b.zip |
Fixing issues with spring loaded adding.
- Delaying until items are added
- Showing bg when going into spring loaded mode
- Fixing regression where dropping widgets on full page would not trigger a notification
- Fixing regression on tablet where pages were no longer being rotated or shown
Change-Id: Iadc0c406f0c065c5029addea1abfee395eed81b9
27 files changed, 306 insertions, 217 deletions
diff --git a/res/layout-large/tab_widget_indicator.xml b/res/layout-land/apps_customize_application.xml index c09c8534c..bface6b7d 100644 --- a/res/layout-large/tab_widget_indicator.xml +++ b/res/layout-land/apps_customize_application.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2010 The Android Open Source Project +<!-- 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. @@ -14,6 +14,19 @@ limitations under the License. --> -<com.android.launcher2.AccessibleTabView +<com.android.launcher2.PagedViewIcon xmlns:android="http://schemas.android.com/apk/res/android" - style="@style/TabIndicator.Wide" /> + xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher" + + style="@style/WorkspaceIcon.Landscape.AppsCustomize" + + android:id="@+id/application_icon" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:gravity="center_horizontal" + + launcher:blurColor="#FF6B8CF0" + launcher:outlineColor="#FF8CD2FF" + + android:focusable="true" + android:background="@drawable/focusable_view_bg" /> diff --git a/res/layout-land/launcher.xml b/res/layout-land/launcher.xml index c120de8f9..4aa487035 100644 --- a/res/layout-land/launcher.xml +++ b/res/layout-land/launcher.xml @@ -31,7 +31,8 @@ android:fadeScrollbars="true" launcher:defaultScreen="2" launcher:cellCountX="4" - launcher:cellCountY="4"> + launcher:cellCountY="4" + launcher:pageSpacing="@dimen/workspace_page_spacing"> <include android:id="@+id/cell1" layout="@layout/workspace_screen" /> <include android:id="@+id/cell2" layout="@layout/workspace_screen" /> diff --git a/res/layout-large-port/workspace.xml b/res/layout-large-port/workspace.xml deleted file mode 100644 index ccd7d3312..000000000 --- a/res/layout-large-port/workspace.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- 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. ---> - -<!-- The workspace contains 5 screens of cells --> -<com.android.launcher2.Workspace - xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher" - android:paddingTop="?android:attr/actionBarSize" - android:paddingBottom="10dp" - launcher:defaultScreen="2" - launcher:pageSpacing="@dimen/workspace_page_spacing_port"> - <include android:id="@+id/cell1" layout="@layout/workspace_screen" /> - <include android:id="@+id/cell2" layout="@layout/workspace_screen" /> - <include android:id="@+id/cell3" layout="@layout/workspace_screen" /> - <include android:id="@+id/cell4" layout="@layout/workspace_screen" /> - <include android:id="@+id/cell5" layout="@layout/workspace_screen" /> -</com.android.launcher2.Workspace>
\ No newline at end of file diff --git a/res/layout-large-land/workspace.xml b/res/layout-large/workspace.xml index e8ea782ee..abed5a8f5 100644 --- a/res/layout-large-land/workspace.xml +++ b/res/layout-large/workspace.xml @@ -21,7 +21,7 @@ android:paddingTop="?android:attr/actionBarSize" android:paddingBottom="10dp" launcher:defaultScreen="2" - launcher:pageSpacing="@dimen/workspace_page_spacing_land"> + launcher:pageSpacing="@dimen/workspace_page_spacing"> <include android:id="@+id/cell1" layout="@layout/workspace_screen" /> <include android:id="@+id/cell2" layout="@layout/workspace_screen" /> <include android:id="@+id/cell3" layout="@layout/workspace_screen" /> diff --git a/res/layout/apps_customize_application.xml b/res/layout-port/apps_customize_application.xml index 37a8df7ee..37b41851f 100644 --- a/res/layout/apps_customize_application.xml +++ b/res/layout-port/apps_customize_application.xml @@ -18,7 +18,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher" - style="@style/WorkspaceIcon.AppsCustomize" + style="@style/WorkspaceIcon.Portrait.AppsCustomize" android:id="@+id/application_icon" android:layout_width="match_parent" diff --git a/res/layout-port/launcher.xml b/res/layout-port/launcher.xml index db074d758..73051babc 100644 --- a/res/layout-port/launcher.xml +++ b/res/layout-port/launcher.xml @@ -29,7 +29,8 @@ android:layout_height="match_parent" launcher:defaultScreen="2" launcher:cellCountX="4" - launcher:cellCountY="4"> + launcher:cellCountY="4" + launcher:pageSpacing="@dimen/workspace_page_spacing"> <include android:id="@+id/cell1" layout="@layout/workspace_screen" /> <include android:id="@+id/cell2" layout="@layout/workspace_screen" /> diff --git a/res/layout/apps_customize_pane.xml b/res/layout/apps_customize_pane.xml index 00c87cb09..adb0a6d35 100644 --- a/res/layout/apps_customize_pane.xml +++ b/res/layout/apps_customize_pane.xml @@ -25,7 +25,7 @@ <FrameLayout android:id="@+id/tabs_container" android:layout_width="wrap_content" - android:layout_height="@dimen/qsb_bar_height" + android:layout_height="@dimen/apps_customize_tab_bar_height" android:layout_gravity="center_horizontal"> <com.android.launcher2.FocusOnlyTabWidget android:id="@android:id/tabs" @@ -64,14 +64,14 @@ android:id="@+id/apps_customize_pane_content" android:layout_width="match_parent" android:layout_height="match_parent" - launcher:cellCountX="@integer/all_apps_view_cellCountX" - launcher:cellCountY="@integer/all_apps_view_cellCountY" - launcher:pageLayoutWidthGap="@dimen/all_apps_view_pageLayoutWidthGap" - launcher:pageLayoutHeightGap="@dimen/all_apps_view_pageLayoutHeightGap" - launcher:pageLayoutPaddingTop="@dimen/all_apps_view_pageLayoutPaddingTop" - launcher:pageLayoutPaddingBottom="@dimen/all_apps_view_pageLayoutPaddingBottom" - launcher:pageLayoutPaddingLeft="@dimen/all_apps_view_pageLayoutPaddingLeft" - launcher:pageLayoutPaddingRight="@dimen/all_apps_view_pageLayoutPaddingRight" + launcher:cellCountX="@integer/apps_customize_cellCountX" + launcher:cellCountY="@integer/apps_customize_cellCountY" + launcher:pageLayoutWidthGap="@dimen/apps_customize_pageLayoutWidthGap" + launcher:pageLayoutHeightGap="@dimen/apps_customize_pageLayoutHeightGap" + launcher:pageLayoutPaddingTop="@dimen/apps_customize_pageLayoutPaddingTop" + launcher:pageLayoutPaddingBottom="@dimen/apps_customize_pageLayoutPaddingBottom" + launcher:pageLayoutPaddingLeft="@dimen/apps_customize_pageLayoutPaddingLeft" + launcher:pageLayoutPaddingRight="@dimen/apps_customize_pageLayoutPaddingRight" launcher:widgetCellWidthGap="@dimen/apps_customize_widget_cell_width_gap" launcher:widgetCellHeightGap="@dimen/apps_customize_widget_cell_height_gap" launcher:widgetCountX="@integer/apps_customize_widget_cell_count_x" diff --git a/res/layout/tab_widget_indicator.xml b/res/layout/tab_widget_indicator.xml index b3694febc..df43d3ddd 100644 --- a/res/layout/tab_widget_indicator.xml +++ b/res/layout/tab_widget_indicator.xml @@ -16,4 +16,4 @@ <com.android.launcher2.AccessibleTabView xmlns:android="http://schemas.android.com/apk/res/android" - style="@style/TabIndicator" /> + style="@style/TabIndicator.AppsCustomize" /> diff --git a/res/values-land/dimens.xml b/res/values-land/dimens.xml index 278da5419..463cd17fa 100644 --- a/res/values-land/dimens.xml +++ b/res/values-land/dimens.xml @@ -24,21 +24,25 @@ <dimen name="workspace_right_padding">@dimen/button_bar_height</dimen> <dimen name="workspace_top_padding">0dp</dimen> <dimen name="workspace_bottom_padding">0dp</dimen> + <dimen name="workspace_page_spacing">8dp</dimen> <dimen name="folder_cell_width">100dip</dimen> <dimen name="folder_cell_height">74dip</dimen> <dimen name="button_bar_height">62dip</dimen> - <integer name="all_apps_view_cellCountX">6</integer> - <integer name="all_apps_view_cellCountY">3</integer> - <dimen name="all_apps_view_pageLayoutWidthGap">-1dp</dimen> - <dimen name="all_apps_view_pageLayoutHeightGap">-1dp</dimen> - <dimen name="all_apps_view_pageLayoutPaddingTop">5dp</dimen> - <dimen name="all_apps_view_pageLayoutPaddingBottom">5dp</dimen> - <dimen name="all_apps_view_pageLayoutPaddingLeft">5dp</dimen> - <dimen name="all_apps_view_pageLayoutPaddingRight">5dp</dimen> - <!-- AppsCustomize --> + <dimen name="apps_customize_cell_width">80dp</dimen> + <!-- The width can be 76dp because we don't have B padding --> + <dimen name="apps_customize_cell_height">76dp</dimen> + <integer name="apps_customize_cellCountX">6</integer> + <integer name="apps_customize_cellCountY">3</integer> + <dimen name="apps_customize_pageLayoutWidthGap">-1dp</dimen> + <dimen name="apps_customize_pageLayoutHeightGap">-1dp</dimen> + <dimen name="apps_customize_pageLayoutPaddingTop">5dp</dimen> + <dimen name="apps_customize_pageLayoutPaddingBottom">5dp</dimen> + <dimen name="apps_customize_pageLayoutPaddingLeft">5dp</dimen> + <dimen name="apps_customize_pageLayoutPaddingRight">5dp</dimen> + <dimen name="apps_customize_tab_bar_height">42dp</dimen> <dimen name="apps_customize_widget_cell_width_gap">30dp</dimen> <dimen name="apps_customize_widget_cell_height_gap">5dp</dimen> <integer name="apps_customize_widget_cell_count_x">3</integer> diff --git a/res/values-land/styles.xml b/res/values-land/styles.xml index 659947be2..e8d767ca8 100644 --- a/res/values-land/styles.xml +++ b/res/values-land/styles.xml @@ -51,6 +51,11 @@ <item name="android:paddingRight">@dimen/toolbar_button_horizontal_padding</item> </style> + <style name="TabIndicator.AppsCustomize"> + <item name="android:paddingTop">5dp</item> + <item name="android:paddingBottom">10dp</item> + </style> + <style name="HotseatButton"> <item name="android:paddingTop">12dip</item> <item name="android:paddingBottom">12dip</item> diff --git a/res/values-large-land/dimens.xml b/res/values-large-land/dimens.xml index ee4c70b8b..d14a8dfd0 100644 --- a/res/values-large-land/dimens.xml +++ b/res/values-large-land/dimens.xml @@ -22,15 +22,16 @@ <dimen name="workspace_bottom_padding">15dip</dimen> <dimen name="workspace_width_gap">32dp</dimen> <dimen name="workspace_height_gap">2dp</dimen> + <dimen name="workspace_page_spacing">50dp</dimen> <!-- the area at the edge of the screen that makes the workspace go left or right while you're dragging. --> <dimen name="scroll_zone">100dip</dimen> - <dimen name="all_apps_view_pageLayoutWidthGap">28dp</dimen> - <dimen name="all_apps_view_pageLayoutHeightGap">8dp</dimen> - <dimen name="all_apps_view_pageLayoutPaddingTop">20dp</dimen> - <dimen name="all_apps_view_pageLayoutPaddingBottom">14dp</dimen> - <dimen name="all_apps_view_pageLayoutPaddingLeft">40dp</dimen> - <dimen name="all_apps_view_pageLayoutPaddingRight">40dp</dimen> + <dimen name="apps_customize_pageLayoutWidthGap">28dp</dimen> + <dimen name="apps_customize_pageLayoutHeightGap">8dp</dimen> + <dimen name="apps_customize_pageLayoutPaddingTop">20dp</dimen> + <dimen name="apps_customize_pageLayoutPaddingBottom">14dp</dimen> + <dimen name="apps_customize_pageLayoutPaddingLeft">40dp</dimen> + <dimen name="apps_customize_pageLayoutPaddingRight">40dp</dimen> </resources>
\ No newline at end of file diff --git a/res/values-large-port/dimens.xml b/res/values-large-port/dimens.xml index c1525ea35..e0651b22b 100644 --- a/res/values-large-port/dimens.xml +++ b/res/values-large-port/dimens.xml @@ -22,6 +22,7 @@ calculating the number of columns to fit a page. In portrait/large we use apps_customize_cell_width / 8. --> <dimen name="apps_customize_peek_width">12dp</dimen> + <dimen name="workspace_page_spacing">64dp</dimen> <!-- Workspace --> <!-- the area at the edge of the screen that makes the workspace go left @@ -35,10 +36,10 @@ <dimen name="workspace_width_gap">0dp</dimen> <dimen name="workspace_height_gap">32dp</dimen> - <dimen name="all_apps_view_pageLayoutWidthGap">24dp</dimen> - <dimen name="all_apps_view_pageLayoutHeightGap">36dp</dimen> - <dimen name="all_apps_view_pageLayoutPaddingTop">25dp</dimen> - <dimen name="all_apps_view_pageLayoutPaddingBottom">10dp</dimen> - <dimen name="all_apps_view_pageLayoutPaddingLeft">20dp</dimen> - <dimen name="all_apps_view_pageLayoutPaddingRight">20dp</dimen> + <dimen name="apps_customize_pageLayoutWidthGap">24dp</dimen> + <dimen name="apps_customize_pageLayoutHeightGap">36dp</dimen> + <dimen name="apps_customize_pageLayoutPaddingTop">25dp</dimen> + <dimen name="apps_customize_pageLayoutPaddingBottom">10dp</dimen> + <dimen name="apps_customize_pageLayoutPaddingLeft">20dp</dimen> + <dimen name="apps_customize_pageLayoutPaddingRight">20dp</dimen> </resources>
\ No newline at end of file diff --git a/res/values-large/dimens.xml b/res/values-large/dimens.xml index 7da10db41..59aaa417d 100644 --- a/res/values-large/dimens.xml +++ b/res/values-large/dimens.xml @@ -25,10 +25,8 @@ <dimen name="workspace_cell_width">96dip</dimen> <dimen name="workspace_cell_height">96dip</dimen> - <dimen name="workspace_page_spacing_land">50dp</dimen> - <dimen name="workspace_page_spacing_port">64dp</dimen> - <!-- AppsCustomize --> + <dimen name="apps_customize_tab_bar_height">56dp</dimen> <dimen name="apps_customize_cell_width">96dp</dimen> <dimen name="apps_customize_cell_height">96dp</dimen> <!-- The amount of space to account for the next/prev pages when diff --git a/res/values-large/styles.xml b/res/values-large/styles.xml index 25b8195dd..bd4efe7d1 100644 --- a/res/values-large/styles.xml +++ b/res/values-large/styles.xml @@ -77,7 +77,7 @@ <item name="android:screenOrientation">unspecified</item> </style> - <style name="TabIndicator.Wide"> + <style name="TabIndicator.AppsCustomize"> <item name="android:paddingLeft">40dp</item> <item name="android:paddingRight">40dp</item> <item name="android:paddingTop">10dp</item> @@ -115,5 +115,9 @@ <item name="android:drawablePadding">7.5dp</item> <item name="android:textColor">#FFFFFFFF</item> <item name="android:textSize">16sp</item> + <item name="android:shadowColor">#393939</item> + <item name="android:shadowDx">0.0</item> + <item name="android:shadowDy">0.0</item> + <item name="android:shadowRadius">2.0</item> </style> </resources> diff --git a/res/values-port/dimens.xml b/res/values-port/dimens.xml index 945699bb1..c5fdd68e0 100644 --- a/res/values-port/dimens.xml +++ b/res/values-port/dimens.xml @@ -23,18 +23,19 @@ <!-- NOTE: This padding is the @dimen/button_bar_height + some padding for signposting --> <dimen name="workspace_bottom_padding">64dp</dimen> + <dimen name="workspace_page_spacing">8dp</dimen> <dimen name="folder_cell_width">74dip</dimen> <dimen name="folder_cell_height">86dip</dimen> - <integer name="all_apps_view_cellCountX">4</integer> - <integer name="all_apps_view_cellCountY">5</integer> - <dimen name="all_apps_view_pageLayoutWidthGap">-1dp</dimen> - <dimen name="all_apps_view_pageLayoutHeightGap">-1dp</dimen> - <dimen name="all_apps_view_pageLayoutPaddingTop">15dp</dimen> - <dimen name="all_apps_view_pageLayoutPaddingBottom">15dp</dimen> - <dimen name="all_apps_view_pageLayoutPaddingLeft">5dp</dimen> - <dimen name="all_apps_view_pageLayoutPaddingRight">5dp</dimen> + <integer name="apps_customize_cellCountX">4</integer> + <integer name="apps_customize_cellCountY">5</integer> + <dimen name="apps_customize_pageLayoutWidthGap">-1dp</dimen> + <dimen name="apps_customize_pageLayoutHeightGap">-1dp</dimen> + <dimen name="apps_customize_pageLayoutPaddingTop">15dp</dimen> + <dimen name="apps_customize_pageLayoutPaddingBottom">15dp</dimen> + <dimen name="apps_customize_pageLayoutPaddingLeft">5dp</dimen> + <dimen name="apps_customize_pageLayoutPaddingRight">5dp</dimen> <dimen name="apps_customize_widget_cell_width_gap">20dp</dimen> <dimen name="apps_customize_widget_cell_height_gap">10dp</dimen> diff --git a/res/values-xlarge-port/dimens.xml b/res/values-xlarge-port/dimens.xml index 31db0b352..4f532805a 100644 --- a/res/values-xlarge-port/dimens.xml +++ b/res/values-xlarge-port/dimens.xml @@ -22,5 +22,5 @@ <!-- We can also afford to have a slightly wider portrait layout in xlarge --> - <dimen name="all_apps_view_pageLayoutWidthGap">36dp</dimen> + <dimen name="apps_customize_pageLayoutWidthGap">36dp</dimen> </resources>
\ No newline at end of file diff --git a/res/values/config.xml b/res/values/config.xml index 497011c3c..f03ded71f 100644 --- a/res/values/config.xml +++ b/res/values/config.xml @@ -1,6 +1,8 @@ <resources> <bool name="config_hardwareAccelerated">true</bool> <!-- AllApps/Customize/AppsCustomize --> + <!-- The alpha of the AppsCustomize bg in spring loaded mode --> + <integer name="config_appsCustomizeSpringLoadedBgAlpha">45</integer> <!-- Fade in/out duration of icons being dragged from the trays --> <integer name="config_dragAppsCustomizeIconFadeInDuration">150</integer> <integer name="config_dragAppsCustomizeIconFadeOutDuration">200</integer> diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 7353eda7d..c04dd8e06 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -29,19 +29,17 @@ <dimen name="toolbar_button_horizontal_padding">12dip</dimen> <!-- AllApps/Customize/AppsCustomize --> - <!-- Size of icons in Workspace/AppsCustomize --> + <dimen name="apps_customize_tab_bar_height">56dp</dimen> <dimen name="app_icon_size">56dp</dimen> + <!-- The width can be 72dp because we don't have L/R padding --> <dimen name="apps_customize_cell_width">72dp</dimen> - <dimen name="apps_customize_cell_height">72dp</dimen> + <dimen name="apps_customize_cell_height">80dp</dimen> <dimen name="apps_customize_peek_width">0dp</dimen> <dimen name="apps_customize_max_gap">18dp</dimen> <dimen name="apps_customize_widget_cell_width_gap">10dp</dimen> <dimen name="apps_customize_widget_cell_height_gap">10dp</dimen> <dimen name="title_texture_width">120px</dimen> - <!-- height of the tab bar in AppsCustomize --> - <dimen name="apps_customize_tab_bar_height">56dp</dimen> - <!-- height of the bottom row of controls --> <dimen name="button_bar_height">56dip</dimen> diff --git a/res/values/styles.xml b/res/values/styles.xml index 06f6ed0f0..46e5f95a5 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -51,12 +51,6 @@ <item name="android:shadowColor">#B0000000</item> </style> - <style name="WorkspaceIcon.AppsCustomize"> - <item name="android:background">@null</item> - <item name="android:drawablePadding">0dp</item> - <item name="android:includeFontPadding">false</item> - </style> - <style name="WorkspaceIcon.Portrait"> <item name="android:drawablePadding">4dp</item> <item name="android:paddingLeft">4dp</item> @@ -72,16 +66,30 @@ <item name="android:paddingTop">2dp</item> <item name="android:paddingBottom">4dp</item> </style> + <style name="WorkspaceIcon.Portrait.Folder"> <item name="android:drawablePadding">0dp</item> <item name="android:paddingTop">0dp</item> </style> - <style name="WorkspaceIcon.Landscape.Folder"> <item name="android:drawablePadding">0dp</item> <item name="android:paddingTop">0dp</item> </style> + <style name="WorkspaceIcon.Portrait.AppsCustomize"> + <item name="android:background">@null</item> + <item name="android:paddingLeft">0dp</item> + <item name="android:paddingRight">0dp</item> + <item name="android:drawablePadding">0dp</item> + <item name="android:includeFontPadding">false</item> + </style> + <style name="WorkspaceIcon.Landscape.AppsCustomize"> + <item name="android:background">@null</item> + <item name="android:paddingBottom">0dp</item> + <item name="android:drawablePadding">0dp</item> + <item name="android:includeFontPadding">false</item> + </style> + <style name="SearchDropTargetBar"> <item name="android:orientation">horizontal</item> <item name="android:layout_width">match_parent</item> @@ -111,6 +119,10 @@ <item name="android:drawablePadding">7.5dp</item> <item name="android:textColor">#FFFFFFFF</item> <item name="android:textSize">16sp</item> + <item name="android:shadowColor">#393939</item> + <item name="android:shadowDx">0.0</item> + <item name="android:shadowDy">0.0</item> + <item name="android:shadowRadius">2.0</item> </style> <style name="TabIndicator"> @@ -129,6 +141,9 @@ <item name="android:shadowDy">1.0</item> <item name="android:shadowRadius">1.0</item> </style> + <style name="TabIndicator.AppsCustomize"> + <!-- Overridden in values-land --> + </style> <style name="MarketButton"> <item name="android:paddingLeft">5dp</item> diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java index 33472ea56..f5874bfaf 100644 --- a/src/com/android/launcher2/AppsCustomizePagedView.java +++ b/src/com/android/launcher2/AppsCustomizePagedView.java @@ -472,9 +472,13 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen } return true; } - private void endDragging(boolean success) { + private void endDragging(View target, boolean success) { mLauncher.getWorkspace().onDragStopped(success); - mLauncher.exitSpringLoadedDragMode(); + if (!success || target != mLauncher.getWorkspace()) { + // Exit spring loaded mode if we have not successfully dropped or have not handled the + // drop in Workspace + mLauncher.exitSpringLoadedDragMode(); + } mLauncher.unlockScreenOrientation(); } @@ -486,7 +490,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen public void onDragViewVisible() {} @Override public void onDropCompleted(View target, DragObject d, boolean success) { - endDragging(success); + endDragging(target, success); // Display an error message if the drag failed due to there not being enough space on the // target layout we were dropping on. diff --git a/src/com/android/launcher2/DragLayer.java b/src/com/android/launcher2/DragLayer.java index dfd816053..0bdfec149 100644 --- a/src/com/android/launcher2/DragLayer.java +++ b/src/com/android/launcher2/DragLayer.java @@ -175,16 +175,25 @@ public class DragLayer extends FrameLayout { mTmpXY[0] + descendant.getWidth(), mTmpXY[1] + descendant.getHeight()); } - private void getDescendantCoordRelativeToSelf(View descendant, int[] coord) { - coord[0] += descendant.getLeft(); - coord[1] += descendant.getTop(); + private float getDescendantCoordRelativeToSelf(View descendant, int[] coord) { + float scale = 1.0f; + float[] pt = {coord[0], coord[1]}; + descendant.getMatrix().mapPoints(pt); + scale *= descendant.getScaleX(); + pt[0] += descendant.getLeft(); + pt[1] += descendant.getTop(); ViewParent viewParent = descendant.getParent(); while (viewParent instanceof View && viewParent != this) { final View view = (View)viewParent; - coord[0] += view.getLeft() + (int) (view.getTranslationX() + 0.5f) - view.getScrollX(); - coord[1] += view.getTop() + (int) (view.getTranslationY() + 0.5f) - view.getScrollY(); + view.getMatrix().mapPoints(pt); + scale *= view.getScaleX(); + pt[0] += view.getLeft() - view.getScrollX(); + pt[1] += view.getTop() - view.getScrollY(); viewParent = view.getParent(); } + coord[0] = (int) pt[0]; + coord[1] = (int) pt[1]; + return scale; } public void getLocationInDragLayer(View child, int[] loc) { @@ -304,6 +313,10 @@ public class DragLayer extends FrameLayout { } public void animateViewIntoPosition(DragView dragView, final View child) { + animateViewIntoPosition(dragView, child, null); + } + public void animateViewIntoPosition(DragView dragView, final View child, + final Runnable onFinishAnimationRunnable) { ((CellLayoutChildren) child.getParent()).measureChild(child); CellLayout.LayoutParams lp = (CellLayout.LayoutParams) child.getLayoutParams(); @@ -311,13 +324,15 @@ public class DragLayer extends FrameLayout { getViewRectRelativeToSelf(dragView, r); int coord[] = new int[2]; - coord[0] = lp.x; - coord[1] = lp.y; + coord[0] = lp.x + (lp.width / 2); + coord[1] = lp.y + (lp.height / 2); // Since the child hasn't necessarily been laid out, we force the lp to be updated with // the correct coordinates and use these to determine the final location - getDescendantCoordRelativeToSelf((View) child.getParent(), coord); - int toX = coord[0] - (dragView.getWidth() - child.getMeasuredWidth()) / 2; - int toY = coord[1] - (dragView.getHeight() - child.getMeasuredHeight()) / 2; + float scale = getDescendantCoordRelativeToSelf((View) child.getParent(), coord); + int toX = coord[0] - lp.width / 2; + int toY = coord[1] - lp.height / 2; + toX -= (dragView.getWidth() - child.getMeasuredWidth()) / 2; + toY -= (dragView.getHeight() - child.getMeasuredHeight()) / 2; final int fromX = r.left + (dragView.getWidth() - child.getMeasuredWidth()) / 2; final int fromY = r.top + (dragView.getHeight() - child.getMeasuredHeight()) / 2; @@ -328,19 +343,39 @@ public class DragLayer extends FrameLayout { child.setVisibility(VISIBLE); ObjectAnimator oa = ObjectAnimator.ofFloat(child, "alpha", 0f, 1f); oa.setDuration(60); + oa.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(android.animation.Animator animation) { + if (onFinishAnimationRunnable != null) { + onFinishAnimationRunnable.run(); + } + } + }); oa.start(); } }; - animateViewIntoPosition(dragView, fromX, fromY, toX, toY, onCompleteRunnable, true); + animateViewIntoPosition(dragView, fromX, fromY, toX, toY, scale, onCompleteRunnable, true); + } + + /* Just fade out in place */ + public void animateViewOut(DragView dragView, Runnable onFinishAnimationRunnable) { + Rect r = new Rect(); + getViewRectRelativeToSelf(dragView, r); + final int fromX = r.left; + final int fromY = r.top; + final int toX = fromX; + final int toY = fromY; + animateViewIntoPosition(dragView, fromX, fromY, toX, toY, 1.0f, onFinishAnimationRunnable, + true); } private void animateViewIntoPosition(final View view, final int fromX, final int fromY, - final int toX, final int toY, Runnable onCompleteRunnable, boolean fadeOut) { + final int toX, final int toY, float finalScale, Runnable onCompleteRunnable, + boolean fadeOut) { Rect from = new Rect(fromX, fromY, fromX + view.getMeasuredWidth(), fromY + view.getMeasuredHeight()); Rect to = new Rect(toX, toY, toX + view.getMeasuredWidth(), toY + view.getMeasuredHeight()); - animateView(view, from, to, 1f, 1.0f, -1, null, null, onCompleteRunnable, true); - + animateView(view, from, to, 1f, finalScale, -1, null, null, onCompleteRunnable, true); } public void animateView(final View view, final Rect from, final Rect to, final float finalAlpha, diff --git a/src/com/android/launcher2/DropTarget.java b/src/com/android/launcher2/DropTarget.java index 071242060..34fa89316 100644 --- a/src/com/android/launcher2/DropTarget.java +++ b/src/com/android/launcher2/DropTarget.java @@ -49,6 +49,9 @@ public interface DropTarget { /** Where the drag originated */ public DragSource dragSource = null; + /** Post drag animation runnable */ + public Runnable postAnimationRunnable = null; + public DragObject() { } } diff --git a/src/com/android/launcher2/FolderIcon.java b/src/com/android/launcher2/FolderIcon.java index 4978e98e9..283c2954f 100644 --- a/src/com/android/launcher2/FolderIcon.java +++ b/src/com/android/launcher2/FolderIcon.java @@ -286,12 +286,13 @@ public class FolderIcon extends LinearLayout implements FolderListener { } public void performCreateAnimation(final ShortcutInfo destInfo, final View destView, - final ShortcutInfo srcInfo, final View srcView, Rect dstRect) { + final ShortcutInfo srcInfo, final View srcView, Rect dstRect, + Runnable postAnimationRunnable) { Drawable animateDrawable = ((TextView) destView).getCompoundDrawables()[1]; computePreviewDrawingParams(animateDrawable.getIntrinsicWidth(), destView.getMeasuredWidth()); // This will animate the dragView (srcView) into the new folder - onDrop(srcInfo, srcView, dstRect, 1); + onDrop(srcInfo, srcView, dstRect, 1, postAnimationRunnable); // This will animate the first item from it's position as an icon into its // position as the first item in the preview @@ -309,7 +310,8 @@ public class FolderIcon extends LinearLayout implements FolderListener { mFolderRingAnimator.animateToNaturalState(); } - private void onDrop(final ShortcutInfo item, View animateView, Rect finalRect, int index) { + private void onDrop(final ShortcutInfo item, View animateView, Rect finalRect, int index, + Runnable postAnimationRunnable) { item.cellX = -1; item.cellY = -1; DragLayer dragLayer = mLauncher.getDragLayer(); @@ -332,7 +334,8 @@ public class FolderIcon extends LinearLayout implements FolderListener { float finalAlpha = index < NUM_ITEMS_IN_PREVIEW ? 0.5f : 0f; dragLayer.animateView(animateView, from, to, finalAlpha, scale, DROP_IN_ANIMATION_DURATION, - new DecelerateInterpolator(2), new AccelerateInterpolator(2), null, false); + new DecelerateInterpolator(2), new AccelerateInterpolator(2), postAnimationRunnable, + false); postDelayed(new Runnable() { public void run() { addItem(item); @@ -348,7 +351,7 @@ public class FolderIcon extends LinearLayout implements FolderListener { } else { item = (ShortcutInfo) d.dragInfo; } - onDrop(item, d.dragView, null, mInfo.contents.size()); + onDrop(item, d.dragView, null, mInfo.contents.size(), d.postAnimationRunnable); } public DropTarget getDropTargetDelegate(DragObject d) { diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index 76866a7f1..530f49ca9 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -167,6 +167,8 @@ public final class Launcher extends Activity private AnimatorSet mStateAnimation; static final int APPWIDGET_HOST_ID = 1024; + private static final int EXIT_SPRINGLOADED_MODE_SHORT_TIMEOUT = 300; + private static final int EXIT_SPRINGLOADED_MODE_LONG_TIMEOUT = 600; private static final Object sLock = new Object(); private static int sScreen = DEFAULT_SCREEN; @@ -592,7 +594,11 @@ public final class Launcher extends Activity } } - private void completeAdd(PendingAddArguments args) { + /** + * Returns whether we should delay spring loaded mode -- for shortcuts and widgets that have + * a configuration step, this allows the proper animations to run after other transitions. + */ + private boolean completeAdd(PendingAddArguments args) { switch (args.requestCode) { case REQUEST_PICK_APPLICATION: completeAddApplication(args.intent, args.screen, args.cellX, args.cellY); @@ -602,22 +608,24 @@ public final class Launcher extends Activity break; case REQUEST_CREATE_SHORTCUT: completeAddShortcut(args.intent, args.screen, args.cellX, args.cellY); - break; + return true; case REQUEST_PICK_APPWIDGET: addAppWidgetFromPick(args.intent); break; case REQUEST_CREATE_APPWIDGET: int appWidgetId = args.intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1); completeAddAppWidget(appWidgetId, args.screen); - break; + return true; case REQUEST_PICK_WALLPAPER: // We just wanted the activity result here so we can clear mWaitingForResult break; } + return false; } @Override protected void onActivityResult(final int requestCode, int resultCode, final Intent data) { + boolean delayExitSpringLoadedMode = false; mWaitingForResult = false; // The pattern used here is that a user PICKs a specific application, @@ -638,17 +646,21 @@ public final class Launcher extends Activity if (isWorkspaceLocked()) { sPendingAddList.add(args); } else { - completeAdd(args); + delayExitSpringLoadedMode = completeAdd(args); } } else if ((requestCode == REQUEST_PICK_APPWIDGET || - requestCode == REQUEST_CREATE_APPWIDGET) && resultCode == RESULT_CANCELED && - data != null) { - // Clean up the appWidgetId if we canceled - int appWidgetId = data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1); - if (appWidgetId != -1) { - mAppWidgetHost.deleteAppWidgetId(appWidgetId); + requestCode == REQUEST_CREATE_APPWIDGET) && resultCode == RESULT_CANCELED) { + if (data != null) { + // Clean up the appWidgetId if we canceled + int appWidgetId = data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1); + if (appWidgetId != -1) { + mAppWidgetHost.deleteAppWidgetId(appWidgetId); + } } } + + // Exit spring loaded mode if necessary after cancelling the configuration of a widget + exitSpringLoadedDragModeDelayed(delayExitSpringLoadedMode); } @Override @@ -1549,6 +1561,9 @@ public final class Launcher extends Activity } else { // Otherwise just add it completeAddAppWidget(appWidgetId, mAddScreen); + + // Exit spring loaded mode if necessary after adding the widget + exitSpringLoadedDragModeDelayed(false); } } @@ -2541,7 +2556,16 @@ public final class Launcher extends Activity } // Otherwise, we are not in spring loaded mode, so don't do anything. } - + void exitSpringLoadedDragModeDelayed(boolean extendedDelay) { + mWorkspace.postDelayed(new Runnable() { + @Override + public void run() { + exitSpringLoadedDragMode(); + } + }, (extendedDelay ? + EXIT_SPRINGLOADED_MODE_LONG_TIMEOUT : + EXIT_SPRINGLOADED_MODE_SHORT_TIMEOUT)); + } void exitSpringLoadedDragMode() { if (mState == State.APPS_CUSTOMIZE_SPRING_LOADED) { mWorkspace.exitSpringLoadedDragMode(Workspace.ShrinkState.BOTTOM_VISIBLE); @@ -2673,10 +2697,6 @@ public final class Launcher extends Activity } } - void onWorkspaceClick(CellLayout layout) { - showWorkspace(true, layout); - } - private Drawable getExternalPackageToolbarIcon(ComponentName activityName) { try { PackageManager packageManager = getPackageManager(); diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java index 81e876fdb..8c74c42e5 100644 --- a/src/com/android/launcher2/PagedView.java +++ b/src/com/android/launcher2/PagedView.java @@ -368,8 +368,11 @@ public abstract class PagedView extends ViewGroup { // we moved this functionality to a helper function so SmoothPagedView can reuse it protected boolean computeScrollHelper() { if (mScroller.computeScrollOffset()) { - mDirtyPageAlpha = true; - scrollTo(mScroller.getCurrX(), mScroller.getCurrY()); + // Don't bother scrolling if the page does not need to be moved + if (mScrollX != mScroller.getCurrX() || mScrollY != mScroller.getCurrY()) { + mDirtyPageAlpha = true; + scrollTo(mScroller.getCurrX(), mScroller.getCurrY()); + } invalidate(); return true; } else if (mNextPage != INVALID_PAGE) { @@ -652,7 +655,7 @@ public abstract class PagedView extends ViewGroup { if (pageCount > 0) { final int pageWidth = getScaledMeasuredWidth(getChildAt(0)); final int screenWidth = getMeasuredWidth(); - int x = getRelativeChildOffset(0) + pageWidth; + int x = getScaledRelativeChildOffset(0) + pageWidth; int leftScreen = 0; int rightScreen = 0; while (x <= mScrollX) { @@ -1255,6 +1258,10 @@ public abstract class PagedView extends ViewGroup { return (getMeasuredWidth() - getChildWidth(index)) / 2; } + protected int getScaledRelativeChildOffset(int index) { + return (getMeasuredWidth() - getScaledMeasuredWidth(getChildAt(index))) / 2; + } + protected int getChildOffset(int index) { if (getChildCount() == 0) return 0; diff --git a/src/com/android/launcher2/SearchDropTargetBar.java b/src/com/android/launcher2/SearchDropTargetBar.java index 943bd00bd..4bfb40af2 100644 --- a/src/com/android/launcher2/SearchDropTargetBar.java +++ b/src/com/android/launcher2/SearchDropTargetBar.java @@ -62,7 +62,6 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D dragController.addDropTarget(mDeleteDropTarget); mInfoDropTarget.setLauncher(launcher); mDeleteDropTarget.setLauncher(launcher); - mDropTargetBar.setBackgroundColor(0x33000000); } @Override diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index ad00d4fe3..1e32ec0a1 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -74,8 +74,7 @@ import java.util.List; * interact with. A workspace is meant to be used with a fixed width only. */ public class Workspace extends SmoothPagedView - implements DropTarget, DragSource, DragScroller, View.OnTouchListener, - View.OnClickListener { + implements DropTarget, DragSource, DragScroller, View.OnTouchListener { @SuppressWarnings({"UnusedDeclaration"}) private static final String TAG = "Launcher.Workspace"; @@ -338,7 +337,6 @@ public class Workspace extends SmoothPagedView } CellLayout cl = ((CellLayout) child); cl.setOnInterceptTouchListener(this); - cl.setOnClickListener(this); cl.setClickable(true); cl.enableHardwareLayers(); } @@ -506,17 +504,6 @@ public class Workspace extends SmoothPagedView return (mIsSmall || mIsInUnshrinkAnimation); } - /** - * Handle a click event on a CellLayout. - */ - @Override - public void onClick(View cellLayout) { - // Only allow clicks on a CellLayout if it is shrunken and visible. - if ((mIsSmall || mIsInUnshrinkAnimation) && mShrinkState != ShrinkState.BOTTOM_HIDDEN) { - mLauncher.onWorkspaceClick((CellLayout) cellLayout); - } - } - protected void onWindowVisibilityChanged (int visibility) { mLauncher.onWindowVisibilityChanged(visibility); } @@ -945,11 +932,11 @@ public class Workspace extends SmoothPagedView mBackgroundFadeInAnimation.start(); } - private void hideBackgroundGradient() { + private void hideBackgroundGradient(float finalAlpha) { if (mBackground == null) return; if (mBackgroundFadeInAnimation != null) mBackgroundFadeInAnimation.cancel(); if (mBackgroundFadeOutAnimation != null) mBackgroundFadeOutAnimation.cancel(); - mBackgroundFadeOutAnimation = ValueAnimator.ofFloat(getBackgroundAlpha(), 0f); + mBackgroundFadeOutAnimation = ValueAnimator.ofFloat(getBackgroundAlpha(), finalAlpha); mBackgroundFadeOutAnimation.addUpdateListener(new AnimatorUpdateListener() { public void onAnimationUpdate(ValueAnimator animation) { setBackgroundAlpha(((Float) animation.getAnimatedValue()).floatValue()); @@ -1113,40 +1100,27 @@ public class Workspace extends SmoothPagedView @Override protected void dispatchDraw(Canvas canvas) { - if (mIsSmall || mIsInUnshrinkAnimation) { - // Draw all the workspaces if we're small - final int pageCount = getChildCount(); - final long drawingTime = getDrawingTime(); - for (int i = 0; i < pageCount; i++) { - final CellLayout page = (CellLayout) getChildAt(i); - if (page.getVisibility() == VISIBLE - && (page.getAlpha() != 0f || page.getBackgroundAlpha() != 0f)) { - drawChild(canvas, page, drawingTime); - } - } - } else { - super.dispatchDraw(canvas); - - if (mInScrollArea && !LauncherApplication.isScreenLarge()) { - final int width = getWidth(); - final int height = getHeight(); - final int pageHeight = getChildAt(0).getHeight(); - - // This determines the height of the glowing edge: 90% of the page height - final int padding = (int) ((height - pageHeight) * 0.5f + pageHeight * 0.1f); - - final CellLayout leftPage = (CellLayout) getChildAt(mCurrentPage - 1); - final CellLayout rightPage = (CellLayout) getChildAt(mCurrentPage + 1); - - if (leftPage != null && leftPage.getIsDragOverlapping()) { - final Drawable d = getResources().getDrawable(R.drawable.page_hover_left_holo); - d.setBounds(mScrollX, padding, mScrollX + d.getIntrinsicWidth(), height - padding); - d.draw(canvas); - } else if (rightPage != null && rightPage.getIsDragOverlapping()) { - final Drawable d = getResources().getDrawable(R.drawable.page_hover_right_holo); - d.setBounds(mScrollX + width - d.getIntrinsicWidth(), padding, mScrollX + width, height - padding); - d.draw(canvas); - } + super.dispatchDraw(canvas); + + if (mInScrollArea && !LauncherApplication.isScreenLarge()) { + final int width = getWidth(); + final int height = getHeight(); + final int pageHeight = getChildAt(0).getHeight(); + + // This determines the height of the glowing edge: 90% of the page height + final int padding = (int) ((height - pageHeight) * 0.5f + pageHeight * 0.1f); + + final CellLayout leftPage = (CellLayout) getChildAt(mCurrentPage - 1); + final CellLayout rightPage = (CellLayout) getChildAt(mCurrentPage + 1); + + if (leftPage != null && leftPage.getIsDragOverlapping()) { + final Drawable d = getResources().getDrawable(R.drawable.page_hover_left_holo); + d.setBounds(mScrollX, padding, mScrollX + d.getIntrinsicWidth(), height - padding); + d.draw(canvas); + } else if (rightPage != null && rightPage.getIsDragOverlapping()) { + final Drawable d = getResources().getDrawable(R.drawable.page_hover_right_holo); + d.setBounds(mScrollX + width - d.getIntrinsicWidth(), padding, mScrollX + width, height - padding); + d.draw(canvas); } } } @@ -1833,9 +1807,8 @@ public class Workspace extends SmoothPagedView } } - if (!springLoaded) { - hideBackgroundGradient(); - } + hideBackgroundGradient(springLoaded ? getResources().getInteger( + R.integer.config_appsCustomizeSpringLoadedBgAlpha) / 100f : 0f); } /** @@ -2034,9 +2007,19 @@ public class Workspace extends SmoothPagedView mDragViewVisualCenter = getDragViewVisualCenter(d.x, d.y, d.xOffset, d.yOffset, d.dragView, mDragViewVisualCenter); - final CellLayout.CellInfo dragCellInfo = mDragInfo; - final int spanX = dragCellInfo == null ? 1 : dragCellInfo.spanX; - final int spanY = dragCellInfo == null ? 1 : dragCellInfo.spanY; + int spanX = 1; + int spanY = 1; + View ignoreView = null; + if (mDragInfo != null) { + final CellLayout.CellInfo dragCellInfo = mDragInfo; + spanX = dragCellInfo.spanX; + spanY = dragCellInfo.spanY; + ignoreView = dragCellInfo.cell; + } else { + final ItemInfo dragInfo = (ItemInfo) d.dragInfo; + spanX = dragInfo.spanX; + spanY = dragInfo.spanY; + } mTargetCell = findNearestArea((int) mDragViewVisualCenter[0], (int) mDragViewVisualCenter[1], spanX, spanY, mDragTargetLayout, mTargetCell); @@ -2049,7 +2032,6 @@ public class Workspace extends SmoothPagedView return true; } - final View ignoreView = dragCellInfo == null ? null : dragCellInfo.cell; // Don't accept the drop if there's no room for the item if (!mDragTargetLayout.findCellForSpanIgnoring(null, spanX, spanY, ignoreView)) { @@ -2091,7 +2073,7 @@ public class Workspace extends SmoothPagedView } boolean createUserFolderIfNecessary(View newView, CellLayout target, - int[] targetCell, boolean external, DragView dragView) { + int[] targetCell, boolean external, DragView dragView, Runnable postAnimationRunnable) { View v = target.getChildAt(targetCell[0], targetCell[1]); boolean hasntMoved = mDragInfo != null && (mDragInfo.cellX == targetCell[0] && mDragInfo.cellY == targetCell[1]); @@ -2123,7 +2105,8 @@ public class Workspace extends SmoothPagedView sourceInfo.cellX = -1; sourceInfo.cellY = -1; - fi.performCreateAnimation(destInfo, v, sourceInfo, dragView, folderLocation); + fi.performCreateAnimation(destInfo, v, sourceInfo, dragView, folderLocation, + postAnimationRunnable); return true; } return false; @@ -2191,7 +2174,7 @@ public class Workspace extends SmoothPagedView boolean dropInscrollArea = mCurrentPage != screen; if (!dropInscrollArea && createUserFolderIfNecessary(cell, dropTargetLayout, - mTargetCell, false, d.dragView)) { + mTargetCell, false, d.dragView, null)) { return; } @@ -2369,8 +2352,7 @@ public class Workspace extends SmoothPagedView if (isShortcut) { // Check if we have enough space on this screen to add a new shortcut if (!layout.findCellForSpan(pos, 1, 1)) { - Toast.makeText(mContext, mContext.getString(R.string.out_of_space), - Toast.LENGTH_SHORT).show(); + mLauncher.showOutOfSpaceMessage(); return false; } } @@ -2809,27 +2791,38 @@ public class Workspace extends SmoothPagedView * NOTE: This can also be called when we are outside of a drag event, when we want * to add an item to one of the workspace screens. */ - private void onDropExternal(int[] touchXY, Object dragInfo, - CellLayout cellLayout, boolean insertAtFirst, DragObject d) { - int screen = indexOfChild(cellLayout); + private void onDropExternal(final int[] touchXY, final Object dragInfo, + final CellLayout cellLayout, boolean insertAtFirst, DragObject d) { + final Runnable exitSpringLoadedRunnable = new Runnable() { + @Override + public void run() { + mLauncher.exitSpringLoadedDragModeDelayed(false); + } + }; + final int screen = indexOfChild(cellLayout); if (screen != mCurrentPage && mShrinkState != ShrinkState.SPRING_LOADED) { snapToPage(screen); } if (dragInfo instanceof PendingAddItemInfo) { - PendingAddItemInfo info = (PendingAddItemInfo) dragInfo; - // When dragging and dropping from customization tray, we deal with creating - // widgets/shortcuts/folders in a slightly different way - switch (info.itemType) { - case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET: - mLauncher.addAppWidgetFromDrop((PendingAddWidgetInfo) info, screen, touchXY); - break; - case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT: - mLauncher.processShortcutFromDrop(info.componentName, screen, touchXY); - break; - default: - throw new IllegalStateException("Unknown item type: " + info.itemType); - } - cellLayout.onDragExit(); + final PendingAddItemInfo info = (PendingAddItemInfo) dragInfo; + mLauncher.getDragLayer().animateViewOut(d.dragView, new Runnable() { + @Override + public void run() { + // When dragging and dropping from customization tray, we deal with creating + // widgets/shortcuts/folders in a slightly different way + switch (info.itemType) { + case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET: + mLauncher.addAppWidgetFromDrop((PendingAddWidgetInfo) info, screen, touchXY); + break; + case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT: + mLauncher.processShortcutFromDrop(info.componentName, screen, touchXY); + break; + default: + throw new IllegalStateException("Unknown item type: " + info.itemType); + } + cellLayout.onDragExit(); + } + }); } else { // This is for other drag/drop cases, like dragging from All Apps ItemInfo info = (ItemInfo) dragInfo; @@ -2853,14 +2846,24 @@ public class Workspace extends SmoothPagedView throw new IllegalStateException("Unknown item type: " + info.itemType); } - int spanX = mDragInfo != null ? mDragInfo.spanX : 1; - int spanY = mDragInfo != null ? mDragInfo.spanY : 1; + int spanX = 1; + int spanY = 1; + if (mDragInfo != null) { + spanX = mDragInfo.spanX; + spanY = mDragInfo.spanY; + } else { + spanX = info.spanX; + spanY = info.spanY; + } + // First we find the cell nearest to point at which the item is // dropped, without any consideration to whether there is an item there. if (touchXY != null) { mTargetCell = findNearestArea((int) touchXY[0], (int) touchXY[1], spanX, spanY, cellLayout, mTargetCell); - if (createUserFolderIfNecessary(view, cellLayout, mTargetCell, true, d.dragView)) { + d.postAnimationRunnable = exitSpringLoadedRunnable; + if (createUserFolderIfNecessary(view, cellLayout, mTargetCell, true, d.dragView, + d.postAnimationRunnable)) { return; } if (addToExistingFolderIfNecessary(view, cellLayout, mTargetCell, d, true)) { @@ -2887,7 +2890,8 @@ public class Workspace extends SmoothPagedView lp.cellX, lp.cellY); if (d.dragView != null) { - mLauncher.getDragLayer().animateViewIntoPosition(d.dragView, view); + mLauncher.getDragLayer().animateViewIntoPosition(d.dragView, view, + exitSpringLoadedRunnable); } } } |