diff options
10 files changed, 204 insertions, 40 deletions
diff --git a/packages/SystemUI/res/layout/recents_grid_task_view.xml b/packages/SystemUI/res/layout/recents_grid_task_view.xml new file mode 100644 index 000000000000..53bec70bd096 --- /dev/null +++ b/packages/SystemUI/res/layout/recents_grid_task_view.xml @@ -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> + + diff --git a/packages/SystemUI/res/layout/recents_task_view.xml b/packages/SystemUI/res/layout/recents_task_view.xml index c8e5b6124196..015e4a2006bb 100644 --- a/packages/SystemUI/res/layout/recents_task_view.xml +++ b/packages/SystemUI/res/layout/recents_task_view.xml @@ -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> diff --git a/packages/SystemUI/res/layout/recents_task_view_incompatible_app_toast.xml b/packages/SystemUI/res/layout/recents_task_view_incompatible_app_toast.xml new file mode 100644 index 000000000000..d573d6b881d2 --- /dev/null +++ b/packages/SystemUI/res/layout/recents_task_view_incompatible_app_toast.xml @@ -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" />
\ No newline at end of file diff --git a/packages/SystemUI/res/layout/recents_task_view_lock_to_app.xml b/packages/SystemUI/res/layout/recents_task_view_lock_to_app.xml new file mode 100644 index 000000000000..8cece1149ce7 --- /dev/null +++ b/packages/SystemUI/res/layout/recents_task_view_lock_to_app.xml @@ -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>
\ No newline at end of file diff --git a/packages/SystemUI/src/com/android/systemui/recents/misc/Utilities.java b/packages/SystemUI/src/com/android/systemui/recents/misc/Utilities.java index 2c5c437bfab0..4349e30f60e0 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/misc/Utilities.java +++ b/packages/SystemUI/src/com/android/systemui/recents/misc/Utilities.java @@ -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(); diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/AnimateableViewBounds.java b/packages/SystemUI/src/com/android/systemui/recents/views/AnimateableViewBounds.java index 253d06a5f5f8..dba085e37427 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/AnimateableViewBounds.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/AnimateableViewBounds.java @@ -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)); 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 8c94c3578e96..1174e20570fa 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java @@ -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 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 de7def6c95c9..9b305151b703 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java @@ -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; diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/grid/AnimateableGridViewBounds.java b/packages/SystemUI/src/com/android/systemui/recents/views/grid/AnimateableGridViewBounds.java new file mode 100644 index 000000000000..a029478c2045 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/recents/views/grid/AnimateableGridViewBounds.java @@ -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() { + } +} diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/grid/GridTaskView.java b/packages/SystemUI/src/com/android/systemui/recents/views/grid/GridTaskView.java new file mode 100644 index 000000000000..da14e2bdf50c --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/recents/views/grid/GridTaskView.java @@ -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)); + } +} |