[Android] Factorize lists texts styles

Geoffrey Métais git at videolan.org
Mon Jun 4 17:56:51 CEST 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Jun  4 17:56:29 2018 +0200| [f1a95f6027b1a18e1646a6e427b13b39ae9d1fda] | committer: Geoffrey Métais

Factorize lists texts styles

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

 vlc-android/res/layout/audio_browser_item.xml | 13 +++----------
 vlc-android/res/layout/history_item.xml       | 10 ++--------
 vlc-android/res/layout/video_grid_card.xml    | 22 ++++++++--------------
 vlc-android/res/layout/video_list_card.xml    | 19 ++++++-------------
 vlc-android/res/values/styles.xml             | 23 +++++++++++++++++++----
 5 files changed, 38 insertions(+), 49 deletions(-)

diff --git a/vlc-android/res/layout/audio_browser_item.xml b/vlc-android/res/layout/audio_browser_item.xml
index 39394f65a..9f5043a68 100644
--- a/vlc-android/res/layout/audio_browser_item.xml
+++ b/vlc-android/res/layout/audio_browser_item.xml
@@ -58,16 +58,13 @@
             vlc:layout_constraintTop_toTopOf="parent"
             vlc:layout_constraintStart_toEndOf="@+id/media_cover"
             vlc:layout_constraintEnd_toStartOf="@+id/item_more"
+            vlc:layout_constraintBottom_toTopOf="@+id/subtitle"
             android:layout_marginStart="@dimen/default_margin"
             android:layout_marginLeft="@dimen/default_margin"
-            vlc:layout_constraintBottom_toTopOf="@+id/subtitle"
-            android:maxLines="2"
             android:gravity="center_vertical"
             vlc:alignMode="@{alignMode}"
             android:text="@{item.title}"
-            android:textColor="?attr/list_title"
-            android:textSize="16sp"
-            android:lineSpacingMultiplier="1.1" />
+            style="@style/VLC.TextViewTitle" />
 
         <TextView
             android:id="@+id/subtitle"
@@ -77,12 +74,8 @@
             vlc:layout_constraintStart_toStartOf="@+id/title"
             vlc:layout_constraintEnd_toEndOf="@+id/title"
             vlc:layout_constraintBottom_toBottomOf="parent"
-            android:singleLine="true"
-            android:maxLines="1"
-            android:ellipsize="middle"
             android:text="@{item.description}"
-            android:textColor="?attr/list_subtitle"
-            android:textSize="12sp"
+            style="@style/VLC.TextViewDescription"
             android:visibility="@{TextUtils.isEmpty(item.description) ? View.GONE : View.VISIBLE}"/>
 
         <ImageView
diff --git a/vlc-android/res/layout/history_item.xml b/vlc-android/res/layout/history_item.xml
index fe91fbfcf..4cca0f325 100644
--- a/vlc-android/res/layout/history_item.xml
+++ b/vlc-android/res/layout/history_item.xml
@@ -38,9 +38,7 @@
             android:layout_width="0dp"
             android:layout_height="wrap_content"
             android:text="@{media.title}"
-            android:fontFamily="sans-serif-light"
-            android:textColor="?attr/list_title"
-            android:textSize="16sp"
+            style="@style/VLC.TextViewTitle"
             android:maxLines="1"
             app:layout_constraintBottom_toTopOf="@+id/subtitle"
             app:layout_constraintTop_toTopOf="parent"
@@ -53,11 +51,7 @@
             android:layout_width="0dp"
             android:layout_height="wrap_content"
             android:text="@{media.artist}"
-            android:fontFamily="sans-serif-light"
-            android:textColor="?attr/list_subtitle"
-            android:maxLines="1"
-            android:singleLine="true"
-            android:ellipsize="start"
+            style="@style/VLC.TextViewDescription"
             android:visibility="@{TextUtils.isEmpty(media.artist) ? View.GONE : View.VISIBLE}"
             app:layout_constraintBottom_toBottomOf="parent"
             app:layout_constraintTop_toBottomOf="@id/title"
diff --git a/vlc-android/res/layout/video_grid_card.xml b/vlc-android/res/layout/video_grid_card.xml
index aec7bd8f6..0929edbac 100644
--- a/vlc-android/res/layout/video_grid_card.xml
+++ b/vlc-android/res/layout/video_grid_card.xml
@@ -90,13 +90,11 @@
             vlc:layout_constraintEnd_toStartOf="@+id/item_more"
             vlc:layout_constraintBottom_toTopOf="@+id/ml_item_time"
             android:layout_marginBottom="1dp"
-            android:fontFamily="sans-serif"
-            android:maxLines="2"
-            android:paddingLeft="@dimen/very_small_margin"
-            android:paddingStart="@dimen/half_default_margin"
-            android:text="@{media.title}"
+            style="@style/VLC.TextViewTitle"
             android:textColor="@color/grey50"
-            android:textSize="@dimen/grid_card_title_text_size"
+            android:layout_marginLeft="@dimen/very_small_margin"
+            android:layout_marginStart="@dimen/half_default_margin"
+            android:text="@{media.title}"
             tools:targetApi="jelly_bean" />
 
         <TextView
@@ -105,16 +103,12 @@
             android:layout_height="wrap_content"
             vlc:layout_constraintBottom_toTopOf="@+id/ml_item_progress"
             vlc:layout_constraintEnd_toStartOf="@+id/item_more"
