You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
Always use addView() and removeView() implementation from ViewGroup
This makes sure, that the index argument is handled correctly everywhere
This commit is contained in:
@@ -207,22 +207,6 @@ extern "C" {
|
||||
JNIEXPORT jlong JNICALL Java_android_widget_FrameLayout_native_1constructor
|
||||
(JNIEnv *, jobject, jobject, jobject);
|
||||
|
||||
/*
|
||||
* Class: android_widget_FrameLayout
|
||||
* Method: native_addView
|
||||
* Signature: (JJILandroid/view/ViewGroup/LayoutParams;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_android_widget_FrameLayout_native_1addView
|
||||
(JNIEnv *, jobject, jlong, jlong, jint, jobject);
|
||||
|
||||
/*
|
||||
* Class: android_widget_FrameLayout
|
||||
* Method: native_removeView
|
||||
* Signature: (JJ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_android_widget_FrameLayout_native_1removeView
|
||||
(JNIEnv *, jobject, jlong, jlong);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -207,22 +207,6 @@ extern "C" {
|
||||
JNIEXPORT jlong JNICALL Java_android_widget_LinearLayout_native_1constructor
|
||||
(JNIEnv *, jobject, jobject, jobject);
|
||||
|
||||
/*
|
||||
* Class: android_widget_LinearLayout
|
||||
* Method: native_addView
|
||||
* Signature: (JJILandroid/view/ViewGroup/LayoutParams;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_android_widget_LinearLayout_native_1addView
|
||||
(JNIEnv *, jobject, jlong, jlong, jint, jobject);
|
||||
|
||||
/*
|
||||
* Class: android_widget_LinearLayout
|
||||
* Method: native_removeView
|
||||
* Signature: (JJ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_android_widget_LinearLayout_native_1removeView
|
||||
(JNIEnv *, jobject, jlong, jlong);
|
||||
|
||||
/*
|
||||
* Class: android_widget_LinearLayout
|
||||
* Method: setOrientation
|
||||
|
||||
@@ -207,22 +207,6 @@ extern "C" {
|
||||
JNIEXPORT jlong JNICALL Java_android_widget_ScrollView_native_1constructor
|
||||
(JNIEnv *, jobject, jobject, jobject);
|
||||
|
||||
/*
|
||||
* Class: android_widget_ScrollView
|
||||
* Method: native_addView
|
||||
* Signature: (JJILandroid/view/ViewGroup/LayoutParams;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_android_widget_ScrollView_native_1addView
|
||||
(JNIEnv *, jobject, jlong, jlong, jint, jobject);
|
||||
|
||||
/*
|
||||
* Class: android_widget_ScrollView
|
||||
* Method: native_removeView
|
||||
* Signature: (JJ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_android_widget_ScrollView_native_1removeView
|
||||
(JNIEnv *, jobject, jlong, jlong);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -136,10 +136,18 @@ JNIEXPORT void JNICALL Java_android_view_ViewGroup_native_1addView(JNIEnv *env,
|
||||
Java_android_view_View_setGravity(env, child, child_gravity);
|
||||
}*/
|
||||
}
|
||||
gtk_box_append(GTK_BOX(_PTR(widget)), gtk_widget_get_parent(GTK_WIDGET(_PTR(child)))); // FIXME - ignores index argument
|
||||
GtkWidget *parent = _PTR(widget);
|
||||
GtkWidget *iter = gtk_widget_get_first_child(parent);
|
||||
for(int i = 0; i < index; i++) {
|
||||
iter = gtk_widget_get_next_sibling(iter);
|
||||
if(iter == NULL)
|
||||
break;
|
||||
}
|
||||
|
||||
gtk_widget_insert_before(gtk_widget_get_parent(GTK_WIDGET(_PTR(child))), parent, iter);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_android_view_ViewGroup_native_1removeView(JNIEnv *env, jobject this, jlong widget, jlong child)
|
||||
{
|
||||
gtk_box_remove(GTK_BOX(_PTR(widget)), gtk_widget_get_parent(GTK_WIDGET(_PTR(child))));
|
||||
gtk_widget_unparent(gtk_widget_get_parent(GTK_WIDGET(_PTR(child))));
|
||||
}
|
||||
|
||||
@@ -81,15 +81,3 @@ JNIEXPORT jlong JNICALL Java_android_widget_FrameLayout_native_1constructor(JNIE
|
||||
gtk_widget_set_name(GTK_WIDGET(frame_layout), "FrameLayout");
|
||||
return _INTPTR(frame_layout);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_android_widget_FrameLayout_native_1addView(JNIEnv *env, jobject this, jlong widget, jlong child, jint index, jobject layout_params)
|
||||
{
|
||||
if(index >= 0)
|
||||
frame_layout_widget_insert_child_at_index(FRAME_LAYOUT_WIDGET(_PTR(widget)), gtk_widget_get_parent(GTK_WIDGET(_PTR(child))), index);
|
||||
else
|
||||
frame_layout_widget_insert_child(FRAME_LAYOUT_WIDGET(_PTR(widget)), gtk_widget_get_parent(GTK_WIDGET(_PTR(child))));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_android_widget_FrameLayout_native_1removeView(JNIEnv *env, jobject this, jlong widget, jlong child) {
|
||||
gtk_widget_unparent(gtk_widget_get_parent(GTK_WIDGET(_PTR(child))));
|
||||
}
|
||||
|
||||
@@ -43,16 +43,6 @@ JNIEXPORT jlong JNICALL Java_android_widget_LinearLayout_native_1constructor(JNI
|
||||
// g_object_set_data(G_OBJECT(wrapper), "background_ninepatch", ninepatch);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_android_widget_LinearLayout_native_1addView(JNIEnv *env, jobject this, jlong widget, jlong child, jint index, jobject layout_params)
|
||||
{
|
||||
gtk_box_append(GTK_BOX(_PTR(widget)), gtk_widget_get_parent(GTK_WIDGET(_PTR(child)))); // FIXME - ignores index argument
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_android_widget_LinearLayout_native_1removeView(JNIEnv *env, jobject this, jlong widget, jlong child)
|
||||
{
|
||||
gtk_box_remove(GTK_BOX(_PTR(widget)), gtk_widget_get_parent(GTK_WIDGET(_PTR(child))));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_android_widget_LinearLayout_setOrientation(JNIEnv *env, jobject this, jint orientation)
|
||||
{
|
||||
gtk_orientable_set_orientation(GTK_ORIENTABLE(_PTR(_GET_LONG_FIELD(this, "widget"))), orientation ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL);
|
||||
|
||||
@@ -20,16 +20,3 @@ JNIEXPORT jlong JNICALL Java_android_widget_ScrollView_native_1constructor(JNIEn
|
||||
gtk_widget_set_name(GTK_WIDGET(box), "ScrollView");
|
||||
return _INTPTR(box);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_android_widget_ScrollView_native_1removeView(JNIEnv *env, jobject this, jlong widget, jlong child)
|
||||
{
|
||||
GtkWidget *_child = gtk_widget_get_parent(GTK_WIDGET(_PTR(child)));
|
||||
|
||||
gtk_box_remove(GTK_BOX(_PTR(widget)), g_object_ref(_child));
|
||||
g_object_force_floating(G_OBJECT(_child));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_android_widget_ScrollView_native_1addView(JNIEnv *env, jobject this, jlong widget, jlong child, jint index, jobject layout_params)
|
||||
{
|
||||
gtk_box_append(GTK_BOX(_PTR(widget)), gtk_widget_get_parent(GTK_WIDGET(_PTR(child))));
|
||||
}
|
||||
|
||||
@@ -2,9 +2,7 @@ package android.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
|
||||
public class FrameLayout extends ViewGroup {
|
||||
|
||||
@@ -22,10 +20,6 @@ public class FrameLayout extends ViewGroup {
|
||||
|
||||
@Override
|
||||
protected native long native_constructor(Context context, AttributeSet attrs);
|
||||
@Override
|
||||
protected native void native_addView(long widget, long child, int index, ViewGroup.LayoutParams params);
|
||||
@Override
|
||||
protected native void native_removeView(long widget, long child);
|
||||
|
||||
@Override
|
||||
public LayoutParams generateLayoutParams(AttributeSet attrs) {
|
||||
|
||||
@@ -2,7 +2,6 @@ package android.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
public class LinearLayout extends ViewGroup {
|
||||
@@ -19,10 +18,6 @@ public class LinearLayout extends ViewGroup {
|
||||
|
||||
@Override
|
||||
protected native long native_constructor(Context context, AttributeSet attrs);
|
||||
@Override
|
||||
protected native void native_addView(long widget, long child, int index, ViewGroup.LayoutParams params);
|
||||
@Override
|
||||
protected native void native_removeView(long widget, long child);
|
||||
|
||||
public native void setOrientation(int orientation);
|
||||
public void setWeightSum(float weightSum) {}
|
||||
|
||||
@@ -2,9 +2,7 @@ package android.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
|
||||
public class ScrollView extends ViewGroup {
|
||||
public ScrollView(Context context, AttributeSet attrs) {
|
||||
@@ -17,10 +15,6 @@ public class ScrollView extends ViewGroup {
|
||||
|
||||
@Override
|
||||
protected native long native_constructor(Context context, AttributeSet attrs);
|
||||
@Override
|
||||
protected native void native_addView(long widget, long child, int index, ViewGroup.LayoutParams params);
|
||||
@Override
|
||||
protected native void native_removeView(long widget, long child);
|
||||
|
||||
public void setFillViewport(boolean fillViewport) {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user