Merge "Don't crash if global search specified bad toolbar icon."
diff --git a/res/drawable-hdpi/default_widget_preview.9.png b/res/drawable-hdpi/default_widget_preview.9.png
deleted file mode 100644
index 833daff..0000000
--- a/res/drawable-hdpi/default_widget_preview.9.png
+++ /dev/null
Binary files differ
diff --git a/res/layout/apps_customize_application.xml b/res/layout-land/apps_customize_application.xml
similarity index 95%
copy from res/layout/apps_customize_application.xml
copy to res/layout-land/apps_customize_application.xml
index 37a8df7..bface6b 100644
--- a/res/layout/apps_customize_application.xml
+++ b/res/layout-land/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.Landscape.AppsCustomize"
android:id="@+id/application_icon"
android:layout_width="match_parent"
diff --git a/res/layout-land/launcher.xml b/res/layout-land/launcher.xml
index c120de8..4aa4870 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 ccd7d33..0000000
--- 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/tab_widget_indicator.xml b/res/layout-large/tab_widget_indicator.xml
deleted file mode 100644
index c09c853..0000000
--- a/res/layout-large/tab_widget_indicator.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 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.
--->
-
-<com.android.launcher2.AccessibleTabView
- xmlns:android="http://schemas.android.com/apk/res/android"
- style="@style/TabIndicator.Wide" />
diff --git a/res/layout-large-land/workspace.xml b/res/layout-large/workspace.xml
similarity index 95%
rename from res/layout-large-land/workspace.xml
rename to res/layout-large/workspace.xml
index e8ea782..abed5a8 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
similarity index 95%
rename from res/layout/apps_customize_application.xml
rename to res/layout-port/apps_customize_application.xml
index 37a8df7..37b4185 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 db074d7..73051ba 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 00c87cb..adb0a6d 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 b3694fe..df43d3d 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 278da54..463cd17 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 659947b..e8d767c 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 ee4c70b..d14a8df 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 c1525ea..e0651b2 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 7da10db..59aaa41 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 25b8195..bd4efe7 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 945699b..c5fdd68 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 31db0b3..4f53280 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 497011c..fca0acc 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>
@@ -45,7 +47,7 @@
<!-- Workspace -->
<!-- The transition duration for the background of the drop targets -->
- <integer name="config_dropTargetBgTransitionDuration">200</integer>
+ <integer name="config_dropTargetBgTransitionDuration">100</integer>
<integer name="config_crosshairsFadeInTime">600</integer>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 7353eda..c04dd8e 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 06f6ed0..46e5f95 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/AllAppsList.java b/src/com/android/launcher2/AllAppsList.java
index 4c9bc5e..051b0bd 100644
--- a/src/com/android/launcher2/AllAppsList.java
+++ b/src/com/android/launcher2/AllAppsList.java
@@ -91,7 +91,7 @@
if (matches.size() > 0) {
for (ResolveInfo info : matches) {
- add(new ApplicationInfo(context.getPackageManager(), info, mIconCache));
+ add(new ApplicationInfo(context.getPackageManager(), info, mIconCache, null));
}
}
}
@@ -142,10 +142,10 @@
info.activityInfo.applicationInfo.packageName,
info.activityInfo.name);
if (applicationInfo == null) {
- add(new ApplicationInfo(context.getPackageManager(), info, mIconCache));
+ add(new ApplicationInfo(context.getPackageManager(), info, mIconCache, null));
} else {
mIconCache.remove(applicationInfo.componentName);
- mIconCache.getTitleAndIcon(applicationInfo, info);
+ mIconCache.getTitleAndIcon(applicationInfo, info, null);
modified.add(applicationInfo);
}
}
diff --git a/src/com/android/launcher2/ApplicationInfo.java b/src/com/android/launcher2/ApplicationInfo.java
index 1d948b7..1fc1d1f 100644
--- a/src/com/android/launcher2/ApplicationInfo.java
+++ b/src/com/android/launcher2/ApplicationInfo.java
@@ -19,12 +19,13 @@
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.pm.ResolveInfo;
import android.graphics.Bitmap;
import android.util.Log;
import java.util.ArrayList;
+import java.util.HashMap;
/**
* Represents an app in AllAppsView.
@@ -38,11 +39,6 @@
CharSequence title;
/**
- * A bitmap of the application's text in the bubble.
- */
- Bitmap titleBitmap;
-
- /**
* The intent used to start the application.
*/
Intent intent;
@@ -71,7 +67,8 @@
/**
* Must not hold the Context.
*/
- public ApplicationInfo(PackageManager pm, ResolveInfo info, IconCache iconCache) {
+ public ApplicationInfo(PackageManager pm, ResolveInfo info, IconCache iconCache,
+ HashMap<Object, CharSequence> labelCache) {
final String packageName = info.activityInfo.applicationInfo.packageName;
this.componentName = new ComponentName(packageName, info.activityInfo.name);
@@ -93,9 +90,9 @@
Log.d(TAG, "PackageManager.getApplicationInfo failed for " + packageName);
}
- iconCache.getTitleAndIcon(this, info);
+ iconCache.getTitleAndIcon(this, info, labelCache);
}
-
+
public ApplicationInfo(ApplicationInfo info) {
super(info);
componentName = info.componentName;
@@ -129,8 +126,8 @@
ArrayList<ApplicationInfo> list) {
Log.d(tag, label + " size=" + list.size());
for (ApplicationInfo info: list) {
- Log.d(tag, " title=\"" + info.title + "\" titleBitmap=" + info.titleBitmap
- + " iconBitmap=" + info.iconBitmap + " firstInstallTime="
+ Log.d(tag, " title=\"" + info.title + "\" iconBitmap="
+ + info.iconBitmap + " firstInstallTime="
+ info.firstInstallTime);
}
}
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index 33472ea..12fe971 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -472,9 +472,13 @@
}
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 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.
@@ -829,19 +833,25 @@
// Generate a preview image if we couldn't load one
if (drawable == null) {
Resources resources = mLauncher.getResources();
+ int bitmapWidth;
+ int bitmapHeight;
- // Specify the dimensions of the bitmap
- if (info.minWidth >= info.minHeight) {
- expectedWidth = cellWidth;
- expectedHeight = mWidgetPreviewIconPaddedDimension;
+ // Specify the dimensions of the bitmap (since we are using a default preview bg with
+ // the full icon, we only imply the aspect ratio of the widget)
+ if (cellHSpan == cellVSpan) {
+ bitmapWidth = bitmapHeight = cellWidth;
+ expectedWidth = expectedHeight = mWidgetPreviewIconPaddedDimension;
+ } else if (cellHSpan >= cellVSpan) {
+ bitmapWidth = expectedWidth = cellWidth;
+ bitmapHeight = expectedHeight = mWidgetPreviewIconPaddedDimension;
} else {
// Note that in vertical widgets, we might not have enough space due to the text
// label, so be conservative and use the width as a height bound
- expectedWidth = mWidgetPreviewIconPaddedDimension;
- expectedHeight = cellWidth;
+ bitmapWidth = expectedWidth = mWidgetPreviewIconPaddedDimension;
+ bitmapHeight = expectedHeight = cellWidth;
}
- preview = Bitmap.createBitmap(expectedWidth, expectedHeight, Config.ARGB_8888);
+ preview = Bitmap.createBitmap(bitmapWidth, bitmapHeight, Config.ARGB_8888);
renderDrawableToBitmap(mDefaultWidgetBackground, preview, 0, 0, expectedWidth,
expectedHeight, 1f,1f);
diff --git a/src/com/android/launcher2/DeleteDropTarget.java b/src/com/android/launcher2/DeleteDropTarget.java
index afa2654..c8c6faa 100644
--- a/src/com/android/launcher2/DeleteDropTarget.java
+++ b/src/com/android/launcher2/DeleteDropTarget.java
@@ -113,6 +113,7 @@
}
mActive = isVisible;
+ mDrawable.resetTransition();
setVisibility(isVisible ? View.VISIBLE : View.GONE);
if (mText.getText().length() > 0) {
mText.setText(isUninstall ? R.string.delete_target_uninstall_label
@@ -135,7 +136,9 @@
public void onDragExit(DragObject d) {
super.onDragExit(d);
- mDrawable.resetTransition();
+ if (!d.dragComplete) {
+ mDrawable.resetTransition();
+ }
}
public void onDrop(DragObject d) {
diff --git a/src/com/android/launcher2/DragController.java b/src/com/android/launcher2/DragController.java
index f6058a0..5aecede 100644
--- a/src/com/android/launcher2/DragController.java
+++ b/src/com/android/launcher2/DragController.java
@@ -110,6 +110,9 @@
private int mLastTouch[] = new int[2];
private int mDistanceSinceScroll = 0;
+ private int mTmpPoint[] = new int[2];
+ private Rect mDragLayerRect = new Rect();
+
/**
* Interface to receive notifications when a drag starts or stops
*/
@@ -385,6 +388,16 @@
}
/**
+ * Clamps the position to the drag layer bounds.
+ */
+ private int[] getClampedDragLayerPos(float x, float y) {
+ mLauncher.getDragLayer().getLocalVisibleRect(mDragLayerRect);
+ mTmpPoint[0] = (int) Math.max(mDragLayerRect.left, Math.min(x, mDragLayerRect.right - 1));
+ mTmpPoint[1] = (int) Math.max(mDragLayerRect.top, Math.min(y, mDragLayerRect.bottom - 1));
+ return mTmpPoint;
+ }
+
+ /**
* Call this from a drag source view.
*/
public boolean onInterceptTouchEvent(MotionEvent ev) {
@@ -394,8 +407,9 @@
}
final int action = ev.getAction();
- final int dragLayerX = (int) ev.getX();
- final int dragLayerY = (int) ev.getY();
+ final int[] dragLayerPos = getClampedDragLayerPos(ev.getX(), ev.getY());
+ final int dragLayerX = dragLayerPos[0];
+ final int dragLayerY = dragLayerPos[1];
switch (action) {
case MotionEvent.ACTION_MOVE:
@@ -506,8 +520,9 @@
}
final int action = ev.getAction();
- final int dragLayerX = (int) ev.getX();
- final int dragLayerY = (int) ev.getY();
+ final int[] dragLayerPos = getClampedDragLayerPos(ev.getX(), ev.getY());
+ final int dragLayerX = dragLayerPos[0];
+ final int dragLayerY = dragLayerPos[1];
switch (action) {
case MotionEvent.ACTION_DOWN:
diff --git a/src/com/android/launcher2/DragLayer.java b/src/com/android/launcher2/DragLayer.java
index dfd8160..0bdfec1 100644
--- a/src/com/android/launcher2/DragLayer.java
+++ b/src/com/android/launcher2/DragLayer.java
@@ -175,16 +175,25 @@
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 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 @@
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 @@
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 0712420..34fa893 100644
--- a/src/com/android/launcher2/DropTarget.java
+++ b/src/com/android/launcher2/DropTarget.java
@@ -49,6 +49,9 @@
/** 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/Folder.java b/src/com/android/launcher2/Folder.java
index 8a1b957..78df80f 100644
--- a/src/com/android/launcher2/Folder.java
+++ b/src/com/android/launcher2/Folder.java
@@ -54,14 +54,12 @@
public class Folder extends LinearLayout implements DragSource, View.OnClickListener,
View.OnLongClickListener, DropTarget, FolderListener, TextView.OnEditorActionListener {
- protected DragController mDragController;
-
- protected Launcher mLauncher;
-
- protected FolderInfo mInfo;
-
private static final String TAG = "Launcher.Folder";
+ protected DragController mDragController;
+ protected Launcher mLauncher;
+ protected FolderInfo mInfo;
+
static final int STATE_NONE = -1;
static final int STATE_SMALL = 0;
static final int STATE_ANIMATING = 1;
@@ -132,6 +130,8 @@
if (sHintText == null) {
sHintText = res.getString(R.string.folder_hint_text);
}
+
+ mLauncher = (Launcher) context;
}
@Override
@@ -286,10 +286,6 @@
mDragController = dragController;
}
- void setLauncher(Launcher launcher) {
- mLauncher = launcher;
- }
-
void setFolderIcon(FolderIcon icon) {
mFolderIcon = icon;
}
@@ -888,6 +884,7 @@
si.cellX = lp.cellY = mEmptyCell[1];
mContent.addViewToCellLayout(mCurrentDragView, -1, (int)item.id, lp, true);
mLauncher.getDragLayer().animateViewIntoPosition(d.dragView, mCurrentDragView);
+ mItemsInvalidated = true;
setupContentDimension(getItemCount());
mSuppressOnAdd = true;
}
diff --git a/src/com/android/launcher2/FolderIcon.java b/src/com/android/launcher2/FolderIcon.java
index 4978e98..952916d 100644
--- a/src/com/android/launcher2/FolderIcon.java
+++ b/src/com/android/launcher2/FolderIcon.java
@@ -127,7 +127,6 @@
Folder folder = Folder.fromXml(launcher);
folder.setDragController(launcher.getDragController());
- folder.setLauncher(launcher);
folder.setFolderIcon(icon);
folder.bind(folderInfo);
icon.mFolder = folder;
@@ -286,12 +285,13 @@
}
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 +309,8 @@
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 +333,8 @@
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 +350,7 @@
} 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/FolderInfo.java b/src/com/android/launcher2/FolderInfo.java
index b5b5b29..3ae31d2 100644
--- a/src/com/android/launcher2/FolderInfo.java
+++ b/src/com/android/launcher2/FolderInfo.java
@@ -99,6 +99,12 @@
}
}
+ @Override
+ void unbind() {
+ super.unbind();
+ listeners.clear();
+ }
+
interface FolderListener {
public void onAdd(ShortcutInfo item);
public void onRemove(ShortcutInfo item);
diff --git a/src/com/android/launcher2/IconCache.java b/src/com/android/launcher2/IconCache.java
index 22691a5..2977383 100644
--- a/src/com/android/launcher2/IconCache.java
+++ b/src/com/android/launcher2/IconCache.java
@@ -40,7 +40,6 @@
private static class CacheEntry {
public Bitmap icon;
public String title;
- public Bitmap titleBitmap;
}
private final Bitmap mDefaultIcon;
@@ -126,15 +125,12 @@
/**
* Fill in "application" with the icon and label for "info."
*/
- public void getTitleAndIcon(ApplicationInfo application, ResolveInfo info) {
+ public void getTitleAndIcon(ApplicationInfo application, ResolveInfo info,
+ HashMap<Object, CharSequence> labelCache) {
synchronized (mCache) {
- CacheEntry entry = cacheLocked(application.componentName, info);
- if (entry.titleBitmap == null) {
- entry.titleBitmap = mBubble.createTextBitmap(entry.title);
- }
+ CacheEntry entry = cacheLocked(application.componentName, info, labelCache);
application.title = entry.title;
- application.titleBitmap = entry.titleBitmap;
application.iconBitmap = entry.icon;
}
}
@@ -148,7 +144,7 @@
return mDefaultIcon;
}
- CacheEntry entry = cacheLocked(component, resolveInfo);
+ CacheEntry entry = cacheLocked(component, resolveInfo, null);
return entry.icon;
}
}
@@ -159,7 +155,7 @@
return null;
}
- CacheEntry entry = cacheLocked(component, resolveInfo);
+ CacheEntry entry = cacheLocked(component, resolveInfo, null);
return entry.icon;
}
}
@@ -168,14 +164,22 @@
return mDefaultIcon == icon;
}
- private CacheEntry cacheLocked(ComponentName componentName, ResolveInfo info) {
+ private CacheEntry cacheLocked(ComponentName componentName, ResolveInfo info,
+ HashMap<Object, CharSequence> labelCache) {
CacheEntry entry = mCache.get(componentName);
if (entry == null) {
entry = new CacheEntry();
mCache.put(componentName, entry);
- entry.title = info.loadLabel(mPackageManager).toString();
+ if (labelCache != null && labelCache.containsKey(info)) {
+ entry.title = labelCache.get(info).toString();
+ } else {
+ entry.title = info.loadLabel(mPackageManager).toString();
+ if (labelCache != null) {
+ labelCache.put(info, entry.title);
+ }
+ }
if (entry.title == null) {
entry.title = info.activityInfo.name;
}
diff --git a/src/com/android/launcher2/InfoDropTarget.java b/src/com/android/launcher2/InfoDropTarget.java
index c7812e3..02e3f01 100644
--- a/src/com/android/launcher2/InfoDropTarget.java
+++ b/src/com/android/launcher2/InfoDropTarget.java
@@ -97,6 +97,7 @@
}
mActive = isVisible;
+ mDrawable.resetTransition();
setVisibility(isVisible ? View.VISIBLE : View.GONE);
}
@@ -115,6 +116,8 @@
public void onDragExit(DragObject d) {
super.onDragExit(d);
- mDrawable.resetTransition();
+ if (!d.dragComplete) {
+ mDrawable.resetTransition();
+ }
}
}
diff --git a/src/com/android/launcher2/ItemInfo.java b/src/com/android/launcher2/ItemInfo.java
index 3a1c29a..8d46624 100644
--- a/src/com/android/launcher2/ItemInfo.java
+++ b/src/com/android/launcher2/ItemInfo.java
@@ -144,7 +144,13 @@
values.put(LauncherSettings.Favorites.ICON, data);
}
}
-
+
+ /**
+ * It is very important that sub-classes implement this if they contain any references
+ * to the activity (anything in the view hierarchy etc.). If not, leaks can result since
+ * ItemInfo objects persist across rotation and can hence leak by holding stale references
+ * to the old view hierarchy / activity.
+ */
void unbind() {
}
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index c06a2ee..4e69ee8 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -167,6 +167,8 @@
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;
@@ -219,8 +221,6 @@
private static LocaleConfiguration sLocaleConfiguration = null;
- private ArrayList<ItemInfo> mDesktopItems = new ArrayList<ItemInfo>();
-
private static HashMap<Long, FolderInfo> sFolders = new HashMap<Long, FolderInfo>();
// Hotseats (quick-launch icons next to AllApps)
@@ -592,7 +592,11 @@
}
}
- 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 +606,24 @@
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 +644,21 @@
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
@@ -1086,8 +1096,6 @@
screen, cellXY[0], cellXY[1], false);
if (!mRestoring) {
- mDesktopItems.add(launcherInfo);
-
// Perform actual inflation because we're live
launcherInfo.hostView = mAppWidgetHost.createView(this, appWidgetId, appWidgetInfo);
@@ -1216,7 +1224,6 @@
}
public void removeAppWidget(LauncherAppWidgetInfo launcherInfo) {
- mDesktopItems.remove(launcherInfo);
removeWidgetToAutoAdvance(launcherInfo.hostView);
launcherInfo.hostView = null;
}
@@ -1302,6 +1309,9 @@
super.onSaveInstanceState(outState);
outState.putInt(RUNTIME_STATE, mState.ordinal());
+ // We close any open folder since it will not be re-opened, and we need to make sure
+ // this state is reflected.
+ closeFolder();
if (mAddScreen > -1 && mWaitingForResult) {
outState.putInt(RUNTIME_STATE_PENDING_ADD_SCREEN, mAddScreen);
@@ -1344,7 +1354,7 @@
TextKeyListener.getInstance().release();
- unbindDesktopItems();
+ unbindWorkspaceItems();
getContentResolver().unregisterContentObserver(mWidgetObserver);
unregisterReceiver(mCloseSystemDialogsReceiver);
@@ -1549,6 +1559,9 @@
} else {
// Otherwise just add it
completeAddAppWidget(appWidgetId, mAddScreen);
+
+ // Exit spring loaded mode if necessary after adding the widget
+ exitSpringLoadedDragModeDelayed(false);
}
}
@@ -1725,11 +1738,8 @@
* Go through the and disconnect any of the callbacks in the drawables and the views or we
* leak the previous Home screen on orientation change.
*/
- private void unbindDesktopItems() {
- for (ItemInfo item: mDesktopItems) {
- item.unbind();
- }
- mDesktopItems.clear();
+ private void unbindWorkspaceItems() {
+ LauncherModel.unbindWorkspaceItems();
}
/**
@@ -2541,7 +2551,16 @@
}
// 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 +2692,6 @@
}
}
- void onWorkspaceClick(CellLayout layout) {
- showWorkspace(true, layout);
- }
-
private Drawable getExternalPackageToolbarIcon(ComponentName activityName) {
try {
PackageManager packageManager = getPackageManager();
@@ -2997,9 +3012,8 @@
});
}
- // This wasn't being called before which resulted in a leak of AppWidgetHostViews (through
- // mDesktopItems -> AppWidgetInfo -> hostView).
- unbindDesktopItems();
+ // This wasn't being called before which resulted in a leak of AppWidgetHostViews
+ unbindWorkspaceItems();
}
/**
@@ -3015,7 +3029,6 @@
for (int i=start; i<end; i++) {
final ItemInfo item = shortcuts.get(i);
- mDesktopItems.add(item);
switch (item.itemType) {
case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:
case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:
@@ -3077,8 +3090,6 @@
workspace.requestLayout();
- mDesktopItems.add(item);
-
if (DEBUG_WIDGETS) {
Log.d(TAG, "bound widget id="+item.appWidgetId+" in "
+ (SystemClock.uptimeMillis()-start) + "ms");
@@ -3250,7 +3261,6 @@
Log.d(TAG, "mRestoring=" + mRestoring);
Log.d(TAG, "mWaitingForResult=" + mWaitingForResult);
Log.d(TAG, "mSavedInstanceState=" + mSavedInstanceState);
- Log.d(TAG, "mDesktopItems.size=" + mDesktopItems.size());
Log.d(TAG, "sFolders.size=" + sFolders.size());
mModel.dumpState();
diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java
index 64b38c0..c19ac4a 100644
--- a/src/com/android/launcher2/LauncherModel.java
+++ b/src/com/android/launcher2/LauncherModel.java
@@ -98,7 +98,7 @@
// sItems is passed to bindItems, which expects a list of all folders and shortcuts created by
// LauncherModel that are directly on the home screen (however, no widgets or shortcuts
// within folders).
- static final ArrayList<ItemInfo> sItems = new ArrayList<ItemInfo>();
+ static final ArrayList<ItemInfo> sWorkspaceItems = new ArrayList<ItemInfo>();
// sAppWidgets is all LauncherAppWidgetInfo created by LauncherModel. Passed to bindAppWidget()
static final ArrayList<LauncherAppWidgetInfo> sAppWidgets =
@@ -148,6 +148,12 @@
return Bitmap.createBitmap(mDefaultIcon);
}
+ public static void unbindWorkspaceItems() {
+ for (ItemInfo item: sWorkspaceItems) {
+ item.unbind();
+ }
+ }
+
/**
* Adds an item to the DB if it was not created previously, or move it to a new
* <container, screen, cellX, cellY>
@@ -197,11 +203,11 @@
// as in Workspace.onDrop. Here, we just add/remove them from the list of items
// that are on the desktop, as appropriate
if (modelItem.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
- if (!sItems.contains(modelItem)) {
- sItems.add(modelItem);
+ if (!sWorkspaceItems.contains(modelItem)) {
+ sWorkspaceItems.add(modelItem);
}
} else {
- sItems.remove(modelItem);
+ sWorkspaceItems.remove(modelItem);
}
}
});
@@ -374,13 +380,13 @@
case LauncherSettings.Favorites.ITEM_TYPE_FOLDER:
sFolders.put(item.id, (FolderInfo) item);
if (item.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
- sItems.add(item);
+ sWorkspaceItems.add(item);
}
break;
case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:
case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:
if (item.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
- sItems.add(item);
+ sWorkspaceItems.add(item);
}
break;
case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET:
@@ -456,11 +462,11 @@
switch (item.itemType) {
case LauncherSettings.Favorites.ITEM_TYPE_FOLDER:
sFolders.remove(item.id);
- sItems.remove(item);
+ sWorkspaceItems.remove(item);
break;
case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:
case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:
- sItems.remove(item);
+ sWorkspaceItems.remove(item);
break;
case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET:
sAppWidgets.remove((LauncherAppWidgetInfo) item);
@@ -482,7 +488,7 @@
cr.delete(LauncherSettings.Favorites.getContentUri(info.id, false), null, null);
sItemsIdMap.remove(info.id);
sFolders.remove(info.id);
- sItems.remove(info);
+ sWorkspaceItems.remove(info);
cr.delete(LauncherSettings.Favorites.CONTENT_URI,
LauncherSettings.Favorites.CONTAINER + "=" + info.id, null);
@@ -630,10 +636,12 @@
private boolean mIsLaunching;
private boolean mStopped;
private boolean mLoadAndBindStepFinished;
+ private HashMap<Object, CharSequence> mLabelCache;
LoaderTask(Context context, boolean isLaunching) {
mContext = context;
mIsLaunching = isLaunching;
+ mLabelCache = new HashMap<Object, CharSequence>();
}
boolean isLaunching() {
@@ -819,7 +827,7 @@
final AppWidgetManager widgets = AppWidgetManager.getInstance(context);
final boolean isSafeMode = manager.isSafeMode();
- sItems.clear();
+ sWorkspaceItems.clear();
sAppWidgets.clear();
sFolders.clear();
sItemsIdMap.clear();
@@ -888,7 +896,7 @@
if (itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {
info = getShortcutInfo(manager, intent, context, c, iconIndex,
- titleIndex);
+ titleIndex, mLabelCache);
} else {
info = getShortcutInfo(c, context, iconTypeIndex,
iconPackageIndex, iconResourceIndex, iconIndex,
@@ -911,7 +919,7 @@
switch (container) {
case LauncherSettings.Favorites.CONTAINER_DESKTOP:
- sItems.add(info);
+ sWorkspaceItems.add(info);
break;
default:
// Item is in a user folder
@@ -955,7 +963,7 @@
}
switch (container) {
case LauncherSettings.Favorites.CONTAINER_DESKTOP:
- sItems.add(folderInfo);
+ sWorkspaceItems.add(folderInfo);
break;
}
@@ -1072,7 +1080,7 @@
}
});
// Add the items to the workspace.
- N = sItems.size();
+ N = sWorkspaceItems.size();
for (int i=0; i<N; i+=ITEMS_CHUNK) {
final int start = i;
final int chunkSize = (i+ITEMS_CHUNK <= N) ? ITEMS_CHUNK : (N-i);
@@ -1080,7 +1088,7 @@
public void run() {
Callbacks callbacks = tryGetCallbacks(oldCallbacks);
if (callbacks != null) {
- callbacks.bindItems(sItems, start, start+chunkSize);
+ callbacks.bindItems(sWorkspaceItems, start, start+chunkSize);
}
}
});
@@ -1249,7 +1257,7 @@
final long sortTime = DEBUG_LOADERS ? SystemClock.uptimeMillis() : 0;
Collections.sort(apps,
- new ResolveInfo.DisplayNameComparator(packageManager));
+ new LauncherModel.ShortcutNameComparator(packageManager, mLabelCache));
if (DEBUG_LOADERS) {
Log.d(TAG, "sort took "
+ (SystemClock.uptimeMillis()-sortTime) + "ms");
@@ -1261,7 +1269,8 @@
startIndex = i;
for (int j=0; i<N && j<batchSize; j++) {
// This builds the icon bitmaps.
- mAllAppsList.add(new ApplicationInfo(packageManager, apps.get(i), mIconCache));
+ mAllAppsList.add(new ApplicationInfo(packageManager, apps.get(i),
+ mIconCache, mLabelCache));
i++;
}
@@ -1317,7 +1326,7 @@
Log.d(TAG, "mLoaderTask.mIsLaunching=" + mIsLaunching);
Log.d(TAG, "mLoaderTask.mStopped=" + mStopped);
Log.d(TAG, "mLoaderTask.mLoadAndBindStepFinished=" + mLoadAndBindStepFinished);
- Log.d(TAG, "mItems size=" + sItems.size());
+ Log.d(TAG, "mItems size=" + sWorkspaceItems.size());
}
}
@@ -1446,7 +1455,7 @@
* doesn't have a Cursor, but
*/
public ShortcutInfo getShortcutInfo(PackageManager manager, Intent intent, Context context) {
- return getShortcutInfo(manager, intent, context, null, -1, -1);
+ return getShortcutInfo(manager, intent, context, null, -1, -1, null);
}
/**
@@ -1455,7 +1464,7 @@
* If c is not null, then it will be used to fill in missing data like the title and icon.
*/
public ShortcutInfo getShortcutInfo(PackageManager manager, Intent intent, Context context,
- Cursor c, int iconIndex, int titleIndex) {
+ Cursor c, int iconIndex, int titleIndex, HashMap<Object, CharSequence> labelCache) {
Bitmap icon = null;
final ShortcutInfo info = new ShortcutInfo();
@@ -1490,7 +1499,14 @@
// from the resource
if (resolveInfo != null) {
- info.title = resolveInfo.activityInfo.loadLabel(manager);
+ if (labelCache != null && labelCache.containsKey(resolveInfo)) {
+ info.title = labelCache.get(resolveInfo);
+ } else {
+ info.title = resolveInfo.activityInfo.loadLabel(manager);
+ if (labelCache != null) {
+ labelCache.put(resolveInfo, info.title);
+ }
+ }
}
// from the db
if (info.title == null) {
@@ -1766,17 +1782,31 @@
};
public static class ShortcutNameComparator implements Comparator<ResolveInfo> {
private PackageManager mPackageManager;
- private HashMap<Object, String> mLabelCache;
+ private HashMap<Object, CharSequence> mLabelCache;
ShortcutNameComparator(PackageManager pm) {
mPackageManager = pm;
- mLabelCache = new HashMap<Object, String>();
+ mLabelCache = new HashMap<Object, CharSequence>();
+ }
+ ShortcutNameComparator(PackageManager pm, HashMap<Object, CharSequence> labelCache) {
+ mPackageManager = pm;
+ mLabelCache = labelCache;
}
public final int compare(ResolveInfo a, ResolveInfo b) {
- String labelA, labelB;
- if (mLabelCache.containsKey(a)) labelA = mLabelCache.get(a);
- else labelA = a.loadLabel(mPackageManager).toString();
- if (mLabelCache.containsKey(b)) labelB = mLabelCache.get(b);
- else labelB = b.loadLabel(mPackageManager).toString();
+ CharSequence labelA, labelB;
+ if (mLabelCache.containsKey(a)) {
+ labelA = mLabelCache.get(a);
+ } else {
+ labelA = a.loadLabel(mPackageManager).toString();
+
+ mLabelCache.put(a, labelA);
+ }
+ if (mLabelCache.containsKey(b)) {
+ labelB = mLabelCache.get(b);
+ } else {
+ labelB = b.loadLabel(mPackageManager).toString();
+
+ mLabelCache.put(b, labelB);
+ }
return sCollator.compare(labelA, labelB);
}
};
@@ -1789,14 +1819,22 @@
}
public final int compare(Object a, Object b) {
String labelA, labelB;
- if (mLabelCache.containsKey(a)) labelA = mLabelCache.get(a);
- else labelA = (a instanceof AppWidgetProviderInfo) ?
+ if (mLabelCache.containsKey(a)) {
+ labelA = mLabelCache.get(a);
+ } else {
+ labelA = (a instanceof AppWidgetProviderInfo) ?
((AppWidgetProviderInfo) a).label :
((ResolveInfo) a).loadLabel(mPackageManager).toString();
- if (mLabelCache.containsKey(b)) labelB = mLabelCache.get(b);
- else labelB = (b instanceof AppWidgetProviderInfo) ?
+ mLabelCache.put(a, labelA);
+ }
+ if (mLabelCache.containsKey(b)) {
+ labelB = mLabelCache.get(b);
+ } else {
+ labelB = (b instanceof AppWidgetProviderInfo) ?
((AppWidgetProviderInfo) b).label :
((ResolveInfo) b).loadLabel(mPackageManager).toString();
+ mLabelCache.put(b, labelB);
+ }
return sCollator.compare(labelA, labelB);
}
};
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index 81e876f..8c74c42 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -368,8 +368,11 @@
// 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 @@
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 @@
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/PagedViewIcon.java b/src/com/android/launcher2/PagedViewIcon.java
index a48a4ef..3ae978d 100644
--- a/src/com/android/launcher2/PagedViewIcon.java
+++ b/src/com/android/launcher2/PagedViewIcon.java
@@ -103,16 +103,6 @@
setTag(info);
}
- public void applyFromResolveInfo(ResolveInfo info, PackageManager packageManager,
- IconCache modelIconCache, HolographicOutlineHelper holoOutlineHelper) {
- mHolographicOutlineHelper = holoOutlineHelper;
- ComponentName cn = new ComponentName(info.activityInfo.packageName, info.activityInfo.name);
- mIcon = modelIconCache.getIcon(cn, info);
- setCompoundDrawablesWithIntrinsicBounds(null, new FastBitmapDrawable(mIcon), null, null);
- setText(info.loadLabel(packageManager));
- setTag(info);
- }
-
public void setHolographicOutline(Bitmap holoOutline) {
mHolographicOutline = holoOutline;
getHolographicOutlineView().invalidate();
@@ -120,8 +110,8 @@
@Override
public void setAlpha(float alpha) {
- final float viewAlpha = mHolographicOutlineHelper.viewAlphaInterpolator(alpha);
- final float holographicAlpha = mHolographicOutlineHelper.highlightAlphaInterpolator(alpha);
+ final float viewAlpha = HolographicOutlineHelper.viewAlphaInterpolator(alpha);
+ final float holographicAlpha = HolographicOutlineHelper.highlightAlphaInterpolator(alpha);
int newViewAlpha = (int) (viewAlpha * 255);
int newHolographicAlpha = (int) (holographicAlpha * 255);
if ((mAlpha != newViewAlpha) || (mHolographicAlpha != newHolographicAlpha)) {
diff --git a/src/com/android/launcher2/SearchDropTargetBar.java b/src/com/android/launcher2/SearchDropTargetBar.java
index 943bd00..e4cf361 100644
--- a/src/com/android/launcher2/SearchDropTargetBar.java
+++ b/src/com/android/launcher2/SearchDropTargetBar.java
@@ -33,7 +33,7 @@
public class SearchDropTargetBar extends FrameLayout implements DragController.DragListener {
private static final int sTransitionInDuration = 275;
- private static final int sTransitionOutDuration = 100;
+ private static final int sTransitionOutDuration = 125;
private ObjectAnimator mDropTargetBarFadeInAnim;
private ObjectAnimator mDropTargetBarFadeOutAnim;
@@ -62,7 +62,6 @@
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 ad00d4f..87279d0 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -74,8 +74,7 @@
* 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 @@
}
CellLayout cl = ((CellLayout) child);
cl.setOnInterceptTouchListener(this);
- cl.setOnClickListener(this);
cl.setClickable(true);
cl.enableHardwareLayers();
}
@@ -506,17 +504,6 @@
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 @@
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 @@
@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);
+ super.dispatchDraw(canvas);
- if (mInScrollArea && !LauncherApplication.isScreenLarge()) {
- final int width = getWidth();
- final int height = getHeight();
- final int pageHeight = getChildAt(0).getHeight();
+ 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);
+ // 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);
+ 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);
- }
+ 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);
}
}
}
@@ -1777,7 +1751,7 @@
// an optimization, but not required
return;
}
- fastInvalidate();
+ invalidate();
if (enableWallpaperEffects) {
setHorizontalWallpaperOffset(a * oldHorizontalWallpaperOffset
+ b * newHorizontalWallpaperOffset);
@@ -1833,9 +1807,8 @@
}
}
- if (!springLoaded) {
- hideBackgroundGradient();
- }
+ hideBackgroundGradient(springLoaded ? getResources().getInteger(
+ R.integer.config_appsCustomizeSpringLoadedBgAlpha) / 100f : 0f);
}
/**
@@ -2034,9 +2007,19 @@
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 @@
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 @@
}
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 @@
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 @@
boolean dropInscrollArea = mCurrentPage != screen;
if (!dropInscrollArea && createUserFolderIfNecessary(cell, dropTargetLayout,
- mTargetCell, false, d.dragView)) {
+ mTargetCell, false, d.dragView, null)) {
return;
}
@@ -2369,8 +2352,7 @@
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 @@
* 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 @@
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 @@
lp.cellX, lp.cellY);
if (d.dragView != null) {
- mLauncher.getDragLayer().animateViewIntoPosition(d.dragView, view);
+ mLauncher.getDragLayer().animateViewIntoPosition(d.dragView, view,
+ exitSpringLoadedRunnable);
}
}
}
@@ -3106,7 +3110,6 @@
void removeItems(final ArrayList<ApplicationInfo> apps) {
final int screenCount = getChildCount();
- final PackageManager manager = getContext().getPackageManager();
final AppWidgetManager widgets = AppWidgetManager.getInstance(getContext());
final HashSet<String> packageNames = new HashSet<String>();