widgets: add minimal widget [#8]

Add the first widget implementation, the minimal widget. This took a
good 2 days of hacking and frustration to get the first prototype
working. And even then, its currently scoped to android 12 until I'm
able to port them. The implementation is still quite rough, but should
become manageable over time. More widgets will come.
This commit is contained in:
OxygenCobalt
2021-08-01 17:32:38 -06:00
parent 58bea1dda5
commit 66be3da7e3
22 changed files with 404 additions and 19 deletions
@@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:alpha="0.3"
android:tint="?attr/colorPrimary"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M12 3v10.55C11.41 13.21 10.73 13 10 13c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4V7h4V3h-6z" />
</vector>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners />
<solid android:color="@color/surface_black" />
</shape>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners />
<solid android:color="@color/surface_day" />
</shape>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners />
<solid android:color="@color/surface_night" />
</shape>
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@android:id/background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:attr/colorBackground"
android:orientation="vertical"
android:theme="@style/Theme.Widget">
<android.widget.ImageView
android:id="@+id/widget_cover"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:scaleType="centerCrop"
tools:ignore="contentDescription"
tools:src="@drawable/ic_song_clear" />
<android.widget.LinearLayout
android:id="@+id/widget_meta"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="?android:attr/colorBackground"
android:orientation="vertical"
android:padding="@dimen/spacing_medium">
<android.widget.TextView
android:id="@+id/widget_song"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.MaterialComponents.Headline6"
android:textColor="?android:attr/textColorPrimary"
android:textStyle="bold"
tools:text="Song Name" />
<android.widget.TextView
android:id="@+id/widget_artist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1"
android:textColor="?android:attr/textColorSecondary"
tools:text="Artist Name" />
</android.widget.LinearLayout>
<android.widget.TextView
android:id="@+id/widget_placeholder_msg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/spacing_medium"
android:text="@string/placeholder_playback"
android:textAppearance="@style/TextAppearance.MaterialComponents.Headline6"
android:textColor="?android:attr/textColorPrimary"
android:textStyle="bold" />
</LinearLayout>
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="surface_color">#151515</color>
<color name="surface_color">@color/surface_night</color>
<color name="divider_color">#323232</color>
<color name="selection_color">#484848</color>
<color name="inactive_color">#404040</color>
+7
View File
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--
Widgets are limited to android 12 until I can find an okay-ish way to backport them.
-->
<bool name="widgets_supported">true</bool>
</resources>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Widget" parent="@android:style/Theme.DeviceDefault.DayNight">
<item name="colorPrimary">?android:attr/colorAccent</item>
<item name="colorSecondary">?android:attr/colorAccent</item>
</style>
</resources>
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="widgets_supported">false</bool>
</resources>
+14 -7
View File
@@ -1,13 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="surface_color">#fafafa</color>
<color name="divider_color">#cbcbcb</color>
<color name="selection_color">#cbcbcb</color>
<color name="inactive_color">#c4c4c4</color>
<color name="control_color">#202020</color>
<color name="nav_color">#01fafafa</color>
<color name="surface_day">#fffafafa</color>
<color name="surface_night">#ff151515</color>
<color name="surface_black">#ff000000</color>
<color name="surface_color_black">#000000</color>
<color name="text_primary_day">#ff000000</color>
<color name="text_secondary_day">#ff323232</color>
<color name="text_primary_night">#ffffffff</color>
<color name="text_secondary_night">#ffbebebe</color>
<color name="surface_color">@color/surface_day</color>
<color name="selection_color">#cbcbcb</color>
<color name="control_color">#202020</color>
<color name="divider_color">#cbcbcb</color>
<color name="inactive_color">#c4c4c4</color>
<color name="nav_color">#01fafafa</color>
<!--
Base color set derived from Music Player GO.
+1
View File
@@ -134,6 +134,7 @@
<string name="placeholder_artist">Unknown Artist</string>
<string name="placeholder_album">Unknown Album</string>
<string name="placeholder_no_date">No Date</string>
<string name="placeholder_playback">No music playing</string>
<!-- Color Label namespace | Accent names -->
<string name="color_label_red">Red</string>
+1 -1
View File
@@ -36,7 +36,7 @@
<!-- Black theme dialog theme -->
<style name="Theme.CustomDialog.Black" parent="Theme.CustomDialog.Base">
<item name="colorSurface">@color/surface_color_black</item>
<item name="colorSurface">@color/surface_black</item>
</style>
<!-- Material-specific dialog style -->
@@ -157,8 +157,6 @@
<item name="android:thumbTint">?attr/colorPrimary</item>
</style>
<!-- Base style for the material buttons -->
<style name="Widget.MaterialComponents.Button.Base" parent="@style/Widget.MaterialComponents.Button.TextButton">
<item name="android:layout_width">0dp</item>
+1 -1
View File
@@ -39,7 +39,7 @@
<!-- The basic black theme derived in all black accents. -->
<style name="Theme.Base.Black" parent="Theme.Base">
<item name="colorSurface">@color/surface_color_black</item>
<item name="colorSurface">@color/surface_black</item>
<item name="materialAlertDialogTheme">@style/Theme.CustomDialog.Black</item>
</style>
</resources>
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:initialLayout="@layout/widget_minimal"
android:targetCellWidth="2"
android:targetCellHeight="2"
android:minResizeWidth="110dp"
android:minResizeHeight="110dp"
android:resizeMode="horizontal|vertical"
android:updatePeriodMillis="0"
android:widgetCategory="home_screen">
</appwidget-provider>