Merge "Separating the UI logic for SettingsPanel and ModeSwitchButton" into udc-dev am: 1c02715ebc
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23078796 Change-Id: I05d55367a3055297e7f16a0e41691350c1a638e3 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -203,19 +203,27 @@ public class MagnificationController implements WindowMagnificationManager.Callb
|
|||||||
|
|
||||||
private void updateMagnificationUIControls(int displayId, int mode) {
|
private void updateMagnificationUIControls(int displayId, int mode) {
|
||||||
final boolean isActivated = isActivated(displayId, mode);
|
final boolean isActivated = isActivated(displayId, mode);
|
||||||
final boolean showUIControls;
|
final boolean showModeSwitchButton;
|
||||||
|
final boolean enableSettingsPanel;
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
showUIControls = isActivated && mMagnificationCapabilities
|
showModeSwitchButton = isActivated
|
||||||
== Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_ALL;
|
&& mMagnificationCapabilities == ACCESSIBILITY_MAGNIFICATION_MODE_ALL;
|
||||||
|
enableSettingsPanel = isActivated
|
||||||
|
&& (mMagnificationCapabilities == ACCESSIBILITY_MAGNIFICATION_MODE_ALL
|
||||||
|
|| mMagnificationCapabilities == ACCESSIBILITY_MAGNIFICATION_MODE_WINDOW);
|
||||||
}
|
}
|
||||||
if (showUIControls) {
|
|
||||||
// we only need to show magnification button, the settings panel showing should be
|
if (showModeSwitchButton) {
|
||||||
// triggered only on sysui side.
|
|
||||||
getWindowMagnificationMgr().showMagnificationButton(displayId, mode);
|
getWindowMagnificationMgr().showMagnificationButton(displayId, mode);
|
||||||
} else {
|
} else {
|
||||||
getWindowMagnificationMgr().removeMagnificationSettingsPanel(displayId);
|
|
||||||
getWindowMagnificationMgr().removeMagnificationButton(displayId);
|
getWindowMagnificationMgr().removeMagnificationButton(displayId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!enableSettingsPanel) {
|
||||||
|
// Whether the settings panel needs to be shown is controlled in system UI.
|
||||||
|
// Here, we only guarantee that the settings panel is closed when it is not needed.
|
||||||
|
getWindowMagnificationMgr().removeMagnificationSettingsPanel(displayId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns {@code true} if the platform supports window magnification feature. */
|
/** Returns {@code true} if the platform supports window magnification feature. */
|
||||||
|
|||||||
@@ -593,6 +593,10 @@ public class MagnificationControllerTest {
|
|||||||
// The second time is triggered when magnification spec is changed.
|
// The second time is triggered when magnification spec is changed.
|
||||||
verify(mWindowMagnificationManager, times(2)).showMagnificationButton(eq(TEST_DISPLAY),
|
verify(mWindowMagnificationManager, times(2)).showMagnificationButton(eq(TEST_DISPLAY),
|
||||||
eq(MODE_FULLSCREEN));
|
eq(MODE_FULLSCREEN));
|
||||||
|
// Never call removeMagnificationSettingsPanel if it is allowed to show the settings panel
|
||||||
|
// in current capability and mode, and the magnification is activated.
|
||||||
|
verify(mWindowMagnificationManager, never()).removeMagnificationSettingsPanel(
|
||||||
|
eq(TEST_DISPLAY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -758,6 +762,10 @@ public class MagnificationControllerTest {
|
|||||||
// The second time is triggered when accessibility action performed.
|
// The second time is triggered when accessibility action performed.
|
||||||
verify(mWindowMagnificationManager, times(2)).showMagnificationButton(eq(TEST_DISPLAY),
|
verify(mWindowMagnificationManager, times(2)).showMagnificationButton(eq(TEST_DISPLAY),
|
||||||
eq(MODE_WINDOW));
|
eq(MODE_WINDOW));
|
||||||
|
// Never call removeMagnificationSettingsPanel if it is allowed to show the settings panel
|
||||||
|
// in current capability and mode, and the magnification is activated.
|
||||||
|
verify(mWindowMagnificationManager, never()).removeMagnificationSettingsPanel(
|
||||||
|
eq(TEST_DISPLAY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -772,6 +780,10 @@ public class MagnificationControllerTest {
|
|||||||
// The first time is triggered when window mode is activated.
|
// The first time is triggered when window mode is activated.
|
||||||
// The second time is triggered when accessibility action performed.
|
// The second time is triggered when accessibility action performed.
|
||||||
verify(mWindowMagnificationManager, times(2)).removeMagnificationButton(eq(TEST_DISPLAY));
|
verify(mWindowMagnificationManager, times(2)).removeMagnificationButton(eq(TEST_DISPLAY));
|
||||||
|
// Never call removeMagnificationSettingsPanel if it is allowed to show the settings panel
|
||||||
|
// in current capability and mode, and the magnification is activated.
|
||||||
|
verify(mWindowMagnificationManager, never()).removeMagnificationSettingsPanel(
|
||||||
|
eq(TEST_DISPLAY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void activateWindowMagnification_triggerCallback() throws RemoteException {
|
@Test public void activateWindowMagnification_triggerCallback() throws RemoteException {
|
||||||
@@ -952,6 +964,10 @@ public class MagnificationControllerTest {
|
|||||||
// The third time is triggered when user interaction changed.
|
// The third time is triggered when user interaction changed.
|
||||||
verify(mWindowMagnificationManager, times(3)).showMagnificationButton(eq(TEST_DISPLAY),
|
verify(mWindowMagnificationManager, times(3)).showMagnificationButton(eq(TEST_DISPLAY),
|
||||||
eq(MODE_FULLSCREEN));
|
eq(MODE_FULLSCREEN));
|
||||||
|
// Never call removeMagnificationSettingsPanel if it is allowed to show the settings panel
|
||||||
|
// in current capability and mode, and the magnification is activated.
|
||||||
|
verify(mWindowMagnificationManager, never()).removeMagnificationSettingsPanel(
|
||||||
|
eq(TEST_DISPLAY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -966,6 +982,10 @@ public class MagnificationControllerTest {
|
|||||||
// The third time is triggered when user interaction changed.
|
// The third time is triggered when user interaction changed.
|
||||||
verify(mWindowMagnificationManager, times(3)).showMagnificationButton(eq(TEST_DISPLAY),
|
verify(mWindowMagnificationManager, times(3)).showMagnificationButton(eq(TEST_DISPLAY),
|
||||||
eq(MODE_FULLSCREEN));
|
eq(MODE_FULLSCREEN));
|
||||||
|
// Never call removeMagnificationSettingsPanel if it is allowed to show the settings panel
|
||||||
|
// in current capability and mode, and the magnification is activated.
|
||||||
|
verify(mWindowMagnificationManager, never()).removeMagnificationSettingsPanel(
|
||||||
|
eq(TEST_DISPLAY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -979,6 +999,10 @@ public class MagnificationControllerTest {
|
|||||||
// The second time is triggered when user interaction changed.
|
// The second time is triggered when user interaction changed.
|
||||||
verify(mWindowMagnificationManager, times(2)).showMagnificationButton(eq(TEST_DISPLAY),
|
verify(mWindowMagnificationManager, times(2)).showMagnificationButton(eq(TEST_DISPLAY),
|
||||||
eq(MODE_WINDOW));
|
eq(MODE_WINDOW));
|
||||||
|
// Never call removeMagnificationSettingsPanel if it is allowed to show the settings panel
|
||||||
|
// in current capability and mode, and the magnification is activated.
|
||||||
|
verify(mWindowMagnificationManager, never()).removeMagnificationSettingsPanel(
|
||||||
|
eq(TEST_DISPLAY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -992,6 +1016,10 @@ public class MagnificationControllerTest {
|
|||||||
// The second time is triggered when user interaction changed.
|
// The second time is triggered when user interaction changed.
|
||||||
verify(mWindowMagnificationManager, times(2)).showMagnificationButton(eq(TEST_DISPLAY),
|
verify(mWindowMagnificationManager, times(2)).showMagnificationButton(eq(TEST_DISPLAY),
|
||||||
eq(MODE_WINDOW));
|
eq(MODE_WINDOW));
|
||||||
|
// Never call removeMagnificationSettingsPanel if it is allowed to show the settings panel
|
||||||
|
// in current capability and mode, and the magnification is activated.
|
||||||
|
verify(mWindowMagnificationManager, never()).removeMagnificationSettingsPanel(
|
||||||
|
eq(TEST_DISPLAY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -1006,11 +1034,16 @@ public class MagnificationControllerTest {
|
|||||||
|
|
||||||
verify(mWindowMagnificationManager, never()).showMagnificationButton(eq(TEST_DISPLAY),
|
verify(mWindowMagnificationManager, never()).showMagnificationButton(eq(TEST_DISPLAY),
|
||||||
eq(MODE_FULLSCREEN));
|
eq(MODE_FULLSCREEN));
|
||||||
|
// The first time is triggered when fullscreen mode is activated.
|
||||||
|
// The second time is triggered when magnification spec is changed.
|
||||||
|
verify(mWindowMagnificationManager, times(2)).removeMagnificationSettingsPanel(
|
||||||
|
eq(TEST_DISPLAY));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onTouchInteractionChanged_fullscreenNotActivated_notShowMagnificationButton()
|
public void
|
||||||
|
onTouchInteractionChanged_fullscreenNotActivated_notShowMagnificationButton()
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
setMagnificationModeSettings(MODE_FULLSCREEN);
|
setMagnificationModeSettings(MODE_FULLSCREEN);
|
||||||
|
|
||||||
@@ -1019,6 +1052,8 @@ public class MagnificationControllerTest {
|
|||||||
|
|
||||||
verify(mWindowMagnificationManager, never()).showMagnificationButton(eq(TEST_DISPLAY),
|
verify(mWindowMagnificationManager, never()).showMagnificationButton(eq(TEST_DISPLAY),
|
||||||
eq(MODE_FULLSCREEN));
|
eq(MODE_FULLSCREEN));
|
||||||
|
verify(mWindowMagnificationManager, times(2)).removeMagnificationSettingsPanel(
|
||||||
|
eq(TEST_DISPLAY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -1028,6 +1063,10 @@ public class MagnificationControllerTest {
|
|||||||
|
|
||||||
verify(mWindowMagnificationManager).showMagnificationButton(eq(TEST_DISPLAY),
|
verify(mWindowMagnificationManager).showMagnificationButton(eq(TEST_DISPLAY),
|
||||||
eq(MODE_WINDOW));
|
eq(MODE_WINDOW));
|
||||||
|
// Never call removeMagnificationSettingsPanel if it is allowed to show the settings panel
|
||||||
|
// in current capability and mode, and the magnification is activated.
|
||||||
|
verify(mWindowMagnificationManager, never()).removeMagnificationSettingsPanel(
|
||||||
|
eq(TEST_DISPLAY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -1042,25 +1081,32 @@ public class MagnificationControllerTest {
|
|||||||
// The third time is triggered when fullscreen mode activation state is updated.
|
// The third time is triggered when fullscreen mode activation state is updated.
|
||||||
verify(mWindowMagnificationManager, times(3)).showMagnificationButton(eq(TEST_DISPLAY),
|
verify(mWindowMagnificationManager, times(3)).showMagnificationButton(eq(TEST_DISPLAY),
|
||||||
eq(MODE_FULLSCREEN));
|
eq(MODE_FULLSCREEN));
|
||||||
|
// Never call removeMagnificationSettingsPanel if it is allowed to show the settings panel
|
||||||
|
// in current capability and mode, and the magnification is activated.
|
||||||
|
verify(mWindowMagnificationManager, never()).removeMagnificationSettingsPanel(
|
||||||
|
eq(TEST_DISPLAY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void disableWindowMode_windowEnabled_removeMagnificationButton()
|
public void disableWindowMode_windowEnabled_removeMagnificationButtonAndSettingsPanel()
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
setMagnificationEnabled(MODE_WINDOW);
|
setMagnificationEnabled(MODE_WINDOW);
|
||||||
|
|
||||||
mWindowMagnificationManager.disableWindowMagnification(TEST_DISPLAY, false);
|
mWindowMagnificationManager.disableWindowMagnification(TEST_DISPLAY, false);
|
||||||
|
|
||||||
verify(mWindowMagnificationManager).removeMagnificationButton(eq(TEST_DISPLAY));
|
verify(mWindowMagnificationManager).removeMagnificationButton(eq(TEST_DISPLAY));
|
||||||
|
verify(mWindowMagnificationManager).removeMagnificationSettingsPanel(eq(TEST_DISPLAY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onFullScreenDeactivated_fullScreenEnabled_removeMagnificationButton()
|
public void
|
||||||
|
onFullScreenDeactivated_fullScreenEnabled_removeMagnificationButtonAneSettingsPanel()
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
setMagnificationEnabled(MODE_FULLSCREEN);
|
setMagnificationEnabled(MODE_FULLSCREEN);
|
||||||
mScreenMagnificationController.reset(TEST_DISPLAY, /* animate= */ true);
|
mScreenMagnificationController.reset(TEST_DISPLAY, /* animate= */ true);
|
||||||
|
|
||||||
verify(mWindowMagnificationManager).removeMagnificationButton(eq(TEST_DISPLAY));
|
verify(mWindowMagnificationManager).removeMagnificationButton(eq(TEST_DISPLAY));
|
||||||
|
verify(mWindowMagnificationManager).removeMagnificationSettingsPanel(eq(TEST_DISPLAY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -1077,6 +1123,8 @@ public class MagnificationControllerTest {
|
|||||||
// The third time is triggered when the disable-magnification callback is triggered.
|
// The third time is triggered when the disable-magnification callback is triggered.
|
||||||
verify(mWindowMagnificationManager, times(3)).showMagnificationButton(eq(TEST_DISPLAY),
|
verify(mWindowMagnificationManager, times(3)).showMagnificationButton(eq(TEST_DISPLAY),
|
||||||
eq(MODE_FULLSCREEN));
|
eq(MODE_FULLSCREEN));
|
||||||
|
// It is triggered when the disable-magnification callback is triggered.
|
||||||
|
verify(mWindowMagnificationManager).removeMagnificationSettingsPanel(eq(TEST_DISPLAY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -1096,6 +1144,8 @@ public class MagnificationControllerTest {
|
|||||||
// The second time is triggered when the disable-magnification callback is triggered.
|
// The second time is triggered when the disable-magnification callback is triggered.
|
||||||
verify(mWindowMagnificationManager, times(2)).showMagnificationButton(eq(TEST_DISPLAY),
|
verify(mWindowMagnificationManager, times(2)).showMagnificationButton(eq(TEST_DISPLAY),
|
||||||
eq(MODE_WINDOW));
|
eq(MODE_WINDOW));
|
||||||
|
// It is triggered when the disable-magnification callback is triggered.
|
||||||
|
verify(mWindowMagnificationManager).removeMagnificationSettingsPanel(eq(TEST_DISPLAY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user