浏览代码

Fix synced folder layout form control widgets alignment

Signed-off-by: Alice Gaudon <alice@gaudon.pro>
Alice Gaudon 5 年之前
父节点
当前提交
e77ffa00a8
共有 2 个文件被更改,包括 83 次插入163 次删除
  1. 82 163
      src/main/res/layout/synced_folders_settings_layout.xml
  2. 1 0
      src/main/res/values/dims.xml

+ 82 - 163
src/main/res/layout/synced_folders_settings_layout.xml

@@ -19,12 +19,11 @@
   License along with this program.  If not, see <http://www.gnu.org/licenses/>.
 -->
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-              android:id="@+id/root"
-              android:layout_width="wrap_content"
-              android:layout_height="wrap_content"
-              android:gravity="center"
-              android:orientation="vertical"
-              android:padding="@dimen/standard_padding">
+    android:id="@+id/root"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:gravity="center"
+    android:orientation="vertical">
 
     <LinearLayout
         android:id="@+id/top_title"
@@ -37,15 +36,14 @@
             android:layout_height="wrap_content"
             android:layout_weight="1"
             android:orientation="vertical"
-            android:paddingBottom="@dimen/standard_padding"
-            android:paddingTop="@dimen/standard_padding">
+            android:padding="@dimen/standard_padding">
 
             <TextView
                 android:id="@+id/synced_folders_settings_title"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:text="@string/synced_folders_preferences"
-                android:textAppearance="@style/TextAppearance.AppCompat.Title"/>
+                android:textAppearance="@style/TextAppearance.AppCompat.Title" />
 
             <TextView
                 android:id="@+id/synced_folders_settings_local_folder_path"
@@ -53,20 +51,15 @@
                 android:layout_height="wrap_content"
                 android:ellipsize="middle"
                 android:maxLines="2"
-                android:textColor="?android:attr/textColorSecondary"/>
-
+                android:textColor="?android:attr/textColorSecondary" />
         </LinearLayout>
 
         <LinearLayout
-            android:layout_width="wrap_content"
+            android:id="@+id/synced_folders_enable_switch_container"
+            android:layout_width="@dimen/synced_folders_control_width"
             android:layout_height="match_parent"
-            android:gravity="end|top"
-            android:orientation="vertical"
-            android:paddingLeft="@dimen/standard_padding"
-            android:paddingStart="@dimen/standard_padding"
-            android:paddingRight="@dimen/zero"
-            android:paddingEnd="@dimen/zero"
-            android:paddingTop="@dimen/standard_padding">
+            android:gravity="center"
+            android:padding="@dimen/standard_padding">
 
             <androidx.appcompat.widget.SwitchCompat
                 android:id="@+id/sync_enabled"
@@ -74,10 +67,8 @@
                 android:layout_height="wrap_content"
                 android:background="@null"
                 android:clickable="false"
-                android:focusable="false"/>
-
+                android:focusable="false" />
         </LinearLayout>
-
     </LinearLayout>
 
     <ScrollView
@@ -95,17 +86,13 @@
                 android:id="@+id/local_folder_container"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:baselineAligned="false"
-                android:clipToPadding="false"
-                android:gravity="center_vertical"
-                android:minHeight="?attr/listPreferredItemHeightSmall">
+                android:baselineAligned="false">
 
                 <RelativeLayout
                     android:layout_width="0dp"
                     android:layout_height="wrap_content"
                     android:layout_weight="1"
-                    android:paddingBottom="@dimen/standard_padding"
-                    android:paddingTop="@dimen/standard_padding">
+                    android:padding="@dimen/standard_padding">
 
                     <TextView
                         android:id="@+id/local_folder_title"
@@ -113,62 +100,51 @@
                         android:layout_height="wrap_content"
                         android:maxLines="2"
                         android:text="@string/prefs_synced_folders_local_path_title"
-                        android:textAppearance="?attr/textAppearanceListItem"/>
+                        android:textAppearance="?attr/textAppearanceListItem" />
 
                     <TextView
                         android:id="@+id/local_folder_summary"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
-                        android:layout_alignLeft="@id/local_folder_title"
-                        android:layout_alignStart="@id/local_folder_title"
                         android:layout_below="@id/local_folder_title"
