Dissmissing AccessibilityMenu through additional means (Screen turning off, back key, touch events elsewhere on the screen).
Bug: 261252772 Test: adb install the app, then enable from Settings Accessibility page. Change-Id: I61e6556c005c3ab429b7e1eca6e40647cb47db4f
This commit is contained in:
@@ -18,11 +18,17 @@ package com.android.systemui.accessibility.accessibilitymenu;
|
||||
|
||||
import android.accessibilityservice.AccessibilityButtonController;
|
||||
import android.accessibilityservice.AccessibilityService;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.Configuration;
|
||||
import android.hardware.display.DisplayManager;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.SystemClock;
|
||||
import android.view.Display;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
@@ -69,7 +75,7 @@ public class AccessibilityMenuService extends AccessibilityService
|
||||
};
|
||||
|
||||
// Update layout.
|
||||
private final Handler mHandler = new Handler(getMainLooper());
|
||||
private final Handler mHandler = new Handler(Looper.getMainLooper());
|
||||
private final Runnable mOnConfigChangedRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -92,11 +98,7 @@ public class AccessibilityMenuService extends AccessibilityService
|
||||
getAccessibilityButtonController().registerAccessibilityButtonCallback(
|
||||
new AccessibilityButtonController.AccessibilityButtonCallback() {
|
||||
/**
|
||||
* Called when the accessibility button in the system's navigation
|
||||
* area is clicked.
|
||||
*
|
||||
* @param controller the controller used to register for this
|
||||
* callback
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void onClicked(AccessibilityButtonController controller) {
|
||||
@@ -107,19 +109,7 @@ public class AccessibilityMenuService extends AccessibilityService
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the availability of the accessibility button in the
|
||||
* system's
|
||||
* navigation area has changed. The accessibility button may become
|
||||
* unavailable
|
||||
* because the device shopped showing the button, the button was
|
||||
* assigned to another
|
||||
* service, or for other reasons.
|
||||
*
|
||||
* @param controller the controller used to register for this
|
||||
* callback
|
||||
* @param available {@code true} if the accessibility button is
|
||||
* available to this
|
||||
* service, {@code false} otherwise
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void onAvailabilityChanged(AccessibilityButtonController controller,
|
||||
@@ -141,8 +131,12 @@ public class AccessibilityMenuService extends AccessibilityService
|
||||
protected void onServiceConnected() {
|
||||
mA11yMenuLayout = new A11yMenuOverlayLayout(this);
|
||||
|
||||
// Temporary measure to force visibility
|
||||
mA11yMenuLayout.toggleVisibility();
|
||||
registerReceiver(new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
mA11yMenuLayout.hideMenu();
|
||||
}}, new IntentFilter(Intent.ACTION_SCREEN_OFF)
|
||||
);
|
||||
|
||||
mDisplayManager = getSystemService(DisplayManager.class);
|
||||
mDisplayManager.registerDisplayListener(mDisplayListener, null);
|
||||
@@ -183,6 +177,14 @@ public class AccessibilityMenuService extends AccessibilityService
|
||||
public void onInterrupt() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onKeyEvent(KeyEvent event) {
|
||||
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
||||
mA11yMenuLayout.hideMenu();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
|
||||
|
||||
Reference in New Issue
Block a user