Use ripple backgrounds for widget rows (Android 5+)

pull/996/head
Alex Baker 5 years ago
parent 9060a86623
commit 52eb32bea9

@ -1,6 +1,7 @@
package org.tasks.widget;
import static androidx.core.content.ContextCompat.getColor;
import static com.todoroo.andlib.utility.AndroidUtilities.atLeastLollipop;
import android.appwidget.AppWidgetManager;
import android.content.Context;
@ -188,6 +189,13 @@ class ScrollableViewsFactory implements RemoteViewsService.RemoteViewsFactory {
editIntent.putExtra(WidgetClickActivity.EXTRA_TASK, task);
row.setOnClickFillInIntent(R.id.widget_row, editIntent);
int theme = widgetPreferences.getThemeIndex();
if (atLeastLollipop()) {
row.setInt(
R.id.widget_row,
"setBackgroundResource",
theme == 0 ? R.drawable.widget_ripple_light : R.drawable.widget_ripple_dark);
}
int horizontalPadding = (int) context.getResources().getDimension(R.dimen.widget_padding);
int verticalPadding = widgetPreferences.getWidgetSpacing();
int textBottomPadding =
@ -210,7 +218,7 @@ class ScrollableViewsFactory implements RemoteViewsService.RemoteViewsFactory {
row.setViewPadding(R.id.widget_description, horizontalPadding, 0, horizontalPadding, textBottomPadding);
}
int dividerColor = ContextCompat.getColor(context, widgetPreferences.getThemeIndex() == 0 ? R.color.black_12 : R.color.white_12);
int dividerColor = ContextCompat.getColor(context, theme == 0 ? R.color.black_12 : R.color.white_12);
row.setImageViewBitmap(R.id.divider, getSolidBackground(dividerColor));
row.setInt(

@ -76,7 +76,6 @@ public class TasksWidget extends InjectingAppWidgetProvider {
ThemeColor color = new ThemeColor(context, widgetPreferences.getColor());
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.scrollable_widget);
remoteViews.setInt(R.id.widget, "setLayoutDirection", locale.getDirectionality());
int rowSpacing = widgetPreferences.getWidgetSpacing();
if (widgetPreferences.showHeader()) {
remoteViews.setViewVisibility(R.id.widget_header, View.VISIBLE);
remoteViews.setViewVisibility(

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple android:color="@color/ripple_material_dark"
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/mask"
android:drawable="@android:color/white" />
</ripple>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple android:color="@color/ripple_material_light"
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/mask">
<color android:color="@android:color/white" />
</item>
</ripple>

@ -90,6 +90,7 @@
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:listSelector="@android:color/transparent"
android:divider="@null"
android:dividerHeight="0dp"/>

Loading…
Cancel
Save