[Android] Improve the pill widget type and widgets break points

Nicolas Pomepuy git at videolan.org
Wed May 18 09:57:56 UTC 2022


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon May  9 10:10:07 2022 +0200| [170d843490204ab4b759fd669ee60b886e5dade9] | committer: Duncan McNamara

Improve the pill widget type and widgets break points

> https://code.videolan.org/videolan/vlc-android/commit/170d843490204ab4b759fd669ee60b886e5dade9
---

 application/vlc-android/res/layout/widget_pill.xml | 119 +++++++++++----------
 .../vlc-android/res/xml/widget_provider_mini.xml   |   4 +-
 .../org/videolan/vlc/widget/utils/WidgetUtils.kt   |   4 +-
 3 files changed, 66 insertions(+), 61 deletions(-)

diff --git a/application/vlc-android/res/layout/widget_pill.xml b/application/vlc-android/res/layout/widget_pill.xml
index 737eb3eea..e40bb952d 100644
--- a/application/vlc-android/res/layout/widget_pill.xml
+++ b/application/vlc-android/res/layout/widget_pill.xml
@@ -21,70 +21,75 @@
   ~
   ~
   -->
-
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
         xmlns:tools="http://schemas.android.com/tools"
-        android:layout_width="match_parent"
         android:layout_height="match_parent"
-        tools:layout_height="match_parent"
-        tools:layout_width="match_parent">
+        android:layout_width="match_parent">
+
+    <RelativeLayout
+            android:layout_width="120dp"
+            android:layout_height="62dp"
+            android:layout_gravity="center"
+            tools:layout_height="match_parent"
+            tools:layout_width="match_parent">
 
-    <ImageView
-            android:id="@+id/player_container_background"
-            android:layout_width="match_parent"
-            android:layout_height="72dp"
-            android:layout_centerInParent="true"
-            android:contentDescription="@null"
-            android:src="@drawable/widget_pill_neutral"
-            tools:src="@drawable/widget_pill_neutral"
-            tools:tint="@color/black" />
+        <ImageView
+                android:id="@+id/player_container_background"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:layout_centerInParent="true"
+                android:contentDescription="@null"
+                android:src="@drawable/widget_pill_neutral"
+                tools:src="@drawable/widget_pill_neutral"
+                tools:tint="@color/black" />
 
-    <ImageView
-            android:id="@+id/progress_round"
-            android:layout_width="match_parent"
-            android:layout_height="72dp"
-            android:layout_centerInParent="true" />
+        <ImageView
+                android:id="@+id/progress_round"
+                android:layout_width="120dp"
+                android:layout_height="62dp"
+                android:layout_centerInParent="true" />
 
 
-    <ImageView
-            android:id="@+id/cover"
-            android:layout_width="48dp"
-            android:layout_height="48dp"
-            android:layout_alignParentStart="true"
-            android:layout_centerVertical="true"
-            android:layout_marginStart="11dp" />
+        <ImageView
+                android:id="@+id/cover"
+                android:layout_width="48dp"
+                android:layout_height="48dp"
+                android:layout_alignParentStart="true"
+                android:layout_centerVertical="true"
+                android:layout_marginStart="11dp" />
 
-    <ImageView
-            android:id="@+id/app_icon"
-            android:layout_width="32dp"
-            android:layout_height="32dp"
-            android:layout_centerVertical="true"
-            android:layout_marginStart="19dp"
-            android:contentDescription="@string/open_vlc"
-            android:src="@drawable/ic_widget_icon" />
+        <ImageView
+                android:id="@+id/app_icon"
+                android:layout_width="32dp"
+                android:layout_height="32dp"
+                android:layout_centerVertical="true"
+                android:layout_marginStart="19dp"
+                android:contentDescription="@string/open_vlc"
+                android:src="@drawable/ic_widget_icon" />
 
