use rounded corners at the widget background

This commit is contained in:
tibbi
2020-05-28 19:00:25 +02:00
parent 8c04934ed4
commit 7974381e76
5 changed files with 279 additions and 218 deletions

View File

@ -68,11 +68,10 @@ class MyWidgetDateTimeProvider : AppWidgetProvider() {
private fun updateColors(context: Context, views: RemoteViews) { private fun updateColors(context: Context, views: RemoteViews) {
val config = context.config val config = context.config
val widgetBgColor = config.widgetBgColor
val widgetTextColor = config.widgetTextColor val widgetTextColor = config.widgetTextColor
views.apply { views.apply {
setBackgroundColor(R.id.widget_date_time_holder, widgetBgColor) applyColorFilter(R.id.widget_background, config.widgetBgColor)
setTextColor(R.id.widget_time, widgetTextColor) setTextColor(R.id.widget_time, widgetTextColor)
setTextColor(R.id.widget_date, widgetTextColor) setTextColor(R.id.widget_date, widgetTextColor)
setTextColor(R.id.widget_next_alarm, widgetTextColor) setTextColor(R.id.widget_next_alarm, widgetTextColor)

View File

@ -1,13 +1,28 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/widget_background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:src="@drawable/widget_round_background" />
<LinearLayout
android:id="@+id/widget_date_time_holder" android:id="@+id/widget_date_time_holder"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
android:paddingLeft="@dimen/small_margin" android:paddingLeft="@dimen/small_margin"
android:paddingRight="@dimen/small_margin" android:paddingRight="@dimen/small_margin"
android:paddingBottom="@dimen/small_margin"> android:paddingBottom="@dimen/small_margin"
tools:ignore="UnusedAttribute">
<TextView <TextView
android:id="@+id/widget_time" android:id="@+id/widget_time"
@ -67,3 +82,4 @@
</RelativeLayout> </RelativeLayout>
</LinearLayout> </LinearLayout>
</RelativeLayout>

View File

@ -1,6 +1,20 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/widget_background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:src="@drawable/widget_round_background" />
<LinearLayout
android:id="@+id/widget_date_time_holder" android:id="@+id/widget_date_time_holder"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -57,3 +71,4 @@
</RelativeLayout> </RelativeLayout>
</LinearLayout> </LinearLayout>
</RelativeLayout>

View File

@ -1,13 +1,28 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/widget_background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:src="@drawable/widget_round_background" />
<LinearLayout
android:id="@+id/widget_date_time_holder" android:id="@+id/widget_date_time_holder"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
android:paddingLeft="@dimen/small_margin" android:paddingLeft="@dimen/small_margin"
android:paddingRight="@dimen/small_margin" android:paddingRight="@dimen/small_margin"
android:paddingBottom="@dimen/small_margin"> android:paddingBottom="@dimen/small_margin"
tools:ignore="UnusedAttribute">
<TextView <TextView
android:id="@+id/widget_time" android:id="@+id/widget_time"
@ -76,3 +91,4 @@
</RelativeLayout> </RelativeLayout>
</LinearLayout> </LinearLayout>
</RelativeLayout>

View File

@ -1,6 +1,20 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/widget_background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:src="@drawable/widget_round_background" />
<LinearLayout
android:id="@+id/widget_date_time_holder" android:id="@+id/widget_date_time_holder"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -66,3 +80,4 @@
</RelativeLayout> </RelativeLayout>
</LinearLayout> </LinearLayout>
</RelativeLayout>