Merge "Removing accessibility "Collapse" action from QS when in split shade" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
914d661995
@@ -25,8 +25,6 @@ import android.content.res.Configuration;
|
|||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.Message;
|
|
||||||
import android.util.ArrayMap;
|
import android.util.ArrayMap;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -108,6 +106,11 @@ public class QSPanel extends LinearLayout implements Tunable {
|
|||||||
private boolean mShouldMoveMediaOnExpansion = true;
|
private boolean mShouldMoveMediaOnExpansion = true;
|
||||||
private boolean mUsingCombinedHeaders = false;
|
private boolean mUsingCombinedHeaders = false;
|
||||||
private QSLogger mQsLogger;
|
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) {
|
public QSPanel(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
@@ -650,7 +653,9 @@ public class QSPanel extends LinearLayout implements Tunable {
|
|||||||
@Override
|
@Override
|
||||||
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
|
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
|
||||||
super.onInitializeAccessibilityNodeInfo(info);
|
super.onInitializeAccessibilityNodeInfo(info);
|
||||||
info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_COLLAPSE);
|
if (mCanCollapse) {
|
||||||
|
info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_COLLAPSE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -669,15 +674,11 @@ public class QSPanel extends LinearLayout implements Tunable {
|
|||||||
mCollapseExpandAction = action;
|
mCollapseExpandAction = action;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class H extends Handler {
|
/**
|
||||||
private static final int ANNOUNCE_FOR_ACCESSIBILITY = 1;
|
* Specifies if these expanded QS can collapse to QQS.
|
||||||
|
*/
|
||||||
@Override
|
public void setCanCollapse(boolean canCollapse) {
|
||||||
public void handleMessage(Message msg) {
|
mCanCollapse = canCollapse;
|
||||||
if (msg.what == ANNOUNCE_FOR_ACCESSIBILITY) {
|
|
||||||
announceForAccessibility((CharSequence) msg.obj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface QSTileLayout {
|
public interface QSTileLayout {
|
||||||
|
|||||||
@@ -148,9 +148,10 @@ public class QSPanelController extends QSPanelControllerBase<QSPanel> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onSplitShadeChanged() {
|
protected void onSplitShadeChanged(boolean shouldUseSplitNotificationShade) {
|
||||||
((PagedTileLayout) mView.getOrCreateTileLayout())
|
((PagedTileLayout) mView.getOrCreateTileLayout())
|
||||||
.forceTilesRedistribution("Split shade state changed");
|
.forceTilesRedistribution("Split shade state changed");
|
||||||
|
mView.setCanCollapse(!shouldUseSplitNotificationShade);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
|
|||||||
@@ -104,14 +104,14 @@ public abstract class QSPanelControllerBase<T extends QSPanel> extends ViewContr
|
|||||||
switchTileLayoutIfNeeded();
|
switchTileLayoutIfNeeded();
|
||||||
onConfigurationChanged();
|
onConfigurationChanged();
|
||||||
if (previousSplitShadeState != mShouldUseSplitNotificationShade) {
|
if (previousSplitShadeState != mShouldUseSplitNotificationShade) {
|
||||||
onSplitShadeChanged();
|
onSplitShadeChanged(mShouldUseSplitNotificationShade);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
protected void onConfigurationChanged() { }
|
protected void onConfigurationChanged() { }
|
||||||
|
|
||||||
protected void onSplitShadeChanged() { }
|
protected void onSplitShadeChanged(boolean shouldUseSplitNotificationShade) { }
|
||||||
|
|
||||||
private final Function1<Boolean, Unit> mMediaHostVisibilityListener = (visible) -> {
|
private final Function1<Boolean, Unit> mMediaHostVisibilityListener = (visible) -> {
|
||||||
if (mMediaVisibilityChangedListener != null) {
|
if (mMediaVisibilityChangedListener != null) {
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ class QSPanelControllerTest : SysuiTestCase() {
|
|||||||
|
|
||||||
whenever(brightnessSliderFactory.create(any(), any())).thenReturn(brightnessSlider)
|
whenever(brightnessSliderFactory.create(any(), any())).thenReturn(brightnessSlider)
|
||||||
whenever(brightnessControllerFactory.create(any())).thenReturn(brightnessController)
|
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.resources).thenReturn(testableResources.resources)
|
||||||
whenever(qsPanel.getOrCreateTileLayout()).thenReturn(pagedTileLayout)
|
whenever(qsPanel.getOrCreateTileLayout()).thenReturn(pagedTileLayout)
|
||||||
whenever(statusBarKeyguardViewManager.isPrimaryBouncerInTransit()).thenReturn(false)
|
whenever(statusBarKeyguardViewManager.isPrimaryBouncerInTransit()).thenReturn(false)
|
||||||
@@ -133,12 +133,31 @@ class QSPanelControllerTest : SysuiTestCase() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun configurationChange_onlySplitShadeConfigChanges_tileAreRedistributed() {
|
fun configurationChange_onlySplitShadeConfigChanges_tileAreRedistributed() {
|
||||||
testableResources.addOverride(R.bool.config_use_split_notification_shade, false)
|
setShouldUseSplitShade(false)
|
||||||
controller.mOnConfigurationChangedListener.onConfigurationChange(configuration)
|
controller.mOnConfigurationChangedListener.onConfigurationChange(configuration)
|
||||||
verify(pagedTileLayout, never()).forceTilesRedistribution(any())
|
verify(pagedTileLayout, never()).forceTilesRedistribution(any())
|
||||||
|
|
||||||
testableResources.addOverride(R.bool.config_use_split_notification_shade, true)
|
setShouldUseSplitShade(true)
|
||||||
controller.mOnConfigurationChangedListener.onConfigurationChange(configuration)
|
controller.mOnConfigurationChangedListener.onConfigurationChange(configuration)
|
||||||
verify(pagedTileLayout).forceTilesRedistribution("Split shade state changed")
|
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.junit.runner.RunWith
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
import org.mockito.Mockito.mock
|
import org.mockito.Mockito.mock
|
||||||
|
import org.mockito.Mockito.never
|
||||||
import org.mockito.Mockito.verify
|
import org.mockito.Mockito.verify
|
||||||
import org.mockito.MockitoAnnotations
|
import org.mockito.MockitoAnnotations
|
||||||
|
|
||||||
@@ -196,6 +197,16 @@ class QSPanelTest : SysuiTestCase() {
|
|||||||
qsPanel.setSquishinessFraction(0.5f)
|
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 {
|
private infix fun View.isLeftOf(other: View): Boolean {
|
||||||
val rect = Rect()
|
val rect = Rect()
|
||||||
getBoundsOnScreen(rect)
|
getBoundsOnScreen(rect)
|
||||||
|
|||||||
Reference in New Issue
Block a user