diff options
26 files changed, 231 insertions, 358 deletions
diff --git a/res/drawable-hdpi/quantum_panel_dark.9.png b/res/drawable-hdpi/quantum_panel_dark.9.png Binary files differindex 057efd157..abaf23026 100644 --- a/res/drawable-hdpi/quantum_panel_dark.9.png +++ b/res/drawable-hdpi/quantum_panel_dark.9.png diff --git a/res/drawable-hdpi/virtual_preload.9.png b/res/drawable-hdpi/virtual_preload.9.png Binary files differnew file mode 100644 index 000000000..71e53263e --- /dev/null +++ b/res/drawable-hdpi/virtual_preload.9.png diff --git a/res/drawable-hdpi/virtual_preload_folder.9.png b/res/drawable-hdpi/virtual_preload_folder.9.png Binary files differnew file mode 100644 index 000000000..ece322669 --- /dev/null +++ b/res/drawable-hdpi/virtual_preload_folder.9.png diff --git a/res/drawable-mdpi/quantum_panel_dark.9.png b/res/drawable-mdpi/quantum_panel_dark.9.png Binary files differindex 7837e4808..7728a7268 100644 --- a/res/drawable-mdpi/quantum_panel_dark.9.png +++ b/res/drawable-mdpi/quantum_panel_dark.9.png diff --git a/res/drawable-mdpi/virtual_preload.9.png b/res/drawable-mdpi/virtual_preload.9.png Binary files differnew file mode 100644 index 000000000..a3c75192d --- /dev/null +++ b/res/drawable-mdpi/virtual_preload.9.png diff --git a/res/drawable-mdpi/virtual_preload_folder.9.png b/res/drawable-mdpi/virtual_preload_folder.9.png Binary files differnew file mode 100644 index 000000000..fa2f1313d --- /dev/null +++ b/res/drawable-mdpi/virtual_preload_folder.9.png diff --git a/res/drawable-xhdpi/quantum_panel_dark.9.png b/res/drawable-xhdpi/quantum_panel_dark.9.png Binary files differindex 8944a8f98..4c1868b55 100644 --- a/res/drawable-xhdpi/quantum_panel_dark.9.png +++ b/res/drawable-xhdpi/quantum_panel_dark.9.png diff --git a/res/drawable-xhdpi/virtual_preload.9.png b/res/drawable-xhdpi/virtual_preload.9.png Binary files differnew file mode 100644 index 000000000..d2c3fea9b --- /dev/null +++ b/res/drawable-xhdpi/virtual_preload.9.png diff --git a/res/drawable-xhdpi/virtual_preload_folder.9.png b/res/drawable-xhdpi/virtual_preload_folder.9.png Binary files differnew file mode 100644 index 000000000..1f9202b41 --- /dev/null +++ b/res/drawable-xhdpi/virtual_preload_folder.9.png diff --git a/res/drawable-xxhdpi/quantum_panel_dark.9.png b/res/drawable-xxhdpi/quantum_panel_dark.9.png Binary files differindex b74f1a65c..17ba0f116 100644 --- a/res/drawable-xxhdpi/quantum_panel_dark.9.png +++ b/res/drawable-xxhdpi/quantum_panel_dark.9.png diff --git a/res/drawable-xxhdpi/virtual_preload.9.png b/res/drawable-xxhdpi/virtual_preload.9.png Binary files differindex 0ec1740bf..93e3b3362 100644 --- a/res/drawable-xxhdpi/virtual_preload.9.png +++ b/res/drawable-xxhdpi/virtual_preload.9.png diff --git a/res/drawable-xxhdpi/virtual_preload_folder.9.png b/res/drawable-xxhdpi/virtual_preload_folder.9.png Binary files differindex ee80c768c..fae19b3f9 100644 --- a/res/drawable-xxhdpi/virtual_preload_folder.9.png +++ b/res/drawable-xxhdpi/virtual_preload_folder.9.png diff --git a/res/layout/apps_customize_pane.xml b/res/layout/apps_customize_pane.xml index 03e433ac9..c2d399e29 100644 --- a/res/layout/apps_customize_pane.xml +++ b/res/layout/apps_customize_pane.xml @@ -15,7 +15,8 @@ --> <com.android.launcher3.AppsCustomizeTabHost xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:launcher="http://schemas.android.com/apk/res-auto/com.android.launcher3"> + xmlns:launcher="http://schemas.android.com/apk/res-auto/com.android.launcher3" + android:clipChildren="false"> <LinearLayout android:id="@+id/content" @@ -27,15 +28,20 @@ <FrameLayout android:layout_width="match_parent" android:layout_height="0dp" - android:layout_weight="1"> + android:layout_weight="1" + android:clipChildren="false"> <FrameLayout android:id="@+id/fake_page_container" android:layout_width="match_parent" - android:layout_height="match_parent" > + android:layout_height="match_parent" + android:clipChildren="false" + android:clipToPadding="false"> <FrameLayout - android:id="@+id/fake_page" - android:layout_width="match_parent" - android:layout_height="match_parent" /> + android:id="@+id/fake_page" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:visibility="invisible" + android:clipToPadding="false" /> </FrameLayout> <com.android.launcher3.AppsCustomizePagedView android:id="@+id/apps_customize_pane_content" @@ -55,13 +61,4 @@ android:layout_height="wrap_content" android:layout_gravity="center" /> </LinearLayout> - - <include - android:id="@+id/market_button" - layout="@layout/market_button" - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:layout_gravity="end" - android:visibility="gone"/> - </com.android.launcher3.AppsCustomizeTabHost> diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml index 77ada31ec..d8ceb99b0 100644 --- a/res/values-tr/strings.xml +++ b/res/values-tr/strings.xml @@ -29,7 +29,7 @@ <string name="widget_adder" msgid="3201040140710381657">"Widget\'lar"</string> <string name="toggle_weight_watcher" msgid="5645299835184636119">"Belleği Göster"</string> <string name="long_press_widget_to_add" msgid="7699152356777458215">"Widget seçmek için dokunun ve basılı tutun."</string> - <string name="market" msgid="2619650989819296998">"Alışveriş yap"</string> + <string name="market" msgid="2619650989819296998">"Mağaza"</string> <string name="widget_dims_format" msgid="2370757736025621599">"%1$d × %2$d"</string> <string name="external_drop_widget_error" msgid="3165821058322217155">"Öğe bu Ana ekrana bırakılamadı."</string> <string name="external_drop_widget_pick_title" msgid="3486317258037690630">"Oluşturmak için widget seçin"</string> diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index 2fc6a2f0e..c29cfb0d9 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -24,7 +24,7 @@ <string name="uid_name" msgid="7820867637514617527">"Android 核心应用"</string> <string name="folder_name" msgid="7371454440695724752"></string> <string name="activity_not_found" msgid="8071924732094499514">"未安装该应用。"</string> - <string name="safemode_shortcut_error" msgid="9160126848219158407">"已下载的应用在安全模式下已被停用"</string> + <string name="safemode_shortcut_error" msgid="9160126848219158407">"安全模式下不允许使用下载的此应用"</string> <string name="widgets_tab_label" msgid="2921133187116603919">"小部件"</string> <string name="widget_adder" msgid="3201040140710381657">"小部件"</string> <string name="toggle_weight_watcher" msgid="5645299835184636119">"显示内存空间"</string> diff --git a/res/values/config.xml b/res/values/config.xml index 750a6aa72..0da0b7023 100644 --- a/res/values/config.xml +++ b/res/values/config.xml @@ -36,15 +36,19 @@ <!-- Fade/zoom in/out duration & scale in the AllApps transition. Note: This should be less than the workspaceShrinkTime as they happen together. --> <integer name="config_appsCustomizeRevealTime">220</integer> - <integer name="config_appsCustomizeItemsAlphaStagger">60</integer> <integer name="config_appsCustomizeZoomInTime">350</integer> <integer name="config_appsCustomizeZoomOutTime">600</integer> <integer name="config_appsCustomizeZoomScaleFactor">7</integer> <integer name="config_appsCustomizeFadeInTime">250</integer> <integer name="config_appsCustomizeFadeOutTime">200</integer> <integer name="config_appsCustomizeWorkspaceShrinkTime">300</integer> - <integer name="config_appsCustomizeWorkspaceAnimationStagger">40</integer> - <integer name="config_workspaceAppsCustomizeAnimationStagger">100</integer> + + <integer name="config_appsCustomizeConcealTime">250</integer> + <integer name="config_appsCustomizeItemsAlphaStagger">60</integer> + + <!-- This constant stores the ratio of the all apps button drawable which + is used for internal (baked-in) padding --> + <integer name="config_allAppsButtonPaddingPercent">17</integer> <integer name="config_workspaceDefaultScreen">0</integer> diff --git a/src/com/android/launcher3/AppsCustomizePagedView.java b/src/com/android/launcher3/AppsCustomizePagedView.java index f78cff09d..b2228f7af 100644 --- a/src/com/android/launcher3/AppsCustomizePagedView.java +++ b/src/com/android/launcher3/AppsCustomizePagedView.java @@ -190,16 +190,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen private int mNumWidgetPages; private Rect mAllAppsPadding = new Rect(); - // Relating to the scroll and overscroll effects - Workspace.ZInterpolator mZInterpolator = new Workspace.ZInterpolator(0.5f); - private static float CAMERA_DISTANCE = 6500; - private static float TRANSITION_SCALE_FACTOR = 0.74f; - private static float TRANSITION_PIVOT = 0.65f; - private static float TRANSITION_MAX_ROTATION = 22; - private static final boolean PERFORM_OVERSCROLL_ROTATION = false; - private AccelerateInterpolator mAlphaInterpolator = new AccelerateInterpolator(0.9f); - private DecelerateInterpolator mLeftScreenAlphaInterpolator = new DecelerateInterpolator(4); - // Previews & outlines ArrayList<AppsCustomizeAsyncTask> mRunningTasks; private static final int sPageSleepDelay = 200; @@ -214,7 +204,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen int mWidgetLoadingId = -1; PendingAddWidgetInfo mCreateWidgetInfo = null; private boolean mDraggingWidget = false; - boolean mPageBackgroundsVisible; + boolean mPageBackgroundsVisible = true; private Toast mWidgetInstructionToast; @@ -259,6 +249,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen if (getImportantForAccessibility() == View.IMPORTANT_FOR_ACCESSIBILITY_AUTO) { setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES); } + setSinglePageInViewport(); } @Override @@ -376,52 +367,19 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen mWidgetSpacingLayout.measure(widthSpec, heightSpec); final boolean hostIsTransitioning = getTabHost().isInTransition(); - - // Restore the page int page = getPageForComponent(mSaveInstanceStateItemIndex); invalidatePageData(Math.max(0, page), hostIsTransitioning); - - // Show All Apps cling if we are finished transitioning, otherwise, we will try again when - // the transition completes in AppsCustomizeTabHost (otherwise the wrong offsets will be - // returned while animating) - if (!hostIsTransitioning) { - post(new Runnable() { - @Override - public void run() { - showAllAppsCling(); - } - }); - } } - void showAllAppsCling() { - if (!mHasShownAllAppsCling && isDataReady()) { - mHasShownAllAppsCling = true; - // Calculate the position for the cling punch through - int[] offset = new int[2]; - int[] pos = mWidgetSpacingLayout.estimateCellPosition(mClingFocusedX, mClingFocusedY); - mLauncher.getDragLayer().getLocationInDragLayer(this, offset); - // PagedViews are centered horizontally but top aligned - // Note we have to shift the items up now that Launcher sits under the status bar - pos[0] += (getMeasuredWidth() - mWidgetSpacingLayout.getMeasuredWidth()) / 2 + - offset[0]; - pos[1] += offset[1] - mLauncher.getDragLayer().getPaddingTop(); - } - } + protected void onLayout(boolean changed, int l, int t, int r, int b) { + super.onLayout(changed, l, t, r, b); - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - int width = MeasureSpec.getSize(widthMeasureSpec); - int height = MeasureSpec.getSize(heightMeasureSpec); if (!isDataReady()) { if ((LauncherAppState.isDisableAllApps() || !mApps.isEmpty()) && !mWidgets.isEmpty()) { setDataIsReady(); - setMeasuredDimension(width, height); - onDataReady(width, height); + onDataReady(getMeasuredWidth(), getMeasuredHeight()); } } - - super.onMeasure(widthMeasureSpec, heightMeasureSpec); } public void onPackagesUpdated(ArrayList<Object> widgetsAndShortcuts) { @@ -1003,8 +961,8 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen Drawable bg = getContext().getResources().getDrawable(R.drawable.quantum_panel); if (bg != null) { + bg.setAlpha(mPageBackgroundsVisible ? 255: 0); layout.setBackground(bg); - bg.setVisible(mPageBackgroundsVisible, false); } setVisibilityOnChildren(layout, View.VISIBLE); @@ -1016,7 +974,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen for (int i = 0; i < childCount; ++i) { Drawable bg = getChildAt(i).getBackground(); if (bg != null) { - bg.setVisible(visible, false); + bg.setAlpha(visible ? 255 : 0); } } } @@ -1164,7 +1122,12 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen // immediately after syncing, we don't have a proper width. int widthSpec = MeasureSpec.makeMeasureSpec(mContentWidth, MeasureSpec.AT_MOST); int heightSpec = MeasureSpec.makeMeasureSpec(mContentHeight, MeasureSpec.AT_MOST); - layout.setBackground(getContext().getResources().getDrawable(R.drawable.quantum_panel_dark)); + + Drawable bg = getContext().getResources().getDrawable(R.drawable.quantum_panel_dark); + if (bg != null) { + bg.setAlpha(mPageBackgroundsVisible ? 255 : 0); + layout.setBackground(bg); + } layout.measure(widthSpec, heightSpec); } @@ -1175,11 +1138,10 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen // Calculate the dimensions of each cell we are giving to each widget final ArrayList<Object> items = new ArrayList<Object>(); - int contentWidth = mContentWidth - getPaddingLeft() - getPaddingRight() - - layout.getPaddingLeft() - layout.getPaddingRight(); + int contentWidth = mContentWidth - layout.getPaddingLeft() - layout.getPaddingRight(); final int cellWidth = contentWidth / mWidgetCountX; - int contentHeight = mContentHeight - getPaddingTop() - getPaddingBottom() - - layout.getPaddingTop() - layout.getPaddingBottom(); + int contentHeight = mContentHeight - layout.getPaddingTop() - layout.getPaddingBottom(); + final int cellHeight = contentHeight / mWidgetCountY; // Prepare the set of widgets to load previews for in the background @@ -1394,73 +1356,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen // In apps customize, we have a scrolling effect which emulates pulling cards off of a stack. @Override protected void screenScrolled(int screenCenter) { - final boolean isRtl = isLayoutRtl(); super.screenScrolled(screenCenter); - - for (int i = 0; i < getChildCount(); i++) { - View v = getPageAt(i); - if (v != null) { - float scrollProgress = getScrollProgress(screenCenter, v, i); - - float interpolatedProgress; - float translationX; - float maxScrollProgress = Math.max(0, scrollProgress); - float minScrollProgress = Math.min(0, scrollProgress); - - if (isRtl) { - translationX = maxScrollProgress * v.getMeasuredWidth(); - interpolatedProgress = mZInterpolator.getInterpolation(Math.abs(maxScrollProgress)); - } else { - translationX = minScrollProgress * v.getMeasuredWidth(); - interpolatedProgress = mZInterpolator.getInterpolation(Math.abs(minScrollProgress)); - } - float scale = (1 - interpolatedProgress) + - interpolatedProgress * TRANSITION_SCALE_FACTOR; - - float alpha; - if (isRtl && (scrollProgress > 0)) { - alpha = mAlphaInterpolator.getInterpolation(1 - Math.abs(maxScrollProgress)); - } else if (!isRtl && (scrollProgress < 0)) { - alpha = mAlphaInterpolator.getInterpolation(1 - Math.abs(scrollProgress)); - } else { - // On large screens we need to fade the page as it nears its leftmost position - alpha = mLeftScreenAlphaInterpolator.getInterpolation(1 - scrollProgress); - } - - v.setCameraDistance(mDensity * CAMERA_DISTANCE); - int pageWidth = v.getMeasuredWidth(); - int pageHeight = v.getMeasuredHeight(); - - if (PERFORM_OVERSCROLL_ROTATION) { - float xPivot = isRtl ? 1f - TRANSITION_PIVOT : TRANSITION_PIVOT; - boolean isOverscrollingFirstPage = isRtl ? scrollProgress > 0 : scrollProgress < 0; - boolean isOverscrollingLastPage = isRtl ? scrollProgress < 0 : scrollProgress > 0; - - if (i == 0 && isOverscrollingFirstPage) { - // Overscroll to the left - v.setPivotX(xPivot * pageWidth); - v.setRotationY(-TRANSITION_MAX_ROTATION * scrollProgress); - scale = 1.0f; - alpha = 1.0f; - // On the first page, we don't want the page to have any lateral motion - translationX = 0; - } else if (i == getChildCount() - 1 && isOverscrollingLastPage) { - // Overscroll to the right - v.setPivotX((1 - xPivot) * pageWidth); - v.setRotationY(-TRANSITION_MAX_ROTATION * scrollProgress); - scale = 1.0f; - alpha = 1.0f; - // On the last page, we don't want the page to have any lateral motion. - translationX = 0; - } else { - v.setPivotY(pageHeight / 2.0f); - v.setPivotX(pageWidth / 2.0f); - v.setRotationY(0f); - } - } - } - } - enableHwLayersOnVisiblePages(); } @@ -1505,7 +1401,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen } protected void overScroll(float amount) { - acceleratedOverScroll(amount); + dampedOverScroll(amount); } /** diff --git a/src/com/android/launcher3/AppsCustomizeTabHost.java b/src/com/android/launcher3/AppsCustomizeTabHost.java index 629bcdb1d..9a516fd41 100644 --- a/src/com/android/launcher3/AppsCustomizeTabHost.java +++ b/src/com/android/launcher3/AppsCustomizeTabHost.java @@ -174,7 +174,7 @@ public class AppsCustomizeTabHost extends FrameLayout implements LauncherTransit // Make sure the current page is loaded (we start loading the side pages after the // transition to prevent slowing down the animation) // TODO: revisit this - mPagedView.loadAssociatedPages(mPagedView.getCurrentPage(), true); + mPagedView.loadAssociatedPages(mPagedView.getCurrentPage()); } } diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java index 07120c5e4..93006b3f5 100644 --- a/src/com/android/launcher3/CellLayout.java +++ b/src/com/android/launcher3/CellLayout.java @@ -71,7 +71,6 @@ public class CellLayout extends ViewGroup { private int mWidthGap; private int mHeightGap; private int mMaxGap; - private boolean mScrollingTransformsDirty = false; private boolean mDropPending = false; // These are temporary variables to prevent having to allocate a new object just to @@ -388,23 +387,6 @@ public class CellLayout extends ViewGroup { return mIsDragOverlapping; } - protected void setOverscrollTransformsDirty(boolean dirty) { - mScrollingTransformsDirty = dirty; - } - - protected void resetOverscrollTransforms() { - if (mScrollingTransformsDirty) { - setOverscrollTransformsDirty(false); - setTranslationX(0); - setRotationY(0); - // It doesn't matter if we pass true or false here, the important thing is that we - // pass 0, which results in the overscroll drawable not being drawn any more. - setOverScrollAmount(0, false); - setPivotX(getMeasuredWidth() / 2); - setPivotY(getMeasuredHeight() / 2); - } - } - @Override protected void onDraw(Canvas canvas) { // When we're large, we are either drawn in a "hover" state (ie when dragging an item to diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 018fcfcbc..8af2a7fbb 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -126,6 +126,7 @@ public class DeviceProfile { int searchBarSpaceHeightPx; int searchBarHeightPx; int pageIndicatorHeightPx; + int allAppsButtonVisualSize; float dragViewScale; @@ -242,6 +243,18 @@ public class DeviceProfile { // Calculate the remaining vars updateFromConfiguration(context, res, wPx, hPx, awPx, ahPx); updateAvailableDimensions(context); + computeAllAppsButtonSize(context); + } + + /** + * Determine the exact visual footprint of the all apps button, taking into account scaling + * and internal padding of the drawable. + */ + private void computeAllAppsButtonSize(Context context) { + Resources res = context.getResources(); + float padding = res.getInteger(R.integer.config_allAppsButtonPaddingPercent) / 100f; + LauncherAppState app = LauncherAppState.getInstance(); + allAppsButtonVisualSize = (int) (hotseatIconSizePx * (1 - padding)); } void addCallback(DeviceProfileCallbacks cb) { diff --git a/src/com/android/launcher3/FocusHelper.java b/src/com/android/launcher3/FocusHelper.java index b1250ceea..df5e0fc33 100644 --- a/src/com/android/launcher3/FocusHelper.java +++ b/src/com/android/launcher3/FocusHelper.java @@ -57,16 +57,6 @@ class HotseatIconKeyEventListener implements View.OnKeyListener { } } -/** - * A keyboard listener we set on the last tab button in AppsCustomize to jump to then - * market icon and vice versa. - */ -class AppsCustomizeTabKeyEventListener implements View.OnKeyListener { - public boolean onKey(View v, int keyCode, KeyEvent event) { - return FocusHelper.handleAppsCustomizeTabKeyEvent(v, keyCode, event); - } -} - public class FocusHelper { /** * Private helper to get the parent TabHost in the view hiearchy. @@ -80,41 +70,6 @@ public class FocusHelper { } /** - * Handles key events in a AppsCustomize tab between the last tab view and the shop button. - */ - static boolean handleAppsCustomizeTabKeyEvent(View v, int keyCode, KeyEvent e) { - final AppsCustomizeTabHost tabHost = findTabHostParent(v); - final ViewGroup contents = tabHost.getContent(); - final View shop = tabHost.findViewById(R.id.market_button); - - final int action = e.getAction(); - final boolean handleKeyEvent = (action != KeyEvent.ACTION_UP); - boolean wasHandled = false; - switch (keyCode) { - case KeyEvent.KEYCODE_DPAD_RIGHT: - if (handleKeyEvent) { - // Select the shop button if we aren't on it - if (v != shop) { - shop.requestFocus(); - } - } - wasHandled = true; - break; - case KeyEvent.KEYCODE_DPAD_DOWN: - if (handleKeyEvent) { - // Select the content view (down is handled by the tab key handler otherwise) - if (v == shop) { - contents.requestFocus(); - wasHandled = true; - } - } - break; - default: break; - } - return wasHandled; - } - - /** * Returns the Viewgroup containing page contents for the page at the index specified. */ private static ViewGroup getAppsCustomizePage(ViewGroup container, int index) { diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index c9d423c34..090d2f753 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -242,6 +242,7 @@ public class Launcher extends Activity private static int NEW_APPS_PAGE_MOVE_DELAY = 500; private static int NEW_APPS_ANIMATION_INACTIVE_TIMEOUT_SECONDS = 5; private static int NEW_APPS_ANIMATION_DELAY = 500; + private static final int SINGLE_FRAME_DELAY = 16; private final BroadcastReceiver mCloseSystemDialogsReceiver = new CloseSystemDialogsIntentReceiver(); @@ -328,10 +329,6 @@ public class Launcher extends Activity // External icons saved in case of resource changes, orientation, etc. private static Drawable.ConstantState[] sGlobalSearchIcon = new Drawable.ConstantState[2]; private static Drawable.ConstantState[] sVoiceSearchIcon = new Drawable.ConstantState[2]; - private static Drawable.ConstantState[] sAppMarketIcon = new Drawable.ConstantState[2]; - - private Intent mAppMarketIntent = null; - private static final boolean DISABLE_MARKET_BUTTON = true; private Drawable mWorkspaceBackgroundDrawable; @@ -457,7 +454,6 @@ public class Launcher extends Activity Environment.getExternalStorageDirectory() + "/launcher"); } - checkForLocaleChange(); setContentView(R.layout.launcher); @@ -559,11 +555,7 @@ public class Launcher extends Activity boolean voiceVisible = false; // If we have a saved version of these external icons, we load them up immediately int coi = getCurrentOrientationIndexForGlobalIcons(); - if (sGlobalSearchIcon[coi] == null || sVoiceSearchIcon[coi] == null || - sAppMarketIcon[coi] == null) { - if (!DISABLE_MARKET_BUTTON) { - updateAppMarketIcon(); - } + if (sGlobalSearchIcon[coi] == null || sVoiceSearchIcon[coi] == null) { searchVisible = updateGlobalSearchIcon(); voiceVisible = updateVoiceSearchIcon(searchVisible); } @@ -575,9 +567,6 @@ public class Launcher extends Activity updateVoiceSearchIcon(sVoiceSearchIcon[coi]); voiceVisible = true; } - if (!DISABLE_MARKET_BUTTON && sAppMarketIcon[coi] != null) { - updateAppMarketIcon(sAppMarketIcon[coi]); - } if (mSearchDropTargetBar != null) { mSearchDropTargetBar.onSearchPackagesChanged(searchVisible, voiceVisible); } @@ -1757,11 +1746,6 @@ public class Launcher extends Activity } }); } - // When Launcher comes back to foreground, a different Activity might be responsible for - // the app market intent, so refresh the icon - if (!DISABLE_MARKET_BUTTON) { - updateAppMarketIcon(); - } clearTypedText(); } } @@ -2743,16 +2727,6 @@ public class Launcher extends Activity return mHapticFeedbackTouchListener; } - public void onClickAppMarketButton(View v) { - if (!DISABLE_MARKET_BUTTON) { - if (mAppMarketIntent != null) { - startActivitySafely(v, mAppMarketIntent, "app market"); - } else { - Log.e(TAG, "Invalid app market intent."); - } - } - } - public void onDragStarted(View view) {} /** @@ -3227,8 +3201,6 @@ public class Launcher extends Activity final float scale = (float) res.getInteger(R.integer.config_appsCustomizeZoomScaleFactor); final View fromView = mWorkspace; final AppsCustomizeTabHost toView = mAppsCustomizeTabHost; - final int startDelay = - res.getInteger(R.integer.config_workspaceAppsCustomizeAnimationStagger); Workspace.State workspaceState = contentType == AppsCustomizePagedView.ContentType.Widgets ? Workspace.State.OVERVIEW_HIDDEN : Workspace.State.NORMAL_HIDDEN; @@ -3249,7 +3221,10 @@ public class Launcher extends Activity final View page = content.getPageAt(content.getCurrentPage()); final View revealView = toView.findViewById(R.id.fake_page); - if (contentType == AppsCustomizePagedView.ContentType.Widgets) { + final float initialPanelAlpha = 1f; + + final boolean isWidgetTray = contentType == AppsCustomizePagedView.ContentType.Widgets; + if (isWidgetTray) { revealView.setBackground(res.getDrawable(R.drawable.quantum_panel_dark)); } else { revealView.setBackground(res.getDrawable(R.drawable.quantum_panel)); @@ -3263,15 +3238,21 @@ public class Launcher extends Activity int height = revealView.getMeasuredHeight(); float revealRadius = (float) Math.sqrt((width * width) / 4 + (height * height) / 4); - float yDrift = height / 2f; + revealView.setTranslationY(0); + // Get the y delta between the center of the page and the center of the all apps button + int[] allAppsToPanelDelta = Utilities.getCenterDeltaInScreenSpace(revealView, + getAllAppsButton(), null); + float yDrift = isWidgetTray ? height / 2 : allAppsToPanelDelta[1]; + + float initAlpha = isWidgetTray ? 0.3f : 1f; revealView.setLayerType(View.LAYER_TYPE_HARDWARE, null); - PropertyValuesHolder panelAlpha = PropertyValuesHolder.ofFloat("alpha", 0.4f, 1f); + PropertyValuesHolder panelAlpha = PropertyValuesHolder.ofFloat("alpha", initAlpha, 1f); PropertyValuesHolder panelDrift = - PropertyValuesHolder.ofFloat("translationY", yDrift, 0f); + PropertyValuesHolder.ofFloat("translationY", yDrift, 0); ObjectAnimator panelAlphaAndDrift = - ObjectAnimator.ofPropertyValuesHolder(revealView, panelAlpha, panelDrift); + LauncherAnimUtils.ofPropertyValuesHolder(revealView, panelAlpha, panelDrift); panelAlphaAndDrift.setDuration(revealDuration); panelAlphaAndDrift.setInterpolator(new LogDecelerateInterpolator(100, 0)); @@ -3281,15 +3262,14 @@ public class Launcher extends Activity page.setVisibility(View.VISIBLE); page.setLayerType(View.LAYER_TYPE_HARDWARE, null); - ObjectAnimator pageDrift = ObjectAnimator.ofFloat(page, "translationY", yDrift, 0); + ObjectAnimator pageDrift = LauncherAnimUtils.ofFloat(page, "translationY", yDrift, 0); pageDrift.setDuration(revealDuration); pageDrift.setInterpolator(new LogDecelerateInterpolator(100, 0)); + pageDrift.setStartDelay(itemsAlphaStagger); mStateAnimation.play(pageDrift); - // TODO (adamcohen): remove this 0.01f hack once fw is fixed - // it's there to work around a framework bug (16918357) - page.setAlpha(0.01f); - ObjectAnimator itemsAlpha = ObjectAnimator.ofFloat(page, "alpha", 0.01f, 1f); + page.setAlpha(0f); + ObjectAnimator itemsAlpha = LauncherAnimUtils.ofFloat(page, "alpha", 0f, 1f); itemsAlpha.setDuration(revealDuration); itemsAlpha.setInterpolator(new AccelerateInterpolator(1.5f)); itemsAlpha.setStartDelay(itemsAlphaStagger); @@ -3299,16 +3279,34 @@ public class Launcher extends Activity View pageIndicators = toView.findViewById(R.id.apps_customize_page_indicator); pageIndicators.setAlpha(0.01f); ObjectAnimator indicatorsAlpha = - ObjectAnimator.ofFloat(pageIndicators, "alpha", 1f); + LauncherAnimUtils.ofFloat(pageIndicators, "alpha", 1f); indicatorsAlpha.setDuration(revealDuration); mStateAnimation.play(indicatorsAlpha); if (material) { + final View allApps = getAllAppsButton(); + int allAppsButtonSize = LauncherAppState.getInstance(). + getDynamicGrid().getDeviceProfile().allAppsButtonVisualSize; + float startRadius = isWidgetTray ? 0 : allAppsButtonSize / 2; ValueAnimator reveal = (ValueAnimator) - ViewAnimationUtils.createCircularReveal(revealView, width / 2, - height / 2, 0f, revealRadius); + LauncherAnimUtils.createCircularReveal(revealView, width / 2, + height / 2, startRadius, revealRadius); reveal.setDuration(revealDuration); reveal.setInterpolator(new LogDecelerateInterpolator(100, 0)); + + reveal.addListener(new AnimatorListenerAdapter() { + public void onAnimationStart(Animator animation) { + if (!isWidgetTray) { + allApps.setVisibility(View.INVISIBLE); + } + } + public void onAnimationEnd(Animator animation) { + if (!isWidgetTray) { + allApps.setVisibility(View.VISIBLE); + } + } + }); + mStateAnimation.play(reveal); } @@ -3417,12 +3415,11 @@ public class Launcher extends Activity } boolean material = Utilities.isLmp(); - Resources res = getResources(); final int duration = res.getInteger(R.integer.config_appsCustomizeZoomOutTime); final int fadeOutDuration = res.getInteger(R.integer.config_appsCustomizeFadeOutTime); - final int revealDuration = res.getInteger(R.integer.config_appsCustomizeRevealTime); + final int revealDuration = res.getInteger(R.integer.config_appsCustomizeConcealTime); final int itemsAlphaStagger = res.getInteger(R.integer.config_appsCustomizeItemsAlphaStagger); @@ -3432,9 +3429,8 @@ public class Launcher extends Activity final View toView = mWorkspace; Animator workspaceAnim = null; if (toState == Workspace.State.NORMAL) { - int stagger = res.getInteger(R.integer.config_appsCustomizeWorkspaceAnimationStagger); workspaceAnim = mWorkspace.getChangeStateAnimation( - toState, animated, stagger, -1); + toState, animated); } else if (toState == Workspace.State.SPRING_LOADED || toState == Workspace.State.OVERVIEW) { workspaceAnim = mWorkspace.getChangeStateAnimation( @@ -3452,7 +3448,9 @@ public class Launcher extends Activity final View revealView = fromView.findViewById(R.id.fake_page); AppsCustomizePagedView.ContentType contentType = content.getContentType(); - if (contentType == AppsCustomizePagedView.ContentType.Widgets) { + final boolean isWidgetTray = contentType == AppsCustomizePagedView.ContentType.Widgets; + + if (isWidgetTray) { revealView.setBackground(res.getDrawable(R.drawable.quantum_panel_dark)); } else { revealView.setBackground(res.getDrawable(R.drawable.quantum_panel)); @@ -3466,34 +3464,43 @@ public class Launcher extends Activity revealView.setVisibility(View.VISIBLE); content.setPageBackgroundsVisible(false); - float yDrift = height / 2f; + final View allAppsButton = getAllAppsButton(); + revealView.setTranslationY(0); + int[] allAppsToPanelDelta = Utilities.getCenterDeltaInScreenSpace(revealView, + allAppsButton, null); + float yDrift = isWidgetTray ? height / 2 : allAppsToPanelDelta[1]; revealView.setLayerType(View.LAYER_TYPE_HARDWARE, null); - PropertyValuesHolder panelAlpha = PropertyValuesHolder.ofFloat(View.ALPHA, 1f, 0f); - PropertyValuesHolder panelDrift = - PropertyValuesHolder.ofFloat("translationY", 0, yDrift); - ObjectAnimator panelAlphaAndDrift = - ObjectAnimator.ofPropertyValuesHolder(revealView, panelAlpha, panelDrift); - panelAlphaAndDrift.setDuration(revealDuration); - - panelAlphaAndDrift.setInterpolator(new LogDecelerateInterpolator(100, 0)); - panelAlphaAndDrift.setStartDelay(itemsAlphaStagger); - - mStateAnimation.play(panelAlphaAndDrift); + // The vertical motion of the apps panel should be delayed by one frame + // from the conceal animation in order to give the right feel. We correpsondingly + // shorten the duration so that the slide and conceal end at the same time. + ObjectAnimator panelDrift = LauncherAnimUtils.ofFloat(revealView, "translationY", 0, yDrift); + panelDrift.setDuration(revealDuration - SINGLE_FRAME_DELAY); + panelDrift.setStartDelay(itemsAlphaStagger + SINGLE_FRAME_DELAY); + panelDrift.setInterpolator(new LogDecelerateInterpolator(100, 0)); + mStateAnimation.play(panelDrift); + + if (isWidgetTray) { + ObjectAnimator panelAlpha = LauncherAnimUtils.ofFloat(revealView, "alpha", 1f, 0.4f); + panelAlpha.setDuration(revealDuration); + panelAlpha.setInterpolator(new LogDecelerateInterpolator(100, 0)); + mStateAnimation.play(panelAlpha); + } if (page != null) { page.setLayerType(View.LAYER_TYPE_HARDWARE, null); - ObjectAnimator pageDrift = ObjectAnimator.ofFloat(page, "translationY", 0, yDrift); - pageDrift.setDuration(revealDuration); + ObjectAnimator pageDrift = LauncherAnimUtils.ofFloat(page, "translationY", + 0, yDrift); + pageDrift.setDuration(revealDuration - SINGLE_FRAME_DELAY); pageDrift.setInterpolator(new LogDecelerateInterpolator(100, 0)); - pageDrift.setStartDelay(itemsAlphaStagger); + pageDrift.setStartDelay(itemsAlphaStagger + SINGLE_FRAME_DELAY); mStateAnimation.play(pageDrift); page.setAlpha(1f); - ObjectAnimator itemsAlpha = ObjectAnimator.ofFloat(page, View.ALPHA, 1f, 0f); - itemsAlpha.setDuration(revealDuration); + ObjectAnimator itemsAlpha = LauncherAnimUtils.ofFloat(page, "alpha", 1f, 0f); + itemsAlpha.setDuration(100); itemsAlpha.setInterpolator(new LogDecelerateInterpolator(100, 0)); mStateAnimation.play(itemsAlpha); } @@ -3501,7 +3508,7 @@ public class Launcher extends Activity View pageIndicators = fromView.findViewById(R.id.apps_customize_page_indicator); pageIndicators.setAlpha(1f); ObjectAnimator indicatorsAlpha = - ObjectAnimator.ofFloat(pageIndicators, "alpha", 0f); + LauncherAnimUtils.ofFloat(pageIndicators, "alpha", 0f); indicatorsAlpha.setDuration(revealDuration); indicatorsAlpha.setInterpolator(new DecelerateInterpolator(1.5f)); mStateAnimation.play(indicatorsAlpha); @@ -3509,9 +3516,15 @@ public class Launcher extends Activity width = revealView.getMeasuredWidth(); if (material) { + if (!isWidgetTray) { + allAppsButton.setVisibility(View.INVISIBLE); + } + int allAppsButtonSize = LauncherAppState.getInstance(). + getDynamicGrid().getDeviceProfile().allAppsButtonVisualSize; + float finalRadius = isWidgetTray ? 0 : allAppsButtonSize / 2; Animator reveal = - ViewAnimationUtils.createCircularReveal(revealView, width / 2, - height / 2 + 100, revealRadius, 0f); + LauncherAnimUtils.createCircularReveal(revealView, width / 2, + height / 2, revealRadius, finalRadius); reveal.setInterpolator(new LogDecelerateInterpolator(100, 0)); reveal.setDuration(revealDuration); reveal.setStartDelay(itemsAlphaStagger); @@ -3519,6 +3532,9 @@ public class Launcher extends Activity reveal.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator animation) { revealView.setVisibility(View.INVISIBLE); + if (!isWidgetTray) { + allAppsButton.setVisibility(View.VISIBLE); + } } }); @@ -3970,44 +3986,6 @@ public class Launcher extends Activity public void disableVoiceButtonProxy(boolean disabled) { updateVoiceButtonProxyVisible(disabled); } - /** - * Sets the app market icon - */ - private void updateAppMarketIcon() { - if (!DISABLE_MARKET_BUTTON) { - final View marketButton = findViewById(R.id.market_button); - Intent intent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_APP_MARKET); - // Find the app market activity by resolving an intent. - // (If multiple app markets are installed, it will return the ResolverActivity.) - ComponentName activityName = intent.resolveActivity(getPackageManager()); - if (activityName != null) { - int coi = getCurrentOrientationIndexForGlobalIcons(); - mAppMarketIntent = intent; - sAppMarketIcon[coi] = updateTextButtonWithIconFromExternalActivity( - R.id.market_button, activityName, R.drawable.ic_launcher_market_holo, - TOOLBAR_ICON_METADATA_NAME); - marketButton.setVisibility(View.VISIBLE); - } else { - // We should hide and disable the view so that we don't try and restore the visibility - // of it when we swap between drag & normal states from IconDropTarget subclasses. - marketButton.setVisibility(View.GONE); - marketButton.setEnabled(false); - } - } - } - - private void updateAppMarketIcon(Drawable.ConstantState d) { - if (!DISABLE_MARKET_BUTTON) { - // Ensure that the new drawable we are creating has the approprate toolbar icon bounds - Resources r = getResources(); - Drawable marketIconDrawable = d.newDrawable(r); - int w = r.getDimensionPixelSize(R.dimen.toolbar_external_icon_width); - int h = r.getDimensionPixelSize(R.dimen.toolbar_external_icon_height); - marketIconDrawable.setBounds(0, 0, w, h); - - updateTextButtonWithDrawable(R.id.market_button, marketIconDrawable); - } - } @Override public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { @@ -4515,12 +4493,6 @@ public class Launcher extends Activity mWorkspace.restoreInstanceStateForRemainingPages(); - // Update the market app icon as necessary (the other icons will be managed in response to - // package changes in bindSearchablesChanged() - if (!DISABLE_MARKET_BUTTON) { - updateAppMarketIcon(); - } - setWorkspaceLoading(false); sendLoadingCompleteBroadcastIfNecessary(); diff --git a/src/com/android/launcher3/LauncherAnimUtils.java b/src/com/android/launcher3/LauncherAnimUtils.java index e6c220b2a..be295f8b3 100644 --- a/src/com/android/launcher3/LauncherAnimUtils.java +++ b/src/com/android/launcher3/LauncherAnimUtils.java @@ -22,6 +22,7 @@ import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.animation.ValueAnimator; import android.view.View; +import android.view.ViewAnimationUtils; import android.view.ViewTreeObserver; import java.util.HashSet; @@ -126,4 +127,14 @@ public class LauncherAnimUtils { new FirstFrameAnimatorHelper(anim, view); return anim; } + + public static Animator createCircularReveal(View view, int centerX, + int centerY, float startRadius, float endRadius) { + Animator anim = ViewAnimationUtils.createCircularReveal(view, centerX, + centerY, startRadius, endRadius); + if (anim instanceof ValueAnimator) { + new FirstFrameAnimatorHelper((ValueAnimator) anim, view); + } + return anim; + } } diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index 90a6b1598..54aa24ef6 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -74,11 +74,12 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc private static final int MIN_LENGTH_FOR_FLING = 25; protected static final int PAGE_SNAP_ANIMATION_DURATION = 750; + protected static final int OVER_SCROLL_PAGE_SNAP_ANIMATION_DURATION = 350; protected static final int SLOW_PAGE_SNAP_ANIMATION_DURATION = 950; protected static final float NANOTIME_DIV = 1000000000.0f; private static final float OVERSCROLL_ACCELERATE_FACTOR = 2; - private static final float OVERSCROLL_DAMP_FACTOR = 0.14f; + private static final float OVERSCROLL_DAMP_FACTOR = 0.07f; private static final float RETURN_TO_ORIGINAL_PAGE_THRESHOLD = 0.33f; // The page is moved more than halfway, automatically move to the next page on touch up. @@ -166,6 +167,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc protected int mUnboundedScrollX; protected int[] mTempVisiblePagesRange = new int[2]; protected boolean mForceDrawAllChildrenNextFrame; + private boolean mSpacePagesAutomatically = false; // mOverScrollX is equal to getScrollX() when we're within the normal scroll range. Otherwise // it is equal to the scaled overscroll position. We use a separate value so as to prevent @@ -844,6 +846,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc final int verticalPadding = getPaddingTop() + getPaddingBottom(); final int horizontalPadding = getPaddingLeft() + getPaddingRight(); + int referenceChildWidth = 0; // The children are given the same width and height as the workspace // unless they were set to WRAP_CONTENT if (DEBUG) Log.d(TAG, "PagedView.onMeasure(): " + widthSize + ", " + heightSize); @@ -888,6 +891,9 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc childWidth = getViewportWidth() - mInsets.left - mInsets.right; childHeight = getViewportHeight(); } + if (referenceChildWidth == 0) { + referenceChildWidth = childWidth; + } final int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(childWidth, childWidthMode); @@ -896,9 +902,24 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc child.measure(childWidthMeasureSpec, childHeightMeasureSpec); } } + if (mSpacePagesAutomatically) { + int spacing = (getViewportWidth() - mInsets.left - mInsets.right + - referenceChildWidth) / 2; + if (spacing >= 0) { + setPageSpacing(spacing); + } + mSpacePagesAutomatically = false; + } setMeasuredDimension(scaledWidthSize, scaledHeightSize); } + /** + * This method should be called once before first layout / measure pass. + */ + protected void setSinglePageInViewport() { + mSpacePagesAutomatically = true; + } + @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { if (!mIsDataReady || getChildCount() == 0) { @@ -1159,7 +1180,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc } protected boolean shouldDrawChild(View child) { - return child.getAlpha() > 0 && child.getVisibility() == VISIBLE; + return child.getVisibility() == VISIBLE; } @Override @@ -1581,29 +1602,20 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc return f * f * f + 1.0f; } - protected void acceleratedOverScroll(float amount) { + protected float acceleratedOverFactor(float amount) { int screenSize = getViewportWidth(); // We want to reach the max over scroll effect when the user has // over scrolled half the size of the screen float f = OVERSCROLL_ACCELERATE_FACTOR * (amount / screenSize); - if (f == 0) return; + if (f == 0) return 0; // Clamp this factor, f, to -1 < f < 1 if (Math.abs(f) >= 1) { f /= Math.abs(f); } - - int overScrollAmount = (int) Math.round(f * screenSize); - if (amount < 0) { - mOverScrollX = overScrollAmount; - super.scrollTo(0, getScrollY()); - } else { - mOverScrollX = mMaxScrollX + overScrollAmount; - super.scrollTo(mMaxScrollX, getScrollY()); - } - invalidate(); + return f; } protected void dampedOverScroll(float amount) { @@ -1622,10 +1634,10 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc int overScrollAmount = (int) Math.round(OVERSCROLL_DAMP_FACTOR * f * screenSize); if (amount < 0) { mOverScrollX = overScrollAmount; - super.scrollTo(0, getScrollY()); + super.scrollTo(mOverScrollX, getScrollY()); } else { mOverScrollX = mMaxScrollX + overScrollAmount; - super.scrollTo(mMaxScrollX, getScrollY()); + super.scrollTo(mOverScrollX, getScrollY()); } invalidate(); } @@ -2125,8 +2137,20 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc return minDistanceFromScreenCenterIndex; } + protected boolean isInOverScroll() { + return (mOverScrollX > mMaxScrollX || mOverScrollX < 0); + } + + protected int getPageSnapDuration() { + if (isInOverScroll()) { + return OVER_SCROLL_PAGE_SNAP_ANIMATION_DURATION; + } + return PAGE_SNAP_ANIMATION_DURATION; + + } + protected void snapToDestination() { - snapToPage(getPageNearestToCenterOfScreen(), PAGE_SNAP_ANIMATION_DURATION); + snapToPage(getPageNearestToCenterOfScreen(), getPageSnapDuration()); } private static class ScrollInterpolator implements Interpolator { @@ -2157,10 +2181,10 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc int delta = newX - mUnboundedScrollX; int duration = 0; - if (Math.abs(velocity) < mMinFlingVelocity) { + if (Math.abs(velocity) < mMinFlingVelocity || isInOverScroll()) { // If the velocity is low enough, then treat this more as an automatic page advance // as opposed to an apparent physical response to flinging - snapToPage(whichPage, PAGE_SNAP_ANIMATION_DURATION); + snapToPage(whichPage, getPageSnapDuration()); return; } @@ -2184,11 +2208,11 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc } protected void snapToPage(int whichPage) { - snapToPage(whichPage, PAGE_SNAP_ANIMATION_DURATION); + snapToPage(whichPage, getPageSnapDuration()); } protected void snapToPageImmediately(int whichPage) { - snapToPage(whichPage, PAGE_SNAP_ANIMATION_DURATION, true, null); + snapToPage(whichPage, getPageSnapDuration(), true, null); } protected void snapToPage(int whichPage, int duration) { diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index 60185c658..f70fc4d86 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -67,6 +67,8 @@ public final class Utilities { static int sColors[] = { 0xffff0000, 0xff00ff00, 0xff0000ff }; static int sColorIndex = 0; + static int[] sLoc0 = new int[2]; + static int[] sLoc1 = new int[2]; // To turn on these properties, type // adb shell setprop log.tag.PROPERTY_NAME [VERBOSE | SUPPRESS] @@ -346,6 +348,25 @@ public final class Utilities { } } + public static int[] getCenterDeltaInScreenSpace(View v0, View v1, int[] delta) { + v0.getLocationInWindow(sLoc0); + v1.getLocationInWindow(sLoc1); + + sLoc0[0] += (v0.getMeasuredWidth() * v0.getScaleX()) / 2; + sLoc0[1] += (v0.getMeasuredHeight() * v0.getScaleY()) / 2; + sLoc1[0] += (v1.getMeasuredWidth() * v1.getScaleX()) / 2; + sLoc1[1] += (v1.getMeasuredHeight() * v1.getScaleY()) / 2; + + if (delta == null) { + delta = new int[2]; + } + + delta[0] = sLoc1[0] - sLoc0[0]; + delta[1] = sLoc1[1] - sLoc0[1]; + + return delta; + } + public static void scaleRectAboutCenter(Rect r, float scale) { int cx = r.centerX(); int cy = r.centerY(); diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 8b3a51496..53a3f948d 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -215,7 +215,7 @@ public class Workspace extends SmoothPagedView private final Rect mTempRect = new Rect(); private final int[] mTempXY = new int[2]; private int[] mTempVisiblePagesRange = new int[2]; - private boolean mOverscrollTransformsSet; + private boolean mOverscrollEffectSet; public static final int DRAG_BITMAP_PADDING = 2; private boolean mWorkspaceFadeInAdjacentScreens; @@ -281,6 +281,8 @@ public class Workspace extends SmoothPagedView private int mLastChildCount = -1; private float mTransitionProgress; + float mOverScrollEffect = 0f; + private Runnable mDeferredAction; private boolean mDeferDropAfterUninstall; private boolean mUninstallSuccessful; @@ -1683,14 +1685,11 @@ public class Workspace extends SmoothPagedView updateStateForCustomContent(screenCenter); enableHwLayersOnVisiblePages(); - boolean shouldOverScroll = (mOverScrollX < 0 && (!hasCustomContent() || isLayoutRtl())) || - (mOverScrollX > mMaxScrollX && (!hasCustomContent() || !isLayoutRtl())); + boolean shouldOverScroll = (mOverScrollEffect < 0 && (!hasCustomContent() || isLayoutRtl())) || + (mOverScrollEffect > 0 && (!hasCustomContent() || !isLayoutRtl())); if (shouldOverScroll) { int index = 0; - float pivotX = 0f; - final float leftBiasedPivot = 0.25f; - final float rightBiasedPivot = 0.75f; final int lowerIndex = 0; final int upperIndex = getChildCount() - 1; @@ -1698,25 +1697,27 @@ public class Workspace extends SmoothPagedView index = (!isRtl && isLeftPage) || (isRtl && !isLeftPage) ? lowerIndex : upperIndex; CellLayout cl = (CellLayout) getChildAt(index); - float scrollProgress = getScrollProgress(screenCenter, cl, index); - cl.setOverScrollAmount(Math.abs(scrollProgress), isLeftPage); + float effect = Math.abs(mOverScrollEffect); + cl.setOverScrollAmount(Math.abs(effect), isLeftPage); - if (!mOverscrollTransformsSet) { - mOverscrollTransformsSet = true; - cl.setOverscrollTransformsDirty(true); - } + mOverscrollEffectSet = true; } else { - if (mOverscrollTransformsSet && getChildCount() > 0) { - mOverscrollTransformsSet = false; - ((CellLayout) getChildAt(0)).resetOverscrollTransforms(); - ((CellLayout) getChildAt(getChildCount() - 1)).resetOverscrollTransforms(); + if (mOverscrollEffectSet && getChildCount() > 0) { + mOverscrollEffectSet = false; + ((CellLayout) getChildAt(0)).setOverScrollAmount(0, false); + ((CellLayout) getChildAt(getChildCount() - 1)).setOverScrollAmount(0, false); } } } + private void computeOverScrollEffect(float amount) { + mOverScrollEffect = acceleratedOverFactor(amount); + } + @Override protected void overScroll(float amount) { - acceleratedOverScroll(amount); + computeOverScrollEffect(amount); + dampedOverScroll(amount); } protected void onAttachedToWindow() { @@ -2241,9 +2242,6 @@ public class Workspace extends SmoothPagedView } else if (stateIsOverview || stateIsOverviewHidden) { mNewScale = mOverviewModeShrinkFactor; } - if (workspaceToAllApps) { - updateChildrenLayersEnabled(false); - } } final int duration; |