Avoid clipping in Grid-based Recents.

This commit avoids clipping in Grid-based Recents by:
- extending TaskView and AnimatableViewBounds in Recents and removing
  all clipping logic;
- returning early in TaskStackView when it wants to clip TaskViews.

Change-Id: I52819a828f84ce42fc8a63085e15a8264000d271
This commit is contained in:
Jiaquan He
2016-12-13 14:36:37 -08:00
parent e4e41ba4a6
commit 5a2eb83383
10 changed files with 204 additions and 40 deletions

View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 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.
-->
<com.android.systemui.recents.views.grid.GridTaskView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true">
<com.android.systemui.recents.views.TaskViewThumbnail
android:id="@+id/task_view_thumbnail"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<include layout="@layout/recents_task_view_header" />
<!-- TODO: Move this into a view stub -->
<include layout="@layout/recents_task_view_lock_to_app"/>
<!-- The incompatible app toast -->
<include layout="@layout/recents_task_view_incompatible_app_toast"/>
</com.android.systemui.recents.views.grid.GridTaskView>

View File

@@ -4,9 +4,9 @@
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.
@@ -26,35 +26,10 @@
<include layout="@layout/recents_task_view_header" />
<!-- TODO: Move this into a view stub -->
<com.android.systemui.statusbar.AlphaOptimizedFrameLayout
android:id="@+id/lock_to_app_fab"
android:layout_width="@dimen/recents_lock_to_app_size"
android:layout_height="@dimen/recents_lock_to_app_size"
android:layout_gravity="bottom|end"
android:layout_marginEnd="15dp"
android:layout_marginBottom="15dp"
android:translationZ="4dp"
android:contentDescription="@string/recents_lock_to_app_button_label"
android:background="@drawable/recents_lock_to_task_button_bg"
android:visibility="invisible"
android:alpha="0">
<ImageView
android:layout_width="@dimen/recents_lock_to_app_icon_size"
android:layout_height="@dimen/recents_lock_to_app_icon_size"
android:layout_gravity="center"
android:src="@drawable/recents_lock_to_app_pin" />
</com.android.systemui.statusbar.AlphaOptimizedFrameLayout>
<include layout="@layout/recents_task_view_lock_to_app"/>
<!-- The incompatible app toast -->
<ViewStub android:id="@+id/incompatible_app_toast_stub"
android:inflatedId="@+id/incompatible_app_toast"
android:layout="@*android:layout/transient_notification"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|center_horizontal"
android:layout_marginTop="48dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp" />
<include layout="@layout/recents_task_view_incompatible_app_toast"/>
</com.android.systemui.recents.views.TaskView>

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 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.
-->
<ViewStub
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/incompatible_app_toast_stub"
android:inflatedId="@+id/incompatible_app_toast"
android:layout="@*android:layout/transient_notification"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|center_horizontal"
android:layout_marginTop="48dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp" />

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 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.
-->
<com.android.systemui.statusbar.AlphaOptimizedFrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/lock_to_app_fab"
android:layout_width="@dimen/recents_lock_to_app_size"
android:layout_height="@dimen/recents_lock_to_app_size"
android:layout_gravity="bottom|end"
android:layout_marginEnd="15dp"
android:layout_marginBottom="15dp"
android:translationZ="4dp"
android:contentDescription="@string/recents_lock_to_app_button_label"
android:background="@drawable/recents_lock_to_task_button_bg"
android:visibility="invisible"
android:alpha="0">
<ImageView
android:layout_width="@dimen/recents_lock_to_app_icon_size"
android:layout_height="@dimen/recents_lock_to_app_icon_size"
android:layout_gravity="center"
android:src="@drawable/recents_lock_to_app_pin" />
</com.android.systemui.statusbar.AlphaOptimizedFrameLayout>

View File