+                        android:layout_alignStart="@id/local_folder_title"
+                        android:layout_alignLeft="@id/local_folder_title"
                         android:ellipsize="middle"
                         android:maxLines="2"
                         android:text="@string/choose_local_folder"
-                        android:textColor="?android:attr/textColorSecondary"/>
-
+                        android:textColor="?android:attr/textColorSecondary" />
                 </RelativeLayout>
 
                 <!-- Preference should place its actual preference widget here. -->
                 <LinearLayout
                     android:id="@+id/local_folder_frame"
-                    android:layout_width="wrap_content"
+                    android:layout_width="@dimen/synced_folders_control_width"
                     android:layout_height="match_parent"
-                    android:gravity="end|center_vertical"
-                    android:orientation="vertical"
-                    android:paddingLeft="@dimen/standard_padding"
-                    android:paddingStart="@dimen/standard_padding"
-                    android:paddingRight="@dimen/zero"
-                    android:paddingEnd="@dimen/zero">
+                    android:gravity="center"
+                    android:padding="@dimen/standard_padding">
 
                     <ImageView
                         android:id="@+id/local_folder_icon"
                         android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
+                        android:layout_height="fill_parent"
                         android:background="@null"
+                        android:contentDescription="@string/folder_icon"
                         android:padding="@dimen/standard_quarter_padding"
-                        android:src="@drawable/ic_folder_open"
-                        android:contentDescription="@string/folder_icon"/>
-
+                        android:src="@drawable/ic_folder_open" />
                 </LinearLayout>
-
             </LinearLayout>
 
             <LinearLayout
                 android:id="@+id/remote_folder_container"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:baselineAligned="false"
-                android:clipToPadding="false"
-                android:gravity="center_vertical"
-                android:minHeight="?attr/listPreferredItemHeightSmall">
+                android:baselineAligned="false">
 
                 <RelativeLayout
                     android:layout_width="0dp"
                     android:layout_height="wrap_content"
                     android:layout_weight="1"
-                    android:paddingBottom="@dimen/standard_padding"
-                    android:paddingTop="@dimen/standard_padding">
+                    android:padding="@dimen/standard_padding">
 
                     <TextView
                         android:id="@+id/remote_folder_title"
@@ -176,62 +152,51 @@
                         android:layout_height="wrap_content"
                         android:maxLines="2"
                         android:text="@string/prefs_synced_folders_remote_path_title"
-                        android:textAppearance="?attr/textAppearanceListItem"/>
+                        android:textAppearance="?attr/textAppearanceListItem" />
 
                     <TextView
                         android:id="@+id/remote_folder_summary"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
+                        android:layout_below="@id/remote_folder_title"
                         android:layout_alignStart="@id/remote_folder_title"
                         android:layout_alignLeft="@id/remote_folder_title"
-                        android:layout_below="@id/remote_folder_title"
                         android:ellipsize="middle"
                         android:maxLines="2"
                         android:text="@string/choose_remote_folder"
-                        android:textColor="?android:attr/textColorSecondary"/>
-
+                        android:textColor="?android:attr/textColorSecondary" />
                 </RelativeLayout>
 
                 <!-- Preference should place its actual preference widget here. -->
                 <LinearLayout
                     android:id="@+id/remote_folder_frame"
-                    android:layout_width="wrap_content"
+                    android:layout_width="@dimen/synced_folders_control_width"
                     android:layout_height="match_parent"
-                    android:gravity="end|center_vertical"
-                    android:orientation="vertical"
-                    android:paddingLeft="@dimen/standard_padding"
-                    android:paddingStart="@dimen/standard_padding"
-                    android:paddingEnd="@dimen/zero"
-                    android:paddingRight="@dimen/zero">
+                    android:gravity="center"
+                    android:padding="@dimen/standard_padding">
 
                     <ImageView
                         android:id="@+id/remote_folder_icon"
                         android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
+                        android:layout_height="fill_parent"
                         android:background="@null"
+                        android:contentDescription="@string/folder_icon"
                         android:padding="@dimen/standard_quarter_padding"
-                        android:src="@drawable/ic_folder_open"
-                        android:contentDescription="@string/folder_icon"/>
-
+                        android:src="@drawable/ic_folder_open" />
                 </LinearLayout>