-            vlc:layout_constraintStart_toStartOf="parent"
+            vlc:layout_constraintStart_toStartOf="@+id/ml_item_title"
             android:layout_marginBottom="2dp"
             android:gravity="start"
-            android:paddingLeft="@dimen/half_default_margin"
-            android:paddingStart="@dimen/half_default_margin"
-            android:maxLines="1"
-            android:text="@{time}"
-            android:textColor="@color/grey200"
-            android:textSize="@dimen/grid_card_subtitle_text_size"
-            tools:targetApi="jelly_bean" />
+            style="@style/VLC.TextViewDescription"
+            android:textColor="@color/grey50"
+            android:text="@{time}" />
 
         <ImageView
             android:id="@+id/item_more"
diff --git a/vlc-android/res/layout/video_list_card.xml b/vlc-android/res/layout/video_list_card.xml
index 2f45989d9..823603139 100644
--- a/vlc-android/res/layout/video_list_card.xml
+++ b/vlc-android/res/layout/video_list_card.xml
@@ -83,14 +83,10 @@
             vlc:layout_constraintBottom_toTopOf="@+id/ml_item_time"
             android:ellipsize="end"
             android:gravity="center_vertical"
-            android:maxLines="2"
-            android:paddingLeft="16dp"
-            android:paddingStart="16dp"
+            android:layout_marginStart="16dp"
+            android:layout_marginLeft="16dp"
             android:text="@{media.title}"
-            android:textColor="?attr/list_title"
-            android:textSize="16sp"
-            android:lineSpacingMultiplier="1.1"
-            tools:targetApi="jelly_bean" />
+            style="@style/VLC.TextViewTitle" />
 
         <ImageView
             android:id="@+id/item_more"
@@ -111,14 +107,11 @@
             android:layout_height="wrap_content"
             vlc:layout_constraintStart_toEndOf="@+id/ml_item_thumbnail"
             vlc:layout_constraintBottom_toTopOf="@+id/ml_item_progress"
+            vlc:layout_constraintStart_toStartOf="@+id/ml_item_title"
+            style="@style/VLC.TextViewDescription"
             android:gravity="start"
-            android:paddingLeft="16dp"
-            android:paddingStart="16dp"
             android:text="@{time}"
-            android:layout_alignWithParentIfMissing="true"
-            android:textColor="?attr/list_subtitle"
-            android:textSize="12sp"
-            tools:targetApi="jelly_bean" />
+            android:layout_alignWithParentIfMissing="true"  />
 
         <ProgressBar
             android:id="@+id/ml_item_progress"
diff --git a/vlc-android/res/values/styles.xml b/vlc-android/res/values/styles.xml
index a96a6eca2..c1e18b24e 100644
--- a/vlc-android/res/values/styles.xml
+++ b/vlc-android/res/values/styles.xml
@@ -4,7 +4,7 @@
     <style name="Theme.VLC" parent="Theme.VLC.7"/>
     <style name="Theme.VLC.7" parent="Theme.VLC.Apearance">
         <item name="actionBarStyle">@style/ActionBar</item>
-        <item name="android:textViewStyle">@style/TextView</item>
+        <item name="android:textViewStyle">@style/VLC.TextView</item>
         <item name="windowActionBarOverlay">true</item>
         <item name="drawerArrowStyle">@style/ActionBar.ArrowToggle</item>
     </style>
@@ -95,14 +95,14 @@
         <item name="list_subtitle">@color/grey400</item>
         <item name="list_title">@color/bt_list_title</item>
         <item name="android:windowBackground">@color/grey900</item>
-        <item name="android:textViewStyle">@style/TextView</item>
+        <item name="android:textViewStyle">@style/VLC.TextView</item>
     </style>
 
     <style name="Theme.VLC.Black" parent="Theme.VLC.Black.7"/>
     <style name="Theme.VLC.Black.7" parent="Theme.VLC.Apearance.Black">
         <item name="actionBarStyle">@style/ActionBar</item>
         <item name="windowActionBarOverlay">true</item>
-        <item name="android:textViewStyle">@style/TextView</item>
+        <item name="android:textViewStyle">@style/VLC.TextView</item>
         <item name="drawerArrowStyle">@style/ActionBar.ArrowToggle</item>
     </style>
 
@@ -281,10 +281,25 @@
         <item name="android:windowAnimationStyle">@android:color/transparent</item>
     </style>
 
-    <style name="TextView" parent="android:Widget.TextView">
+    <style name="VLC.TextView" parent="android:Widget.TextView">
         <item name="android:textDirection">locale</item>
     </style>
 
+    <style name="VLC.TextViewTitle" parent="VLC.TextView">
+        <item name="android:textSize">16sp</item>
+        <item name="android:textColor">?attr/list_title</item>
+        <item name="android:maxLines">2</item>
+        <item name="android:lineSpacingMultiplier">1.1</item>
+    </style>
+
+    <style name="VLC.TextViewDescription" parent="VLC.TextView">
+        <item name="android:textSize">12sp</item>
+        <item name="android:textColor">?attr/list_subtitle</item>
+        <item name="android:singleLine">true</item>
+        <item name="android:maxLines">1</item>
+        <item name="android:ellipsize">start</item>
+    </style>
+
     <style name="ActionBar" parent="Widget.AppCompat.Light.ActionBar">
         <item name="titleTextStyle">@style/ActionBar.Text</item>
     </style>



More information about the Android mailing list