diff options
author | Android Build Merger (Role) <noreply-android-build-merger@google.com> | 2018-04-27 20:34:22 +0000 |
---|---|---|
committer | Android Build Merger (Role) <noreply-android-build-merger@google.com> | 2018-04-27 20:34:22 +0000 |
commit | 37048c1e9f366972d0f891f9dde54b4248f50e3a (patch) | |
tree | 3459b65ffb4389b2101be7f675787a7b80e946b2 /quickstep | |
parent | 87b264fe7f9db8bff2a387b3199523548a4e0aff (diff) | |
parent | cc0c98ad945a911499e92bcf3a5bc364acdf6e3b (diff) | |
download | android_packages_apps_Trebuchet-37048c1e9f366972d0f891f9dde54b4248f50e3a.tar.gz android_packages_apps_Trebuchet-37048c1e9f366972d0f891f9dde54b4248f50e3a.tar.bz2 android_packages_apps_Trebuchet-37048c1e9f366972d0f891f9dde54b4248f50e3a.zip |
[automerger] Enable Clear-all button by default am: cc0c98ad94
Change-Id: I5271c1bb8dd9c016fb11189c2ecda5481f6a9399
Diffstat (limited to 'quickstep')
3 files changed, 66 insertions, 41 deletions
diff --git a/quickstep/res/layout/overview_clear_all_button.xml b/quickstep/res/layout/overview_clear_all_button.xml index c8f235fcd..1ada914b7 100644 --- a/quickstep/res/layout/overview_clear_all_button.xml +++ b/quickstep/res/layout/overview_clear_all_button.xml @@ -6,7 +6,7 @@ style="@android:style/Widget.DeviceDefault.Button.Borderless" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_gravity="end|top" + android:layout_gravity="start|top" android:fontFamily="sans-serif-medium" android:text="@string/recents_clear_all" android:textColor="?attr/workspaceTextColor" diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 7d707e37a..51b787ba0 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -88,8 +88,6 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl private static final String TAG = RecentsView.class.getSimpleName(); - public static final boolean DEBUG_SHOW_CLEAR_ALL_BUTTON = false; - private final Rect mTempRect = new Rect(); public static final FloatProperty<RecentsView> ADJACENT_SCALE = @@ -104,7 +102,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl return recentsView.mAdjacentScale; } }; - private static final boolean FLIP_RECENTS = true; + public static final boolean FLIP_RECENTS = true; private static final int DISMISS_TASK_DURATION = 300; private static final float[] sTempFloatArray = new float[3]; @@ -305,41 +303,55 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl } private float calculateClearAllButtonAlpha() { - if (mClearAllButton.getVisibility() != View.VISIBLE || getChildCount() == 0) return 0; - - // Current visible coordinate of the right border of the rightmost task. - final int carouselCurrentRight = getChildAt(getChildCount() - 1).getRight() - getScrollX(); - - // As the right border (let's call it E aka carouselCurrentRight) of the carousel moves - // over Clear all button, the button changes trasparency. - // leftOfAlphaChange < rightOfAlphaChange; these are the points of the 100% and 0% alpha - // correspondingly. Alpha changes linearly between 100% and 0% as E moves through this - // range. It doesn't change outside of the range. - - // Once E hits the left border of the Clear-All button, the whole button is uncovered, - // and it should have alpha 100%. - final float leftOfAlphaChange = mClearAllButton.getX(); - - // The rightmost possible right coordinate of the carousel. - final int carouselMotionLimit = getScrollForPage(getChildCount() - 1) + getWidth() - - getPaddingRight() - mInsets.right; + final int childCount = getChildCount(); + if (mClearAllButton.getVisibility() != View.VISIBLE || childCount == 0) return 0; + + // Current visible coordinate of the end of the oldest task. + final View lastChild = getChildAt(childCount - 1); + final int carouselCurrentEnd = + (mIsRtl ? lastChild.getLeft() : lastChild.getRight()) - getScrollX(); + + // As the end (let's call it E aka carouselCurrentEnd) of the carousel moves over Clear + // all button, the button changes trasparency. + // fullAlphaX and zeroAlphaX are the points of the 100% and 0% alpha correspondingly. + // Alpha changes linearly between 100% and 0% as E moves through this range. It doesn't + // change outside of the range. + + // Once E hits the border of the Clear-All button that looks towards the most recent + // task, the whole button is uncovered, and it should have alpha 100%. + final float fullAlphaX = mIsRtl ? + mClearAllButton.getX() + mClearAllButton.getWidth() : + mClearAllButton.getX(); + + // X coordinate of the carousel scrolled as far as possible in the direction towards the + // button. Logically, the button is "behind" the least recent task. This is the + // coordinate of the end of the least recent task in the carousel just after opening, + // with the most recent task in the center, and the rest of tasks go from that point + // towards and potentially behind the button. + final int carouselMotionLimit = getScrollForPage(childCount - 1) - getScrollForPage(0) + + (mIsRtl ? + getPaddingLeft() + mInsets.left : + getWidth() - getPaddingRight() - mInsets.right); // The carousel might not be able to ever cover a part of the Clear-all button. Then // always show the button as 100%. Technically, this check also prevents dividing by zero - // or a negative number when calculating the transparency ratio below. - if (carouselMotionLimit <= leftOfAlphaChange) return 1; + // or getting a negative transparency ratio. + if (mIsRtl ? carouselMotionLimit >= fullAlphaX : carouselMotionLimit <= fullAlphaX) { + return 1; + } // If the carousel is able to cover the button completely, we make the button completely - // transparent when E hits the right border of the button. - // Or, the carousel may not be able to move that far to the right so it completely covers - // the button. Then we set the rightmost possible position of the carousel as the point + // transparent when E hits the border of the button farthest from the most recent task. + // Or, the carousel may not be able to move that far towards the button so it completely + // covers the it. Then we set the motion limit position of the carousel as the point // where the button reaches 0 alpha. - final float rightOfAlphaChange = Math.min( - mClearAllButton.getX() + mClearAllButton.getWidth(), carouselMotionLimit); + final float zeroAlphaX = mIsRtl ? + Math.max(mClearAllButton.getX(), carouselMotionLimit) : + Math.min(mClearAllButton.getX() + mClearAllButton.getWidth(), carouselMotionLimit); return Utilities.boundToRange( - (rightOfAlphaChange - carouselCurrentRight) / - (rightOfAlphaChange - leftOfAlphaChange), 0, 1); + (zeroAlphaX - carouselCurrentEnd) / + (zeroAlphaX - fullAlphaX), 0, 1); } private void updateClearAllButtonAlpha() { @@ -356,9 +368,8 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl @Override public boolean onTouchEvent(MotionEvent ev) { - if (DEBUG_SHOW_CLEAR_ALL_BUTTON && ev.getAction() == MotionEvent.ACTION_DOWN - && mTouchState == TOUCH_STATE_REST && mScroller.isFinished() - && mClearAllButton.getVisibility() == View.VISIBLE) { + if (ev.getAction() == MotionEvent.ACTION_DOWN && mTouchState == TOUCH_STATE_REST + && mScroller.isFinished() && mClearAllButton.getVisibility() == View.VISIBLE) { mClearAllButton.getHitRect(mTempRect); mTempRect.offset(-getLeft(), -getTop()); if (mTempRect.contains((int) ev.getX(), (int) ev.getY())) { @@ -1207,21 +1218,29 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl return ""; } + private int additionalScrollForClearAllButton() { + return (int) getResources().getDimension( + R.dimen.clear_all_container_width) - getPaddingEnd(); + } + @Override protected int computeMaxScrollX() { - if (!DEBUG_SHOW_CLEAR_ALL_BUTTON || getChildCount() == 0) { + if (getChildCount() == 0) { return super.computeMaxScrollX(); } // Allow a clear_all_container_width-sized gap after the last task. - return super.computeMaxScrollX() + (int) getResources().getDimension( - R.dimen.clear_all_container_width) - getPaddingEnd(); + return super.computeMaxScrollX() + (mIsRtl ? 0 : additionalScrollForClearAllButton()); + } + + @Override + protected int offsetForPageScrolls() { + return mIsRtl ? additionalScrollForClearAllButton() : 0; } private void updateClearAllButtonVisibility() { if (mClearAllButton == null) return; - mClearAllButton.setVisibility( - !DEBUG_SHOW_CLEAR_ALL_BUTTON || mShowEmptyMessage ? GONE : VISIBLE); + mClearAllButton.setVisibility(mShowEmptyMessage ? GONE : VISIBLE); updateClearAllButtonAlpha(); } diff --git a/quickstep/src/com/android/quickstep/views/RecentsViewContainer.java b/quickstep/src/com/android/quickstep/views/RecentsViewContainer.java index 988b3ad1f..6b89b66f4 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsViewContainer.java +++ b/quickstep/src/com/android/quickstep/views/RecentsViewContainer.java @@ -4,6 +4,7 @@ import android.content.Context; import android.graphics.Rect; import android.util.AttributeSet; import android.util.FloatProperty; +import android.view.Gravity; import android.view.MotionEvent; import android.view.View; @@ -43,6 +44,10 @@ public class RecentsViewContainer extends InsettableFrameLayout { }); mRecentsView = (RecentsView) findViewById(R.id.overview_panel); + final InsettableFrameLayout.LayoutParams params = + (InsettableFrameLayout.LayoutParams) mClearAllButton.getLayoutParams(); + params.gravity = Gravity.TOP | (RecentsView.FLIP_RECENTS ? Gravity.START : Gravity.END); + mClearAllButton.setLayoutParams(params); mRecentsView.setClearAllButton(mClearAllButton); } @@ -53,8 +58,9 @@ public class RecentsViewContainer extends InsettableFrameLayout { mRecentsView.getTaskSize(mTempRect); mClearAllButton.setTranslationX( - (mClearAllButton.getMeasuredWidth() - getResources().getDimension( - R.dimen.clear_all_container_width)) / 2); + (mRecentsView.isRtl() ? 1 : -1) * + (getResources().getDimension(R.dimen.clear_all_container_width) + - mClearAllButton.getMeasuredWidth()) / 2); mClearAllButton.setTranslationY( mTempRect.top + (mTempRect.height() - mClearAllButton.getMeasuredHeight()) / 2 - mClearAllButton.getTop()); |