Fixing topView not being considered in all places when calculating accessible
and focusable views Bug: 30563273 Change-Id: I6253ce33ee5c328efdde2ea733029975b31e5eb8
This commit is contained in:
@@ -3151,6 +3151,14 @@ public class Launcher extends Activity
|
||||
}
|
||||
}
|
||||
|
||||
public View getTopFloatingView() {
|
||||
View topView = getOpenShortcutsContainer();
|
||||
if (topView == null) {
|
||||
topView = getWorkspace().getOpenFolder();
|
||||
}
|
||||
return topView;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The open shortcuts container, or null if there is none
|
||||
*/
|
||||
|
||||
@@ -102,8 +102,8 @@ public class PinchToOverviewListener extends ScaleGestureDetector.SimpleOnScaleG
|
||||
// once the state switching animation is complete.
|
||||
return false;
|
||||
}
|
||||
if (mWorkspace.getOpenFolder() != null) {
|
||||
// Don't listen for the pinch gesture if a folder is open.
|
||||
if (mLauncher.getTopFloatingView() != null) {
|
||||
// Don't listen for the pinch gesture if a floating view is open.
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,8 @@ import android.util.SparseArray;
|
||||
import android.util.TypedValue;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.launcher3.compat.UserHandleCompat;
|
||||
@@ -906,4 +908,15 @@ public final class Utilities {
|
||||
ta.recycle();
|
||||
return colorAccent;
|
||||
}
|
||||
|
||||
public static void sendCustomAccessibilityEvent(View target, int type, String text) {
|
||||
AccessibilityManager accessibilityManager = (AccessibilityManager)
|
||||
target.getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
|
||||
if (accessibilityManager.isEnabled()) {
|
||||
AccessibilityEvent event = AccessibilityEvent.obtain(type);
|
||||
target.onInitializeAccessibilityEvent(event);
|
||||
event.getText().add(text);
|
||||
accessibilityManager.sendAccessibilityEvent(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1857,19 +1857,6 @@ public class Workspace extends PagedView
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect) {
|
||||
if (!mLauncher.isAppsViewVisible()) {
|
||||
final Folder openFolder = getOpenFolder();
|
||||
if (openFolder != null) {
|
||||
return openFolder.requestFocus(direction, previouslyFocusedRect);
|
||||
} else {
|
||||
return super.onRequestFocusInDescendants(direction, previouslyFocusedRect);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDescendantFocusability() {
|
||||
if (workspaceInModalState()) {
|
||||
@@ -1878,18 +1865,6 @@ public class Workspace extends PagedView
|
||||
return super.getDescendantFocusability();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFocusables(ArrayList<View> views, int direction, int focusableMode) {
|
||||
if (!mLauncher.isAppsViewVisible()) {
|
||||
final Folder openFolder = getOpenFolder();
|
||||
if (openFolder != null) {
|
||||
openFolder.addFocusables(views, direction);
|
||||
} else {
|
||||
super.addFocusables(views, direction, focusableMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean workspaceInModalState() {
|
||||
return mState != State.NORMAL;
|
||||
}
|
||||
|
||||
@@ -343,16 +343,9 @@ public class DragLayer extends InsettableFrameLayout {
|
||||
}
|
||||
|
||||
private void sendTapOutsideFolderAccessibilityEvent(boolean isEditingName) {
|
||||
AccessibilityManager accessibilityManager = (AccessibilityManager)
|
||||
getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
|
||||
if (accessibilityManager.isEnabled()) {
|
||||
int stringId = isEditingName ? R.string.folder_tap_to_rename : R.string.folder_tap_to_close;
|
||||
AccessibilityEvent event = AccessibilityEvent.obtain(
|
||||
AccessibilityEvent.TYPE_VIEW_FOCUSED);
|
||||
onInitializeAccessibilityEvent(event);
|
||||
event.getText().add(getContext().getString(stringId));
|
||||
accessibilityManager.sendAccessibilityEvent(event);
|
||||
}
|
||||
int stringId = isEditingName ? R.string.folder_tap_to_rename : R.string.folder_tap_to_close;
|
||||
Utilities.sendCustomAccessibilityEvent(
|
||||
this, AccessibilityEvent.TYPE_VIEW_FOCUSED, getContext().getString(stringId));
|
||||
}
|
||||
|
||||
private boolean isInAccessibleDrag() {
|
||||
@@ -362,37 +355,27 @@ public class DragLayer extends InsettableFrameLayout {
|
||||
@Override
|
||||
public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) {
|
||||
// Shortcuts can appear above folder
|
||||
View topView = mLauncher.getOpenShortcutsContainer();
|
||||
View topView = mLauncher.getTopFloatingView();
|
||||
if (topView != null) {
|
||||
return handleTopViewSendAccessibilityEvent(topView, child, event);
|
||||
}
|
||||
|
||||
topView = mLauncher.getWorkspace().getOpenFolder();
|
||||
if (topView != null) {
|
||||
return handleTopViewSendAccessibilityEvent(topView, child, event);
|
||||
if (child == topView) {
|
||||
return super.onRequestSendAccessibilityEvent(child, event);
|
||||
}
|
||||
if (isInAccessibleDrag() && child instanceof DropTargetBar) {
|
||||
return super.onRequestSendAccessibilityEvent(child, event);
|
||||
}
|
||||
// Skip propagating onRequestSendAccessibilityEvent for all other children
|
||||
// which are not topView
|
||||
return false;
|
||||
}
|
||||
return super.onRequestSendAccessibilityEvent(child, event);
|
||||
}
|
||||
|
||||
private boolean handleTopViewSendAccessibilityEvent(
|
||||
View topView, View child, AccessibilityEvent event) {
|
||||
if (child == topView) {
|
||||
return super.onRequestSendAccessibilityEvent(child, event);
|
||||
}
|
||||
if (isInAccessibleDrag() && child instanceof DropTargetBar) {
|
||||
return super.onRequestSendAccessibilityEvent(child, event);
|
||||
}
|
||||
// Skip propagating onRequestSendAccessibilityEvent for all other children
|
||||
// which are not topView
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChildrenForAccessibility(ArrayList<View> childrenForAccessibility) {
|
||||
Folder currentFolder = mLauncher.getWorkspace().getOpenFolder();
|
||||
if (currentFolder != null) {
|
||||
// Only add the folder as a child for accessibility when it is open
|
||||
childrenForAccessibility.add(currentFolder);
|
||||
View topView = mLauncher.getTopFloatingView();
|
||||
if (topView != null) {
|
||||
// Only add the top view as a child for accessibility when it is open
|
||||
childrenForAccessibility.add(topView);
|
||||
|
||||
if (isInAccessibleDrag()) {
|
||||
childrenForAccessibility.add(mLauncher.getDropTargetBar());
|
||||
@@ -1037,6 +1020,26 @@ public class DragLayer extends InsettableFrameLayout {
|
||||
return mBackgroundAlpha;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect) {
|
||||
View topView = mLauncher.getTopFloatingView();
|
||||
if (topView != null) {
|
||||
return topView.requestFocus(direction, previouslyFocusedRect);
|
||||
} else {
|
||||
return super.onRequestFocusInDescendants(direction, previouslyFocusedRect);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFocusables(ArrayList<View> views, int direction, int focusableMode) {
|
||||
View topView = mLauncher.getTopFloatingView();
|
||||
if (topView != null) {
|
||||
topView.addFocusables(views, direction);
|
||||
} else {
|
||||
super.addFocusables(views, direction, focusableMode);
|
||||
}
|
||||
}
|
||||
|
||||
public void setTouchCompleteListener(TouchCompleteListener listener) {
|
||||
mTouchCompleteListener = listener;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@ import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewDebug;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import android.view.animation.AccelerateInterpolator;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
@@ -52,7 +51,6 @@ import android.widget.TextView;
|
||||
|
||||
import com.android.launcher3.Alarm;
|
||||
import com.android.launcher3.CellLayout;
|
||||
import com.android.launcher3.CellLayout.CellInfo;
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.DragSource;
|
||||
import com.android.launcher3.DropTarget;
|
||||
@@ -77,7 +75,6 @@ import com.android.launcher3.dragndrop.DragController;
|
||||
import com.android.launcher3.dragndrop.DragController.DragListener;
|
||||
import com.android.launcher3.dragndrop.DragLayer;
|
||||
import com.android.launcher3.dragndrop.DragOptions;
|
||||
import com.android.launcher3.logging.UserEventDispatcher.LaunchSourceProvider;
|
||||
import com.android.launcher3.pageindicators.PageIndicatorDots;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
|
||||
@@ -366,7 +363,8 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
|
||||
LauncherModel.updateItemInDatabase(mLauncher, mInfo);
|
||||
|
||||
if (commit) {
|
||||
sendCustomAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED,
|
||||
Utilities.sendCustomAccessibilityEvent(
|
||||
this, AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED,
|
||||
getContext().getString(R.string.folder_renamed, newTitle));
|
||||
}
|
||||
|
||||
@@ -605,7 +603,9 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
|
||||
openFolderAnim.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
sendCustomAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED,
|
||||
Utilities.sendCustomAccessibilityEvent(
|
||||
Folder.this,
|
||||
AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED,
|
||||
mContent.getAccessibilityDescription());
|
||||
mState = STATE_ANIMATING;
|
||||
}
|
||||
@@ -675,17 +675,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
|
||||
mDragController.addDragListener(this);
|
||||
}
|
||||
|
||||
@Thunk void sendCustomAccessibilityEvent(int type, String text) {
|
||||
AccessibilityManager accessibilityManager = (AccessibilityManager)
|
||||
getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
|
||||
if (accessibilityManager.isEnabled()) {
|
||||
AccessibilityEvent event = AccessibilityEvent.obtain(type);
|
||||
onInitializeAccessibilityEvent(event);
|
||||
event.getText().add(text);
|
||||
accessibilityManager.sendAccessibilityEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
public void animateClosed() {
|
||||
if (!(getParent() instanceof DragLayer)) return;
|
||||
final ObjectAnimator oa = LauncherAnimUtils.ofViewAlphaAndScale(this, 0, 0.9f, 0.9f);
|
||||
@@ -697,7 +686,9 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
|
||||
}
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
sendCustomAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED,
|
||||
Utilities.sendCustomAccessibilityEvent(
|
||||
Folder.this,
|
||||
AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED,
|
||||
getContext().getString(R.string.folder_closed));
|
||||
mState = STATE_ANIMATING;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ import android.graphics.drawable.ShapeDrawable;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.Gravity;
|
||||
import android.view.HapticFeedbackConstants;
|
||||
@@ -65,7 +64,6 @@ import com.android.launcher3.dragndrop.DragLayer;
|
||||
import com.android.launcher3.dragndrop.DragOptions;
|
||||
import com.android.launcher3.dragndrop.DragView;
|
||||
import com.android.launcher3.graphics.TriangleShape;
|
||||
import com.android.launcher3.logging.UserEventDispatcher;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
|
||||
|
||||
@@ -255,8 +253,10 @@ public class DeepShortcutsContainer extends LinearLayout implements View.OnLongC
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mOpenCloseAnimator = null;
|
||||
|
||||
sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
|
||||
Utilities.sendCustomAccessibilityEvent(
|
||||
DeepShortcutsContainer.this,
|
||||
AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED,
|
||||
getContext().getString(R.string.action_deep_shortcut));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user