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
TextView: implement setTextColor
also uncomment Resources.getCachedColorStateList
This commit is contained in:
@@ -231,6 +231,14 @@ JNIEXPORT void JNICALL Java_android_widget_TextView_native_1setText
|
|||||||
JNIEXPORT void JNICALL Java_android_widget_TextView_setTextSize
|
JNIEXPORT void JNICALL Java_android_widget_TextView_setTextSize
|
||||||
(JNIEnv *, jobject, jfloat);
|
(JNIEnv *, jobject, jfloat);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: android_widget_TextView
|
||||||
|
* Method: native_setTextColor
|
||||||
|
* Signature: (I)V
|
||||||
|
*/
|
||||||
|
JNIEXPORT void JNICALL Java_android_widget_TextView_native_1setTextColor
|
||||||
|
(JNIEnv *, jobject, jint);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -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));
|
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)
|
JNIEXPORT void JNICALL Java_android_widget_TextView_setTextSize(JNIEnv *env, jobject this, jfloat size)
|
||||||
{
|
{
|
||||||
GtkLabel *label = GTK_LABEL(_PTR(_GET_LONG_FIELD(this, "widget")));
|
GtkLabel *label = GTK_LABEL(_PTR(_GET_LONG_FIELD(this, "widget")));
|
||||||
|
|||||||
@@ -845,7 +845,7 @@ public class Resources {
|
|||||||
* @return Returns a ColorStateList object containing either a single
|
* @return Returns a ColorStateList object containing either a single
|
||||||
* solid color or multiple colors that can be selected based on a state.
|
* solid color or multiple colors that can be selected based on a state.
|
||||||
*/
|
*/
|
||||||
public ColorStateList getColorStateList(int id) throws NotFoundException { /*
|
public ColorStateList getColorStateList(int id) throws NotFoundException {
|
||||||
TypedValue value;
|
TypedValue value;
|
||||||
synchronized (mAccessLock) {
|
synchronized (mAccessLock) {
|
||||||
value = mTmpValue;
|
value = mTmpValue;
|
||||||
@@ -862,8 +862,7 @@ public class Resources {
|
|||||||
mTmpValue = value;
|
mTmpValue = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;*/
|
return res;
|
||||||
return new ColorStateList(new int[][] {new int[0]}, new int[1]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -71,8 +71,13 @@ public class TextView extends View {
|
|||||||
public native final void native_setText(String text);
|
public native final void native_setText(String text);
|
||||||
public native void setTextSize(float size);
|
public native void setTextSize(float size);
|
||||||
|
|
||||||
public void setTextColor(int color) {}
|
public native final void native_setTextColor(int color);
|
||||||
public void setTextColor(ColorStateList colors) {}
|
public void setTextColor(int color) {
|
||||||
|
native_setTextColor(color);
|
||||||
|
}
|
||||||
|
public void setTextColor(ColorStateList colors) {
|
||||||
|
setTextColor(colors.getDefaultColor()); // TODO: do this properly
|
||||||
|
}
|
||||||
public void setTextSize(int unit, float size) {}
|
public void setTextSize(int unit, float size) {}
|
||||||
public void setTypeface(Typeface tf, int style) {}
|
public void setTypeface(Typeface tf, int style) {}
|
||||||
public void setTypeface(Typeface tf) {}
|
public void setTypeface(Typeface tf) {}
|
||||||
|
|||||||
Reference in New Issue
Block a user