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
remove View.haveComplexMeasure as it is redundant with haveCustomMeasure
Makes haveCustomMeasure true by default. And disable it for widgets which previously set haveComplexMeasure
This commit is contained in:
@@ -258,10 +258,10 @@ JNIEXPORT void JNICALL Java_android_view_View_native_1destructor
|
|||||||
/*
|
/*
|
||||||
* Class: android_view_View
|
* Class: android_view_View
|
||||||
* Method: native_measure
|
* Method: native_measure
|
||||||
* Signature: (JIIZ)V
|
* Signature: (JII)V
|
||||||
*/
|
*/
|
||||||
JNIEXPORT void JNICALL Java_android_view_View_native_1measure
|
JNIEXPORT void JNICALL Java_android_view_View_native_1measure
|
||||||
(JNIEnv *, jobject, jlong, jint, jint, jboolean);
|
(JNIEnv *, jobject, jlong, jint, jint);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: android_view_View
|
* Class: android_view_View
|
||||||
|
|||||||
@@ -347,7 +347,6 @@ JNIEXPORT jlong JNICALL Java_android_view_View_native_1constructor(JNIEnv *env,
|
|||||||
jmethodID layout_method = _METHOD(class, "onLayout", "(ZIIII)V");
|
jmethodID layout_method = _METHOD(class, "onLayout", "(ZIIII)V");
|
||||||
if (measure_method != handle_cache.view.onMeasure || layout_method != handle_cache.view.onLayout) {
|
if (measure_method != handle_cache.view.onMeasure || layout_method != handle_cache.view.onLayout) {
|
||||||
gtk_widget_set_layout_manager(widget, android_layout_new(_REF(this)));
|
gtk_widget_set_layout_manager(widget, android_layout_new(_REF(this)));
|
||||||
(*env)->SetBooleanField(env, this, _FIELD_ID(class, "haveCustomMeasure", "Z"), true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_METHOD(_CLASS(this), "onGenericMotionEvent", "(Landroid/view/MotionEvent;)Z") != handle_cache.view.onGenericMotionEvent) {
|
if (_METHOD(_CLASS(this), "onGenericMotionEvent", "(Landroid/view/MotionEvent;)Z") != handle_cache.view.onGenericMotionEvent) {
|
||||||
@@ -376,7 +375,7 @@ JNIEXPORT void JNICALL Java_android_view_View_native_1destructor(JNIEnv *env, jo
|
|||||||
#define MEASURE_SPEC_AT_MOST (2 << 30)
|
#define MEASURE_SPEC_AT_MOST (2 << 30)
|
||||||
#define MEASURE_SPEC_MASK (0x3 << 30)
|
#define MEASURE_SPEC_MASK (0x3 << 30)
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_android_view_View_native_1measure(JNIEnv *env, jobject this, jlong widget_ptr, jint width_spec, jint height_spec, jboolean is_complex) {
|
JNIEXPORT void JNICALL Java_android_view_View_native_1measure(JNIEnv *env, jobject this, jlong widget_ptr, jint width_spec, jint height_spec) {
|
||||||
int width = -1;
|
int width = -1;
|
||||||
int height = -1;
|
int height = -1;
|
||||||
GtkWidget *widget = gtk_widget_get_parent(GTK_WIDGET(_PTR(widget_ptr)));
|
GtkWidget *widget = gtk_widget_get_parent(GTK_WIDGET(_PTR(widget_ptr)));
|
||||||
@@ -386,11 +385,11 @@ JNIEXPORT void JNICALL Java_android_view_View_native_1measure(JNIEnv *env, jobje
|
|||||||
int height_spec_mode = height_spec & MEASURE_SPEC_MASK;
|
int height_spec_mode = height_spec & MEASURE_SPEC_MASK;
|
||||||
GtkSizeRequestMode request_mode;
|
GtkSizeRequestMode request_mode;
|
||||||
|
|
||||||
if (width_spec_mode == MEASURE_SPEC_EXACTLY || (!is_complex && width_spec_mode == MEASURE_SPEC_AT_MOST)) {
|
if (width_spec_mode == MEASURE_SPEC_EXACTLY) {
|
||||||
width = width_spec_size;
|
width = width_spec_size;
|
||||||
request_mode = GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
|
request_mode = GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
|
||||||
}
|
}
|
||||||
if (height_spec_mode == MEASURE_SPEC_EXACTLY || (!is_complex && height_spec_mode == MEASURE_SPEC_AT_MOST)) {
|
if (height_spec_mode == MEASURE_SPEC_EXACTLY) {
|
||||||
height = height_spec_size;
|
height = height_spec_size;
|
||||||
request_mode = GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT;
|
request_mode = GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ JNIEXPORT jlong JNICALL Java_android_widget_ScrollView_native_1constructor(JNIEn
|
|||||||
GtkWidget *scrolled_window = gtk_scrolled_window_new();
|
GtkWidget *scrolled_window = gtk_scrolled_window_new();
|
||||||
wrapper_widget_set_child(WRAPPER_WIDGET(wrapper), scrolled_window);
|
wrapper_widget_set_child(WRAPPER_WIDGET(wrapper), scrolled_window);
|
||||||
gtk_widget_set_name(scrolled_window, "ScrollView");
|
gtk_widget_set_name(scrolled_window, "ScrollView");
|
||||||
(*env)->SetBooleanField(env, this, _FIELD_ID(_CLASS(this), "haveCustomMeasure", "Z"), true);
|
|
||||||
return _INTPTR(scrolled_window);
|
return _INTPTR(scrolled_window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -813,8 +813,7 @@ public class View extends Object {
|
|||||||
private boolean layoutRequested = true;
|
private boolean layoutRequested = true;
|
||||||
private int oldWidth;
|
private int oldWidth;
|
||||||
private int oldHeight;
|
private int oldHeight;
|
||||||
private boolean haveCustomMeasure;
|
protected boolean haveCustomMeasure = true;
|
||||||
protected boolean haveComplexMeasure = false;
|
|
||||||
|
|
||||||
private int visibility = View.VISIBLE;
|
private int visibility = View.VISIBLE;
|
||||||
private float alpha = 1.0f;
|
private float alpha = 1.0f;
|
||||||
@@ -936,7 +935,7 @@ public class View extends Object {
|
|||||||
* We decide between simple widgets which handles MEASURE_SPEC_AT_MOST the same way as
|
* We decide between simple widgets which handles MEASURE_SPEC_AT_MOST the same way as
|
||||||
* MEASURE_SPEC_EXACTLY, and complex widgets which handles MEASURE_SPEC_AT_MOST by measuring the content
|
* MEASURE_SPEC_EXACTLY, and complex widgets which handles MEASURE_SPEC_AT_MOST by measuring the content
|
||||||
*/
|
*/
|
||||||
protected native void native_measure(long widget, int widthMeasureSpec, int heightMeasureSpec, boolean isComplex);
|
protected native void native_measure(long widget, int widthMeasureSpec, int heightMeasureSpec);
|
||||||
protected native void native_layout(long widget, int l, int t, int r, int b);
|
protected native void native_layout(long widget, int l, int t, int r, int b);
|
||||||
protected native void native_requestLayout(long widget);
|
protected native void native_requestLayout(long widget);
|
||||||
protected native void native_setBackgroundDrawable(long widget, long paintable);
|
protected native void native_setBackgroundDrawable(long widget, long paintable);
|
||||||
@@ -976,7 +975,7 @@ public class View extends Object {
|
|||||||
if (haveCustomMeasure) // calling native_measure here would create infinite loop
|
if (haveCustomMeasure) // calling native_measure here would create infinite loop
|
||||||
setMeasuredDimension(getDefaultSize(getSuggestedMinimumWidth(), widthMeasureSpec), getDefaultSize(getSuggestedMinimumHeight(), heightMeasureSpec));
|
setMeasuredDimension(getDefaultSize(getSuggestedMinimumWidth(), widthMeasureSpec), getDefaultSize(getSuggestedMinimumHeight(), heightMeasureSpec));
|
||||||
else
|
else
|
||||||
native_measure(widget, widthMeasureSpec, heightMeasureSpec, haveComplexMeasure);
|
native_measure(widget, widthMeasureSpec, heightMeasureSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPressed(boolean pressed) {
|
public void setPressed(boolean pressed) {
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ public class ViewGroup extends View implements ViewParent, ViewManager {
|
|||||||
super(context, attrs, defStyleAttr);
|
super(context, attrs, defStyleAttr);
|
||||||
|
|
||||||
children = new ArrayList<View>();
|
children = new ArrayList<View>();
|
||||||
haveComplexMeasure = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addView(View child) {
|
public void addView(View child) {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class ImageView extends View {
|
|||||||
public ImageView(Context context, AttributeSet attrs, int defStyleAttr) {
|
public ImageView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
super(context, attrs, defStyleAttr);
|
super(context, attrs, defStyleAttr);
|
||||||
|
|
||||||
haveComplexMeasure = true;
|
haveCustomMeasure = false;
|
||||||
if (attrs != null) {
|
if (attrs != null) {
|
||||||
int resid = attrs.getAttributeResourceValue("http://schemas.android.com/apk/res/android", "src", 0);
|
int resid = attrs.getAttributeResourceValue("http://schemas.android.com/apk/res/android", "src", 0);
|
||||||
if (resid != 0 && !getResources().getString(resid).endsWith(".xml")) {
|
if (resid != 0 && !getResources().getString(resid).endsWith(".xml")) {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class ProgressBar extends View {
|
|||||||
|
|
||||||
public ProgressBar(Context context, AttributeSet attrs, int defStyle) {
|
public ProgressBar(Context context, AttributeSet attrs, int defStyle) {
|
||||||
super(context, attrs, defStyle);
|
super(context, attrs, defStyle);
|
||||||
haveComplexMeasure = true;
|
haveCustomMeasure = false;
|
||||||
TypedArray a = context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.ProgressBar, defStyle, 0);
|
TypedArray a = context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.ProgressBar, defStyle, 0);
|
||||||
setIndeterminate(a.getBoolean(com.android.internal.R.styleable.ProgressBar_indeterminate, false));
|
setIndeterminate(a.getBoolean(com.android.internal.R.styleable.ProgressBar_indeterminate, false));
|
||||||
a.recycle();
|
a.recycle();
|
||||||
|
|||||||
@@ -8,12 +8,12 @@ public class Space extends View {
|
|||||||
|
|
||||||
public Space(Context context) {
|
public Space(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
haveComplexMeasure = true;
|
haveCustomMeasure = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Space(Context context, AttributeSet attributeSet) {
|
public Space(Context context, AttributeSet attributeSet) {
|
||||||
super(context, attributeSet);
|
super(context, attributeSet);
|
||||||
haveComplexMeasure = true;
|
haveCustomMeasure = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -60,7 +60,7 @@ public class TextView extends View {
|
|||||||
}
|
}
|
||||||
} catch(java.lang.Exception e) { System.out.println("exception while inflating TextView:"); e.printStackTrace(); }
|
} catch(java.lang.Exception e) { System.out.println("exception while inflating TextView:"); e.printStackTrace(); }
|
||||||
a.recycle();
|
a.recycle();
|
||||||
haveComplexMeasure = true;
|
haveCustomMeasure = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user