@@ -86,7 +86,7 @@ public class Utilities {
public static <T extends View> T findParent(View v, Class<T> parentClass) {
ViewParent parent = v.getParent();
while (parent != null) {
if (parent.getClass().equals(parentClass)) {
if (parentClass.isAssignableFrom(parent.getClass())) {
return (T) parent;
}
parent = parent.getParent();

View File

@@ -30,17 +30,17 @@ public class AnimateableViewBounds extends ViewOutlineProvider {
private static final float MIN_ALPHA = 0.1f;
private static final float MAX_ALPHA = 0.8f;
View mSourceView;
protected View mSourceView;
@ViewDebug.ExportedProperty(category="recents")
Rect mClipRect = new Rect();
protected Rect mClipRect = new Rect();
@ViewDebug.ExportedProperty(category="recents")
Rect mClipBounds = new Rect();
protected Rect mClipBounds = new Rect();
@ViewDebug.ExportedProperty(category="recents")
Rect mLastClipBounds = new Rect();
protected Rect mLastClipBounds = new Rect();
@ViewDebug.ExportedProperty(category="recents")
int mCornerRadius;
protected int mCornerRadius;
@ViewDebug.ExportedProperty(category="recents")
float mAlpha = 1f;
protected float mAlpha = 1f;
public AnimateableViewBounds(View source, int cornerRadius) {
mSourceView = source;
@@ -110,7 +110,7 @@ public class AnimateableViewBounds extends ViewOutlineProvider {
return mClipRect.bottom;
}
private void updateClipBounds() {
protected void updateClipBounds() {
mClipBounds.set(Math.max(0, mClipRect.left), Math.max(0, mClipRect.top),
mSourceView.getWidth() - Math.max(0, mClipRect.right),
mSourceView.getHeight() - Math.max(0, mClipRect.bottom));

View File

@@ -92,6 +92,7 @@ import com.android.systemui.recents.misc.Utilities;
import com.android.systemui.recents.model.Task;
import com.android.systemui.recents.model.TaskStack;
import com.android.systemui.recents.views.grid.GridTaskView;
import java.io.PrintWriter;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -782,6 +783,11 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
* Updates the clip for each of the task views from back to front.
*/
private void clipTaskViews() {
// We never clip task views in grid layout
if (Recents.getConfiguration().isGridEnabled) {
return;
}
// Update the clip on each task child
List<TaskView> taskViews = getTaskViews();
TaskView tmpTv = null;
@@ -1506,7 +1512,11 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
@Override
public TaskView createView(Context context) {
return (TaskView) mInflater.inflate(R.layout.recents_task_view, this, false);
if (Recents.getConfiguration().isGridEnabled) {
return (GridTaskView) mInflater.inflate(R.layout.recents_grid_task_view, this, false);
} else {
return (TaskView) mInflater.inflate(R.layout.recents_task_view, this, false);
}
}
@Override

View File

@@ -176,8 +176,7 @@ public class TaskView extends FixedSizeFrameLayout implements Task.TaskCallbacks
super(context, attrs, defStyleAttr, defStyleRes);
RecentsConfiguration config = Recents.getConfiguration();
Resources res = context.getResources();
mViewBounds = new AnimateableViewBounds(this, res.getDimensionPixelSize(
R.dimen.recents_task_view_shadow_rounded_corners_radius));
mViewBounds = createOutlineProvider();
if (config.fakeShadows) {
setBackground(new FakeShadowDrawable(res, config));
}
@@ -207,6 +206,12 @@ public class TaskView extends FixedSizeFrameLayout implements Task.TaskCallbacks
return mTask;
}
/* Create an outline provider to clip and outline the view */
protected AnimateableViewBounds createOutlineProvider() {
return new AnimateableViewBounds(this, mContext.getResources().getDimensionPixelSize(
R.dimen.recents_task_view_shadow_rounded_corners_radius));
}
/** Returns the view bounds. */
AnimateableViewBounds getViewBounds() {
return mViewBounds;

View File

@@ -0,0 +1,32 @@
/*
* Copyright (C) 2016 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.
*/
package com.android.systemui.recents.views.grid;
import android.view.View;
import com.android.systemui.recents.views.AnimateableViewBounds;
/* An outline provider for grid-based task views. */
class AnimateableGridViewBounds extends AnimateableViewBounds {
public AnimateableGridViewBounds(View source, int cornerRadius) {
super(source, cornerRadius);
}
@Override
protected void updateClipBounds() {
}
}

View File

@@ -0,0 +1,47 @@
/*
* Copyright (C) 2016 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.
*/
package com.android.systemui.recents.views.grid;
import android.content.Context;
import android.util.AttributeSet;
import com.android.systemui.R;
import com.android.systemui.recents.views.AnimateableViewBounds;
import com.android.systemui.recents.views.TaskView;
public class GridTaskView extends TaskView {
public GridTaskView(Context context) {
this(context, null);
}
public GridTaskView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public GridTaskView(Context context, AttributeSet attrs, int defStyleAttr) {
this(context, attrs, defStyleAttr, 0);
}
public GridTaskView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
@Override
protected AnimateableViewBounds createOutlineProvider() {
return new AnimateableGridViewBounds(this, mContext.getResources().getDimensionPixelSize(
R.dimen.recents_task_view_shadow_rounded_corners_radius));
}
}