mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-04-28 12:17:57 +03:00
View: implement requestFocus() and isFocused()
This commit is contained in:
parent
d0952101a6
commit
fe7790c4ff
3 changed files with 38 additions and 2 deletions
|
@ -343,6 +343,14 @@ JNIEXPORT void JNICALL Java_android_view_View_native_1drawBackground
|
|||
JNIEXPORT void JNICALL Java_android_view_View_native_1drawContent
|
||||
(JNIEnv *, jobject, jlong, jlong);
|
||||
|
||||
/*
|
||||
* Class: android_view_View
|
||||
* Method: nativeRequestFocus
|
||||
* Signature: (JI)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_android_view_View_nativeRequestFocus
|
||||
(JNIEnv *, jobject, jlong, jint);
|
||||
|
||||
/*
|
||||
* Class: android_view_View
|
||||
* Method: nativeSetFullscreen
|
||||
|
@ -391,6 +399,14 @@ JNIEXPORT void JNICALL Java_android_view_View_native_1setPadding
|
|||
JNIEXPORT void JNICALL Java_android_view_View_nativeSetOnLongClickListener
|
||||
(JNIEnv *, jobject, jlong);
|
||||
|
||||
/*
|
||||
* Class: android_view_View
|
||||
* Method: nativeIsFocused
|
||||
* Signature: (J)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_android_view_View_nativeIsFocused
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: android_view_View
|
||||
* Method: native_getMatrix
|
||||
|
|
|
@ -665,4 +665,19 @@ JNIEXPORT void JNICALL Java_android_view_View_native_1removeClasses(JNIEnv *env,
|
|||
|
||||
(*env)->ReleaseStringUTFChars(env, class_name_jstr, class_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_android_view_View_nativeRequestFocus(JNIEnv *env, jobject this, jlong widget_ptr, jint direction) {
|
||||
GtkWidget *widget = GTK_WIDGET(_PTR(widget_ptr));
|
||||
GtkWidget *wrapper = gtk_widget_get_parent(widget);
|
||||
if (gtk_widget_get_focusable(widget))
|
||||
gtk_widget_grab_focus(widget);
|
||||
else
|
||||
gtk_widget_grab_focus(wrapper);
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_android_view_View_nativeIsFocused(JNIEnv *env, jobject this, jlong widget_ptr) {
|
||||
GtkWidget *widget = GTK_WIDGET(_PTR(widget_ptr));
|
||||
GtkWidget *wrapper = gtk_widget_get_parent(widget);
|
||||
return gtk_widget_has_focus(widget) || gtk_widget_has_focus(wrapper);
|
||||
}
|
||||
|
|
|
@ -1128,8 +1128,10 @@ public class View implements Drawable.Callback {
|
|||
return requestFocus(direction, null);
|
||||
}
|
||||
public boolean requestFocus(int direction, Rect previouslyFocusedRect) {
|
||||
nativeRequestFocus(widget, direction);
|
||||
return true;
|
||||
}
|
||||
private native void nativeRequestFocus(long widget, int direction);
|
||||
|
||||
private native void nativeSetFullscreen(long widget, boolean fullscreen);
|
||||
|
||||
|
@ -1596,7 +1598,10 @@ public class View implements Drawable.Callback {
|
|||
public boolean isLayoutRequested() {return layoutRequested;}
|
||||
public int getBaseline() {return -1;}
|
||||
public boolean hasFocusable() {return false;}
|
||||
public boolean isFocused() {return false;}
|
||||
private static native boolean nativeIsFocused(long widget);
|
||||
public boolean isFocused() {
|
||||
return nativeIsFocused(widget);
|
||||
}
|
||||
|
||||
public void clearAnimation() {}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue