Browse Source

Review some margins in details view. Add method to show more than one item in share users list view (details view)

masensio 9 years ago
parent
commit
3ddc2046d9

+ 15 - 12
res/layout/file_details_fragment.xml

@@ -34,6 +34,7 @@
                     android:id="@+id/fdScrollView"
                     android:layout_width="match_parent"
                     android:layout_height="match_parent"
+                    android:orientation="vertical"
                     android:fillViewport="true">
             <LinearLayout
                 android:layout_width="match_parent"
@@ -89,7 +90,8 @@
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
                     android:layout_marginLeft="16dp"
-                    android:layout_marginRight="16dp">
+                    android:layout_marginRight="16dp"
+                    android:layout_marginBottom="8dp">
 
                     <TableRow
                         android:id="@+id/fdTypeRow"
@@ -109,7 +111,8 @@
                             android:layout_width="wrap_content"
                             android:layout_height="wrap_content"
                             android:text="@string/placeholder_filetype"
-                            android:textSize="16sp"/>
+                            android:textSize="16sp"
+                            android:layout_marginLeft="4dp" />
 
                     </TableRow>
                     <TableRow
@@ -129,7 +132,8 @@
                             android:layout_width="wrap_content"
                             android:layout_height="wrap_content"
                             android:text="@string/placeholder_filesize"
-                            android:textSize="16sp" />
+                            android:textSize="16sp"
+                            android:layout_marginLeft="4dp" />
 
                     </TableRow>
                     <TableRow
@@ -150,7 +154,8 @@
                             android:layout_width="wrap_content"
                             android:layout_height="wrap_content"
                             android:text="@string/placeholder_timestamp"
-                            android:textSize="16sp" />
+                            android:textSize="16sp"
+                            android:layout_marginLeft="4dp" />
 
                     </TableRow>
                     <TableRow
@@ -170,7 +175,8 @@
                             android:layout_width="wrap_content"
                             android:layout_height="wrap_content"
                             android:text="@string/placeholder_timestamp"
-                            android:textSize="16sp"/>
+                            android:textSize="16sp"
+                            android:layout_marginLeft="4dp" />
 
                     </TableRow>
 
@@ -179,14 +185,13 @@
                 <View
                     android:layout_width="match_parent"
                     android:layout_height="1dp"
-                    android:layout_margin = "10dp"
+                    android:layout_margin = "5dp"
                     android:background="@color/list_divider_background"/>
 
                 <RelativeLayout
                     android:id="@+id/fdProgressAndControl"
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
-                    android:layout_below="@+id/fdDetailsContainer"
                     android:gravity="center_horizontal"
                     android:layout_margin="16dp">
                     <Switch
@@ -195,7 +200,6 @@
                         android:layout_height="wrap_content"
                         android:textSize="16sp"
                         android:text="@string/favorite"
-                        android:textColor="@color/textColor"
                         android:layout_gravity="start"/>
 
                     <LinearLayout
@@ -246,13 +250,13 @@
                 <View
                     android:layout_width="match_parent"
                     android:layout_height="1dp"
-                    android:layout_margin = "10dp"
+                    android:layout_margin = "5dp"
                     android:background="@color/list_divider_background"/>
 
                 <LinearLayout
                     android:id="@+id/fdShareContainer"
                     android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
+                    android:layout_height="match_parent"
                     android:orientation="vertical"
                     android:layout_margin="16dp">
                     <TextView
@@ -261,7 +265,6 @@
                         android:layout_height="wrap_content"
                         android:textSize="16sp"
                         android:text="@string/action_share"
-                        android:textColor="@color/textColor"
                         android:layout_gravity="start"/>
                     <TextView
                         android:id="@+id/fdSharebyLink"
@@ -278,7 +281,7 @@
                         android:textSize="16sp"
                         android:text="@string/filedetails_share_users_with_access"
                         android:layout_gravity="start"
-                        android:layout_marginTop="8dp"/>
+                        android:layout_marginTop="12dp"/>
 
                     <ListView
                         android:layout_width="match_parent"

+ 4 - 19
res/layout/file_details_share_user_item.xml

@@ -16,30 +16,21 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 -->
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-              android:layout_width="match_parent"
-              android:layout_height="match_parent"
-              android:orientation="vertical">
-
-    <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:orientation="horizontal"
-        android:weightSum="1"
-        android:longClickable="true">
+        android:weightSum="1">
 
         <ImageView
             android:id="@+id/userIcon"
-            android:layout_width="24sp"
-            android:layout_height="24sp"
-            android:layout_marginLeft="16sp"
-            android:layout_gravity="center_vertical"
+            android:layout_width="32sp"
+            android:layout_height="32sp"
             android:src="@drawable/ic_account_circle_dark"
-            />
+            android:layout_gravity="center_vertical"/>
 
         <TextView
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:layout_weight="0.9"
             android:textSize="16dip"
             android:text="@string/username"
             android:id="@+id/userOrGroupName"
@@ -47,10 +38,4 @@
             android:singleLine="true"
             android:ellipsize="middle"
             android:textColor="@color/owncloud_blue"/>
-    </LinearLayout>
-
-    <View
-        android:layout_width="match_parent"
-        android:layout_height="1dp"
-        android:background="@color/list_divider_background"></View>
 </LinearLayout>

+ 27 - 1
src/com/owncloud/android/ui/fragment/FileDetailFragment.java

@@ -33,6 +33,7 @@ import android.view.View.OnClickListener;
 import android.view.ViewGroup;
 import android.widget.CompoundButton;
 import android.widget.ImageView;
+import android.widget.ListAdapter;
 import android.widget.ListView;
 import android.widget.ProgressBar;
 import android.widget.RelativeLayout;
@@ -527,7 +528,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
         // Get Users and Groups
         if (((FileActivity) getActivity()).getStorageManager() != null) {
             FileDataStorageManager fileDataStorageManager = ((FileActivity) getActivity()).getStorageManager();
-            mShares =fileDataStorageManager.getSharesWithForAFile(
+            mShares = fileDataStorageManager.getSharesWithForAFile(
                     getFile().getRemotePath(),mAccount.name
             );
 
@@ -554,12 +555,37 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
             usersList.setVisibility(View.VISIBLE);
             usersList.setAdapter(mUserGroupsAdapter);
             noList.setVisibility(View.GONE);
+            setListViewHeightBasedOnChildren(usersList);
 
         } else {
             usersList.setVisibility(View.GONE);
             noList.setVisibility(View.VISIBLE);
         }
     }
+
+    /* Fix scroll in listview when the parent is ac ScrollView */
+    private static void setListViewHeightBasedOnChildren(ListView listView) {
+        ListAdapter listAdapter = listView.getAdapter();
+        if (listAdapter == null) {
+            return;
+        }
+        int desiredWidth = View.MeasureSpec.makeMeasureSpec(listView.getWidth(), View.MeasureSpec.AT_MOST);
+        int totalHeight = 0;
+        View view = null;
+        for (int i = 0; i < listAdapter.getCount(); i++) {
+            view = listAdapter.getView(i, view, listView);
+            if (i == 0) {
+                view.setLayoutParams(new ViewGroup.LayoutParams(desiredWidth, ViewGroup.LayoutParams.WRAP_CONTENT));
+            }
+            view.measure(desiredWidth, View.MeasureSpec.UNSPECIFIED);
+            totalHeight += view.getMeasuredHeight();
+        }
+        ViewGroup.LayoutParams params = listView.getLayoutParams();
+        params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
+        listView.setLayoutParams(params);
+        listView.requestLayout();
+    }
+
     /**
      * Enables or disables buttons for a file being downloaded
      */