diff options
-rw-r--r-- | res/drawable-xlarge-mdpi/app_market_generic.png | bin | 2750 -> 957 bytes | |||
-rw-r--r-- | res/layout-xlarge-land/all_apps_tabbed.xml | 21 | ||||
-rw-r--r-- | res/layout-xlarge-land/launcher.xml | 32 | ||||
-rw-r--r-- | res/layout-xlarge-land/workspace_screen.xml | 8 | ||||
-rw-r--r-- | res/layout-xlarge-port/all_apps_tabbed.xml | 21 | ||||
-rw-r--r-- | res/layout-xlarge-port/launcher.xml | 17 | ||||
-rw-r--r-- | res/values-xlarge-land/dimens.xml | 6 | ||||
-rw-r--r-- | res/values-xlarge/dimens.xml | 5 | ||||
-rw-r--r-- | res/values-xlarge/styles.xml | 1 | ||||
-rw-r--r-- | src/com/android/launcher2/AllAppsPagedView.java | 6 | ||||
-rw-r--r-- | src/com/android/launcher2/AllAppsTabbed.java | 9 | ||||
-rw-r--r-- | src/com/android/launcher2/ApplicationInfoDropTarget.java | 17 | ||||
-rw-r--r-- | src/com/android/launcher2/DeleteZone.java | 84 | ||||
-rw-r--r-- | src/com/android/launcher2/DragController.java | 1 | ||||
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 17 | ||||
-rw-r--r-- | src/com/android/launcher2/PagedView.java | 32 | ||||
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 92 |
17 files changed, 242 insertions, 127 deletions
diff --git a/res/drawable-xlarge-mdpi/app_market_generic.png b/res/drawable-xlarge-mdpi/app_market_generic.png Binary files differindex 0ceaeefde..c093e2425 100644 --- a/res/drawable-xlarge-mdpi/app_market_generic.png +++ b/res/drawable-xlarge-mdpi/app_market_generic.png diff --git a/res/layout-xlarge-land/all_apps_tabbed.xml b/res/layout-xlarge-land/all_apps_tabbed.xml index 89a310477..8a0e8b843 100644 --- a/res/layout-xlarge-land/all_apps_tabbed.xml +++ b/res/layout-xlarge-land/all_apps_tabbed.xml @@ -20,13 +20,24 @@ android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> - <TabWidget - android:id="@android:id/tabs" + <RelativeLayout android:layout_width="952dp" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" - android:background="@drawable/tab_unselected_holo" - android:tabStripEnabled="false" /> + android:background="@drawable/tab_unselected_holo"> + <TabWidget + android:id="@android:id/tabs" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:tabStripEnabled="false" /> + <ImageView + android:id="@+id/market_button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentRight="true" + android:onClick="onClickAppMarketButton" /> + </RelativeLayout> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="match_parent" @@ -34,7 +45,7 @@ <com.android.launcher2.AllAppsPagedView android:id="@+id/all_apps_paged_view" android:layout_width="match_parent" - android:layout_height="match_parent" + android:layout_height="wrap_content" launcher:cellCountX="7" launcher:cellCountY="5" launcher:pageLayoutWidthGap="36dp" diff --git a/res/layout-xlarge-land/launcher.xml b/res/layout-xlarge-land/launcher.xml index e5ba3934c..8e6f1fe4b 100644 --- a/res/layout-xlarge-land/launcher.xml +++ b/res/layout-xlarge-land/launcher.xml @@ -22,23 +22,17 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - <include - layout="@layout/all_apps_tabbed" - android:id="@+id/all_apps_view" - android:layout_width="match_parent" - android:layout_height="600dp" - android:layout_gravity="top"/> - <!-- The workspace contains 5 screens of cells --> <com.android.launcher2.Workspace android:id="@+id/workspace" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingTop="?android:attr/actionBarSize" + android:paddingBottom="10dp" launcher:defaultScreen="2" launcher:cellCountX="8" launcher:cellCountY="7" - launcher:pageSpacing="32dp"> + launcher:pageSpacing="50dp"> <include android:id="@+id/cell1" layout="@layout/workspace_screen" /> <include android:id="@+id/cell2" layout="@layout/workspace_screen" /> @@ -47,6 +41,13 @@ <include android:id="@+id/cell5" layout="@layout/workspace_screen" /> </com.android.launcher2.Workspace> + <include + layout="@layout/all_apps_tabbed" + android:id="@+id/all_apps_view" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_gravity="top" /> + <RelativeLayout android:id="@+id/all_apps_button_cluster" android:layout_width="fill_parent" @@ -92,25 +93,12 @@ android:focusable="true" android:clickable="true" /> - <!-- The button to bring up the installed app market. - The icon for this button will be dynamically set. --> - <ImageView - android:id="@+id/market_button" - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:layout_alignLeft="@id/all_apps_button" - - android:onClick="onClickAppMarketButton" - android:focusable="false" - android:clickable="false" - android:visibility="gone"/> - <com.android.launcher2.DeleteZone android:id="@+id/delete_zone" android:src="@drawable/delete_zone_selector" android:layout_width="wrap_content" android:layout_height="match_parent" - android:layout_alignLeft="@id/all_apps_button" + android:layout_alignRight="@id/all_apps_button" android:visibility="gone" launcher:direction="horizontal" /> diff --git a/res/layout-xlarge-land/workspace_screen.xml b/res/layout-xlarge-land/workspace_screen.xml index 64de05e82..e983b7920 100644 --- a/res/layout-xlarge-land/workspace_screen.xml +++ b/res/layout-xlarge-land/workspace_screen.xml @@ -26,7 +26,7 @@ launcher:cellHeight="@dimen/workspace_cell_height" launcher:widthGap="@dimen/workspace_width_gap" launcher:heightGap="@dimen/workspace_height_gap" - launcher:yAxisStartPadding="25dip" - launcher:yAxisEndPadding="25dip" - launcher:xAxisStartPadding="40dip" - launcher:xAxisEndPadding="40dip" /> + launcher:yAxisStartPadding="15dip" + launcher:yAxisEndPadding="15dip" + launcher:xAxisStartPadding="25dip" + launcher:xAxisEndPadding="25dip" /> diff --git a/res/layout-xlarge-port/all_apps_tabbed.xml b/res/layout-xlarge-port/all_apps_tabbed.xml index 65e3729fd..038a9a039 100644 --- a/res/layout-xlarge-port/all_apps_tabbed.xml +++ b/res/layout-xlarge-port/all_apps_tabbed.xml @@ -20,13 +20,24 @@ android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> - <TabWidget - android:id="@android:id/tabs" + <RelativeLayout android:layout_width="700dp" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" - android:background="@drawable/tab_unselected_holo" - android:tabStripEnabled="false" /> + android:background="@drawable/tab_unselected_holo"> + <TabWidget + android:id="@android:id/tabs" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:tabStripEnabled="false" /> + <ImageView + android:id="@+id/market_button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentRight="true" + android:onClick="onClickAppMarketButton" /> + </RelativeLayout> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="match_parent" @@ -34,7 +45,7 @@ <com.android.launcher2.AllAppsPagedView android:id="@+id/all_apps_paged_view" android:layout_width="match_parent" - android:layout_height="match_parent" + android:layout_height="wrap_content" launcher:cellCountX="5" launcher:cellCountY="7" launcher:pageLayoutWidthGap="36dp" diff --git a/res/layout-xlarge-port/launcher.xml b/res/layout-xlarge-port/launcher.xml index 13b69fee4..a6fff4a58 100644 --- a/res/layout-xlarge-port/launcher.xml +++ b/res/layout-xlarge-port/launcher.xml @@ -22,19 +22,13 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - <include - layout="@layout/all_apps_tabbed" - android:id="@+id/all_apps_view" - android:layout_width="match_parent" - android:layout_height="1040dp" - android:layout_gravity="top"/> - <!-- The workspace contains 5 screens of cells --> <com.android.launcher2.Workspace android:id="@+id/workspace" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingTop="?android:attr/actionBarSize" + android:paddingBottom="10dp" launcher:defaultScreen="2" launcher:cellCountX="8" launcher:cellCountY="7" @@ -47,6 +41,13 @@ <include android:id="@+id/cell5" layout="@layout/workspace_screen" /> </com.android.launcher2.Workspace> + <include + layout="@layout/all_apps_tabbed" + android:id="@+id/all_apps_view" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_gravity="top"/> + <RelativeLayout android:id="@+id/all_apps_button_cluster" android:layout_width="fill_parent" @@ -110,7 +111,7 @@ android:src="@drawable/delete_zone_selector" android:layout_width="wrap_content" android:layout_height="match_parent" - android:layout_alignLeft="@id/all_apps_button" + android:layout_alignRight="@id/all_apps_button" android:visibility="gone" launcher:direction="horizontal" /> diff --git a/res/values-xlarge-land/dimens.xml b/res/values-xlarge-land/dimens.xml index db31cf1cf..51037f5b0 100644 --- a/res/values-xlarge-land/dimens.xml +++ b/res/values-xlarge-land/dimens.xml @@ -17,9 +17,9 @@ <resources> <!-- the area at the edge of the screen that makes the workspace go left or right while you're dragging. --> - <dimen name="scroll_zone">160dip</dimen> + <dimen name="scroll_zone">100dip</dimen> <!-- Width/height gap overrides for the workspace --> - <dimen name="workspace_width_gap">16dp</dimen> - <dimen name="workspace_height_gap">5dp</dimen> + <dimen name="workspace_width_gap">32dp</dimen> + <dimen name="workspace_height_gap">2dp</dimen> </resources>
\ No newline at end of file diff --git a/res/values-xlarge/dimens.xml b/res/values-xlarge/dimens.xml index 667f0e310..d98674f6c 100644 --- a/res/values-xlarge/dimens.xml +++ b/res/values-xlarge/dimens.xml @@ -45,4 +45,9 @@ <dimen name="toolbar_padding">10dip</dimen> <dimen name="toolbar_button_spacing">20dip</dimen> + + <!-- height & width of the drop rectangle for the trash icon --> + <dimen name="delete_zone_size">50dip</dimen> + <dimen name="delete_zone_min_padding">10dip</dimen> + <dimen name="delete_zone_max_padding">20dip</dimen> </resources> diff --git a/res/values-xlarge/styles.xml b/res/values-xlarge/styles.xml index 83cdbccb5..fcbd9695d 100644 --- a/res/values-xlarge/styles.xml +++ b/res/values-xlarge/styles.xml @@ -35,5 +35,6 @@ <style name="WorkspaceIcon.Landscape"> <item name="android:drawablePadding">0dip</item> <item name="android:paddingTop">0dip</item> + <item name="android:includeFontPadding">false</item> </style> </resources> diff --git a/src/com/android/launcher2/AllAppsPagedView.java b/src/com/android/launcher2/AllAppsPagedView.java index 351384f93..f472600a2 100644 --- a/src/com/android/launcher2/AllAppsPagedView.java +++ b/src/com/android/launcher2/AllAppsPagedView.java @@ -498,8 +498,10 @@ public class AllAppsPagedView extends PagedView } }); - menu.add(0, MENU_APP_INFO, 0, R.string.cab_menu_app_info).setActionView(infoButton); menu.add(0, MENU_DELETE_APP, 0, R.string.cab_menu_delete_app).setActionView(deleteZone); + menu.add(0, MENU_APP_INFO, 0, R.string.cab_menu_app_info).setActionView(infoButton); + + mLauncher.getWorkspace().shrinkToBottomVisible(); return true; } @@ -531,6 +533,8 @@ public class AllAppsPagedView extends PagedView mDragController.removeDropTarget(this); endChoiceMode(); + + mLauncher.getWorkspace().shrinkToBottomHidden(); } @Override diff --git a/src/com/android/launcher2/AllAppsTabbed.java b/src/com/android/launcher2/AllAppsTabbed.java index a6e21b9d7..0e3246154 100644 --- a/src/com/android/launcher2/AllAppsTabbed.java +++ b/src/com/android/launcher2/AllAppsTabbed.java @@ -25,6 +25,7 @@ import android.content.Context; import android.content.res.Resources; import android.util.AttributeSet; import android.util.Log; +import android.view.MotionEvent; import android.view.View; import android.widget.TabHost; @@ -169,4 +170,12 @@ public class AllAppsTabbed extends TabHost implements AllAppsView { public void surrender() { mAllApps.surrender(); } + + @Override + public boolean onTouchEvent(MotionEvent ev) { + if (ev.getY() > mAllApps.getBottom()) { + return false; + } + return true; + } } diff --git a/src/com/android/launcher2/ApplicationInfoDropTarget.java b/src/com/android/launcher2/ApplicationInfoDropTarget.java index 3e5ebd5ba..c2922ab37 100644 --- a/src/com/android/launcher2/ApplicationInfoDropTarget.java +++ b/src/com/android/launcher2/ApplicationInfoDropTarget.java @@ -16,6 +16,8 @@ package com.android.launcher2; +import com.android.launcher.R; + import android.content.ComponentName; import android.content.Context; import android.graphics.Paint; @@ -133,11 +135,16 @@ public class ApplicationInfoDropTarget extends ImageView implements DropTarget, // In that case, this icon is more tightly spaced next to the delete icon so we want // it to have a smaller drag region. When the new drag&drop system comes in, we'll // dispatch the drag/drop by calculating what target you're overlapping - final int dragPadding = mManageVisibility ? 50 : 10; - outRect.top -= dragPadding; - outRect.left -= dragPadding; - outRect.bottom += dragPadding; - outRect.right += dragPadding; + final int minPadding = R.dimen.delete_zone_min_padding; + final int maxPadding = R.dimen.delete_zone_max_padding; + final int outerDragPadding = + getResources().getDimensionPixelSize(R.dimen.delete_zone_size); + final int innerDragPadding = getResources().getDimensionPixelSize( + mManageVisibility ? maxPadding : minPadding); + outRect.top -= outerDragPadding; + outRect.left -= innerDragPadding; + outRect.bottom += outerDragPadding; + outRect.right += outerDragPadding; } } diff --git a/src/com/android/launcher2/DeleteZone.java b/src/com/android/launcher2/DeleteZone.java index 4acde1c50..be651b273 100644 --- a/src/com/android/launcher2/DeleteZone.java +++ b/src/com/android/launcher2/DeleteZone.java @@ -210,56 +210,72 @@ public class DeleteZone extends ImageView implements DropTarget, DragController. // In that case, this icon is more tightly spaced next to the delete icon so we want // it to have a smaller drag region. When the new drag&drop system comes in, we'll // dispatch the drag/drop by calculating what target you're overlapping - final int dragPadding = mManageVisibility ? 50 : 10; - outRect.top -= dragPadding; - outRect.left -= dragPadding; - outRect.bottom += dragPadding; - outRect.right += dragPadding; + final int minPadding = R.dimen.delete_zone_min_padding; + final int maxPadding = R.dimen.delete_zone_max_padding; + final int outerDragPadding = + getResources().getDimensionPixelSize(R.dimen.delete_zone_size); + final int innerDragPadding = getResources().getDimensionPixelSize( + mManageVisibility ? maxPadding : minPadding); + outRect.top -= outerDragPadding; + outRect.left -= innerDragPadding; + outRect.bottom += outerDragPadding; + outRect.right += innerDragPadding; } } private void createAnimations() { - if (mInAnimation == null) { - mInAnimation = new FastAnimationSet(); - final AnimationSet animationSet = mInAnimation; - animationSet.setInterpolator(new AccelerateInterpolator()); - animationSet.addAnimation(new AlphaAnimation(0.0f, 1.0f)); - if (mOrientation == ORIENTATION_HORIZONTAL) { - animationSet.addAnimation(new TranslateAnimation(Animation.ABSOLUTE, 0.0f, - Animation.ABSOLUTE, 0.0f, Animation.RELATIVE_TO_SELF, 1.0f, - Animation.RELATIVE_TO_SELF, 0.0f)); - } else { - animationSet.addAnimation(new TranslateAnimation(Animation.RELATIVE_TO_SELF, - 1.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.ABSOLUTE, 0.0f, - Animation.ABSOLUTE, 0.0f)); - } - animationSet.setDuration(ANIMATION_DURATION); - } if (mHandleInAnimation == null) { mHandleInAnimation = new AlphaAnimation(0.0f, 1.0f); mHandleInAnimation.setDuration(ANIMATION_DURATION); } - if (mOutAnimation == null) { - mOutAnimation = new FastAnimationSet(); - final AnimationSet animationSet = mOutAnimation; - animationSet.setInterpolator(new AccelerateInterpolator()); - animationSet.addAnimation(new AlphaAnimation(1.0f, 0.0f)); - if (mOrientation == ORIENTATION_HORIZONTAL) { - animationSet.addAnimation(new FastTranslateAnimation(Animation.ABSOLUTE, 0.0f, - Animation.ABSOLUTE, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, - Animation.RELATIVE_TO_SELF, 1.0f)); + + if (mInAnimation == null) { + mInAnimation = new FastAnimationSet(); + if (!LauncherApplication.isScreenXLarge()) { + final AnimationSet animationSet = mInAnimation; + animationSet.setInterpolator(new AccelerateInterpolator()); + animationSet.addAnimation(new AlphaAnimation(0.0f, 1.0f)); + if (mOrientation == ORIENTATION_HORIZONTAL) { + animationSet.addAnimation(new TranslateAnimation(Animation.ABSOLUTE, 0.0f, + Animation.ABSOLUTE, 0.0f, Animation.RELATIVE_TO_SELF, 1.0f, + Animation.RELATIVE_TO_SELF, 0.0f)); + } else { + animationSet.addAnimation(new TranslateAnimation(Animation.RELATIVE_TO_SELF, + 1.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.ABSOLUTE, 0.0f, + Animation.ABSOLUTE, 0.0f)); + } + animationSet.setDuration(ANIMATION_DURATION); } else { - animationSet.addAnimation(new FastTranslateAnimation(Animation.RELATIVE_TO_SELF, - 0.0f, Animation.RELATIVE_TO_SELF, 1.0f, Animation.ABSOLUTE, 0.0f, - Animation.ABSOLUTE, 0.0f)); + mInAnimation.addAnimation(mHandleInAnimation); } - animationSet.setDuration(ANIMATION_DURATION); } + if (mHandleOutAnimation == null) { mHandleOutAnimation = new AlphaAnimation(1.0f, 0.0f); mHandleOutAnimation.setFillAfter(true); mHandleOutAnimation.setDuration(ANIMATION_DURATION); } + + if (mOutAnimation == null) { + mOutAnimation = new FastAnimationSet(); + if (!LauncherApplication.isScreenXLarge()) { + final AnimationSet animationSet = mOutAnimation; + animationSet.setInterpolator(new AccelerateInterpolator()); + animationSet.addAnimation(new AlphaAnimation(1.0f, 0.0f)); + if (mOrientation == ORIENTATION_HORIZONTAL) { + animationSet.addAnimation(new FastTranslateAnimation(Animation.ABSOLUTE, 0.0f, + Animation.ABSOLUTE, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, + Animation.RELATIVE_TO_SELF, 1.0f)); + } else { + animationSet.addAnimation(new FastTranslateAnimation(Animation.RELATIVE_TO_SELF, + 0.0f, Animation.RELATIVE_TO_SELF, 1.0f, Animation.ABSOLUTE, 0.0f, + Animation.ABSOLUTE, 0.0f)); + } + animationSet.setDuration(ANIMATION_DURATION); + } else { + mOutAnimation.addAnimation(mHandleOutAnimation); + } + } } void setLauncher(Launcher launcher) { diff --git a/src/com/android/launcher2/DragController.java b/src/com/android/launcher2/DragController.java index d796fbe91..272bf8bfa 100644 --- a/src/com/android/launcher2/DragController.java +++ b/src/com/android/launcher2/DragController.java @@ -20,7 +20,6 @@ import com.android.launcher.R; import android.content.Context; import android.graphics.Bitmap; -import android.graphics.PointF; import android.graphics.Rect; import android.graphics.RectF; import android.os.Handler; diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index 464ea64da..9954f39d5 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -312,7 +312,6 @@ public final class Launcher extends Activity String shortcutsLabel = getString(R.string.shortcuts_tab_label); mHomeCustomizationDrawer.addTab(mHomeCustomizationDrawer.newTabSpec(SHORTCUTS_TAG) .setIndicator(shortcutsLabel).setContent(contentFactory)); - mHomeCustomizationDrawer.setOnTabChangedListener(new OnTabChangeListener() { public void onTabChanged(String tabId) { // animate the changing of the tab content by fading pages in and out @@ -876,6 +875,7 @@ public final class Launcher extends Activity } mWorkspace = (Workspace) dragLayer.findViewById(R.id.workspace); + final Workspace workspace = mWorkspace; workspace.setHapticFeedbackEnabled(false); @@ -2479,7 +2479,6 @@ public final class Launcher extends Activity private void hideAndShowToolbarButtons(State newState, AnimatorSet showSeq, AnimatorSet hideSeq) { final View searchButton = findViewById(R.id.search_button); final View allAppsButton = findViewById(R.id.all_apps_button); - final View marketButton = findViewById(R.id.market_button); final View configureButton = findViewById(R.id.configure_button); switch (newState) { @@ -2487,20 +2486,16 @@ public final class Launcher extends Activity hideOrShowToolbarButton(true, searchButton, showSeq); hideOrShowToolbarButton(true, allAppsButton, showSeq); hideOrShowToolbarButton(true, configureButton, showSeq); - hideOrShowToolbarButton(false, marketButton, hideSeq); mDeleteZone.setHandle(allAppsButton); break; case ALL_APPS: - hideOrShowToolbarButton(true, configureButton, showSeq); - hideOrShowToolbarButton(true, marketButton, showSeq); + hideOrShowToolbarButton(false, configureButton, hideSeq); hideOrShowToolbarButton(false, searchButton, hideSeq); hideOrShowToolbarButton(false, allAppsButton, hideSeq); - mDeleteZone.setHandle(marketButton); break; case CUSTOMIZE: - hideOrShowToolbarButton(true, allAppsButton, showSeq); + hideOrShowToolbarButton(false, allAppsButton, hideSeq); hideOrShowToolbarButton(false, searchButton, hideSeq); - hideOrShowToolbarButton(false, marketButton, hideSeq); hideOrShowToolbarButton(false, configureButton, hideSeq); mDeleteZone.setHandle(allAppsButton); break; @@ -2544,7 +2539,7 @@ public final class Launcher extends Activity setPivotsForZoom(toView, toState, scale); if (toAllApps) { - mWorkspace.shrinkToBottom(animated); + mWorkspace.shrinkToBottomHidden(animated); } else { mWorkspace.shrinkToTop(animated); } @@ -2683,7 +2678,7 @@ public final class Launcher extends Activity mAllAppsPagedView.endChoiceMode(); if (toState == State.ALL_APPS) { - mWorkspace.shrinkToBottom(animated); + mWorkspace.shrinkToBottomHidden(animated); } else { mWorkspace.shrinkToTop(animated); } @@ -2754,6 +2749,7 @@ public final class Launcher extends Activity // TODO: fade these two too mDeleteZone.setVisibility(View.GONE); + // Change the state *after* we've called all the transition code mState = State.ALL_APPS; } @@ -2774,6 +2770,7 @@ public final class Launcher extends Activity } else if (mState == State.CUSTOMIZE) { hideCustomizationDrawer(animated); } + // Change the state *after* we've called all the transition code mState = State.WORKSPACE; } diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java index d4dffe6b0..fb8b7d64d 100644 --- a/src/com/android/launcher2/PagedView.java +++ b/src/com/android/launcher2/PagedView.java @@ -349,11 +349,16 @@ public abstract class PagedView extends ViewGroup { throw new IllegalStateException("Workspace can only be used in EXACTLY mode."); } + /* Allow the height to be set as WRAP_CONTENT. This allows the particular case + * of the All apps view on XLarge displays to not take up more space then it needs. Width + * is still not allowed to be set as WRAP_CONTENT since many parts of the code expect + * each page to have the same width. + */ final int heightMode = MeasureSpec.getMode(heightMeasureSpec); - final int heightSize = MeasureSpec.getSize(heightMeasureSpec); - if (heightMode != MeasureSpec.EXACTLY) { - throw new IllegalStateException("Workspace can only be used in EXACTLY mode."); - } + int heightSize = MeasureSpec.getSize(heightMeasureSpec); + int maxChildHeight = 0; + + final int verticalPadding = mPaddingTop + mPaddingBottom; // The children are given the same width and height as the workspace // unless they were set to WRAP_CONTENT @@ -380,9 +385,14 @@ public abstract class PagedView extends ViewGroup { final int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(widthSize, childWidthMode); final int childHeightMeasureSpec = - MeasureSpec.makeMeasureSpec(heightSize, childHeightMode); + MeasureSpec.makeMeasureSpec(heightSize - verticalPadding, childHeightMode); child.measure(childWidthMeasureSpec, childHeightMeasureSpec); + maxChildHeight = Math.max(maxChildHeight, child.getMeasuredHeight()); + } + + if (heightMode == MeasureSpec.AT_MOST) { + heightSize = maxChildHeight + verticalPadding; } setMeasuredDimension(widthSize, heightSize); @@ -399,6 +409,7 @@ public abstract class PagedView extends ViewGroup { mFirstLayout = false; } + final int verticalPadding = mPaddingTop + mPaddingBottom; final int childCount = getChildCount(); int childLeft = 0; if (childCount > 0) { @@ -409,10 +420,13 @@ public abstract class PagedView extends ViewGroup { final View child = getChildAt(i); if (child.getVisibility() != View.GONE) { final int childWidth = child.getMeasuredWidth(); - final int childHeight = (mCenterPagesVertically ? - (getMeasuredHeight() - child.getMeasuredHeight()) / 2 : 0); - child.layout(childLeft, childHeight, - childLeft + childWidth, childHeight + child.getMeasuredHeight()); + final int childHeight = child.getMeasuredHeight(); + int childTop = mPaddingTop; + if (mCenterPagesVertically) { + childTop += ((getMeasuredHeight() - verticalPadding) - childHeight) / 2; + } + child.layout(childLeft, childTop, + childLeft + childWidth, childTop + childHeight); childLeft += childWidth + mPageSpacing; } } diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index 7e33a2c44..b5b0c5689 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -43,6 +43,7 @@ import android.content.pm.ProviderInfo; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Bitmap; +import android.graphics.Camera; import android.graphics.Canvas; import android.graphics.Matrix; import android.graphics.Paint; @@ -83,6 +84,7 @@ public class Workspace extends SmoothPagedView // Y rotation to apply to the workspace screens private static final float WORKSPACE_ROTATION = 12.5f; + private static final float WORKSPACE_TRANSLATION = 50.0f; // These are extra scale factors to apply to the mini home screens // so as to achieve the desired transform @@ -154,7 +156,6 @@ public class Workspace extends SmoothPagedView private AnimatorSet mAnimator; private boolean mInScrollArea = false; - private boolean mInDragMode = false; private final HolographicOutlineHelper mOutlineHelper = new HolographicOutlineHelper(); private Bitmap mDragOutline = null; @@ -172,6 +173,11 @@ public class Workspace extends SmoothPagedView /** Used to trigger an animation as soon as the workspace stops scrolling. */ private Animator mAnimOnPageEndMoving = null; + // Camera and Matrix used to determine the final position of a neighboring CellLayout + private final Matrix mMatrix = new Matrix(); + private final Camera mCamera = new Camera(); + private final float mTempFloat2[] = new float[2]; + /** * Used to inflate the Workspace from XML. * @@ -414,7 +420,10 @@ public class Workspace extends SmoothPagedView public boolean onTouch(View v, MotionEvent event) { // this is an intercepted event being forwarded from a cell layout if (mIsSmall || mIsInUnshrinkAnimation) { - mLauncher.onWorkspaceClick((CellLayout) v); + // Only allow clicks on a CellLayout if it is visible + if (mShrunkenState != ShrinkPosition.SHRINK_TO_BOTTOM_HIDDEN) { + mLauncher.onWorkspaceClick((CellLayout) v); + } return true; } else if (!mPageMoving) { if (v == getChildAt(mCurrentPage - 1)) { @@ -444,7 +453,12 @@ public class Workspace extends SmoothPagedView @Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (mIsSmall || mIsInUnshrinkAnimation) { - // when the home screens are shrunken, shouldn't allow side-scrolling + if (mLauncher.isAllAppsVisible() && + mShrunkenState == ShrinkPosition.SHRINK_TO_BOTTOM_HIDDEN) { + // Intercept this event so we can show the workspace in full view + // when it is clicked on and it is small + return true; + } return false; } return super.onInterceptTouchEvent(ev); @@ -550,6 +564,31 @@ public class Workspace extends SmoothPagedView return mBackgroundAlpha; } + /** + * Due to 3D transformations, if two CellLayouts are theoretically touching each other, + * on the xy plane, when one is rotated along the y-axis, the gap between them is perceived + * as being larger. This method computes what offset the rotated view should be translated + * in order to minimize this perceived gap. + * @param degrees Angle of the view + * @param width Width of the view + * @param height Height of the view + * @return Offset to be used in a View.setTranslationX() call + */ + private float getOffsetXForRotation(float degrees, int width, int height) { + mMatrix.reset(); + mCamera.save(); + mCamera.rotateY(Math.abs(degrees)); + mCamera.getMatrix(mMatrix); + mCamera.restore(); + + mMatrix.preTranslate(-width * 0.5f, -height * 0.5f); + mMatrix.postTranslate(width * 0.5f, height * 0.5f); + mTempFloat2[0] = width; + mTempFloat2[1] = height; + mMatrix.mapPoints(mTempFloat2); + return (width - mTempFloat2[0]) * (degrees > 0.0f ? 1.0f : -1.0f); + } + @Override protected void screenScrolled(int screenCenter) { final int halfScreenSize = getMeasuredWidth() / 2; @@ -567,6 +606,8 @@ public class Workspace extends SmoothPagedView cl.setBackgroundAlphaMultiplier(Math.abs(scrollProgress)); float rotation = WORKSPACE_ROTATION * scrollProgress; + float translationX = getOffsetXForRotation(rotation, cl.getWidth(), cl.getHeight()); + cl.setTranslationX(translationX); cl.setRotationY(rotation); } } @@ -681,6 +722,7 @@ public class Workspace extends SmoothPagedView return false; } } + return super.dispatchTouchEvent(ev); } @@ -719,7 +761,14 @@ public class Workspace extends SmoothPagedView mScroller.abortAnimation(); } setCurrentPage(mCurrentPage); - return false; // We don't want the events. Let them fall through to the all apps view. + + if (mShrunkenState == ShrinkPosition.SHRINK_TO_BOTTOM_HIDDEN) { + mLauncher.showWorkspace(true); + // Let the events fall through to the CellLayouts because if they are not + // hit, then we get a crash due to a missing ACTION_DOWN touch event + } + + return false; // We don't want the events } return super.onTouchEvent(ev); @@ -737,14 +786,22 @@ public class Workspace extends SmoothPagedView shrink(ShrinkPosition.SHRINK_TO_MIDDLE, true); } - void shrinkToBottom() { - shrinkToBottom(true); + void shrinkToBottomHidden() { + shrinkToBottomHidden(true); + } + + void shrinkToBottomVisible() { + shrinkToBottomVisible(true); } - void shrinkToBottom(boolean animated) { + void shrinkToBottomHidden(boolean animated) { shrink(ShrinkPosition.SHRINK_TO_BOTTOM_HIDDEN, animated); } + void shrinkToBottomVisible(boolean animated) { + shrink(ShrinkPosition.SHRINK_TO_BOTTOM_VISIBLE, animated); + } + private float getYScaleForScreen(int screen) { int x = Math.abs(screen - 2); @@ -813,7 +870,7 @@ public class Workspace extends SmoothPagedView // We shrink and disappear to nothing in the case of all apps // (which is when we shrink to the bottom) newY = screenHeight - newY - scaledPageHeight; - finalAlpha = 0.25f; + finalAlpha = 0.0f; } else if (shrinkPosition == ShrinkPosition.SHRINK_TO_MIDDLE) { newY = screenHeight / 2 - scaledPageHeight / 2; finalAlpha = 1.0f; @@ -985,14 +1042,11 @@ public class Workspace extends SmoothPagedView * start a drag in Launcher, regardless of whether the drag has ever entered the Workspace * * These methods mark the appropriate pages as accepting drops (which alters their visual - * appearance) and, if the pages are hidden, makes them visible. + * appearance). * */ public void onDragStartedWithItemSpans(int spanX, int spanY) { updateWhichPagesAcceptDropsDuringDrag(mShrunkenState, spanX, spanY); - if (mShrunkenState == ShrinkPosition.SHRINK_TO_BOTTOM_HIDDEN) { - shrink(ShrinkPosition.SHRINK_TO_BOTTOM_VISIBLE, true); - } } public void onDragStartedWithItemMinSize(int minWidth, int minHeight) { @@ -1004,9 +1058,6 @@ public class Workspace extends SmoothPagedView // never dragged over public void onDragStopped() { updateWhichPagesAcceptDrops(mShrunkenState); - if (mShrunkenState == ShrinkPosition.SHRINK_TO_BOTTOM_VISIBLE) { - shrink(ShrinkPosition.SHRINK_TO_BOTTOM_HIDDEN, true); - } } // We call this when we trigger an unshrink by clicking on the CellLayout cl @@ -1051,6 +1102,7 @@ public class Workspace extends SmoothPagedView if (mAnimator != null) { mAnimator.cancel(); } + mAnimator = new AnimatorSet(); final int screenCount = getChildCount(); @@ -1066,10 +1118,11 @@ public class Workspace extends SmoothPagedView rotation = -WORKSPACE_ROTATION; } - if (animated) { + float translation = getOffsetXForRotation(rotation, cl.getWidth(), cl.getHeight()); + if (animated) { ObjectAnimator animWithInterpolator = ObjectAnimator.ofPropertyValuesHolder(cl, - PropertyValuesHolder.ofFloat("translationX", 0.0f), + PropertyValuesHolder.ofFloat("translationX", translation), PropertyValuesHolder.ofFloat("translationY", 0.0f), PropertyValuesHolder.ofFloat("scaleX", 1.0f), PropertyValuesHolder.ofFloat("scaleY", 1.0f), @@ -1080,7 +1133,7 @@ public class Workspace extends SmoothPagedView animWithInterpolator.setInterpolator(mZoomInInterpolator); mAnimator.playTogether(animWithInterpolator); } else { - cl.setTranslationX(0.0f); + cl.setTranslationX(translation); cl.setTranslationY(0.0f); cl.setScaleX(1.0f); cl.setScaleY(1.0f); @@ -1089,6 +1142,7 @@ public class Workspace extends SmoothPagedView cl.setRotationY(rotation); } } + if (animated) { // If we call this when we're not animated, onAnimationEnd is never called on // the listener; make sure we only use the listener when we're actually animating @@ -1418,7 +1472,6 @@ public class Workspace extends SmoothPagedView mDragTargetLayout = getCurrentDropLayout(); mDragTargetLayout.onDragEnter(); showOutlines(); - mInDragMode = true; } } @@ -1823,7 +1876,6 @@ public class Workspace extends SmoothPagedView } if (!mIsPageMoving) { hideOutlines(); - mInDragMode = false; } clearAllHovers(); } |