[Android] Fix dialog button theme on Android 8

Nicolas Pomepuy git at videolan.org
Wed Mar 23 06:58:18 UTC 2022


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Fri Mar 18 10:04:04 2022 +0100| [3a4f32841ff35c97bb348cb1063c292ece0e970b] | committer: Nicolas Pomepuy

Fix dialog button theme on Android 8

Fixes #2417
Fixes #2108

> https://code.videolan.org/videolan/vlc-android/commit/3a4f32841ff35c97bb348cb1063c292ece0e970b
---

 .../src/main/res/drawable/button_background.xml    | 31 +++++++++++++++++++++
 .../res/drawable/button_background_selected.xml    | 32 ++++++++++++++++++++++
 .../res/layout/network_server_dialog.xml           |  8 ++++--
 .../vlc-android/res/layout/vlc_login_dialog.xml    |  4 +--
 application/vlc-android/res/values-v27/styles.xml  |  1 +
 application/vlc-android/res/values/styles.xml      | 17 ++++++++----
 6 files changed, 83 insertions(+), 10 deletions(-)

diff --git a/application/resources/src/main/res/drawable/button_background.xml b/application/resources/src/main/res/drawable/button_background.xml
new file mode 100644
index 000000000..6601fe77f
--- /dev/null
+++ b/application/resources/src/main/res/drawable/button_background.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ *************************************************************************
+  ~  button_background.xml
+  ~ **************************************************************************
+  ~ Copyright © 2022 VLC authors and VideoLAN
+  ~ Author: Nicolas POMEPUY
+  ~ This program is free software; you can redistribute it and/or modify
+  ~ it under the terms of the GNU General Public License as published by
+  ~ the Free Software Foundation; either version 2 of the License, or
+  ~ (at your option) any later version.
+  ~
+  ~ This program is distributed in the hope that it will be useful,
+  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  ~ GNU General Public License for more details.
+  ~
+  ~ You should have received a copy of the GNU General Public License
+  ~ along with this program; if not, write to the Free Software
+  ~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+  ~ ***************************************************************************
+  ~
+  ~
+  -->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_pressed="true" android:drawable="@drawable/button_background_selected" />
+    <item android:state_focused="true" android:drawable="@drawable/button_background_selected" />
+    <item android:drawable="@color/transparent" />
+
+</selector>
\ No newline at end of file
diff --git a/application/resources/src/main/res/drawable/button_background_selected.xml b/application/resources/src/main/res/drawable/button_background_selected.xml
new file mode 100644
index 000000000..093635a4b
--- /dev/null
+++ b/application/resources/src/main/res/drawable/button_background_selected.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ *************************************************************************
+  ~  button_background_selected.xml
+  ~ **************************************************************************
+  ~ Copyright © 2022 VLC authors and VideoLAN
+  ~ Author: Nicolas POMEPUY
+  ~ This program is free software; you can redistribute it and/or modify
+  ~ it under the terms of the GNU General Public License as published by
+  ~ the Free Software Foundation; either version 2 of the License, or
+  ~ (at your option) any later version.
+  ~
+  ~ This program is distributed in the hope that it will be useful,
+  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  ~ GNU General Public License for more details.
+  ~
+  ~ You should have received a copy of the GNU General Public License
+  ~ along with this program; if not, write to the Free Software
+  ~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+  ~ ***************************************************************************
+  ~
+  ~
+  -->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+        android:shape="rectangle">
+    <corners android:radius="4dp"/>
+    <solid android:color="@color/orange200transparent" />
+
+
+</shape>
\ No newline at end of file
diff --git a/application/vlc-android/res/layout/network_server_dialog.xml b/application/vlc-android/res/layout/network_server_dialog.xml
index b54b479f9..9559d3971 100644
--- a/application/vlc-android/res/layout/network_server_dialog.xml
+++ b/application/vlc-android/res/layout/network_server_dialog.xml
@@ -160,7 +160,9 @@
 
         <Button
                 android:id="@+id/server_cancel"
-                style="@style/Widget.MaterialComponents.Button.TextButton.Dialog"
+                style="@style/Widget.MaterialComponents.Button.TextButton"
+                android:focusable="true"
+                android:clickable="true"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_marginEnd="16dp"
@@ -171,7 +173,9 @@
 
         <Button
                 android:id="@+id/server_save"
-                style="@style/Widget.MaterialComponents.Button.TextButton.Dialog"
+                style="@style/Widget.MaterialComponents.Button.TextButton"
+                android:focusable="true"
+                android:clickable="true"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_marginTop="24dp"
diff --git a/application/vlc-android/res/layout/vlc_login_dialog.xml b/application/vlc-android/res/layout/vlc_login_dialog.xml
index 4fd0c1509..ef9603d88 100644
--- a/application/vlc-android/res/layout/vlc_login_dialog.xml
+++ b/application/vlc-android/res/layout/vlc_login_dialog.xml
@@ -99,7 +99,7 @@
                     android:text="@string/cancel"
                     android:textSize="14sp"
                     android:onClick="@{handler::onCancel}"
-                    style="@style/Widget.MaterialComponents.Button.TextButton.Dialog" />
+                    style="@style/VLCDialogButton" />
 
             <Button
                     android:id="@+id/action"
@@ -113,7 +113,7 @@
                     android:text="@string/ok"
                     android:textSize="14sp"
                     android:onClick="@{handler::onLogin}"
-                    style="@style/Widget.MaterialComponents.Button.TextButton.Dialog" />
+                    style="@style/VLCDialogButton" />
         </RelativeLayout>
     </ScrollView>
 </layout>
diff --git a/application/vlc-android/res/values-v27/styles.xml b/application/vlc-android/res/values-v27/styles.xml
index 13937720f..314b927cb 100644
--- a/application/vlc-android/res/values-v27/styles.xml
+++ b/application/vlc-android/res/values-v27/styles.xml
@@ -60,4 +60,5 @@
         <item name="android:navigationBarColor">@color/white</item>
         <item name="android:windowLightNavigationBar">true</item>
     </style>
+    <style name="VLCDialogButton" parent="Widget.MaterialComponents.Button.TextButton.Dialog"/>
 </resources>
\ No newline at end of file
diff --git a/application/vlc-android/res/values/styles.xml b/application/vlc-android/res/values/styles.xml
index 041bd52dc..c971200ae 100644
--- a/application/vlc-android/res/values/styles.xml
+++ b/application/vlc-android/res/values/styles.xml
@@ -721,12 +721,17 @@
 
     </style>
 
-        <style name="About"/>
-        <style name="About.Title">
-            <item name="android:textSize">16sp</item>
-            <item name="android:textColor">?attr/font_default</item>
-            <item name="android:fontFamily">sans-serif-medium</item>
+    <style name="About" />
 
-        </style>
+    <style name="About.Title">
+        <item name="android:textSize">16sp</item>
+        <item name="android:textColor">?attr/font_default</item>
+        <item name="android:fontFamily">sans-serif-medium</item>
+
+    </style>
+
+    <style name="VLCDialogButton" parent="TextAppearance.MaterialComponents.Button">
+        <item name="android:background">@drawable/button_background</item>
+    </style>
 
 </resources>



More information about the Android mailing list