diff options
| author | 2016-01-28 16:48:18 -0800 | |
|---|---|---|
| committer | 2016-01-29 15:08:08 -0800 | |
| commit | 9b5c847a19bf7dbfe3fe00f11cbbdf581794fccc (patch) | |
| tree | 92ec4f0ac2135a36265b2e4fc3755125dd72c623 | |
| parent | 957c742f1fbbc194e38b3c692d9207c8013c1b89 (diff) | |
Re-enabling fade-in of header bar icons.
- Removing extra syscall when rebinding tasks
- Only bind the click listeners on the header bar after they are visible
Change-Id: I6879b30a985ca8274ee77126b152daa985054371
12 files changed, 81 insertions, 117 deletions
diff --git a/packages/SystemUI/res/drawable/recents_button_bg.xml b/packages/SystemUI/res/drawable/recents_button_bg.xml deleted file mode 100644 index 7456365912c5..000000000000 --- a/packages/SystemUI/res/drawable/recents_button_bg.xml +++ /dev/null @@ -1,19 +0,0 @@ -<?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. ---> - -<ripple xmlns:android="http://schemas.android.com/apk/res/android" - android:color="#40ffffff"> -</ripple> diff --git a/packages/SystemUI/res/drawable/recents_task_view_header_bg.xml b/packages/SystemUI/res/drawable/recents_task_view_header_bg.xml deleted file mode 100644 index 745af33333df..000000000000 --- a/packages/SystemUI/res/drawable/recents_task_view_header_bg.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?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. ---> - -<ripple xmlns:android="http://schemas.android.com/apk/res/android" - android:color="?android:attr/colorControlHighlight"> - <item android:drawable="@android:color/transparent" /> -</ripple>
\ No newline at end of file diff --git a/packages/SystemUI/res/drawable/recents_task_view_header_bg_color.xml b/packages/SystemUI/res/drawable/recents_task_view_header_bg_color.xml deleted file mode 100644 index 5f9341c0d151..000000000000 --- a/packages/SystemUI/res/drawable/recents_task_view_header_bg_color.xml +++ /dev/null @@ -1,22 +0,0 @@ -<?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/layout/recents_task_view_header.xml b/packages/SystemUI/res/layout/recents_task_view_header.xml index 5c67f8010e93..deb8e91b5049 100644 --- a/packages/SystemUI/res/layout/recents_task_view_header.xml +++ b/packages/SystemUI/res/layout/recents_task_view_header.xml @@ -49,8 +49,9 @@ android:layout_marginEnd="@dimen/recents_task_view_header_button_width" android:layout_gravity="center_vertical|end" android:padding="15dp" - android:background="@drawable/recents_button_bg" android:src="@drawable/star" + android:background="?android:selectableItemBackground" + android:alpha="0" android:visibility="gone" /> <com.android.systemui.recents.views.FixedSizeImageView android:id="@+id/dismiss_task" @@ -58,9 +59,10 @@ android:layout_height="@dimen/recents_task_view_header_button_height" android:layout_gravity="center_vertical|end" android:padding="15dp" - android:background="@drawable/recents_button_bg" - android:visibility="invisible" - android:src="@drawable/recents_dismiss_light" /> + android:src="@drawable/recents_dismiss_light" + android:background="?android:selectableItemBackground" + android:alpha="0" + android:visibility="gone" /> <!-- The progress indicator shows if auto-paging is enabled --> <ViewStub android:id="@+id/focus_timer_indicator_stub" diff --git a/packages/SystemUI/res/layout/recents_task_view_header_overlay.xml b/packages/SystemUI/res/layout/recents_task_view_header_overlay.xml index dabfc809bb06..10659a3e48e3 100644 --- a/packages/SystemUI/res/layout/recents_task_view_header_overlay.xml +++ b/packages/SystemUI/res/layout/recents_task_view_header_overlay.xml @@ -45,6 +45,6 @@ android:layout_height="@dimen/recents_task_bar_height" android:layout_gravity="center_vertical|end" android:padding="15dp" - android:background="@drawable/recents_button_bg" + android:background="?android:selectableItemBackground" android:src="@drawable/recents_info_light" /> </FrameLayout>
\ No newline at end of file diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java index 35e97e517328..5a60a19ef832 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java +++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java @@ -806,7 +806,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener } else { Canvas c = new Canvas(thumbnail); c.scale(toTransform.scale, toTransform.scale); - mHeaderBar.rebindToTask(toTask); + mHeaderBar.rebindToTask(toTask, false /* touchExplorationEnabled */); mHeaderBar.draw(c); c.setBitmap(null); } diff --git a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java index ecf8ecbcff6e..d22cd53ccfbb 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java +++ b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java @@ -256,8 +256,6 @@ public class SystemServicesProxy { * Returns whether this device has freeform workspaces. */ public boolean hasFreeformWorkspaceSupport() { - if (mPm == null) return false; - return mHasFreeformWorkspaceSupport; } diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/FixedSizeImageView.java b/packages/SystemUI/src/com/android/systemui/recents/views/FixedSizeImageView.java index f5ab01f5bf5b..d3b5e473eb7d 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/FixedSizeImageView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/FixedSizeImageView.java @@ -20,13 +20,14 @@ import android.content.Context; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.util.AttributeSet; -import android.widget.ImageView; + +import com.android.systemui.statusbar.AlphaOptimizedImageView; /** * This is an optimized ImageView that does not trigger a <code>requestLayout()</code> or * <code>invalidate()</code> when setting the image to <code>null</code>. */ -public class FixedSizeImageView extends ImageView { +public class FixedSizeImageView extends AlphaOptimizedImageView { private boolean mAllowRelayout = true; private boolean mAllowInvalidate = true; @@ -73,9 +74,4 @@ public class FixedSizeImageView extends ImageView { mAllowRelayout = true; mAllowInvalidate = true; } - - @Override - public boolean hasOverlappingRendering() { - return false; - } } 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 264cede8e71a..ee6f5f914027 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java @@ -231,8 +231,8 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal @Override protected void onAttachedToWindow() { EventBus.getDefault().register(this, RecentsActivity.EVENT_BUS_PRIORITY + 1); - readSystemFlags(); super.onAttachedToWindow(); + readSystemFlags(); } @Override @@ -1417,7 +1417,9 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal Recents.getTaskLoader().loadTaskData(task, true /* fetchAndInvalidateThumbnails */); // If the doze trigger has already fired, then update the state for this task view - tv.setNoUserInteractionState(); + if (mUIDozeTrigger.hasTriggered()) { + tv.setNoUserInteractionState(); + } // Set the new state for this view, including the callbacks and view clipping tv.setCallbacks(this); 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 2e8e665c7630..853f8688767f 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java @@ -29,6 +29,7 @@ import android.graphics.Point; import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; import android.graphics.Rect; +import android.provider.Settings; import android.util.AttributeSet; import android.util.FloatProperty; import android.util.IntProperty; @@ -114,6 +115,7 @@ public class TaskView extends FixedSizeFrameLayout implements Task.TaskCallbacks Task mTask; boolean mTaskDataLoaded; boolean mClipViewInStack = true; + boolean mTouchExplorationEnabled; AnimateableViewBounds mViewBounds; private AnimatorSet mTransformAnimation; @@ -162,6 +164,7 @@ public class TaskView extends FixedSizeFrameLayout implements Task.TaskCallbacks void reset() { resetViewProperties(); resetNoUserInteractionState(); + readSystemFlags(); setClipViewInStack(false); setCallbacks(null); } @@ -177,6 +180,12 @@ public class TaskView extends FixedSizeFrameLayout implements Task.TaskCallbacks } @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + readSystemFlags(); + } + + @Override protected void onFinishInflate() { // Bind the views mContent = findViewById(R.id.task_view_content); @@ -545,7 +554,7 @@ public class TaskView extends FixedSizeFrameLayout implements Task.TaskCallbacks public void onTaskDataLoaded(Task task) { // Bind each of the views to the new task data mThumbnailView.rebindToTask(mTask); - mHeaderView.rebindToTask(mTask); + mHeaderView.rebindToTask(mTask, mTouchExplorationEnabled); mTaskDataLoaded = true; } @@ -554,13 +563,13 @@ public class TaskView extends FixedSizeFrameLayout implements Task.TaskCallbacks // Unbind each of the views from the task data and remove the task callback mTask.removeCallback(this); mThumbnailView.unbindFromTask(); - mHeaderView.unbindFromTask(); + mHeaderView.unbindFromTask(mTouchExplorationEnabled); mTaskDataLoaded = false; } @Override public void onTaskStackIdChanged() { - mHeaderView.rebindToTask(mTask); + mHeaderView.rebindToTask(mTask, mTouchExplorationEnabled); } /**** View.OnClickListener Implementation ****/ @@ -615,4 +624,12 @@ public class TaskView extends FixedSizeFrameLayout implements Task.TaskCallbacks } EventBus.getDefault().unregister(this); } + + /** + * Reads current system flags related to accessibility and screen pinning. + */ + private void readSystemFlags() { + SystemServicesProxy ssp = Recents.getSystemServices(); + mTouchExplorationEnabled = ssp.isTouchExplorationEnabled(); + } } 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 408ffb468535..5e17b908cb95 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java @@ -214,14 +214,18 @@ public class TaskViewHeader extends FrameLayout @Override protected void onFinishInflate() { + SystemServicesProxy ssp = Recents.getSystemServices(); + // Initialize the icon and description views mIconView = (ImageView) findViewById(R.id.icon); mIconView.setClickable(false); mIconView.setOnLongClickListener(this); mTitleView = (TextView) findViewById(R.id.title); mDismissButton = (ImageView) findViewById(R.id.dismiss_task); - mDismissButton.setOnClickListener(this); - mMoveTaskButton = (ImageView) findViewById(R.id.move_task); + if (ssp.hasFreeformWorkspaceSupport()) { + mMoveTaskButton = (ImageView) findViewById(R.id.move_task); + mMoveTaskButton.setVisibility(View.VISIBLE); + } mFocusTimerIndicatorStub = (ViewStub) findViewById(R.id.focus_timer_indicator_stub); mAppOverlayViewStub = (ViewStub) findViewById(R.id.app_overlay_stub); } @@ -339,7 +343,6 @@ public class TaskViewHeader extends FrameLayout void setDimAlpha(float dimAlpha) { mDimAlpha = dimAlpha; updateBackgroundColor(dimAlpha); - invalidate(); } /** @@ -353,11 +356,12 @@ public class TaskViewHeader extends FrameLayout mTmpHSL[2] = Math.min(1f, mTmpHSL[2] + OVERLAY_LIGHTNESS_INCREMENT * (1.0f - dimAlpha)); mOverlayBackground.setColorAndDim(ColorUtils.HSLToColor(mTmpHSL), dimAlpha); mDimLayerPaint.setAlpha((int) (dimAlpha * 255)); + invalidate(); } } /** Binds the bar view to the task */ - public void rebindToTask(Task t) { + public void rebindToTask(Task t, boolean touchExplorationEnabled) { SystemServicesProxy ssp = Recents.getSystemServices(); mTask = t; @@ -391,10 +395,6 @@ public class TaskViewHeader extends FrameLayout ? mLightFreeformIcon : mDarkFreeformIcon); } - if (mMoveTaskButton.getVisibility() != View.VISIBLE) { - mMoveTaskButton.setVisibility(View.VISIBLE); - } - mMoveTaskButton.setOnClickListener(this); } if (Recents.getDebugFlags().isFastToggleRecentsEnabled()) { @@ -408,32 +408,37 @@ public class TaskViewHeader extends FrameLayout } // In accessibility, a single click on the focused app info button will show it - if (ssp.isTouchExplorationEnabled()) { + if (touchExplorationEnabled) { mIconView.setOnClickListener(this); } } /** Unbinds the bar view from the task */ - void unbindFromTask() { + void unbindFromTask(boolean touchExplorationEnabled) { mTask = null; mIconView.setImageDrawable(null); - mIconView.setOnClickListener(null); - mMoveTaskButton.setOnClickListener(null); + if (touchExplorationEnabled) { + mIconView.setOnClickListener(null); + } } /** Animates this task bar if the user does not interact with the stack after a certain time. */ void startNoUserInteractionAnimation() { - if (mDismissButton.getVisibility() != View.VISIBLE) { - mDismissButton.setVisibility(View.VISIBLE); - mDismissButton.setAlpha(0f); - mDismissButton.animate() - .alpha(1f) - .setStartDelay(0) - .setInterpolator(Interpolators.FAST_OUT_LINEAR_IN) - .setDuration(getResources().getInteger( - R.integer.recents_task_enter_from_app_duration)) - .start(); - } + int duration = getResources().getInteger(R.integer.recents_task_enter_from_app_duration); + mDismissButton.setOnClickListener(this); + mDismissButton.setVisibility(View.VISIBLE); + mDismissButton.animate() + .alpha(1f) + .setInterpolator(Interpolators.FAST_OUT_LINEAR_IN) + .setDuration(duration) + .start(); + mMoveTaskButton.setOnClickListener(this); + mMoveTaskButton.setVisibility(View.VISIBLE); + mMoveTaskButton.animate() + .alpha(1f) + .setInterpolator(Interpolators.FAST_OUT_LINEAR_IN) + .setDuration(duration) + .start(); } /** @@ -441,11 +446,14 @@ public class TaskViewHeader extends FrameLayout * time. */ void setNoUserInteractionState() { - if (mDismissButton.getVisibility() != View.VISIBLE) { - mDismissButton.animate().cancel(); - mDismissButton.setVisibility(View.VISIBLE); - mDismissButton.setAlpha(1f); - } + mDismissButton.setVisibility(View.VISIBLE); + mDismissButton.animate().cancel(); + mDismissButton.setAlpha(1f); + mDismissButton.setOnClickListener(this); + mMoveTaskButton.setVisibility(View.VISIBLE); + mMoveTaskButton.animate().cancel(); + mMoveTaskButton.setAlpha(1f); + mMoveTaskButton.setOnClickListener(this); } /** @@ -454,6 +462,11 @@ public class TaskViewHeader extends FrameLayout */ void resetNoUserInteractionState() { mDismissButton.setVisibility(View.INVISIBLE); + mDismissButton.setAlpha(0f); + mDismissButton.setOnClickListener(null); + mMoveTaskButton.setVisibility(View.INVISIBLE); + mMoveTaskButton.setAlpha(0f); + mMoveTaskButton.setOnClickListener(null); } @Override @@ -467,11 +480,8 @@ public class TaskViewHeader extends FrameLayout @Override public void onClick(View v) { if (v == mIconView) { - SystemServicesProxy ssp = Recents.getSystemServices(); - if (ssp.isTouchExplorationEnabled()) { - // In accessibility, a single click on the focused app info button will show it - EventBus.getDefault().send(new ShowApplicationInfoEvent(mTask)); - } + // In accessibility, a single click on the focused app info button will show it + EventBus.getDefault().send(new ShowApplicationInfoEvent(mTask)); } else if (v == mDismissButton) { TaskView tv = Utilities.findParent(this, TaskView.class); tv.dismissTask(); 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 ea406442020d..f90951e4ccd1 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewThumbnail.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewThumbnail.java @@ -93,7 +93,6 @@ public class TaskViewThumbnail extends View { mTaskViewRect.set(0, 0, width, height); updateThumbnailScale(); - invalidate(); } @Override @@ -120,7 +119,6 @@ public class TaskViewThumbnail extends View { mDrawPaint.setShader(null); mThumbnailRect.setEmpty(); } - invalidate(); } /** Updates the paint to draw the thumbnail. */ @@ -138,7 +136,9 @@ public class TaskViewThumbnail extends View { mDrawPaint.setColorFilter(null); mDrawPaint.setColor(Color.argb(255, grey, grey, grey)); } - invalidate(); + if (!mInvisible) { + invalidate(); + } } /** |