[Android] Convert MRLPanel to constraintLayout

Habib Kazemi git at videolan.org
Mon Aug 6 16:18:27 CEST 2018


vlc-android | branch: master | Habib Kazemi <kazemihabib1996 at gmail.com> | Tue Jul 31 12:36:59 2018 +0430| [76e23fc193d5de6d93bb5e3b4e20b042d1e6de4c] | committer: Geoffrey Métais

Convert MRLPanel to constraintLayout

Signed-off-by: Geoffrey Métais <geoffrey.metais at gmail.com>

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

 vlc-android/res/layout/mrl_panel.xml               | 73 +++++++++++++---------
 vlc-android/res/values-w600dp/dimens.xml           |  6 ++
 vlc-android/res/values/dimens.xml                  |  3 +
 vlc-android/res/values/strings.xml                 |  1 +
 .../videolan/vlc/gui/network/MRLPanelFragment.kt   |  2 +-
 5 files changed, 54 insertions(+), 31 deletions(-)

diff --git a/vlc-android/res/layout/mrl_panel.xml b/vlc-android/res/layout/mrl_panel.xml
index 5a217fd6f..65d5ead8c 100644
--- a/vlc-android/res/layout/mrl_panel.xml
+++ b/vlc-android/res/layout/mrl_panel.xml
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
-<layout xmlns:android="http://schemas.android.com/apk/res/android">
+<layout xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:android="http://schemas.android.com/apk/res/android">
     <data>
         <variable name="viewmodel"
             type="org.videolan.vlc.viewmodels.MRLPanelModel"/>
@@ -7,57 +8,69 @@
 
     <android.support.v4.widget.NestedScrollView
         android:layout_width="match_parent"
-        android:layout_height="match_parent" >
-        <RelativeLayout
+        android:layout_height="match_parent">
+
+        <android.support.constraint.ConstraintLayout
             android:id="@+id/mrl_root"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
             android:background="?attr/background_default_darker"
-            android:padding="32dp"
-            android:layoutDirection="ltr">
+            android:layoutDirection="ltr"
+            android:padding="16dp"
+            android:minWidth="@dimen/mrl_panel_min_width">
+
             <android.support.design.widget.TextInputLayout
-                android:layout_width="match_parent"
+                android:id="@+id/mrl_edit"
+                android:layout_width="0dp"
                 android:layout_height="wrap_content"
-                android:layout_toLeftOf="@+id/send"
-                android:layout_toStartOf="@+id/send"
-                android:layout_marginTop="5dip"
-                android:layout_marginBottom="16dp"
-                android:id="@+id/mrl_edit">
+                android:layout_marginTop="4dip"
+                android:layout_marginEnd="4dp"
+                android:layout_marginRight="4dp"
+                app:layout_constraintEnd_toStartOf="@+id/play"
+                app:layout_constraintRight_toLeftOf="@+id/play"
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintTop_toTopOf="parent">
 
                 <!--android:paddingTop ==> Space between cursor and top hint-->
                 <!--android:paddingBottom ==> Space between cursor and bottom border-->
-                <EditText
+                <android.support.design.widget.TextInputEditText
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
                     android:layout_alignParentTop="true"
+                    android:layout_marginRight="8dp"
+                    android:background="@drawable/edittext_bottom_border"
                     android:hint="@string/open_mrl_dialog_msg"
+                    android:imeOptions="actionGo"
                     android:inputType="textUri"
+                    android:maxLines="2"
+                    android:paddingTop="8dp"
+                    android:paddingBottom="4dp"
                     android:text="@={viewmodel.observableSearchText}"
                     android:textColor="?font_default"
-                    android:maxLines="2"
-                    android:layout_marginRight="8dp"
-                    android:paddingTop="10dp"
-                    android:paddingBottom="5dp"
-                    android:textCursorDrawable="@drawable/cursor_o"
-                    android:background="@drawable/edittext_bottom_border"
-                    android:imeOptions="actionGo"/>
+                    android:textCursorDrawable="@drawable/cursor_o" />
             </android.support.design.widget.TextInputLayout>
+
             <ImageView
-                android:id="@+id/send"
+                android:id="@+id/play"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:layout_alignParentRight="true"
-                android:layout_alignParentEnd="true"
-                android:layout_alignBottom="@+id/mrl_edit"
-                android:layout_alignTop="@+id/mrl_edit"
+                android:contentDescription="@string/play_button"
                 android:scaleType="center"
-                android:src="@drawable/ic_send"/>
+                android:src="@drawable/ic_send"
+                app:layout_constraintBottom_toBottomOf="@+id/mrl_edit"
+                app:layout_constraintEnd_toEndOf="parent"
+                app:layout_constraintRight_toRightOf="parent"
+                app:layout_constraintTop_toTopOf="@+id/mrl_edit" />
+
             <android.support.v7.widget.RecyclerView
                 android:id="@+id/mrl_list"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:layout_below="@+id/mrl_edit"
-                android:background="?attr/background_default"/>
-        </RelativeLayout>
+                android:layout_marginTop="16dp"
+                android:background="?attr/background_default"
+                app:layout_constraintEnd_toEndOf="parent"
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintTop_toBottomOf="@+id/mrl_edit" />
+        </android.support.constraint.ConstraintLayout>
     </android.support.v4.widget.NestedScrollView>
 </layout>
diff --git a/vlc-android/res/values-w600dp/dimens.xml b/vlc-android/res/values-w600dp/dimens.xml
new file mode 100644
index 000000000..d2b120c0e
--- /dev/null
+++ b/vlc-android/res/values-w600dp/dimens.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<resources>
+    <!--MRLPanel-->
+    <dimen name="mrl_panel_min_width">380dp</dimen>
+</resources>
\ No newline at end of file
diff --git a/vlc-android/res/values/dimens.xml b/vlc-android/res/values/dimens.xml
index 191bd3b9d..57c16381c 100644
--- a/vlc-android/res/values/dimens.xml
+++ b/vlc-android/res/values/dimens.xml
@@ -76,4 +76,7 @@
     <dimen name="progress_layout_height">24dp</dimen>
     <dimen name="dialog_sd_wisard_width">320dp</dimen>
     <dimen name="dialog_sd_wisard_height">420dp</dimen>
+
+    <!--MRLPanel-->
+    <dimen name="mrl_panel_min_width">300dp</dimen>
 </resources>
\ No newline at end of file
diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index 09a374c79..84f0a0435 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -219,6 +219,7 @@
     <string name="playback_speed_title">Save Playback Speed</string>
     <string name="playback_speed_summary">Remember the playback speed you set</string>
 
+    <string name="play_button">Play Button</string>
     <!-- Tips -->
     <string name="video_player_tips">Video player tips:</string>
     <string name="seek">Seek</string>
diff --git a/vlc-android/src/org/videolan/vlc/gui/network/MRLPanelFragment.kt b/vlc-android/src/org/videolan/vlc/gui/network/MRLPanelFragment.kt
index 02f962446..01cffef40 100644
--- a/vlc-android/src/org/videolan/vlc/gui/network/MRLPanelFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/network/MRLPanelFragment.kt
@@ -76,7 +76,7 @@ class MRLPanelFragment : DialogFragment(), View.OnKeyListener, TextView.OnEditor
         recyclerView.layoutManager = LinearLayoutManager(activity)
         recyclerView.adapter = adapter
         viewModel.observableHistory.observe(this, Observer { adapter.setList(it) })
-        binding.send.setOnClickListener(this)
+        binding.play.setOnClickListener(this)
 
         dialog.setTitle(R.string.open_mrl_dialog_title)
         return binding.root



More information about the Android mailing list