Bug 729237 - Fixed AndroidBridge emit a11y event function, added java string class as class member. r=blassey

This commit is contained in:
Eitan Isaacson 2012-02-25 20:38:27 -05:00
Родитель 6f7e29375a
Коммит 645a4c2ff6
3 изменённых файлов: 24 добавлений и 17 удалений

Просмотреть файл

@ -1871,7 +1871,7 @@ public class GeckoAppShell
return false;
}
public static void emitGeckoAccessibilityEvent (int eventType, String role, String text, String description, boolean enabled, boolean checked, boolean password) {
public static void emitGeckoAccessibilityEvent (int eventType, String[] textList, String description, boolean enabled, boolean checked, boolean password) {
AccessibilityManager accessibilityManager =
(AccessibilityManager) GeckoApp.mAppContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
@ -1882,13 +1882,14 @@ public class GeckoAppShell
LayerView layerView = layerController.getView();
AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
event.setClassName(layerView.getClass().getName() + "$" + role);
event.setClassName(layerView.getClass().getName());
event.setPackageName(GeckoApp.mAppContext.getPackageName());
event.setEnabled(enabled);
event.setChecked(checked);
event.setPassword(password);
event.setContentDescription(description);
event.getText().add(text);
for (String text: textList)
event.getText().add(text);
accessibilityManager.sendAccessibilityEvent(event);
}

Просмотреть файл

@ -178,6 +178,7 @@ AndroidBridge::Init(JNIEnv *jEnv,
jGetCurrentNetworkInformation = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getCurrentNetworkInformation", "()[D");
jEnableNetworkNotifications = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "enableNetworkNotifications", "()V");
jDisableNetworkNotifications = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "disableNetworkNotifications", "()V");
jEmitGeckoAccessibilityEvent = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "emitGeckoAccessibilityEvent", "(I[Ljava/lang/String;Ljava/lang/String;ZZZ)V");
jEGLContextClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("javax/microedition/khronos/egl/EGLContext"));
jEGL10Class = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("javax/microedition/khronos/egl/EGL10"));
@ -186,6 +187,8 @@ AndroidBridge::Init(JNIEnv *jEnv,
jEGLConfigImplClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("com/google/android/gles_jni/EGLConfigImpl"));
jEGLDisplayImplClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("com/google/android/gles_jni/EGLDisplayImpl"));
jStringClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("java/lang/String"));
InitAndroidJavaWrappers(jEnv);
// jEnv should NOT be cached here by anything -- the jEnv here
@ -1487,17 +1490,17 @@ AndroidBridge::MarkURIVisited(const nsAString& aURI)
env->CallStaticVoidMethod(mGeckoAppShellClass, jMarkUriVisited, jstrURI);
}
void AndroidBridge::EmitGeckoAccessibilityEvent (PRInt32 eventType, const nsAString& role, const nsAString& text, const nsAString& description, bool enabled, bool checked, bool password) {
JNIEnv *env = GetJNIEnv();
if (!env)
return;
AutoLocalJNIFrame jniFrame(env);
jstring jstrRole = env->NewString(nsPromiseFlatString(role).get(), role.Length());
jstring jstrText = env->NewString(nsPromiseFlatString(text).get(), text.Length());
jstring jstrDescription = env->NewString(nsPromiseFlatString(description).get(), description.Length());
env->CallStaticVoidMethod(mGeckoAppShellClass, jEmitGeckoAccessibilityEvent, eventType, jstrRole, jstrText, jstrDescription, enabled, checked, password);
void AndroidBridge::EmitGeckoAccessibilityEvent (PRInt32 eventType, const nsTArray<nsString>& text, const nsAString& description, bool enabled, bool checked, bool password) {
AutoLocalJNIFrame jniFrame;
jobjectArray jarrayText = mJNIEnv->NewObjectArray(text.Length(),
jStringClass, 0);
for (PRUint32 i = 0; i < text.Length() ; i++) {
jstring jstrText = mJNIEnv->NewString(nsPromiseFlatString(text[i]).get(),
text[i].Length());
mJNIEnv->SetObjectArrayElement(jarrayText, i, jstrText);
}
jstring jstrDescription = mJNIEnv->NewString(nsPromiseFlatString(description).get(), description.Length());
mJNIEnv->CallStaticVoidMethod(mGeckoAppShellClass, jEmitGeckoAccessibilityEvent, eventType, jarrayText, jstrDescription, enabled, checked, password);
}
PRUint16
@ -1584,8 +1587,8 @@ AndroidBridge::CreateMessageList(const dom::sms::SmsFilterData& aFilter, bool aR
jobjectArray numbers =
(jobjectArray)env->NewObjectArray(aFilter.numbers().Length(),
env->FindClass("java/lang/String"),
env->NewStringUTF(""));
jStringClass,
env->NewStringUTF(""));
for (PRUint32 i = 0; i < aFilter.numbers().Length(); ++i) {
env->SetObjectArrayElement(numbers, i,

Просмотреть файл

@ -357,7 +357,7 @@ public:
nsCOMPtr<nsIAndroidDrawMetadataProvider> GetDrawMetadataProvider();
void EmitGeckoAccessibilityEvent (PRInt32 eventType, const nsAString& role, const nsAString& text, const nsAString& description, bool enabled, bool checked, bool password);
void EmitGeckoAccessibilityEvent (PRInt32 eventType, const nsTArray<nsString>& text, const nsAString& description, bool enabled, bool checked, bool password);
void CheckURIVisited(const nsAString& uri);
void MarkURIVisited(const nsAString& uri);
@ -498,6 +498,9 @@ protected:
jclass jEGLContextClass;
jclass jEGL10Class;
// some convinient types to have around
jclass jStringClass;
// calls we've dlopened from libjnigraphics.so
int (* AndroidBitmap_getInfo)(JNIEnv *env, jobject bitmap, void *info);
int (* AndroidBitmap_lockPixels)(JNIEnv *env, jobject bitmap, void **buffer);