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
android/view/View: naive implementation for setBackgroundColor
This commit is contained in:
@@ -287,6 +287,14 @@ JNIEXPORT void JNICALL Java_android_view_View_native_1requestLayout
|
|||||||
JNIEXPORT void JNICALL Java_android_view_View_nativeInvalidate
|
JNIEXPORT void JNICALL Java_android_view_View_nativeInvalidate
|
||||||
(JNIEnv *, jclass, jlong);
|
(JNIEnv *, jclass, jlong);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: android_view_View
|
||||||
|
* Method: setBackgroundColor
|
||||||
|
* Signature: (I)V
|
||||||
|
*/
|
||||||
|
JNIEXPORT void JNICALL Java_android_view_View_setBackgroundColor
|
||||||
|
(JNIEnv *, jobject, jint);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: android_view_View
|
* Class: android_view_View
|
||||||
* Method: setVisibility
|
* Method: setVisibility
|
||||||
|
|||||||
@@ -321,3 +321,17 @@ JNIEXPORT void JNICALL Java_android_view_View_native_1requestLayout(JNIEnv *env,
|
|||||||
|
|
||||||
gtk_widget_queue_resize(widget);
|
gtk_widget_queue_resize(widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: this will probably behave unfortunately if called multiple times
|
||||||
|
JNIEXPORT void JNICALL Java_android_view_View_setBackgroundColor(JNIEnv *env, jobject this, jint color)
|
||||||
|
{
|
||||||
|
GtkWidget *widget = GTK_WIDGET(_PTR(_GET_LONG_FIELD(this, "widget")));
|
||||||
|
|
||||||
|
GtkCssProvider *css_provider = gtk_css_provider_new();
|
||||||
|
|
||||||
|
char *css_string = g_markup_printf_escaped("* { background-color: #%06x%02x; }", color & 0xFFFFFF, (color >> 24) & 0xFF);
|
||||||
|
gtk_css_provider_load_from_string(css_provider, css_string);
|
||||||
|
g_free(css_string);
|
||||||
|
|
||||||
|
gtk_style_context_add_provider(gtk_widget_get_style_context(gtk_widget_get_parent(widget)), GTK_STYLE_PROVIDER(css_provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||||
|
}
|
||||||
|
|||||||
@@ -962,7 +962,7 @@ public class View extends Object {
|
|||||||
}
|
}
|
||||||
private static native void nativeInvalidate(long widget);
|
private static native void nativeInvalidate(long widget);
|
||||||
|
|
||||||
public void setBackgroundColor(int color) {}
|
public native void setBackgroundColor(int color);
|
||||||
public native void setVisibility(int visibility);
|
public native void setVisibility(int visibility);
|
||||||
public void setPadding(int left, int top, int right, int bottom) {}
|
public void setPadding(int left, int top, int right, int bottom) {}
|
||||||
public void setBackgroundResource(int resid) {
|
public void setBackgroundResource(int resid) {
|
||||||
|
|||||||
Reference in New Issue
Block a user