ソースを参照

Styled blog view.

seavenois 9 年 前
コミット
e7b71723b2

+ 6 - 4
app/src/main/java/com/ivalentin/margolariak/ActivityLayout.java

@@ -87,9 +87,10 @@ public class ActivityLayout extends Fragment{
                 //Create a new row
                 //Create a new row
                 entry = (LinearLayout) factory.inflate(R.layout.row_activity_future, null);
                 entry = (LinearLayout) factory.inflate(R.layout.row_activity_future, 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);
                 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);
                 entry.setLayoutParams(layoutParams);
 
 
                 //Set title
                 //Set title
@@ -178,9 +179,10 @@ public class ActivityLayout extends Fragment{
             //Create a new row
             //Create a new row
             entry = (LinearLayout) factory.inflate(R.layout.row_activity_past, null);
             entry = (LinearLayout) factory.inflate(R.layout.row_activity_past, 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);
             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);
             entry.setLayoutParams(layoutParams);
 
 
             //Set title
             //Set title

+ 6 - 5
app/src/main/java/com/ivalentin/margolariak/BlogLayout.java

@@ -158,9 +158,10 @@ public class BlogLayout extends Fragment{
             //Create a new row
             //Create a new row
             entry = (LinearLayout) factory.inflate(R.layout.row_blog, null);
             entry = (LinearLayout) factory.inflate(R.layout.row_blog, 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);
             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);
             entry.setLayoutParams(layoutParams);
 
 
             //Set title
             //Set title
@@ -169,9 +170,6 @@ public class BlogLayout extends Fragment{
 
 
             //Set text
             //Set text
             String text = Html.fromHtml(cursor.getString(2)).toString();
             String text = Html.fromHtml(cursor.getString(2)).toString();
-            if (text.length() > 180){
-                text = text.substring(0, 180) + "...";
-            }
             TextView tvText = (TextView) entry.findViewById(R.id.tv_row_blog_text);
             TextView tvText = (TextView) entry.findViewById(R.id.tv_row_blog_text);
             tvText.setText(text);
             tvText.setText(text);
 
 
@@ -206,6 +204,9 @@ public class BlogLayout extends Fragment{
                     new DownloadImage(GM.SERVER + "/img/blog/miniature/" + image, this.getActivity().getFilesDir().toString() + "/img/blog/miniature/" + image, iv, GM.IMG_MINIATURE).execute();
                     new DownloadImage(GM.SERVER + "/img/blog/miniature/" + image, this.getActivity().getFilesDir().toString() + "/img/blog/miniature/" + image, iv, GM.IMG_MINIATURE).execute();
                 }
                 }
             }
             }
+            else{
+                iv.setVisibility(View.GONE);
+            }
             cursorImage.close();
             cursorImage.close();
 
 
             //Count comments
             //Count comments

+ 0 - 1
app/src/main/res/layout/fragment_layout_activities.xml

@@ -49,7 +49,6 @@
                 android:orientation="vertical"
                 android:orientation="vertical"
                 android:layout_width="match_parent"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
                 android:layout_height="match_parent"
-                android:layout_margin="7dp"
                 android:id="@+id/ll_activities_future_list" />
                 android:id="@+id/ll_activities_future_list" />
         </LinearLayout>
         </LinearLayout>
 
 

+ 12 - 7
app/src/main/res/layout/fragment_layout_blog.xml

@@ -5,8 +5,6 @@
     android:layout_width="fill_parent"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:layout_height="wrap_content"
     android:id="@+id/scrollView3"
     android:id="@+id/scrollView3"
-    android:background="@color/background_app"
-    android:padding="7dp"
     tools:ignore="Overdraw">
     tools:ignore="Overdraw">
 
 
     <LinearLayout
     <LinearLayout
@@ -15,16 +13,23 @@
         android:layout_height="fill_parent"
         android:layout_height="fill_parent"
         android:layout_weight="1"
         android:layout_weight="1"
         android:background="@drawable/section"
         android:background="@drawable/section"
-        android:padding="5dp">
+        android:layout_margin="10dp">
 
 
         <TextView
         <TextView
-            android:layout_width="wrap_content"
+            android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_height="wrap_content"
-            android:textAppearance="?android:attr/textAppearanceLarge"
             android:text="@string/section_title_blog"
             android:text="@string/section_title_blog"
+            android:textAppearance="?android:attr/textAppearanceLarge"
             android:textStyle="bold"
             android:textStyle="bold"
-            android:layout_marginBottom="10dp"
-            android:layout_margin="5dp" />
+            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"/>
 
 
         <LinearLayout
         <LinearLayout
             android:orientation="vertical"
             android:orientation="vertical"

+ 2 - 1
app/src/main/res/layout/row_activity_future.xml

