TextView: implement setTextColor

also uncomment Resources.getCachedColorStateList
This commit is contained in:
Mis012
2023-09-03 12:57:13 +02:00
parent 1e47824a79
commit 897a1e68a4
4 changed files with 31 additions and 5 deletions

View File

@@ -29,6 +29,20 @@ JNIEXPORT void JNICALL Java_android_widget_TextView_native_1setText(JNIEnv *env,
gtk_label_set_text(GTK_LABEL(_PTR(_GET_LONG_FIELD(this, "widget"))), _CSTRING(charseq));
}
// FIXME: this will probably behave unfortunately if called multiple times
JNIEXPORT void JNICALL Java_android_widget_TextView_native_1setTextColor(JNIEnv *env, jobject this, jint color)
{
GtkLabel *label = GTK_LABEL(_PTR(_GET_LONG_FIELD(this, "widget")));
GtkCssProvider *css_provider = gtk_css_provider_new();
char *css_string = g_markup_printf_escaped("* { color: #%06x; }", color & 0xFFFFFF);
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(label)), GTK_STYLE_PROVIDER(css_provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
JNIEXPORT void JNICALL Java_android_widget_TextView_setTextSize(JNIEnv *env, jobject this, jfloat size)
{
GtkLabel *label = GTK_LABEL(_PTR(_GET_LONG_FIELD(this, "widget")));