diff options
7 files changed, 88 insertions, 31 deletions
diff --git a/packages/SystemUI/res/drawable/recents_freeform_workspace_bg.xml b/packages/SystemUI/res/drawable/recents_freeform_workspace_bg.xml new file mode 100644 index 000000000000..5f9341c0d151 --- /dev/null +++ b/packages/SystemUI/res/drawable/recents_freeform_workspace_bg.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2014 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"> + <corners android:topLeftRadius="@dimen/recents_task_view_rounded_corners_radius" + android:topRightRadius="@dimen/recents_task_view_rounded_corners_radius"/> + <solid android:color="#00000000" /> +</shape>
\ No newline at end of file diff --git a/packages/SystemUI/res/values/colors.xml b/packages/SystemUI/res/values/colors.xml index 7aff02d1f911..8875515378d5 100644 --- a/packages/SystemUI/res/values/colors.xml +++ b/packages/SystemUI/res/values/colors.xml @@ -68,6 +68,8 @@ <color name="recents_task_view_lock_to_app_button_background_color">#ffe6e6e6</color> <!-- The lock to task button foreground color. --> <color name="recents_task_view_lock_to_app_button_color">#ff666666</color> + <!-- The background color for the freeform workspace. --> + <color name="recents_freeform_workspace_bg_color">#66000000</color> <color name="keyguard_affordance">#ffffffff</color> diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/FreeformWorkspaceLayoutAlgorithm.java b/packages/SystemUI/src/com/android/systemui/recents/views/FreeformWorkspaceLayoutAlgorithm.java index 25f9e80db75f..2351aa3fe049 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/FreeformWorkspaceLayoutAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/FreeformWorkspaceLayoutAlgorithm.java @@ -143,7 +143,7 @@ public class FreeformWorkspaceLayoutAlgorithm { final Rect taskRect = stackLayout.mTaskRect; final RectF ffRect = mTaskRectMap.get(task.key); - transformOut.scale = 0.95f; + transformOut.scale = 1f; transformOut.alpha = 1f; transformOut.translationZ = stackLayout.mMaxTranslationZ; if (task.thumbnail != null) { diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java index 831cb1228a7f..881c72dcaf83 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java @@ -24,8 +24,8 @@ import android.content.res.Resources; import android.graphics.Canvas; import android.graphics.Rect; import android.graphics.RectF; -import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; +import android.graphics.drawable.GradientDrawable; import android.os.Bundle; import android.util.IntProperty; import android.util.Log; @@ -95,15 +95,15 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal private static final float SHOW_HISTORY_BUTTON_SCROLL_THRESHOLD = 0.3f; private static final float HIDE_HISTORY_BUTTON_SCROLL_THRESHOLD = 0.3f; - public static final Property<ColorDrawable, Integer> COLOR_DRAWABLE_ALPHA = - new IntProperty<ColorDrawable>("colorDrawableAlpha") { + public static final Property<Drawable, Integer> DRAWABLE_ALPHA = + new IntProperty<Drawable>("drawableAlpha") { @Override - public void setValue(ColorDrawable object, int alpha) { + public void setValue(Drawable object, int alpha) { object.setAlpha(alpha); } @Override - public Integer get(ColorDrawable object) { + public Integer get(Drawable object) { return object.getAlpha(); } }; @@ -119,7 +119,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal TaskStackViewScroller mStackScroller; TaskStackViewTouchHandler mTouchHandler; TaskStackViewCallbacks mCb; - ColorDrawable mFreeformWorkspaceBackground; + GradientDrawable mFreeformWorkspaceBackground; ObjectAnimator mFreeformWorkspaceBackgroundAnimator; ViewPool<TaskView, Task> mViewPool; ArrayList<TaskViewTransform> mCurrentTaskTransforms = new ArrayList<>(); @@ -176,6 +176,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal public TaskStackView(Context context, TaskStack stack) { super(context); + SystemServicesProxy ssp = Recents.getSystemServices(); Resources res = context.getResources(); // Set the stack first @@ -207,8 +208,12 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal }); setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES); - mFreeformWorkspaceBackground = new ColorDrawable(0x33000000); + mFreeformWorkspaceBackground = (GradientDrawable) getContext().getDrawable( + R.drawable.recents_freeform_workspace_bg); mFreeformWorkspaceBackground.setCallback(this); + if (ssp.hasFreeformWorkspaceSupport()) { + setBackgroundColor(getContext().getColor(R.color.recents_freeform_workspace_bg_color)); + } } /** Sets the callbacks */ @@ -1588,7 +1593,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal Utilities.cancelAnimationWithoutCallbacks(mFreeformWorkspaceBackgroundAnimator); mFreeformWorkspaceBackgroundAnimator = ObjectAnimator.ofInt(mFreeformWorkspaceBackground, - COLOR_DRAWABLE_ALPHA, mFreeformWorkspaceBackground.getAlpha(), targetAlpha); + DRAWABLE_ALPHA, mFreeformWorkspaceBackground.getAlpha(), targetAlpha); mFreeformWorkspaceBackgroundAnimator.setDuration(duration); mFreeformWorkspaceBackgroundAnimator.setInterpolator(interpolator); mFreeformWorkspaceBackgroundAnimator.start(); diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java index 499770967bac..cfffc5f95daf 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java @@ -179,6 +179,13 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks, } @Override + protected void onSizeChanged(int w, int h, int oldw, int oldh) { + super.onSizeChanged(w, h, oldw, oldh); + mHeaderView.onTaskViewSizeChanged(w, h); + mThumbnailView.onTaskViewSizeChanged(w, h); + } + + @Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (ev.getAction() == MotionEvent.ACTION_DOWN) { mDownTouchPos.set((int) (ev.getX() * getScaleX()), (int) (ev.getY() * getScaleY())); diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java index d782a63ca009..6a1f6d19722b 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java @@ -31,6 +31,7 @@ import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.GradientDrawable; import android.graphics.drawable.RippleDrawable; +import android.graphics.drawable.ShapeDrawable; import android.util.AttributeSet; import android.view.View; import android.view.ViewOutlineProvider; @@ -66,6 +67,7 @@ public class TaskViewHeader extends FrameLayout TextView mActivityDescription; // Header drawables + Rect mTaskViewRect = new Rect(); int mCornerRadius; int mHighlightHeight; Drawable mLightDismissDrawable; @@ -99,13 +101,6 @@ public class TaskViewHeader extends FrameLayout public TaskViewHeader(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); setWillNotDraw(false); - setClipToOutline(true); - setOutlineProvider(new ViewOutlineProvider() { - @Override - public void getOutline(View view, Outline outline) { - outline.setRect(0, 0, getWidth(), getHeight()); - } - }); // Load the dismiss resources mDimLayerPaint.setColor(Color.argb(0, 0, 0, 0)); @@ -148,8 +143,8 @@ public class TaskViewHeader extends FrameLayout mApplicationIcon.setBackground(null); } - mBackgroundColorDrawable = (GradientDrawable) getContext().getDrawable(R.drawable - .recents_task_view_header_bg_color); + mBackgroundColorDrawable = (GradientDrawable) getContext().getDrawable( + R.drawable.recents_task_view_header_bg_color); // Copy the ripple drawable since we are going to be manipulating it mBackground = (RippleDrawable) getContext().getDrawable(R.drawable.recents_task_view_header_bg); @@ -159,14 +154,37 @@ public class TaskViewHeader extends FrameLayout setBackground(mBackground); } + /** + * Called when the task view frame changes, allowing us to move the contents of the header + * to match the frame changes. + */ + public void onTaskViewSizeChanged(int width, int height) { + mTaskViewRect.set(0, 0, width, height); + if (mDismissButton.getMeasuredWidth() > (width - mApplicationIcon.getMeasuredWidth())) { + mDismissButton.setAlpha(0f); + } else { + mDismissButton.setAlpha(1f); + if (mDismissButton != null) { + mDismissButton.setTranslationX(width - getMeasuredWidth()); + } + } + if (mActivityDescription.getMeasuredWidth() > (width - + (mApplicationIcon.getMeasuredWidth() + mDismissButton.getMeasuredWidth()))) { + mActivityDescription.setAlpha(0f); + } else { + mActivityDescription.setAlpha(1f); + } + invalidate(); + } + @Override protected void onDraw(Canvas canvas) { // Draw the highlight at the top edge (but put the bottom edge just out of view) float offset = (float) Math.ceil(mHighlightHeight / 2f); float radius = mCornerRadius; int count = canvas.save(Canvas.CLIP_SAVE_FLAG); - canvas.clipRect(0, 0, getMeasuredWidth(), getMeasuredHeight()); - canvas.drawRoundRect(-offset, 0f, (float) getMeasuredWidth() + offset, + canvas.clipRect(0, 0, mTaskViewRect.width(), getMeasuredHeight()); + canvas.drawRoundRect(-offset, 0f, (float) mTaskViewRect.width() + offset, getMeasuredHeight() + radius, radius, radius, sHighlightPaint); canvas.restoreToCount(count); } @@ -180,12 +198,6 @@ public class TaskViewHeader extends FrameLayout invalidate(); } - /** Returns the secondary color for a primary color. */ - int getSecondaryColor(int primaryColor, boolean useLightOverlayColor) { - int overlayColor = useLightOverlayColor ? Color.WHITE : Color.BLACK; - return Utilities.getColorWithOverlay(primaryColor, overlayColor, 0.8f); - } - /** Binds the bar view to the task */ public void rebindToTask(Task t) { mTask = t; @@ -332,10 +344,9 @@ public class TaskViewHeader extends FrameLayout protected void dispatchDraw(Canvas canvas) { super.dispatchDraw(canvas); - // Draw the thumbnail with the rounded corners - canvas.drawRoundRect(0, 0, getWidth(), getHeight(), - mCornerRadius, - mCornerRadius, mDimLayerPaint); + // Draw the dim layer with the rounded corners + canvas.drawRoundRect(0, 0, mTaskViewRect.width(), getHeight(), + mCornerRadius, mCornerRadius, mDimLayerPaint); } /** Notifies the associated TaskView has been focused. */ diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewThumbnail.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewThumbnail.java index 7bb2c7bb9fe2..37d8cd69d10d 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewThumbnail.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewThumbnail.java @@ -56,6 +56,7 @@ public class TaskViewThumbnail extends View { }; // Drawing + Rect mTaskViewRect = new Rect(); int mCornerRadius; float mDimAlpha; Matrix mScaleMatrix = new Matrix(); @@ -98,13 +99,22 @@ public class TaskViewThumbnail extends View { com.android.internal.R.interpolator.fast_out_slow_in); } + /** + * Called when the task view frame changes, allowing us to move the contents of the header + * to match the frame changes. + */ + public void onTaskViewSizeChanged(int width, int height) { + mTaskViewRect.set(0, 0, width, height); + invalidate(); + } + @Override protected void onDraw(Canvas canvas) { if (mInvisible) { return; } // Draw the thumbnail with the rounded corners - canvas.drawRoundRect(0, 0, getWidth(), getHeight(), + canvas.drawRoundRect(0, 0, mTaskViewRect.width(), mTaskViewRect.height(), mCornerRadius, mCornerRadius, mDrawPaint); } |