-
             </LinearLayout>
 
             <LinearLayout
                 android:id="@+id/setting_instant_upload_on_wifi_container"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:baselineAligned="false"
-                android:clipToPadding="false"
-                android:gravity="center_vertical"
-                android:minHeight="?attr/listPreferredItemHeightSmall">
+                android:baselineAligned="false">
 
                 <RelativeLayout
                     android:layout_width="0dp"
                     android:layout_height="wrap_content"
                     android:layout_weight="1"
-                    android:paddingBottom="@dimen/standard_padding"
-                    android:paddingTop="@dimen/standard_padding">
+                    android:padding="@dimen/standard_padding">
 
                     <TextView
                         android:id="@+id/setting_instant_upload_on_wifi_label"
@@ -240,48 +205,37 @@
                         android:ellipsize="marquee"
                         android:maxLines="2"
                         android:text="@string/auto_upload_on_wifi"
-                        android:textAppearance="?attr/textAppearanceListItem"/>
-
+                        android:textAppearance="?attr/textAppearanceListItem" />
                 </RelativeLayout>
 
                 <LinearLayout
                     android:id="@+id/setting_instant_upload_on_wifi_frame"
-                    android:layout_width="wrap_content"
+                    android:layout_width="@dimen/synced_folders_control_width"
                     android:layout_height="match_parent"
-                    android:gravity="end|center_vertical"
-                    android:orientation="vertical"
-                    android:paddingLeft="@dimen/standard_padding"
-                    android:paddingStart="@dimen/standard_padding"
-                    android:paddingRight="@dimen/zero"
-                    android:paddingEnd="@dimen/zero">
+                    android:gravity="center"
+                    android:padding="@dimen/standard_padding">
 
                     <androidx.appcompat.widget.AppCompatCheckBox
                         android:id="@+id/setting_instant_upload_on_wifi_checkbox"
-                        android:layout_width="wrap_content"
+                        android:layout_width="32dp"
                         android:layout_height="wrap_content"
                         android:background="@null"
                         android:clickable="false"
-                        android:focusable="false"/>
-
+                        android:focusable="false" />
                 </LinearLayout>
-
             </LinearLayout>
 
             <LinearLayout
                 android:id="@+id/setting_instant_upload_on_charging_container"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:baselineAligned="false"
-                android:clipToPadding="false"
-                android:gravity="center_vertical"
-                android:minHeight="?attr/listPreferredItemHeightSmall">
+                android:baselineAligned="false">
 
                 <RelativeLayout
                     android:layout_width="0dp"
                     android:layout_height="wrap_content"
                     android:layout_weight="1"
-                    android:paddingBottom="@dimen/standard_padding"
-                    android:paddingTop="@dimen/standard_padding">
+                    android:padding="@dimen/standard_padding">
 
                     <TextView
                         android:id="@+id/setting_instant_upload_on_charging_label"
@@ -290,48 +244,37 @@
                         android:ellipsize="marquee"
                         android:maxLines="2"
                         android:text="@string/instant_upload_on_charging"
-                        android:textAppearance="?attr/textAppearanceListItem"/>
-
+                        android:textAppearance="?attr/textAppearanceListItem" />
                 </RelativeLayout>
 
                 <LinearLayout
                     android:id="@+id/setting_instant_upload_on_charging_frame"
-                    android:layout_width="wrap_content"
+                    android:layout_width="@dimen/synced_folders_control_width"
                     android:layout_height="match_parent"
-                    android:gravity="end|center_vertical"
-                    android:orientation="vertical"
-                    android:paddingLeft="@dimen/standard_padding"
-                    android:paddingStart="@dimen/standard_padding"
-                    android:paddingRight="@dimen/zero"
-                    android:paddingEnd="@dimen/zero">
+                    android:gravity="center"
+                    android:padding="@dimen/standard_padding">
 
                     <androidx.appcompat.widget.AppCompatCheckBox
                         android:id="@+id/setting_instant_upload_on_charging_checkbox"
-                        android:layout_width="wrap_content"
+                        android:layout_width="32dp"
                         android:layout_height="wrap_content"
                         android:background="@null"
                         android:clickable="false"
