Merge "Initial changes to support a fixed all-apps layout." into ub-launcher3-burnaby

This commit is contained in:
Winson Chung
2015-04-09 23:55:57 +00:00
committed by Android (Google) Code Review
20 changed files with 268 additions and 126 deletions
+6 -4
View File
@@ -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" />
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#ffffff" />
<corners
android:radius="2dp" />
</shape>
+2 -2
View File
@@ -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>
+5 -4
View File
@@ -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" />
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#ffffff" />
<corners android:radius="2dp" />
</shape>
-21
View File
@@ -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>
@@ -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>
-1
View File
@@ -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"
+1 -1
View File
@@ -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" />
+2 -5
View File
@@ -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>
-1
View File
@@ -21,5 +21,4 @@
android:layout_gravity="center"
android:elevation="15dp"
android:visibility="invisible"
android:background="@drawable/apps_reveal_bg"
android:focusable="false" />
-3
View File
@@ -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"
+2
View File
@@ -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>
@@ -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;
}
/**
+123 -30
View File
@@ -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) {
@@ -125,6 +136,15 @@ public class AppsContainerView extends FrameLayout implements DragSource, Insett
mApps.removeApps(apps);
}
/**
* Hides the search bar
*/
public void hideSearchBar() {
mSearchBar.setVisibility(View.GONE);
updateBackgrounds();
updatePaddings();
}
/**
* Scrolls this list view to the top.
*/
@@ -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("");
} else {
mSearchBar.setFocusableInTouchMode(true);
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 {
// 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));
}
}
+13 -4
View File
@@ -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;
@@ -149,6 +153,14 @@ class AppsGridAdapter extends RecyclerView.Adapter<AppsGridAdapter.ViewHolder> {
mSectionTextPaint.setAntiAlias(true);
}
/**
* Sets the number of apps per row.
*/
public void setNumAppsPerRow(int appsPerRow) {
mAppsPerRow = appsPerRow;
mGridLayoutMgr.setSpanCount(appsPerRow);
}
/**
* Sets whether we are in RTL mode.
*/
@@ -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;
}
/**
+12 -4
View File
@@ -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,
+39 -8
View File
@@ -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);
}
@@ -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);
}
@@ -123,6 +123,10 @@ public class LauncherExtension extends Launcher {
public void onClickAllAppsButton(View v) {
}
@Override
public void onAllAppsShown() {
}
@Override
public void bindAllApplications(ArrayList<AppInfo> apps) {
}
@@ -245,6 +249,11 @@ public class LauncherExtension extends Launcher {
return false;
}
@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;
@@ -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();
+7 -2
View File
@@ -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;