Replacing AllApps/Customize in tablet UI with Apps/Customize.

Change-Id: I11a296b25472e4bf298a468865b0dff29f500aaa
This commit is contained in:
Winson Chung committed 2011-06-13 11:49:32 -07:00
1 parent bf5a5c894d
commit f0ea4d3378
36 files changed
+722 -1003

No files matched your search

File renamed without changes.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

@@ -1,24 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2007, 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.
*/
-->
<transition xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_home_delete_holo_dark" />
<item android:drawable="@drawable/ic_home_delete_hover_holo_dark" />
</transition>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

-1
View File
@@ -38,7 +38,6 @@
<include android:id="@+id/cell3" layout="@layout/workspace_screen" />
<include android:id="@+id/cell4" layout="@layout/workspace_screen" />
<include android:id="@+id/cell5" layout="@layout/workspace_screen" />
</com.android.launcher2.Workspace>
<include layout="@layout/qsb_bar"
+6 -14
View File
@@ -28,23 +28,15 @@
android:layout_width="match_parent"
android:layout_height="match_parent" />
<include layout="@layout/button_bar"
android:id="@+id/all_apps_button_cluster"
android:layout_width="fill_parent"
android:layout_height="?android:attr/actionBarSize"
<include layout="@layout/qsb_bar"
android:id="@+id/qsb_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/qsb_bar_height"
android:layout_gravity="top" />
<include layout="@layout/all_apps_tabbed"
android:id="@+id/all_apps_view"
<include layout="@layout/apps_customize_pane"
android:id="@+id/apps_customize_pane"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top"
android:visibility="invisible" />
<include layout="@layout/customization_drawer"
android:id="@+id/customization_drawer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:visibility="invisible" />
</com.android.launcher2.DragLayer>
+135
View File
@@ -0,0 +1,135 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2011 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<com.android.launcher2.SearchDropTargetBar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
android:focusable="false">
<!-- Search buttons container -->
<RelativeLayout
style="@style/SearchDropTargetBar"
android:id="@+id/qsb_search_bar"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Global search icon -->
<ImageView
style="@style/SearchButton"
android:id="@+id/search_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/ic_generic_search"
android:background="@drawable/button_bg"
android:onClick="onClickSearchButton"
android:focusable="true"
android:clickable="true"
android:contentDescription="@string/accessibility_search_button" />
<ImageView
style="@style/SearchButtonDivider"
android:id="@+id/search_divider"
android:layout_toRightOf="@+id/search_button"
android:src="@drawable/divider_launcher_holo"
android:onClick="onClickSearchButton"
android:focusable="false"
android:clickable="true" />
<!-- Voice search icon -->
<ImageView
style="@style/SearchButton"
android:id="@+id/voice_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/search_divider"
android:src="@drawable/ic_voice_search"
android:background="@drawable/button_bg"
android:onClick="onClickVoiceButton"
android:focusable="true"
android:clickable="true"
android:contentDescription="@string/accessibility_voice_search_button" />
<!-- AppsCustomize icon -->
<com.android.launcher2.StrokedTextView
android:id="@+id/all_apps_button"
android:onClick="onClickAllAppsButton"
android:drawableLeft="@drawable/ic_home_all_apps_holo_dark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@+id/all_apps_divider"
android:paddingLeft="@dimen/toolbar_button_horizontal_padding"
android:paddingRight="@dimen/toolbar_button_horizontal_padding"
android:paddingTop="@dimen/all_apps_button_vertical_padding"
android:paddingBottom="@dimen/all_apps_button_vertical_padding"
android:background="@drawable/button_bg"
android:gravity="center"
android:textColor="#CCFFFFFF"
android:textSize="18sp"
launcher:strokeColor="#991e3157"
launcher:strokeTextColor="#DDFFFFFF"
launcher:strokeWidth="2.5"
android:shadowColor="#DA000000"
android:shadowDx="0.0"
android:shadowDy="0.0"
android:shadowRadius="2.5"
android:focusable="true"
android:clickable="true"
android:contentDescription="@string/accessibility_all_apps_button" />
</RelativeLayout>
<!-- Drag specific targets container -->
<LinearLayout
style="@style/SearchDropTargetBar"
android:id="@+id/drag_target_bar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0">
<FrameLayout
style="@style/DropTargetButtonContainer"
android:layout_weight="1">
<!-- Delete target -->
<com.android.launcher2.DeleteDropTarget
style="@style/DropTargetButton"
android:id="@+id/delete_target"
android:text="@string/delete_zone_label_workspace"
android:drawableLeft="@drawable/delete_zone_selector"
launcher:strokeColor="#991e3157"
launcher:strokeTextColor="#DDFFFFFF"
launcher:strokeWidth="2.5" />
</FrameLayout>
<FrameLayout
style="@style/DropTargetButtonContainer"
android:layout_weight="1">
<!-- Info target -->
<com.android.launcher2.InfoDropTarget
style="@style/DropTargetButton"
android:id="@+id/info_target"
android:text="@string/info_target_label"
android:drawableLeft="@drawable/ic_home_info_holo_dark"
launcher:strokeColor="#991e3157"
launcher:strokeTextColor="#DDFFFFFF"
launcher:strokeWidth="2.5" />
</FrameLayout>
</LinearLayout>
</com.android.launcher2.SearchDropTargetBar>
+1 -1
View File
@@ -40,7 +40,7 @@
<include layout="@layout/qsb_bar"
android:id="@+id/qsb_bar"
android:layout_width="fill_parent"
android:layout_width="match_parent"
android:layout_height="@dimen/qsb_bar_height"
android:layout_gravity="top" />
+19 -47
View File
@@ -16,10 +16,6 @@
<com.android.launcher2.AppsCustomizeTabHost
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher">
<com.android.launcher2.AllAppsBackground
android:id="@+id/all_apps_background"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
@@ -28,57 +24,33 @@
with the text in the tabs in AppsCustomizeTabHost. -->
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="@dimen/apps_customize_tab_bar_height"
android:layout_height="@dimen/qsb_bar_height"
android:layout_gravity="center_horizontal">
<com.android.launcher2.FocusOnlyTabWidget
android:id="@android:id/tabs"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="left"
android:background="@drawable/tab_unselected_holo"
android:tabStripEnabled="false" />
<FrameLayout
<TextView
style="@style/MarketButton"
android:id="@+id/market_button"
android:onClick="onClickAppMarketButton"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="right">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:visibility="gone">
<com.android.launcher2.ApplicationInfoDropTarget
android:id="@+id/all_apps_info_target"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:drawableLeft="@drawable/ic_home_info_holo_dark"
android:background="@drawable/focusable_view_bg"
android:focusable="true"
android:visibility="gone" />
<com.android.launcher2.DeleteZone
style="@style/DeleteZone"
android:id="@+id/all_apps_delete_zone"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:background="@drawable/focusable_view_bg"
android:focusable="true"
android:visibility="gone"
launcher:direction="horizontal" />
</LinearLayout>
<TextView
style="@style/MarketButton"
android:id="@+id/market_button"
android:onClick="onClickAppMarketButton"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:background="@drawable/tab_widget_indicator_selector"
android:focusable="true"
android:clickable="true" />
</FrameLayout>
android:layout_gravity="right"
android:gravity="center"
android:text="@string/market"
android:textColor="@color/workspace_all_apps_and_delete_zone_text_color"
android:textSize="18sp"
android:shadowColor="@color/workspace_all_apps_and_delete_zone_text_shadow_color"
android:shadowDx="0.0"
android:shadowDy="0.0"
android:shadowRadius="2.0"
android:background="@drawable/tab_widget_indicator_selector"
android:focusable="true"
android:clickable="true" />
</FrameLayout>
<FrameLayout
android:id="@android:id/tabcontent"
@@ -87,7 +59,7 @@
<com.android.launcher2.AppsCustomizePagedView
android:id="@+id/apps_customize_pane_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
launcher:cellCountX="@integer/all_apps_view_cellCountX"
launcher:cellCountY="@integer/all_apps_view_cellCountY"
launcher:pageLayoutWidthGap="@dimen/all_apps_view_pageLayoutWidthGap"
+11
View File
@@ -38,6 +38,17 @@
android:adjustViewBounds="true"
android:scaleType="fitStart" />
<!-- The divider image. -->
<ImageView
style="WidgetDivider"
android:id="@+id/divider"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:src="@drawable/widget_divider" />
<!-- The name of the widget. -->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget_name"
+8 -2
View File
@@ -75,7 +75,10 @@
style="@style/DropTargetButton"
android:id="@+id/delete_target"
android:text="@string/delete_zone_label_workspace"
android:drawableLeft="@drawable/delete_zone_selector" />
android:drawableLeft="@drawable/delete_zone_selector"
launcher:strokeColor="#991e3157"
launcher:strokeTextColor="#DDFFFFFF"
launcher:strokeWidth="2.5" />
</FrameLayout>
<FrameLayout
@@ -86,7 +89,10 @@
style="@style/DropTargetButton"
android:id="@+id/info_target"
android:text="@string/info_target_label"
android:drawableLeft="@drawable/ic_home_info_holo_dark" />
android:drawableLeft="@drawable/ic_home_info_holo_dark"
launcher:strokeColor="#991e3157"
launcher:strokeTextColor="#DDFFFFFF"
launcher:strokeWidth="2.5" />
</FrameLayout>
</LinearLayout>
</com.android.launcher2.SearchDropTargetBar>
+8 -1
View File
@@ -15,11 +15,18 @@
-->
<resources>
<dimen name="apps_customize_cell_width">96dp</dimen>
<dimen name="apps_customize_cell_height">96dp</dimen>
<!-- The amount of space to account for the next/prev pages when
calculating the number of columns to fit a page.
In portrait/large we use apps_customize_cell_width / 8. -->
<dimen name="apps_customize_peek_width">12dp</dimen>
<!-- the area at the edge of the screen that makes the workspace go left
or right while you're dragging. -->
<dimen name="scroll_zone">40dp</dimen>
<dimen name="all_apps_view_pageLayoutWidthGap">36dp</dimen>
<dimen name="all_apps_view_pageLayoutWidthGap">24dp</dimen>
<dimen name="all_apps_view_pageLayoutHeightGap">36dp</dimen>
<dimen name="all_apps_view_pageLayoutPaddingTop">25dp</dimen>
<dimen name="all_apps_view_pageLayoutPaddingBottom">10dp</dimen>
+1 -1
View File
@@ -7,7 +7,7 @@
<integer name="config_customizeZoomScaleFactor">7</integer>
<integer name="config_customizeFadeInTime">800</integer>
<!-- Out of 100, the percent to shrink the workspace during spring loaded mode. -->
<integer name="config_workspaceSpringLoadShrinkPercentage">70</integer>
<integer name="config_workspaceSpringLoadShrinkPercentage">90</integer>
<!-- The slope, in percent, of the drag movement needed to drag an item out of
Customize (y / x * 100%) -->
+10
View File
@@ -15,8 +15,18 @@
-->
<resources>
<!-- Workspace -->
<dimen name="qsb_bar_height">56dp</dimen>
<dimen name="apps_customize_cell_width">96dp</dimen>
<dimen name="apps_customize_cell_height">96dp</dimen>
<!-- The amount of space to account for the next/prev pages when
calculating the number of columns to fit a page.
In landscape/large we use apps_customize_cell_width / 4. -->
<dimen name="apps_customize_peek_width">48dp</dimen>
<dimen name="apps_customize_widget_cell_width_gap">36dp</dimen>
<dimen name="apps_customize_widget_cell_height_gap">36dp</dimen>
<dimen name="workspace_cell_width">96dip</dimen>
<dimen name="workspace_cell_height">96dip</dimen>
+10
View File
@@ -26,4 +26,14 @@
<!-- Negative button text for the wallpaper selection dialog [CHAR_LIMIT=40]-->
<string name="wallpaper_cancel">Cancel</string>
<!-- Label for delete drop target. [CHAR_LIMIT=30] -->
<string name="delete_target_label">Remove</string>
<!-- Label for uninstall drop target. [CHAR_LIMIT=30]-->
<string name="delete_target_uninstall_label">Uninstall</string>
<!-- Label for the info icon. [CHAR_LIMIT=30] -->
<string name="info_target_label">Manage</string>
<!-- Market button text [CHAR LIMIT=32] -->
<string name="market">Shop</string>
</resources>
+36 -1
View File
@@ -42,10 +42,14 @@
<item name="android:includeFontPadding">false</item>
</style>
<style name="WidgetDivider">
<item name="android:visibility">visible</item>
</style>
<style name="TabIndicator.Wide">
<item name="android:paddingLeft">40dp</item>
<item name="android:paddingRight">40dp</item>
<item name="android:paddingTop">15dp</item>
<item name="android:paddingTop">10dp</item>
<item name="android:paddingBottom">20dp</item>
<item name="android:textSize">20sp</item>
</style>
@@ -53,6 +57,37 @@
<style name="CustomizeTabIndicator.Wide" parent="TabIndicator.Wide">
</style>
<!-- QSB Search / Drop Target bar -->
<style name="SearchDropTargetBar">
<item name="android:orientation">horizontal</item>
</style>
<style name="SearchButton">
<item name="android:layout_gravity">center_vertical</item>
<item name="android:paddingTop">@dimen/toolbar_button_vertical_padding</item>
<item name="android:paddingBottom">@dimen/toolbar_button_vertical_padding</item>
<item name="android:paddingLeft">@dimen/toolbar_button_horizontal_padding</item>
<item name="android:paddingRight">@dimen/toolbar_button_horizontal_padding</item>
</style>
<style name="SearchButtonDivider">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">match_parent</item>
<item name="android:layout_gravity">center_vertical</item>
</style>
<style name="DropTargetButtonContainer">
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">match_parent</item>
</style>
<style name="DropTargetButton">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">match_parent</item>
<item name="android:layout_gravity">center_horizontal</item>
<item name="android:gravity">center_vertical</item>
<item name="android:drawablePadding">7.5dp</item>
<item name="android:paddingTop">@dimen/toolbar_button_vertical_padding</item>
<item name="android:paddingBottom">@dimen/toolbar_button_vertical_padding</item>
</style>
<style name="config_orientation">
<item name="@android:screenOrientation">unspecified</item>
</style>
+26
View File
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<!-- The amount of space to account for the next/prev pages when
calculating the number of columns to fit a page.
In portrait/xlarge we use apps_customize_cell_width / 4. -->
<dimen name="apps_customize_peek_width">48dp</dimen>
<!-- We can also afford to have a slightly wider portrait layout in
xlarge -->
<dimen name="all_apps_view_pageLayoutWidthGap">36dp</dimen>
</resources>
-1
View File
@@ -104,7 +104,6 @@
<attr name="pageLayoutPaddingBottom" format="dimension" />
<attr name="pageLayoutPaddingLeft" format="dimension" />
<attr name="pageLayoutPaddingRight" format="dimension" />
<attr name="pageLayoutMaxHeight" format="dimension" />
<!-- The space between adjacent pages of the PagedView. -->
<attr name="pageSpacing" format="dimension" />
</declare-styleable>
+4
View File
@@ -27,6 +27,10 @@
<dimen name="app_icon_size">50dp</dimen>
<dimen name="apps_customize_cell_width">68dp</dimen>
<dimen name="apps_customize_cell_height">68dp</dimen>
<!-- In portrat/normal, we peek only 1/8th the app cell width -->
<dimen name="apps_customize_peek_width">9dp</dimen>
<dimen name="apps_customize_widget_cell_width_gap">10dp</dimen>
<dimen name="apps_customize_widget_cell_height_gap">10dp</dimen>
<dimen name="title_texture_width">120px</dimen>
<!-- height of the tab bar in AppsCustomize -->
+2 -2
View File
@@ -83,8 +83,8 @@
<string name="all_apps_no_games">No games found.</string>
<!-- Message to show when there are no downloaded apps [CHAR_LIMIT=50] -->
<string name="all_apps_no_downloads">You have no downloaded applications.</string>
<!-- Market button text [CHAR LIMIT=32] -->
<string name="market">Shop</string>
<!-- Market button text. The market button has no text in the Phone UI. [CHAR LIMIT=32] -->
<string name="market"></string>
<!-- Customization Drawer -->
<!-- The format string for the dimensions of a widget in the drawer -->
+4
View File
@@ -68,6 +68,10 @@
<item name="android:layout_marginRight">10dip</item>
</style>
<style name="WidgetDivider">
<item name="android:visibility">gone</item>
</style>
<style name="SearchDropTargetBar">
<item name="android:orientation">horizontal</item>
</style>
@@ -208,7 +208,6 @@ public class AllAppsPagedView extends PagedViewWithDraggableItems implements All
@Override
public void setup(Launcher launcher, DragController dragController) {
mLauncher = launcher;
mLauncher.setAllAppsPagedView(this);
mDragController = dragController;
}
@@ -50,15 +50,13 @@ public class ApplicationInfoDropTarget extends IconDropTarget {
int colour = getContext().getResources().getColor(R.color.info_target_hover_tint);
mHoverPaint.setColorFilter(new PorterDuffColorFilter(colour, PorterDuff.Mode.SRC_ATOP));
if (LauncherApplication.isScreenLarge()) {
// For the application info drop target, we just ignore the left padding since we don't want
// to overlap with the delete zone padding
int tb = getResources().getDimensionPixelSize(
R.dimen.delete_zone_vertical_drag_padding);
int lr = getResources().getDimensionPixelSize(
R.dimen.delete_zone_horizontal_drag_padding);
setDragPadding(tb, lr, tb, 0);
}
// For the application info drop target, we just ignore the left padding since we don't want
// to overlap with the delete zone padding
int tb = getResources().getDimensionPixelSize(
R.dimen.delete_zone_vertical_drag_padding);
int lr = getResources().getDimensionPixelSize(
R.dimen.delete_zone_horizontal_drag_padding);
setDragPadding(tb, lr, tb, 0);
}
public boolean acceptDrop(DragObject d) {
@@ -16,11 +16,8 @@
package com.android.launcher2;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.animation.ValueAnimator;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProviderInfo;
@@ -30,12 +27,13 @@ import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.Bitmap.Config;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
@@ -44,8 +42,6 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
@@ -88,9 +84,10 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
private IconCache mIconCache;
// Dimens
private Runnable mOnSizeChangedCallback;
private int mContentWidth;
private int mMaxWidgetSpan, mMinWidgetSpan;
private int mCellWidthGap, mCellHeightGap;
private int mWidgetWidthGap, mWidgetHeightGap;
private int mWidgetCountX, mWidgetCountY;
private final int mWidgetPreviewIconPaddedDimension;
private final float sWidgetPreviewIconPaddingPercentage = 0.25f;
@@ -120,23 +117,19 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
mDefaultWidgetBackground = resources.getDrawable(R.drawable.default_widget_preview);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PagedView, 0, 0);
// TODO-APPS_CUSTOMIZE: remove these unnecessary attrs after
mCellCountX = a.getInt(R.styleable.PagedView_cellCountX, 6);
mCellCountY = a.getInt(R.styleable.PagedView_cellCountY, 4);
a.recycle();
a = context.obtainStyledAttributes(attrs, R.styleable.AppsCustomizePagedView, 0, 0);
mCellWidthGap =
a.getDimensionPixelSize(R.styleable.AppsCustomizePagedView_widgetCellWidthGap, 10);
mCellHeightGap =
a.getDimensionPixelSize(R.styleable.AppsCustomizePagedView_widgetCellHeightGap, 10);
mWidgetWidthGap =
a.getDimensionPixelSize(R.styleable.AppsCustomizePagedView_widgetCellWidthGap, 0);
mWidgetHeightGap =
a.getDimensionPixelSize(R.styleable.AppsCustomizePagedView_widgetCellHeightGap, 0);
mWidgetCountX = a.getInt(R.styleable.AppsCustomizePagedView_widgetCountX, 2);
mWidgetCountY = a.getInt(R.styleable.AppsCustomizePagedView_widgetCountY, 2);
a.recycle();
// Create a dummy page that we can use to approximate the cell dimensions of widgets and
// the content width (to be used by our parent)
mWidgetSpacingLayout = new PagedViewCellLayout(context);
setupPage(mWidgetSpacingLayout);
mContentWidth = mWidgetSpacingLayout.getContentWidth();
mWidgetSpacingLayout = new PagedViewCellLayout(getContext());
// The max widget span is the length N, such that NxN is the largest bounds that the widget
// preview can be before applying the widget scaling
@@ -160,6 +153,70 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
setDragSlopeThreshold(r.getInteger(R.integer.config_appsCustomizeDragSlopeThreshold)/100f);
}
@Override
protected void onWallpaperTap(android.view.MotionEvent ev) {
mLauncher.showWorkspace(true);
}
/**
* This differs from isDataReady as this is the test done if isDataReady is not set.
*/
private boolean testDataReady() {
return !mApps.isEmpty() && !mWidgets.isEmpty();
}
protected void onDataReady(int width, int height) {
// Note that we transpose the counts in portrait so that we get a similar layout
boolean isLandscape = getResources().getConfiguration().orientation ==
Configuration.ORIENTATION_LANDSCAPE;
int maxCellCountX = Integer.MAX_VALUE;
int maxCellCountY = Integer.MAX_VALUE;
if (LauncherApplication.isScreenLarge()) {
maxCellCountX = (isLandscape ? LauncherModel.getCellCountX() :
LauncherModel.getCellCountY());
maxCellCountY = (isLandscape ? LauncherModel.getCellCountY() :
LauncherModel.getCellCountX());
}
// Now that the data is ready, we can calculate the content width, the number of cells to
// use for each page
mWidgetSpacingLayout.setGap(mPageLayoutWidthGap, mPageLayoutHeightGap);
mWidgetSpacingLayout.setPadding(mPageLayoutPaddingLeft, mPageLayoutPaddingTop,
mPageLayoutPaddingRight, mPageLayoutPaddingBottom);
mWidgetSpacingLayout.calculateCellCount(width, height, maxCellCountX, maxCellCountY);
mCellCountX = mWidgetSpacingLayout.getCellCountX();
mCellCountY = mWidgetSpacingLayout.getCellCountY();
mWidgetCountX = Math.max(1, (int) Math.round(mCellCountX / 2f));
mWidgetCountY = Math.max(1, (int) Math.round(mCellCountY / 3f));
mContentWidth = mWidgetSpacingLayout.getContentWidth();
// Notify our parent so that we can synchronize the tab bar width to this page width
if (mOnSizeChangedCallback != null) {
mOnSizeChangedCallback.run();
}
invalidatePageData();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int width = MeasureSpec.getSize(widthMeasureSpec);
int height = MeasureSpec.getSize(heightMeasureSpec);
if (!isDataReady()) {
if (testDataReady()) {
setDataIsReady();
setMeasuredDimension(width, height);
onDataReady(width, height);
}
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
public void setOnSizeChangedCallback(Runnable r) {
mOnSizeChangedCallback = r;
}
/** Removes and returns the ResolveInfo with the specified ComponentName */
private ResolveInfo removeResolveInfoWithComponentName(List<ResolveInfo> list,
ComponentName cn) {
@@ -179,108 +236,20 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
public void onPackagesUpdated() {
// Get the list of widgets and shortcuts
mWidgets.clear();
mWidgets.addAll(AppWidgetManager.getInstance(mLauncher).getInstalledProviders());
Intent shortcutsIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT);
mWidgets.addAll(mPackageManager.queryIntentActivities(shortcutsIntent, 0));
Collections.sort(mWidgets,
List<AppWidgetProviderInfo> widgets =
AppWidgetManager.getInstance(mLauncher).getInstalledProviders();
Collections.sort(widgets,
new LauncherModel.WidgetAndShortcutNameComparator(mPackageManager));
}
Intent shortcutsIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT);
List<ResolveInfo> shortcuts = mPackageManager.queryIntentActivities(shortcutsIntent, 0);
Collections.sort(shortcuts,
new LauncherModel.WidgetAndShortcutNameComparator(mPackageManager));
mWidgets.addAll(widgets);
mWidgets.addAll(shortcuts);
/**
* Animates the given item onto the center of a home screen, and then scales the item to
* look as though it's disappearing onto that screen.
*/
private void animateItemOntoScreen(View dragView,
final CellLayout layout, final ItemInfo info) {
// On the phone, we only want to fade the widget preview out
float[] position = new float[2];
position[0] = layout.getWidth() / 2;
position[1] = layout.getHeight() / 2;
mLauncher.getWorkspace().mapPointFromChildToSelf(layout, position);
int dragViewWidth = dragView.getMeasuredWidth();
int dragViewHeight = dragView.getMeasuredHeight();
float heightOffset = 0;
float widthOffset = 0;
if (dragView instanceof ImageView) {
Drawable d = ((ImageView) dragView).getDrawable();
int width = d.getIntrinsicWidth();
int height = d.getIntrinsicHeight();
if ((1.0 * width / height) >= (1.0f * dragViewWidth) / dragViewHeight) {
float f = (dragViewWidth / (width * 1.0f));
heightOffset = ANIMATION_SCALE * (dragViewHeight - f * height) / 2;
} else {
float f = (dragViewHeight / (height * 1.0f));
widthOffset = ANIMATION_SCALE * (dragViewWidth - f * width) / 2;
}
}
final float toX = position[0] - dragView.getMeasuredWidth() / 2 + widthOffset;
final float toY = position[1] - dragView.getMeasuredHeight() / 2 + heightOffset;
final DragLayer dragLayer = (DragLayer) mLauncher.findViewById(R.id.drag_layer);
final View dragCopy = dragLayer.createDragView(dragView);
dragCopy.setAlpha(1.0f);
// Translate the item to the center of the appropriate home screen
animateIntoPosition(dragCopy, toX, toY, null);
// The drop-onto-screen animation begins a bit later, but ends at the same time.
final int startDelay = TRANSLATE_ANIM_DURATION - DROP_ANIM_DURATION;
// Scale down the icon and fade out the alpha
animateDropOntoScreen(dragCopy, info, DROP_ANIM_DURATION, startDelay);
}
/**
* Animation which scales the view down and animates its alpha, making it appear to disappear
* onto a home screen.
*/
private void animateDropOntoScreen(
final View view, final ItemInfo info, int duration, int delay) {
final DragLayer dragLayer = (DragLayer) mLauncher.findViewById(R.id.drag_layer);
final CellLayout layout = mLauncher.getWorkspace().getCurrentDropLayout();
ObjectAnimator anim = ObjectAnimator.ofPropertyValuesHolder(view,
PropertyValuesHolder.ofFloat("alpha", 1.0f, 0.0f),
PropertyValuesHolder.ofFloat("scaleX", ANIMATION_SCALE),
PropertyValuesHolder.ofFloat("scaleY", ANIMATION_SCALE));
anim.setInterpolator(new LinearInterpolator());
if (delay > 0) {
anim.setStartDelay(delay);
}
anim.setDuration(duration);
anim.addListener(new AnimatorListenerAdapter() {
public void onAnimationEnd(Animator animation) {
dragLayer.removeView(view);
mLauncher.addExternalItemToScreen(info, layout);
info.dropPos = null;
}
});
anim.start();
}
/**
* Animates the x,y position of the view, and optionally execute a Runnable on animation end.
*/
private void animateIntoPosition(
View view, float toX, float toY, final Runnable endRunnable) {
ObjectAnimator anim = ObjectAnimator.ofPropertyValuesHolder(view,
PropertyValuesHolder.ofFloat("x", toX),
PropertyValuesHolder.ofFloat("y", toY));
anim.setInterpolator(new DecelerateInterpolator(2.5f));
anim.setDuration(TRANSLATE_ANIM_DURATION);
if (endRunnable != null) {
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
endRunnable.run();
}
});
}
anim.start();
// The next layout pass will trigger data-ready if both widgets and apps are set, so request
// a layout to do this test and invalidate the page data when ready.
if (testDataReady()) requestLayout();
}
@Override
@@ -324,24 +293,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
// Make a copy of the ApplicationInfo
ApplicationInfo appInfo = new ApplicationInfo((ApplicationInfo) v.getTag());
// Show the uninstall button if the app is uninstallable.
if ((appInfo.flags & ApplicationInfo.DOWNLOADED_FLAG) != 0) {
DeleteZone allAppsDeleteZone = (DeleteZone)
mLauncher.findViewById(R.id.all_apps_delete_zone);
allAppsDeleteZone.setDragAndDropEnabled(true);
if ((appInfo.flags & ApplicationInfo.UPDATED_SYSTEM_APP_FLAG) != 0) {
allAppsDeleteZone.setText(R.string.delete_zone_label_all_apps_system_app);
} else {
allAppsDeleteZone.setText(R.string.delete_zone_label_all_apps);
}
}
// Show the info button
ApplicationInfoDropTarget allAppsInfoButton =
(ApplicationInfoDropTarget) mLauncher.findViewById(R.id.all_apps_info_target);
allAppsInfoButton.setDragAndDropEnabled(true);
// Compose the drag image (top compound drawable, index is 1)
final TextView tv = (TextView) v;
final Drawable icon = tv.getCompoundDrawables()[1];
@@ -542,6 +493,10 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
int y = index / mCellCountX;
layout.addViewToCellLayout(icon, -1, i, new PagedViewCellLayout.LayoutParams(x,y, 1,1));
}
// Create the hardware layers
layout.allowHardwareLayerCreation();
layout.createHardwareLayers();
}
/*
* Widgets PagedView implementation
@@ -585,14 +540,11 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
// We only need to make it wide enough so as not allow the preview to be scaled
int expectedWidth = cellWidth;
int expectedHeight = mWidgetPreviewIconPaddedDimension;
int offset = (int) (iconSize * sWidgetPreviewIconPaddingPercentage);
// Render the icon
Bitmap preview = Bitmap.createBitmap(expectedWidth, expectedHeight, Config.ARGB_8888);
Drawable icon = mIconCache.getFullResIcon(info, mPackageManager);
renderDrawableToBitmap(mDefaultWidgetBackground, preview, 0, 0,
mWidgetPreviewIconPaddedDimension, mWidgetPreviewIconPaddedDimension, 1f, 1f);
renderDrawableToBitmap(icon, preview, offset, offset, iconSize, iconSize, 1f, 1f);
renderDrawableToBitmap(icon, preview, 0, 0, iconSize, iconSize, 1f, 1f);
FastBitmapDrawable iconDrawable = new FastBitmapDrawable(preview);
iconDrawable.setBounds(0, 0, expectedWidth, expectedHeight);
mWidgetPreviewCache.put(info, preview);
@@ -706,9 +658,9 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
int numPages = (int) Math.ceil(mWidgets.size() / (float) numWidgetsPerPage);
int offset = page * numWidgetsPerPage;
int cellWidth = ((mWidgetSpacingLayout.getContentWidth() - mPageLayoutWidthGap
- ((mWidgetCountX - 1) * mCellWidthGap)) / mWidgetCountX);
- ((mWidgetCountX - 1) * mWidgetWidthGap)) / mWidgetCountX);
int cellHeight = ((mWidgetSpacingLayout.getContentHeight() - mPageLayoutHeightGap
- ((mWidgetCountY - 1) * mCellHeightGap)) / mWidgetCountY);
- ((mWidgetCountY - 1) * mWidgetHeightGap)) / mWidgetCountY);
for (int i = 0; i < Math.min(numWidgetsPerPage, mWidgets.size() - offset); ++i) {
Object rawInfo = mWidgets.get(offset + i);
PendingAddItemInfo createItemInfo = null;
@@ -746,8 +698,8 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
int iy = i / mWidgetCountX;
PagedViewGridLayout.LayoutParams lp = new PagedViewGridLayout.LayoutParams(cellWidth,
cellHeight);
lp.leftMargin = (ix * cellWidth) + (ix * mCellWidthGap);
lp.topMargin = (iy * cellHeight) + (iy * mCellHeightGap);
lp.leftMargin = (ix * cellWidth) + (ix * mWidgetWidthGap);
lp.topMargin = (iy * cellHeight) + (iy * mWidgetHeightGap);
layout.addView(widget, lp);
}
}
@@ -836,7 +788,10 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
public void setApps(ArrayList<ApplicationInfo> list) {
mApps = list;
Collections.sort(mApps, LauncherModel.APP_NAME_COMPARATOR);
invalidatePageData();
// The next layout pass will trigger data-ready if both widgets and apps are set, so request
// a layout to do this test and invalidate the page data when ready.
if (testDataReady()) requestLayout();
}
private void addAppsWithoutInvalidate(ArrayList<ApplicationInfo> list) {
// We add it in place, in alphabetical order
@@ -16,6 +16,7 @@
package com.android.launcher2;
import android.animation.Animator;
import android.content.Context;
import android.content.res.Resources;
import android.util.AttributeSet;
@@ -36,6 +37,7 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
private static final String WIDGETS_TAB_TAG = "WIDGETS";
private final LayoutInflater mLayoutInflater;
private ViewGroup mTabs;
private AppsCustomizePagedView mAppsCustomizePane;
public AppsCustomizeTabHost(Context context, AttributeSet attrs) {
@@ -43,6 +45,9 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
mLayoutInflater = LayoutInflater.from(context);
}
/**
* Convenience methods to select specific tabs
*/
void selectAppsTab() {
setCurrentTabByTag(APPS_TAB_TAG);
}
@@ -61,6 +66,7 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
final ViewGroup tabs = (ViewGroup) findViewById(com.android.internal.R.id.tabs);
final AppsCustomizePagedView appsCustomizePane = (AppsCustomizePagedView)
findViewById(R.id.apps_customize_pane_content);
mTabs = tabs;
mAppsCustomizePane = appsCustomizePane;
if (tabs == null || mAppsCustomizePane == null) throw new Resources.NotFoundException();
@@ -81,9 +87,18 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
tabView.setText(mContext.getString(R.string.widgets_tab_label));
addTab(newTabSpec(WIDGETS_TAB_TAG).setIndicator(tabView).setContent(contentFactory));
setOnTabChangedListener(this);
}
// Set the width of the tab bar to match the content (for now)
tabs.getLayoutParams().width = mAppsCustomizePane.getPageContentWidth();
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
boolean remeasureTabWidth = (mTabs.getLayoutParams().width <= 0);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
// Set the width of the tab list to the content width
if (remeasureTabWidth) {
mTabs.getLayoutParams().width = mAppsCustomizePane.getPageContentWidth();
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
@Override
@@ -138,11 +153,21 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
/* LauncherTransitionable overrides */
@Override
public void onLauncherTransitionStart(android.animation.Animator animation) {
// TODO-APPS_CUSTOMIZE: see AllAppsTabbed.onLauncherTransitionStart();
public void onLauncherTransitionStart(Animator animation) {
if (animation != null) {
// Turn on hardware layers for performance
setLayerType(LAYER_TYPE_HARDWARE, null);
// force building the layer at the beginning of the animation, so you don't get a
// blip early in the animation
buildLayer();
}
}
@Override
public void onLauncherTransitionEnd(android.animation.Animator animation) {
// TODO-APPS_CUSTOMIZE: see AllAppsTabbed.onLauncherTransitionEnd();
public void onLauncherTransitionEnd(Animator animation) {
if (animation != null) {
setLayerType(LAYER_TYPE_NONE, null);
}
}
}
@@ -86,7 +86,7 @@ public class DeleteDropTarget extends IconDropTarget {
boolean isVisible = true;
boolean isUninstall = false;
// If we are dragging a widget from AppsCustomize , hide the delete target
// If we are dragging a widget from AppsCustomize, hide the delete target
if (isAllAppsWidget(source, info)) {
isVisible = false;
}
@@ -28,7 +28,7 @@ import android.widget.TextView;
* Implements a DropTarget which allows applications to be dropped on it,
* in order to launch the application info for that app.
*/
public class IconDropTarget extends TextView implements DropTarget, DragController.DragListener {
public class IconDropTarget extends StrokedTextView implements DropTarget, DragController.DragListener {
protected Launcher mLauncher;
/**
File diff suppressed because it is too large. Load diff
@@ -29,7 +29,6 @@ public class LauncherApplication extends Application {
public IconCache mIconCache;
private static boolean sIsScreenLarge;
private static float sScreenDensity;
private static final boolean ENABLE_ROTATION = false;
@Override
public void onCreate() {
@@ -98,10 +97,6 @@ public class LauncherApplication extends Application {
return mModel;
}
public static boolean isInPlaceRotationEnabled() {
return sIsScreenLarge && ENABLE_ROTATION;
}
public static boolean isScreenLarge() {
return sIsScreenLarge;
}
+32 -24
View File
@@ -77,7 +77,6 @@ public abstract class PagedView extends ViewGroup {
protected int mCurrentPage;
protected int mNextPage = INVALID_PAGE;
protected int mRestorePage = -1;
protected int mMaxScrollX;
protected Scroller mScroller;
private VelocityTracker mVelocityTracker;
@@ -112,7 +111,6 @@ public abstract class PagedView extends ViewGroup {
protected int mPageLayoutPaddingRight;
protected int mPageLayoutWidthGap;
protected int mPageLayoutHeightGap;
protected int mPageLayoutMaxHeight;
protected int mCellCountX = 0;
protected int mCellCountY = 0;
protected boolean mCenterPagesVertically;
@@ -161,6 +159,9 @@ public abstract class PagedView extends ViewGroup {
protected boolean mIsPageMoving = false;
// All syncs and layout passes are deferred until data is ready.
protected boolean mIsDataReady = false;
public interface PageSwitchListener {
void onPageSwitch(View newPage, int newPageIndex);
}
@@ -192,8 +193,6 @@ public abstract class PagedView extends ViewGroup {
R.styleable.PagedView_pageLayoutWidthGap, -1);
mPageLayoutHeightGap = a.getDimensionPixelSize(
R.styleable.PagedView_pageLayoutHeightGap, -1);
mPageLayoutMaxHeight = a.getDimensionPixelSize(
R.styleable.PagedView_pageLayoutMaxHeight, -1);
a.recycle();
setHapticFeedbackEnabled(false);
@@ -223,6 +222,17 @@ public abstract class PagedView extends ViewGroup {
}
}
/**
* Called by subclasses to mark that data is ready, and that we can begin loading and laying
* out pages.
*/
protected void setDataIsReady() {
mIsDataReady = true;
}
protected boolean isDataReady() {
return mIsDataReady;
}
/**
* Returns the index of the currently displayed page.
*
@@ -244,10 +254,6 @@ public abstract class PagedView extends ViewGroup {
return getWidth();
}
public int getTouchState() {
return mTouchState;
}
/**
* Updates the scroll of the current page immediately to its final scroll position. We use this
* in CustomizePagedView to allow tabs to share the same PagedView while resetting the scroll of
@@ -376,6 +382,11 @@ public abstract class PagedView extends ViewGroup {
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (!mIsDataReady) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
return;
}
final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
final int widthSize = MeasureSpec.getSize(widthMeasureSpec);
if (widthMode != MeasureSpec.EXACTLY) {
@@ -393,9 +404,6 @@ public abstract class PagedView extends ViewGroup {
final int verticalPadding = mPaddingTop + mPaddingBottom;
if (mPageLayoutMaxHeight != -1) {
heightSize = Math.min(mPageLayoutMaxHeight, heightSize);
}
// The children are given the same width and height as the workspace
// unless they were set to WRAP_CONTENT
@@ -489,6 +497,10 @@ public abstract class PagedView extends ViewGroup {
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
if (!mIsDataReady) {
return;
}
if (DEBUG) Log.d(TAG, "PagedView.onLayout()");
if (mFirstLayout && mCurrentPage >= 0 && mCurrentPage < getChildCount()) {
setHorizontalScrollBarEnabled(false);
@@ -560,10 +572,14 @@ public abstract class PagedView extends ViewGroup {
if (distanceFromScreenCenter > 0) {
if (i > 0) {
d += getScaledMeasuredWidth(getChildAt(i - 1)) / 2;
} else {
continue;
}
} else {
if (i < childCount - 1) {
d += getScaledMeasuredWidth(getChildAt(i + 1)) / 2;
} else {
continue;
}
}
d += mPageSpacing;
@@ -839,7 +855,6 @@ public abstract class PagedView extends ViewGroup {
}
case MotionEvent.ACTION_UP:
onWallpaperTap(ev);
case MotionEvent.ACTION_CANCEL:
mTouchState = TOUCH_STATE_REST;
mAllowLongPress = false;
@@ -1176,8 +1191,7 @@ public abstract class PagedView extends ViewGroup {
}
}
protected void onWallpaperTap(MotionEvent ev) {
}
protected void onWallpaperTap(MotionEvent ev) {}
@Override
public void requestChildFocus(View child, View focused) {
@@ -1537,10 +1551,6 @@ public abstract class PagedView extends ViewGroup {
}
}
public void setRestorePage(int restorePage) {
mRestorePage = restorePage;
}
/**
* This method is called ONLY to synchronize the number of pages that the paged view has.
* To actually fill the pages with information, implement syncPageItems() below. It is
@@ -1568,6 +1578,10 @@ public abstract class PagedView extends ViewGroup {
}
protected void invalidatePageData() {
if (!mIsDataReady) {
return;
}
if (mContentIsRefreshable) {
// Update all the pages
syncPages();
@@ -1579,12 +1593,6 @@ public abstract class PagedView extends ViewGroup {
mDirtyPageContent.add(true);
}
// Use the restore page if necessary
if (mRestorePage > -1) {
mCurrentPage = mRestorePage;
mRestorePage = -1;
}
// Load any pages that are necessary for the current window of views
loadAssociatedPages(mCurrentPage);
mDirtyPageAlpha = true;
@@ -40,6 +40,7 @@ public class PagedViewCellLayout extends ViewGroup implements Page {
private int mCellHeight;
private int mWidthGap;
private int mHeightGap;
private float mPeekWidth;
protected PagedViewCellLayoutChildren mChildren;
private PagedViewCellLayoutChildren mHolographicChildren;
private boolean mAllowHardwareLayerCreation = false;
@@ -62,6 +63,7 @@ public class PagedViewCellLayout extends ViewGroup implements Page {
Resources resources = context.getResources();
mCellWidth = resources.getDimensionPixelSize(R.dimen.apps_customize_cell_width);
mCellHeight = resources.getDimensionPixelSize(R.dimen.apps_customize_cell_height);
mPeekWidth = resources.getDimensionPixelSize(R.dimen.apps_customize_peek_width);
mCellCountX = LauncherModel.getCellCountX();
mCellCountY = LauncherModel.getCellCountY();
mWidthGap = mHeightGap = -1;
@@ -229,11 +231,11 @@ public class PagedViewCellLayout extends ViewGroup implements Page {
int vSpaceLeft = heightSpecSize - mPaddingTop
- mPaddingBottom - (cellHeight * mCellCountY);
int heightGap = vSpaceLeft / numHeightGaps;
int heightGap = (numHeightGaps <= 0) ? 0 : (vSpaceLeft / numHeightGaps);
int hSpaceLeft = widthSpecSize - mPaddingLeft
- mPaddingRight - (cellWidth * mCellCountX);
int widthGap = hSpaceLeft / numWidthGaps;
int widthGap = (numWidthGaps <= 0) ? 0 : (hSpaceLeft / numWidthGaps);
// center it around the min gaps
int minGap = Math.min(widthGap, heightGap);
@@ -271,15 +273,7 @@ public class PagedViewCellLayout extends ViewGroup implements Page {
}
int getContentWidth() {
if (LauncherApplication.isScreenLarge()) {
// Return the distance from the left edge of the content of the leftmost icon to
// the right edge of the content of the rightmost icon
// icons are centered within cells, find out how much padding that accounts for
return getWidthBeforeFirstLayout() - (mCellWidth - Utilities.getIconContentSize());
} else {
return getWidthBeforeFirstLayout() + mPaddingLeft + mPaddingRight;
}
return getWidthBeforeFirstLayout() + mPaddingLeft + mPaddingRight;
}
int getContentHeight() {
@@ -308,7 +302,20 @@ public class PagedViewCellLayout extends ViewGroup implements Page {
@Override
public boolean onTouchEvent(MotionEvent event) {
return super.onTouchEvent(event) || true;
boolean result = super.onTouchEvent(event);
int count = getPageChildCount();
if (count > 0) {
// We only intercept the touch if we are tapping in empty space after the final row
View child = getChildOnPageAt(count - 1);
int bottom = child.getBottom();
int numRows = (int) Math.ceil((float) getPageChildCount() / getCellCountX());
if (numRows < getCellCountY()) {
// Add a little bit of buffer if there is room for another row
bottom += mCellHeight / 2;
}
result = result || (event.getY() < bottom);
}
return result;
}
public void enableCenteredContent(boolean enabled) {
@@ -361,16 +368,37 @@ public class PagedViewCellLayout extends ViewGroup implements Page {
* Estimates the number of cells that the specified width would take up.
*/
public int estimateCellHSpan(int width) {
// TODO: we need to take widthGap into effect
return (width + mCellWidth) / mCellWidth;
// The space for a page assuming that we want to show half of a column of the previous and
// next pages is the width - left padding (current & next page) - right padding (previous &
// current page) - half cell width (for previous and next pages)
int availWidth = (int) (width - (2 * mPaddingLeft + 2 * mPaddingRight) - (2 * mPeekWidth));
// We know that we have to fit N cells with N-1 width gaps, so we just juggle to solve for N
int n = Math.max(1, (availWidth + mWidthGap) / (mCellWidth + mWidthGap));
// We don't do anything fancy to determine if we squeeze another row in.
return n;
}
/**
* Estimates the number of cells that the specified height would take up.
*/
public int estimateCellVSpan(int height) {
// TODO: we need to take heightGap into effect
return (height + mCellHeight) / mCellHeight;
// The space for a page is the height - top padding (current page) - bottom padding (current
// page)
int availHeight = height - (mPaddingTop + mPaddingBottom);
// We know that we have to fit N cells with N-1 height gaps, so we juggle to solve for N
int n = Math.max(1, (availHeight + mHeightGap) / (mCellHeight + mHeightGap));
// We don't do anything fancy to determine if we squeeze another row in.
return n;
}
public void calculateCellCount(int width, int height, int maxCellCountX, int maxCellCountY) {
mCellCountX = Math.min(maxCellCountX, estimateCellHSpan(width));
mCellCountY = Math.min(maxCellCountY, estimateCellVSpan(height));
requestLayout();
}
/**
@@ -59,14 +59,15 @@ public class PagedViewGridLayout extends FrameLayout implements Page {
@Override
public boolean onTouchEvent(MotionEvent event) {
// We eat up the touch events here, since the PagedView (which uses the same swiping
// touch code as Workspace previously) uses onInterceptTouchEvent() to determine when
// the user is scrolling between pages. This means that if the pages themselves don't
// handle touch events, it gets forwarded up to PagedView itself, and it's own
// onTouchEvent() handling will prevent further intercept touch events from being called
// (it's the same view in that case). This is not ideal, but to prevent more changes,
// we just always mark the touch event as handled.
return super.onTouchEvent(event) || true;
boolean result = super.onTouchEvent(event);
int count = getPageChildCount();
if (count > 0) {
// We only intercept the touch if we are tapping in empty space after the final row
View child = getChildOnPageAt(count - 1);
int bottom = child.getBottom();
result = result || (event.getY() < bottom);
}
return result;
}
@Override
@@ -33,8 +33,9 @@ import com.android.launcher.R;
public class SearchDropTargetBar extends FrameLayout implements DragController.DragListener {
private static final int sTransitionInDuration = 275;
private static final int sTransitionOutDuration = 200;
private static final int sTransitionOutDuration = 100;
private boolean mIsSearchBarHidden;
private View mQSBSearchBar;
private View mDropTargetBar;
private IconDropTarget mInfoDropTarget;
@@ -69,20 +70,54 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
mDeleteDropTarget = (IconDropTarget) mDropTargetBar.findViewById(R.id.delete_target);
}
/*
* Shows and hides the search bar.
*/
public void showSearchBar(boolean animated) {
if (animated) {
mQSBSearchBar.animate().alpha(1f).setDuration(sTransitionInDuration);
} else {
mQSBSearchBar.setAlpha(1f);
}
mIsSearchBarHidden = false;
}
public void hideSearchBar(boolean animated) {
if (animated) {
mQSBSearchBar.animate().alpha(0f).setDuration(sTransitionOutDuration);
} else {
mQSBSearchBar.setAlpha(0f);
}
mIsSearchBarHidden = true;
}
/*
* Gets various transition durations.
*/
public int getTransitionInDuration() {
return sTransitionInDuration;
}
public int getTransitionOutDuration() {
return sTransitionOutDuration;
}
/*
* DragController.DragListener implementation
*/
@Override
public void onDragStart(DragSource source, Object info, int dragAction) {
// Animate out the QSB search bar, and animate in the drop target bar
mQSBSearchBar.animate().alpha(0f).setDuration(sTransitionOutDuration);
mDropTargetBar.animate().alpha(1f).setDuration(sTransitionInDuration);
if (!mIsSearchBarHidden) {
mQSBSearchBar.animate().alpha(0f).setDuration(sTransitionOutDuration);
}
}
@Override
public void onDragEnd() {
// Restore the QSB search bar, and animate out the drop target bar
mDropTargetBar.animate().alpha(0f).setDuration(sTransitionOutDuration);
mQSBSearchBar.animate().alpha(1f).setDuration(sTransitionInDuration);
if (!mIsSearchBarHidden) {
mQSBSearchBar.animate().alpha(1f).setDuration(sTransitionInDuration);
}
}
}
+17 -150
View File
@@ -106,17 +106,12 @@ public class Workspace extends SmoothPagedView
private ValueAnimator mBackgroundFadeInAnimation;
private ValueAnimator mBackgroundFadeOutAnimation;
private Drawable mBackground;
private Drawable mCustomizeTrayBackground;
boolean mDrawBackground = true;
private boolean mDrawCustomizeTrayBackground;
private float mBackgroundAlpha = 0;
private float mOverScrollMaxBackgroundAlpha = 0.0f;
private int mOverScrollPageIndex = -1;
private View mCustomizationDrawer;
private View mCustomizationDrawerContent;
private int[] mCustomizationDrawerPos = new int[2];
private float[] mCustomizationDrawerTransformedPos = new float[2];
private final WallpaperManager mWallpaperManager;
private IBinder mWindowToken;
@@ -173,7 +168,7 @@ public class Workspace extends SmoothPagedView
private boolean mIsInUnshrinkAnimation = false;
private AnimatorListener mShrinkAnimationListener;
private AnimatorListener mUnshrinkAnimationListener;
enum ShrinkState { TOP, SPRING_LOADED, MIDDLE, BOTTOM_HIDDEN, BOTTOM_VISIBLE };
enum ShrinkState { SPRING_LOADED, MIDDLE, BOTTOM_HIDDEN, BOTTOM_VISIBLE };
private ShrinkState mShrinkState;
private boolean mWaitingToShrink = false;
private ShrinkState mWaitingToShrinkState;
@@ -257,6 +252,9 @@ public class Workspace extends SmoothPagedView
super(context, attrs, defStyle);
mContentIsRefreshable = false;
// With workspace, data is available straight from the get-go
setDataIsReady();
if (!LauncherApplication.isScreenLarge()) {
mFadeInAdjacentScreens = false;
}
@@ -330,7 +328,6 @@ public class Workspace extends SmoothPagedView
try {
final Resources res = getResources();
mBackground = res.getDrawable(R.drawable.all_apps_bg_gradient);
mCustomizeTrayBackground = res.getDrawable(R.drawable.customize_bg_gradient);
} catch (Resources.NotFoundException e) {
// In this case, we will skip drawing background protection
}
@@ -345,8 +342,12 @@ public class Workspace extends SmoothPagedView
public void onAnimationEnd(Animator animation) {
mIsInUnshrinkAnimation = false;
mSyncWallpaperOffsetWithScroll = true;
if (mShrinkState != ShrinkState.SPRING_LOADED) {
mDrawCustomizeTrayBackground = false;
if (mShrinkState == ShrinkState.SPRING_LOADED) {
View layout = null;
if (mLastDragView != null) {
layout = findMatchingPageForDragOver(mLastDragView, mLastDragOriginX,
mLastDragOriginY, mLastDragXOffset, mLastDragYOffset);
}
}
mWallpaperOffset.setOverrideHorizontalCatchupConstant(false);
mAnimator = null;
@@ -598,24 +599,6 @@ public class Workspace extends SmoothPagedView
mYDown = ev.getY();
}
if (mIsSmall || mIsInUnshrinkAnimation) {
if (mLauncher.isAllAppsVisible() && mShrinkState == ShrinkState.BOTTOM_HIDDEN) {
// Intercept this event so we can show the workspace in full view
// when it is clicked on and it is small
PagedView appsPane = null;
if (LauncherApplication.isScreenLarge()) {
appsPane = (PagedView) mLauncher.findViewById(R.id.all_apps_paged_view);
} else {
appsPane = (PagedView) mLauncher.findViewById(R.id.apps_customize_pane_content);
}
if (appsPane != null) {
appsPane.onInterceptTouchEvent(ev);
}
return true;
}
return false;
}
return super.onInterceptTouchEvent(ev);
}
@@ -1000,12 +983,6 @@ public class Workspace extends SmoothPagedView
private void showBackgroundGradientForAllApps() {
showBackgroundGradient();
mDrawCustomizeTrayBackground = false;
}
private void showBackgroundGradientForCustomizeTray() {
showBackgroundGradient();
mDrawCustomizeTrayBackground = true;
}
private void showBackgroundGradient() {
@@ -1169,12 +1146,6 @@ public class Workspace extends SmoothPagedView
}
});
}
if (LauncherApplication.isInPlaceRotationEnabled()) {
// When the device is rotated, the scroll position of the current screen
// needs to be refreshed
setCurrentPage(getCurrentPage());
}
}
public void showFolderAccept(FolderRingAnimator fra) {
@@ -1195,33 +1166,10 @@ public class Workspace extends SmoothPagedView
// Draw the background gradient if necessary
if (mBackground != null && mBackgroundAlpha > 0.0f && mDrawBackground) {
int alpha = (int) (mBackgroundAlpha * 255);
if (mDrawCustomizeTrayBackground) {
// Find out where to offset the gradient for the customization tray content
mCustomizationDrawer.getLocationOnScreen(mCustomizationDrawerPos);
final Matrix m = mCustomizationDrawer.getMatrix();
mCustomizationDrawerTransformedPos[0] = 0.0f;
mCustomizationDrawerTransformedPos[1] = mCustomizationDrawerContent.getTop();
m.mapPoints(mCustomizationDrawerTransformedPos);
// Draw the bg glow behind the gradient
mCustomizeTrayBackground.setAlpha(alpha);
mCustomizeTrayBackground.setBounds(mScrollX, 0, mScrollX + getMeasuredWidth(),
getMeasuredHeight());
mCustomizeTrayBackground.draw(canvas);
// Draw the bg gradient
final int offset = (int) (mCustomizationDrawerPos[1] +
mCustomizationDrawerTransformedPos[1]);
mBackground.setAlpha(alpha);
mBackground.setBounds(mScrollX, offset, mScrollX + getMeasuredWidth(),
offset + getMeasuredHeight());
mBackground.draw(canvas);
} else {
mBackground.setAlpha(alpha);
mBackground.setBounds(mScrollX, 0, mScrollX + getMeasuredWidth(),
getMeasuredHeight());
mBackground.draw(canvas);
}
mBackground.setAlpha(alpha);
mBackground.setBounds(mScrollX, 0, mScrollX + getMeasuredWidth(),
getMeasuredHeight());
mBackground.draw(canvas);
}
// The folder outer / inner ring image(s)
@@ -1401,39 +1349,6 @@ public class Workspace extends SmoothPagedView
}
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
if (mLauncher.isAllAppsVisible() && mShrinkState == ShrinkState.BOTTOM_HIDDEN) {
PagedView appsPane;
if (LauncherApplication.isScreenLarge()) {
appsPane = (PagedView) mLauncher.findViewById(R.id.all_apps_paged_view);
} else {
appsPane = (PagedView) mLauncher.findViewById(R.id.apps_customize_pane_content);
}
if (appsPane != null) {
if (ev.getAction() == MotionEvent.ACTION_UP &&
appsPane.getTouchState() == TOUCH_STATE_REST) {
// Cancel any scrolling that is in progress.
if (!mScroller.isFinished()) {
mScroller.abortAnimation();
}
setCurrentPage(mCurrentPage);
if (mShrinkState == ShrinkState.BOTTOM_HIDDEN) {
mLauncher.showWorkspace(true);
}
appsPane.onTouchEvent(ev);
return true;
} else {
return appsPane.onTouchEvent(ev);
}
}
}
return super.onTouchEvent(ev);
}
protected void enableChildrenLayers(boolean enable) {
for (int i = 0; i < getPageCount(); i++) {
((ViewGroup)getChildAt(i)).setChildrenLayersEnabled(enable);
@@ -1488,18 +1403,6 @@ public class Workspace extends SmoothPagedView
shrink(shrinkState, true);
}
private int getCustomizeDrawerHeight() {
TabHost customizationDrawer = mLauncher.getCustomizationDrawer();
int height = customizationDrawer.getHeight();
TabWidget tabWidget = (TabWidget)
customizationDrawer.findViewById(com.android.internal.R.id.tabs);
if (tabWidget.getTabCount() > 0) {
TextView tabText = (TextView) tabWidget.getChildTabViewAt(0);
// subtract the empty space above the tab text
height -= ((tabWidget.getHeight() - tabText.getLineHeight())) / 2;
}
return height;
}
// we use this to shrink the workspace for the all apps view and the customize view
public void shrink(ShrinkState shrinkState, boolean animated) {
@@ -1571,8 +1474,6 @@ public class Workspace extends SmoothPagedView
} else if (shrinkState == ShrinkState.MIDDLE) {
y = screenHeight / 2 - scaledPageHeight / 2;
finalAlpha = 1.0f;
} else if (shrinkState == ShrinkState.TOP) {
y = (screenHeight - getCustomizeDrawerHeight() - scaledPageHeight) / 2;
}
int duration;
@@ -1667,11 +1568,6 @@ public class Workspace extends SmoothPagedView
if (enableWallpaperEffects) {
switch (shrinkState) {
// animating in
case TOP:
// customize
wallpaperOffset = 0.5f + offsetFromCenter;
mWallpaperOffset.setVerticalCatchupConstant(isLandscape ? 0.46f : 0.44f);
break;
case MIDDLE:
case SPRING_LOADED:
wallpaperOffset = 0.5f;
@@ -1740,11 +1636,7 @@ public class Workspace extends SmoothPagedView
}
setChildrenDrawnWithCacheEnabled(true);
if (shrinkState == ShrinkState.TOP) {
showBackgroundGradientForCustomizeTray();
} else {
showBackgroundGradientForAllApps();
}
showBackgroundGradientForAllApps();
}
/*
@@ -1826,14 +1718,10 @@ public class Workspace extends SmoothPagedView
cl.setAcceptsDrops(cl.findCellForSpan(null, spanX, spanY));
} else {
switch (state) {
case TOP:
cl.setIsDefaultDropTarget(i == mCurrentPage);
case BOTTOM_HIDDEN:
case BOTTOM_VISIBLE:
case SPRING_LOADED:
if (state != ShrinkState.TOP) {
cl.setIsDefaultDropTarget(false);
}
cl.setIsDefaultDropTarget(false);
if (!isDragHappening) {
// even if a drag isn't happening, we don't want to show a screen as
// accepting drops if it doesn't have at least one free cell
@@ -2045,14 +1933,6 @@ public class Workspace extends SmoothPagedView
if (enableWallpaperEffects) {
switch (mShrinkState) {
// animating out
case TOP:
// customize
if (animated) {
mWallpaperOffset.setHorizontalCatchupConstant(isLandscape ? 0.65f : 0.62f);
mWallpaperOffset.setVerticalCatchupConstant(isLandscape ? 0.65f : 0.62f);
mWallpaperOffset.setOverrideHorizontalCatchupConstant(true);
}
break;
case MIDDLE:
case SPRING_LOADED:
if (animated) {
@@ -2541,13 +2421,6 @@ public class Workspace extends SmoothPagedView
if (d.dragSource != this) {
final int[] touchXY = new int[] { (int) mDragViewVisualCenter[0],
(int) mDragViewVisualCenter[1] };
if (LauncherApplication.isScreenLarge() && (mIsSmall || mIsInUnshrinkAnimation)
&& !mLauncher.isAllAppsVisible()) {
// When the workspace is shrunk and the drop comes from customize, don't actually
// add the item to the screen -- customize will do this itself
((ItemInfo) d.dragInfo).dropPos = touchXY;
return;
}
onDropExternal(touchXY, d.dragInfo, dropTargetLayout, false, d.dragView);
} else if (mDragInfo != null) {
final View cell = mDragInfo.cell;
@@ -3367,12 +3240,6 @@ public class Workspace extends SmoothPagedView
void setup(Launcher launcher, DragController dragController) {
mLauncher = launcher;
mSpringLoadedDragController = new SpringLoadedDragController(mLauncher);
mCustomizationDrawer = mLauncher.findViewById(R.id.customization_drawer);
if (mCustomizationDrawer != null) {
mCustomizationDrawerContent =
mCustomizationDrawer.findViewById(com.android.internal.R.id.tabcontent);
}
mDragController = dragController;
}