-    <ImageView
-            android:id="@+id/cover_background"
-            android:layout_width="48dp"
-            android:layout_height="48dp"
-            android:layout_alignLeft="@+id/cover"
-            android:layout_alignTop="@+id/cover"
-            android:layout_alignRight="@+id/cover"
-            android:layout_alignBottom="@+id/cover"
-            android:contentDescription="@null"
-            android:src="@drawable/widget_circle" />
+        <ImageView
+                android:id="@+id/cover_background"
+                android:layout_width="48dp"
+                android:layout_height="48dp"
+                android:layout_alignLeft="@+id/cover"
+                android:layout_alignTop="@+id/cover"
+                android:layout_alignRight="@+id/cover"
+                android:layout_alignBottom="@+id/cover"
+                android:contentDescription="@null"
+                android:src="@drawable/widget_circle" />
 
-    <ImageView
-            android:id="@+id/play_pause"
-            android:layout_width="48dp"
-            android:layout_height="48dp"
-            android:layout_alignParentEnd="true"
-            android:layout_centerVertical="true"
-            android:layout_marginStart="48dp"
-            android:layout_marginEnd="8dp"
-            android:background="@drawable/widget_touch_background"
-            android:contentDescription="@string/resume_playback_short_title"
-            android:padding="8dp"
-            android:src="@drawable/ic_widget_play" />
+        <ImageView
+                android:id="@+id/play_pause"
+                android:layout_width="48dp"
+                android:layout_height="48dp"
+                android:layout_alignParentEnd="true"
+                android:layout_centerVertical="true"
+                android:layout_marginStart="48dp"
+                android:layout_marginEnd="8dp"
+                android:background="@drawable/widget_touch_background"
+                android:contentDescription="@string/resume_playback_short_title"
+                android:padding="8dp"
+                android:src="@drawable/ic_widget_play" />
 
-</RelativeLayout>
\ No newline at end of file
+    </RelativeLayout>
+</FrameLayout>
\ No newline at end of file
diff --git a/application/vlc-android/res/xml/widget_provider_mini.xml b/application/vlc-android/res/xml/widget_provider_mini.xml
index a3ba799c4..d0ef6c937 100644
--- a/application/vlc-android/res/xml/widget_provider_mini.xml
+++ b/application/vlc-android/res/xml/widget_provider_mini.xml
@@ -26,9 +26,9 @@
         android:configure="org.videolan.vlc.widget.MiniPlayerConfigureActivity"
         android:widgetFeatures="reconfigurable"
         android:initialLayout="@layout/widget_mini"
-        android:minWidth="48dp"
+        android:minWidth="120dp"
         android:minHeight="48dp"
-        android:minResizeWidth="48dp"
+        android:minResizeWidth="120dp"
         android:minResizeHeight="48dp"
         android:previewImage="@drawable/widget_preview_w"
         android:resizeMode="horizontal|vertical"
diff --git a/application/vlc-android/src/org/videolan/vlc/widget/utils/WidgetUtils.kt b/application/vlc-android/src/org/videolan/vlc/widget/utils/WidgetUtils.kt
index 2242dc04f..66f941478 100644
--- a/application/vlc-android/src/org/videolan/vlc/widget/utils/WidgetUtils.kt
+++ b/application/vlc-android/src/org/videolan/vlc/widget/utils/WidgetUtils.kt
@@ -176,9 +176,9 @@ fun WidgetCacheEntry.generatePillProgressbar(context: Context, progress: Float):
     paint.style = Paint.Style.STROKE
     paint.strokeCap = Paint.Cap.ROUND
     paint.color = widget.getForegroundColor(context, true, palette)
-    val realWidth = widget.width.dp.toFloat()
+    val realWidth = 120.dp.toFloat()
 
-    val progressHeight = 72.dp.toFloat()
+    val progressHeight = 62.dp.toFloat()
     val halfHeight = progressHeight / 2
     val bitmapResult = Bitmap.createBitmap(realWidth.toInt(), progressHeight.toInt(), Bitmap.Config.ARGB_8888)
     val canvas = Canvas(bitmapResult)



More information about the Android mailing list