enable RippleDrawable inflation

This commit is contained in:
Julian Winkler
2025-10-26 16:04:01 +01:00
parent f8a3b31379
commit 448d76ce43
3 changed files with 24 additions and 3 deletions

View File

@@ -650,13 +650,29 @@ JNIEXPORT void JNICALL Java_android_view_View_setBackgroundColor(JNIEnv *env, jo
if (((color >> 24) & 0xFF) != 0) if (((color >> 24) & 0xFF) != 0)
widget_set_needs_allocation(widget); widget_set_needs_allocation(widget);
} }
#pragma GCC diagnostic pop
JNIEXPORT void JNICALL Java_android_view_View_native_1setBackgroundDrawable(JNIEnv *env, jobject this, jlong widget_ptr, jlong paintable_ptr) { JNIEXPORT void JNICALL Java_android_view_View_native_1setBackgroundDrawable(JNIEnv *env, jobject this, jlong widget_ptr, jlong paintable_ptr) {
GtkWidget *widget = GTK_WIDGET(_PTR(widget_ptr)); GtkWidget *widget = GTK_WIDGET(_PTR(widget_ptr));
GdkPaintable *paintable = GDK_PAINTABLE(_PTR(paintable_ptr)); GdkPaintable *paintable = GDK_PAINTABLE(_PTR(paintable_ptr));
wrapper_widget_set_background(WRAPPER_WIDGET(gtk_widget_get_parent(widget)), paintable); wrapper_widget_set_background(WRAPPER_WIDGET(gtk_widget_get_parent(widget)), paintable);
GtkStyleContext *style_context = gtk_widget_get_style_context(widget);
GtkCssProvider *old_provider = g_object_get_data(G_OBJECT(widget), "background_paintable_style_provider");
if(old_provider)
gtk_style_context_remove_provider(style_context, GTK_STYLE_PROVIDER(old_provider));
GtkCssProvider *css_provider = gtk_css_provider_new();
char *css_string = g_markup_printf_escaped("* { background-image: none; }");
gtk_css_provider_load_from_string(css_provider, css_string);
g_free(css_string);
gtk_style_context_add_provider(style_context, GTK_STYLE_PROVIDER(css_provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_set_data(G_OBJECT(widget), "background_paintable_style_provider", css_provider);
if (paintable)
widget_set_needs_allocation(widget);
} }
#pragma GCC diagnostic pop
JNIEXPORT jboolean JNICALL Java_android_view_View_native_1getGlobalVisibleRect(JNIEnv *env, jobject this, jlong widget_ptr, jobject rect) { JNIEXPORT jboolean JNICALL Java_android_view_View_native_1getGlobalVisibleRect(JNIEnv *env, jobject this, jlong widget_ptr, jobject rect) {
GtkWidget *widget = gtk_widget_get_parent(GTK_WIDGET(_PTR(widget_ptr))); GtkWidget *widget = gtk_widget_get_parent(GTK_WIDGET(_PTR(widget_ptr)));

View File

@@ -248,8 +248,9 @@ public class Drawable {
return new Drawable(); return new Drawable();
} }
case "ripple": { case "ripple": {
// FIXME: the non-pressed state of RippleDrawable should be equivalent to this RippleDrawable drawable = new RippleDrawable();
return new ColorDrawable(0); drawable.inflate(resources, parser, attrs, theme);
return drawable;
} }
case "vector": { case "vector": {
VectorDrawable drawable = new VectorDrawable(); VectorDrawable drawable = new VectorDrawable();
@@ -356,6 +357,8 @@ public class Drawable {
public void setFilterBitmap(boolean filter) {} public void setFilterBitmap(boolean filter) {}
public void setHotspotBounds(int left, int top, int right, int bottom) {}
protected static native long native_paintable_from_path(String path); protected static native long native_paintable_from_path(String path);
protected native long native_constructor(); protected native long native_constructor();
protected native void native_invalidate(long paintable); protected native void native_invalidate(long paintable);

View File

@@ -8,6 +8,8 @@ public class RippleDrawable extends LayerDrawable {
super(drawable == null ? new Drawable[] {} : new Drawable[] {drawable}); super(drawable == null ? new Drawable[] {} : new Drawable[] {drawable});
} }
RippleDrawable() {}
public void setColor(ColorStateList colorStateList) {} public void setColor(ColorStateList colorStateList) {}
public void setRadius(int radius) {} public void setRadius(int radius) {}