@@ -29,7 +29,8 @@
             android:layout_gravity="center_vertical"
             android:layout_gravity="center_vertical"
             android:background="@color/image_border"
             android:background="@color/image_border"
             android:padding="0.5dp"
             android:padding="0.5dp"
-            android:layout_margin="3dp"/>
+            android:layout_margin="3dp"
+            android:adjustViewBounds="true"/>
 
 
         <LinearLayout
         <LinearLayout
             android:orientation="vertical"
             android:orientation="vertical"

+ 2 - 1
app/src/main/res/layout/row_activity_past.xml

@@ -37,7 +37,8 @@
             android:padding="0.5dp"
             android:padding="0.5dp"
             android:layout_margin="2dp"
             android:layout_margin="2dp"
             android:layout_gravity="top"
             android:layout_gravity="top"
-            android:maxHeight="100dp"/>
+            android:maxHeight="100dp"
+            android:adjustViewBounds="true"/>
 
 
         <LinearLayout
         <LinearLayout
             android:orientation="vertical"
             android:orientation="vertical"

+ 50 - 18
app/src/main/res/layout/row_blog.xml

@@ -5,12 +5,15 @@
     android:layout_width="match_parent"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:layout_height="wrap_content"
     android:background="@drawable/entry"
     android:background="@drawable/entry"
-    android:padding="4dp">
+    android:padding="7dp"
+    android:layout_margin="8dp">
 
 
     <TextView
     <TextView
         android:layout_width="wrap_content"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_height="wrap_content"
-        android:textAppearance="?android:attr/textAppearanceLarge"
+        android:textAppearance="?android:attr/textAppearanceMedium"
+        android:textColor="@color/entry_title"
+        android:textStyle="bold"
         android:id="@+id/tv_row_blog_title" />
         android:id="@+id/tv_row_blog_title" />
 
 
     <TextView
     <TextView
@@ -26,31 +29,60 @@
         android:layout_height="match_parent">
         android:layout_height="match_parent">
 
 
         <ImageView
         <ImageView
-            android:layout_width="fill_parent"
+            android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_height="wrap_content"
             android:id="@+id/iv_row_blog_image"
             android:id="@+id/iv_row_blog_image"
-            android:maxWidth="130dp"
+            android:maxWidth="110dp"
             android:contentDescription="@string/app_cdesc"
             android:contentDescription="@string/app_cdesc"
-            android:layout_weight=".8"
+            android:minHeight="30dp"
+            android:minWidth="30dp"
+            android:layout_gravity="top|center_vertical"
+            android:background="@color/image_border"
+            android:padding="0.5dp"
             android:layout_margin="3dp"
             android:layout_margin="3dp"
-            android:layout_gravity="center_vertical"
-            android:adjustViewBounds="true"/>
+            android:adjustViewBounds="true"
+            android:maxHeight="100dp"/>
 
 
-        <TextView
-            android:layout_width="fill_parent"
+        <LinearLayout
+            android:orientation="vertical"
+            android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_height="wrap_content"
-            android:id="@+id/tv_row_blog_text"
-            android:layout_weight=".2"
-            android:textAppearance="@android:style/TextAppearance.Medium"
-            android:layout_margin="5dp" />
+            android:layout_gravity="top">
+
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:id="@+id/tv_row_blog_text"
+                android:textAppearance="@android:style/TextAppearance.Medium"
+                android:layout_margin="5dp"
+                android:maxLines="4"
+                android:minHeight="30dp"/>
+
+            <ImageView
+                android:layout_width="match_parent"
+                android:layout_weight="1"
+                android:layout_height="40dp"
+                android:layout_marginTop="-40dp"
+                android:background="@drawable/gradient_v_white"
+                android:adjustViewBounds="true"/>
+
+        </LinearLayout>
+
     </LinearLayout>
     </LinearLayout>
 
 
-    <LinearLayout
-        android:orientation="vertical"
+    <ImageView
         android:layout_width="match_parent"
         android:layout_width="match_parent"
-        android:layout_height="2dp"
-        android:background="@color/background_separator"
-        android:layout_margin="10dp"/>
+        android:layout_height="0.5dp"
+        android:background="@color/image_border"
+        android:layout_margin="10dp"
+        android:layout_marginBottom="1dp"
+        android:layout_marginEnd="10dp"
+        android:layout_marginLeft="10dp"
+        android:layout_marginRight="10dp"
+        android:layout_marginStart="10dp"
+        android:layout_marginTop="3dp"
+        android:alpha="0.5"
+        android:adjustViewBounds="false"/>
 
 
     <LinearLayout
     <LinearLayout
         android:orientation="horizontal"
         android:orientation="horizontal"