Bug 802280 - Send Layerview focus change events to js. r=blassey

This commit is contained in:
Eitan Isaacson 2012-10-19 10:06:08 -07:00
parent da0b92f8bf
commit f5d2f18a05
2 changed files with 19 additions and 5 deletions

View File

@ -30,10 +30,11 @@ public class GeckoAccessibility {
private static final int VIRTUAL_CURSOR_POSITION = 2;
private static final int VIRTUAL_CURSOR_NEXT = 3;
private static boolean mEnabled = false;
private static JSONObject mEventMessage = null;
private static AccessibilityNodeInfo mVirtualCursorNode = null;
private static final HashSet<String> ServiceWhitelist =
private static final HashSet<String> sServiceWhitelist =
new HashSet<String>(Arrays.asList(new String[] {
"com.google.android.marvin.talkback.TalkBackService", // Google Talkback screen reader
"com.mot.readout.ScreenReader", // Motorola screen reader
@ -45,7 +46,7 @@ public class GeckoAccessibility {
GeckoAppShell.getHandler().post(new Runnable() {
public void run() {
JSONObject ret = new JSONObject();
boolean enabled = false;
mEnabled = false;
AccessibilityManager accessibilityManager =
(AccessibilityManager) GeckoApp.mAppContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
if (accessibilityManager.isEnabled()) {
@ -54,14 +55,14 @@ public class GeckoAccessibility {
List<RunningServiceInfo> runningServices = activityManager.getRunningServices(Integer.MAX_VALUE);
for (RunningServiceInfo runningServiceInfo : runningServices) {
enabled = ServiceWhitelist.contains(runningServiceInfo.service.getClassName());
if (enabled)
mEnabled = sServiceWhitelist.contains(runningServiceInfo.service.getClassName());
if (mEnabled)
break;
}
}
try {
ret.put("enabled", enabled);
ret.put("enabled", mEnabled);
} catch (Exception ex) {
Log.e(LOGTAG, "Error building JSON arguments for Accessibility:Settings:", ex);
}
@ -185,6 +186,12 @@ public class GeckoAccessibility {
}
}
public static void onLayerViewFocusChanged(LayerView layerview, boolean gainFocus) {
if (mEnabled)
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Accessibility:Focus",
gainFocus ? "true" : "false"));
}
public static class GeckoAccessibilityDelegate extends View.AccessibilityDelegate {
AccessibilityNodeProvider mAccessibilityNodeProvider;

View File

@ -17,6 +17,7 @@ import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.PixelFormat;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.SurfaceTexture;
import android.os.Build;
import android.util.AttributeSet;
@ -404,4 +405,10 @@ public class LayerView extends FrameLayout {
return mLayerClient.getPanZoomController().getOverScrollMode();
return super.getOverScrollMode();
}
@Override
public void onFocusChanged (boolean gainFocus, int direction, Rect previouslyFocusedRect) {
super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
GeckoAccessibility.onLayerViewFocusChanged(this, gainFocus);
}
}