Răsfoiți Sursa

Styles for the La Blanca section. Improved date formatter.

Iñigo Valentin 9 ani în urmă
părinte
comite
951af22793

+ 1 - 1
app/src/main/java/com/ivalentin/margolariak/ActivityFutureLayout.java

@@ -111,7 +111,7 @@ public class ActivityFutureLayout extends Fragment implements OnMapReadyCallback
 		}
 		wvText.loadDataWithBaseURL(null, cursor.getString(2), "text/html", "utf-8", null);
 		//wvText.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
-        tvDate.setText(GM.formatDate(cursor.getString(3) + " 00:00:00", lang, false));
+        tvDate.setText(GM.formatDate(cursor.getString(3) + " 00:00:00", lang, true, false, false));
         tvPrice.setText(String.format(getString(R.string.price), cursor.getInt(5)));
         tvCity.setText(cursor.getString(4));
 

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

@@ -112,7 +112,7 @@ public class ActivityLayout extends Fragment{
 
                 //Set date
                 TextView tvDate = (TextView) entry.findViewById(R.id.tv_row_activity_future_date);
-                tvDate.setText(GM.formatDate(cursor.getString(1) + " 00:00:00", lang, false));
+                tvDate.setText(GM.formatDate(cursor.getString(1) + " 00:00:00", lang, true, false, false));
 
                 //Set hidden id
                 TextView tvId = (TextView) entry.findViewById(R.id.tv_row_activity_future_hidden);
@@ -206,7 +206,7 @@ public class ActivityLayout extends Fragment{
 
             //Set date
             TextView tvDate = (TextView) entry.findViewById(R.id.tv_row_activity_past_date);
-            tvDate.setText(GM.formatDate(cursorPast.getString(1) + " 00:00:00", lang, false));
+            tvDate.setText(GM.formatDate(cursorPast.getString(1) + " 00:00:00", lang, true, true, false));
 
             //Set hidden id
             TextView tvId = (TextView) entry.findViewById(R.id.tv_row_activity_past_hidden);

+ 1 - 1
app/src/main/java/com/ivalentin/margolariak/ActivityPastLayout.java

@@ -81,7 +81,7 @@ public class ActivityPastLayout extends Fragment {
         } else {
             wvText.loadDataWithBaseURL(null, cursor.getString(5), "text/html", "utf-8", null);
         }
-        tvDate.setText(GM.formatDate(cursor.getString(3) + " 00:00:00", lang, false));
+        tvDate.setText(GM.formatDate(cursor.getString(3) + " 00:00:00", lang, true, true, false));
         tvCity.setText(cursor.getString(4));
 
         //Get images

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

@@ -175,7 +175,7 @@ public class BlogLayout extends Fragment{
 
             //Set date
             TextView tvDate = (TextView) entry.findViewById(R.id.tv_row_blog_date);
-            tvDate.setText(GM.formatDate(cursor.getString(3), lang, false));
+            tvDate.setText(GM.formatDate(cursor.getString(3), lang, true, true, false));
 
             //Set hidden id
             TextView tvId = (TextView) entry.findViewById(R.id.tv_row_blog_hidden);

+ 30 - 7
app/src/main/java/com/ivalentin/margolariak/GM.java

@@ -1209,15 +1209,17 @@ final class GM {
 	/**
 	 * Formats a datetime format strings and returns a human readable date, depending on the language
 	 *
-	 * @param dateString String in a datetime format
-	 * @param lang Language (es, en, eu)
-	 * @param includeTime Also returns the hour and minutes
+	 * @param dateString String in a datetime format.
+	 * @param lang Language (es, en, eu).
+	 * @param includeDay Also returns the weekday.
+	 * @param includeYear Also returns the year.
+	 * @param includeTime Also returns the hour and minute.
 	 *
 	 * @return The fragment view
 	 *
 	 * @see android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
 	 */
-	static String formatDate(String dateString, String lang, boolean includeTime){
+	static String formatDate(String dateString, String lang, boolean includeDay, boolean includeYear, boolean includeTime){
 
 		String output = "";
 
@@ -1252,7 +1254,14 @@ final class GM {
 				case "es":
 					dayName = dayNameEs[dayNumber];
 					monthName = monthNameEs[monthNumber];
-					output = dayName + ", " + day + " de " + monthName + " de " + year;
+					output = "";
+					if (includeDay){
+						output = dayName + ", ";
+					}
+					output = output + day + " de " + monthName;
+					if (includeYear){
+						output = output + " de " + year;
+					}
 					if (includeTime){
 						output = output + " a las " + time;
 					}
@@ -1260,7 +1269,14 @@ final class GM {
 				case "eu":
 					dayName = dayNameEu[dayNumber];
 					monthName = monthNameEu[monthNumber];
-					output = year + "ko" + monthName + " " + day + "an, " + dayName;
+					output = "";
+					if (includeYear){
+						output = year + "ko";
+					}
+					output = output + monthName + " " + day + "an";
+					if (includeDay){
+						output = output + ", " + dayName;
+					}
 					if (includeTime){
 						output = output + " " + time + "etan";
 					}
@@ -1268,7 +1284,14 @@ final class GM {
 				default:
 					dayName = dayNameEn[dayNumber];
 					monthName = monthNameEn[monthNumber];
-					output = dayName + ", " + monthName + " " + day + ", " + year;
+					output = "";
+					if (includeDay){
+						output = dayName + ", ";
+					}
+					output = output + monthName + " " + day;
+					if (includeYear){
+						output = output + ", " + year;
+					}
 					if (includeTime){
 						output = output + " " + time;
 					}

+ 3 - 3
app/src/main/java/com/ivalentin/margolariak/HomeLayout.java

@@ -666,7 +666,7 @@ public class HomeLayout extends Fragment implements LocationListener {
 
 			//Set date
 			TextView tvDate = (TextView) entry.findViewById(R.id.tv_row_home_activity_date);
-			tvDate.setText(GM.formatDate(cursor.getString(1) + " 00:00:00", lang, false));
+			tvDate.setText(GM.formatDate(cursor.getString(1) + " 00:00:00", lang, true, true, false));
 
 			//Set hidden id
 			TextView tvId = (TextView) entry.findViewById(R.id.tv_row_home_activity_hidden);
@@ -797,7 +797,7 @@ public class HomeLayout extends Fragment implements LocationListener {
 
 				//Set date
 				TextView tvDate = (TextView) entry.findViewById(R.id.tv_row_home_activity_date);
-				tvDate.setText(GM.formatDate(cursor.getString(1) + " 00:00:00", lang, false));
+				tvDate.setText(GM.formatDate(cursor.getString(1) + " 00:00:00", lang, true, false, false));
 
 				//Set hidden id
 				TextView tvId = (TextView) entry.findViewById(R.id.tv_row_home_activity_hidden);
@@ -916,7 +916,7 @@ public class HomeLayout extends Fragment implements LocationListener {
 
 			//Set date
 			TextView tvDate = (TextView) entry.findViewById(R.id.tv_row_home_blog_date);
-			tvDate.setText(GM.formatDate(cursor.getString(3), lang, false));
+			tvDate.setText(GM.formatDate(cursor.getString(3), lang, true, true, false));
 
 			//Set hidden id
 			TextView tvId = (TextView) entry.findViewById(R.id.tv_row_home_blog_hidden);

+ 3 - 2
app/src/main/java/com/ivalentin/margolariak/LablancaLayout.java

@@ -124,7 +124,8 @@ public class LablancaLayout extends Fragment {
 
 			//Set date
 			TextView tvDate = (TextView) entry.findViewById(R.id.tv_row_festival_price_day_date);
-			DateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss", Locale.ENGLISH);
+			tvDate.setText(GM.formatDate(cursorDays.getString(0) + " 00:00:00", lang, false, false, false));
+			/*DateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
 			Date date;
 			try {
 				date = format.parse(cursorDays.getString(0));
@@ -143,7 +144,7 @@ public class LablancaLayout extends Fragment {
 			}
 			catch(Exception ex){
 				Log.e("Date format error", ex.toString());
-			}
+			}*/
 
 			list.addView(entry);
 		}

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

@@ -193,7 +193,7 @@ public class PhotoLayout extends Fragment {
 		else{
 			tvDescription.setVisibility(View.GONE);
 		}
-		tvDate.setText(GM.formatDate(cursor.getString(4), lang, true));
+		tvDate.setText(GM.formatDate(cursor.getString(4), lang, true, true, false));
 
 		//Get image
 		String image = cursor.getString(1);
@@ -248,7 +248,7 @@ public class PhotoLayout extends Fragment {
 			TextView tvUser = (TextView) entry.findViewById(R.id.tv_row_comment_user);
 			tvUser.setText(commentCursor.getString(2));
 			TextView tvCDate = (TextView) entry.findViewById(R.id.tv_row_comment_date);
-			tvCDate.setText(GM.formatDate(commentCursor.getString(1), lang, true));
+			tvCDate.setText(GM.formatDate(commentCursor.getString(1), lang, true, true, true));
 			TextView tvText = (TextView) entry.findViewById(R.id.tv_row_comment_text);
 			tvText.setText(commentCursor.getString(0));
 

+ 1 - 1
app/src/main/java/com/ivalentin/margolariak/PostComment.java

@@ -187,7 +187,7 @@ class PostComment extends AsyncTask<String, String, Integer> {
             Date d = new Date();
             String date = DateFormat.format("yyyy-MM-dd hh:mm:ss", d.getTime()).toString();
             TextView tvCDate = (TextView) entry.findViewById(R.id.tv_row_comment_date);
-            tvCDate.setText(GM.formatDate(date, language, true));
+            tvCDate.setText(GM.formatDate(date, language, true, true, true));
             TextView tvText = (TextView) entry.findViewById(R.id.tv_row_comment_text);
             tvText.setText(text);
 

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

@@ -90,7 +90,7 @@ public class PostLayout extends Fragment {
         ((MainActivity) getActivity()).setSectionTitle(cursor.getString(1));
         ((MainActivity) getActivity()).setShareLink(String.format(getString(R.string.share_with_title), cursor.getString(1)), GM.SHARE.BLOG + cursor.getString(4));
         wvText.loadDataWithBaseURL(null, cursor.getString(2), "text/html", "utf-8", null);
-        tvDate.setText(GM.formatDate(cursor.getString(3), lang, true));
+        tvDate.setText(GM.formatDate(cursor.getString(3), lang, true, true, true));
 
         //Get images
         Cursor imageCursor = db.rawQuery("SELECT image, idx FROM post_image WHERE post = " + id + " ORDER BY idx LIMIT 5;", null);
@@ -132,7 +132,7 @@ public class PostLayout extends Fragment {
             TextView tvUser = (TextView) entry.findViewById(R.id.tv_row_comment_user);
             tvUser.setText(commentCursor.getString(2));
             TextView tvCDate = (TextView) entry.findViewById(R.id.tv_row_comment_date);
-            tvCDate.setText(GM.formatDate(commentCursor.getString(1), lang, true));
+            tvCDate.setText(GM.formatDate(commentCursor.getString(1), lang, true, true, true));
             TextView tvText = (TextView) entry.findViewById(R.id.tv_row_comment_text);
             tvText.setText(commentCursor.getString(0));
 

+ 21 - 21
app/src/main/res/layout/activity_main.xml

@@ -17,17 +17,17 @@
 		<!-- Button to open slider menu -->
 
 		<ImageView
-			android:contentDescription="@string/app_name"
 			android:id="@+id/iv_logo"
-			android:src="@drawable/ic_launcher"
-			android:adjustViewBounds="true"
-			android:layout_weight=".2"
-			android:padding="1dp"
-			android:layout_height="wrap_content"
 			android:layout_width="wrap_content"
+			android:layout_height="wrap_content"
+			android:layout_gravity="center_vertical"
+			android:layout_weight=".2"
+			android:adjustViewBounds="true"
+			android:contentDescription="@string/app_name"
 			android:maxHeight="45dp"
 			android:maxWidth="45dp"
-			android:layout_gravity="center_vertical"/>
+			android:padding="1dp"
+			android:src="@drawable/ic_launcher"/>
 
 		<!-- Layout with the app title and current section -->
 
@@ -37,7 +37,7 @@
 			android:layout_gravity="center_vertical|center"
 			android:layout_weight=".8"
 			android:gravity="center"
-			android:orientation="vertical" >
+			android:orientation="vertical">
 
 			<!-- App name. Remains unchanged -->
 
@@ -46,9 +46,9 @@
 				android:layout_height="wrap_content"
 				android:gravity="center"
 				android:text="@string/app_name"
+				android:textColor="@color/menu_entry"
 				android:textSize="18sp"
-				android:textStyle="bold"
-				android:textColor="@color/menu_entry"/>
+				android:textStyle="bold"/>
 
 			<!-- Section title -->
 
@@ -58,32 +58,32 @@
 				android:layout_height="wrap_content"
 				android:gravity="center"
 				android:text="@string/menu_home"
-				android:textSize="20sp"
-				android:textColor="@color/menu_entry"/>
+				android:textColor="@color/menu_entry"
+				android:textSize="20sp"/>
 
 		</LinearLayout>
 
 		<ImageButton
+			android:id="@+id/bt_menu"
 			android:layout_width="wrap_content"
 			android:layout_height="match_parent"
-			android:src="@drawable/ic_expand"
-			android:contentDescription="@string/tutorial_menu"
-			android:onClick="showMenu"
 			android:layout_weight=".2"
-			android:id="@+id/bt_menu"
-			app:srcCompat="@drawable/ic_expand"
-			android:background="#00000000"
 			android:adjustViewBounds="false"
-			android:cropToPadding="false"/>
+			android:background="#00000000"
+			android:contentDescription="@string/tutorial_menu"
+			android:cropToPadding="false"
+			android:onClick="showMenu"
+			android:src="@drawable/ic_expand"
+			app:srcCompat="@drawable/ic_expand"/>
 
 		<ProgressBar
 			android:id="@+id/pb_sync"
 			android:layout_width="40dp"
 			android:layout_height="40dp"
 			android:layout_weight=".2"
-			android:visibility="gone"
 			android:maxHeight="40dp"
-			android:maxWidth="40dp"/>
+			android:maxWidth="40dp"
+			android:visibility="gone"/>
 
 	</LinearLayout>
 

+ 39 - 35
app/src/main/res/layout/fragment_layout_lablanca.xml

@@ -15,17 +15,14 @@
         android:paddingBottom="5dp">
 
         <LinearLayout
-            android:orientation="vertical"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
-            android:background="@drawable/section">
+            android:background="@drawable/section"
+            android:orientation="vertical">
 
             <TextView
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:textAppearance="?android:attr/textAppearanceLarge"
-                android:textStyle="bold"
-                tools:layout_width="match_parent"
                 android:background="@drawable/section_title"
                 android:paddingBottom="4dp"
                 android:paddingEnd="10dp"
@@ -33,33 +30,37 @@
                 android:paddingRight="10dp"
                 android:paddingStart="20dp"
                 android:paddingTop="4dp"
+                android:text="@string/lablanca_title"
+                android:textAppearance="?android:attr/textAppearanceLarge"
                 android:textColor="@color/section_title"
-                android:text="@string/lablanca_title"/>
+                android:textStyle="bold"
+                tools:layout_width="match_parent"/>
 
             <LinearLayout
-                android:orientation="vertical"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
+                android:layout_margin="10dp"
                 android:background="@drawable/entry"
+                android:orientation="vertical"
                 android:padding="7dp">
 
                 <ImageView
+                    android:id="@+id/iv_lablanca_header"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
-                    android:id="@+id/iv_lablanca_header"
-                    android:contentDescription="@string/app_cdesc"
+                    android:layout_gravity="center_horizontal"
                     android:layout_margin="3dp"
                     android:adjustViewBounds="true"
-                    android:layout_gravity="center_horizontal"
+                    android:contentDescription="@string/app_cdesc"
                     android:maxHeight="130dp"/>
 
                 <WebView
+                    android:id="@+id/wv_lablanca_header"
                     android:layout_width="fill_parent"
                     android:layout_height="wrap_content"
-                    android:textAppearance="?android:attr/textAppearanceMedium"
-                    android:id="@+id/wv_lablanca_header"
-                    android:padding="7dp"
                     android:layout_marginBottom="7dp"
+                    android:padding="7dp"
+                    android:textAppearance="?android:attr/textAppearanceMedium"
                     />
             </LinearLayout>
 
@@ -89,34 +90,35 @@
                 android:text="@string/lablanca_schedule"/>
 
             <LinearLayout
-                android:orientation="horizontal"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
+                android:layout_margin="10dp"
                 android:background="@drawable/entry"
+                android:orientation="horizontal"
                 android:padding="7dp">
 
                 <Button
+                    android:id="@+id/bt_lablanca_schedule_city"
                     android:layout_width="fill_parent"
                     android:layout_height="fill_parent"
-                    android:text="@string/lablanca_schedule_city"
-                    android:id="@+id/bt_lablanca_schedule_city"
+                    android:layout_margin="6dp"
+                    android:layout_weight=".5"
                     android:background="@drawable/button_selector"
+                    android:text="@string/lablanca_schedule_city"
                     android:textColor="@color/input_button_color"
                     android:textStyle="bold"
-                    android:layout_margin="6dp"
-                    android:layout_weight=".5"
                     tools:ignore="ButtonStyle"/>
 
                 <Button
+                    android:id="@+id/bt_lablanca_schedule_gm"
                     android:layout_width="fill_parent"
                     android:layout_height="fill_parent"
-                    android:text="@string/lablanca_schedule_gm"
-                    android:id="@+id/bt_lablanca_schedule_gm"
+                    android:layout_margin="6dp"
+                    android:layout_weight=".5"
                     android:background="@drawable/button_selector"
+                    android:text="@string/lablanca_schedule_gm"
                     android:textColor="@color/input_button_color"
                     android:textStyle="bold"
-                    android:layout_margin="6dp"
-                    android:layout_weight=".5"
                     tools:ignore="ButtonStyle"/>
             </LinearLayout>
 
@@ -147,49 +149,51 @@
                 android:textColor="@color/section_title"/>
 
             <LinearLayout
-                android:orientation="vertical"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
+                android:layout_margin="10dp"
                 android:background="@drawable/entry"
+                android:orientation="vertical"
                 android:padding="7dp">
 
                 <TextView
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
-                    android:textAppearance="?android:attr/textAppearanceLarge"
+                    android:layout_marginBottom="15dp"
                     android:text="@string/lablanca_prices_days"
-                    android:layout_marginBottom="15dp"/>
+                    android:textAppearance="?android:attr/textAppearanceMedium"
+                    android:textColor="@color/entry_title"
+                    android:textStyle="bold"/>
 
                 <LinearLayout
-                    android:orientation="vertical"
+                    android:id="@+id/ll_lablanca_prices_days_list"
                     android:layout_width="match_parent"
                     android:layout_height="match_parent"
-                    android:id="@+id/ll_lablanca_prices_days_list">
+                    android:orientation="vertical">
                 </LinearLayout>
             </LinearLayout>
 
             <LinearLayout
-                android:orientation="vertical"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
+                android:layout_margin="10dp"
                 android:background="@drawable/entry"
-                android:padding="7dp"
-                android:layout_marginTop="10dp"
-                android:layout_marginBottom="10dp">
+                android:orientation="vertical"
+                android:padding="7dp">
 
                 <TextView
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
+                    android:text="@string/lablanca_prices_pack"
                     android:textAppearance="?android:attr/textAppearanceMedium"
                     android:textColor="@color/entry_title"
-                    android:textStyle="bold"
-                    android:text="@string/lablanca_prices_pack"/>
+                    android:textStyle="bold"/>
 
                 <LinearLayout
-                    android:orientation="vertical"
+                    android:id="@+id/ll_lablanca_prices_packs_list"
                     android:layout_width="match_parent"
                     android:layout_height="match_parent"
-                    android:id="@+id/ll_lablanca_prices_packs_list"
+                    android:orientation="vertical"
                     />
             </LinearLayout>
 

+ 13 - 6
app/src/main/res/layout/row_festival_price_day.xml

@@ -18,26 +18,33 @@
             android:layout_height="wrap_content">
 
             <TextView
+                android:id="@+id/tv_row_festival_price_day_date"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:textAppearance="@android:style/TextAppearance.Small"
-                android:id="@+id/tv_row_festival_price_day_date"/>
+                android:textAppearance="@android:style/TextAppearance.Large"
+                android:textStyle="bold"/>
 
             <TextView
+                android:id="@+id/tv_row_festival_price_day_name"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
+                android:layout_marginLeft="5dp"
+                android:layout_marginStart="5dp"
                 android:textAppearance="@android:style/TextAppearance.Medium"
-                android:id="@+id/tv_row_festival_price_day_name"/>
+                android:textStyle="italic"/>
 
         </LinearLayout>
 
         <TextView
+            android:id="@+id/tv_row_festival_price_day_price"
             android:layout_width="fill_parent"
             android:layout_height="wrap_content"
-            android:textAppearance="@android:style/TextAppearance.Medium"
-            android:id="@+id/tv_row_festival_price_day_price"
+            android:layout_gravity="bottom"
             android:gravity="end"
-            android:layout_gravity="bottom"/>
+            android:textAppearance="@android:style/TextAppearance.Large"
+            android:textColor="@color/background_menu"
+            android:textSize="24sp"
+            android:textStyle="bold"/>
     </LinearLayout>
 
     <LinearLayout

+ 15 - 9
app/src/main/res/layout/row_festival_price_pack.xml

@@ -19,29 +19,35 @@
             android:layout_weight=".3">
 
             <TextView
+                android:id="@+id/tv_row_festival_price_pack_name"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:textAppearance="@android:style/TextAppearance.Medium"
-                android:id="@+id/tv_row_festival_price_pack_name"/>
+                android:textAppearance="@android:style/TextAppearance.Large"
+                android:textStyle="bold"/>
 
             <TextView
+                android:id="@+id/tv_row_festival_price_pack_text"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:textAppearance="@android:style/TextAppearance.Small"
-                android:id="@+id/tv_row_festival_price_pack_text"
-                android:layout_marginStart="10dp"/>
+                android:layout_marginLeft="5dp"
+                android:layout_marginStart="5dp"
+                android:textAppearance="@android:style/TextAppearance.Medium"
+                android:textStyle="italic"/>
 
         </LinearLayout>
 
         <TextView
+            android:id="@+id/tv_row_festival_price_pack_price"
             android:layout_width="fill_parent"
             android:layout_height="wrap_content"
-            android:textAppearance="@android:style/TextAppearance.Medium"
-            android:id="@+id/tv_row_festival_price_pack_price"
-            android:gravity="end"
             android:layout_gravity="bottom"
+            android:layout_weight=".7"
+            android:gravity="end"
             android:minWidth="70dp"
-            android:layout_weight=".7"/>
+            android:textAppearance="@android:style/TextAppearance.Large"
+            android:textColor="@color/background_menu"
+            android:textSize="24sp"
+            android:textStyle="bold"/>
     </LinearLayout>
 
     <LinearLayout