Merge "Applying the alpha to individual tasks instead of the view" into ub-launcher3-master
|
Before Width: | Height: | Size: 563 B |
|
Before Width: | Height: | Size: 527 B |
|
Before Width: | Height: | Size: 426 B |
|
Before Width: | Height: | Size: 433 B |
|
Before Width: | Height: | Size: 648 B |
|
Before Width: | Height: | Size: 631 B |
|
Before Width: | Height: | Size: 798 B |
|
Before Width: | Height: | Size: 787 B |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 576 B |
@@ -21,7 +21,6 @@
|
||||
android:layout_height="match_parent"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
android:alpha="0.0"
|
||||
android:visibility="invisible"
|
||||
android:focusableInTouchMode="true" >
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
<dimen name="task_corner_radius">2dp</dimen>
|
||||
<dimen name="task_fade_length">20dp</dimen>
|
||||
<dimen name="recents_page_spacing">10dp</dimen>
|
||||
<dimen name="recents_page_fade_length">100dp</dimen>
|
||||
|
||||
<!-- The speed in dp/s at which the user needs to be scrolling in recents such that we start
|
||||
loading full resolution screenshots. -->
|
||||
|
||||
@@ -110,8 +110,7 @@ public class OverviewState extends LauncherState {
|
||||
@Override
|
||||
public int getVisibleElements(Launcher launcher) {
|
||||
if (launcher.getDeviceProfile().isVerticalBarLayout()) {
|
||||
// TODO: Remove hotseat from overview
|
||||
return HOTSEAT_ICONS;
|
||||
return NONE;
|
||||
} else {
|
||||
return launcher.getAppsView().getFloatingHeaderView().hasVisibleContent()
|
||||
? HOTSEAT_EXTRA | ALL_APPS_HEADER_EXTRA : HOTSEAT_ICONS | HOTSEAT_EXTRA;
|
||||
|
||||
@@ -22,6 +22,7 @@ import static com.android.launcher3.anim.Interpolators.LINEAR;
|
||||
import static com.android.launcher3.compat.AccessibilityManagerCompat.isAccessibilityEnabled;
|
||||
import static com.android.quickstep.views.LauncherRecentsView.TRANSLATION_X_FACTOR;
|
||||
import static com.android.quickstep.views.LauncherRecentsView.TRANSLATION_Y_FACTOR;
|
||||
import static com.android.quickstep.views.RecentsView.CONTENT_ALPHA;
|
||||
|
||||
import android.animation.ValueAnimator;
|
||||
import android.annotation.TargetApi;
|
||||
@@ -49,7 +50,7 @@ public class RecentsViewStateController implements StateHandler {
|
||||
|
||||
@Override
|
||||
public void setState(LauncherState state) {
|
||||
mRecentsView.setAlpha(state.overviewUi ? 1 : 0);
|
||||
mRecentsView.setContentAlpha(state.overviewUi ? 1 : 0);
|
||||
updateVisibility(mRecentsView, isAccessibilityEnabled(mLauncher));
|
||||
float[] translationFactor = state.getOverviewTranslationFactor(mLauncher);
|
||||
mRecentsView.setTranslationXFactor(translationFactor[0]);
|
||||
@@ -83,7 +84,7 @@ public class RecentsViewStateController implements StateHandler {
|
||||
setter.setFloat(mRecentsView, TRANSLATION_Y_FACTOR,
|
||||
translationFactor[1],
|
||||
builder.getInterpolator(ANIM_OVERVIEW_TRANSLATION, LINEAR));
|
||||
setter.setViewAlpha(mRecentsView, toState.overviewUi ? 1 : 0, LINEAR);
|
||||
setter.setFloat(mRecentsView, CONTENT_ALPHA, toState.overviewUi ? 1 : 0, LINEAR);
|
||||
|
||||
if (toState.overviewUi) {
|
||||
ValueAnimator updateAnim = ValueAnimator.ofFloat(0, 1);
|
||||
|
||||
@@ -19,18 +19,7 @@ import static com.android.launcher3.LauncherState.NORMAL;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapShader;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff.Mode;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Shader;
|
||||
import android.graphics.Shader.TileMode;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.FloatProperty;
|
||||
@@ -75,12 +64,6 @@ public class LauncherRecentsView extends RecentsView<Launcher> implements Insett
|
||||
}
|
||||
};
|
||||
|
||||
private Bitmap mScrim;
|
||||
private Paint mFadePaint;
|
||||
private Shader mFadeShader;
|
||||
private Matrix mFadeMatrix;
|
||||
private boolean mScrimOnLeft;
|
||||
|
||||
private float mTranslationXFactor;
|
||||
private float mTranslationYFactor;
|
||||
private Rect mPagePadding = new Rect();
|
||||
@@ -95,6 +78,7 @@ public class LauncherRecentsView extends RecentsView<Launcher> implements Insett
|
||||
|
||||
public LauncherRecentsView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
setContentAlpha(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -109,60 +93,6 @@ public class LauncherRecentsView extends RecentsView<Launcher> implements Insett
|
||||
setPadding(padding.left, padding.top, padding.right, 0);
|
||||
mPagePadding.set(padding);
|
||||
mPagePadding.top += getResources().getDimensionPixelSize(R.dimen.task_thumbnail_top_margin);
|
||||
|
||||
if (dp.isVerticalBarLayout()) {
|
||||
boolean wasScrimOnLeft = mScrimOnLeft;
|
||||
mScrimOnLeft = dp.isSeascape();
|
||||
|
||||
if (mScrim == null || wasScrimOnLeft != mScrimOnLeft) {
|
||||
Drawable scrim = getContext().getDrawable(mScrimOnLeft
|
||||
? R.drawable.recents_horizontal_scrim_left
|
||||
: R.drawable.recents_horizontal_scrim_right);
|
||||
if (scrim instanceof BitmapDrawable) {
|
||||
mScrim = ((BitmapDrawable) scrim).getBitmap();
|
||||
mFadePaint = new Paint();
|
||||
mFadePaint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));
|
||||
mFadeShader = new BitmapShader(mScrim, TileMode.CLAMP, TileMode.REPEAT);
|
||||
mFadeMatrix = new Matrix();
|
||||
} else {
|
||||
mScrim = null;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mScrim = null;
|
||||
mFadePaint = null;
|
||||
mFadeShader = null;
|
||||
mFadeMatrix = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
if (mScrim == null) {
|
||||
super.draw(canvas);
|
||||
return;
|
||||
}
|
||||
|
||||
final int flags = Canvas.HAS_ALPHA_LAYER_SAVE_FLAG;
|
||||
|
||||
int length = mScrim.getWidth();
|
||||
int height = getHeight();
|
||||
int saveCount = canvas.getSaveCount();
|
||||
|
||||
int scrimLeft;
|
||||
if (mScrimOnLeft) {
|
||||
scrimLeft = getScrollX();
|
||||
} else {
|
||||
scrimLeft = getScrollX() + getWidth() - length;
|
||||
}
|
||||
canvas.saveLayer(scrimLeft, 0, scrimLeft + length, height, null, flags);
|
||||
super.draw(canvas);
|
||||
|
||||
mFadeMatrix.setTranslate(scrimLeft, 0);
|
||||
mFadeShader.setLocalMatrix(mFadeMatrix);
|
||||
mFadePaint.setShader(mFadeShader);
|
||||
canvas.drawRect(scrimLeft, 0, scrimLeft + length, height, mFadePaint);
|
||||
canvas.restoreToCount(saveCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,6 +33,7 @@ import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.util.ArraySet;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.FloatProperty;
|
||||
import android.util.SparseBooleanArray;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -66,6 +67,21 @@ import java.util.ArrayList;
|
||||
public abstract class RecentsView<T extends BaseActivity>
|
||||
extends PagedView implements OnSharedPreferenceChangeListener {
|
||||
|
||||
public static final FloatProperty<RecentsView> CONTENT_ALPHA =
|
||||
new FloatProperty<RecentsView>("contentAlpha") {
|
||||
|
||||
|
||||
@Override
|
||||
public void setValue(RecentsView recentsView, float v) {
|
||||
recentsView.setContentAlpha(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float get(RecentsView recentsView) {
|
||||
return recentsView.mContentAlpha;
|
||||
}
|
||||
};
|
||||
|
||||
private static final String PREF_FLIP_RECENTS = "pref_flip_recents";
|
||||
private static final int DISMISS_TASK_DURATION = 300;
|
||||
|
||||
@@ -109,6 +125,8 @@ public abstract class RecentsView<T extends BaseActivity>
|
||||
|
||||
private PendingAnimation mPendingAnimation;
|
||||
|
||||
private float mContentAlpha = 1;
|
||||
|
||||
// Keeps track of task views whose visual state should not be reset
|
||||
private ArraySet<TaskView> mIgnoreResetTaskViews = new ArraySet<>();
|
||||
|
||||
@@ -305,12 +323,10 @@ public abstract class RecentsView<T extends BaseActivity>
|
||||
|
||||
float overviewHeight, overviewWidth;
|
||||
if (profile.isVerticalBarLayout()) {
|
||||
float scrimLength = context.getResources()
|
||||
.getDimension(R.dimen.recents_page_fade_length);
|
||||
float maxPadding = Math.max(padding.left, padding.right);
|
||||
|
||||
// Use the same padding on both sides for symmetry.
|
||||
float availableWidth = taskWidth - 2 * Math.max(maxPadding, scrimLength);
|
||||
float availableWidth = taskWidth - 2 * maxPadding;
|
||||
float availableHeight = profile.availableHeightPx - padding.top - padding.bottom
|
||||
- sTempStableInsets.top;
|
||||
float scaledRatio = Math.min(availableWidth / taskWidth, availableHeight / taskHeight);
|
||||
@@ -675,4 +691,21 @@ public abstract class RecentsView<T extends BaseActivity>
|
||||
final TaskView nextTask = (TaskView) getChildAt(getNextPage());
|
||||
nextTask.launchTask(true);
|
||||
}
|
||||
|
||||
public void setContentAlpha(float alpha) {
|
||||
if (mContentAlpha == alpha) {
|
||||
return;
|
||||
}
|
||||
mContentAlpha = alpha;
|
||||
for (int i = getChildCount() - 1; i >= 0; i--) {
|
||||
getChildAt(i).setAlpha(alpha);
|
||||
}
|
||||
setVisibility(alpha > 0 ? VISIBLE : GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewAdded(View child) {
|
||||
super.onViewAdded(child);
|
||||
child.setAlpha(mContentAlpha);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,6 +176,12 @@ public class TaskView extends FrameLayout implements TaskCallbacks, PageCallback
|
||||
setScaleY(scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOverlappingRendering() {
|
||||
// TODO: Clip-out the icon region from the thumbnail, since they are overlapping.
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final class TaskOutlineProvider extends ViewOutlineProvider {
|
||||
|
||||
private final int mMarginTop;
|
||||
|
||||
@@ -188,6 +188,10 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
||||
mMinFlingVelocity = (int) (MIN_FLING_VELOCITY * density);
|
||||
mMinSnapVelocity = (int) (MIN_SNAP_VELOCITY * density);
|
||||
setWillNotDraw(false);
|
||||
|
||||
if (Utilities.ATLEAST_OREO) {
|
||||
setDefaultFocusHighlightEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setDefaultInterpolator(Interpolator interpolator) {
|
||||
|
||||