-                        android:focusable="false"/>
-
+                        android:focusable="false" />
                 </LinearLayout>
-
             </LinearLayout>
 
             <LinearLayout
                 android:id="@+id/setting_instant_upload_existing_container"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:baselineAligned="false"
-                android:clipToPadding="false"
-                android:gravity="center_vertical"
-                android:minHeight="?attr/listPreferredItemHeightSmall">
+                android:baselineAligned="false">
 
                 <RelativeLayout
                     android:layout_width="0dp"
                     android:layout_height="wrap_content"
                     android:layout_weight="1"
-                    android:paddingBottom="@dimen/standard_padding"
-                    android:paddingTop="@dimen/standard_padding">
+                    android:padding="@dimen/standard_padding">
 
                     <TextView
                         android:id="@+id/setting_instant_upload_existing_label"
@@ -340,48 +283,37 @@
                         android:ellipsize="marquee"
                         android:singleLine="true"
                         android:text="@string/instant_upload_existing"
-                        android:textAppearance="?attr/textAppearanceListItem"/>
-
+                        android:textAppearance="?attr/textAppearanceListItem" />
                 </RelativeLayout>
 
                 <LinearLayout
                     android:id="@+id/setting_instant_upload_existing"
-                    android:layout_width="wrap_content"
+                    android:layout_width="@dimen/synced_folders_control_width"
                     android:layout_height="match_parent"
-                    android:gravity="end|center_vertical"
-                    android:orientation="vertical"
-                    android:paddingLeft="@dimen/standard_padding"
-                    android:paddingStart="@dimen/standard_padding"
-                    android:paddingRight="@dimen/zero"
-                    android:paddingEnd="@dimen/zero">
+                    android:gravity="center"
+                    android:padding="@dimen/standard_padding">
 
                     <androidx.appcompat.widget.AppCompatCheckBox
                         android:id="@+id/setting_instant_upload_existing_checkbox"
-                        android:layout_width="wrap_content"
+                        android:layout_width="32dp"
                         android:layout_height="wrap_content"
                         android:background="@null"
                         android:clickable="false"
-                        android:focusable="false"/>
-
+                        android:focusable="false" />
                 </LinearLayout>
-
             </LinearLayout>
 
             <LinearLayout
                 android:id="@+id/setting_instant_upload_path_use_subfolders_container"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:baselineAligned="false"
-                android:clipToPadding="false"
-                android:gravity="center_vertical"
-                android:minHeight="?attr/listPreferredItemHeightSmall">
+                android:baselineAligned="false">
 
                 <RelativeLayout
                     android:layout_width="0dp"
                     android:layout_height="wrap_content"
                     android:layout_weight="1"
-                    android:paddingBottom="@dimen/standard_padding"
-                    android:paddingTop="@dimen/standard_padding">
+                    android:padding="@dimen/standard_padding">
 
                     <TextView
                         android:id="@+id/setting_instant_upload_path_use_subfolders_label"
@@ -390,44 +322,37 @@
                         android:ellipsize="marquee"
                         android:maxLines="2"
                         android:text="@string/prefs_instant_upload_path_use_subfolders_title"
-                        android:textAppearance="?attr/textAppearanceListItem"/>
+                        android:textAppearance="?attr/textAppearanceListItem" />
 
                     <TextView
                         android:id="@+id/setting_instant_upload_path_use_subfolders_summary"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
-                        android:layout_alignLeft="@id/setting_instant_upload_path_use_subfolders_label"
-                        android:layout_alignStart="@id/setting_instant_upload_path_use_subfolders_label"
                         android:layout_below="@id/setting_instant_upload_path_use_subfolders_label"
+                        android:layout_alignStart="@id/setting_instant_upload_path_use_subfolders_label"
+                        android:layout_alignLeft="@id/setting_instant_upload_path_use_subfolders_label"
                         android:ellipsize="end"
                         android:maxLines="2"
                         android:text="@string/prefs_instant_upload_path_use_subfolders_summary"
-                        android:textColor="?android:attr/textColorSecondary"/>
-
+                        android:textColor="?android:attr/textColorSecondary" />
                 </RelativeLayout>
 
                 <!-- Preference should place its actual preference widget here. -->
                 <LinearLayout
                     android:id="@+id/setting_instant_upload_path_use_subfolders_frame"
