summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Tryshev <vadimt@google.com>2018-04-30 13:52:13 -0700
committerVadim Tryshev <vadimt@google.com>2018-05-01 11:20:14 -0700
commit4e3e54a45ab30d23d78cd58e3cf780378dd261cc (patch)
tree3662b9423e3eec28cd7f666feb4d3d40e7bd59fa
parent1e0b98fa6e145e4a80781541b3631b2284b1ce82 (diff)
downloadandroid_packages_apps_Trebuchet-4e3e54a45ab30d23d78cd58e3cf780378dd261cc.tar.gz
android_packages_apps_Trebuchet-4e3e54a45ab30d23d78cd58e3cf780378dd261cc.tar.bz2
android_packages_apps_Trebuchet-4e3e54a45ab30d23d78cd58e3cf780378dd261cc.zip
Accessibility of clear-all button
Making it visible to accessibility even when it’s completely hidden behind a task. I had to mark it visible as a view. Now it’s invisible only when there are no tasks in RecensView, to hide it from accessibility. Focusing on the button completely reveals it. Bug: 72222505 Test: Manual Change-Id: Ia31a1136e07faed93b4a44d5be69483d3b88364d
-rw-r--r--quickstep/res/layout/overview_clear_all_button.xml3
-rw-r--r--quickstep/src/com/android/quickstep/views/ClearAllButton.java55
-rw-r--r--quickstep/src/com/android/quickstep/views/RecentsView.java16
-rw-r--r--quickstep/src/com/android/quickstep/views/RecentsViewContainer.java23
4 files changed, 91 insertions, 6 deletions
diff --git a/quickstep/res/layout/overview_clear_all_button.xml b/quickstep/res/layout/overview_clear_all_button.xml
index 1ada914b7..0dc5d7cad 100644
--- a/quickstep/res/layout/overview_clear_all_button.xml
+++ b/quickstep/res/layout/overview_clear_all_button.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
-<TextView
+<com.android.quickstep.views.ClearAllButton
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/clear_all_button"
style="@android:style/Widget.DeviceDefault.Button.Borderless"
@@ -10,5 +10,6 @@
android:fontFamily="sans-serif-medium"
android:text="@string/recents_clear_all"
android:textColor="?attr/workspaceTextColor"
+ android:visibility="invisible"
android:textSize="14sp"
/> \ No newline at end of file
diff --git a/quickstep/src/com/android/quickstep/views/ClearAllButton.java b/quickstep/src/com/android/quickstep/views/ClearAllButton.java
new file mode 100644
index 000000000..14867ab78
--- /dev/null
+++ b/quickstep/src/com/android/quickstep/views/ClearAllButton.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2018 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.quickstep.views;
+
+import static android.view.accessibility.AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.util.AttributeSet;
+import android.view.accessibility.AccessibilityNodeInfo;
+import android.widget.TextView;
+
+public class ClearAllButton extends TextView {
+ RecentsView mRecentsView;
+
+ public ClearAllButton(Context context, @Nullable AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public void setRecentsView(RecentsView recentsView) {
+ mRecentsView = recentsView;
+ }
+
+ @Override
+ public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
+ super.onInitializeAccessibilityNodeInfo(info);
+ // Should be visible to accessibility even when completely covered by the task.
+ // Otherwise, we won't be able to scroll to it.
+ info.setVisibleToUser(true);
+ }
+
+ @Override
+ public boolean performAccessibilityAction(int action, Bundle arguments) {
+ final boolean res = super.performAccessibilityAction(action, arguments);
+ if (action == ACTION_ACCESSIBILITY_FOCUS) {
+ mRecentsView.revealClearAllButton();
+ }
+ return res;
+ }
+}
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index f521b25cc..e1624d153 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -264,6 +264,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
loader.unloadTaskData(task);
loader.getHighResThumbnailLoader().onTaskInvisible(task);
}
+ onChildViewsChanged();
}
public boolean isTaskViewVisible(TaskView tv) {
@@ -358,7 +359,6 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
if (mClearAllButton != null) {
final float alpha = calculateClearAllButtonAlpha();
mClearAllButton.setAlpha(alpha * mContentAlpha);
- mClearAllButton.setVisibility(alpha == 0 ? INVISIBLE : VISIBLE);
}
}
@@ -371,7 +371,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
@Override
public boolean onTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN && mTouchState == TOUCH_STATE_REST
- && mScroller.isFinished() && mClearAllButton.getVisibility() == View.VISIBLE) {
+ && mScroller.isFinished() && mClearAllButton.getAlpha() > 0) {
mClearAllButton.getHitRect(mTempRect);
mTempRect.offset(-getLeft(), -getTop());
if (mTempRect.contains((int) ev.getX(), (int) ev.getY())) {
@@ -1011,6 +1011,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
super.onViewAdded(child);
child.setAlpha(mContentAlpha);
setAdjacentScale(mAdjacentScale);
+ onChildViewsChanged();
}
@Override
@@ -1243,4 +1244,15 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
mClearAllButton = clearAllButton;
updateClearAllButtonAlpha();
}
+
+ private void onChildViewsChanged() {
+ final int childCount = getChildCount();
+ mClearAllButton.setAccessibilityTraversalAfter(
+ childCount == 0 ? NO_ID : getChildAt(childCount - 1).getId());
+ mClearAllButton.setVisibility(childCount == 0 ? INVISIBLE : VISIBLE);
+ }
+
+ public void revealClearAllButton() {
+ scrollTo(mIsRtl ? 0 : computeMaxScrollX(), 0);
+ }
}
diff --git a/quickstep/src/com/android/quickstep/views/RecentsViewContainer.java b/quickstep/src/com/android/quickstep/views/RecentsViewContainer.java
index 15925b571..a951de922 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsViewContainer.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsViewContainer.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2018 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.quickstep.views;
import static com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch.TAP;
@@ -9,7 +25,6 @@ import android.util.AttributeSet;
import android.util.FloatProperty;
import android.view.Gravity;
import android.view.MotionEvent;
-import android.view.View;
import com.android.launcher3.InsettableFrameLayout;
import com.android.launcher3.R;
@@ -31,7 +46,7 @@ public class RecentsViewContainer extends InsettableFrameLayout {
private final Rect mTempRect = new Rect();
private RecentsView mRecentsView;
- private View mClearAllButton;
+ private ClearAllButton mClearAllButton;
public RecentsViewContainer(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -48,13 +63,15 @@ public class RecentsViewContainer extends InsettableFrameLayout {
mRecentsView.dismissAllTasks();
});
- mRecentsView = (RecentsView) findViewById(R.id.overview_panel);
+ mRecentsView = findViewById(R.id.overview_panel);
final InsettableFrameLayout.LayoutParams params =
(InsettableFrameLayout.LayoutParams) mClearAllButton.getLayoutParams();
params.gravity = Gravity.TOP | (RecentsView.FLIP_RECENTS ? Gravity.START : Gravity.END);
mClearAllButton.setLayoutParams(params);
mClearAllButton.forceHasOverlappingRendering(false);
+
mRecentsView.setClearAllButton(mClearAllButton);
+ mClearAllButton.setRecentsView(mRecentsView);
}
@Override