Merge "Saving the system wallpaper thumbnail prefixed by the SDK_INT so that it is recreated after a system update." into ub-now-porkchop
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 47e9368..3633c8c 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -72,11 +72,15 @@
<application
android:name="com.android.launcher3.LauncherApplication"
- android:label="@string/application_name"
- android:icon="@mipmap/ic_launcher_home"
+ android:allowBackup="@bool/enable_backup"
+ android:backupAgent="com.android.launcher3.LauncherBackupAgentHelper"
android:hardwareAccelerated="true"
+ android:icon="@mipmap/ic_launcher_home"
+ android:label="@string/application_name"
android:largeHeap="@bool/config_largeHeap"
- android:supportsRtl="true">
+ android:restoreAnyVersion="true"
+ android:supportsRtl="true" >
+
<activity
android:name="com.android.launcher3.Launcher"
android:launchMode="singleTask"
diff --git a/res/drawable-hdpi/focused_bg.9.png b/res/drawable-hdpi/focused_bg.9.png
deleted file mode 100644
index 2925ae8..0000000
--- a/res/drawable-hdpi/focused_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/quantum_panel_dark.9.png b/res/drawable-hdpi/quantum_panel_dark.9.png
index 057efd1..abaf230 100644
--- a/res/drawable-hdpi/quantum_panel_dark.9.png
+++ b/res/drawable-hdpi/quantum_panel_dark.9.png
Binary files differ
diff --git a/res/drawable-hdpi/virtual_preload.9.png b/res/drawable-hdpi/virtual_preload.9.png
new file mode 100644
index 0000000..71e5326
--- /dev/null
+++ b/res/drawable-hdpi/virtual_preload.9.png
Binary files differ
diff --git a/res/drawable-hdpi/virtual_preload_folder.9.png b/res/drawable-hdpi/virtual_preload_folder.9.png
new file mode 100644
index 0000000..ece3226
--- /dev/null
+++ b/res/drawable-hdpi/virtual_preload_folder.9.png
Binary files differ
diff --git a/res/drawable-hdpi/widget_container_holo.9.png b/res/drawable-hdpi/widget_container_holo.9.png
deleted file mode 100644
index 8c15a7c..0000000
--- a/res/drawable-hdpi/widget_container_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/focused_bg.9.png b/res/drawable-mdpi/focused_bg.9.png
deleted file mode 100644
index 89c29ac..0000000
--- a/res/drawable-mdpi/focused_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/quantum_panel_dark.9.png b/res/drawable-mdpi/quantum_panel_dark.9.png
index 7837e48..7728a72 100644
--- a/res/drawable-mdpi/quantum_panel_dark.9.png
+++ b/res/drawable-mdpi/quantum_panel_dark.9.png
Binary files differ
diff --git a/res/drawable-mdpi/virtual_preload.9.png b/res/drawable-mdpi/virtual_preload.9.png
new file mode 100644
index 0000000..a3c7519
--- /dev/null
+++ b/res/drawable-mdpi/virtual_preload.9.png
Binary files differ
diff --git a/res/drawable-mdpi/virtual_preload_folder.9.png b/res/drawable-mdpi/virtual_preload_folder.9.png
new file mode 100644
index 0000000..fa2f131
--- /dev/null
+++ b/res/drawable-mdpi/virtual_preload_folder.9.png
Binary files differ
diff --git a/res/drawable-mdpi/widget_container_holo.9.png b/res/drawable-mdpi/widget_container_holo.9.png
deleted file mode 100644
index db24457..0000000
--- a/res/drawable-mdpi/widget_container_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/focused_bg.9.png b/res/drawable-xhdpi/focused_bg.9.png
deleted file mode 100644
index 197a269..0000000
--- a/res/drawable-xhdpi/focused_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/quantum_panel_dark.9.png b/res/drawable-xhdpi/quantum_panel_dark.9.png
index 8944a8f..4c1868b 100644
--- a/res/drawable-xhdpi/quantum_panel_dark.9.png
+++ b/res/drawable-xhdpi/quantum_panel_dark.9.png
Binary files differ
diff --git a/res/drawable-xhdpi/virtual_preload.9.png b/res/drawable-xhdpi/virtual_preload.9.png
new file mode 100644
index 0000000..d2c3fea
--- /dev/null
+++ b/res/drawable-xhdpi/virtual_preload.9.png
Binary files differ
diff --git a/res/drawable-xhdpi/virtual_preload_folder.9.png b/res/drawable-xhdpi/virtual_preload_folder.9.png
new file mode 100644
index 0000000..1f9202b
--- /dev/null
+++ b/res/drawable-xhdpi/virtual_preload_folder.9.png
Binary files differ
diff --git a/res/drawable-xhdpi/widget_container_holo.9.png b/res/drawable-xhdpi/widget_container_holo.9.png
deleted file mode 100644
index 1313fe7..0000000
--- a/res/drawable-xhdpi/widget_container_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/bg_preloader.png b/res/drawable-xxhdpi/bg_preloader.png
deleted file mode 100644
index 56b8060..0000000
--- a/res/drawable-xxhdpi/bg_preloader.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/bg_preloader_progress.png b/res/drawable-xxhdpi/bg_preloader_progress.png
deleted file mode 100644
index 443afe9..0000000
--- a/res/drawable-xxhdpi/bg_preloader_progress.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/focused_bg.9.png b/res/drawable-xxhdpi/focused_bg.9.png
deleted file mode 100644
index 84d3062..0000000
--- a/res/drawable-xxhdpi/focused_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/quantum_panel_dark.9.png b/res/drawable-xxhdpi/quantum_panel_dark.9.png
index b74f1a6..17ba0f1 100644
--- a/res/drawable-xxhdpi/quantum_panel_dark.9.png
+++ b/res/drawable-xxhdpi/quantum_panel_dark.9.png
Binary files differ
diff --git a/res/drawable-xxhdpi/virtual_preload.9.png b/res/drawable-xxhdpi/virtual_preload.9.png
index 0ec1740..93e3b33 100644
--- a/res/drawable-xxhdpi/virtual_preload.9.png
+++ b/res/drawable-xxhdpi/virtual_preload.9.png
Binary files differ
diff --git a/res/drawable-xxhdpi/virtual_preload_folder.9.png b/res/drawable-xxhdpi/virtual_preload_folder.9.png
index ee80c76..fae19b3 100644
--- a/res/drawable-xxhdpi/virtual_preload_folder.9.png
+++ b/res/drawable-xxhdpi/virtual_preload_folder.9.png
Binary files differ
diff --git a/res/drawable-xxhdpi/widget_container_holo.9.png b/res/drawable-xxhdpi/widget_container_holo.9.png
deleted file mode 100644
index 8f79920..0000000
--- a/res/drawable-xxhdpi/widget_container_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable/bg_appwidget_not_ready.xml b/res/drawable/bg_appwidget_not_ready.xml
deleted file mode 100644
index a8b56c2..0000000
--- a/res/drawable/bg_appwidget_not_ready.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2014 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.
--->
-
-<shape xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="rectangle" >
-
- <corners android:radius="5dp" />
-
- <solid android:color="@android:color/white" />
-
-</shape>
\ No newline at end of file
diff --git a/res/drawable/focusable_view_bg.xml b/res/drawable/focusable_view_bg.xml
index 66661e2..e156513 100644
--- a/res/drawable/focusable_view_bg.xml
+++ b/res/drawable/focusable_view_bg.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 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.
@@ -15,5 +16,11 @@
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_focused="true" android:drawable="@drawable/focused_bg" />
-</selector>
+
+ <item android:state_focused="true">
+ <shape android:shape="rectangle">
+ <solid android:color="@color/focused_background" />
+ </shape>
+ </item>
+
+</selector>
\ No newline at end of file
diff --git a/res/layout-land/launcher.xml b/res/layout-land/launcher.xml
index 7791609..0af9e59 100644
--- a/res/layout-land/launcher.xml
+++ b/res/layout-land/launcher.xml
@@ -30,6 +30,11 @@
android:layout_height="match_parent"
android:fitsSystemWindows="true">
+ <com.android.launcher3.FocusIndicatorView
+ android:id="@+id/focus_indicator"
+ android:layout_width="52dp"
+ android:layout_height="52dp" />
+
<!-- The workspace contains 5 screens of cells -->
<com.android.launcher3.Workspace
android:id="@+id/workspace"
diff --git a/res/layout-port/launcher.xml b/res/layout-port/launcher.xml
index 574b73e..46e0c0f 100644
--- a/res/layout-port/launcher.xml
+++ b/res/layout-port/launcher.xml
@@ -29,6 +29,11 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
+ <com.android.launcher3.FocusIndicatorView
+ android:id="@+id/focus_indicator"
+ android:layout_width="52dp"
+ android:layout_height="52dp" />
+
<!-- The workspace contains 5 screens of cells -->
<com.android.launcher3.Workspace
android:id="@+id/workspace"
diff --git a/res/layout-sw720dp/launcher.xml b/res/layout-sw720dp/launcher.xml
index 685d03c..f8b8437 100644
--- a/res/layout-sw720dp/launcher.xml
+++ b/res/layout-sw720dp/launcher.xml
@@ -30,6 +30,11 @@
android:layout_height="match_parent"
android:fitsSystemWindows="true">
+ <com.android.launcher3.FocusIndicatorView
+ android:id="@+id/focus_indicator"
+ android:layout_width="52dp"
+ android:layout_height="52dp" />
+
<!-- The workspace contains 5 screens of cells -->
<com.android.launcher3.Workspace
android:id="@+id/workspace"
diff --git a/res/layout/all_apps_button.xml b/res/layout/all_apps_button.xml
index 1b9ea08..9d6d82b 100644
--- a/res/layout/all_apps_button.xml
+++ b/res/layout/all_apps_button.xml
@@ -16,5 +16,4 @@
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/WorkspaceIcon"
- android:focusable="true"
- android:background="@drawable/focusable_view_bg" />
+ android:focusable="true" />
diff --git a/res/layout/application.xml b/res/layout/application.xml
index e4909dd..c21dea0 100644
--- a/res/layout/application.xml
+++ b/res/layout/application.xml
@@ -16,5 +16,4 @@
<com.android.launcher3.BubbleTextView xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/WorkspaceIcon"
- android:focusable="true"
- android:background="@drawable/focusable_view_bg" />
+ android:focusable="true" />
diff --git a/res/layout/apps_customize_application.xml b/res/layout/apps_customize_application.xml
index b48b9b7..17f4a8e 100644
--- a/res/layout/apps_customize_application.xml
+++ b/res/layout/apps_customize_application.xml
@@ -20,5 +20,4 @@
style="@style/WorkspaceIcon.AppsCustomize"
android:id="@+id/application_icon"
- android:focusable="true"
- android:background="@drawable/focusable_view_bg" />
+ android:focusable="true" />
diff --git a/res/layout/apps_customize_pane.xml b/res/layout/apps_customize_pane.xml
index 03e433a..c2d399e 100644
--- a/res/layout/apps_customize_pane.xml
+++ b/res/layout/apps_customize_pane.xml
@@ -15,7 +15,8 @@
-->
<com.android.launcher3.AppsCustomizeTabHost
xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:launcher="http://schemas.android.com/apk/res-auto/com.android.launcher3">
+ xmlns:launcher="http://schemas.android.com/apk/res-auto/com.android.launcher3"
+ android:clipChildren="false">
<LinearLayout
android:id="@+id/content"
@@ -27,15 +28,20 @@
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
- android:layout_weight="1">
+ android:layout_weight="1"
+ android:clipChildren="false">
<FrameLayout
android:id="@+id/fake_page_container"
android:layout_width="match_parent"
- android:layout_height="match_parent" >
+ android:layout_height="match_parent"
+ android:clipChildren="false"
+ android:clipToPadding="false">
<FrameLayout
- android:id="@+id/fake_page"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
+ android:id="@+id/fake_page"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:visibility="invisible"
+ android:clipToPadding="false" />
</FrameLayout>
<com.android.launcher3.AppsCustomizePagedView
android:id="@+id/apps_customize_pane_content"
@@ -55,13 +61,4 @@
android:layout_height="wrap_content"
android:layout_gravity="center" />
</LinearLayout>
-
- <include
- android:id="@+id/market_button"
- layout="@layout/market_button"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_gravity="end"
- android:visibility="gone"/>
-
</com.android.launcher3.AppsCustomizeTabHost>
diff --git a/res/layout/appwidget_not_ready.xml b/res/layout/appwidget_not_ready.xml
index f5f2aab..be7c33b 100644
--- a/res/layout/appwidget_not_ready.xml
+++ b/res/layout/appwidget_not_ready.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2009 The Android Open Source Project
+<!--
+ Copyright (C) 2009 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,15 +15,6 @@
limitations under the License.
-->
-<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+<View xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:paddingLeft="20dip"
- android:paddingRight="20dip"
- android:layout_margin="10dip"
- android:gravity="center"
- android:background="@drawable/bg_appwidget_not_ready"
- android:textAppearance="?android:attr/textAppearanceMediumInverse"
- android:textColor="@color/appwidget_not_ready_color"
- android:text="@string/gadget_pending_text"
- />
+ android:layout_height="match_parent" />
diff --git a/res/layout/folder_application.xml b/res/layout/folder_application.xml
index 37dd79d..b48b613 100644
--- a/res/layout/folder_application.xml
+++ b/res/layout/folder_application.xml
@@ -16,5 +16,4 @@
<com.android.launcher3.BubbleTextView xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/WorkspaceIcon.Folder"
- android:focusable="true"
- android:background="@drawable/focusable_view_bg" />
+ android:focusable="true" />
diff --git a/res/layout/folder_icon.xml b/res/layout/folder_icon.xml
index 5147f99..fd45d76 100644
--- a/res/layout/folder_icon.xml
+++ b/res/layout/folder_icon.xml
@@ -19,8 +19,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
- android:focusable="true"
- android:background="@drawable/focusable_view_bg">
+ android:focusable="true" >
<ImageView
android:id="@+id/preview_background"
android:layout_gravity="center_horizontal"
diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml
index 77ada31..d8ceb99 100644
--- a/res/values-tr/strings.xml
+++ b/res/values-tr/strings.xml
@@ -29,7 +29,7 @@
<string name="widget_adder" msgid="3201040140710381657">"Widget\'lar"</string>
<string name="toggle_weight_watcher" msgid="5645299835184636119">"Belleği Göster"</string>
<string name="long_press_widget_to_add" msgid="7699152356777458215">"Widget seçmek için dokunun ve basılı tutun."</string>
- <string name="market" msgid="2619650989819296998">"Alışveriş yap"</string>
+ <string name="market" msgid="2619650989819296998">"Mağaza"</string>
<string name="widget_dims_format" msgid="2370757736025621599">"%1$d × %2$d"</string>
<string name="external_drop_widget_error" msgid="3165821058322217155">"Öğe bu Ana ekrana bırakılamadı."</string>
<string name="external_drop_widget_pick_title" msgid="3486317258037690630">"Oluşturmak için widget seçin"</string>
diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml
index 2fc6a2f..c29cfb0 100644
--- a/res/values-zh-rCN/strings.xml
+++ b/res/values-zh-rCN/strings.xml
@@ -24,7 +24,7 @@
<string name="uid_name" msgid="7820867637514617527">"Android 核心应用"</string>
<string name="folder_name" msgid="7371454440695724752"></string>
<string name="activity_not_found" msgid="8071924732094499514">"未安装该应用。"</string>
- <string name="safemode_shortcut_error" msgid="9160126848219158407">"已下载的应用在安全模式下已被停用"</string>
+ <string name="safemode_shortcut_error" msgid="9160126848219158407">"安全模式下不允许使用下载的此应用"</string>
<string name="widgets_tab_label" msgid="2921133187116603919">"小部件"</string>
<string name="widget_adder" msgid="3201040140710381657">"小部件"</string>
<string name="toggle_weight_watcher" msgid="5645299835184636119">"显示内存空间"</string>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 41f3892..5e9c6ec 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -24,9 +24,9 @@
<color name="info_target_hover_tint">#DA0099CC</color>
<color name="bubble_dark_background">#20000000</color>
+ <color name="focused_background">#80c6c5c5</color>
<color name="appwidget_error_color">#FCCC</color>
- <color name="appwidget_not_ready_color">#F48F</color>
<color name="workspace_all_apps_and_delete_zone_text_color">#CCFFFFFF</color>
<color name="workspace_all_apps_and_delete_zone_text_shadow_color">#A0000000</color>
diff --git a/res/values/config.xml b/res/values/config.xml
index a16f265..19ae44c 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -17,6 +17,10 @@
<!-- Max number of page indicators to show -->
<integer name="config_maxNumberOfPageIndicatorsToShow">21</integer>
+ <!-- App data backup and restore. To enble backup, register with an android backup service.
+ http://developer.android.com/guide/topics/data/backup.html#BackupKey -->
+ <bool name="enable_backup">false</bool>
+
<!-- DragController -->
<integer name="config_flingToDeleteMinVelocity">-1500</integer>
@@ -32,15 +36,19 @@
<!-- Fade/zoom in/out duration & scale in the AllApps transition.
Note: This should be less than the workspaceShrinkTime as they happen together. -->
<integer name="config_appsCustomizeRevealTime">220</integer>
- <integer name="config_appsCustomizeItemsAlphaStagger">60</integer>
<integer name="config_appsCustomizeZoomInTime">350</integer>
<integer name="config_appsCustomizeZoomOutTime">600</integer>
<integer name="config_appsCustomizeZoomScaleFactor">7</integer>
<integer name="config_appsCustomizeFadeInTime">250</integer>
<integer name="config_appsCustomizeFadeOutTime">200</integer>
<integer name="config_appsCustomizeWorkspaceShrinkTime">300</integer>
- <integer name="config_appsCustomizeWorkspaceAnimationStagger">40</integer>
- <integer name="config_workspaceAppsCustomizeAnimationStagger">100</integer>
+
+ <integer name="config_appsCustomizeConcealTime">250</integer>
+ <integer name="config_appsCustomizeItemsAlphaStagger">60</integer>
+
+ <!-- This constant stores the ratio of the all apps button drawable which
+ is used for internal (baked-in) padding -->
+ <integer name="config_allAppsButtonPaddingPercent">17</integer>
<integer name="config_workspaceDefaultScreen">0</integer>
@@ -71,7 +79,9 @@
<integer name="config_dropAnimMaxDuration">500</integer>
<!-- The duration of the UserFolder opening and closing animation -->
- <integer name="config_folderAnimDuration">120</integer>
+ <integer name="config_folderExpandDuration">120</integer>
+ <integer name="config_materialFolderExpandDuration">200</integer>
+ <integer name="config_materialFolderExpandStagger">60</integer>
<!-- The distance at which the animation should take the max duration -->
<integer name="config_dropAnimMaxDist">800</integer>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 286e04f..aa5f7b6 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -193,11 +193,8 @@
<!-- Text to show user in place of a gadget when we can't display it properly -->
<string name="gadget_error_text">Problem loading widget</string>
- <!-- Text to show user in place of a gadget when it is not yet ready. -->
- <string name="gadget_pending_text" translatable="false">Widget not ready</string>
-
<!-- Text to show user in place of a gadget when it is not yet initialized. -->
- <string name="gadget_setup_text" translatable="false">Setup widget</string>
+ <string name="gadget_setup_text">Setup</string>
<!-- Text to inform the user that they can't uninstall a system application -->
<string name="uninstall_system_app_text">This is a system app and can\'t be uninstalled.</string>
diff --git a/src/com/android/launcher3/AppsCustomizeCellLayout.java b/src/com/android/launcher3/AppsCustomizeCellLayout.java
index 3c8bda9..76b81d2 100644
--- a/src/com/android/launcher3/AppsCustomizeCellLayout.java
+++ b/src/com/android/launcher3/AppsCustomizeCellLayout.java
@@ -20,8 +20,16 @@
import android.view.View;
public class AppsCustomizeCellLayout extends CellLayout implements Page {
+
+ final FocusIndicatorView mFocusHandlerView;
+
public AppsCustomizeCellLayout(Context context) {
super(context);
+
+ mFocusHandlerView = new FocusIndicatorView(context);
+ addView(mFocusHandlerView, 0);
+ mFocusHandlerView.getLayoutParams().width = FocusIndicatorView.DEFAULT_LAYOUT_SIZE;
+ mFocusHandlerView.getLayoutParams().height = FocusIndicatorView.DEFAULT_LAYOUT_SIZE;
}
@Override
diff --git a/src/com/android/launcher3/AppsCustomizePagedView.java b/src/com/android/launcher3/AppsCustomizePagedView.java
index e0543ce..b2228f7 100644
--- a/src/com/android/launcher3/AppsCustomizePagedView.java
+++ b/src/com/android/launcher3/AppsCustomizePagedView.java
@@ -190,16 +190,6 @@
private int mNumWidgetPages;
private Rect mAllAppsPadding = new Rect();
- // Relating to the scroll and overscroll effects
- Workspace.ZInterpolator mZInterpolator = new Workspace.ZInterpolator(0.5f);
- private static float CAMERA_DISTANCE = 6500;
- private static float TRANSITION_SCALE_FACTOR = 0.74f;
- private static float TRANSITION_PIVOT = 0.65f;
- private static float TRANSITION_MAX_ROTATION = 22;
- private static final boolean PERFORM_OVERSCROLL_ROTATION = false;
- private AccelerateInterpolator mAlphaInterpolator = new AccelerateInterpolator(0.9f);
- private DecelerateInterpolator mLeftScreenAlphaInterpolator = new DecelerateInterpolator(4);
-
// Previews & outlines
ArrayList<AppsCustomizeAsyncTask> mRunningTasks;
private static final int sPageSleepDelay = 200;
@@ -214,7 +204,7 @@
int mWidgetLoadingId = -1;
PendingAddWidgetInfo mCreateWidgetInfo = null;
private boolean mDraggingWidget = false;
- boolean mPageBackgroundsVisible;
+ boolean mPageBackgroundsVisible = true;
private Toast mWidgetInstructionToast;
@@ -259,6 +249,7 @@
if (getImportantForAccessibility() == View.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
}
+ setSinglePageInViewport();
}
@Override
@@ -376,52 +367,19 @@
mWidgetSpacingLayout.measure(widthSpec, heightSpec);
final boolean hostIsTransitioning = getTabHost().isInTransition();
-
- // Restore the page
int page = getPageForComponent(mSaveInstanceStateItemIndex);
invalidatePageData(Math.max(0, page), hostIsTransitioning);
-
- // Show All Apps cling if we are finished transitioning, otherwise, we will try again when
- // the transition completes in AppsCustomizeTabHost (otherwise the wrong offsets will be
- // returned while animating)
- if (!hostIsTransitioning) {
- post(new Runnable() {
- @Override
- public void run() {
- showAllAppsCling();
- }
- });
- }
}
- void showAllAppsCling() {
- if (!mHasShownAllAppsCling && isDataReady()) {
- mHasShownAllAppsCling = true;
- // Calculate the position for the cling punch through
- int[] offset = new int[2];
- int[] pos = mWidgetSpacingLayout.estimateCellPosition(mClingFocusedX, mClingFocusedY);
- mLauncher.getDragLayer().getLocationInDragLayer(this, offset);
- // PagedViews are centered horizontally but top aligned
- // Note we have to shift the items up now that Launcher sits under the status bar
- pos[0] += (getMeasuredWidth() - mWidgetSpacingLayout.getMeasuredWidth()) / 2 +
- offset[0];
- pos[1] += offset[1] - mLauncher.getDragLayer().getPaddingTop();
- }
- }
+ protected void onLayout(boolean changed, int l, int t, int r, int b) {
+ super.onLayout(changed, l, t, r, b);
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- int width = MeasureSpec.getSize(widthMeasureSpec);
- int height = MeasureSpec.getSize(heightMeasureSpec);
if (!isDataReady()) {
if ((LauncherAppState.isDisableAllApps() || !mApps.isEmpty()) && !mWidgets.isEmpty()) {
setDataIsReady();
- setMeasuredDimension(width, height);
- onDataReady(width, height);
+ onDataReady(getMeasuredWidth(), getMeasuredHeight());
}
}
-
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
public void onPackagesUpdated(ArrayList<Object> widgetsAndShortcuts) {
@@ -1003,8 +961,8 @@
Drawable bg = getContext().getResources().getDrawable(R.drawable.quantum_panel);
if (bg != null) {
+ bg.setAlpha(mPageBackgroundsVisible ? 255: 0);
layout.setBackground(bg);
- bg.setVisible(mPageBackgroundsVisible, false);
}
setVisibilityOnChildren(layout, View.VISIBLE);
@@ -1016,7 +974,7 @@
for (int i = 0; i < childCount; ++i) {
Drawable bg = getChildAt(i).getBackground();
if (bg != null) {
- bg.setVisible(visible, false);
+ bg.setAlpha(visible ? 255 : 0);
}
}
}
@@ -1041,6 +999,7 @@
icon.setOnLongClickListener(this);
icon.setOnTouchListener(this);
icon.setOnKeyListener(this);
+ icon.setOnFocusChangeListener(layout.mFocusHandlerView);
int index = i - startIndex;
int x = index % mCellCountX;
@@ -1163,7 +1122,12 @@
// immediately after syncing, we don't have a proper width.
int widthSpec = MeasureSpec.makeMeasureSpec(mContentWidth, MeasureSpec.AT_MOST);
int heightSpec = MeasureSpec.makeMeasureSpec(mContentHeight, MeasureSpec.AT_MOST);
- layout.setBackground(getContext().getResources().getDrawable(R.drawable.quantum_panel_dark));
+
+ Drawable bg = getContext().getResources().getDrawable(R.drawable.quantum_panel_dark);
+ if (bg != null) {
+ bg.setAlpha(mPageBackgroundsVisible ? 255 : 0);
+ layout.setBackground(bg);
+ }
layout.measure(widthSpec, heightSpec);
}
@@ -1174,11 +1138,10 @@
// Calculate the dimensions of each cell we are giving to each widget
final ArrayList<Object> items = new ArrayList<Object>();
- int contentWidth = mContentWidth - getPaddingLeft() - getPaddingRight()
- - layout.getPaddingLeft() - layout.getPaddingRight();
+ int contentWidth = mContentWidth - layout.getPaddingLeft() - layout.getPaddingRight();
final int cellWidth = contentWidth / mWidgetCountX;
- int contentHeight = mContentHeight - getPaddingTop() - getPaddingBottom()
- - layout.getPaddingTop() - layout.getPaddingBottom();
+ int contentHeight = mContentHeight - layout.getPaddingTop() - layout.getPaddingBottom();
+
final int cellHeight = contentHeight / mWidgetCountY;
// Prepare the set of widgets to load previews for in the background
@@ -1393,73 +1356,7 @@
// In apps customize, we have a scrolling effect which emulates pulling cards off of a stack.
@Override
protected void screenScrolled(int screenCenter) {
- final boolean isRtl = isLayoutRtl();
super.screenScrolled(screenCenter);
-
- for (int i = 0; i < getChildCount(); i++) {
- View v = getPageAt(i);
- if (v != null) {
- float scrollProgress = getScrollProgress(screenCenter, v, i);
-
- float interpolatedProgress;
- float translationX;
- float maxScrollProgress = Math.max(0, scrollProgress);
- float minScrollProgress = Math.min(0, scrollProgress);
-
- if (isRtl) {
- translationX = maxScrollProgress * v.getMeasuredWidth();
- interpolatedProgress = mZInterpolator.getInterpolation(Math.abs(maxScrollProgress));
- } else {
- translationX = minScrollProgress * v.getMeasuredWidth();
- interpolatedProgress = mZInterpolator.getInterpolation(Math.abs(minScrollProgress));
- }
- float scale = (1 - interpolatedProgress) +
- interpolatedProgress * TRANSITION_SCALE_FACTOR;
-
- float alpha;
- if (isRtl && (scrollProgress > 0)) {
- alpha = mAlphaInterpolator.getInterpolation(1 - Math.abs(maxScrollProgress));
- } else if (!isRtl && (scrollProgress < 0)) {
- alpha = mAlphaInterpolator.getInterpolation(1 - Math.abs(scrollProgress));
- } else {
- // On large screens we need to fade the page as it nears its leftmost position
- alpha = mLeftScreenAlphaInterpolator.getInterpolation(1 - scrollProgress);
- }
-
- v.setCameraDistance(mDensity * CAMERA_DISTANCE);
- int pageWidth = v.getMeasuredWidth();
- int pageHeight = v.getMeasuredHeight();
-
- if (PERFORM_OVERSCROLL_ROTATION) {
- float xPivot = isRtl ? 1f - TRANSITION_PIVOT : TRANSITION_PIVOT;
- boolean isOverscrollingFirstPage = isRtl ? scrollProgress > 0 : scrollProgress < 0;
- boolean isOverscrollingLastPage = isRtl ? scrollProgress < 0 : scrollProgress > 0;
-
- if (i == 0 && isOverscrollingFirstPage) {
- // Overscroll to the left
- v.setPivotX(xPivot * pageWidth);
- v.setRotationY(-TRANSITION_MAX_ROTATION * scrollProgress);
- scale = 1.0f;
- alpha = 1.0f;
- // On the first page, we don't want the page to have any lateral motion
- translationX = 0;
- } else if (i == getChildCount() - 1 && isOverscrollingLastPage) {
- // Overscroll to the right
- v.setPivotX((1 - xPivot) * pageWidth);
- v.setRotationY(-TRANSITION_MAX_ROTATION * scrollProgress);
- scale = 1.0f;
- alpha = 1.0f;
- // On the last page, we don't want the page to have any lateral motion.
- translationX = 0;
- } else {
- v.setPivotY(pageHeight / 2.0f);
- v.setPivotX(pageWidth / 2.0f);
- v.setRotationY(0f);
- }
- }
- }
- }
-
enableHwLayersOnVisiblePages();
}
@@ -1504,7 +1401,7 @@
}
protected void overScroll(float amount) {
- acceleratedOverScroll(amount);
+ dampedOverScroll(amount);
}
/**
diff --git a/src/com/android/launcher3/AppsCustomizeTabHost.java b/src/com/android/launcher3/AppsCustomizeTabHost.java
index 629bcdb..9a516fd 100644
--- a/src/com/android/launcher3/AppsCustomizeTabHost.java
+++ b/src/com/android/launcher3/AppsCustomizeTabHost.java
@@ -174,7 +174,7 @@
// Make sure the current page is loaded (we start loading the side pages after the
// transition to prevent slowing down the animation)
// TODO: revisit this
- mPagedView.loadAssociatedPages(mPagedView.getCurrentPage(), true);
+ mPagedView.loadAssociatedPages(mPagedView.getCurrentPage());
}
}
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index 1073764..93006b3 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -71,7 +71,6 @@
private int mWidthGap;
private int mHeightGap;
private int mMaxGap;
- private boolean mScrollingTransformsDirty = false;
private boolean mDropPending = false;
// These are temporary variables to prevent having to allocate a new object just to
@@ -388,23 +387,6 @@
return mIsDragOverlapping;
}
- protected void setOverscrollTransformsDirty(boolean dirty) {
- mScrollingTransformsDirty = dirty;
- }
-
- protected void resetOverscrollTransforms() {
- if (mScrollingTransformsDirty) {
- setOverscrollTransformsDirty(false);
- setTranslationX(0);
- setRotationY(0);
- // It doesn't matter if we pass true or false here, the important thing is that we
- // pass 0, which results in the overscroll drawable not being drawn any more.
- setOverScrollAmount(0, false);
- setPivotX(getMeasuredWidth() / 2);
- setPivotY(getMeasuredHeight() / 2);
- }
- }
-
@Override
protected void onDraw(Canvas canvas) {
// When we're large, we are either drawn in a "hover" state (ie when dragging an item to
@@ -989,10 +971,7 @@
}
public ShortcutAndWidgetContainer getShortcutsAndWidgets() {
- if (getChildCount() > 0) {
- return (ShortcutAndWidgetContainer) getChildAt(0);
- }
- return null;
+ return mShortcutsAndWidgets;
}
public View getChildAt(int x, int y) {
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 018fcfc..8af2a7f 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -126,6 +126,7 @@
int searchBarSpaceHeightPx;
int searchBarHeightPx;
int pageIndicatorHeightPx;
+ int allAppsButtonVisualSize;
float dragViewScale;
@@ -242,6 +243,18 @@
// Calculate the remaining vars
updateFromConfiguration(context, res, wPx, hPx, awPx, ahPx);
updateAvailableDimensions(context);
+ computeAllAppsButtonSize(context);
+ }
+
+ /**
+ * Determine the exact visual footprint of the all apps button, taking into account scaling
+ * and internal padding of the drawable.
+ */
+ private void computeAllAppsButtonSize(Context context) {
+ Resources res = context.getResources();
+ float padding = res.getInteger(R.integer.config_allAppsButtonPaddingPercent) / 100f;
+ LauncherAppState app = LauncherAppState.getInstance();
+ allAppsButtonVisualSize = (int) (hotseatIconSizePx * (1 - padding));
}
void addCallback(DeviceProfileCallbacks cb) {
diff --git a/src/com/android/launcher3/FocusHelper.java b/src/com/android/launcher3/FocusHelper.java
index b1250ce..df5e0fc 100644
--- a/src/com/android/launcher3/FocusHelper.java
+++ b/src/com/android/launcher3/FocusHelper.java
@@ -57,16 +57,6 @@
}
}
-/**
- * A keyboard listener we set on the last tab button in AppsCustomize to jump to then
- * market icon and vice versa.
- */
-class AppsCustomizeTabKeyEventListener implements View.OnKeyListener {
- public boolean onKey(View v, int keyCode, KeyEvent event) {
- return FocusHelper.handleAppsCustomizeTabKeyEvent(v, keyCode, event);
- }
-}
-
public class FocusHelper {
/**
* Private helper to get the parent TabHost in the view hiearchy.
@@ -80,41 +70,6 @@
}
/**
- * Handles key events in a AppsCustomize tab between the last tab view and the shop button.
- */
- static boolean handleAppsCustomizeTabKeyEvent(View v, int keyCode, KeyEvent e) {
- final AppsCustomizeTabHost tabHost = findTabHostParent(v);
- final ViewGroup contents = tabHost.getContent();
- final View shop = tabHost.findViewById(R.id.market_button);
-
- final int action = e.getAction();
- final boolean handleKeyEvent = (action != KeyEvent.ACTION_UP);
- boolean wasHandled = false;
- switch (keyCode) {
- case KeyEvent.KEYCODE_DPAD_RIGHT:
- if (handleKeyEvent) {
- // Select the shop button if we aren't on it
- if (v != shop) {
- shop.requestFocus();
- }
- }
- wasHandled = true;
- break;
- case KeyEvent.KEYCODE_DPAD_DOWN:
- if (handleKeyEvent) {
- // Select the content view (down is handled by the tab key handler otherwise)
- if (v == shop) {
- contents.requestFocus();
- wasHandled = true;
- }
- }
- break;
- default: break;
- }
- return wasHandled;
- }
-
- /**
* Returns the Viewgroup containing page contents for the page at the index specified.
*/
private static ViewGroup getAppsCustomizePage(ViewGroup container, int index) {
diff --git a/src/com/android/launcher3/FocusIndicatorView.java b/src/com/android/launcher3/FocusIndicatorView.java
new file mode 100644
index 0000000..12b7a40
--- /dev/null
+++ b/src/com/android/launcher3/FocusIndicatorView.java
@@ -0,0 +1,146 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.launcher3;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.util.AttributeSet;
+import android.util.Pair;
+import android.view.View;
+import android.view.ViewParent;
+
+public class FocusIndicatorView extends View implements View.OnFocusChangeListener {
+
+ // It can be any number >0. The view is resized using scaleX and scaleY.
+ static final int DEFAULT_LAYOUT_SIZE = 100;
+ private static final float MIN_VISIBLE_ALPHA = 0.2f;
+
+ private static final int[] sTempPos = new int[2];
+ private static final int[] sTempShift = new int[2];
+
+ private final int[] mIndicatorPos = new int[2];
+ private final int[] mTargetViewPos = new int[2];
+
+ private View mLastFocusedView;
+ private boolean mInitiated;
+
+ private Pair<View, Boolean> mPendingCall;
+
+ public FocusIndicatorView(Context context) {
+ this(context, null);
+ }
+
+ public FocusIndicatorView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ setAlpha(0);
+ setBackgroundColor(getResources().getColor(R.color.focused_background));
+ }
+
+ @Override
+ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
+ super.onSizeChanged(w, h, oldw, oldh);
+
+ // Redraw if it is already showing. This avoids a bug where the height changes by a small
+ // amount on connecting/disconnecting a bluetooth keyboard.
+ if (mLastFocusedView != null) {
+ mPendingCall = Pair.create(mLastFocusedView, Boolean.TRUE);
+ invalidate();
+ }
+ }
+
+ @Override
+ public void onFocusChange(View v, boolean hasFocus) {
+ mPendingCall = null;
+ if (!mInitiated && (getWidth() == 0)) {
+ // View not yet laid out. Wait until the view is ready to be drawn, so that be can
+ // get the location on screen.
+ mPendingCall = Pair.create(v, hasFocus);
+ invalidate();
+ return;
+ }
+
+ if (!mInitiated) {
+ getLocationRelativeToParentPagedView(this, mIndicatorPos);
+ mInitiated = true;
+ }
+
+ if (hasFocus) {
+ int indicatorWidth = getWidth();
+ int indicatorHeight = getHeight();
+
+ float scaleX = v.getScaleX() * v.getWidth() / indicatorWidth;
+ float scaleY = v.getScaleY() * v.getHeight() / indicatorHeight;
+
+ getLocationRelativeToParentPagedView(v, mTargetViewPos);
+ float x = mTargetViewPos[0] - mIndicatorPos[0] - (1 - scaleX) * indicatorWidth / 2;
+ float y = mTargetViewPos[1] - mIndicatorPos[1] - (1 - scaleY) * indicatorHeight / 2;
+
+ if (getAlpha() > MIN_VISIBLE_ALPHA) {
+ animate()
+ .translationX(x)
+ .translationY(y)
+ .scaleX(scaleX)
+ .scaleY(scaleY)
+ .alpha(1);
+ } else {
+ setTranslationX(x);
+ setTranslationY(y);
+ setScaleX(scaleX);
+ setScaleY(scaleY);
+ animate().alpha(1);
+ }
+ mLastFocusedView = v;
+ } else {
+ if (mLastFocusedView == v) {
+ mLastFocusedView = null;
+ animate().alpha(0);
+ }
+ }
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ if (mPendingCall != null) {
+ onFocusChange(mPendingCall.first, mPendingCall.second);
+ }
+ }
+
+ /**
+ * Gets the location of a view relative in the window, off-setting any shift due to
+ * page view scroll
+ */
+ private static void getLocationRelativeToParentPagedView(View v, int[] pos) {
+ getPagedViewScrollShift(v, sTempShift);
+ v.getLocationInWindow(sTempPos);
+ pos[0] = sTempPos[0] + sTempShift[0];
+ pos[1] = sTempPos[1] + sTempShift[1];
+ }
+
+ private static void getPagedViewScrollShift(View child, int[] shift) {
+ ViewParent parent = child.getParent();
+ if (parent instanceof PagedView) {
+ View parentView = (View) parent;
+ child.getLocationInWindow(sTempPos);
+ shift[0] = parentView.getPaddingLeft() - sTempPos[0];
+ shift[1] = -(int) child.getTranslationY();
+ } else if (parent instanceof View) {
+ getPagedViewScrollShift((View) parent, shift);
+ } else {
+ shift[0] = shift[1] = 0;
+ }
+ }
+}
diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java
index fcedaea..c548a6f 100644
--- a/src/com/android/launcher3/Folder.java
+++ b/src/com/android/launcher3/Folder.java
@@ -18,6 +18,7 @@
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
+import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.content.Context;
@@ -40,6 +41,7 @@
import android.view.View;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
+import android.view.animation.AccelerateInterpolator;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.LinearLayout;
@@ -72,6 +74,8 @@
private static final int CLOSE_FOLDER_DELAY_MS = 150;
private int mExpandDuration;
+ private int mMaterialExpandDuration;
+ private int mMaterialExpandStagger;
protected CellLayout mContent;
private ScrollView mScrollView;
private final LayoutInflater mInflater;
@@ -112,6 +116,8 @@
private static String sDefaultFolderName;
private static String sHintText;
+ private FocusIndicatorView mFocusIndicatorHandler;
+
private int DRAG_MODE_NONE = 0;
private int DRAG_MODE_REORDER = 1;
private int mDragMode = DRAG_MODE_NONE;
@@ -157,7 +163,9 @@
mInputMethodManager = (InputMethodManager)
getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
- mExpandDuration = res.getInteger(R.integer.config_folderAnimDuration);
+ mExpandDuration = res.getInteger(R.integer.config_folderExpandDuration);
+ mMaterialExpandDuration = res.getInteger(R.integer.config_materialFolderExpandDuration);
+ mMaterialExpandStagger = res.getInteger(R.integer.config_materialFolderExpandStagger);
if (sDefaultFolderName == null) {
sDefaultFolderName = res.getString(R.string.folder_name);
@@ -178,6 +186,11 @@
mScrollView = (ScrollView) findViewById(R.id.scroll_view);
mContent = (CellLayout) findViewById(R.id.folder_content);
+ mFocusIndicatorHandler = new FocusIndicatorView(getContext());
+ mContent.addView(mFocusIndicatorHandler, 0);
+ mFocusIndicatorHandler.getLayoutParams().height = FocusIndicatorView.DEFAULT_LAYOUT_SIZE;
+ mFocusIndicatorHandler.getLayoutParams().width = FocusIndicatorView.DEFAULT_LAYOUT_SIZE;
+
LauncherAppState app = LauncherAppState.getInstance();
DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
@@ -443,18 +456,93 @@
mState = STATE_SMALL;
}
+ private void prepareReveal() {
+ setScaleX(1f);
+ setScaleY(1f);
+ setAlpha(1f);
+ mState = STATE_SMALL;
+ }
+
public void animateOpen() {
- positionAndSizeAsIcon();
-
if (!(getParent() instanceof DragLayer)) return;
- centerAboutIcon();
- PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1);
- PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.0f);
- PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 1.0f);
- final ObjectAnimator oa =
- LauncherAnimUtils.ofPropertyValuesHolder(this, alpha, scaleX, scaleY);
- oa.addListener(new AnimatorListenerAdapter() {
+ Animator openFolderAnim = null;
+ final Runnable onCompleteRunnable;
+ if (!Utilities.isLmp()) {
+ positionAndSizeAsIcon();
+ centerAboutIcon();
+
+ PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1);
+ PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.0f);
+ PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 1.0f);
+ final ObjectAnimator oa =
+ LauncherAnimUtils.ofPropertyValuesHolder(this, alpha, scaleX, scaleY);
+ oa.setDuration(mExpandDuration);
+ openFolderAnim = oa;
+
+ setLayerType(LAYER_TYPE_HARDWARE, null);
+ onCompleteRunnable = new Runnable() {
+ @Override
+ public void run() {
+ setLayerType(LAYER_TYPE_NONE, null);
+ }
+ };
+ } else {
+ prepareReveal();
+ centerAboutIcon();
+
+ int width = getPaddingLeft() + getPaddingRight() + mContent.getDesiredWidth();
+ int height = getFolderHeight();
+
+ float transX = - 0.075f * (width / 2 - getPivotX());
+ float transY = - 0.075f * (height / 2 - getPivotY());
+ setTranslationX(transX);
+ setTranslationY(transY);
+ PropertyValuesHolder tx = PropertyValuesHolder.ofFloat("translationX", transX, 0);
+ PropertyValuesHolder ty = PropertyValuesHolder.ofFloat("translationY", transY, 0);
+
+ int rx = (int) Math.max(Math.max(width - getPivotX(), 0), getPivotX());
+ int ry = (int) Math.max(Math.max(height - getPivotY(), 0), getPivotY());
+ float radius = (float) Math.sqrt(rx * rx + ry * ry);
+ AnimatorSet anim = LauncherAnimUtils.createAnimatorSet();
+ Animator reveal = LauncherAnimUtils.createCircularReveal(this, (int) getPivotX(),
+ (int) getPivotY(), 0, radius);
+ reveal.setDuration(mMaterialExpandDuration);
+ reveal.setInterpolator(new LogDecelerateInterpolator(100, 0));
+
+ mContent.setAlpha(0f);
+ Animator iconsAlpha = LauncherAnimUtils.ofFloat(mContent, "alpha", 0f, 1f);
+ iconsAlpha.setDuration(mMaterialExpandDuration);
+ iconsAlpha.setStartDelay(mMaterialExpandStagger);
+ iconsAlpha.setInterpolator(new AccelerateInterpolator(1.5f));
+
+ mFolderName.setAlpha(0f);
+ Animator textAlpha = LauncherAnimUtils.ofFloat(mFolderName, "alpha", 0f, 1f);
+ textAlpha.setDuration(mMaterialExpandDuration);
+ textAlpha.setStartDelay(mMaterialExpandStagger);
+ textAlpha.setInterpolator(new AccelerateInterpolator(1.5f));
+
+ Animator drift = LauncherAnimUtils.ofPropertyValuesHolder(this, tx, ty);
+ drift.setDuration(mMaterialExpandDuration);
+ drift.setStartDelay(mMaterialExpandStagger);
+ drift.setInterpolator(new LogDecelerateInterpolator(60, 0));
+
+ anim.play(drift);
+ anim.play(iconsAlpha);
+ anim.play(textAlpha);
+ anim.play(reveal);
+
+ openFolderAnim = anim;
+
+ mContent.setLayerType(LAYER_TYPE_HARDWARE, null);
+ onCompleteRunnable = new Runnable() {
+ @Override
+ public void run() {
+ mContent.setLayerType(LAYER_TYPE_NONE, null);
+ }
+ };
+ }
+ openFolderAnim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
sendCustomAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED,
@@ -465,7 +553,10 @@
@Override
public void onAnimationEnd(Animator animation) {
mState = STATE_OPEN;
- setLayerType(LAYER_TYPE_NONE, null);
+
+ if (onCompleteRunnable != null) {
+ onCompleteRunnable.run();
+ }
// Only show cling if we are not in the middle of a drag - this would be quite jarring.
if (!mDragController.isDragging()) {
@@ -479,9 +570,7 @@
setFocusOnFirstChild();
}
});
- oa.setDuration(mExpandDuration);
- setLayerType(LAYER_TYPE_HARDWARE, null);
- oa.start();
+ openFolderAnim.start();
// Make sure the folder picks up the last drag move even if the finger doesn't move.
if (mDragController.isDragging()) {
@@ -572,6 +661,7 @@
textView.setOnClickListener(this);
textView.setOnLongClickListener(this);
+ textView.setOnFocusChangeListener(mFocusIndicatorHandler);
// We need to check here to verify that the given item's location isn't already occupied
// by another item.
diff --git a/src/com/android/launcher3/FolderIcon.java b/src/com/android/launcher3/FolderIcon.java
index c0b9da7..21efd71 100644
--- a/src/com/android/launcher3/FolderIcon.java
+++ b/src/com/android/launcher3/FolderIcon.java
@@ -178,6 +178,7 @@
icon.mFolderRingAnimator = new FolderRingAnimator(launcher, icon);
folderInfo.addListener(icon);
+ icon.setOnFocusChangeListener(launcher.mFocusHandler);
return icon;
}
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index 79cac8f..3d6befa 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -159,6 +159,7 @@
allAppsButton.setOnTouchListener(mLauncher.getHapticFeedbackTouchListener());
mLauncher.setAllAppsButton(allAppsButton);
allAppsButton.setOnClickListener(mLauncher);
+ allAppsButton.setOnFocusChangeListener(mLauncher.mFocusHandler);
}
// Note: We do this to ensure that the hotseat is always laid out in the orientation of
diff --git a/src/com/android/launcher3/IconCache.java b/src/com/android/launcher3/IconCache.java
index 221df58..06b7775 100644
--- a/src/com/android/launcher3/IconCache.java
+++ b/src/com/android/launcher3/IconCache.java
@@ -16,22 +16,20 @@
package com.android.launcher3;
-import com.android.launcher3.backup.BackupProtos;
-
import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
+import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
-import android.graphics.Paint;
import android.graphics.drawable.Drawable;
-import android.os.Build;
import android.util.Log;
import com.android.launcher3.compat.LauncherActivityInfoCompat;
@@ -54,12 +52,15 @@
* Cache of application icons. Icons can be made from any thread.
*/
public class IconCache {
- @SuppressWarnings("unused")
+
private static final String TAG = "Launcher.IconCache";
private static final int INITIAL_ICON_CACHE_CAPACITY = 50;
private static final String RESOURCE_FILE_PREFIX = "icon_";
+ // Empty class name is used for storing package default entry.
+ private static final String EMPTY_CLASS_NAME = ".";
+
private static final boolean DEBUG = true;
private static class CacheEntry {
@@ -237,7 +238,7 @@
HashMap<Object, CharSequence> labelCache) {
synchronized (mCache) {
CacheEntry entry = cacheLocked(application.componentName, info, labelCache,
- info.getUser());
+ info.getUser(), false);
application.title = entry.title;
application.iconBitmap = entry.icon;
@@ -246,10 +247,10 @@
}
public Bitmap getIcon(Intent intent, UserHandleCompat user) {
- return getIcon(intent, null, user);
+ return getIcon(intent, null, user, true);
}
- public Bitmap getIcon(Intent intent, String title, UserHandleCompat user) {
+ public Bitmap getIcon(Intent intent, String title, UserHandleCompat user, boolean usePkgIcon) {
synchronized (mCache) {
LauncherActivityInfoCompat launcherActInfo =
mLauncherApps.resolveActivity(intent, user);
@@ -257,11 +258,11 @@
// null info means not installed, but if we have a component from the intent then
// we should still look in the cache for restored app icons.
- if (launcherActInfo == null && component == null) {
+ if (component == null) {
return getDefaultIcon(user);
}
- CacheEntry entry = cacheLocked(component, launcherActInfo, null, user);
+ CacheEntry entry = cacheLocked(component, launcherActInfo, null, user, usePkgIcon);
if (title != null) {
entry.title = title;
entry.contentDescription = mUserManager.getBadgedLabelForUser(title, user);
@@ -284,7 +285,7 @@
return null;
}
- CacheEntry entry = cacheLocked(component, info, labelCache, info.getUser());
+ CacheEntry entry = cacheLocked(component, info, labelCache, info.getUser(), false);
return entry.icon;
}
}
@@ -294,7 +295,7 @@
}
private CacheEntry cacheLocked(ComponentName componentName, LauncherActivityInfoCompat info,
- HashMap<Object, CharSequence> labelCache, UserHandleCompat user) {
+ HashMap<Object, CharSequence> labelCache, UserHandleCompat user, boolean usePackageIcon) {
CacheKey cacheKey = new CacheKey(componentName, user);
CacheEntry entry = mCache.get(cacheKey);
if (entry == null) {
@@ -324,15 +325,52 @@
componentName.toShortString());
entry.icon = preloaded;
} else {
- if (DEBUG) Log.d(TAG, "using default icon for " +
- componentName.toShortString());
- entry.icon = getDefaultIcon(user);
+ if (usePackageIcon) {
+ CacheEntry packageEntry = getEntryForPackage(
+ componentName.getPackageName(), user);
+ if (packageEntry != null && packageEntry.icon != null) {
+ if (DEBUG) Log.d(TAG, "using package default icon for " +
+ componentName.toShortString());
+ entry.icon = packageEntry.icon;
+ }
+ }
+ if (entry.icon == null) {
+ if (DEBUG) Log.d(TAG, "using default icon for " +
+ componentName.toShortString());
+ entry.icon = getDefaultIcon(user);
+ }
}
}
}
return entry;
}
+ /**
+ * Gets an entry for the package, which can be used as a fallback entry for various components.
+ */
+ private CacheEntry getEntryForPackage(String packageName, UserHandleCompat user) {
+ ComponentName cn = getPackageComponent(packageName);
+ CacheKey cacheKey = new CacheKey(cn, user);
+ CacheEntry entry = mCache.get(cacheKey);
+ if (entry == null) {
+ entry = new CacheEntry();
+ mCache.put(cacheKey, entry);
+
+ try {
+ ApplicationInfo info = mPackageManager.getApplicationInfo(packageName, 0);
+ entry.title = info.loadLabel(mPackageManager);
+ entry.icon = Utilities.createIconBitmap(info.loadIcon(mPackageManager), mContext);
+ } catch (NameNotFoundException e) {
+ if (DEBUG) Log.d(TAG, "Application not installed " + packageName);
+ }
+
+ if (entry.icon == null) {
+ entry.icon = getPreloadedIcon(cn, user);
+ }
+ }
+ return entry;
+ }
+
public HashMap<ComponentName,Bitmap> getAllIcons() {
synchronized (mCache) {
HashMap<ComponentName,Bitmap> set = new HashMap<ComponentName,Bitmap>();
@@ -471,4 +509,8 @@
String filename = resourceName.replace(File.separatorChar, '_');
return RESOURCE_FILE_PREFIX + filename;
}
+
+ static ComponentName getPackageComponent(String packageName) {
+ return new ComponentName(packageName, EMPTY_CLASS_NAME);
+ }
}
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 5eedc8a..88a60d0 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -23,7 +23,6 @@
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.animation.ValueAnimator;
-import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.ActivityManager;
@@ -90,10 +89,8 @@
import android.view.Window;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityEvent;
-import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
-import android.view.animation.LinearInterpolator;
import android.view.inputmethod.InputMethodManager;
import android.widget.Advanceable;
import android.widget.FrameLayout;
@@ -245,6 +242,7 @@
private static int NEW_APPS_PAGE_MOVE_DELAY = 500;
private static int NEW_APPS_ANIMATION_INACTIVE_TIMEOUT_SECONDS = 5;
private static int NEW_APPS_ANIMATION_DELAY = 500;
+ private static final int SINGLE_FRAME_DELAY = 16;
private final BroadcastReceiver mCloseSystemDialogsReceiver
= new CloseSystemDialogsIntentReceiver();
@@ -331,10 +329,6 @@
// External icons saved in case of resource changes, orientation, etc.
private static Drawable.ConstantState[] sGlobalSearchIcon = new Drawable.ConstantState[2];
private static Drawable.ConstantState[] sVoiceSearchIcon = new Drawable.ConstantState[2];
- private static Drawable.ConstantState[] sAppMarketIcon = new Drawable.ConstantState[2];
-
- private Intent mAppMarketIntent = null;
- private static final boolean DISABLE_MARKET_BUTTON = true;
private Drawable mWorkspaceBackgroundDrawable;
@@ -387,6 +381,8 @@
private Stats mStats;
+ FocusIndicatorView mFocusHandler;
+
static boolean isPropertyEnabled(String propertyName) {
return Log.isLoggable(propertyName, Log.VERBOSE);
}
@@ -458,7 +454,6 @@
Environment.getExternalStorageDirectory() + "/launcher");
}
-
checkForLocaleChange();
setContentView(R.layout.launcher);
@@ -560,11 +555,7 @@
boolean voiceVisible = false;
// If we have a saved version of these external icons, we load them up immediately
int coi = getCurrentOrientationIndexForGlobalIcons();
- if (sGlobalSearchIcon[coi] == null || sVoiceSearchIcon[coi] == null ||
- sAppMarketIcon[coi] == null) {
- if (!DISABLE_MARKET_BUTTON) {
- updateAppMarketIcon();
- }
+ if (sGlobalSearchIcon[coi] == null || sVoiceSearchIcon[coi] == null) {
searchVisible = updateGlobalSearchIcon();
voiceVisible = updateVoiceSearchIcon(searchVisible);
}
@@ -576,9 +567,6 @@
updateVoiceSearchIcon(sVoiceSearchIcon[coi]);
voiceVisible = true;
}
- if (!DISABLE_MARKET_BUTTON && sAppMarketIcon[coi] != null) {
- updateAppMarketIcon(sAppMarketIcon[coi]);
- }
if (mSearchDropTargetBar != null) {
mSearchDropTargetBar.onSearchPackagesChanged(searchVisible, voiceVisible);
}
@@ -1292,6 +1280,7 @@
final DragController dragController = mDragController;
mLauncherView = findViewById(R.id.launcher);
+ mFocusHandler = (FocusIndicatorView) findViewById(R.id.focus_indicator);
mDragLayer = (DragLayer) findViewById(R.id.drag_layer);
mWorkspace = (Workspace) mDragLayer.findViewById(R.id.workspace);
mWorkspace.setPageSwitchListener(this);
@@ -1431,6 +1420,7 @@
BubbleTextView favorite = (BubbleTextView) mInflater.inflate(layoutResId, parent, false);
favorite.applyFromShortcutInfo(info, mIconCache, true);
favorite.setOnClickListener(this);
+ favorite.setOnFocusChangeListener(mFocusHandler);
return favorite;
}
@@ -1756,11 +1746,6 @@
}
});
}
- // When Launcher comes back to foreground, a different Activity might be responsible for
- // the app market intent, so refresh the icon
- if (!DISABLE_MARKET_BUTTON) {
- updateAppMarketIcon();
- }
clearTypedText();
}
}
@@ -2742,16 +2727,6 @@
return mHapticFeedbackTouchListener;
}
- public void onClickAppMarketButton(View v) {
- if (!DISABLE_MARKET_BUTTON) {
- if (mAppMarketIntent != null) {
- startActivitySafely(v, mAppMarketIntent, "app market");
- } else {
- Log.e(TAG, "Invalid app market intent.");
- }
- }
- }
-
public void onDragStarted(View view) {}
/**
@@ -2939,7 +2914,10 @@
ObjectAnimator oa = LauncherAnimUtils.ofPropertyValuesHolder(mFolderIconImageView, alpha,
scaleX, scaleY);
- oa.setDuration(getResources().getInteger(R.integer.config_folderAnimDuration));
+ if (Utilities.isLmp()) {
+ oa.setInterpolator(new LogDecelerateInterpolator(100, 0));
+ }
+ oa.setDuration(getResources().getInteger(R.integer.config_folderExpandDuration));
oa.start();
}
@@ -2956,7 +2934,7 @@
copyFolderIconToImage(fi);
ObjectAnimator oa = LauncherAnimUtils.ofPropertyValuesHolder(mFolderIconImageView, alpha,
scaleX, scaleY);
- oa.setDuration(getResources().getInteger(R.integer.config_folderAnimDuration));
+ oa.setDuration(getResources().getInteger(R.integer.config_folderExpandDuration));
oa.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
@@ -3226,8 +3204,6 @@
final float scale = (float) res.getInteger(R.integer.config_appsCustomizeZoomScaleFactor);
final View fromView = mWorkspace;
final AppsCustomizeTabHost toView = mAppsCustomizeTabHost;
- final int startDelay =
- res.getInteger(R.integer.config_workspaceAppsCustomizeAnimationStagger);
Workspace.State workspaceState = contentType == AppsCustomizePagedView.ContentType.Widgets ?
Workspace.State.OVERVIEW_HIDDEN : Workspace.State.NORMAL_HIDDEN;
@@ -3248,7 +3224,10 @@
final View page = content.getPageAt(content.getCurrentPage());
final View revealView = toView.findViewById(R.id.fake_page);
- if (contentType == AppsCustomizePagedView.ContentType.Widgets) {
+ final float initialPanelAlpha = 1f;
+
+ final boolean isWidgetTray = contentType == AppsCustomizePagedView.ContentType.Widgets;
+ if (isWidgetTray) {
revealView.setBackground(res.getDrawable(R.drawable.quantum_panel_dark));
} else {
revealView.setBackground(res.getDrawable(R.drawable.quantum_panel));
@@ -3262,15 +3241,21 @@
int height = revealView.getMeasuredHeight();
float revealRadius = (float) Math.sqrt((width * width) / 4 + (height * height) / 4);
- float yDrift = height / 2f;
+ revealView.setTranslationY(0);
+ // Get the y delta between the center of the page and the center of the all apps button
+ int[] allAppsToPanelDelta = Utilities.getCenterDeltaInScreenSpace(revealView,
+ getAllAppsButton(), null);
+ float yDrift = isWidgetTray ? height / 2 : allAppsToPanelDelta[1];
+
+ float initAlpha = isWidgetTray ? 0.3f : 1f;
revealView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
- PropertyValuesHolder panelAlpha = PropertyValuesHolder.ofFloat("alpha", 0.4f, 1f);
+ PropertyValuesHolder panelAlpha = PropertyValuesHolder.ofFloat("alpha", initAlpha, 1f);
PropertyValuesHolder panelDrift =
- PropertyValuesHolder.ofFloat("translationY", yDrift, 0f);
+ PropertyValuesHolder.ofFloat("translationY", yDrift, 0);
ObjectAnimator panelAlphaAndDrift =
- ObjectAnimator.ofPropertyValuesHolder(revealView, panelAlpha, panelDrift);
+ LauncherAnimUtils.ofPropertyValuesHolder(revealView, panelAlpha, panelDrift);
panelAlphaAndDrift.setDuration(revealDuration);
panelAlphaAndDrift.setInterpolator(new LogDecelerateInterpolator(100, 0));
@@ -3280,15 +3265,14 @@
page.setVisibility(View.VISIBLE);
page.setLayerType(View.LAYER_TYPE_HARDWARE, null);
- ObjectAnimator pageDrift = ObjectAnimator.ofFloat(page, "translationY", yDrift, 0);
+ ObjectAnimator pageDrift = LauncherAnimUtils.ofFloat(page, "translationY", yDrift, 0);
pageDrift.setDuration(revealDuration);
pageDrift.setInterpolator(new LogDecelerateInterpolator(100, 0));
+ pageDrift.setStartDelay(itemsAlphaStagger);
mStateAnimation.play(pageDrift);
- // TODO (adamcohen): remove this 0.01f hack once fw is fixed
- // it's there to work around a framework bug (16918357)
- page.setAlpha(0.01f);
- ObjectAnimator itemsAlpha = ObjectAnimator.ofFloat(page, "alpha", 0.01f, 1f);
+ page.setAlpha(0f);
+ ObjectAnimator itemsAlpha = LauncherAnimUtils.ofFloat(page, "alpha", 0f, 1f);
itemsAlpha.setDuration(revealDuration);
itemsAlpha.setInterpolator(new AccelerateInterpolator(1.5f));
itemsAlpha.setStartDelay(itemsAlphaStagger);
@@ -3298,16 +3282,33 @@
View pageIndicators = toView.findViewById(R.id.apps_customize_page_indicator);
pageIndicators.setAlpha(0.01f);
ObjectAnimator indicatorsAlpha =
- ObjectAnimator.ofFloat(pageIndicators, "alpha", 1f);
+ LauncherAnimUtils.ofFloat(pageIndicators, "alpha", 1f);
indicatorsAlpha.setDuration(revealDuration);
mStateAnimation.play(indicatorsAlpha);
if (material) {
- ValueAnimator reveal = (ValueAnimator)
- ViewAnimationUtils.createCircularReveal(revealView, width / 2,
- height / 2, 0f, revealRadius);
+ final View allApps = getAllAppsButton();
+ int allAppsButtonSize = LauncherAppState.getInstance().
+ getDynamicGrid().getDeviceProfile().allAppsButtonVisualSize;
+ float startRadius = isWidgetTray ? 0 : allAppsButtonSize / 2;
+ Animator reveal = LauncherAnimUtils.createCircularReveal(revealView, width / 2,
+ height / 2, startRadius, revealRadius);
reveal.setDuration(revealDuration);
reveal.setInterpolator(new LogDecelerateInterpolator(100, 0));
+
+ reveal.addListener(new AnimatorListenerAdapter() {
+ public void onAnimationStart(Animator animation) {
+ if (!isWidgetTray) {
+ allApps.setVisibility(View.INVISIBLE);
+ }
+ }
+ public void onAnimationEnd(Animator animation) {
+ if (!isWidgetTray) {
+ allApps.setVisibility(View.VISIBLE);
+ }
+ }
+ });
+
mStateAnimation.play(reveal);
}
@@ -3416,12 +3417,11 @@
}
boolean material = Utilities.isLmp();
-
Resources res = getResources();
final int duration = res.getInteger(R.integer.config_appsCustomizeZoomOutTime);
final int fadeOutDuration = res.getInteger(R.integer.config_appsCustomizeFadeOutTime);
- final int revealDuration = res.getInteger(R.integer.config_appsCustomizeRevealTime);
+ final int revealDuration = res.getInteger(R.integer.config_appsCustomizeConcealTime);
final int itemsAlphaStagger =
res.getInteger(R.integer.config_appsCustomizeItemsAlphaStagger);
@@ -3431,9 +3431,8 @@
final View toView = mWorkspace;
Animator workspaceAnim = null;
if (toState == Workspace.State.NORMAL) {
- int stagger = res.getInteger(R.integer.config_appsCustomizeWorkspaceAnimationStagger);
workspaceAnim = mWorkspace.getChangeStateAnimation(
- toState, animated, stagger, -1);
+ toState, animated);
} else if (toState == Workspace.State.SPRING_LOADED ||
toState == Workspace.State.OVERVIEW) {
workspaceAnim = mWorkspace.getChangeStateAnimation(
@@ -3451,7 +3450,9 @@
final View revealView = fromView.findViewById(R.id.fake_page);
AppsCustomizePagedView.ContentType contentType = content.getContentType();
- if (contentType == AppsCustomizePagedView.ContentType.Widgets) {
+ final boolean isWidgetTray = contentType == AppsCustomizePagedView.ContentType.Widgets;
+
+ if (isWidgetTray) {
revealView.setBackground(res.getDrawable(R.drawable.quantum_panel_dark));
} else {
revealView.setBackground(res.getDrawable(R.drawable.quantum_panel));
@@ -3465,34 +3466,43 @@
revealView.setVisibility(View.VISIBLE);
content.setPageBackgroundsVisible(false);
- float yDrift = height / 2f;
+ final View allAppsButton = getAllAppsButton();
+ revealView.setTranslationY(0);
+ int[] allAppsToPanelDelta = Utilities.getCenterDeltaInScreenSpace(revealView,
+ allAppsButton, null);
+ float yDrift = isWidgetTray ? height / 2 : allAppsToPanelDelta[1];
revealView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
- PropertyValuesHolder panelAlpha = PropertyValuesHolder.ofFloat(View.ALPHA, 1f, 0f);
- PropertyValuesHolder panelDrift =
- PropertyValuesHolder.ofFloat("translationY", 0, yDrift);
- ObjectAnimator panelAlphaAndDrift =
- ObjectAnimator.ofPropertyValuesHolder(revealView, panelAlpha, panelDrift);
- panelAlphaAndDrift.setDuration(revealDuration);
+ // The vertical motion of the apps panel should be delayed by one frame
+ // from the conceal animation in order to give the right feel. We correpsondingly
+ // shorten the duration so that the slide and conceal end at the same time.
+ ObjectAnimator panelDrift = LauncherAnimUtils.ofFloat(revealView, "translationY", 0, yDrift);
+ panelDrift.setDuration(revealDuration - SINGLE_FRAME_DELAY);
+ panelDrift.setStartDelay(itemsAlphaStagger + SINGLE_FRAME_DELAY);
+ panelDrift.setInterpolator(new LogDecelerateInterpolator(100, 0));
+ mStateAnimation.play(panelDrift);
- panelAlphaAndDrift.setInterpolator(new LogDecelerateInterpolator(100, 0));
- panelAlphaAndDrift.setStartDelay(itemsAlphaStagger);
-
- mStateAnimation.play(panelAlphaAndDrift);
+ if (isWidgetTray) {
+ ObjectAnimator panelAlpha = LauncherAnimUtils.ofFloat(revealView, "alpha", 1f, 0.4f);
+ panelAlpha.setDuration(revealDuration);
+ panelAlpha.setInterpolator(new LogDecelerateInterpolator(100, 0));
+ mStateAnimation.play(panelAlpha);
+ }
if (page != null) {
page.setLayerType(View.LAYER_TYPE_HARDWARE, null);
- ObjectAnimator pageDrift = ObjectAnimator.ofFloat(page, "translationY", 0, yDrift);
- pageDrift.setDuration(revealDuration);
+ ObjectAnimator pageDrift = LauncherAnimUtils.ofFloat(page, "translationY",
+ 0, yDrift);
+ pageDrift.setDuration(revealDuration - SINGLE_FRAME_DELAY);
pageDrift.setInterpolator(new LogDecelerateInterpolator(100, 0));
- pageDrift.setStartDelay(itemsAlphaStagger);
+ pageDrift.setStartDelay(itemsAlphaStagger + SINGLE_FRAME_DELAY);
mStateAnimation.play(pageDrift);
page.setAlpha(1f);
- ObjectAnimator itemsAlpha = ObjectAnimator.ofFloat(page, View.ALPHA, 1f, 0f);
- itemsAlpha.setDuration(revealDuration);
+ ObjectAnimator itemsAlpha = LauncherAnimUtils.ofFloat(page, "alpha", 1f, 0f);
+ itemsAlpha.setDuration(100);
itemsAlpha.setInterpolator(new LogDecelerateInterpolator(100, 0));
mStateAnimation.play(itemsAlpha);
}
@@ -3500,7 +3510,7 @@
View pageIndicators = fromView.findViewById(R.id.apps_customize_page_indicator);
pageIndicators.setAlpha(1f);
ObjectAnimator indicatorsAlpha =
- ObjectAnimator.ofFloat(pageIndicators, "alpha", 0f);
+ LauncherAnimUtils.ofFloat(pageIndicators, "alpha", 0f);
indicatorsAlpha.setDuration(revealDuration);
indicatorsAlpha.setInterpolator(new DecelerateInterpolator(1.5f));
mStateAnimation.play(indicatorsAlpha);
@@ -3508,9 +3518,15 @@
width = revealView.getMeasuredWidth();
if (material) {
+ if (!isWidgetTray) {
+ allAppsButton.setVisibility(View.INVISIBLE);
+ }
+ int allAppsButtonSize = LauncherAppState.getInstance().
+ getDynamicGrid().getDeviceProfile().allAppsButtonVisualSize;
+ float finalRadius = isWidgetTray ? 0 : allAppsButtonSize / 2;
Animator reveal =
- ViewAnimationUtils.createCircularReveal(revealView, width / 2,
- height / 2 + 100, revealRadius, 0f);
+ LauncherAnimUtils.createCircularReveal(revealView, width / 2,
+ height / 2, revealRadius, finalRadius);
reveal.setInterpolator(new LogDecelerateInterpolator(100, 0));
reveal.setDuration(revealDuration);
reveal.setStartDelay(itemsAlphaStagger);
@@ -3518,6 +3534,9 @@
reveal.addListener(new AnimatorListenerAdapter() {
public void onAnimationEnd(Animator animation) {
revealView.setVisibility(View.INVISIBLE);
+ if (!isWidgetTray) {
+ allAppsButton.setVisibility(View.VISIBLE);
+ }
}
});
@@ -3969,44 +3988,6 @@
public void disableVoiceButtonProxy(boolean disabled) {
updateVoiceButtonProxyVisible(disabled);
}
- /**
- * Sets the app market icon
- */
- private void updateAppMarketIcon() {
- if (!DISABLE_MARKET_BUTTON) {
- final View marketButton = findViewById(R.id.market_button);
- Intent intent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_APP_MARKET);
- // Find the app market activity by resolving an intent.
- // (If multiple app markets are installed, it will return the ResolverActivity.)
- ComponentName activityName = intent.resolveActivity(getPackageManager());
- if (activityName != null) {
- int coi = getCurrentOrientationIndexForGlobalIcons();
- mAppMarketIntent = intent;
- sAppMarketIcon[coi] = updateTextButtonWithIconFromExternalActivity(
- R.id.market_button, activityName, R.drawable.ic_launcher_market_holo,
- TOOLBAR_ICON_METADATA_NAME);
- marketButton.setVisibility(View.VISIBLE);
- } else {
- // We should hide and disable the view so that we don't try and restore the visibility
- // of it when we swap between drag & normal states from IconDropTarget subclasses.
- marketButton.setVisibility(View.GONE);
- marketButton.setEnabled(false);
- }
- }
- }
-
- private void updateAppMarketIcon(Drawable.ConstantState d) {
- if (!DISABLE_MARKET_BUTTON) {
- // Ensure that the new drawable we are creating has the approprate toolbar icon bounds
- Resources r = getResources();
- Drawable marketIconDrawable = d.newDrawable(r);
- int w = r.getDimensionPixelSize(R.dimen.toolbar_external_icon_width);
- int h = r.getDimensionPixelSize(R.dimen.toolbar_external_icon_height);
- marketIconDrawable.setBounds(0, 0, w, h);
-
- updateTextButtonWithDrawable(R.id.market_button, marketIconDrawable);
- }
- }
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
@@ -4445,7 +4426,9 @@
item.hostView = mAppWidgetHost.createView(this, appWidgetId, appWidgetInfo);
} else {
appWidgetInfo = null;
- item.hostView = new PendingAppWidgetHostView(this, item.restoreStatus);
+ PendingAppWidgetHostView view = new PendingAppWidgetHostView(this, item);
+ view.updateIcon(mIconCache);
+ item.hostView = view;
item.hostView.updateAppWidget(null);
item.hostView.setOnClickListener(this);
}
@@ -4478,10 +4461,7 @@
return;
}
- PendingAppWidgetHostView pendingView = (PendingAppWidgetHostView) view;
- pendingView.setStatus(LauncherAppWidgetInfo.RESTORE_COMPLETED);
-
- LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) pendingView.getTag();
+ LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) view.getTag();
info.restoreStatus = LauncherAppWidgetInfo.RESTORE_COMPLETED;
mWorkspace.reinflateWidgetsIfNecessary();
@@ -4515,12 +4495,6 @@
mWorkspace.restoreInstanceStateForRemainingPages();
- // Update the market app icon as necessary (the other icons will be managed in response to
- // package changes in bindSearchablesChanged()
- if (!DISABLE_MARKET_BUTTON) {
- updateAppMarketIcon();
- }
-
setWorkspaceLoading(false);
sendLoadingCompleteBroadcastIfNecessary();
diff --git a/src/com/android/launcher3/LauncherAnimUtils.java b/src/com/android/launcher3/LauncherAnimUtils.java
index e6c220b..be295f8 100644
--- a/src/com/android/launcher3/LauncherAnimUtils.java
+++ b/src/com/android/launcher3/LauncherAnimUtils.java
@@ -22,6 +22,7 @@
import android.animation.PropertyValuesHolder;
import android.animation.ValueAnimator;
import android.view.View;
+import android.view.ViewAnimationUtils;
import android.view.ViewTreeObserver;
import java.util.HashSet;
@@ -126,4 +127,14 @@
new FirstFrameAnimatorHelper(anim, view);
return anim;
}
+
+ public static Animator createCircularReveal(View view, int centerX,
+ int centerY, float startRadius, float endRadius) {
+ Animator anim = ViewAnimationUtils.createCircularReveal(view, centerX,
+ centerY, startRadius, endRadius);
+ if (anim instanceof ValueAnimator) {
+ new FirstFrameAnimatorHelper((ValueAnimator) anim, view);
+ }
+ return anim;
+ }
}
diff --git a/src/com/android/launcher3/LauncherAppWidgetHost.java b/src/com/android/launcher3/LauncherAppWidgetHost.java
index fa5e38f..a309f26 100644
--- a/src/com/android/launcher3/LauncherAppWidgetHost.java
+++ b/src/com/android/launcher3/LauncherAppWidgetHost.java
@@ -22,6 +22,8 @@
import android.content.Context;
import android.os.TransactionTooLargeException;
+import java.util.ArrayList;
+
/**
* Specific {@link AppWidgetHost} that creates our {@link LauncherAppWidgetHostView}
* which correctly captures all long-press events. This ensures that users can
@@ -29,6 +31,8 @@
*/
public class LauncherAppWidgetHost extends AppWidgetHost {
+ private final ArrayList<Runnable> mProviderChangeListeners = new ArrayList<Runnable>();
+
Launcher mLauncher;
public LauncherAppWidgetHost(Launcher launcher, int hostId) {
@@ -64,9 +68,21 @@
clearViews();
}
+ public void addProviderChangeListener(Runnable callback) {
+ mProviderChangeListeners.add(callback);
+ }
+
+ public void removeProviderChangeListener(Runnable callback) {
+ mProviderChangeListeners.remove(callback);
+ }
+
protected void onProvidersChanged() {
// Once we get the message that widget packages are updated, we need to rebind items
// in AppsCustomize accordingly.
mLauncher.bindPackagesUpdated(LauncherModel.getSortedWidgetsAndShortcuts(mLauncher));
+
+ for (Runnable callback : mProviderChangeListeners) {
+ callback.run();
+ }
}
}
diff --git a/src/com/android/launcher3/LauncherAppWidgetInfo.java b/src/com/android/launcher3/LauncherAppWidgetInfo.java
index c1535ab..4755482 100644
--- a/src/com/android/launcher3/LauncherAppWidgetInfo.java
+++ b/src/com/android/launcher3/LauncherAppWidgetInfo.java
@@ -67,6 +67,11 @@
*/
int restoreStatus;
+ /**
+ * Indicates the installation progress of the widget provider
+ */
+ int installProgress;
+
private boolean mHasNotifiedInitialWidgetSizeChanged;
/**
diff --git a/src/com/android/launcher3/LauncherBackupHelper.java b/src/com/android/launcher3/LauncherBackupHelper.java
index aecf9b0..64e82c7 100644
--- a/src/com/android/launcher3/LauncherBackupHelper.java
+++ b/src/com/android/launcher3/LauncherBackupHelper.java
@@ -692,6 +692,9 @@
.decodeByteArray(widget.icon.data, 0, widget.icon.data.length);
if (icon == null) {
Log.w(TAG, "failed to unpack widget icon for " + key.name);
+ } else {
+ IconCache.preloadIcon(mContext, ComponentName.unflattenFromString(widget.provider),
+ icon, widget.icon.dpi);
}
}
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 109a700..4c9d1a7 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -3089,7 +3089,7 @@
info.user = UserHandleCompat.myUserHandle();
info.contentDescription = mUserManager.getBadgedLabelForUser(
info.title.toString(), info.user);
- info.setIcon(mIconCache.getIcon(intent, info.title.toString(), info.user));
+ info.setIcon(mIconCache.getIcon(intent, info.title.toString(), info.user, false));
info.itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
info.restoredIntent = intent;
info.wasPromise = true;
@@ -3378,7 +3378,7 @@
/**
* Attempts to find an AppWidgetProviderInfo that matches the given component.
*/
- AppWidgetProviderInfo findAppWidgetProviderInfoWithComponent(Context context,
+ static AppWidgetProviderInfo findAppWidgetProviderInfoWithComponent(Context context,
ComponentName component) {
List<AppWidgetProviderInfo> widgets =
AppWidgetManager.getInstance(context).getInstalledProviders();
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 90a6b15..54aa24e 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -74,11 +74,12 @@
private static final int MIN_LENGTH_FOR_FLING = 25;
protected static final int PAGE_SNAP_ANIMATION_DURATION = 750;
+ protected static final int OVER_SCROLL_PAGE_SNAP_ANIMATION_DURATION = 350;
protected static final int SLOW_PAGE_SNAP_ANIMATION_DURATION = 950;
protected static final float NANOTIME_DIV = 1000000000.0f;
private static final float OVERSCROLL_ACCELERATE_FACTOR = 2;
- private static final float OVERSCROLL_DAMP_FACTOR = 0.14f;
+ private static final float OVERSCROLL_DAMP_FACTOR = 0.07f;
private static final float RETURN_TO_ORIGINAL_PAGE_THRESHOLD = 0.33f;
// The page is moved more than halfway, automatically move to the next page on touch up.
@@ -166,6 +167,7 @@
protected int mUnboundedScrollX;
protected int[] mTempVisiblePagesRange = new int[2];
protected boolean mForceDrawAllChildrenNextFrame;
+ private boolean mSpacePagesAutomatically = false;
// mOverScrollX is equal to getScrollX() when we're within the normal scroll range. Otherwise
// it is equal to the scaled overscroll position. We use a separate value so as to prevent
@@ -844,6 +846,7 @@
final int verticalPadding = getPaddingTop() + getPaddingBottom();
final int horizontalPadding = getPaddingLeft() + getPaddingRight();
+ int referenceChildWidth = 0;
// The children are given the same width and height as the workspace
// unless they were set to WRAP_CONTENT
if (DEBUG) Log.d(TAG, "PagedView.onMeasure(): " + widthSize + ", " + heightSize);
@@ -888,6 +891,9 @@
childWidth = getViewportWidth() - mInsets.left - mInsets.right;
childHeight = getViewportHeight();
}
+ if (referenceChildWidth == 0) {
+ referenceChildWidth = childWidth;
+ }
final int childWidthMeasureSpec =
MeasureSpec.makeMeasureSpec(childWidth, childWidthMode);
@@ -896,9 +902,24 @@
child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
}
}
+ if (mSpacePagesAutomatically) {
+ int spacing = (getViewportWidth() - mInsets.left - mInsets.right
+ - referenceChildWidth) / 2;
+ if (spacing >= 0) {
+ setPageSpacing(spacing);
+ }
+ mSpacePagesAutomatically = false;
+ }
setMeasuredDimension(scaledWidthSize, scaledHeightSize);
}
+ /**
+ * This method should be called once before first layout / measure pass.
+ */
+ protected void setSinglePageInViewport() {
+ mSpacePagesAutomatically = true;
+ }
+
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
if (!mIsDataReady || getChildCount() == 0) {
@@ -1159,7 +1180,7 @@
}
protected boolean shouldDrawChild(View child) {
- return child.getAlpha() > 0 && child.getVisibility() == VISIBLE;
+ return child.getVisibility() == VISIBLE;
}
@Override
@@ -1581,29 +1602,20 @@
return f * f * f + 1.0f;
}
- protected void acceleratedOverScroll(float amount) {
+ protected float acceleratedOverFactor(float amount) {
int screenSize = getViewportWidth();
// We want to reach the max over scroll effect when the user has
// over scrolled half the size of the screen
float f = OVERSCROLL_ACCELERATE_FACTOR * (amount / screenSize);
- if (f == 0) return;
+ if (f == 0) return 0;
// Clamp this factor, f, to -1 < f < 1
if (Math.abs(f) >= 1) {
f /= Math.abs(f);
}
-
- int overScrollAmount = (int) Math.round(f * screenSize);
- if (amount < 0) {
- mOverScrollX = overScrollAmount;
- super.scrollTo(0, getScrollY());
- } else {
- mOverScrollX = mMaxScrollX + overScrollAmount;
- super.scrollTo(mMaxScrollX, getScrollY());
- }
- invalidate();
+ return f;
}
protected void dampedOverScroll(float amount) {
@@ -1622,10 +1634,10 @@
int overScrollAmount = (int) Math.round(OVERSCROLL_DAMP_FACTOR * f * screenSize);
if (amount < 0) {
mOverScrollX = overScrollAmount;
- super.scrollTo(0, getScrollY());
+ super.scrollTo(mOverScrollX, getScrollY());
} else {
mOverScrollX = mMaxScrollX + overScrollAmount;
- super.scrollTo(mMaxScrollX, getScrollY());
+ super.scrollTo(mOverScrollX, getScrollY());
}
invalidate();
}
@@ -2125,8 +2137,20 @@
return minDistanceFromScreenCenterIndex;
}
+ protected boolean isInOverScroll() {
+ return (mOverScrollX > mMaxScrollX || mOverScrollX < 0);
+ }
+
+ protected int getPageSnapDuration() {
+ if (isInOverScroll()) {
+ return OVER_SCROLL_PAGE_SNAP_ANIMATION_DURATION;
+ }
+ return PAGE_SNAP_ANIMATION_DURATION;
+
+ }
+
protected void snapToDestination() {
- snapToPage(getPageNearestToCenterOfScreen(), PAGE_SNAP_ANIMATION_DURATION);
+ snapToPage(getPageNearestToCenterOfScreen(), getPageSnapDuration());
}
private static class ScrollInterpolator implements Interpolator {
@@ -2157,10 +2181,10 @@
int delta = newX - mUnboundedScrollX;
int duration = 0;
- if (Math.abs(velocity) < mMinFlingVelocity) {
+ if (Math.abs(velocity) < mMinFlingVelocity || isInOverScroll()) {
// If the velocity is low enough, then treat this more as an automatic page advance
// as opposed to an apparent physical response to flinging
- snapToPage(whichPage, PAGE_SNAP_ANIMATION_DURATION);
+ snapToPage(whichPage, getPageSnapDuration());
return;
}
@@ -2184,11 +2208,11 @@
}
protected void snapToPage(int whichPage) {
- snapToPage(whichPage, PAGE_SNAP_ANIMATION_DURATION);
+ snapToPage(whichPage, getPageSnapDuration());
}
protected void snapToPageImmediately(int whichPage) {
- snapToPage(whichPage, PAGE_SNAP_ANIMATION_DURATION, true, null);
+ snapToPage(whichPage, getPageSnapDuration(), true, null);
}
protected void snapToPage(int whichPage, int duration) {
diff --git a/src/com/android/launcher3/PendingAppWidgetHostView.java b/src/com/android/launcher3/PendingAppWidgetHostView.java
index 048e9f8..0401436 100644
--- a/src/com/android/launcher3/PendingAppWidgetHostView.java
+++ b/src/com/android/launcher3/PendingAppWidgetHostView.java
@@ -1,21 +1,59 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package com.android.launcher3;
import android.content.Context;
+import android.content.Intent;
+import android.content.res.Resources.Theme;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
-import android.widget.TextView;
public class PendingAppWidgetHostView extends LauncherAppWidgetHostView implements OnClickListener {
- int mRestoreStatus;
+ private static Theme sPreloaderTheme;
- private TextView mDefaultView;
+ private final Rect mRect = new Rect();
+ private View mDefaultView;
private OnClickListener mClickListener;
+ private final LauncherAppWidgetInfo mInfo;
+ private final int mStartState;
+ private final Intent mIconLookupIntent;
- public PendingAppWidgetHostView(Context context, int restoreStatus) {
+ private Bitmap mIcon;
+ private PreloadIconDrawable mDrawable;
+
+ private Drawable mCenterDrawable;
+ private Drawable mTopCornerDrawable;
+
+ private boolean mDrawableSizeChanged;
+
+ public PendingAppWidgetHostView(Context context, LauncherAppWidgetInfo info) {
super(context);
- mRestoreStatus = restoreStatus;
+ mInfo = info;
+ mStartState = info.restoreStatus;
+ mIconLookupIntent = new Intent().setComponent(info.providerName);
+
+ setBackgroundResource(R.drawable.quantum_panel_dark);
+ setWillNotDraw(false);
}
@Override
@@ -27,7 +65,7 @@
@Override
protected View getDefaultView() {
if (mDefaultView == null) {
- mDefaultView = (TextView) mInflater.inflate(R.layout.appwidget_not_ready, this, false);
+ mDefaultView = mInflater.inflate(R.layout.appwidget_not_ready, this, false);
mDefaultView.setOnClickListener(this);
applyState();
}
@@ -39,26 +77,57 @@
mClickListener = l;
}
- public void setStatus(int status) {
- if (mRestoreStatus != status) {
- mRestoreStatus = status;
- applyState();
+ @Override
+ public boolean isReinflateRequired() {
+ // Re inflate is required any time the widget restore status changes
+ return mStartState != mInfo.restoreStatus;
+ }
+
+ @Override
+ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
+ super.onSizeChanged(w, h, oldw, oldh);
+ mDrawableSizeChanged = true;
+ }
+
+ public void updateIcon(IconCache cache) {
+ Bitmap icon = cache.getIcon(mIconLookupIntent, mInfo.user);
+ if (mIcon == icon) {
+ return;
+ }
+ mIcon = icon;
+ if (mDrawable != null) {
+ mDrawable.setCallback(null);
+ mDrawable = null;
+ }
+ if (mIcon != null) {
+ // The view displays two modes, one with a setup icon and another with a preload icon
+ // in the center.
+ if (isReadyForClickSetup()) {
+ mCenterDrawable = getResources().getDrawable(R.drawable.ic_setting);
+ mTopCornerDrawable = new FastBitmapDrawable(mIcon);
+ } else {
+ if (sPreloaderTheme == null) {
+ sPreloaderTheme = getResources().newTheme();
+ sPreloaderTheme.applyStyle(R.style.PreloadIcon, true);
+ }
+
+ FastBitmapDrawable drawable = Utilities.createIconDrawable(mIcon);
+ mDrawable = new PreloadIconDrawable(drawable, sPreloaderTheme);
+ mDrawable.setCallback(this);
+ applyState();
+ }
+ mDrawableSizeChanged = true;
}
}
@Override
- public boolean isReinflateRequired() {
- // Re inflate is required if the the widget is restored.
- return mRestoreStatus == LauncherAppWidgetInfo.RESTORE_COMPLETED;
+ protected boolean verifyDrawable(Drawable who) {
+ return (who == mDrawable) || super.verifyDrawable(who);
}
- private void applyState() {
- if (mDefaultView != null) {
- if (isReadyForClickSetup()) {
- mDefaultView.setText(R.string.gadget_setup_text);
- } else {
- mDefaultView.setText(R.string.gadget_pending_text);
- }
+ public void applyState() {
+ if (mDrawable != null) {
+ mDrawable.setLevel(mInfo.installProgress);
}
}
@@ -72,7 +141,51 @@
}
public boolean isReadyForClickSetup() {
- return (mRestoreStatus & LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY) == 0
- && (mRestoreStatus & LauncherAppWidgetInfo.FLAG_UI_NOT_READY) != 0;
+ return (mInfo.restoreStatus & LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY) == 0
+ && (mInfo.restoreStatus & LauncherAppWidgetInfo.FLAG_UI_NOT_READY) != 0;
}
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ if (mDrawable != null) {
+ if (mDrawableSizeChanged) {
+ int maxSize = LauncherAppState.getInstance().getDynamicGrid()
+ .getDeviceProfile().iconSizePx + 2 * mDrawable.getOutset();
+ int size = Math.min(maxSize, Math.min(
+ getWidth() - getPaddingLeft() - getPaddingRight(),
+ getHeight() - getPaddingTop() - getPaddingBottom()));
+
+ mRect.set(0, 0, size, size);
+ mRect.inset(mDrawable.getOutset(), mDrawable.getOutset());
+ mRect.offsetTo((getWidth() - mRect.width()) / 2, (getHeight() - mRect.height()) / 2);
+ mDrawable.setBounds(mRect);
+ mDrawableSizeChanged = false;
+ }
+
+ mDrawable.draw(canvas);
+ } else if ((mCenterDrawable != null) && (mTopCornerDrawable != null)) {
+ if (mDrawableSizeChanged) {
+ int iconSize = getResources().getDimensionPixelSize(R.dimen.app_icon_size);
+ int paddingTop = getPaddingTop();
+ int paddingLeft = getPaddingLeft();
+
+ int size = Math.min(iconSize, Math.min(
+ getWidth() - paddingLeft - getPaddingRight(),
+ getHeight() - paddingTop - getPaddingBottom()));
+ mRect.set(0, 0, size, size);
+ mRect.offsetTo((getWidth() - mRect.width()) / 2, (getHeight() - mRect.height()) / 2);
+ mCenterDrawable.setBounds(mRect);
+
+ size = Math.min(size / 2,
+ Math.max(mRect.top - paddingTop, mRect.left - paddingLeft));
+ mTopCornerDrawable.setBounds(paddingLeft, paddingTop,
+ paddingLeft + size, paddingTop + size);
+ mDrawableSizeChanged = false;
+ }
+
+ mCenterDrawable.draw(canvas);
+ mTopCornerDrawable.draw(canvas);
+ }
+ }
+
}
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 60185c6..f70fc4d 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -67,6 +67,8 @@
static int sColors[] = { 0xffff0000, 0xff00ff00, 0xff0000ff };
static int sColorIndex = 0;
+ static int[] sLoc0 = new int[2];
+ static int[] sLoc1 = new int[2];
// To turn on these properties, type
// adb shell setprop log.tag.PROPERTY_NAME [VERBOSE | SUPPRESS]
@@ -346,6 +348,25 @@
}
}
+ public static int[] getCenterDeltaInScreenSpace(View v0, View v1, int[] delta) {
+ v0.getLocationInWindow(sLoc0);
+ v1.getLocationInWindow(sLoc1);
+
+ sLoc0[0] += (v0.getMeasuredWidth() * v0.getScaleX()) / 2;
+ sLoc0[1] += (v0.getMeasuredHeight() * v0.getScaleY()) / 2;
+ sLoc1[0] += (v1.getMeasuredWidth() * v1.getScaleX()) / 2;
+ sLoc1[1] += (v1.getMeasuredHeight() * v1.getScaleY()) / 2;
+
+ if (delta == null) {
+ delta = new int[2];
+ }
+
+ delta[0] = sLoc1[0] - sLoc0[0];
+ delta[1] = sLoc1[1] - sLoc0[1];
+
+ return delta;
+ }
+
public static void scaleRectAboutCenter(Rect r, float scale) {
int cx = r.centerX();
int cy = r.centerY();
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index cd6fcca..53a3f94 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -27,6 +27,7 @@
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.app.WallpaperManager;
+import android.appwidget.AppWidgetHost;
import android.appwidget.AppWidgetHostView;
import android.appwidget.AppWidgetProviderInfo;
import android.content.ComponentName;
@@ -45,7 +46,10 @@
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.AsyncTask;
+import android.os.Handler;
+import android.os.Handler.Callback;
import android.os.IBinder;
+import android.os.Message;
import android.os.Parcelable;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
@@ -74,6 +78,7 @@
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
/**
* The workspace is a wide area with a wallpaper and a finite number of pages.
@@ -210,7 +215,7 @@
private final Rect mTempRect = new Rect();
private final int[] mTempXY = new int[2];
private int[] mTempVisiblePagesRange = new int[2];
- private boolean mOverscrollTransformsSet;
+ private boolean mOverscrollEffectSet;
public static final int DRAG_BITMAP_PADDING = 2;
private boolean mWorkspaceFadeInAdjacentScreens;
@@ -276,6 +281,8 @@
private int mLastChildCount = -1;
private float mTransitionProgress;
+ float mOverScrollEffect = 0f;
+
private Runnable mDeferredAction;
private boolean mDeferDropAfterUninstall;
private boolean mUninstallSuccessful;
@@ -431,7 +438,6 @@
* Initializes various states for this workspace.
*/
protected void initWorkspace() {
- Context context = getContext();
mCurrentPage = mDefaultPage;
Launcher.setScreen(mCurrentPage);
LauncherAppState app = LauncherAppState.getInstance();
@@ -1679,14 +1685,11 @@
updateStateForCustomContent(screenCenter);
enableHwLayersOnVisiblePages();
- boolean shouldOverScroll = (mOverScrollX < 0 && (!hasCustomContent() || isLayoutRtl())) ||
- (mOverScrollX > mMaxScrollX && (!hasCustomContent() || !isLayoutRtl()));
+ boolean shouldOverScroll = (mOverScrollEffect < 0 && (!hasCustomContent() || isLayoutRtl())) ||
+ (mOverScrollEffect > 0 && (!hasCustomContent() || !isLayoutRtl()));
if (shouldOverScroll) {
int index = 0;
- float pivotX = 0f;
- final float leftBiasedPivot = 0.25f;
- final float rightBiasedPivot = 0.75f;
final int lowerIndex = 0;
final int upperIndex = getChildCount() - 1;
@@ -1694,25 +1697,27 @@
index = (!isRtl && isLeftPage) || (isRtl && !isLeftPage) ? lowerIndex : upperIndex;
CellLayout cl = (CellLayout) getChildAt(index);
- float scrollProgress = getScrollProgress(screenCenter, cl, index);
- cl.setOverScrollAmount(Math.abs(scrollProgress), isLeftPage);
+ float effect = Math.abs(mOverScrollEffect);
+ cl.setOverScrollAmount(Math.abs(effect), isLeftPage);
- if (!mOverscrollTransformsSet) {
- mOverscrollTransformsSet = true;
- cl.setOverscrollTransformsDirty(true);
- }
+ mOverscrollEffectSet = true;
} else {
- if (mOverscrollTransformsSet && getChildCount() > 0) {
- mOverscrollTransformsSet = false;
- ((CellLayout) getChildAt(0)).resetOverscrollTransforms();
- ((CellLayout) getChildAt(getChildCount() - 1)).resetOverscrollTransforms();
+ if (mOverscrollEffectSet && getChildCount() > 0) {
+ mOverscrollEffectSet = false;
+ ((CellLayout) getChildAt(0)).setOverScrollAmount(0, false);
+ ((CellLayout) getChildAt(getChildCount() - 1)).setOverScrollAmount(0, false);
}
}
}
+ private void computeOverScrollEffect(float amount) {
+ mOverScrollEffect = acceleratedOverFactor(amount);
+ }
+
@Override
protected void overScroll(float amount) {
- acceleratedOverScroll(amount);
+ computeOverScrollEffect(amount);
+ dampedOverScroll(amount);
}
protected void onAttachedToWindow() {
@@ -2237,9 +2242,6 @@
} else if (stateIsOverview || stateIsOverviewHidden) {
mNewScale = mOverviewModeShrinkFactor;
}
- if (workspaceToAllApps) {
- updateChildrenLayersEnabled(false);
- }
}
final int duration;
@@ -4887,7 +4889,14 @@
((ShortcutInfo) info).setProgress(installInfo.progress);
((ShortcutInfo) info).setState(installInfo.state);
((BubbleTextView)v).applyState();
+ } else if (v instanceof PendingAppWidgetHostView
+ && info instanceof LauncherAppWidgetInfo
+ && ((LauncherAppWidgetInfo) info).providerName.getPackageName()
+ .equals(installInfo.packageName)) {
+ ((LauncherAppWidgetInfo) info).installProgress = installInfo.progress;
+ ((PendingAppWidgetHostView) v).applyState();
}
+
// process all the shortcuts
return false;
}
@@ -4904,7 +4913,8 @@
}
private void restorePendingWidgets(final Set<String> installedPackaged) {
- final AtomicBoolean widgetsChanged = new AtomicBoolean(false);
+ final ArrayList<LauncherAppWidgetInfo> changedInfo = new ArrayList<LauncherAppWidgetInfo>();
+
// Iterate non recursively as widgets can't be inside a folder.
mapOverItems(MAP_NO_RECURSE, new ItemOperator() {
@@ -4914,18 +4924,28 @@
LauncherAppWidgetInfo widgetInfo = (LauncherAppWidgetInfo) info;
if (widgetInfo.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY)
&& installedPackaged.contains(widgetInfo.providerName.getPackageName())) {
- widgetsChanged.set(true);
+
+ changedInfo.add(widgetInfo);
+
+ // Remove the provider not ready flag
+ widgetInfo.restoreStatus &= ~LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY;
+ LauncherModel.updateItemInDatabase(getContext(), widgetInfo);
}
}
// process all the widget
return false;
}
});
- if (widgetsChanged.get()) {
- // Reload layout and update widget status
- // TODO instead of full reload, just update the specific widgets
- getContext().getContentResolver()
- .notifyChange(LauncherSettings.Favorites.CONTENT_URI, null);
+ if (!changedInfo.isEmpty()) {
+ DeferredWidgetRefresh widgetRefresh = new DeferredWidgetRefresh(changedInfo,
+ mLauncher.getAppWidgetHost());
+ if (LauncherModel.findAppWidgetProviderInfoWithComponent(getContext(),
+ changedInfo.get(0).providerName) != null) {
+ // Re-inflate the widgets which have changed status
+ widgetRefresh.run();
+ } else {
+ // widgetRefresh will automatically run when the packages are updated.
+ }
}
}
@@ -5003,4 +5023,53 @@
public void getLocationInDragLayer(int[] loc) {
mLauncher.getDragLayer().getLocationInDragLayer(this, loc);
}
+
+ /**
+ * Used as a workaround to ensure that the AppWidgetService receives the
+ * PACKAGE_ADDED broadcast before updating widgets.
+ */
+ private class DeferredWidgetRefresh implements Runnable {
+ private final ArrayList<LauncherAppWidgetInfo> mInfos;
+ private final LauncherAppWidgetHost mHost;
+ private final Handler mHandler;
+
+ private boolean mRefreshPending;
+
+ public DeferredWidgetRefresh(ArrayList<LauncherAppWidgetInfo> infos,
+ LauncherAppWidgetHost host) {
+ mInfos = infos;
+ mHost = host;
+ mHandler = new Handler();
+ mRefreshPending = true;
+
+ mHost.addProviderChangeListener(this);
+ // Force refresh after 10 seconds, if we don't get the provider changed event.
+ // This could happen when the provider is no longer available in the app.
+ mHandler.postDelayed(this, 10000);
+ }
+
+ @Override
+ public void run() {
+ mHost.removeProviderChangeListener(this);
+ mHandler.removeCallbacks(this);
+
+ if (!mRefreshPending) {
+ return;
+ }
+
+ mRefreshPending = false;
+
+ for (LauncherAppWidgetInfo info : mInfos) {
+ if (info.hostView instanceof PendingAppWidgetHostView) {
+ PendingAppWidgetHostView view = (PendingAppWidgetHostView) info.hostView;
+ mLauncher.removeAppWidget(info);
+
+ CellLayout cl = (CellLayout) view.getParent().getParent();
+ // Remove the current widget
+ cl.removeView(view);
+ mLauncher.bindAppWidget(info);
+ }
+ }
+ }
+ }
}
diff --git a/src/com/android/launcher3/compat/PackageInstallerCompatVL.java b/src/com/android/launcher3/compat/PackageInstallerCompatVL.java
index 26e1b7c..c78ab99 100644
--- a/src/com/android/launcher3/compat/PackageInstallerCompatVL.java
+++ b/src/com/android/launcher3/compat/PackageInstallerCompatVL.java
@@ -17,9 +17,9 @@
package com.android.launcher3.compat;
import android.content.Context;
-import android.content.pm.InstallSessionInfo;
import android.content.pm.PackageInstaller;
import android.content.pm.PackageInstaller.SessionCallback;
+import android.content.pm.PackageInstaller.SessionInfo;
import android.util.Log;
import android.util.SparseArray;
@@ -33,7 +33,7 @@
private static final String TAG = "PackageInstallerCompatVL";
private static final boolean DEBUG = false;
- private final SparseArray<InstallSessionInfo> mPendingReplays = new SparseArray<InstallSessionInfo>();
+ private final SparseArray<SessionInfo> mPendingReplays = new SparseArray<SessionInfo>();
private final PackageInstaller mInstaller;
private boolean mResumed;
@@ -47,7 +47,7 @@
mInstaller.addSessionCallback(mCallback);
// On start, send updates for all active sessions
- for (InstallSessionInfo info : mInstaller.getAllSessions()) {
+ for (SessionInfo info : mInstaller.getAllSessions()) {
mPendingReplays.append(info.getSessionId(), info);
}
}
@@ -102,7 +102,7 @@
updates.add(newInfo);
}
for (int i = mPendingReplays.size() - 1; i > 0; i--) {
- InstallSessionInfo session = mPendingReplays.valueAt(i);
+ SessionInfo session = mPendingReplays.valueAt(i);
if (session.getAppPackageName() != null) {
updates.add(new PackageInstallInfo(session.getAppPackageName(),
ShortcutInfo.PACKAGE_STATE_INSTALLING,
@@ -119,7 +119,7 @@
@Override
public void onCreated(int sessionId) {
- InstallSessionInfo session = mInstaller.getSessionInfo(sessionId);
+ SessionInfo session = mInstaller.getSessionInfo(sessionId);
if (session != null) {
mPendingReplays.put(sessionId, session);
replayUpdates(null);
@@ -129,7 +129,7 @@
@Override
public void onFinished(int sessionId, boolean success) {
mPendingReplays.remove(sessionId);
- InstallSessionInfo session = mInstaller.getSessionInfo(sessionId);
+ SessionInfo session = mInstaller.getSessionInfo(sessionId);
if ((session != null) && (session.getAppPackageName() != null)) {
// Replay all updates with a one time update for this installed package. No
// need to store this record for future updates, as the app list will get
@@ -142,7 +142,7 @@
@Override
public void onProgressChanged(int sessionId, float progress) {
- InstallSessionInfo session = mInstaller.getSessionInfo(sessionId);
+ SessionInfo session = mInstaller.getSessionInfo(sessionId);
if (session != null) {
mPendingReplays.put(sessionId, session);
replayUpdates(null);