[Android] Empty view improvements

Nicolas Pomepuy git at videolan.org
Mon Jul 5 11:12:29 UTC 2021


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Wed Jun 23 13:35:38 2021 +0200| [35748dd5d6a980a00ac51b959442c3276b246b44] | committer: Nicolas Pomepuy

Empty view improvements

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

 .../src/main/res/drawable/ic_permission.xml        |  9 +++++
 .../vlc-android/res/layout/view_empty_loading.xml  | 38 ++++++++++++++--------
 .../videolan/vlc/gui/view/EmptyLoadingStateView.kt |  4 ++-
 3 files changed, 36 insertions(+), 15 deletions(-)

diff --git a/application/resources/src/main/res/drawable/ic_permission.xml b/application/resources/src/main/res/drawable/ic_permission.xml
new file mode 100644
index 000000000..f8feee4bd
--- /dev/null
+++ b/application/resources/src/main/res/drawable/ic_permission.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:width="96dp"
+        android:height="96dp"
+        android:viewportWidth="24"
+        android:viewportHeight="24">
+    <path
+            android:fillColor="?attr/font_light"
+            android:pathData="M12,17c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM18,8h-1L17,6c0,-2.76 -2.24,-5 -5,-5S7,3.24 7,6h1.9c0,-1.71 1.39,-3.1 3.1,-3.1 1.71,0 3.1,1.39 3.1,3.1v2L6,8c-1.1,0 -2,0.9 -2,2v10c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L20,10c0,-1.1 -0.9,-2 -2,-2zM18,20L6,20L6,10h12v10z" />
+</vector>
diff --git a/application/vlc-android/res/layout/view_empty_loading.xml b/application/vlc-android/res/layout/view_empty_loading.xml
index da5094002..c82fb9fe0 100644
--- a/application/vlc-android/res/layout/view_empty_loading.xml
+++ b/application/vlc-android/res/layout/view_empty_loading.xml
@@ -37,22 +37,33 @@
             android:orientation="horizontal"
             app:layout_constraintGuide_percent="0.5" />
 
+    <androidx.constraintlayout.widget.Barrier
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            app:barrierDirection="top"
+            android:id="@+id/text_barrier"
+            app:constraint_referenced_ids="permissionTextView,emptyTextView"/>
+
+    <androidx.constraintlayout.widget.Barrier
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            app:barrierDirection="bottom"
+            android:id="@+id/text_barrier_bottom"
+            app:constraint_referenced_ids="permissionTextView,emptyTextView"/>
+
     <TextView
             android:id="@+id/emptyTextView"
             android:layout_width="0dp"
             android:layout_height="wrap_content"
             android:layout_marginLeft="16dp"
             android:layout_marginRight="16dp"
-            android:layout_marginBottom="16dp"
             android:gravity="center"
             android:maxWidth="600dp"
             android:textSize="20sp"
-            app:layout_constraintBottom_toTopOf="@+id/emptyImageView"
-            app:layout_constraintHorizontal_bias="1.0"
+            app:layout_constraintBottom_toBottomOf="@id/guideline12"
             app:layout_constraintLeft_toLeftOf="parent"
             app:layout_constraintRight_toRightOf="parent"
-            app:layout_constraintTop_toTopOf="parent"
-            app:layout_constraintVertical_chainStyle="packed"
+            app:layout_constraintTop_toTopOf="@id/guideline12"
             tools:visibility="visible" />
 
     <TextView
@@ -64,22 +75,23 @@
             android:layout_marginBottom="16dp"
             android:gravity="center"
             android:maxWidth="600dp"
-            android:textSize="20sp"
             android:text="@string/permission_media"
-            app:layout_constraintHorizontal_bias="1.0"
+            android:textSize="20sp"
+            app:layout_constraintBottom_toBottomOf="@id/guideline12"
             app:layout_constraintLeft_toLeftOf="parent"
             app:layout_constraintRight_toRightOf="parent"
