Explorar o código

fix layouts to handle poll with many options

make options scrollable

replace constraint layout with linear layouts + layout_weight="1"

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Marcel Hibbe %!s(int64=3) %!d(string=hai) anos
pai
achega
6ab5dace1c

+ 25 - 25
app/src/main/res/layout/dialog_poll_main.xml

@@ -16,34 +16,37 @@
   You should have received a copy of the GNU General Public License
   along with this program. If not, see <http://www.gnu.org/licenses/>.
 -->
-<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
-    android:layout_height="wrap_content"
+    android:layout_height="match_parent"
     android:padding="@dimen/standard_padding"
+    android:orientation="vertical"
     tools:background="@color/white">
 
-    <ImageView
-        android:id="@+id/message_poll_icon"
-        android:layout_width="wrap_content"
+    <LinearLayout
+        android:layout_width="match_parent"
         android:layout_height="wrap_content"
+        android:orientation="horizontal">
 
-        android:contentDescription="@null"
-        android:src="@drawable/ic_baseline_bar_chart_24"
-        app:layout_constraintStart_toStartOf="parent"
-        app:layout_constraintTop_toTopOf="parent"
-        app:tint="@color/high_emphasis_menu_icon" />
+        <ImageView
+            android:id="@+id/message_poll_icon"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:contentDescription="@null"
+            android:src="@drawable/ic_baseline_bar_chart_24"
+            app:tint="@color/high_emphasis_menu_icon" />
 
-    <androidx.emoji.widget.EmojiTextView
-        android:id="@+id/message_poll_title"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_marginStart="8dp"
-        android:textStyle="bold"
-        app:layout_constraintStart_toEndOf="@id/message_poll_icon"
-        app:layout_constraintTop_toTopOf="@+id/message_poll_icon"
-        tools:text="This is the poll title?" />
+        <androidx.emoji.widget.EmojiTextView
+            android:id="@+id/message_poll_title"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginStart="8dp"
+            android:textStyle="bold"
+            tools:text="This is the poll title?" />
+
+    </LinearLayout>
 
     <TextView
         android:id="@+id/poll_details_text"
@@ -51,16 +54,13 @@
         android:layout_height="wrap_content"
         android:layout_marginTop="16dp"
         android:textColor="@color/low_emphasis_text"
-        app:layout_constraintStart_toStartOf="@id/message_poll_icon"
-        app:layout_constraintTop_toBottomOf="@+id/message_poll_title"
         tools:text="Poll results - 93 votes" />
 
     <FrameLayout
         android:id="@+id/message_poll_content_fragment"
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
+        android:layout_height="0dp"
         android:layout_marginTop="16dp"
-        app:layout_constraintTop_toBottomOf="@id/poll_details_text"
-        tools:layout_height="400dp" />
+        android:layout_weight="1" />
 
-</androidx.constraintlayout.widget.ConstraintLayout>
+</LinearLayout>

+ 27 - 25
app/src/main/res/layout/dialog_poll_results.xml

@@ -16,19 +16,19 @@
   You should have received a copy of the GNU General Public License
   along with this program. If not, see <http://www.gnu.org/licenses/>.
 -->
-<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     xmlns:tools="http://schemas.android.com/tools"
-    tools:background="@color/white">
+    tools:background="@color/white"
+    android:orientation="vertical">
 
     <LinearLayout
         android:id="@+id/poll_results_list_wrapper"
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        app:layout_constraintStart_toStartOf="parent"
-        app:layout_constraintTop_toTopOf="parent">
+        android:layout_height="0dp"
+        android:layout_weight="1">
 
         <androidx.recyclerview.widget.RecyclerView
             android:id="@+id/poll_results_list"
@@ -37,25 +37,27 @@
             tools:listitem="@layout/poll_result_header_item" />
     </LinearLayout>
 
-    <com.google.android.material.button.MaterialButton
-        android:id="@+id/poll_results_end_poll_button"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:text="@string/polls_end_poll"
-        style="@style/OutlinedButton"
-        android:layout_marginEnd="@dimen/standard_margin"
-        app:cornerRadius="@dimen/button_corner_radius"
-        app:layout_constraintEnd_toStartOf="@+id/edit_vote_button"
-        app:layout_constraintTop_toBottomOf="@+id/poll_results_list_wrapper" />
-
-    <com.google.android.material.button.MaterialButton
-        android:id="@+id/edit_vote_button"
-        android:layout_width="wrap_content"
+    <LinearLayout
+        android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:text="@string/edit"
-        android:theme="@style/Button.Primary"
-        app:cornerRadius="@dimen/button_corner_radius"
-        app:layout_constraintEnd_toEndOf="parent"
-        app:layout_constraintTop_toBottomOf="@+id/poll_results_list_wrapper" />
+        android:gravity="end">
+
+        <com.google.android.material.button.MaterialButton
+            android:id="@+id/poll_results_end_poll_button"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="@string/polls_end_poll"
+            style="@style/OutlinedButton"
+            android:layout_marginEnd="@dimen/standard_margin"
+            app:cornerRadius="@dimen/button_corner_radius" />
+
+        <com.google.android.material.button.MaterialButton
+            android:id="@+id/edit_vote_button"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="@string/edit"
+            android:theme="@style/Button.Primary"
+            app:cornerRadius="@dimen/button_corner_radius" />
+    </LinearLayout>
 
