ソースを参照

Styled Gallery fragment.

seavenois 9 年 前
コミット
b9a70d15ed

+ 11 - 2
app/src/main/java/com/ivalentin/margolariak/GalleryLayout.java

@@ -18,6 +18,7 @@ import android.widget.LinearLayout;
 import android.widget.TextView;
 
 import java.io.File;
+import java.util.Random;
 
 /**
  * Fragment of the gallery section.
@@ -84,9 +85,10 @@ public class GalleryLayout extends Fragment{
             //Create a new row
             entry = (LinearLayout) factory.inflate(R.layout.row_gallery, null);
 
-            //Set margins
+            //Set margins TODO: I dont know why it doesnt read margins from the xml
             LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
-            layoutParams.setMargins(10, 10, 10, 25);
+			int margin = (int) (9 * getActivity().getResources().getDisplayMetrics().density);
+            layoutParams.setMargins(margin, margin, margin, margin);
             entry.setLayoutParams(layoutParams);
 
             //Set title
@@ -109,6 +111,7 @@ public class GalleryLayout extends Fragment{
 
             //Loop
             int i = 0;
+            Random r;
             while (cursorImage.moveToNext()){
                 String image = cursorImage.getString(1);
 
@@ -127,6 +130,12 @@ public class GalleryLayout extends Fragment{
                     fpath.mkdirs();
                     new DownloadImage(GM.SERVER + "/img/galeria/miniature/" + image, this.getActivity().getFilesDir().toString() + "/img/galeria/miniature/" + image, preview[i], GM.IMG_MINIATURE).execute();
                 }
+
+                //Rotate the image
+                r = new Random();
+                int rot = r.nextInt(31) - 15;
+                preview[i].setRotation(rot);
+
                 i ++;
             }
 

+ 31 - 20
app/src/main/res/layout/fragment_layout_gallery.xml

@@ -5,15 +5,13 @@
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:id="@+id/scrollView3"
-    android:background="@color/background_app"
-    android:padding="7dp"
     tools:ignore="Overdraw">
 
     <LinearLayout
         android:orientation="vertical"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:paddingBottom="20dp">
+        >
 
         <LinearLayout
             android:orientation="vertical"
@@ -57,27 +55,40 @@
 
         </LinearLayout>
 
+        <TextView
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:text="@string/gallery_albums"
+            android:textAppearance="?android:attr/textAppearanceLarge"
+            android:textStyle="bold"
+            tools:layout_width="match_parent"
+            android:background="@drawable/section_title"
+            android:paddingBottom="4dp"
+            android:paddingEnd="10dp"
+            android:paddingLeft="20dp"
+            android:paddingRight="10dp"
+            android:paddingStart="20dp"
+            android:paddingTop="4dp"
+            android:textColor="@color/section_title"
+            android:layout_marginTop="10dp"
+            android:layout_marginLeft="10dp"
+            android:layout_marginRight="10dp"
+            android:layout_marginStart="10dp"
+            android:layout_marginEnd="10dp"
+            android:layout_marginBottom="-1.5dp"/>
+
         <LinearLayout
             android:orientation="vertical"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
-            android:background="@drawable/section"
-            android:padding="7dp"
-            android:layout_marginTop="20dp">
-
-            <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:textAppearance="?android:attr/textAppearanceLarge"
-                android:text="@string/gallery_albums"
-                android:textStyle="bold"/>
+            android:id="@+id/ll_gallery_album_list"
+            android:layout_marginBottom="10dp"
+            android:layout_marginEnd="10dp"
+            android:layout_marginLeft="10dp"
+            android:layout_marginRight="10dp"
+            android:layout_marginStart="10dp"
+            android:layout_marginTop="0dp"
+            android:background="@drawable/section_large"/>
 
-            <LinearLayout
-                android:orientation="vertical"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:layout_marginBottom="10dp"
-                android:id="@+id/ll_gallery_album_list"/>
-        </LinearLayout>
     </LinearLayout>
 </com.ivalentin.margolariak.CustomScrollView>

+ 48 - 36
app/src/main/res/layout/row_gallery.xml

@@ -1,17 +1,25 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:orientation="vertical" android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:background="@drawable/entry"
-    android:padding="7dp">
+              android:orientation="vertical" android:layout_width="match_parent"
+              android:layout_height="wrap_content"
+              android:background="@drawable/entry"
+              android:padding="7dp"
+              android:layout_margin="8dp">
+
+    <TextView
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:textAppearance="?android:attr/textAppearanceMedium"
+        android:textColor="@color/entry_title"
+        android:textStyle="bold"
+        android:id="@+id/tv_row_gallery_title" />
 
     <RelativeLayout
         android:layout_width="wrap_content"
-        android:layout_height="match_parent"
+        android:layout_height="wrap_content"
         android:layout_gravity="center"
-        android:padding="15dp"
-        android:background="@drawable/album"
-        android:layout_margin="15dp">
+        android:layout_margin="0dp"
+        android:layout_marginBottom="10dp">
 
         <ImageView
             android:contentDescription="@string/app_cdesc"
@@ -23,14 +31,18 @@
             android:layout_alignParentLeft="false"
             android:layout_alignParentRight="false"
             android:layout_alignParentBottom="false"
-            android:layout_marginEnd="90dp"
-            android:layout_marginBottom="90dp"
-            android:padding="1dp"
+            android:layout_marginEnd="110dp"
+            android:layout_marginBottom="110dp"
+            android:padding="2dp"
             android:layout_alignParentEnd="false"
             android:layout_alignParentStart="false"
             android:maxHeight="180dp"
             android:src="@drawable/photo_placeholder_thumb"
-            android:adjustViewBounds="true"/>
+            android:adjustViewBounds="true"
+            android:layout_marginTop="20dp"
+            android:layout_marginStart="20dp"
+            android:layout_marginRight="20dp"
+            android:layout_marginLeft="20dp"/>
 
         <ImageView
             android:contentDescription="@string/app_cdesc"
@@ -42,15 +54,17 @@
             android:layout_alignParentLeft="false"
             android:layout_alignParentEnd="false"
             android:layout_alignParentBottom="false"
-            android:layout_marginEnd="60dp"
-            android:layout_marginBottom="60dp"
-            android:layout_marginStart="30dp"
-            android:layout_marginTop="30dp"
-            android:padding="1dp"
+            android:layout_marginEnd="80dp"
+            android:layout_marginBottom="80dp"
+            android:layout_marginStart="50dp"
+            android:layout_marginTop="50dp"
+            android:padding="2dp"
             android:layout_alignParentStart="false"
             android:maxHeight="180dp"
             android:src="@drawable/photo_placeholder_thumb"
-            android:adjustViewBounds="true"/>
+            android:adjustViewBounds="true"
+            android:layout_marginLeft="20dp"
+            android:layout_marginRight="20dp"/>
 
         <ImageView
             android:contentDescription="@string/app_cdesc"
@@ -62,15 +76,17 @@
             android:layout_alignParentLeft="false"
             android:layout_alignParentEnd="false"
             android:layout_alignParentBottom="false"
-            android:layout_marginStart="60dp"
-            android:layout_marginTop="60dp"
-            android:padding="1dp"
+            android:layout_marginStart="80dp"
+            android:layout_marginTop="80dp"
+            android:padding="2dp"
             android:layout_alignParentStart="false"
             android:maxHeight="180dp"
-            android:layout_marginEnd="30dp"
-            android:layout_marginBottom="30dp"
+            android:layout_marginEnd="50dp"
+            android:layout_marginBottom="50dp"
             android:src="@drawable/photo_placeholder_thumb"
-            android:adjustViewBounds="true"/>
+            android:adjustViewBounds="true"
+            android:layout_marginLeft="20dp"
+            android:layout_marginRight="20dp"/>
 
         <ImageView
             android:contentDescription="@string/app_cdesc"
@@ -82,23 +98,19 @@
             android:layout_alignParentLeft="false"
             android:layout_alignParentEnd="false"
             android:layout_alignParentBottom="false"
-            android:layout_marginStart="90dp"
-            android:layout_marginTop="90dp"
-            android:padding="1dp"
+            android:layout_marginStart="110dp"
+            android:layout_marginTop="110dp"
+            android:padding="2dp"
             android:layout_alignParentStart="false"
             android:maxHeight="180dp"
             android:src="@drawable/photo_placeholder_thumb"
-            android:adjustViewBounds="true"/>
+            android:adjustViewBounds="true"
+            android:layout_marginBottom="20dp"
+            android:layout_marginEnd="20dp"
+            android:layout_marginLeft="20dp"
+            android:layout_marginRight="20dp"/>
     </RelativeLayout>
 
-    <TextView
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:textAppearance="@android:style/TextAppearance.Large"
-        android:id="@+id/tv_row_gallery_title"
-        android:layout_marginTop="15dp"
-        android:layout_gravity="center_horizontal" />
-
     <TextView
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"