Removing accessibility "Collapse" action from QS when in split shade
This action resulted in broken QS state in split shade and didn't make much sense as QS can't be collapsed. Now this action is dependent on split shade state and is only announced in non-split shade. Fixes: 269462512 Test: QSPanelControllerTest Test: talkback on -> open split shade -> focus on QS -> tap with three fingers -> see no "Actions" in menu Change-Id: I007f0e87d41a36bd71c28d95f566335852e2e732
This commit is contained in:
@@ -25,8 +25,6 @@ import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
@@ -108,6 +106,11 @@ public class QSPanel extends LinearLayout implements Tunable {
|
||||
private boolean mShouldMoveMediaOnExpansion = true;
|
||||
private boolean mUsingCombinedHeaders = false;
|
||||
private QSLogger mQsLogger;
|
||||
/**
|
||||
* Specifies if we can collapse to QQS in current state. In split shade that should be always
|
||||
* false. It influences available accessibility actions.
|
||||
*/
|
||||
private boolean mCanCollapse = true;
|
||||
|
||||
public QSPanel(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
@@ -650,7 +653,9 @@ public class QSPanel extends LinearLayout implements Tunable {
|
||||
@Override
|
||||
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
|
||||
super.onInitializeAccessibilityNodeInfo(info);
|
||||
info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_COLLAPSE);
|
||||
if (mCanCollapse) {
|
||||
info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_COLLAPSE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -669,15 +674,11 @@ public class QSPanel extends LinearLayout implements Tunable {
|
||||
mCollapseExpandAction = action;
|
||||
}
|
||||
|
||||
private class H extends Handler {
|
||||
private static final int ANNOUNCE_FOR_ACCESSIBILITY = 1;
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
if (msg.what == ANNOUNCE_FOR_ACCESSIBILITY) {
|
||||
announceForAccessibility((CharSequence) msg.obj);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Specifies if these expanded QS can collapse to QQS.
|
||||
*/
|
||||
public void setCanCollapse(boolean canCollapse) {
|
||||
mCanCollapse = canCollapse;
|
||||
}
|
||||
|
||||
public interface QSTileLayout {
|
||||
|
||||
@@ -148,9 +148,10 @@ public class QSPanelController extends QSPanelControllerBase<QSPanel> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSplitShadeChanged() {
|
||||
protected void onSplitShadeChanged(boolean shouldUseSplitNotificationShade) {
|
||||
((PagedTileLayout) mView.getOrCreateTileLayout())
|
||||
.forceTilesRedistribution("Split shade state changed");
|
||||
mView.setCanCollapse(!shouldUseSplitNotificationShade);
|
||||
}
|
||||
|
||||
/** */
|
||||
|
||||
@@ -104,14 +104,14 @@ public abstract class QSPanelControllerBase<T extends QSPanel> extends ViewContr
|
||||
switchTileLayoutIfNeeded();
|
||||
onConfigurationChanged();
|
||||
if (previousSplitShadeState != mShouldUseSplitNotificationShade) {
|
||||
onSplitShadeChanged();
|
||||
onSplitShadeChanged(mShouldUseSplitNotificationShade);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
protected void onConfigurationChanged() { }
|
||||
|
||||
protected void onSplitShadeChanged() { }
|
||||
protected void onSplitShadeChanged(boolean shouldUseSplitNotificationShade) { }
|
||||
|
||||
private final Function1<Boolean, Unit> mMediaHostVisibilityListener = (visible) -> {
|
||||
if (mMediaVisibilityChangedListener != null) {
|
||||
|
||||
@@ -70,7 +70,7 @@ class QSPanelControllerTest : SysuiTestCase() {
|
||||
|
||||
whenever(brightnessSliderFactory.create(any(), any())).thenReturn(brightnessSlider)
|
||||
whenever(brightnessControllerFactory.create(any())).thenReturn(brightnessController)
|
||||
testableResources.addOverride(R.bool.config_use_split_notification_shade, false)
|
||||
setShouldUseSplitShade(false)
|
||||
whenever(qsPanel.resources).thenReturn(testableResources.resources)
|
||||
whenever(qsPanel.getOrCreateTileLayout()).thenReturn(pagedTileLayout)
|
||||
whenever(statusBarKeyguardViewManager.isPrimaryBouncerInTransit()).thenReturn(false)
|
||||
@@ -133,12 +133,31 @@ class QSPanelControllerTest : SysuiTestCase() {
|
||||
|
||||
@Test
|
||||
fun configurationChange_onlySplitShadeConfigChanges_tileAreRedistributed() {
|
||||
testableResources.addOverride(R.bool.config_use_split_notification_shade, false)
|
||||
setShouldUseSplitShade(false)
|
||||
controller.mOnConfigurationChangedListener.onConfigurationChange(configuration)
|
||||
verify(pagedTileLayout, never()).forceTilesRedistribution(any())
|
||||
|
||||
testableResources.addOverride(R.bool.config_use_split_notification_shade, true)
|
||||
setShouldUseSplitShade(true)
|
||||
controller.mOnConfigurationChangedListener.onConfigurationChange(configuration)
|
||||
verify(pagedTileLayout).forceTilesRedistribution("Split shade state changed")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun configurationChange_onlySplitShadeConfigChanges_qsPanelCanBeCollapsed() {
|
||||
setShouldUseSplitShade(false)
|
||||
controller.mOnConfigurationChangedListener.onConfigurationChange(configuration)
|
||||
verify(qsPanel, never()).setCanCollapse(anyBoolean())
|
||||
|
||||
setShouldUseSplitShade(true)
|
||||
controller.mOnConfigurationChangedListener.onConfigurationChange(configuration)
|
||||
verify(qsPanel).setCanCollapse(false)
|
||||
|
||||
setShouldUseSplitShade(false)
|
||||
controller.mOnConfigurationChangedListener.onConfigurationChange(configuration)
|
||||
verify(qsPanel).setCanCollapse(true)
|
||||
}
|
||||
|
||||
private fun setShouldUseSplitShade(shouldUse: Boolean) {
|
||||
testableResources.addOverride(R.bool.config_use_split_notification_shade, shouldUse)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.mock
|
||||
import org.mockito.Mockito.never
|
||||
import org.mockito.Mockito.verify
|
||||
import org.mockito.MockitoAnnotations
|
||||
|
||||
@@ -196,6 +197,16 @@ class QSPanelTest : SysuiTestCase() {
|
||||
qsPanel.setSquishinessFraction(0.5f)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSplitShade_CollapseAccessibilityActionNotAnnounced() {
|
||||
qsPanel.setCanCollapse(false)
|
||||
val accessibilityInfo = mock(AccessibilityNodeInfo::class.java)
|
||||
qsPanel.onInitializeAccessibilityNodeInfo(accessibilityInfo)
|
||||
|
||||
val actionCollapse = AccessibilityNodeInfo.AccessibilityAction.ACTION_COLLAPSE
|
||||
verify(accessibilityInfo, never()).addAction(actionCollapse)
|
||||
}
|
||||
|
||||
private infix fun View.isLeftOf(other: View): Boolean {
|
||||
val rect = Rect()
|
||||
getBoundsOnScreen(rect)
|
||||
|
||||
Reference in New Issue
Block a user