-</androidx.constraintlayout.widget.ConstraintLayout>
+</LinearLayout>

+ 40 - 38
app/src/main/res/layout/dialog_poll_vote.xml

@@ -16,60 +16,62 @@
   You should have received a copy of the GNU General Public License
   along with this program. If not, see <http://www.gnu.org/licenses/>.
 -->
-<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     android:layout_width="match_parent"
-    android:layout_height="wrap_content"
+    android:layout_height="match_parent"
     xmlns:tools="http://schemas.android.com/tools"
-    tools:background="@color/white">
+    tools:background="@color/white"
+    android:orientation="vertical">
 
-    <LinearLayout
+    <ScrollView
         android:id="@+id/vote_options_wrapper"
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        app:layout_constraintStart_toStartOf="parent"
-        app:layout_constraintTop_toTopOf="parent"
-        android:orientation="vertical">
+        android:layout_height="0dp"
+        android:layout_weight="1"
+        android:padding="@dimen/standard_half_padding">
 
         <LinearLayout
-            android:id="@+id/vote_options_checkboxes_wrapper"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:orientation="vertical">
 
+            <LinearLayout
+                android:id="@+id/vote_options_checkboxes_wrapper"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="vertical" />
+
+            <RadioGroup
+                android:id="@+id/poll_vote_radio_group"
+                android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                tools:layout_height="400dp"
+                tools:layout_width="match_parent" />
         </LinearLayout>
+    </ScrollView>
 
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:gravity="end">
 
-        <RadioGroup
-            android:id="@+id/poll_vote_radio_group"
-            android:layout_height="wrap_content"
+        <com.google.android.material.button.MaterialButton
+            android:id="@+id/poll_vote_end_poll_button"
             android:layout_width="wrap_content"
-            tools:layout_height="400dp"
-            tools:layout_width="match_parent" />
+            android:layout_height="wrap_content"
+            android:text="@string/polls_end_poll"
+            style="@style/OutlinedButton"
+            android:layout_marginEnd="@dimen/standard_margin"
+            app:cornerRadius="@dimen/button_corner_radius" />
 
+        <com.google.android.material.button.MaterialButton
+            android:id="@+id/poll_vote_submit_button"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="@string/edit"
+            android:theme="@style/Button.Primary"
+            app:cornerRadius="@dimen/button_corner_radius" />
     </LinearLayout>
 
-
-    <com.google.android.material.button.MaterialButton
-        android:id="@+id/poll_vote_end_poll_button"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:text="@string/polls_end_poll"
-        style="@style/OutlinedButton"
-        android:layout_marginEnd="@dimen/standard_margin"
-        app:cornerRadius="@dimen/button_corner_radius"
-        app:layout_constraintEnd_toStartOf="@+id/poll_vote_submit_button"
-        app:layout_constraintTop_toBottomOf="@+id/vote_options_wrapper" />
-
-
-    <com.google.android.material.button.MaterialButton
-        android:id="@+id/poll_vote_submit_button"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        app:cornerRadius="@dimen/button_corner_radius"
-        android:text="@string/nc_common_submit"
-        android:theme="@style/Button.Primary"
-        app:layout_constraintEnd_toEndOf="parent"
-        app:layout_constraintTop_toBottomOf="@+id/vote_options_wrapper" />
-
-</androidx.constraintlayout.widget.ConstraintLayout>
+</LinearLayout>

+ 2 - 0
app/src/main/res/layout/poll_result_header_item.xml

@@ -3,6 +3,8 @@
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
+    android:paddingStart="@dimen/standard_half_padding"
+    android:paddingEnd="@dimen/standard_half_padding"
     tools:background="@color/white">
 
     <TextView

+ 2 - 0
app/src/main/res/layout/poll_result_voter_item.xml

@@ -3,6 +3,8 @@
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
+    android:paddingStart="@dimen/standard_half_padding"
+    android:paddingEnd="@dimen/standard_half_padding"
     android:paddingBottom="4dp"
     tools:background="@color/white">