diff options
author | Winson Chung <winsonc@google.com> | 2015-04-08 10:27:49 -0700 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2015-04-09 13:18:31 -0700 |
commit | 0f785720667ab8afe4b4620a6c333d382d8659ed (patch) | |
tree | 9bd5ddba76c5df2c700e05c7a1829e2fb4d14d92 | |
parent | 3f471440a8b6b71d4c15501a96befd3b715c9e8f (diff) | |
download | android_packages_apps_Trebuchet-0f785720667ab8afe4b4620a6c333d382d8659ed.tar.gz android_packages_apps_Trebuchet-0f785720667ab8afe4b4620a6c333d382d8659ed.tar.bz2 android_packages_apps_Trebuchet-0f785720667ab8afe4b4620a6c333d382d8659ed.zip |
Initial changes to support a fixed all-apps layout.
- Dynamically update padding and background depending on fixed bounds and searchbar
- Fixes issue with drag layer bg getting clobbered when rotating launcher
- Tapping outside the bounds of all apps should close all apps
- Fixing typo causing widgets to not show in sw720dp devices
Bug: 20127840
Change-Id: I29c3f905bdee940f938ffe054f58434887073092
20 files changed, 267 insertions, 125 deletions
diff --git a/res/drawable/apps_list_bg.xml b/res/drawable/apps_list_bg.xml index 64177c16b..0e56684b5 100644 --- a/res/drawable/apps_list_bg.xml +++ b/res/drawable/apps_list_bg.xml @@ -14,7 +14,9 @@ See the License for the specific language governing permissions and limitations under the License. --> -<inset xmlns:android="http://schemas.android.com/apk/res/android" - android:drawable="@drawable/apps_list_bg_inset" - android:insetLeft="@dimen/apps_container_inset" - android:insetRight="@dimen/apps_container_inset" />
\ No newline at end of file +<shape xmlns:android="http://schemas.android.com/apk/res/android" + android:shape="rectangle"> + <solid android:color="#ffffff" /> + <corners + android:radius="2dp" /> +</shape>
\ No newline at end of file diff --git a/res/drawable/apps_list_search_bg.xml b/res/drawable/apps_list_search_bg.xml index eda33a918..63c4d5591 100644 --- a/res/drawable/apps_list_search_bg.xml +++ b/res/drawable/apps_list_search_bg.xml @@ -18,6 +18,6 @@ android:shape="rectangle"> <solid android:color="#ffffff" /> <corners - android:topLeftRadius="3dp" - android:topRightRadius="3dp" /> + android:bottomLeftRadius="2dp" + android:bottomRightRadius="2dp" /> </shape>
\ No newline at end of file diff --git a/res/drawable/apps_reveal_bg.xml b/res/drawable/apps_reveal_bg.xml index 47c608f85..07505a596 100644 --- a/res/drawable/apps_reveal_bg.xml +++ b/res/drawable/apps_reveal_bg.xml @@ -14,7 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. --> -<inset xmlns:android="http://schemas.android.com/apk/res/android" - android:drawable="@drawable/apps_reveal_bg_inset" - android:insetLeft="@dimen/apps_container_inset" - android:insetRight="@dimen/apps_container_inset" />
\ No newline at end of file +<shape xmlns:android="http://schemas.android.com/apk/res/android" + android:shape="rectangle"> + <solid android:color="#ffffff" /> + <corners android:radius="2dp" /> +</shape>
\ No newline at end of file diff --git a/res/drawable/apps_reveal_bg_inset.xml b/res/drawable/apps_reveal_bg_inset.xml deleted file mode 100644 index 61f1c083a..000000000 --- a/res/drawable/apps_reveal_bg_inset.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - Copyright (C) 2015 The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> -<shape xmlns:android="http://schemas.android.com/apk/res/android" - android:shape="rectangle"> - <solid android:color="#ffffff" /> - <corners android:radius="3dp" /> -</shape>
\ No newline at end of file diff --git a/res/drawable/apps_list_bg_inset.xml b/res/drawable/apps_search_bg.xml index 5ea78952f..405e8447c 100644 --- a/res/drawable/apps_list_bg_inset.xml +++ b/res/drawable/apps_search_bg.xml @@ -18,6 +18,6 @@ android:shape="rectangle"> <solid android:color="#ffffff" /> <corners - android:bottomLeftRadius="3dp" - android:bottomRightRadius="3dp" /> + android:topLeftRadius="2dp" + android:topRightRadius="2dp" /> </shape>
\ No newline at end of file diff --git a/res/layout-sw600dp/apps_view.xml b/res/layout-sw600dp/apps_view.xml index fba170b2e..e6e0ec358 100644 --- a/res/layout-sw600dp/apps_view.xml +++ b/res/layout-sw600dp/apps_view.xml @@ -19,7 +19,6 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:padding="@dimen/apps_container_inset" - android:background="@drawable/apps_customize_bg" android:descendantFocusability="afterDescendants"> <include layout="@layout/apps_reveal_view" diff --git a/res/layout-sw720dp/launcher.xml b/res/layout-sw720dp/launcher.xml index 8bd827a25..a9601af6a 100644 --- a/res/layout-sw720dp/launcher.xml +++ b/res/layout-sw720dp/launcher.xml @@ -67,7 +67,7 @@ android:layout_gravity="center_horizontal" /> <include layout="@layout/widgets_view" - android:id="@+id/widget_view" + android:id="@+id/widgets_view" android:layout_width="match_parent" android:layout_height="match_parent" android:visibility="invisible" /> diff --git a/res/layout/apps_list_view.xml b/res/layout/apps_list_view.xml index 3e42f8489..595c46caf 100644 --- a/res/layout/apps_list_view.xml +++ b/res/layout/apps_list_view.xml @@ -25,8 +25,6 @@ android:id="@+id/app_search_box" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginLeft="@dimen/apps_container_inset" - android:layout_marginRight="@dimen/apps_container_inset" android:padding="16dp" android:hint="@string/apps_view_search_bar_hint" android:maxLines="1" @@ -37,7 +35,7 @@ android:textColor="#4c4c4c" android:textColorHint="#9c9c9c" android:imeOptions="actionDone|flagNoExtractUi" - android:background="@drawable/apps_list_search_bg" + android:background="@drawable/apps_search_bg" android:elevation="4dp" /> <com.android.launcher3.AppsContainerRecyclerView android:id="@+id/apps_list_view" @@ -48,6 +46,5 @@ android:paddingBottom="12dp" android:clipToPadding="false" android:focusable="true" - android:descendantFocusability="afterDescendants" - android:background="@drawable/apps_list_bg" /> + android:descendantFocusability="afterDescendants" /> </LinearLayout>
\ No newline at end of file diff --git a/res/layout/apps_reveal_view.xml b/res/layout/apps_reveal_view.xml index bc93359c1..2951ea4f4 100644 --- a/res/layout/apps_reveal_view.xml +++ b/res/layout/apps_reveal_view.xml @@ -21,5 +21,4 @@ android:layout_gravity="center" android:elevation="15dp" android:visibility="invisible" - android:background="@drawable/apps_reveal_bg" android:focusable="false" />
\ No newline at end of file diff --git a/res/layout/apps_view.xml b/res/layout/apps_view.xml index 86d67e15f..7f09f7795 100644 --- a/res/layout/apps_view.xml +++ b/res/layout/apps_view.xml @@ -21,9 +21,6 @@ android:id="@+id/apps_view" android:layout_width="match_parent" android:layout_height="match_parent" - android:paddingTop="@dimen/apps_container_inset" - android:paddingBottom="@dimen/apps_container_inset" - android:background="@drawable/apps_customize_bg" android:descendantFocusability="afterDescendants"> <include layout="@layout/apps_reveal_view" diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 7c99278a8..101b7558a 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -50,6 +50,8 @@ <dimen name="apps_container_width">0dp</dimen> <dimen name="apps_container_height">0dp</dimen> <dimen name="apps_container_inset">8dp</dimen> + <!-- Note: This needs to match the fixed insets for the search box --> + <dimen name="apps_container_fixed_bounds_inset">8dp</dimen> <dimen name="apps_grid_view_start_margin">52dp</dimen> <dimen name="apps_view_row_height">64dp</dimen> <dimen name="apps_view_section_text_size">24sp</dimen> diff --git a/src/com/android/launcher3/AppsContainerRecyclerView.java b/src/com/android/launcher3/AppsContainerRecyclerView.java index c93bacf93..bb2aeb096 100644 --- a/src/com/android/launcher3/AppsContainerRecyclerView.java +++ b/src/com/android/launcher3/AppsContainerRecyclerView.java @@ -196,13 +196,27 @@ public class AppsContainerRecyclerView extends RecyclerView } break; case MotionEvent.ACTION_UP: + ViewConfiguration viewConfig = ViewConfiguration.get(getContext()); + float dx = ev.getX() - mDownX; + float dy = ev.getY() - mDownY; + float distance = (float) Math.sqrt(dx * dx + dy * dy); + if (distance < viewConfig.getScaledTouchSlop()) { + Rect backgroundPadding = new Rect(); + getBackground().getPadding(backgroundPadding); + boolean isOutsideBounds = ev.getX() < backgroundPadding.left || + ev.getX() > (getWidth() - backgroundPadding.right); + if (isOutsideBounds) { + Launcher launcher = (Launcher) getContext(); + launcher.showWorkspace(true); + } + } + // Fall through case MotionEvent.ACTION_CANCEL: mDraggingFastScroller = false; animateFastScrollerVisibility(false); break; } return mDraggingFastScroller; - } /** diff --git a/src/com/android/launcher3/AppsContainerView.java b/src/com/android/launcher3/AppsContainerView.java index 2de45cbcc..559f6eb83 100644 --- a/src/com/android/launcher3/AppsContainerView.java +++ b/src/com/android/launcher3/AppsContainerView.java @@ -19,6 +19,7 @@ import android.content.Context; import android.content.res.Resources; import android.graphics.Point; import android.graphics.Rect; +import android.graphics.drawable.InsetDrawable; import android.support.v7.widget.RecyclerView; import android.text.Editable; import android.text.TextWatcher; @@ -26,12 +27,13 @@ import android.util.AttributeSet; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; +import android.view.ViewConfiguration; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; import android.widget.FrameLayout; +import android.widget.LinearLayout; import android.widget.TextView; - import com.android.launcher3.util.Thunk; import java.util.List; @@ -59,8 +61,13 @@ public class AppsContainerView extends FrameLayout implements DragSource, Insett private EditText mSearchBar; private int mNumAppsPerRow; private Point mLastTouchDownPos = new Point(); - private Rect mPadding = new Rect(); + private Rect mInsets = new Rect(); + private Rect mFixedBounds = new Rect(); private int mContentMarginStart; + // Normal container insets + private int mContainerInset; + // Fixed bounds container insets + private int mFixedBoundsContainerInset; public AppsContainerView(Context context) { this(context, null); @@ -76,6 +83,10 @@ public class AppsContainerView extends FrameLayout implements DragSource, Insett DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); Resources res = context.getResources(); + mContainerInset = context.getResources().getDimensionPixelSize( + R.dimen.apps_container_inset); + mFixedBoundsContainerInset = context.getResources().getDimensionPixelSize( + R.dimen.apps_container_fixed_bounds_inset); mLauncher = (Launcher) context; mApps = new AlphabeticalAppsList(context); if (USE_LAYOUT == GRID_LAYOUT) { @@ -126,6 +137,15 @@ public class AppsContainerView extends FrameLayout implements DragSource, Insett } /** + * Hides the search bar + */ + public void hideSearchBar() { + mSearchBar.setVisibility(View.GONE); + updateBackgrounds(); + updatePaddings(); + } + + /** * Scrolls this list view to the top. */ public void scrollToTop() { @@ -154,45 +174,58 @@ public class AppsContainerView extends FrameLayout implements DragSource, Insett ((AppsGridAdapter) mAdapter).setRtl(isRtl); } mSearchBar = (EditText) findViewById(R.id.app_search_box); - mSearchBar.addTextChangedListener(this); - mSearchBar.setOnEditorActionListener(this); + if (mSearchBar != null) { + mSearchBar.addTextChangedListener(this); + mSearchBar.setOnEditorActionListener(this); + } mAppsListView = (AppsContainerRecyclerView) findViewById(R.id.apps_list_view); mAppsListView.setApps(mApps); mAppsListView.setNumAppsPerRow(mNumAppsPerRow); mAppsListView.setLayoutManager(mLayoutManager); mAppsListView.setAdapter(mAdapter); mAppsListView.setHasFixedSize(true); - if (isRtl) { - mAppsListView.setPadding( - mAppsListView.getPaddingLeft(), - mAppsListView.getPaddingTop(), - mAppsListView.getPaddingRight() + mContentMarginStart, - mAppsListView.getPaddingBottom()); - } else { - mAppsListView.setPadding( - mAppsListView.getPaddingLeft() + mContentMarginStart, - mAppsListView.getPaddingTop(), - mAppsListView.getPaddingRight(), - mAppsListView.getPaddingBottom()); - } if (mItemDecoration != null) { mAppsListView.addItemDecoration(mItemDecoration); } - mPadding.set(getPaddingLeft(), getPaddingTop(), getPaddingRight(), - getPaddingBottom()); + updateBackgrounds(); + updatePaddings(); } @Override public void setInsets(Rect insets) { - setPadding(mPadding.left + insets.left, mPadding.top + insets.top, - mPadding.right + insets.right, mPadding.bottom + insets.bottom); + mInsets.set(insets); + updatePaddings(); + } + + /** + * Sets the fixed bounds for this Apps view. + */ + public void setFixedBounds(Context context, Rect fixedBounds) { + if (!fixedBounds.isEmpty() && !fixedBounds.equals(mFixedBounds)) { + // Update the number of items in the grid + LauncherAppState app = LauncherAppState.getInstance(); + DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); + if (grid.updateAppsViewNumCols(context.getResources(), fixedBounds.width())) { + mNumAppsPerRow = grid.appsViewNumCols; + mAppsListView.setNumAppsPerRow(mNumAppsPerRow); + if (USE_LAYOUT == GRID_LAYOUT) { + ((AppsGridAdapter) mAdapter).setNumAppsPerRow(mNumAppsPerRow); + } + } + + mFixedBounds.set(fixedBounds); + } + updateBackgrounds(); + updatePaddings(); } @Override public boolean onTouch(View v, MotionEvent ev) { - if (ev.getAction() == MotionEvent.ACTION_DOWN || - ev.getAction() == MotionEvent.ACTION_MOVE) { - mLastTouchDownPos.set((int) ev.getX(), (int) ev.getY()); + switch (ev.getAction()) { + case MotionEvent.ACTION_DOWN: + case MotionEvent.ACTION_MOVE: + mLastTouchDownPos.set((int) ev.getX(), (int) ev.getY()); + break; } return false; } @@ -359,7 +392,9 @@ public class AppsContainerView extends FrameLayout implements DragSource, Insett public void onLauncherTransitionPrepare(Launcher l, boolean animated, boolean toWorkspace) { if (!toWorkspace) { // Disable the focus so that the search bar doesn't get focus - mSearchBar.setFocusableInTouchMode(false); + if (mSearchBar != null) { + mSearchBar.setFocusableInTouchMode(false); + } } } @@ -375,11 +410,69 @@ public class AppsContainerView extends FrameLayout implements DragSource, Insett @Override public void onLauncherTransitionEnd(Launcher l, boolean animated, boolean toWorkspace) { - if (toWorkspace) { - // Clear the search bar - mSearchBar.setText(""); + if (mSearchBar != null) { + if (toWorkspace) { + // Clear the search bar + mSearchBar.setText(""); + } else { + mSearchBar.setFocusableInTouchMode(true); + } + } + } + + /** + * Update the padding of the Apps view and children. To ensure that the RecyclerView has the + * full width to handle touches right to the edge of the screen, we only apply the top and + * bottom padding to the AppsContainerView and then the left/right padding on the RecyclerView + * itself. In particular, the left/right padding is applied to the background of the view, + * and then additionally inset by the start margin. + */ + private void updatePaddings() { + boolean isRtl = (getResources().getConfiguration().getLayoutDirection() == + LAYOUT_DIRECTION_RTL); + boolean hasSearchBar = (mSearchBar != null) && (mSearchBar.getVisibility() == View.VISIBLE); + + if (mFixedBounds.isEmpty()) { + // If there are no fixed bounds, then use the default padding and insets + setPadding(mInsets.left, mContainerInset + mInsets.top, mInsets.right, + mContainerInset + mInsets.bottom); } else { - mSearchBar.setFocusableInTouchMode(true); + // If there are fixed bounds, then we update the padding to reflect the fixed bounds. + setPadding(mFixedBounds.left, mFixedBounds.top + mFixedBoundsContainerInset, + getMeasuredWidth() - mFixedBounds.right, + mInsets.bottom + mFixedBoundsContainerInset); } + + // Update the apps recycler view + int inset = mFixedBounds.isEmpty() ? mContainerInset : mFixedBoundsContainerInset; + if (isRtl) { + mAppsListView.setPadding(inset, inset, inset + mContentMarginStart, inset); + } else { + mAppsListView.setPadding(inset + mContentMarginStart, inset, inset, inset); + } + + // Update the search bar + if (hasSearchBar) { + LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mSearchBar.getLayoutParams(); + lp.leftMargin = lp.rightMargin = inset; + } + } + + /** + * Update the background of the Apps view and children. + */ + private void updateBackgrounds() { + int inset = mFixedBounds.isEmpty() ? mContainerInset : mFixedBoundsContainerInset; + boolean hasSearchBar = (mSearchBar != null) && (mSearchBar.getVisibility() == View.VISIBLE); + + // Update the background of the reveal view and list to be inset with the fixed bound + // insets instead of the default insets + mAppsListView.setBackground(new InsetDrawable( + getContext().getResources().getDrawable( + hasSearchBar ? R.drawable.apps_list_search_bg : R.drawable.apps_list_bg), + inset, 0, inset, 0)); + getRevealView().setBackground(new InsetDrawable( + getContext().getResources().getDrawable(R.drawable.apps_reveal_bg), + inset, 0, inset, 0)); } } diff --git a/src/com/android/launcher3/AppsGridAdapter.java b/src/com/android/launcher3/AppsGridAdapter.java index 5b6967c26..c8ce397f2 100644 --- a/src/com/android/launcher3/AppsGridAdapter.java +++ b/src/com/android/launcher3/AppsGridAdapter.java @@ -112,6 +112,7 @@ class AppsGridAdapter extends RecyclerView.Adapter<AppsGridAdapter.ViewHolder> { private LayoutInflater mLayoutInflater; @Thunk AlphabeticalAppsList mApps; + private GridLayoutManager mGridLayoutMgr; private GridSpanSizer mGridSizer; private GridItemDecoration mItemDecoration; private View.OnTouchListener mTouchListener; @@ -135,6 +136,9 @@ class AppsGridAdapter extends RecyclerView.Adapter<AppsGridAdapter.ViewHolder> { mApps = apps; mAppsPerRow = appsPerRow; mGridSizer = new GridSpanSizer(); + mGridLayoutMgr = new GridLayoutManager(context, appsPerRow, GridLayoutManager.VERTICAL, + false); + mGridLayoutMgr.setSpanSizeLookup(mGridSizer); mItemDecoration = new GridItemDecoration(); mLayoutInflater = LayoutInflater.from(context); mTouchListener = touchListener; @@ -150,6 +154,14 @@ class AppsGridAdapter extends RecyclerView.Adapter<AppsGridAdapter.ViewHolder> { } /** + * Sets the number of apps per row. + */ + public void setNumAppsPerRow(int appsPerRow) { + mAppsPerRow = appsPerRow; + mGridLayoutMgr.setSpanCount(appsPerRow); + } + + /** * Sets whether we are in RTL mode. */ public void setRtl(boolean rtl) { @@ -167,10 +179,7 @@ class AppsGridAdapter extends RecyclerView.Adapter<AppsGridAdapter.ViewHolder> { * Returns the grid layout manager. */ public GridLayoutManager getLayoutManager(Context context) { - GridLayoutManager layoutMgr = new GridLayoutManager(context, mAppsPerRow, - GridLayoutManager.VERTICAL, false); - layoutMgr.setSpanSizeLookup(mGridSizer); - return layoutMgr; + return mGridLayoutMgr; } /** diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index ea2852080..786f2ce03 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -423,13 +423,21 @@ public class DeviceProfile { allAppsNumCols = Math.max(minEdgeCellCount, Math.min(maxCols, allAppsNumCols)); } - int appsContainerViewPx = res.getDimensionPixelSize(R.dimen.apps_container_width); + int appsContainerViewWidthPx = res.getDimensionPixelSize(R.dimen.apps_container_width); + updateAppsViewNumCols(res, appsContainerViewWidthPx); + } + + public boolean updateAppsViewNumCols(Resources res, int containerWidth) { int appsViewLeftMarginPx = res.getDimensionPixelSize(R.dimen.apps_grid_view_start_margin); - int availableAppsWidthPx = (appsContainerViewPx > 0) ? appsContainerViewPx : - availableWidthPx; - appsViewNumCols = (availableAppsWidthPx - appsViewLeftMarginPx) / + int availableAppsWidthPx = (containerWidth > 0) ? containerWidth : availableWidthPx; + int numCols = (availableAppsWidthPx - appsViewLeftMarginPx) / (allAppsCellWidthPx + 2 * allAppsCellPaddingPx); + if (numCols != appsViewNumCols) { + appsViewNumCols = numCols; + return true; + } + return false; } void updateFromConfiguration(Context context, Resources resources, int wPx, int hPx, diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 068934e1b..3d2a34647 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -520,6 +520,17 @@ public class Launcher extends Activity public boolean setLauncherCallbacks(LauncherCallbacks callbacks) { mLauncherCallbacks = callbacks; + mLauncherCallbacks.setLauncherAppsCallback(new Launcher.LauncherAppsCallbacks() { + @Override + public void onAllAppsBoundsChanged(Rect bounds) { + mAppsView.setFixedBounds(Launcher.this, bounds); + } + + @Override + public void dismissAllApps() { + showWorkspace(true); + } + }); return true; } @@ -1141,6 +1152,19 @@ public class Launcher extends Activity public void forceExitFullImmersion(); } + public interface LauncherAppsCallbacks { + /** + * Updates launcher to the available space that AllApps can take so as not to overlap with + * any other views. + */ + public void onAllAppsBoundsChanged(Rect bounds); + + /** + * Called to dismiss all apps if it is showing. + */ + public void dismissAllApps(); + } + public interface LauncherOverlayCallbacks { /** * This method indicates whether a call to {@link #enterFullImmersion()} will succeed, @@ -1418,6 +1442,9 @@ public class Launcher extends Activity // Setup Apps mAppsView = (AppsContainerView) findViewById(R.id.apps_view); + if (mLauncherCallbacks != null && mLauncherCallbacks.overrideAllAppsSearch()) { + mAppsView.hideSearchBar(); + } // Setup AppsCustomize mWidgetsView = (WidgetsContainerView) findViewById(R.id.widgets_view); @@ -2587,9 +2614,6 @@ public class Launcher extends Activity } else { showAppsView(true /* animated */, false /* resetListToTop */); } - if (mLauncherCallbacks != null) { - mLauncherCallbacks.onClickAllAppsButton(v); - } } private void showBrokenAppInstallDialog(final String packageName, @@ -3270,7 +3294,9 @@ public class Launcher extends Activity } void showWorkspace(boolean animated, Runnable onCompleteRunnable) { - if (mState != State.WORKSPACE || mWorkspace.getState() != Workspace.State.NORMAL) { + boolean changed = mState != State.WORKSPACE || + mWorkspace.getState() != Workspace.State.NORMAL; + if (changed) { boolean wasInSpringLoadedMode = (mState != State.WORKSPACE); mWorkspace.setVisibility(View.VISIBLE); mStateTransitionAnimation.startAnimationToWorkspace(mState, Workspace.State.NORMAL, @@ -3295,11 +3321,13 @@ public class Launcher extends Activity mUserPresent = true; updateAutoAdvanceState(); - // Send an accessibility event to announce the context change - getWindow().getDecorView() - .sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); + if (changed) { + // Send an accessibility event to announce the context change + getWindow().getDecorView() + .sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); - onWorkspaceShown(animated); + onWorkspaceShown(animated); + } } void showOverviewMode(boolean animated) { @@ -3350,6 +3378,9 @@ public class Launcher extends Activity if (toState == State.APPS) { mStateTransitionAnimation.startAnimationToAllApps(animated); + if (mLauncherCallbacks != null) { + mLauncherCallbacks.onAllAppsShown(); + } } else { mStateTransitionAnimation.startAnimationToWidgets(animated); } diff --git a/src/com/android/launcher3/LauncherCallbacks.java b/src/com/android/launcher3/LauncherCallbacks.java index d8128d6e5..2fee81c3d 100644 --- a/src/com/android/launcher3/LauncherCallbacks.java +++ b/src/com/android/launcher3/LauncherCallbacks.java @@ -50,6 +50,7 @@ public interface LauncherCallbacks { public void onLauncherProviderChange(); public void finishBindingItems(final boolean upgradePath); public void onClickAllAppsButton(View v); + public void onAllAppsShown(); public void bindAllApplications(ArrayList<AppInfo> apps); public void onClickFolderIcon(View v); public void onClickAppShortcut(View v); @@ -87,6 +88,7 @@ public interface LauncherCallbacks { public ComponentName getWallpaperPickerComponent(); public boolean overrideWallpaperDimensions(); public boolean isLauncherPreinstalled(); + public boolean overrideAllAppsSearch(); /** * Returning true will immediately result in a call to {@link #setLauncherOverlayView(ViewGroup, @@ -106,4 +108,12 @@ public interface LauncherCallbacks { public Launcher.LauncherOverlay setLauncherOverlayView(InsettableFrameLayout container, Launcher.LauncherOverlayCallbacks callbacks); + /** + * Sets the callbacks to allow any extensions to callback to the launcher. + * + * @param callbacks A set of callbacks to the Launcher, is actually a LauncherAppsCallback, but + * for implementation purposes is passed around as an object. + */ + public void setLauncherAppsCallback(Object callbacks); + } diff --git a/src/com/android/launcher3/LauncherExtension.java b/src/com/android/launcher3/LauncherExtension.java index fe9bd6c23..e4fdbbc7c 100644 --- a/src/com/android/launcher3/LauncherExtension.java +++ b/src/com/android/launcher3/LauncherExtension.java @@ -124,6 +124,10 @@ public class LauncherExtension extends Launcher { } @Override + public void onAllAppsShown() { + } + + @Override public void bindAllApplications(ArrayList<AppInfo> apps) { } @@ -246,6 +250,11 @@ public class LauncherExtension extends Launcher { } @Override + public boolean overrideAllAppsSearch() { + return false; + } + + @Override public boolean isLauncherPreinstalled() { return false; } @@ -265,6 +274,11 @@ public class LauncherExtension extends Launcher { return mLauncherOverlay; } + @Override + public void setLauncherAppsCallback(Object callbacks) { + // Do nothing + } + class LauncherExtensionOverlay implements LauncherOverlay { LauncherOverlayCallbacks mLauncherOverlayCallbacks; ViewGroup mOverlayView; diff --git a/src/com/android/launcher3/LauncherStateTransitionAnimation.java b/src/com/android/launcher3/LauncherStateTransitionAnimation.java index e92bfb053..57bd5b2c6 100644 --- a/src/com/android/launcher3/LauncherStateTransitionAnimation.java +++ b/src/com/android/launcher3/LauncherStateTransitionAnimation.java @@ -174,7 +174,7 @@ public class LauncherStateTransitionAnimation { } }; startAnimationToOverlay(Workspace.State.NORMAL_HIDDEN, toView, toView.getContentView(), - toView.getRevealView(), null, animated, cb); + toView.getRevealView(), animated, false /* hideSearchBar */, cb); } /** @@ -198,7 +198,7 @@ public class LauncherStateTransitionAnimation { } }; startAnimationToOverlay(Workspace.State.OVERVIEW_HIDDEN, toView, toView.getContentView(), - toView.getRevealView(), null, animated, cb); + toView.getRevealView(), animated, true /* hideSearchBar */, cb); } /** @@ -226,8 +226,8 @@ public class LauncherStateTransitionAnimation { * Creates and starts a new animation to a particular overlay view. */ private void startAnimationToOverlay(final Workspace.State toWorkspaceState, final View toView, - final View contentView, final View revealView, final View pageIndicatorsView, - final boolean animated, final PrivateTransitionCallbacks pCb) { + final View contentView, final View revealView, final boolean animated, + final boolean hideSearchBar, final PrivateTransitionCallbacks pCb) { final Resources res = mLauncher.getResources(); final boolean material = Utilities.isLmpOrAbove(); final int revealDuration = res.getInteger(R.integer.config_appsCustomizeRevealTime); @@ -293,15 +293,6 @@ public class LauncherStateTransitionAnimation { layerViews.put(revealView, BUILD_AND_SET_LAYER); mStateAnimation.play(panelAlphaAndDrift); - // Setup the animation for the page indicators - if (pageIndicatorsView != null) { - pageIndicatorsView.setAlpha(0.01f); - ObjectAnimator indicatorsAlpha = - ObjectAnimator.ofFloat(pageIndicatorsView, "alpha", 1f); - indicatorsAlpha.setDuration(revealDuration); - mStateAnimation.play(indicatorsAlpha); - } - // Setup the animation for the content view contentView.setVisibility(View.VISIBLE); contentView.setAlpha(0f); @@ -354,8 +345,9 @@ public class LauncherStateTransitionAnimation { } } - // Hide the search bar - mCb.onStateTransitionHideSearchBar(); + if (hideSearchBar) { + mCb.onStateTransitionHideSearchBar(); + } // This can hold unnecessary references to views. mStateAnimation = null; @@ -414,8 +406,9 @@ public class LauncherStateTransitionAnimation { // Show the content view contentView.setVisibility(View.VISIBLE); - // Hide the search bar - mCb.onStateTransitionHideSearchBar(); + if (hideSearchBar) { + mCb.onStateTransitionHideSearchBar(); + } dispatchOnLauncherTransitionPrepare(fromView, animated, false); dispatchOnLauncherTransitionStart(fromView, animated, false); @@ -484,8 +477,7 @@ public class LauncherStateTransitionAnimation { } }; startAnimationToWorkspaceFromOverlay(toWorkspaceState, appsView, appsView.getContentView(), - appsView.getRevealView(), null /* pageIndicatorsView */, animated, - onCompleteRunnable, cb); + appsView.getRevealView(), animated, onCompleteRunnable, cb); } /** @@ -516,8 +508,8 @@ public class LauncherStateTransitionAnimation { } }; startAnimationToWorkspaceFromOverlay(toWorkspaceState, widgetsView, - widgetsView.getContentView(), widgetsView.getRevealView(), - null, animated, onCompleteRunnable, cb); + widgetsView.getContentView(), widgetsView.getRevealView(), animated, + onCompleteRunnable, cb); } /** @@ -525,8 +517,8 @@ public class LauncherStateTransitionAnimation { */ private void startAnimationToWorkspaceFromOverlay(final Workspace.State toWorkspaceState, final View fromView, final View contentView, final View revealView, - final View pageIndicatorsView, final boolean animated, - final Runnable onCompleteRunnable, final PrivateTransitionCallbacks pCb) { + final boolean animated, final Runnable onCompleteRunnable, + final PrivateTransitionCallbacks pCb) { final Resources res = mLauncher.getResources(); final boolean material = Utilities.isLmpOrAbove(); final int revealDuration = res.getInteger(R.integer.config_appsCustomizeRevealTime); @@ -631,16 +623,6 @@ public class LauncherStateTransitionAnimation { itemsAlpha.setInterpolator(decelerateInterpolator); mStateAnimation.play(itemsAlpha); - // Setup the page indicators animation - if (pageIndicatorsView != null) { - pageIndicatorsView.setAlpha(1f); - ObjectAnimator indicatorsAlpha = - LauncherAnimUtils.ofFloat(pageIndicatorsView, "alpha", 0f); - indicatorsAlpha.setDuration(revealDuration); - indicatorsAlpha.setInterpolator(new DecelerateInterpolator(1.5f)); - mStateAnimation.play(indicatorsAlpha); - } - if (material) { // Animate the all apps button float finalRadius = pCb.getMaterialRevealViewStartFinalRadius(); diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 8cc99a044..91739711b 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -1700,7 +1700,11 @@ public class Workspace extends SmoothPagedView mLastCustomContentScrollProgress = progress; - mLauncher.getDragLayer().setBackgroundAlpha(progress * 0.8f); + // We should only update the drag layer background alpha if we are not in all apps or the + // widgets tray + if (mState == State.NORMAL) { + mLauncher.getDragLayer().setBackgroundAlpha(progress * 0.8f); + } if (mLauncher.getHotseat() != null) { mLauncher.getHotseat().setTranslationX(translationX); @@ -2252,7 +2256,8 @@ public class Workspace extends SmoothPagedView float finalBackgroundAlpha = (stateIsSpringLoaded || stateIsOverview) ? 1.0f : 0f; float finalHotseatAndPageIndicatorAlpha = (stateIsNormal || stateIsSpringLoaded) ? 1f : 0f; float finalOverviewPanelAlpha = stateIsOverview ? 1f : 0f; - float finalSearchBarAlpha = !stateIsNormal ? 0f : 1f; + // We keep the search bar visible on the workspace and in AllApps now + float finalSearchBarAlpha = (stateIsNormal || stateIsNormalHidden) ? 1f : 0f; float finalWorkspaceTranslationY = stateIsOverview || stateIsOverviewHidden ? getOverviewModeTranslationY() : 0; |