Merge "Create accessibility menu for bubble bar" into main
This commit is contained in:
@@ -30,6 +30,7 @@ import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Bundle;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.FloatProperty;
|
||||
import android.util.LayoutDirection;
|
||||
@@ -38,6 +39,7 @@ import android.view.Gravity;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.dynamicanimation.animation.SpringForce;
|
||||
@@ -367,6 +369,47 @@ public class BubbleBarView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) {
|
||||
super.onInitializeAccessibilityNodeInfoInternal(info);
|
||||
// Always show only expand action as the menu is only for collapsed bubble bar
|
||||
info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_EXPAND);
|
||||
info.addAction(new AccessibilityNodeInfo.AccessibilityAction(R.id.action_dismiss_all,
|
||||
getResources().getString(R.string.bubble_bar_action_dismiss_all)));
|
||||
if (mBubbleBarLocation.isOnLeft(isLayoutRtl())) {
|
||||
info.addAction(new AccessibilityNodeInfo.AccessibilityAction(R.id.action_move_right,
|
||||
getResources().getString(R.string.bubble_bar_action_move_right)));
|
||||
} else {
|
||||
info.addAction(new AccessibilityNodeInfo.AccessibilityAction(R.id.action_move_left,
|
||||
getResources().getString(R.string.bubble_bar_action_move_left)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performAccessibilityActionInternal(int action,
|
||||
@androidx.annotation.Nullable Bundle arguments) {
|
||||
if (super.performAccessibilityActionInternal(action, arguments)) {
|
||||
return true;
|
||||
}
|
||||
if (action == AccessibilityNodeInfo.ACTION_EXPAND) {
|
||||
mController.expandBubbleBar();
|
||||
return true;
|
||||
}
|
||||
if (action == R.id.action_dismiss_all) {
|
||||
mController.dismissBubbleBar();
|
||||
return true;
|
||||
}
|
||||
if (action == R.id.action_move_left) {
|
||||
mController.updateBubbleBarLocation(BubbleBarLocation.LEFT);
|
||||
return true;
|
||||
}
|
||||
if (action == R.id.action_move_right) {
|
||||
mController.updateBubbleBarLocation(BubbleBarLocation.RIGHT);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressLint("RtlHardcoded")
|
||||
private void onBubbleBarLocationChanged() {
|
||||
final boolean onLeft = mBubbleBarLocation.isOnLeft(isLayoutRtl());
|
||||
@@ -1382,5 +1425,14 @@ public class BubbleBarView extends FrameLayout {
|
||||
|
||||
/** Notifies the controller that the bubble bar was touched while it was animating. */
|
||||
void onBubbleBarTouchedWhileAnimating();
|
||||
|
||||
/** Requests the controller to expand bubble bar */
|
||||
void expandBubbleBar();
|
||||
|
||||
/** Requests the controller to dismiss the bubble bar */
|
||||
void dismissBubbleBar();
|
||||
|
||||
/** Requests the controller to update bubble bar location to the given value */
|
||||
void updateBubbleBarLocation(BubbleBarLocation location);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ public class BubbleBarViewController {
|
||||
dp -> onBubbleBarConfigurationChanged(/* animate= */ true));
|
||||
mBubbleBarScale.updateValue(1f);
|
||||
mBubbleClickListener = v -> onBubbleClicked((BubbleView) v);
|
||||
mBubbleBarClickListener = v -> onBubbleBarClicked();
|
||||
mBubbleBarClickListener = v -> expandBubbleBar();
|
||||
mBubbleDragController.setupBubbleBarView(mBarView);
|
||||
mBarView.setOnClickListener(mBubbleBarClickListener);
|
||||
mBarView.addOnLayoutChangeListener(
|
||||
@@ -137,6 +137,21 @@ public class BubbleBarViewController {
|
||||
public void onBubbleBarTouchedWhileAnimating() {
|
||||
BubbleBarViewController.this.onBubbleBarTouchedWhileAnimating();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void expandBubbleBar() {
|
||||
BubbleBarViewController.this.expandBubbleBar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismissBubbleBar() {
|
||||
onDismissAllBubbles();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBubbleBarLocation(BubbleBarLocation location) {
|
||||
mBubbleBarController.updateBubbleBarLocation(location);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -162,7 +177,7 @@ public class BubbleBarViewController {
|
||||
mBubbleStashController.onNewBubbleAnimationInterrupted(false, mBarView.getTranslationY());
|
||||
}
|
||||
|
||||
private void onBubbleBarClicked() {
|
||||
private void expandBubbleBar() {
|
||||
if (mShouldShowEducation) {
|
||||
mShouldShowEducation = false;
|
||||
// Get the bubble bar bounds on screen
|
||||
@@ -609,17 +624,17 @@ public class BubbleBarViewController {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when bubble was dragged into the dismiss target. Notifies System
|
||||
* Called when given bubble was dismissed. Notifies SystemUI
|
||||
* @param bubble dismissed bubble item
|
||||
*/
|
||||
public void onDismissBubbleWhileDragging(@NonNull BubbleBarItem bubble) {
|
||||
public void onDismissBubble(@NonNull BubbleBarItem bubble) {
|
||||
mSystemUiProxy.dragBubbleToDismiss(bubble.getKey(), mTimeSource.currentTimeMillis());
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when bubble stack was dragged into the dismiss target
|
||||
* Called when bubble stack was dismissed
|
||||
*/
|
||||
public void onDismissAllBubblesWhileDragging() {
|
||||
public void onDismissAllBubbles() {
|
||||
mSystemUiProxy.removeAllBubbles();
|
||||
}
|
||||
|
||||
|
||||
@@ -143,10 +143,10 @@ public class BubbleDismissController {
|
||||
if (mMagnetizedObject.getUnderlyingObject() instanceof BubbleView) {
|
||||
BubbleView bubbleView = (BubbleView) mMagnetizedObject.getUnderlyingObject();
|
||||
if (bubbleView.getBubble() != null) {
|
||||
mBubbleBarViewController.onDismissBubbleWhileDragging(bubbleView.getBubble());
|
||||
mBubbleBarViewController.onDismissBubble(bubbleView.getBubble());
|
||||
}
|
||||
} else if (mMagnetizedObject.getUnderlyingObject() instanceof BubbleBarView) {
|
||||
mBubbleBarViewController.onDismissAllBubblesWhileDragging();
|
||||
mBubbleBarViewController.onDismissAllBubbles();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user