-                    android:layout_width="wrap_content"
+                    android:layout_width="@dimen/synced_folders_control_width"
                     android:layout_height="match_parent"
-                    android:gravity="end|center_vertical"
-                    android:orientation="vertical"
-                    android:paddingLeft="@dimen/standard_padding"
-                    android:paddingStart="@dimen/standard_padding"
-                    android:paddingRight="@dimen/zero"
-                    android:paddingEnd="@dimen/zero">
+                    android:gravity="center"
+                    android:padding="@dimen/standard_padding">
 
                     <androidx.appcompat.widget.AppCompatCheckBox
                         android:id="@+id/setting_instant_upload_path_use_subfolders_checkbox"
-                        android:layout_width="wrap_content"
+                        android:layout_width="32dp"
                         android:layout_height="wrap_content"
                         android:background="@null"
                         android:clickable="false"
-                        android:focusable="false"/>
-
+                        android:focusable="false" />
                 </LinearLayout>
-
             </LinearLayout>
 
             <LinearLayout
@@ -439,8 +364,7 @@
                 android:gravity="center_vertical"
                 android:minHeight="?attr/listPreferredItemHeightSmall"
                 android:orientation="vertical"
-                android:paddingBottom="@dimen/standard_padding"
-                android:paddingTop="@dimen/standard_padding">
+                android:padding="@dimen/standard_padding">
 
                 <TextView
                     android:id="@+id/setting_instant_behaviour_title"
@@ -449,7 +373,7 @@
                     android:ellipsize="marquee"
                     android:maxLines="2"
                     android:text="@string/prefs_instant_behaviour_title"
-                    android:textAppearance="?attr/textAppearanceListItem"/>
+                    android:textAppearance="?attr/textAppearanceListItem" />
 
                 <TextView
                     android:id="@+id/setting_instant_behaviour_summary"
@@ -458,49 +382,44 @@
                     android:ellipsize="end"
                     android:maxLines="2"
                     android:text="@string/placeholder_filename"
-                    android:textColor="?android:attr/textColorSecondary"/>
-
+                    android:textColor="?android:attr/textColorSecondary" />
             </LinearLayout>
-
         </LinearLayout>
-
     </ScrollView>
 
     <RelativeLayout
         android:layout_width="match_parent"
-        android:layout_height="wrap_content">
+        android:layout_height="wrap_content"
+        android:padding="@dimen/standard_padding">
 
         <com.google.android.material.button.MaterialButton
             android:id="@+id/delete"
             style="@style/Button.Borderless.Destructive"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:layout_alignParentLeft="true"
             android:layout_alignParentStart="true"
-            android:text="@string/common_delete"/>
+            android:layout_alignParentLeft="true"
+            android:text="@string/common_delete" />
 
         <LinearLayout
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:layout_alignParentRight="true"
-            android:layout_alignParentEnd="true">
+            android:layout_alignParentEnd="true"
+            android:layout_alignParentRight="true">
 
             <com.google.android.material.button.MaterialButton
                 android:id="@+id/cancel"
                 style="@style/Button.Borderless"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:text="@string/common_cancel"/>
+                android:text="@string/common_cancel" />
 
             <com.google.android.material.button.MaterialButton
                 android:id="@+id/save"
                 style="@style/Button.Borderless"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:text="@string/common_save"/>
-
+                android:text="@string/common_save" />
         </LinearLayout>
-
     </RelativeLayout>
-
 </LinearLayout>

+ 1 - 0
src/main/res/values/dims.xml

@@ -135,6 +135,7 @@
     <dimen name="synced_folders_item_type_layout_height">32dp</dimen>
     <dimen name="synced_folders_item_type_layout_right_end_margin">24dp</dimen>
     <dimen name="synced_folders_recycler_view_layout_margin">-3dp</dimen>
+    <dimen name="synced_folders_control_width">80dp</dimen>
     <dimen name="toolbar_user_information_layout_margin">12dp</dimen>
     <dimen name="bottom_sheet_text_size">16sp</dimen>
     <dimen name="permission_dialog_text_size">18sp</dimen>