-            app:layout_constraintTop_toTopOf="parent"
+            app:layout_constraintTop_toTopOf="@id/guideline12"
             tools:visibility="visible" />
 
     <androidx.appcompat.widget.AppCompatImageView
             android:id="@+id/emptyImageView"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            app:layout_constraintBottom_toTopOf="@+id/guideline12"
+            android:layout_marginBottom="16dp"
+            app:layout_constraintBottom_toTopOf="@+id/text_barrier"
             app:layout_constraintEnd_toEndOf="parent"
             app:layout_constraintStart_toStartOf="parent"
-            app:layout_constraintTop_toTopOf="@+id/guideline12"
+            app:layout_constraintTop_toTopOf="parent"
             app:srcCompat="@drawable/ic_empty" />
 
     <Button
@@ -89,10 +101,9 @@
             android:layout_height="wrap_content"
             android:layout_marginTop="16dp"
             android:text="@string/button_medialibrary_preferences"
-            app:layout_constraintBottom_toBottomOf="parent"
             app:layout_constraintLeft_toLeftOf="parent"
             app:layout_constraintRight_toRightOf="parent"
-            app:layout_constraintTop_toBottomOf="@+id/emptyImageView" />
+            app:layout_constraintTop_toBottomOf="@+id/text_barrier_bottom" />
 
 
     <Button
@@ -102,10 +113,9 @@
             android:layout_height="wrap_content"
             android:layout_marginTop="16dp"
             android:text="@string/permission_ask_again"
-            app:layout_constraintBottom_toBottomOf="parent"
             app:layout_constraintLeft_toLeftOf="parent"
             app:layout_constraintRight_toRightOf="parent"
-            app:layout_constraintTop_toBottomOf="@+id/emptyImageView" />
+            app:layout_constraintTop_toBottomOf="@+id/text_barrier_bottom" />
 
     <TextView
             android:id="@+id/loadingTitle"
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/view/EmptyLoadingStateView.kt b/application/vlc-android/src/org/videolan/vlc/gui/view/EmptyLoadingStateView.kt
index 5135e1023..7c7bba542 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/view/EmptyLoadingStateView.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/view/EmptyLoadingStateView.kt
@@ -36,6 +36,7 @@ import android.widget.FrameLayout
 import androidx.annotation.StringRes
 import androidx.constraintlayout.widget.ConstraintLayout
 import androidx.constraintlayout.widget.ConstraintSet
+import androidx.core.content.ContextCompat
 import androidx.fragment.app.FragmentActivity
 import androidx.transition.TransitionManager
 import kotlinx.android.synthetic.main.view_empty_loading.view.*
@@ -61,7 +62,8 @@ class EmptyLoadingStateView : FrameLayout {
             loadingFlipper.visibility = if (value == EmptyLoadingState.LOADING) View.VISIBLE else View.GONE
             loadingTitle.visibility = if (value == EmptyLoadingState.LOADING) View.VISIBLE else View.GONE
             emptyTextView.visibility = if (value == EmptyLoadingState.EMPTY) View.VISIBLE else View.GONE
-            emptyImageView.visibility = if (value == EmptyLoadingState.EMPTY) View.VISIBLE else View.GONE
+            emptyImageView.visibility = if (value == EmptyLoadingState.EMPTY || value == EmptyLoadingState.MISSING_PERMISSION) View.VISIBLE else View.GONE
+            emptyImageView.setImageDrawable(ContextCompat.getDrawable(context, if (value == EmptyLoadingState.EMPTY) R.drawable.ic_empty else R.drawable.ic_permission_big))
             permissionTextView.visibility = if (value == EmptyLoadingState.MISSING_PERMISSION) View.VISIBLE else View.GONE
             grantPermissionButton.visibility = if (value == EmptyLoadingState.MISSING_PERMISSION) View.VISIBLE else View.GONE
             noMediaButton.visibility = if (showNoMedia && value == EmptyLoadingState.EMPTY) View.VISIBLE else View.GONE



More information about the Android mailing list