Cleaning up dead code.

Change-Id: I922e20b41d19ca9936c75277ba7c58a291d297fa
This commit is contained in:
Winson Chung
2011-06-23 13:04:10 -07:00
parent 845149a05a
commit 4e076545e4
37 changed files with 28 additions and 6144 deletions
@@ -1,36 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/no_items_icon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:paddingTop="2dip"
android:textColor="#FFFFFFFF"
android:textSize="15sp"
android:shadowColor="#FF000000"
android:shadowDx="0.0"
android:shadowDy="1.0"
android:shadowRadius="1.0"
android:drawablePadding="0dip"
android:maxLines="2"
android:fadingEdge="horizontal"
android:focusable="false" />
@@ -1,32 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<com.android.launcher2.PagedViewIcon
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
launcher:blurColor="#FF6B8CF0"
launcher:outlineColor="#FF8CD2FF"
style="@style/WorkspaceIcon.AppsCustomize"
android:id="@+id/application_icon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:focusable="true"
android:background="@drawable/focusable_view_bg" />
-115
View File
@@ -1,115 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<com.android.launcher2.AllAppsTabbed
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"
android:layout_height="match_parent">
<!-- The layout_width of this RelativeLayout gets overwritten in
AllAppsTabbed.onFinishInflate -->
<RelativeLayout
android:id="@+id/all_apps_tab_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="@drawable/tab_unselected_holo">
<com.android.launcher2.FocusOnlyTabWidget
android:id="@android:id/tabs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:tabStripEnabled="false" />
<FrameLayout
android:id="@+id/market_info_frame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true">
<com.android.launcher2.ApplicationInfoDropTarget
android:id="@+id/all_apps_info_target"
android:drawableRight="@drawable/ic_home_info_holo_dark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="invisible"
android:background="@drawable/focusable_view_bg"
android:focusable="true" />
<TextView
android:id="@+id/market_button"
android:onClick="onClickAppMarketButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:paddingRight="22dp"
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/focusable_view_bg"
android:focusable="true"
android:clickable="true" />
</FrameLayout>
<com.android.launcher2.DeleteZone
android:id="@+id/all_apps_delete_zone"
android:drawablePadding="@dimen/delete_zone_drawable_padding"
android:drawableLeft="@drawable/delete_zone_selector"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/market_info_frame"
android:layout_centerVertical="true"
android:visibility="invisible"
android:paddingRight="22dp"
launcher:direction="horizontal"
android:gravity="center"
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/focusable_view_bg"
android:focusable="true" />
</RelativeLayout>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.android.launcher2.AllAppsPagedView
android:id="@+id/all_apps_paged_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
launcher:pageLayoutWidthGap="@dimen/all_apps_view_pageLayoutWidthGap"
launcher:pageLayoutHeightGap="@dimen/all_apps_view_pageLayoutHeightGap"
launcher:pageLayoutPaddingTop="@dimen/all_apps_view_pageLayoutPaddingTop"
launcher:pageLayoutPaddingBottom="@dimen/all_apps_view_pageLayoutPaddingBottom"
launcher:pageLayoutPaddingLeft="@dimen/all_apps_view_pageLayoutPaddingLeft"
launcher:pageLayoutPaddingRight="@dimen/all_apps_view_pageLayoutPaddingRight">
</com.android.launcher2.AllAppsPagedView>
</FrameLayout>
</LinearLayout>
</com.android.launcher2.AllAppsTabbed>
-51
View File
@@ -1,51 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<com.android.launcher2.CustomizeTrayTabHost
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- The layout_width of this RelativeLayout gets overwritten in
CustomizeTrayTabHost.onFinishInflate -->
<com.android.launcher2.FocusOnlyTabWidget
android:id="@android:id/tabs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="@drawable/tab_unselected_holo"
android:tabStripEnabled="false" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.android.launcher2.CustomizePagedView
android:id="@+id/customization_drawer_tab_contents"
android:layout_width="match_parent"
android:layout_height="match_parent"
launcher:wallpaperCellSpanX="@integer/customization_drawer_contents_wallpaperCellSpanX"
launcher:wallpaperCellCountX="@integer/customization_drawer_contents_wallpaperCellCountX"
launcher:widgetCellCountX="@integer/customization_drawer_contents_widgetCellCountX"
launcher:pageLayoutWidthGap="@dimen/customization_drawer_contents_pageLayoutWidthGap"
launcher:pageLayoutHeightGap="@dimen/customization_drawer_contents_pageLayoutHeightGap"
launcher:pageLayoutPaddingTop="@dimen/customization_drawer_contents_pageLayoutPaddingTop"
launcher:pageLayoutPaddingBottom="@dimen/customization_drawer_contents_pageLayoutPaddingBottom"
launcher:pageLayoutPaddingLeft="@dimen/customization_drawer_contents_pageLayoutPaddingLeft"
launcher:pageLayoutPaddingRight="@dimen/customization_drawer_contents_pageLayoutPaddingRight" />
</FrameLayout>
</LinearLayout>
</com.android.launcher2.CustomizeTrayTabHost>
@@ -1,31 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<com.android.launcher2.PagedViewIcon
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
launcher:blurColor="#FF6B8CF0"
launcher:outlineColor="#FF8CD2FF"
android:id="@+id/customize_icon"
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/WorkspaceIcon.Landscape"
android:background="@drawable/focusable_view_bg"
android:focusable="true" />
@@ -1,69 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<com.android.launcher2.PagedViewWidget
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:paddingRight="25dp"
android:paddingBottom="50dp"
launcher:blurColor="#FF6B8CF0"
launcher:outlineColor="#FF8CD2FF"
android:background="@drawable/focusable_view_bg"
android:focusable="true">
<!-- The preview image for the wallpaper. -->
<ImageView
android:id="@+id/wallpaper_preview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:adjustViewBounds="true"
android:scaleType="fitStart" />
<!-- The divider image. -->
<ImageView
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 wallpaper -->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/wallpaper_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="left"
android:textColor="#FFFFFFFF"
android:textSize="14sp"
android:shadowColor="#FF000000"
android:shadowDx="0.0"
android:shadowDy="1.0"
android:shadowRadius="1.0"
android:maxLines="2"
android:fadingEdge="horizontal" />
</com.android.launcher2.PagedViewWidget>
@@ -1,85 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<com.android.launcher2.PagedViewWidget
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:paddingRight="25dp"
android:paddingBottom="50dp"
launcher:blurColor="#FF6B8CF0"
launcher:outlineColor="#FF8CD2FF"
android:background="@drawable/focusable_view_bg"
android:focusable="true">
<!-- The icon of the widget. -->
<ImageView
android:id="@+id/widget_preview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:adjustViewBounds="true"
android:scaleType="fitStart" />
<!-- The divider image. -->
<ImageView
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"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="left"
android:textColor="#FFFFFFFF"
android:textSize="14sp"
android:shadowColor="#FF000000"
android:shadowDx="0.0"
android:shadowDy="1.0"
android:shadowRadius="1.0"
android:maxLines="2"
android:fadingEdge="horizontal" />
<!-- The original dimensions of the widget (can't be the same text as above due to different
style. -->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget_dims"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="left"
android:textColor="#FF999999"
android:textSize="14sp"
android:shadowColor="#99000000"
android:shadowDx="0.0"
android:shadowDy="1.0"
android:shadowRadius="1.0" />
</com.android.launcher2.PagedViewWidget>
@@ -1,19 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<com.android.launcher2.AccessibleTabView
xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/CustomizeTabIndicator.Wide" />
-2
View File
@@ -43,6 +43,4 @@
<dimen name="apps_customize_widget_cell_height_gap">0dp</dimen>
<integer name="apps_customize_widget_cell_count_x">3</integer>
<integer name="apps_customize_widget_cell_count_y">1</integer>
<integer name="apps_customize_wallpaper_cell_count_x">3</integer>
<integer name="apps_customize_wallpaper_cell_count_y">1</integer>
</resources>
-12
View File
@@ -33,16 +33,4 @@
<dimen name="all_apps_view_pageLayoutPaddingBottom">14dp</dimen>
<dimen name="all_apps_view_pageLayoutPaddingLeft">40dp</dimen>
<dimen name="all_apps_view_pageLayoutPaddingRight">40dp</dimen>
<!-- Dimensions for customize should generally be the same as all apps, or very similar. -->
<dimen name="customization_drawer_contents_pageLayoutWidthGap">32dp</dimen>
<dimen name="customization_drawer_contents_pageLayoutHeightGap">12dp</dimen>
<dimen name="customization_drawer_contents_pageLayoutPaddingTop">20dp</dimen>
<dimen name="customization_drawer_contents_pageLayoutPaddingBottom">20dp</dimen>
<dimen name="customization_drawer_contents_pageLayoutPaddingLeft">40dp</dimen>
<dimen name="customization_drawer_contents_pageLayoutPaddingRight">40dp</dimen>
<integer name="customization_drawer_contents_wallpaperCellSpanX">3</integer>
<integer name="customization_drawer_contents_wallpaperCellCountX">12</integer>
<integer name="customization_drawer_contents_widgetCellCountX">14</integer>
</resources>
-12
View File
@@ -41,16 +41,4 @@
<dimen name="all_apps_view_pageLayoutPaddingBottom">10dp</dimen>
<dimen name="all_apps_view_pageLayoutPaddingLeft">20dp</dimen>
<dimen name="all_apps_view_pageLayoutPaddingRight">20dp</dimen>
<integer name="customization_drawer_contents_wallpaperCellSpanX">3</integer>
<integer name="customization_drawer_contents_wallpaperCellCountX">9</integer>
<integer name="customization_drawer_contents_widgetCellCountX">9</integer>
<!-- Dimensions for customize should generally be the same as all apps, or very similar. -->
<dimen name="customization_drawer_contents_pageLayoutWidthGap">36dp</dimen>
<dimen name="customization_drawer_contents_pageLayoutHeightGap">12dp</dimen>
<dimen name="customization_drawer_contents_pageLayoutPaddingTop">25dp</dimen>
<dimen name="customization_drawer_contents_pageLayoutPaddingBottom">25dp</dimen>
<dimen name="customization_drawer_contents_pageLayoutPaddingLeft">20dp</dimen>
<dimen name="customization_drawer_contents_pageLayoutPaddingRight">20dp</dimen>
</resources>
-28
View File
@@ -1,28 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
* Copyright (C) 2008 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>
<style name="CustomizeTabIndicator.Wide" parent="TabIndicator.Wide">
<item name="android:paddingLeft">20dp</item>
<item name="android:paddingRight">20dp</item>
<item name="android:paddingTop">12dp</item>
<item name="android:paddingBottom">16dp</item>
<item name="android:textSize">16sp</item>
</style>
</resources>
-14
View File
@@ -39,7 +39,6 @@
<!-- Size of icons in workspace -->
<dimen name="app_icon_size">72dp</dimen>
<!-- Size of content of icons in workspace, as specified by the android icon guidelines -->
<dimen name="app_icon_content_size">60dp</dimen>
@@ -55,9 +54,6 @@
<dimen name="all_apps_button_drawable_padding">0dip</dimen>
<dimen name="all_apps_button_vertical_padding">4dip</dimen>
<integer name="land_all_apps_view_cellCountX">7</integer>
<integer name="land_all_apps_view_cellCountY">5</integer>
<!-- height & width of the drop rectangle for the trash icon -->
<dimen name="delete_zone_vertical_drag_padding">20dip</dimen>
<dimen name="delete_zone_horizontal_drag_padding">20dip</dimen>
@@ -82,16 +78,6 @@
<dimen name="dragViewOffsetX">0dp</dimen>
<dimen name="dragViewOffsetY">-12dp</dimen>
<!-- The actual number of rows/columns will be determined dynamically based on the screen
size, but in portrait we want to cap the rows at 3, otherwise it looks weird. -->
<integer name="customization_drawer_contents_maxCellCountY">3</integer>
<!-- The percentage of vertical space that the customize tray should try to fill. -->
<integer name="customization_drawer_verticalFillPercentage">65</integer>
<!-- Max number of rows in all apps, because too many looks weird. -->
<integer name="all_apps_view_maxCellCountY">6</integer>
<!-- Workspace grid -->
<!-- Padding applied to AppWidgets -->
<dimen name="app_widget_padding_left">12dp</dimen>
-4
View File
@@ -75,10 +75,6 @@
<item name="android:textSize">20sp</item>
</style>
<style name="CustomizeTabIndicator.Wide" parent="TabIndicator.Wide">
</style>
<!-- QSB Search / Drop Target bar -->
<style name="SearchDropTargetBar">
<item name="android:orientation">horizontal</item>
-2
View File
@@ -40,6 +40,4 @@
<dimen name="apps_customize_widget_cell_height_gap">40dp</dimen>
<integer name="apps_customize_widget_cell_count_x">2</integer>
<integer name="apps_customize_widget_cell_count_y">2</integer>
<integer name="apps_customize_wallpaper_cell_count_x">1</integer>
<integer name="apps_customize_wallpaper_cell_count_y">1</integer>
</resources>
-25
View File
@@ -1,25 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<resources>
<style name="CustomizeTabIndicator.Wide" parent="TabIndicator.Wide">
<item name="android:paddingLeft">20dp</item>
<item name="android:paddingRight">20dp</item>
</style>
</resources>
-23
View File
@@ -1,23 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<resources>
<style name="CustomizeTabIndicator.Wide" parent="TabIndicator.Wide">
</style>
</resources>
-18
View File
@@ -114,24 +114,6 @@
<attr name="widgetCountY" format="integer" />
</declare-styleable>
<!-- CustomizePagedView specific attributes. These attributes are used to customize
a CustomizePagedView view in XML files. -->
<declare-styleable name="CustomizePagedView">
<!-- The cell span of an item in the wallpapers tab -->
<attr name="wallpaperCellSpanX" format="integer" />
<!-- The max cell span of all items in a particular wallpaper tab page -->
<attr name="wallpaperCellCountX" format="integer" />
<!-- The number of horizontal cells for the widget tab -->
<attr name="widgetCellCountX" format="integer" />
</declare-styleable>
<!-- DeleteZone specific attributes. These attributes are used to customize
a DeleteZone view in XML files. -->
<declare-styleable name="DeleteZone">
<!-- Orientation of the delete zone. -->
<attr name="direction" />
</declare-styleable>
<!-- HandleView specific attributes. These attributes are used to customize
a HandleView view in XML files. -->
<declare-styleable name="HandleView">
-6
View File
@@ -57,12 +57,6 @@
<dimen name="allAppsSmallScreenVerticalMarginLandscape">30dip</dimen>
<dimen name="allAppsSmallScreenVerticalMarginPortrait">60dip</dimen>
<!-- height & width of the drop rectangle for the trash icon -->
<dimen name="delete_zone_size">70dip</dimen>
<!-- delete_zone_size_full - button_bar_height_portrait -->
<dimen name="delete_zone_padding">14dip</dimen>
<!-- padding between the delete zone drawable and text -->
<dimen name="delete_zone_drawable_padding">8dip</dimen>
-17
View File
@@ -64,30 +64,13 @@
<string name="applications_tab_label">App shortcuts</string>
<!-- Placeholder text, will be removed -->
<string name="wallpapers_temp_tab_text">This will be the wallpapers tab</string>
<!-- Labels for the tabs in All Apps -->
<!-- Title of the tab for all applications (includes games and non-games) [CHAR_LIMIT=12] -->
<string name="all_apps_tab_all">All</string>
<!-- Title of the tab for all applications *except* games [CHAR_LIMIT=24] -->
<string name="all_apps_tab_apps">Apps</string>
<!-- Title of the tab for applications labeled as games [CHAR_LIMIT=24] -->
<string name="all_apps_tab_games">Games</string>
<!-- Tile of the tab for applications that were downloaded from market [CHAR_LIMIT=24] -->
<string name="all_apps_tab_downloaded">My apps</string>
<!-- AppsCustomize pane -->
<!-- Message to tell the user to long-press on a widget to add it [CHAR_LIMIT=50] -->
<string name="long_press_widget_to_add">Long-press to pick up a widget</string>
<!-- All Apps pane -->
<!-- Message to show when there are no games [CHAR_LIMIT=25] -->
<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. The market button text is removed in Launcher.java
in the Phone UI. [CHAR LIMIT=32] -->
<string name="market">Shop</string>
<!-- Customization Drawer -->
<!-- The format string for the dimensions of a widget in the drawer -->
<string name="widget_dims_format" translatable="false">%1$d x %2$d</string>
-12
View File
@@ -135,18 +135,6 @@
<item name="android:shadowRadius">2.0</item>
</style>
<style name="DeleteZone">
<item name="android:drawableLeft">@drawable/delete_zone_selector</item>
<item name="android:drawablePadding">@dimen/delete_zone_drawable_padding</item>
<item name="android:paddingRight">20dp</item>
<item name="android:textColor">@color/workspace_all_apps_and_delete_zone_text_color</item>
<item name="android:textSize">18sp</item>
<item name="android:shadowColor">@color/workspace_all_apps_and_delete_zone_text_shadow_color</item>
<item name="android:shadowDx">0.0</item>
<item name="android:shadowDy">0.0</item>
<item name="android:shadowRadius">2.0</item>
</style>
<style name="HotseatButton">
<item name="android:paddingLeft">12dip</item>
<item name="android:paddingRight">12dip</item>
-348
View File
@@ -1,348 +0,0 @@
/*
* Copyright (C) 2008 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.launcher2;
import android.content.ComponentName;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.android.launcher.R;
import com.android.launcher2.DropTarget.DragObject;
import java.util.ArrayList;
import java.util.Collections;
public class AllApps2D
extends RelativeLayout
implements AllAppsView,
AdapterView.OnItemClickListener,
AdapterView.OnItemLongClickListener,
View.OnKeyListener,
DragSource {
private static final String TAG = "Launcher.AllApps2D";
private static final boolean DEBUG = false;
private Launcher mLauncher;
private DragController mDragController;
private GridView mGrid;
/** All applications in the system (we might only be showing a subset) */
private ArrayList<ApplicationInfo> mAllAppsList = new ArrayList<ApplicationInfo>();
/** Currently visible applications in the grid */
private ArrayList<ApplicationInfo> mVisibleAppsList = new ArrayList<ApplicationInfo>();
public enum AppType { APP, GAME, DOWNLOADED, ALL };
private AppType mCurrentFilter = AppType.ALL;
// preserve compatibility with 3D all apps:
// 0.0 -> hidden
// 1.0 -> shown and opaque
// intermediate values -> partially shown & partially opaque
private float mZoom;
private AppsAdapter mAppsAdapter;
// ------------------------------------------------------------
public static class HomeButton extends ImageButton {
public HomeButton(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public View focusSearch(int direction) {
if (direction == FOCUS_UP) return super.focusSearch(direction);
return null;
}
}
public class AppsAdapter extends ArrayAdapter<ApplicationInfo> {
private final LayoutInflater mInflater;
public AppsAdapter(Context context, ArrayList<ApplicationInfo> apps) {
super(context, 0, apps);
mInflater = LayoutInflater.from(context);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final ApplicationInfo info = getItem(position);
if (convertView == null) {
convertView = mInflater.inflate(R.layout.application_boxed, parent, false);
}
// if (!info.filtered) {
// info.icon = Utilities.createIconThumbnail(info.icon, getContext());
// info.filtered = true;
// }
final TextView textView = (TextView) convertView;
if (DEBUG) {
Log.d(TAG, "icon bitmap = " + info.iconBitmap
+ " density = " + info.iconBitmap.getDensity());
}
info.iconBitmap.setDensity(Bitmap.DENSITY_NONE);
textView.setCompoundDrawablesWithIntrinsicBounds(null, new BitmapDrawable(info.iconBitmap), null, null);
textView.setText(info.title);
return convertView;
}
}
public AllApps2D(Context context, AttributeSet attrs) {
super(context, attrs);
setVisibility(View.GONE);
setSoundEffectsEnabled(false);
mAppsAdapter = new AppsAdapter(getContext(), mVisibleAppsList);
}
@Override
protected void onFinishInflate() {
try {
mGrid = (GridView)findViewWithTag("all_apps_2d_grid");
if (mGrid == null) throw new Resources.NotFoundException();
mGrid.setOnItemClickListener(this);
mGrid.setOnItemLongClickListener(this);
// The home button is optional; some layouts might not use it
ImageButton homeButton = (ImageButton) findViewWithTag("all_apps_2d_home");
if (homeButton != null) {
homeButton.setOnClickListener(
new View.OnClickListener() {
public void onClick(View v) {
mLauncher.showWorkspace(true);
}
});
}
} catch (Resources.NotFoundException e) {
Log.e(TAG, "Can't find necessary layout elements for AllApps2D");
}
setOnKeyListener(this);
}
public AllApps2D(Context context, AttributeSet attrs, int defStyle) {
this(context, attrs);
}
@Override
public void setup(Launcher launcher, DragController dragController) {
mLauncher = launcher;
mDragController = dragController;
}
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (!isVisible()) return false;
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
mLauncher.showWorkspace(true);
break;
default:
return false;
}
return true;
}
public void onItemClick(AdapterView parent, View v, int position, long id) {
ApplicationInfo app = (ApplicationInfo) parent.getItemAtPosition(position);
mLauncher.startActivitySafely(app.intent, app);
}
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
if (!view.isInTouchMode()) {
return false;
}
ApplicationInfo app = (ApplicationInfo) parent.getItemAtPosition(position);
app = new ApplicationInfo(app);
mDragController.startDrag(view, this, app, DragController.DRAG_ACTION_COPY);
mLauncher.showWorkspace(true);
return true;
}
protected void onFocusChanged(boolean gainFocus, int direction, android.graphics.Rect prev) {
if (gainFocus) {
mGrid.requestFocus();
}
}
@Override
public void onDragViewVisible() {
}
@Override
public void onDropCompleted(View target, DragObject d, boolean success) {
}
/**
* Zoom to the specifed level.
*
* @param zoom [0..1] 0 is hidden, 1 is open
*/
public void zoom(float zoom, boolean animate) {
// Log.d(TAG, "zooming " + ((zoom == 1.0) ? "open" : "closed"));
cancelLongPress();
mZoom = zoom;
if (isVisible()) {
getParent().bringChildToFront(this);
setVisibility(View.VISIBLE);
mGrid.setAdapter(mAppsAdapter);
if (animate) {
startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.all_apps_2d_fade_in));
} else {
onAnimationEnd();
}
} else {
if (animate) {
startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.all_apps_2d_fade_out));
} else {
onAnimationEnd();
}
}
}
protected void onAnimationEnd() {
if (!isVisible()) {
setVisibility(View.GONE);
mGrid.setAdapter(null);
mZoom = 0.0f;
} else {
mZoom = 1.0f;
}
mLauncher.zoomed(mZoom);
}
public boolean isVisible() {
return mZoom > 0.001f;
}
public boolean isAnimating() {
return (getAnimation() != null);
}
public void setApps(ArrayList<ApplicationInfo> list) {
mAllAppsList.clear();
addApps(list);
filterApps(mCurrentFilter);
}
public void addApps(ArrayList<ApplicationInfo> list) {
final int N = list.size();
for (int i=0; i<N; i++) {
final ApplicationInfo item = list.get(i);
int index = Collections.binarySearch(mAllAppsList, item,
LauncherModel.APP_NAME_COMPARATOR);
if (index < 0) {
index = -(index+1);
}
mAllAppsList.add(index, item);
}
filterApps(mCurrentFilter);
}
public void removeApps(ArrayList<ApplicationInfo> list) {
final int N = list.size();
for (int i=0; i<N; i++) {
final ApplicationInfo item = list.get(i);
int index = findAppByComponent(mAllAppsList, item);
if (index >= 0) {
mAllAppsList.remove(index);
} else {
Log.w(TAG, "couldn't find a match for item \"" + item + "\"");
// Try to recover. This should keep us from crashing for now.
}
}
filterApps(mCurrentFilter);
}
public void updateApps(ArrayList<ApplicationInfo> list) {
// Just remove and add, because they may need to be re-sorted.
removeApps(list);
addApps(list);
}
public void filterApps(AppType appType) {
mCurrentFilter = appType;
mAppsAdapter.setNotifyOnChange(false);
mVisibleAppsList.clear();
if (appType == AppType.ALL) {
mVisibleAppsList.addAll(mAllAppsList);
} else if (appType == AppType.DOWNLOADED) {
for (ApplicationInfo info : mAllAppsList) {
if ((info.flags & ApplicationInfo.DOWNLOADED_FLAG) != 0) {
mVisibleAppsList.add(info);
}
}
}
mAppsAdapter.notifyDataSetChanged();
}
private static int findAppByComponent(ArrayList<ApplicationInfo> list, ApplicationInfo item) {
ComponentName component = item.intent.getComponent();
final int N = list.size();
for (int i=0; i<N; i++) {
ApplicationInfo x = list.get(i);
if (x.intent.getComponent().equals(component)) {
return i;
}
}
return -1;
}
public void dumpState() {
ApplicationInfo.dumpApplicationInfoList(TAG, "mAllAppsList", mAllAppsList);
}
public void surrender() {
}
public void reset() {
// Do nothing
}
}
File diff suppressed because it is too large Load Diff
@@ -1,53 +0,0 @@
/*
* 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.
*/
package com.android.launcher2;
import com.android.launcher.R;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
/**
* The background for AllApps which moves independently of the AllApps tray (for example, when we
* transition between AllApps and the Workspace while in spring-loaded mode).
*/
public class AllAppsBackground extends View {
private Drawable mBackground;
public AllAppsBackground(Context context) {
this(context, null);
}
public AllAppsBackground(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public AllAppsBackground(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mBackground = getResources().getDrawable(R.drawable.all_apps_bg_gradient);
}
@Override
public void onDraw(Canvas canvas) {
mBackground.setBounds(mScrollX, 0, mScrollX + getMeasuredWidth(),
getMeasuredHeight());
mBackground.draw(canvas);
}
}
@@ -1,709 +0,0 @@
/*
* 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.
*/
package com.android.launcher2;
import android.content.ComponentName;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.AnimationUtils;
import android.widget.Checkable;
import android.widget.TextView;
import com.android.launcher.R;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
/**
* An implementation of PagedView that populates the pages of the workspace
* with all of the user's applications.
*/
public class AllAppsPagedView extends PagedViewWithDraggableItems implements AllAppsView,
View.OnClickListener, DragSource, DropTarget {
private static final String TAG = "AllAppsPagedView";
private Launcher mLauncher;
private DragController mDragController;
// preserve compatibility with 3D all apps:
// 0.0 -> hidden
// 1.0 -> shown and opaque
// intermediate values -> partially shown & partially opaque
private float mZoom;
// set of all applications
private ArrayList<ApplicationInfo> mApps;
private ArrayList<ApplicationInfo> mFilteredApps;
// the types of applications to filter
static final int ALL_APPS_FLAG = -1;
private int mAppFilter = ALL_APPS_FLAG;
private final LayoutInflater mInflater;
private boolean mAllowHardwareLayerCreation;
private int mPageContentWidth;
private boolean mHasMadeSuccessfulDrop;
private int mLastMeasureWidth = -1;
private int mLastMeasureHeight = -1;
private boolean mWaitingToInitPages = true;
private int mMaxCellCountY;
public AllAppsPagedView(Context context) {
this(context, null);
}
public AllAppsPagedView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public AllAppsPagedView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PagedView, defStyle, 0);
mInflater = LayoutInflater.from(context);
mApps = new ArrayList<ApplicationInfo>();
mFilteredApps = new ArrayList<ApplicationInfo>();
a.recycle();
setSoundEffectsEnabled(false);
final Resources r = context.getResources();
setDragSlopeThreshold(
r.getInteger(R.integer.config_appsCustomizeDragSlopeThreshold) / 100.0f);
mMaxCellCountY = r.getInteger(R.integer.all_apps_view_maxCellCountY);
}
@Override
protected void init() {
super.init();
mCenterPagesVertically = false;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
final int width = MeasureSpec.getSize(widthMeasureSpec);
final int height = MeasureSpec.getSize(heightMeasureSpec);
if (mLastMeasureWidth != width || mLastMeasureHeight != height) {
// Create a dummy page and set it up to find out the content width (used by our parent)
PagedViewCellLayout layout = new PagedViewCellLayout(getContext());
setupPage(layout);
mPageContentWidth = layout.getContentWidth();
mCellCountX = determineCellCountX(width, layout);
mCellCountY = determineCellCountY(height, layout);
mLastMeasureWidth = width;
mLastMeasureHeight = height;
postInvalidatePageData(true);
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
if (mWaitingToInitPages) {
mWaitingToInitPages = false;
postInvalidatePageData(false);
}
super.onLayout(changed, left, top, right, bottom);
}
private int determineCellCountX(int availableWidth, PagedViewCellLayout layout) {
int cellCountX = 0;
final int cellWidth = layout.getCellWidth();
// Subtract padding for current page and adjacent pages
availableWidth -= mPageLayoutPaddingLeft * 2 + mPageLayoutPaddingRight * 2;
availableWidth -= cellWidth; // Assume at least one column
cellCountX = 1 + availableWidth / (cellWidth + mPageLayoutWidthGap);
availableWidth = availableWidth % (cellWidth + mPageLayoutWidthGap);
// Ensures that we show at least 30% of the holo icons on each side
final int minLeftoverWidth = (int) (cellWidth * 0.6f);
// Reserve room for the holo outlines
if (cellCountX <= 4) {
// When we're really tight on space, just pack the icons a bit closer together
final int missingWidth = minLeftoverWidth - availableWidth;
if (missingWidth > 0) {
mPageLayoutWidthGap -= Math.ceil(missingWidth * 1.0f / (cellCountX - 1));
}
} else {
if (cellCountX >= 8) {
// Carve out a few extra columns for very large widths
cellCountX = (int) (cellCountX * 0.9f);
} else if (availableWidth < minLeftoverWidth) {
cellCountX -= 1;
}
}
return cellCountX;
}
private int determineCellCountY(int availableHeight, PagedViewCellLayout layout) {
final int cellHeight = layout.getCellHeight();
final int screenHeight = mLauncher.getResources().getDisplayMetrics().heightPixels;
availableHeight -= mPageLayoutPaddingTop + mPageLayoutPaddingBottom;
availableHeight -= cellHeight; // Assume at least one row
Resources r = getContext().getResources();
float scaleFactor = r.getInteger(R.integer.config_appsCustomizeZoomScaleFactor) / 100f;
availableHeight -= screenHeight * scaleFactor;
if (availableHeight > 0) {
return Math.min(mMaxCellCountY,
1 + availableHeight / (cellHeight + mPageLayoutHeightGap));
}
return 0;
}
int getCellCountX() {
return mCellCountX;
}
int getCellCountY() {
return mCellCountY;
}
void allowHardwareLayerCreation() {
// This is called after the first time we launch into All Apps. Before that point,
// there's no need for hardware layers here since there's a hardware layer set on the
// parent, AllAppsTabbed, during the AllApps transition -- creating hardware layers here
// before the animation is done slows down the animation
if (mAllowHardwareLayerCreation) {
return;
}
mAllowHardwareLayerCreation = true;
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
PagedViewCellLayout page = (PagedViewCellLayout) getChildAt(i);
page.allowHardwareLayerCreation();
}
}
@Override
public void setup(Launcher launcher, DragController dragController) {
mLauncher = launcher;
mDragController = dragController;
}
public void setAppFilter(int filterType) {
mAppFilter = filterType;
if (mApps != null) {
mFilteredApps = rebuildFilteredApps(mApps);
setCurrentPage(0);
invalidatePageData();
}
}
void resetSuccessfulDropFlag() {
mHasMadeSuccessfulDrop = false;
}
@Override
public void zoom(float zoom, boolean animate) {
mZoom = zoom;
cancelLongPress();
if (isVisible()) {
if (animate) {
startAnimation(AnimationUtils.loadAnimation(getContext(),
R.anim.all_apps_2d_fade_in));
} else {
onAnimationEnd();
}
} else {
if (animate) {
startAnimation(AnimationUtils.loadAnimation(getContext(),
R.anim.all_apps_2d_fade_out));
} else {
onAnimationEnd();
}
}
}
protected void onAnimationEnd() {
if (!isVisible()) {
mZoom = 0.0f;
endChoiceMode();
} else {
mZoom = 1.0f;
}
if (mLauncher != null)
mLauncher.zoomed(mZoom);
}
private int getChildIndexForGrandChild(View v) {
final int childCount = getChildCount();
for (int i = 0; i < childCount; ++i) {
final Page layout = (Page) getChildAt(i);
if (layout.indexOfChildOnPage(v) > -1) {
return i;
}
}
return -1;
}
@Override
public void onClick(View v) {
// if we are already in a choice mode, then just change the selection
if (v instanceof Checkable) {
if (!isChoiceMode(CHOICE_MODE_NONE)) {
Checkable c = (Checkable) v;
if (isChoiceMode(CHOICE_MODE_SINGLE)) {
// Uncheck all the other grandchildren, and toggle the clicked one
boolean wasChecked = c.isChecked();
resetCheckedGrandchildren();
c.setChecked(!wasChecked);
} else {
c.toggle();
}
if (getCheckedGrandchildren().size() == 0) {
endChoiceMode();
}
return;
}
}
// otherwise continue and launch the application
int childIndex = getChildIndexForGrandChild(v);
if (childIndex == getCurrentPage()) {
final ApplicationInfo app = (ApplicationInfo) v.getTag();
// animate some feedback to the click
animateClickFeedback(v, new Runnable() {
@Override
public void run() {
mLauncher.startActivitySafely(app.intent, app);
}
});
endChoiceMode();
}
}
private void setupDragMode(ApplicationInfo info) {
mLauncher.getWorkspace().shrink(Workspace.ShrinkState.BOTTOM_VISIBLE);
// Only show the uninstall button if the app is uninstallable.
if ((info.flags & ApplicationInfo.DOWNLOADED_FLAG) != 0) {
DeleteZone allAppsDeleteZone = (DeleteZone)
mLauncher.findViewById(R.id.all_apps_delete_zone);
allAppsDeleteZone.setDragAndDropEnabled(true);
if ((info.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);
}
}
ApplicationInfoDropTarget allAppsInfoButton =
(ApplicationInfoDropTarget) mLauncher.findViewById(R.id.all_apps_info_target);
allAppsInfoButton.setDragAndDropEnabled(true);
}
private void tearDownDragMode() {
post(new Runnable() {
// Once the drag operation has fully completed, hence the post, we want to disable the
// deleteZone and the appInfoButton in all apps, and re-enable the instance which
// live in the workspace
public void run() {
DeleteZone allAppsDeleteZone =
(DeleteZone) mLauncher.findViewById(R.id.all_apps_delete_zone);
// if onDestroy was called on Launcher, we might have already deleted the
// all apps delete zone / info button, so check if they are null
if (allAppsDeleteZone != null) allAppsDeleteZone.setDragAndDropEnabled(false);
ApplicationInfoDropTarget allAppsInfoButton =
(ApplicationInfoDropTarget) mLauncher.findViewById(R.id.all_apps_info_target);
if (allAppsInfoButton != null) allAppsInfoButton.setDragAndDropEnabled(false);
}
});
resetCheckedGrandchildren();
mDragController.removeDropTarget(this);
}
@Override
protected boolean beginDragging(View v) {
if (!v.isInTouchMode()) return false;
if (!super.beginDragging(v)) return false;
ApplicationInfo app = (ApplicationInfo) v.getTag();
app = new ApplicationInfo(app);
// Start drag mode after the item is selected
setupDragMode(app);
// get icon (top compound drawable, index is 1)
final TextView tv = (TextView) v;
final Drawable icon = tv.getCompoundDrawables()[1];
Bitmap b = Bitmap.createBitmap(v.getWidth(), v.getHeight(),
Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
c.translate((v.getWidth() - icon.getIntrinsicWidth()) / 2, v.getPaddingTop());
icon.draw(c);
Rect dragRect = null;
if (v instanceof TextView) {
int iconSize = getResources().getDimensionPixelSize(R.dimen.app_icon_size);
int top = v.getPaddingTop();
int left = (b.getWidth() - iconSize) / 2;
int right = left + iconSize;
int bottom = top + iconSize;
dragRect = new Rect(left, top, right, bottom);
}
// We toggle the checked state _after_ we create the view for the drag in case toggling the
// checked state changes the view's look
if (v instanceof Checkable) {
// In preparation for drag, we always reset the checked grand children regardless of
// what choice mode we are in
resetCheckedGrandchildren();
// Toggle the selection on the dragged app
Checkable checkable = (Checkable) v;
// Note: we toggle the checkable state to actually cause an alpha fade for the duration
// of the drag of the item. (The fade-in will occur when all checked states are
// disabled when dragging ends)
checkable.toggle();
}
// Start the drag
mLauncher.lockScreenOrientation();
mLauncher.getWorkspace().onDragStartedWithItemSpans(1, 1, b);
mDragController.startDrag(v, b, this, app, DragController.DRAG_ACTION_COPY, dragRect);
b.recycle();
return true;
}
@Override
public void onDragViewVisible() {
}
@Override
public void onDropCompleted(View target, DragObject d, boolean success) {
// close the choice action mode if we have a proper drop
if (target != this) {
endChoiceMode();
}
tearDownDragMode();
mLauncher.getWorkspace().onDragStopped(success);
mLauncher.unlockScreenOrientation();
if (!success && !mHasMadeSuccessfulDrop) {
mLauncher.getWorkspace().shrink(Workspace.ShrinkState.BOTTOM_HIDDEN);
} else {
mHasMadeSuccessfulDrop |= success;
}
}
int getPageContentWidth() {
return mPageContentWidth;
}
@Override
public boolean isVisible() {
return mZoom > 0.001f;
}
@Override
public boolean isAnimating() {
return (getAnimation() != null);
}
private ArrayList<ApplicationInfo> rebuildFilteredApps(ArrayList<ApplicationInfo> apps) {
ArrayList<ApplicationInfo> filteredApps = new ArrayList<ApplicationInfo>();
if (mAppFilter == ALL_APPS_FLAG) {
return apps;
} else {
final int length = apps.size();
for (int i = 0; i < length; ++i) {
ApplicationInfo info = apps.get(i);
if ((info.flags & mAppFilter) > 0) {
filteredApps.add(info);
}
}
Collections.sort(filteredApps, LauncherModel.APP_INSTALL_TIME_COMPARATOR);
}
return filteredApps;
}
@Override
public void setApps(ArrayList<ApplicationInfo> list) {
mApps = list;
Collections.sort(mApps, LauncherModel.APP_NAME_COMPARATOR);
mFilteredApps = rebuildFilteredApps(mApps);
invalidatePageData();
}
private void addAppsWithoutInvalidate(ArrayList<ApplicationInfo> list) {
// we add it in place, in alphabetical order
final int count = list.size();
for (int i = 0; i < count; ++i) {
final ApplicationInfo info = list.get(i);
final int index = Collections.binarySearch(mApps, info, LauncherModel.APP_NAME_COMPARATOR);
if (index < 0) {
mApps.add(-(index + 1), info);
} else {
mApps.add(index, info);
}
}
mFilteredApps = rebuildFilteredApps(mApps);
}
@Override
public void addApps(ArrayList<ApplicationInfo> list) {
addAppsWithoutInvalidate(list);
invalidatePageData();
}
private void removeAppsWithoutInvalidate(ArrayList<ApplicationInfo> list) {
// End the choice mode if any of the items in the list that are being removed are
// currently selected
ArrayList<Checkable> checkedList = getCheckedGrandchildren();
HashSet<ApplicationInfo> checkedAppInfos = new HashSet<ApplicationInfo>();
for (Checkable checked : checkedList) {
PagedViewIcon icon = (PagedViewIcon) checked;
checkedAppInfos.add((ApplicationInfo) icon.getTag());
}
for (ApplicationInfo info : list) {
if (checkedAppInfos.contains(info)) {
endChoiceMode();
break;
}
}
// Loop through all the apps and remove apps that have the same component
final int length = list.size();
for (int i = 0; i < length; ++i) {
final ApplicationInfo info = list.get(i);
int removeIndex = findAppByComponent(mApps, info);
if (removeIndex > -1) {
mApps.remove(removeIndex);
}
}
mFilteredApps = rebuildFilteredApps(mApps);
}
@Override
public void removeApps(ArrayList<ApplicationInfo> list) {
removeAppsWithoutInvalidate(list);
invalidatePageData();
}
@Override
public void updateApps(ArrayList<ApplicationInfo> list) {
removeAppsWithoutInvalidate(list);
addAppsWithoutInvalidate(list);
invalidatePageData();
}
private int findAppByComponent(ArrayList<ApplicationInfo> list, ApplicationInfo item) {
if (item != null && item.intent != null) {
ComponentName removeComponent = item.intent.getComponent();
final int length = list.size();
for (int i = 0; i < length; ++i) {
ApplicationInfo info = list.get(i);
if (info.intent.getComponent().equals(removeComponent)) {
return i;
}
}
}
return -1;
}
@Override
public void dumpState() {
ApplicationInfo.dumpApplicationInfoList(TAG, "mApps", mApps);
}
@Override
public void surrender() {
// do nothing?
}
public void reset() {
setCurrentPage(0);
invalidatePageData();
}
private void setupPage(PagedViewCellLayout layout) {
layout.setCellCount(mCellCountX, mCellCountY);
layout.setPadding(mPageLayoutPaddingLeft, mPageLayoutPaddingTop, mPageLayoutPaddingRight,
mPageLayoutPaddingBottom);
layout.setGap(mPageLayoutWidthGap, mPageLayoutHeightGap);
}
@Override
protected void invalidatePageData() {
if (mWaitingToInitPages || mCellCountX <= 0 || mCellCountY <= 0) {
// We don't know our size yet, which means we haven't calculated cell count x/y;
// onMeasure will call us once we figure out our size
return;
}
super.invalidatePageData();
}
@Override
public void syncPages() {
/*
// ensure that we have the right number of pages (min of 1, since we have placeholders)
int numPages = Math.max(1,
(int) Math.ceil((float) mFilteredApps.size() / (mCellCountX * mCellCountY)));
int curNumPages = getChildCount();
// remove any extra pages after the "last" page
int extraPageDiff = curNumPages - numPages;
for (int i = 0; i < extraPageDiff; ++i) {
removeViewAt(numPages);
}
// add any necessary pages
for (int i = curNumPages; i < numPages; ++i) {
PagedViewCellLayout layout = new PagedViewCellLayout(getContext());
if (mAllowHardwareLayerCreation) {
layout.allowHardwareLayerCreation();
}
setupPage(layout);
addView(layout);
}
// bound the current page
setCurrentPage(Math.max(0, Math.min(numPages - 1, getCurrentPage())));
*/
}
@Override
public void syncPageItems(int page) {
/*
// Ensure that we have the right number of items on the pages
final int numPages = getPageCount();
final int cellsPerPage = mCellCountX * mCellCountY;
final int startIndex = page * cellsPerPage;
final int endIndex = Math.min(startIndex + cellsPerPage, mFilteredApps.size());
PagedViewCellLayout layout = (PagedViewCellLayout) getChildAt(page);
if (!mFilteredApps.isEmpty()) {
int curNumPageItems = layout.getPageChildCount();
int numPageItems = endIndex - startIndex;
boolean createHolographicOutlines = (numPages > 1);
// If we were previously an empty page, then restart anew
boolean wasEmptyPage = false;
if (curNumPageItems == 1) {
View icon = layout.getChildOnPageAt(0);
if (icon.getTag() == null) {
wasEmptyPage = true;
}
}
if (wasEmptyPage) {
// Remove all the previous items
curNumPageItems = 0;
layout.removeAllViewsOnPage();
} else {
// Remove any extra items
int extraPageItemsDiff = curNumPageItems - numPageItems;
for (int i = 0; i < extraPageItemsDiff; ++i) {
layout.removeViewOnPageAt(numPageItems);
}
}
// Add any necessary items
for (int i = curNumPageItems; i < numPageItems; ++i) {
TextView text = (TextView) mInflater.inflate(
R.layout.all_apps_paged_view_application, layout, false);
text.setOnClickListener(this);
text.setOnLongClickListener(this);
text.setOnTouchListener(this);
layout.addViewToCellLayout(text, -1, i,
new PagedViewCellLayout.LayoutParams(0, 0, 1, 1));
}
// Actually reapply to the existing text views
for (int i = startIndex; i < endIndex; ++i) {
final int index = i - startIndex;
final ApplicationInfo info = mFilteredApps.get(i);
PagedViewIcon icon = (PagedViewIcon) layout.getChildOnPageAt(index);
icon.applyFromApplicationInfo(
info, null, true, createHolographicOutlines);
PagedViewCellLayout.LayoutParams params =
(PagedViewCellLayout.LayoutParams) icon.getLayoutParams();
params.cellX = index % mCellCountX;
params.cellY = index / mCellCountX;
}
// We should try and sync all the holographic icons after adding/removing new items
layout.reloadHolographicIcons(createHolographicOutlines);
// Default to left-aligned icons
layout.enableCenteredContent(false);
} else {
// There are no items, so show the user a small message
TextView icon = (TextView) mInflater.inflate(
R.layout.all_apps_no_items_placeholder, layout, false);
switch (mAppFilter) {
case ApplicationInfo.DOWNLOADED_FLAG:
icon.setText(mContext.getString(R.string.all_apps_no_downloads));
break;
default: break;
}
// Center-align the message
final boolean createHolographicOutlines = (numPages > 1);
layout.enableCenteredContent(true);
layout.removeAllViewsOnPage();
layout.addViewToCellLayout(icon, -1, 0,
new PagedViewCellLayout.LayoutParams(0, 0, 4, 1));
}
layout.createHardwareLayers();
*/
}
/*
* We don't actually use AllAppsPagedView as a drop target... it's only used to intercept a drop
* to the workspace.
*/
public boolean acceptDrop(DragObject d) {
return false;
}
public DropTarget getDropTargetDelegate(DragObject d) {
return null;
}
public void onDragEnter(DragObject d) {}
public void onDragExit(DragObject d) {}
public void onDragOver(DragObject d) {}
public void onDrop(DragObject d) {}
public boolean isDropEnabled() {
return true;
}
}
@@ -1,286 +0,0 @@
/*
* 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.
*/
package com.android.launcher2;
import com.android.launcher.R;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.Resources;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TabHost;
import android.widget.TabWidget;
import android.widget.TextView;
import java.util.ArrayList;
/**
* Implements a tabbed version of AllApps2D.
*/
public class AllAppsTabbed extends TabHost implements AllAppsView, LauncherTransitionable {
private static final String TAG = "Launcher.AllAppsTabbed";
private static final String TAG_ALL = "ALL";
private static final String TAG_DOWNLOADED = "DOWNLOADED";
private AllAppsPagedView mAllApps;
private AllAppsBackground mBackground;
private Launcher mLauncher;
private Context mContext;
private final LayoutInflater mInflater;
private boolean mFirstLayout = true;
public AllAppsTabbed(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
mInflater = LayoutInflater.from(context);
}
@Override
protected void onFinishInflate() {
// setup the tab host
setup();
try {
mAllApps = (AllAppsPagedView) findViewById(R.id.all_apps_paged_view);
if (mAllApps == null) throw new Resources.NotFoundException();
mBackground = (AllAppsBackground) findViewById(R.id.all_apps_background);
if (mBackground == null) throw new Resources.NotFoundException();
} catch (Resources.NotFoundException e) {
Log.e(TAG, "Can't find necessary layout elements for AllAppsTabbed");
}
// share the same AllApps workspace across all the tabs
TabContentFactory contentFactory = new TabContentFactory() {
public View createTabContent(String tag) {
return mAllApps;
}
};
// Create the tabs and wire them up properly
AppsCustomizeTabKeyEventListener keyListener = new AppsCustomizeTabKeyEventListener();
TextView tabView;
TabWidget tabWidget = (TabWidget) findViewById(com.android.internal.R.id.tabs);
tabView = (TextView) mInflater.inflate(R.layout.tab_widget_indicator, tabWidget, false);
tabView.setText(mContext.getString(R.string.all_apps_tab_all));
addTab(newTabSpec(TAG_ALL).setIndicator(tabView).setContent(contentFactory));
tabView = (TextView) mInflater.inflate(R.layout.tab_widget_indicator, tabWidget, false);
tabView.setText(mContext.getString(R.string.all_apps_tab_downloaded));
addTab(newTabSpec(TAG_DOWNLOADED).setIndicator(tabView).setContent(contentFactory));
// Setup the key listener to jump between the last tab view and the market icon
View lastTab = tabWidget.getChildTabViewAt(tabWidget.getTabCount() - 1);
lastTab.setOnKeyListener(keyListener);
View shopButton = findViewById(R.id.market_button);
shopButton.setOnKeyListener(keyListener);
setOnTabChangedListener(new OnTabChangeListener() {
public void onTabChanged(String tabId) {
// animate the changing of the tab content by fading pages in and out
final Resources res = getResources();
final int duration = res.getInteger(R.integer.config_tabTransitionDuration);
final float alpha = mAllApps.getAlpha();
ValueAnimator alphaAnim = ObjectAnimator.ofFloat(mAllApps, "alpha", alpha, 0.0f).
setDuration(duration);
alphaAnim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
String tag = getCurrentTabTag();
if (tag == TAG_ALL) {
mAllApps.setAppFilter(AllAppsPagedView.ALL_APPS_FLAG);
} else if (tag == TAG_DOWNLOADED) {
mAllApps.setAppFilter(ApplicationInfo.DOWNLOADED_FLAG);
}
final float alpha = mAllApps.getAlpha();
ObjectAnimator.ofFloat(mAllApps, "alpha", alpha, 1.0f).
setDuration(duration).start();
}
});
alphaAnim.start();
}
});
// It needs to be INVISIBLE so that it will be measured in the layout.
// Otherwise the animations is messed up when we show it for the first time.
setVisibility(INVISIBLE);
}
@Override
public void setup(Launcher launcher, DragController dragController) {
mLauncher = launcher;
mAllApps.setup(launcher, dragController);
}
@Override
public void zoom(float zoom, boolean animate) {
// NOTE: animate parameter is ignored for the TabHost itself
setVisibility((zoom == 0.0f) ? View.GONE : View.VISIBLE);
mAllApps.zoom(zoom, animate);
}
@Override
public void setVisibility(int visibility) {
if (visibility == View.GONE && mFirstLayout) {
// It needs to be INVISIBLE so that it will be measured in the layout.
// Otherwise the animations is messed up when we show it for the first time.
visibility = View.INVISIBLE;
}
final boolean isVisible = (visibility == View.VISIBLE);
super.setVisibility(visibility);
float zoom = (isVisible ? 1.0f : 0.0f);
mAllApps.zoom(zoom, false);
}
@Override
public boolean isVisible() {
return mAllApps.isVisible();
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
if (mFirstLayout) {
mFirstLayout = false;
}
// Set the width of the tab bar properly
int pageWidth = mAllApps.getPageContentWidth();
TabWidget tabWidget = (TabWidget) findViewById(com.android.internal.R.id.tabs);
View allAppsTabBar = (View) findViewById(R.id.all_apps_tab_bar);
if (allAppsTabBar == null) throw new Resources.NotFoundException();
int tabWidgetPadding = 0;
final int childCount = tabWidget.getChildCount();
if (childCount > 0) {
tabWidgetPadding += tabWidget.getChildAt(0).getPaddingLeft() * 2;
}
int newWidth = Math.min(getMeasuredWidth(), pageWidth + tabWidgetPadding);
if (newWidth != allAppsTabBar.getLayoutParams().width) {
allAppsTabBar.getLayoutParams().width = newWidth;
post(new Runnable() {
public void run() {
requestLayout();
}
});
}
super.onLayout(changed, l, t, r, b);
}
@Override
public boolean isAnimating() {
return (getAnimation() != null);
}
@Override
public void onLauncherTransitionStart(Animator animation) {
if (animation != null) {
// Turn on hardware layers for performance
setLayerType(LAYER_TYPE_HARDWARE, null);
// Re-enable the rendering of the dimmed background in All Apps for performance reasons
// if we're fading it in
if (mLauncher.getWorkspace().getBackgroundAlpha() == 0f) {
mLauncher.getWorkspace().disableBackground();
mBackground.setVisibility(VISIBLE);
}
// just a sanity check that we don't build a layer before a call to onLayout
if (!mFirstLayout) {
// 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(Animator animation) {
if (animation != null) {
setLayerType(LAYER_TYPE_NONE, null);
// To improve the performance of the first time All Apps is run, we initially keep
// hardware layers in AllAppsPagedView disabled since AllAppsTabbed itself is drawn in a
// hardware layer, and creating additional hardware layers slows down the animation. We
// create them here, after the animation is over.
}
// Move the rendering of the dimmed background to workspace after the all apps animation
// is done, so that the background is not rendered *above* the mini workspace screens
if (mBackground.getVisibility() != GONE) {
mLauncher.getWorkspace().enableBackground();
mBackground.setVisibility(GONE);
}
mAllApps.allowHardwareLayerCreation();
}
@Override
public void setApps(ArrayList<ApplicationInfo> list) {
mAllApps.setApps(list);
}
@Override
public void addApps(ArrayList<ApplicationInfo> list) {
mAllApps.addApps(list);
}
@Override
public void removeApps(ArrayList<ApplicationInfo> list) {
mAllApps.removeApps(list);
}
@Override
public void updateApps(ArrayList<ApplicationInfo> list) {
mAllApps.updateApps(list);
}
@Override
public void dumpState() {
mAllApps.dumpState();
}
@Override
public void surrender() {
mAllApps.surrender();
}
public void reset() {
mAllApps.reset();
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
if (ev.getY() > mAllApps.getBottom()) {
return false;
}
return true;
}
@Override
public int getDescendantFocusability() {
if (getVisibility() != View.VISIBLE) {
return ViewGroup.FOCUS_BLOCK_DESCENDANTS;
}
return super.getDescendantFocusability();
}
}
@@ -1,171 +0,0 @@
/*
* 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.
*/
package com.android.launcher2;
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.Animator.AnimatorListener;
import android.content.ComponentName;
import android.content.Context;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.util.AttributeSet;
import android.view.View;
import com.android.launcher.R;
/**
* Implements a DropTarget which allows applications to be dropped on it,
* in order to launch the application info for that app.
*/
public class ApplicationInfoDropTarget extends IconDropTarget {
private static final int sFadeInAnimationDuration = 200;
private static final int sFadeOutAnimationDuration = 100;
private AnimatorSet mFadeAnimator;
public ApplicationInfoDropTarget(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public ApplicationInfoDropTarget(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// Set the hover paint colour
int colour = getContext().getResources().getColor(R.color.info_target_hover_tint);
mHoverPaint.setColorFilter(new PorterDuffColorFilter(colour, PorterDuff.Mode.SRC_ATOP));
// 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) {
// acceptDrop is called just before onDrop. We do the work here, rather than
// in onDrop, because it allows us to reject the drop (by returning false)
// so that the object being dragged isn't removed from the home screen.
if (getVisibility() != VISIBLE) return false;
ComponentName componentName = null;
if (d.dragInfo instanceof ApplicationInfo) {
componentName = ((ApplicationInfo) d.dragInfo).componentName;
} else if (d.dragInfo instanceof ShortcutInfo) {
componentName = ((ShortcutInfo) d.dragInfo).intent.getComponent();
}
mLauncher.startApplicationDetailsActivity(componentName);
return false;
}
public void onDragEnter(DragObject d) {
if (!mDragAndDropEnabled) return;
d.dragView.setPaint(mHoverPaint);
}
public void onDragExit(DragObject d) {
if (!mDragAndDropEnabled) return;
d.dragView.setPaint(null);
}
public void onDragStart(DragSource source, Object info, int dragAction) {
if (info != null && mDragAndDropEnabled) {
final int itemType = ((ItemInfo)info).itemType;
mActive = (itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION);
if (mActive) {
// Fade in this icon
if (mFadeAnimator != null) mFadeAnimator.cancel();
mFadeAnimator = new AnimatorSet();
Animator infoButtonAnimator = ObjectAnimator.ofFloat(this, "alpha", 0.0f, 1.0f);
infoButtonAnimator.setDuration(sFadeInAnimationDuration);
mFadeAnimator.play(infoButtonAnimator);
setVisibility(VISIBLE);
// Fade out the overlapping views
if (mOverlappingViews != null) {
for (View view : mOverlappingViews) {
ObjectAnimator oa = ObjectAnimator.ofFloat(view, "alpha", 0.0f);
oa.setDuration(sFadeOutAnimationDuration);
mFadeAnimator.play(oa);
}
mFadeAnimator.addListener(new AnimatorListener() {
public void onAnimationStart(Animator animation) {}
public void onAnimationRepeat(Animator animation) {}
public void onAnimationEnd(Animator animation) {
onEndOrCancel();
}
public void onAnimationCancel(Animator animation) {
onEndOrCancel();
}
private void onEndOrCancel() {
for (View view : mOverlappingViews) {
view.setVisibility(INVISIBLE);
}
mFadeAnimator = null;
}
});
}
mFadeAnimator.start();
}
}
}
public void onDragEnd() {
if (!mDragAndDropEnabled) return;
if (mActive) mActive = false;
// Fade out this icon
if (mFadeAnimator != null) mFadeAnimator.cancel();
mFadeAnimator = new AnimatorSet();
Animator infoButtonAnimator = ObjectAnimator.ofFloat(this, "alpha", 0.0f);
infoButtonAnimator.setDuration(sFadeOutAnimationDuration);
mFadeAnimator.addListener(new AnimatorListener() {
public void onAnimationStart(Animator animation) {}
public void onAnimationRepeat(Animator animation) {}
public void onAnimationEnd(Animator animation) {
onEndOrCancel();
}
public void onAnimationCancel(Animator animation) {
onEndOrCancel();
}
private void onEndOrCancel() {
setVisibility(GONE);
mFadeAnimator = null;
}
});
mFadeAnimator.play(infoButtonAnimator);
// Fade in the overlapping views
if (mOverlappingViews != null) {
for (View view : mOverlappingViews) {
// Check whether the views are enabled first, before trying to fade them in
if (view.isEnabled()) {
ObjectAnimator oa = ObjectAnimator.ofFloat(view, "alpha", 1.0f);
oa.setDuration(sFadeInAnimationDuration);
mFadeAnimator.play(oa);
view.setVisibility(VISIBLE);
}
}
}
mFadeAnimator.start();
}
}
@@ -33,9 +33,6 @@ import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff.Mode;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
@@ -64,6 +61,7 @@ import java.util.List;
interface AsyncTaskCallback {
void run(AppsCustomizeAsyncTask task, AsyncTaskPageData data);
}
/**
* The data needed to perform either of the custom AsyncTasks.
*/
@@ -72,8 +70,8 @@ class AsyncTaskPageData {
AsyncTaskCallback postR) {
page = p;
items = l;
srcImages = si;
images = new ArrayList<Bitmap>();
sourceImages = si;
generatedImages = new ArrayList<Bitmap>();
cellWidth = cellHeight = -1;
doInBackgroundCallback = bgR;
postExecuteCallback = postR;
@@ -82,7 +80,7 @@ class AsyncTaskPageData {
AsyncTaskCallback postR) {
page = p;
items = l;
images = new ArrayList<Bitmap>();
generatedImages = new ArrayList<Bitmap>();
cellWidth = cw;
cellHeight = ch;
doInBackgroundCallback = bgR;
@@ -90,13 +88,14 @@ class AsyncTaskPageData {
}
int page;
ArrayList<Object> items;
ArrayList<Bitmap> srcImages;
ArrayList<Bitmap> images;
ArrayList<Bitmap> sourceImages;
ArrayList<Bitmap> generatedImages;
int cellWidth;
int cellHeight;
AsyncTaskCallback doInBackgroundCallback;
AsyncTaskCallback postExecuteCallback;
}
/**
* A generic template for an async task used in AppsCustomize.
*/
@@ -131,22 +130,6 @@ class AppsCustomizeAsyncTask extends AsyncTask<AsyncTaskPageData, Void, AsyncTas
AppsCustomizePagedView.ContentType pageContentType;
int threadPriority;
}
/**
* An AsyncTask that loads widget previews from package manager in the background.
*/
class LoadWidgetPreviewsTask extends AppsCustomizeAsyncTask {
LoadWidgetPreviewsTask(int p, AppsCustomizePagedView.ContentType t) {
super(p, t);
}
}
/**
* An AsyncTask that generates holgoraphic outlines for a specified set of bitmaps.
*/
class GenerateHoloOutlinesTask extends AppsCustomizeAsyncTask {
GenerateHoloOutlinesTask(int p, AppsCustomizePagedView.ContentType t) {
super(p, t);
}
}
/**
* The Apps/Customize page that displays all the applications, widgets, and shortcuts.
@@ -462,22 +445,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
return true;
}
private void endDragging(boolean success) {
post(new Runnable() {
// Once the drag operation has fully completed, hence the post, we want to disable the
// deleteZone and the appInfoButton in all apps, and re-enable the instance which
// live in the workspace
public void run() {
// if onDestroy was called on Launcher, we might have already deleted the
// all apps delete zone / info button, so check if they are null
DeleteZone allAppsDeleteZone =
(DeleteZone) mLauncher.findViewById(R.id.all_apps_delete_zone);
ApplicationInfoDropTarget allAppsInfoButton =
(ApplicationInfoDropTarget) mLauncher.findViewById(R.id.all_apps_info_target);
if (allAppsDeleteZone != null) allAppsDeleteZone.setDragAndDropEnabled(false);
if (allAppsInfoButton != null) allAppsInfoButton.setDragAndDropEnabled(false);
}
});
mLauncher.exitSpringLoadedDragMode();
mLauncher.getWorkspace().onDragStopped(success);
mLauncher.unlockScreenOrientation();
@@ -624,7 +591,8 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
while (iter.hasNext()) {
AppsCustomizeAsyncTask task = (AppsCustomizeAsyncTask) iter.next();
int taskPage = task.page;
if (taskPage < (mCurrentPage - 2) || taskPage > (mCurrentPage + 2)) {
if (taskPage < getAssociatedLowerPageBound(mCurrentPage) ||
taskPage > getAssociatedUpperPageBound(mCurrentPage)) {
task.cancel(false);
iter.remove();
} else {
@@ -641,7 +609,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
// Load each of the widget/shortcut previews
ArrayList<Object> items = data.items;
ArrayList<Bitmap> images = data.images;
ArrayList<Bitmap> images = data.generatedImages;
int count = items.size();
int cellWidth = data.cellWidth;
int cellHeight = data.cellHeight;
@@ -655,12 +623,12 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
AppWidgetProviderInfo info = (AppWidgetProviderInfo) rawInfo;
int[] cellSpans = CellLayout.rectToCell(getResources(),
info.minWidth, info.minHeight, null);
images.add(getWidgetPreviewInBackground(info, cellSpans[0],cellSpans[1],
images.add(getWidgetPreview(info, cellSpans[0],cellSpans[1],
cellWidth, cellHeight));
} else if (rawInfo instanceof ResolveInfo) {
// Fill in the shortcuts information
ResolveInfo info = (ResolveInfo) rawInfo;
images.add(getShortcutPreviewInBackground(info, cellWidth, cellHeight));
images.add(getShortcutPreview(info, cellWidth, cellHeight));
}
}
}
@@ -676,7 +644,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
});
// Ensure that the task is appropriately prioritized and runs in parallel
LoadWidgetPreviewsTask t = new LoadWidgetPreviewsTask(page, mContentType);
AppsCustomizeAsyncTask t = new AppsCustomizeAsyncTask(page, mContentType);
t.setThreadPriority(getThreadPriorityForPage(page));
t.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, pageData);
mRunningTasks.add(t);
@@ -693,8 +661,8 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
// Ensure that this task starts running at the correct priority
task.syncThreadPriority();
ArrayList<Bitmap> images = data.images;
ArrayList<Bitmap> srcImages = data.srcImages;
ArrayList<Bitmap> images = data.generatedImages;
ArrayList<Bitmap> srcImages = data.sourceImages;
int count = srcImages.size();
Canvas c = new Canvas();
for (int i = 0; i < count && !task.isCancelled(); ++i) {
@@ -726,8 +694,8 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
});
// Ensure that the outline task always runs in the background, serially
GenerateHoloOutlinesTask t =
new GenerateHoloOutlinesTask(page, mContentType);
AppsCustomizeAsyncTask t =
new AppsCustomizeAsyncTask(page, mContentType);
t.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
t.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, pageData);
mRunningTasks.add(t);
@@ -762,7 +730,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
d.setBounds(oldBounds); // Restore the bounds
}
}
private Bitmap getShortcutPreviewInBackground(ResolveInfo info, int cellWidth,
private Bitmap getShortcutPreview(ResolveInfo info, int cellWidth,
int cellHeight) {
Resources resources = mLauncher.getResources();
int iconSize = resources.getDimensionPixelSize(R.dimen.app_icon_size);
@@ -776,7 +744,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
renderDrawableToBitmap(icon, preview, 0, 0, iconSize, iconSize, 1f, 1f);
return preview;
}
private Bitmap getWidgetPreviewInBackground(AppWidgetProviderInfo info,
private Bitmap getWidgetPreview(AppWidgetProviderInfo info,
int cellHSpan, int cellVSpan, int cellWidth, int cellHeight) {
// Calculate the size of the drawable
@@ -901,7 +869,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
createItemInfo = new PendingAddWidgetInfo(info, null, null);
int[] cellSpans = CellLayout.rectToCell(getResources(),
info.minWidth, info.minHeight, null);
FastBitmapDrawable preview = new FastBitmapDrawable(data.images.get(i));
FastBitmapDrawable preview = new FastBitmapDrawable(data.generatedImages.get(i));
widget.applyFromAppWidgetProviderInfo(info, preview, -1, cellSpans,
mHolographicOutlineHelper);
widget.setTag(createItemInfo);
@@ -912,7 +880,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
createItemInfo.itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
createItemInfo.componentName = new ComponentName(info.activityInfo.packageName,
info.activityInfo.name);
FastBitmapDrawable preview = new FastBitmapDrawable(data.images.get(i));
FastBitmapDrawable preview = new FastBitmapDrawable(data.generatedImages.get(i));
widget.applyFromResolveInfo(mPackageManager, info, preview,
mHolographicOutlineHelper);
widget.setTag(createItemInfo);
@@ -933,7 +901,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
invalidate();
forceUpdateAdjacentPagesAlpha();
prepareGenerateHoloOutlinesTask(data.page, data.items, data.images);
prepareGenerateHoloOutlinesTask(data.page, data.items, data.generatedImages);
}
private void onHolographicPageItemsLoaded(AsyncTaskPageData data) {
// Invalidate early to short-circuit children invalidates
@@ -946,13 +914,13 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
int count = cl.getPageChildCount();
for (int i = 0; i < count; ++i) {
PagedViewIcon icon = (PagedViewIcon) cl.getChildOnPageAt(i);
icon.setHolographicOutline(data.images.get(i));
icon.setHolographicOutline(data.generatedImages.get(i));
}
} else {
int count = layout.getChildCount();
for (int i = 0; i < count; ++i) {
View v = layout.getChildAt(i);
((PagedViewWidget) v).setHolographicOutline(data.images.get(i));
((PagedViewWidget) v).setHolographicOutline(data.generatedImages.get(i));
}
}
}
File diff suppressed because it is too large Load Diff
@@ -1,211 +0,0 @@
/*
* 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.launcher2;
import java.util.Random;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.Resources;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TabHost;
import android.widget.TabWidget;
import android.widget.TextView;
import com.android.launcher.R;
import com.android.launcher2.CustomizePagedView.CustomizationType;
public class CustomizeTrayTabHost extends TabHost implements LauncherTransitionable {
// tags for the customization tabs
private static final String WIDGETS_TAG = "widgets";
private static final String APPLICATIONS_TAG = "applications";
private static final String SHORTCUTS_TAG = "shortcuts";
private static final String WALLPAPERS_TAG = "wallpapers";
private boolean mFirstLayout = true;
// How much of the vertical space this control should attempt to fill
private float mVerticalFillPercentage;
private final LayoutInflater mInflater;
private Context mContext;
private CustomizePagedView mCustomizePagedView;
public CustomizeTrayTabHost(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
mInflater = LayoutInflater.from(context);
}
@Override
protected void onFinishInflate() {
final Resources res = getResources();
setup();
mCustomizePagedView =
(CustomizePagedView) findViewById(R.id.customization_drawer_tab_contents);
// Configure tabs
TabContentFactory contentFactory = new TabContentFactory() {
public View createTabContent(String tag) {
return mCustomizePagedView;
}
};
TextView tabView;
TabWidget tabWidget = (TabWidget) findViewById(com.android.internal.R.id.tabs);
tabView = (TextView) mInflater.inflate(
R.layout.customize_tab_widget_indicator, tabWidget, false);
tabView.setText(mContext.getString(R.string.widgets_tab_label));
addTab(newTabSpec(WIDGETS_TAG)
.setIndicator(tabView).setContent(contentFactory));
tabView = (TextView) mInflater.inflate(
R.layout.customize_tab_widget_indicator, tabWidget, false);
tabView.setText(mContext.getString(R.string.all_apps_tab_apps));
addTab(newTabSpec(APPLICATIONS_TAG)
.setIndicator(tabView).setContent(contentFactory));
tabView = (TextView) mInflater.inflate(
R.layout.customize_tab_widget_indicator, tabWidget, false);
tabView.setText(mContext.getString(R.string.wallpapers_tab_label));
addTab(newTabSpec(WALLPAPERS_TAG)
.setIndicator(tabView).setContent(contentFactory));
tabView = (TextView) mInflater.inflate(
R.layout.customize_tab_widget_indicator, tabWidget, false);
tabView.setText(mContext.getString(R.string.shortcuts_tab_label));
addTab(newTabSpec(SHORTCUTS_TAG)
.setIndicator(tabView).setContent(contentFactory));
mVerticalFillPercentage =
res.getInteger(R.integer.customization_drawer_verticalFillPercentage) / 100f;
setOnTabChangedListener(new OnTabChangeListener() {
public void onTabChanged(String tabId) {
final CustomizePagedView.CustomizationType newType =
getCustomizeFilterForTabTag(tabId);
if (newType != mCustomizePagedView.getCustomizationFilter()) {
// animate the changing of the tab content by fading pages in and out
final int duration = res.getInteger(R.integer.config_tabTransitionDuration);
final float alpha = mCustomizePagedView.getAlpha();
ValueAnimator alphaAnim = ObjectAnimator.ofFloat(mCustomizePagedView,
"alpha", alpha, 0.0f);
alphaAnim.setDuration(duration);
alphaAnim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mCustomizePagedView.setCustomizationFilter(newType);
final float alpha = mCustomizePagedView.getAlpha();
ValueAnimator alphaAnim = ObjectAnimator.ofFloat(
mCustomizePagedView, "alpha", alpha, 1.0f);
alphaAnim.setDuration(duration);
alphaAnim.start();
}
});
alphaAnim.start();
}
}
});
}
@Override
public void onLauncherTransitionStart(Animator animation) {
if (animation != null) {
setLayerType(LAYER_TYPE_HARDWARE, null);
// just a sanity check that we don't build a layer before a call to onLayout
if (!mFirstLayout) {
// 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(Animator animation) {
if (animation != null) {
setLayerType(LAYER_TYPE_NONE, null);
}
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
// If there's extra room, try to grow to fill it
if (MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.AT_MOST) {
final int availableHeight = MeasureSpec.getSize(heightMeasureSpec);
final int finalHeight = Math.max(getMeasuredHeight(),
(int) (availableHeight * mVerticalFillPercentage));
// Measure a second time with EXACTLY so that we get sized correctly
heightMeasureSpec = MeasureSpec.makeMeasureSpec(finalHeight, MeasureSpec.EXACTLY);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
if (mFirstLayout) {
mFirstLayout = false;
final CustomizePagedView customizePagedView =
(CustomizePagedView) findViewById(R.id.customization_drawer_tab_contents);
TabWidget tabWidget = (TabWidget) findViewById(com.android.internal.R.id.tabs);
// Set the width of the tab bar properly
int pageWidth = customizePagedView.getPageContentWidth();
TabWidget customizeTabBar = (TabWidget) findViewById(com.android.internal.R.id.tabs);
if (customizeTabBar == null) throw new Resources.NotFoundException();
int tabWidgetPadding = 0;
final int childCount = tabWidget.getChildCount();
if (childCount > 0) {
tabWidgetPadding += tabWidget.getChildAt(0).getPaddingLeft() * 2;
}
customizeTabBar.getLayoutParams().width = pageWidth + tabWidgetPadding;
}
super.onLayout(changed, l, t, r, b);
}
@Override
public int getDescendantFocusability() {
if (getVisibility() != View.VISIBLE) {
return ViewGroup.FOCUS_BLOCK_DESCENDANTS;
}
return super.getDescendantFocusability();
}
CustomizationType getCustomizeFilterForTabTag(String tag) {
if (tag.equals(WIDGETS_TAG)) {
return CustomizationType.WidgetCustomization;
} else if (tag.equals(APPLICATIONS_TAG)) {
return CustomizationType.ApplicationCustomization;
} else if (tag.equals(WALLPAPERS_TAG)) {
return CustomizePagedView.CustomizationType.WallpaperCustomization;
} else if (tag.equals(SHORTCUTS_TAG)) {
return CustomizePagedView.CustomizationType.ShortcutCustomization;
}
return CustomizationType.WidgetCustomization;
}
}
-270
View File
@@ -1,270 +0,0 @@
/*
* Copyright (C) 2008 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.launcher2;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.TransitionDrawable;
import android.util.AttributeSet;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import com.android.launcher.R;
public class DeleteZone extends IconDropTarget {
private static final int ORIENTATION_HORIZONTAL = 1;
private static final int TRANSITION_DURATION = 250;
private static final int ANIMATION_DURATION = 200;
private static final int XLARGE_TRANSITION_DURATION = 150;
private static final int XLARGE_ANIMATION_DURATION = 200;
private static final int LEFT_DRAWABLE = 0;
private AnimatorSet mInAnimation;
private AnimatorSet mOutAnimation;
private int mOrientation;
private DragController mDragController;
private final RectF mRegionF = new RectF();
private final Rect mRegion = new Rect();
private TransitionDrawable mTransition;
private int mTextColor;
private int mDragTextColor;
public DeleteZone(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public DeleteZone(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
final int srcColor = context.getResources().getColor(R.color.delete_target_hover_tint);
mHoverPaint.setColorFilter(new PorterDuffColorFilter(srcColor, PorterDuff.Mode.SRC_ATOP));
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DeleteZone, defStyle, 0);
mOrientation = a.getInt(R.styleable.DeleteZone_direction, ORIENTATION_HORIZONTAL);
a.recycle();
if (LauncherApplication.isScreenLarge()) {
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, lr);
}
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mTransition = (TransitionDrawable) getCompoundDrawables()[LEFT_DRAWABLE];
if (LauncherApplication.isScreenLarge()) {
mTransition.setCrossFadeEnabled(false);
}
Resources r = getResources();
mTextColor = r.getColor(R.color.workspace_all_apps_and_delete_zone_text_color);
mDragTextColor = r.getColor(R.color.workspace_delete_zone_drag_text_color);
}
public boolean acceptDrop(DragObject d) {
return true;
}
public void onDrop(DragObject d) {
if (!mDragAndDropEnabled) return;
final ItemInfo item = (ItemInfo) d.dragInfo;
// On x-large screens, you can uninstall an app by dragging from all apps
if (item instanceof ApplicationInfo && LauncherApplication.isScreenLarge()) {
mLauncher.startApplicationUninstallActivity((ApplicationInfo) item);
}
if (item.container == -1) return;
if (item.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
if (item instanceof LauncherAppWidgetInfo) {
mLauncher.removeAppWidget((LauncherAppWidgetInfo) item);
}
}
if (item instanceof FolderInfo) {
final FolderInfo folderInfo = (FolderInfo)item;
LauncherModel.deleteFolderContentsFromDatabase(mLauncher, folderInfo);
mLauncher.removeFolder(folderInfo);
} else if (item instanceof LauncherAppWidgetInfo) {
final LauncherAppWidgetInfo launcherAppWidgetInfo = (LauncherAppWidgetInfo) item;
final LauncherAppWidgetHost appWidgetHost = mLauncher.getAppWidgetHost();
if (appWidgetHost != null) {
// Deleting an app widget ID is a void call but writes to disk before returning
// to the caller...
new Thread("deleteAppWidgetId") {
public void run() {
appWidgetHost.deleteAppWidgetId(launcherAppWidgetInfo.appWidgetId);
}
}.start();
}
}
LauncherModel.deleteItemFromDatabase(mLauncher, item);
}
public void onDragEnter(DragObject d) {
if (mDragAndDropEnabled) {
mTransition.reverseTransition(getTransitionAnimationDuration());
setTextColor(mDragTextColor);
super.onDragEnter(d);
}
}
public void onDragExit(DragObject d) {
if (mDragAndDropEnabled) {
mTransition.reverseTransition(getTransitionAnimationDuration());
setTextColor(mTextColor);
super.onDragExit(d);
}
}
public void onDragStart(DragSource source, Object info, int dragAction) {
final ItemInfo item = (ItemInfo) info;
if (item != null && mDragAndDropEnabled) {
mActive = true;
getHitRect(mRegion);
mRegionF.set(mRegion);
if (LauncherApplication.isScreenLarge()) {
// This region will be a "dead zone" for scrolling; make it extend to the edge of
// the screen so users don't accidentally trigger a scroll while deleting items
mRegionF.top = mLauncher.getWorkspace().getTop();
mRegionF.right = mLauncher.getWorkspace().getRight();
}
mDragController.setDeleteRegion(mRegionF);
// Make sure the icon is set to the default drawable, not the hover drawable
mTransition.resetTransition();
createAnimations();
mInAnimation.start();
if (mOverlappingViews != null) {
for (View view : mOverlappingViews) {
createOutAlphaAnim(view).start();
}
}
setVisibility(VISIBLE);
}
}
public void onDragEnd() {
if (mActive && mDragAndDropEnabled) {
mActive = false;
mDragController.setDeleteRegion(null);
mOutAnimation.start();
if (mOverlappingViews != null) {
for (View view : mOverlappingViews) {
createInAlphaAnim(view).start();
}
}
}
}
private Animator createAlphaAnim(View v, float start, float end) {
Animator anim = ObjectAnimator.ofFloat(v, "alpha", start, end);
anim.setDuration(getAnimationDuration());
return anim;
}
private Animator createInAlphaAnim(View v) {
return createAlphaAnim(v, 0f, 1f);
}
private Animator createOutAlphaAnim(View v) {
return createAlphaAnim(v, 1f, 0f);
}
private void createAnimations() {
int duration = getAnimationDuration();
Animator inAlphaAnim = createInAlphaAnim(this);
if (mInAnimation == null) {
mInAnimation = new AnimatorSet();
mInAnimation.setInterpolator(new AccelerateInterpolator());
mInAnimation.setDuration(duration);
if (!LauncherApplication.isScreenLarge()) {
Animator translateAnim;
if (mOrientation == ORIENTATION_HORIZONTAL) {
translateAnim = ObjectAnimator.ofFloat(this, "translationY",
getMeasuredWidth(), 0f);
} else {
translateAnim = ObjectAnimator.ofFloat(this, "translationX",
getMeasuredHeight(), 0f);
}
mInAnimation.playTogether(translateAnim, inAlphaAnim);
} else {
mInAnimation.play(inAlphaAnim);
}
}
Animator outAlphaAnim = createOutAlphaAnim(this);
if (mOutAnimation == null) {
mOutAnimation = new AnimatorSet();
mOutAnimation.setInterpolator(new AccelerateInterpolator());
mOutAnimation.setDuration(duration);
if (!LauncherApplication.isScreenLarge()) {
Animator translateAnim;
if (mOrientation == ORIENTATION_HORIZONTAL) {
translateAnim = ObjectAnimator.ofFloat(this, "translationY", 0f,
getMeasuredWidth());
} else {
translateAnim = ObjectAnimator.ofFloat(this, "translationX", 0f,
getMeasuredHeight());
}
mOutAnimation.playTogether(translateAnim, outAlphaAnim);
} else {
mOutAnimation.addListener(new AnimatorListenerAdapter() {
public void onAnimationEnd(Animator animation) {
setVisibility(GONE);
}
});
mOutAnimation.play(outAlphaAnim);
}
}
}
void setDragController(DragController dragController) {
mDragController = dragController;
}
private int getTransitionAnimationDuration() {
return LauncherApplication.isScreenLarge() ?
XLARGE_TRANSITION_DURATION : TRANSITION_DURATION;
}
private int getAnimationDuration() {
return LauncherApplication.isScreenLarge() ?
XLARGE_ANIMATION_DURATION : ANIMATION_DURATION;
}
}
@@ -1,136 +0,0 @@
/*
* 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.
*/
package com.android.launcher2;
import android.content.Context;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;
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 StrokedTextView implements DropTarget, DragController.DragListener {
protected Launcher mLauncher;
/**
* If true, this View responsible for managing its own visibility, and that of its overlapping
* views. This is generally the case, but it will be set to false when this is part of the
* Contextual Action Bar.
*/
protected boolean mDragAndDropEnabled;
/** Whether this drop target is active for the current drag */
protected boolean mActive;
/** The views that this view should appear in the place of. */
protected View[] mOverlappingViews = null;
/** The paint applied to the drag view on hover */
protected final Paint mHoverPaint = new Paint();
/** Drag zone padding [T, R, B, L] */
protected final int mDragPadding[] = new int[4];
public IconDropTarget(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public IconDropTarget(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mDragAndDropEnabled = true;
}
protected void setDragPadding(int t, int r, int b, int l) {
mDragPadding[0] = t;
mDragPadding[1] = r;
mDragPadding[2] = b;
mDragPadding[3] = l;
}
void setLauncher(Launcher launcher) {
mLauncher = launcher;
}
void setOverlappingView(View view) {
mOverlappingViews = new View[] { view };
}
void setOverlappingViews(View[] views) {
mOverlappingViews = views;
}
void setDragAndDropEnabled(boolean enabled) {
mDragAndDropEnabled = enabled;
}
public boolean acceptDrop(DragObject d) {
return false;
}
public void onDrop(DragObject d) {
// Do nothing
}
public void onDragEnter(DragObject d) {
if (mDragAndDropEnabled) {
d.dragView.setPaint(mHoverPaint);
}
}
public void onDragOver(DragObject d) {
// Do nothing
}
public void onDragExit(DragObject d) {
if (mDragAndDropEnabled) {
d.dragView.setPaint(null);
}
}
public void onDragStart(DragSource source, Object info, int dragAction) {
// Do nothing
}
public boolean isDropEnabled() {
return mDragAndDropEnabled && mActive;
}
public void onDragEnd() {
// Do nothing
}
@Override
public void getHitRect(Rect outRect) {
super.getHitRect(outRect);
if (LauncherApplication.isScreenLarge()) {
outRect.top -= mDragPadding[0];
outRect.right += mDragPadding[1];
outRect.bottom += mDragPadding[2];
outRect.left -= mDragPadding[3];
}
}
@Override
public DropTarget getDropTargetDelegate(DragObject d) {
return null;
}
}
-1
View File
@@ -193,7 +193,6 @@ public final class Launcher extends Activity
private FolderInfo mFolderInfo;
private DeleteZone mDeleteZone;
private ViewGroup mButtonCluster;
private View mAllAppsButton;
private SearchDropTargetBar mSearchDeleteBar;
+4 -4
View File
@@ -166,7 +166,7 @@ public abstract class PagedView extends ViewGroup {
private static final int sScrollIndicatorFadeOutDuration = 650;
// If set, will defer loading associated pages until the scrolling settles
private boolean mDeferLoadAssociatedPagesAfterScroll;
private boolean mDeferLoadAssociatedPagesUntilScrollCompletes;
public interface PageSwitchListener {
void onPageSwitch(View newPage, int newPageIndex);
@@ -375,9 +375,9 @@ public abstract class PagedView extends ViewGroup {
notifyPageSwitchListener();
// Load the associated pages if necessary
if (mDeferLoadAssociatedPagesAfterScroll) {
if (mDeferLoadAssociatedPagesUntilScrollCompletes) {
loadAssociatedPages(mCurrentPage);
mDeferLoadAssociatedPagesAfterScroll = false;
mDeferLoadAssociatedPagesUntilScrollCompletes = false;
}
// We don't want to trigger a page end moving unless the page has settled
@@ -1390,7 +1390,7 @@ public abstract class PagedView extends ViewGroup {
if (mDeferScrollUpdate) {
loadAssociatedPages(mNextPage);
} else {
mDeferLoadAssociatedPagesAfterScroll = true;
mDeferLoadAssociatedPagesUntilScrollCompletes = true;
}
notifyPageSwitchListener();
invalidate();
@@ -1,121 +0,0 @@
/*
* 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.
*/
package com.android.launcher2;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.LinearLayout;
/**
* The linear layout used strictly for the widget/wallpaper tab of the customization tray.
* To be deprecated.
*/
public class PagedViewExtendedLayout extends LinearLayout implements Page {
static final String TAG = "PagedViewExtendedLayout";
public PagedViewExtendedLayout(Context context) {
this(context, null);
}
public PagedViewExtendedLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public PagedViewExtendedLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (LauncherApplication.isScreenLarge()) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
} else {
// PagedView currently has issues with different-sized pages since it calculates the
// offset of each page to scroll to before it updates the actual size of each page
// (which canchange depending on the content if the contains aren't a fixed size).
// We work around this by having a minimum size on each widget page).
int widthSpecSize = Math.max(getSuggestedMinimumWidth(),
MeasureSpec.getSize(widthMeasureSpec));
int widthSpecMode = MeasureSpec.AT_MOST;
super.onMeasure(MeasureSpec.makeMeasureSpec(widthSpecSize, widthSpecMode),
heightMeasureSpec);
}
}
@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;
}
@Override
protected boolean onSetAlpha(int alpha) {
return true;
}
@Override
public void setAlpha(float alpha) {
setChildrenAlpha(alpha);
super.setAlpha(alpha);
}
private void setChildrenAlpha(float alpha) {
final int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
getChildAt(i).setAlpha(alpha);
}
}
@Override
public void removeAllViewsOnPage() {
removeAllViews();
}
@Override
public void removeViewOnPageAt(int index) {
removeViewAt(index);
}
@Override
public int getPageChildCount() {
return getChildCount();
}
@Override
public View getChildOnPageAt(int i) {
return getChildAt(i);
}
@Override
public int indexOfChildOnPage(View v) {
return indexOfChild(v);
}
public static class LayoutParams extends LinearLayout.LayoutParams {
public LayoutParams() {
super(LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.MATCH_PARENT);
}
}
}
@@ -140,23 +140,6 @@ public class PagedViewWidget extends LinearLayout implements Checkable {
}
}
public void applyFromWallpaperInfo(ResolveInfo info, PackageManager packageManager,
FastBitmapDrawable preview, int maxWidth, HolographicOutlineHelper holoOutlineHelper) {
mHolographicOutlineHelper = holoOutlineHelper;
ImageView image = (ImageView) findViewById(R.id.wallpaper_preview);
image.setMaxWidth(maxWidth);
image.setImageDrawable(preview);
mPreviewImageView = image;
TextView name = (TextView) findViewById(R.id.wallpaper_name);
name.setText(info.loadLabel(packageManager));
name.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
// Hide the divider in the Phone UI.
if (!LauncherApplication.isScreenLarge()) {
findViewById(R.id.divider).setVisibility(View.GONE);
}
}
public void setHolographicOutline(Bitmap holoOutline) {
mHolographicOutline = holoOutline;
invalidate();
-385
View File
@@ -1,385 +0,0 @@
#pragma version(1)
#pragma rs java_package_name(com.android.launcher2)
#include "rs_graphics.rsh"
#define PI 3.14159f
// Constants from Java
int COLUMNS_PER_PAGE_PORTRAIT;
int ROWS_PER_PAGE_PORTRAIT;
int COLUMNS_PER_PAGE_LANDSCAPE;
int ROWS_PER_PAGE_LANDSCAPE;
int gIconCount;
int gSelectedIconIndex = -1;
rs_allocation gSelectedIconTexture;
rs_allocation gHomeButton;
rs_program_fragment gPFTexNearest;
rs_program_fragment gPFTexMip;
rs_program_fragment gPFTexMipAlpha;
rs_program_vertex gPVCurve;
rs_program_store gPS;
rs_mesh gSMCell;
rs_allocation *gIcons;
rs_allocation *gLabels;
typedef struct VpConsts {
rs_matrix4x4 Proj;
float4 Position;
float4 ScaleOffset;
float2 BendPos;
float2 ImgSize;
} VpConsts_t;
VpConsts_t *vpConstants;
// Attraction to center values from page edge to page center.
static float g_AttractionTable[9] = {20.f, 20.f, 20.f, 10.f, -10.f, -20.f, -20.f, -20.f, -20.f};
static float g_FrictionTable[9] = {10.f, 10.f, 11.f, 15.f, 15.f, 11.f, 10.f, 10.f, 10.f};
static float g_PhysicsTableSize = 7;
static float gZoomTarget;
float gTargetPos;
static float g_PosPage = 0.f;
static float g_PosVelocity = 0.f;
static float g_LastPositionX = 0.f;
static bool g_LastTouchDown = false;
static float g_DT;
static int g_PosMax;
static float g_Zoom = 0.f;
static float g_Animation = 1.f;
static float g_OldPosPage;
static float g_OldPosVelocity;
static float g_OldZoom;
static float g_MoveToTotalTime = 0.2f;
static float g_MoveToTime = 0.f;
static float g_MoveToOldPos = 0.f;
static int g_Cols;
static int g_Rows;
rs_allocation g_VPConstAlloc;
// Drawing constants, should be parameters ======
#define VIEW_ANGLE 1.28700222f
static void updateReadback() {
if ((g_OldPosPage != g_PosPage) ||
(g_OldPosVelocity != g_PosVelocity) ||
(g_OldZoom != g_Zoom)) {
g_OldPosPage = g_PosPage;
g_OldPosVelocity = g_PosVelocity;
g_OldZoom = g_Zoom;
int i[3];
i[0] = g_PosPage * (1 << 16);
i[1] = g_PosVelocity * (1 << 16);
i[2] = g_OldZoom * (1 << 16);
rsSendToClientBlocking(1, &i[0], sizeof(i));
}
}
void init() {
}
void move(float newPos) {
if (g_LastTouchDown) {
float dx = -(newPos - g_LastPositionX);
g_PosVelocity = 0;
g_PosPage += dx * 5.2f;
float pmin = -0.49f;
float pmax = g_PosMax + 0.49f;
g_PosPage = clamp(g_PosPage, pmin, pmax);
}
g_LastTouchDown = true;
g_LastPositionX = newPos;
g_MoveToTime = 0;
}
void moveTo(float targetPos) {
gTargetPos = targetPos;
g_MoveToTime = g_MoveToTotalTime;
g_PosVelocity = 0;
g_MoveToOldPos = g_PosPage;
}
void setZoom(float z, /*bool*/ int animate) {
gZoomTarget = z;
if (gZoomTarget < 0.001f) {
gZoomTarget = 0;
}
if (!animate) {
g_Zoom = gZoomTarget;
}
updateReadback();
}
void fling(float newPos, float vel) {
move(newPos);
g_LastTouchDown = false;
g_PosVelocity = -vel * 4;
float av = fabs(g_PosVelocity);
float minVel = 3.5f;
minVel *= 1.f - (fabs(rsFrac(g_PosPage + 0.5f) - 0.5f) * 0.45f);
if (av < minVel && av > 0.2f) {
if (g_PosVelocity > 0) {
g_PosVelocity = minVel;
} else {
g_PosVelocity = -minVel;
}
}
if (g_PosPage <= 0) {
g_PosVelocity = max(0.f, g_PosVelocity);
}
if (g_PosPage > g_PosMax) {
g_PosVelocity = min(0.f, g_PosVelocity);
}
}
// Interpolates values in the range 0..1 to a curve that eases in
// and out.
static float getInterpolation(float input) {
return (cos((input + 1) * PI) * 0.5f) + 0.5f;
}
static void updatePos() {
if (g_LastTouchDown) {
return;
}
float tablePosNorm = rsFrac(g_PosPage + 0.5f);
float tablePosF = tablePosNorm * g_PhysicsTableSize;
int tablePosI = tablePosF;
float tablePosFrac = tablePosF - tablePosI;
float accel = mix(g_AttractionTable[tablePosI],
g_AttractionTable[tablePosI + 1],
tablePosFrac) * g_DT;
float friction = mix(g_FrictionTable[tablePosI],
g_FrictionTable[tablePosI + 1],
tablePosFrac) * g_DT;
if (g_MoveToTime) {
// New position is old posiition + (total distance) * (interpolated time)
g_PosPage = g_MoveToOldPos + (gTargetPos - g_MoveToOldPos) * getInterpolation((g_MoveToTotalTime - g_MoveToTime) / g_MoveToTotalTime);
g_MoveToTime -= g_DT;
if (g_MoveToTime <= 0) {
g_MoveToTime = 0;
g_PosPage = gTargetPos;
}
return;
}
// If our velocity is low OR acceleration is opposing it, apply it.
if (fabs(g_PosVelocity) < 4.0f || (g_PosVelocity * accel) < 0) {
g_PosVelocity += accel;
}
//RS_DEBUG(g_PosPage);
//RS_DEBUG(g_PosVelocity);
//RS_DEBUG(friction);
//RS_DEBUG(accel);
// Normal physics
if (g_PosVelocity > 0) {
g_PosVelocity -= friction;
g_PosVelocity = max(g_PosVelocity, 0.f);
} else {
g_PosVelocity += friction;
g_PosVelocity = min(g_PosVelocity, 0.f);
}
if ((friction > fabs(g_PosVelocity)) && (friction > fabs(accel))) {
// Special get back to center and overcome friction physics.
float t = tablePosNorm - 0.5f;
if (fabs(t) < (friction * g_DT)) {
// really close, just snap
g_PosPage = round(g_PosPage);
g_PosVelocity = 0;
} else {
if (t > 0) {
g_PosVelocity = -friction;
} else {
g_PosVelocity = friction;
}
}
}
// Check for out of boundry conditions.
if (g_PosPage < 0 && g_PosVelocity < 0) {
float damp = 1.0f + (g_PosPage * 4);
damp = clamp(damp, 0.f, 0.9f);
g_PosVelocity *= damp;
}
if (g_PosPage > g_PosMax && g_PosVelocity > 0) {
float damp = 1.0f - ((g_PosPage - g_PosMax) * 4);
damp = clamp(damp, 0.f, 0.9f);
g_PosVelocity *= damp;
}
g_PosPage += g_PosVelocity * g_DT;
g_PosPage = clamp(g_PosPage, -0.49f, g_PosMax + 0.49f);
}
static void
draw_home_button()
{
rsgBindTexture(gPFTexNearest, 0, gHomeButton);
float w = rsgGetWidth();
float h = rsgGetHeight();
float tw = rsAllocationGetDimX(gHomeButton);
float th = rsAllocationGetDimY(gHomeButton);
float x;
float y;
if (w > h) {
x = w - (tw * (1 - g_Animation)) + 20;
y = (h - th) * 0.5f;
} else {
x = (w - tw) / 2;
y = -g_Animation * th;
y -= 30; // move the house to the edge of the screen as it doesn't fill the texture.
}
rsgDrawSpriteScreenspace(x, y, 0, tw, th);
}
static void drawFrontGrid(float rowOffset, float p)
{
float h = rsgGetHeight();
float w = rsgGetWidth();
int intRowOffset = rowOffset;
float rowFrac = rowOffset - intRowOffset;
float colWidth = 120.f;//w / 4;
float rowHeight = colWidth + 25.f;
float yoff = 0.5f * h + 1.5f * rowHeight;
int row, col;
int colCount = 4;
if (w > h) {
colCount = 6;
rowHeight -= 12.f;
yoff = 0.47f * h + 1.0f * rowHeight;
}
int iconNum = (intRowOffset - 5) * colCount;
rsgBindProgramVertex(gPVCurve);
vpConstants->Position.z = p;
for (row = -5; row < 15; row++) {
float y = yoff - ((-rowFrac + row) * rowHeight);
for (col=0; col < colCount; col++) {
if (iconNum >= gIconCount) {
return;
}
if (iconNum >= 0) {
float x = colWidth * col + (colWidth / 2);
vpConstants->Position.x = x + 0.2f;
if (gSelectedIconIndex == iconNum && !p && rsIsObject(gSelectedIconTexture)) {
rsgBindProgramFragment(gPFTexNearest);
rsgBindTexture(gPFTexNearest, 0, gSelectedIconTexture);
vpConstants->ImgSize.x = rsAllocationGetDimX(gSelectedIconTexture);
vpConstants->ImgSize.y = rsAllocationGetDimY(gSelectedIconTexture);
vpConstants->Position.y = y - (rsAllocationGetDimY(gSelectedIconTexture)
- rsAllocationGetDimY(gIcons[iconNum])) * 0.5f;
rsgAllocationSyncAll(g_VPConstAlloc);
rsgDrawMesh(gSMCell);
}
rsgBindProgramFragment(gPFTexMip);
vpConstants->ImgSize.x = rsAllocationGetDimX(gIcons[iconNum]);
vpConstants->ImgSize.y = rsAllocationGetDimY(gIcons[iconNum]);
vpConstants->Position.y = y - 0.2f;
rsgAllocationSyncAll(g_VPConstAlloc);
rsgBindTexture(gPFTexMip, 0, gIcons[iconNum]);
rsgDrawMesh(gSMCell);
rsgBindProgramFragment(gPFTexMipAlpha);
vpConstants->ImgSize.x = rsAllocationGetDimX(gLabels[iconNum]);
vpConstants->ImgSize.y = rsAllocationGetDimY(gLabels[iconNum]);
vpConstants->Position.y = y - 64.f - 0.2f;
rsgAllocationSyncAll(g_VPConstAlloc);
rsgBindTexture(gPFTexMipAlpha, 0, gLabels[iconNum]);
rsgDrawMesh(gSMCell);
}
iconNum++;
}
}
}
int root()
{
// Compute dt in seconds.
// physics may break if DT is large.
g_DT = min(rsGetDt(), 0.1f);
g_VPConstAlloc = rsGetAllocation(vpConstants);
if (g_Zoom != gZoomTarget) {
float dz = g_DT * 1.7f;
if (gZoomTarget < 0.5f) {
dz = -dz;
}
if (fabs(g_Zoom - gZoomTarget) < fabs(dz)) {
g_Zoom = gZoomTarget;
} else {
g_Zoom += dz;
}
updateReadback();
}
g_Animation = pow(1.f - g_Zoom, 3.f);
// Set clear value to dim the background based on the zoom position.
if ((g_Zoom < 0.001f) && (gZoomTarget < 0.001f)) {
rsgClearColor(0.0f, 0.0f, 0.0f, 0.0f);
// When we're zoomed out and not tracking motion events, reset the pos to 0.
if (!g_LastTouchDown) {
g_PosPage = 0;
}
return 0;
} else {
rsgClearColor(0.0f, 0.0f, 0.0f, g_Zoom);
}
rsgBindProgramStore(gPS);
// icons & labels
if (rsgGetWidth() > rsgGetHeight()) {
g_Cols = COLUMNS_PER_PAGE_LANDSCAPE;
g_Rows = ROWS_PER_PAGE_LANDSCAPE;
} else {
g_Cols = COLUMNS_PER_PAGE_PORTRAIT;
g_Rows = ROWS_PER_PAGE_PORTRAIT;
}
g_PosMax = ((gIconCount + (g_Cols-1)) / g_Cols) - g_Rows;
if (g_PosMax < 0) g_PosMax = 0;
updatePos();
updateReadback();
// Draw the icons ========================================
drawFrontGrid(g_PosPage, g_Animation);
rsgBindProgramFragment(gPFTexNearest);
draw_home_button();
return (g_PosVelocity != 0) || rsFrac(g_PosPage) || g_Zoom != gZoomTarget || (g_MoveToTime != 0);
}