seavenois пре 10 година
родитељ
комит
6548384fc6

+ 5 - 0
app/src/main/java/com/ivalentin/margolariak/GM.java

@@ -170,6 +170,11 @@ final class GM {
 	 * Name of the preference indicating if the user wants to to receive notifications intended for the general public.
 	 */
 	static final String PREF_NOTIFICATION = "prefNotification";
+
+	/**
+	 * Name of the preference indicating if the tutorial has been seen.
+	 */
+	static final String PREF_TUTORIAL = "prefTutorial";
 	
 	/**
 	 * Default value of the preference indicating if the user wants to to receive notifications intended for the general public.

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

@@ -29,9 +29,11 @@ import android.support.v4.app.ActivityCompat;
 import android.text.Html;
 import android.util.Log;
 import android.view.LayoutInflater;
+import android.view.MotionEvent;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.view.ViewGroup;
+import android.widget.Button;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.TextView;
@@ -75,6 +77,29 @@ public class HomeLayout extends Fragment implements LocationListener {
 		//Variable to know if I need a location manager
 		boolean requestLocation = false;
 
+		//Show tutorial if its the first time
+		final SharedPreferences preferences = view.getContext().getSharedPreferences(GM.PREF, Context.MODE_PRIVATE);
+		if (preferences.getBoolean(GM.PREF_TUTORIAL, false) == false) {
+			final LinearLayout llTutorial = (LinearLayout) getActivity().findViewById(R.id.ll_tutorial);
+			llTutorial.setVisibility(View.VISIBLE);
+			llTutorial.setOnTouchListener(new View.OnTouchListener() {
+				@Override
+				public boolean onTouch(View v, MotionEvent event) {
+					return true;
+				}
+			});
+			Button btTutorial = (Button) getActivity().findViewById(R.id.bt_tutorial);
+			btTutorial.setOnClickListener(new OnClickListener() {
+				@Override
+				public void onClick(View v) {
+					llTutorial.setVisibility(View.GONE);
+					SharedPreferences.Editor editor = preferences.edit();
+					editor.putBoolean(GM.PREF_TUTORIAL, true);
+					editor.apply();
+				}
+			});
+		}
+
 		//Request location permissions if not set
 		if (ActivityCompat.checkSelfPermission(view.getContext(), android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(view.getContext(), android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
 			ActivityCompat.requestPermissions(this.getActivity(), new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, GM.PERMISSION_LOCATION);

BIN
app/src/main/res/drawable/tutorial.png


+ 283 - 251
app/src/main/res/layout/activity_main.xml

@@ -1,293 +1,325 @@
-<com.ivalentin.margolariak.MainLayout
+<FrameLayout
 	xmlns:android="http://schemas.android.com/apk/res/android"
-	android:id="@+id/main_layout"
 	android:layout_width="match_parent"
-	android:layout_height="match_parent"
-	android:fitsSystemWindows="true"
-	android:background="@color/background_menu">
-    
-	
-    <!-- Slider menu -->
-
-    <ScrollView
-		android:layout_width="wrap_content"
-		android:layout_height="fill_parent"
-		android:nestedScrollingEnabled="false">
-
-        <LinearLayout
-			android:layout_width="match_parent"
-			android:layout_height="wrap_content"
-			android:divider="@drawable/divider"
-			android:orientation="vertical"
-			android:padding="10dp"
-			android:baselineAligned="false"	>
+	android:layout_height="match_parent">
 
-            <TextView
-				android:id="@+id/menu_home"
-				android:layout_width="fill_parent"
-				android:layout_height="wrap_content"
-				android:layout_marginBottom="10dp"
-				android:layout_marginTop="10dp"
-				android:gravity="center_vertical"
-				android:text="@string/menu_home"
-				android:textAppearance="?android:attr/textAppearanceLarge"
-				android:textStyle="bold"
-				android:textColor="@color/menu_entry"
-				android:paddingTop="4dp"
-				android:paddingBottom="4dp"/>
+	<com.ivalentin.margolariak.MainLayout
+		android:id="@+id/main_layout"
+		android:layout_width="match_parent"
+		android:layout_height="match_parent"
+		android:fitsSystemWindows="true"
+		android:background="@color/background_menu">
+
+
+		<!-- Slider menu -->
+
+		<ScrollView
+			android:layout_width="wrap_content"
+			android:layout_height="fill_parent"
+			android:nestedScrollingEnabled="false">
 
 			<LinearLayout
-				android:orientation="vertical"
-				android:layout_width="fill_parent"
+				android:layout_width="match_parent"
 				android:layout_height="wrap_content"
-				android:id="@+id/ll_menu_location"
-				android:visibility="gone">
+				android:divider="@drawable/divider"
+				android:orientation="vertical"
+				android:padding="10dp"
+				android:baselineAligned="false"	>
+
+				<TextView
+					android:id="@+id/menu_home"
+					android:layout_width="fill_parent"
+					android:layout_height="wrap_content"
+					android:layout_marginBottom="10dp"
+					android:layout_marginTop="10dp"
+					android:gravity="center_vertical"
+					android:text="@string/menu_home"
+					android:textAppearance="?android:attr/textAppearanceLarge"
+					android:textStyle="bold"
+					android:textColor="@color/menu_entry"
+					android:paddingTop="4dp"
+					android:paddingBottom="4dp"/>
+
+				<LinearLayout
+					android:orientation="vertical"
+					android:layout_width="fill_parent"
+					android:layout_height="wrap_content"
+					android:id="@+id/ll_menu_location"
+					android:visibility="gone">
+
+					<View
+						android:layout_width="fill_parent"
+						android:layout_height="1dp"
+						android:background="@color/background_separator"/>
+
+					<TextView
+						android:id="@+id/menu_location"
+						android:layout_width="fill_parent"
+						android:layout_height="wrap_content"
+						android:layout_marginBottom="10dp"
+						android:layout_marginTop="10dp"
+						android:gravity="center_vertical"
+						android:text="@string/menu_location"
+						android:textAppearance="?android:attr/textAppearanceLarge"
+						android:textStyle="bold"
+						android:textColor="@color/menu_entry"
+						android:paddingBottom="4dp"
+						android:paddingTop="4dp"/>
+				</LinearLayout>
+
+				<View
+					android:layout_width="fill_parent"
+					android:layout_height="1dp"
+					android:background="@color/background_separator"/>
+
+				<TextView
+					android:id="@+id/menu_lablanca"
+					android:layout_width="fill_parent"
+					android:layout_height="wrap_content"
+					android:layout_marginBottom="10dp"
+					android:layout_marginTop="10dp"
+					android:gravity="center_vertical"
+					android:text="@string/menu_lablanca"
+					android:textAppearance="?android:attr/textAppearanceLarge"
+					android:textStyle="bold"
+					android:textColor="@color/menu_entry"
+					android:paddingTop="4dp"
+					android:paddingBottom="4dp"/>
+
+				<TextView
+					android:id="@+id/menu_lablanca_schedule"
+					android:layout_width="fill_parent"
+					android:layout_height="wrap_content"
+					android:layout_marginBottom="10dp"
+					android:layout_marginTop="10dp"
+					android:layout_marginStart="20dp"
+					android:layout_marginLeft="20dp"
+					android:gravity="center_vertical"
+					android:text="@string/menu_lablanca_schedule"
+					android:textAppearance="?android:attr/textAppearanceMedium"
+					android:textColor="@color/menu_entry"
+					android:visibility="gone"
+					android:paddingTop="2dp"
+					android:paddingBottom="2dp"/>
+
+				<TextView
+					android:id="@+id/menu_lablanca_gm_schedule"
+					android:layout_width="fill_parent"
+					android:layout_height="wrap_content"
+					android:layout_marginBottom="10dp"
+					android:layout_marginTop="10dp"
+					android:layout_marginStart="20dp"
+					android:layout_marginLeft="20dp"
+					android:gravity="center_vertical"
+					android:text="@string/menu_lablanca_gm_schedule"
+					android:textAppearance="?android:attr/textAppearanceMedium"
+					android:textColor="@color/menu_entry"
+					android:visibility="gone"
+					android:paddingBottom="2dp"
+					android:paddingTop="2dp"/>
+
+				<View
+					android:layout_width="fill_parent"
+					android:layout_height="1dp"
+					android:background="@color/background_separator"/>
+
+				<TextView
+					android:id="@+id/menu_activities"
+					android:layout_width="fill_parent"
+					android:layout_height="wrap_content"
+					android:layout_marginBottom="10dp"
+					android:layout_marginTop="10dp"
+					android:gravity="center_vertical"
+					android:text="@string/menu_activities"
+					android:textAppearance="?android:attr/textAppearanceLarge"
+					android:textStyle="bold"
+					android:textColor="@color/menu_entry"
+					android:paddingTop="4dp"
+					android:paddingBottom="4dp"/>
+
+				<View
+					android:layout_width="fill_parent"
+					android:layout_height="1dp"
+					android:background="@color/background_separator"/>
+
+				<TextView
+					android:id="@+id/menu_blog"
+					android:layout_width="fill_parent"
+					android:layout_height="wrap_content"
+					android:layout_marginBottom="10dp"
+					android:layout_marginTop="10dp"
+					android:gravity="center_vertical"
+					android:text="@string/menu_blog"
+					android:textAppearance="?android:attr/textAppearanceLarge"
+					android:textStyle="bold"
+					android:textColor="@color/menu_entry"
+					android:paddingBottom="4dp"
+					android:paddingTop="4dp"/>
+
+				<View
+					android:layout_width="fill_parent"
+					android:layout_height="1dp"
+					android:background="@color/background_separator"/>
+
+				<TextView
+					android:id="@+id/menu_gallery"
+					android:layout_width="fill_parent"
+					android:layout_height="wrap_content"
+					android:layout_marginBottom="10dp"
+					android:layout_marginTop="10dp"
+					android:gravity="center_vertical"
+					android:text="@string/menu_gallery"
+					android:textAppearance="?android:attr/textAppearanceLarge"
+					android:textStyle="bold"
+					android:textColor="@color/menu_entry"
+					android:paddingTop="4dp"
+					android:paddingBottom="4dp"/>
 
 				<View
-                    android:layout_width="fill_parent"
-                    android:layout_height="1dp"
-                    android:background="@color/background_separator"/>
+					android:layout_width="fill_parent"
+					android:layout_height="1dp"
+					android:background="@color/background_separator"/>
 
 				<TextView
-					android:id="@+id/menu_location"
+					android:id="@+id/menu_settings"
 					android:layout_width="fill_parent"
 					android:layout_height="wrap_content"
 					android:layout_marginBottom="10dp"
 					android:layout_marginTop="10dp"
 					android:gravity="center_vertical"
-					android:text="@string/menu_location"
+					android:text="@string/menu_settings"
 					android:textAppearance="?android:attr/textAppearanceLarge"
 					android:textStyle="bold"
 					android:textColor="@color/menu_entry"
 					android:paddingBottom="4dp"
 					android:paddingTop="4dp"/>
+
+				<TextView
+					android:layout_width="fill_parent"
+					android:layout_height="fill_parent"
+					android:textAppearance="?android:attr/textAppearanceMedium"
+					android:id="@+id/menu_space"
+					android:padding="5dp"/>
+
 			</LinearLayout>
 
-			<View
-				android:layout_width="fill_parent"
-				android:layout_height="1dp"
-				android:background="@color/background_separator"/>
+		</ScrollView>
 
-			<TextView
-				android:id="@+id/menu_lablanca"
-				android:layout_width="fill_parent"
-				android:layout_height="wrap_content"
-				android:layout_marginBottom="10dp"
-				android:layout_marginTop="10dp"
-				android:gravity="center_vertical"
-				android:text="@string/menu_lablanca"
-				android:textAppearance="?android:attr/textAppearanceLarge"
-				android:textStyle="bold"
-				android:textColor="@color/menu_entry"
-				android:paddingTop="4dp"
-				android:paddingBottom="4dp"/>
-
-            <TextView
-				android:id="@+id/menu_lablanca_schedule"
-				android:layout_width="fill_parent"
-				android:layout_height="wrap_content"
-				android:layout_marginBottom="10dp"
-				android:layout_marginTop="10dp"
-				android:layout_marginStart="20dp"
-				android:layout_marginLeft="20dp"
-				android:gravity="center_vertical"
-				android:text="@string/menu_lablanca_schedule"
-				android:textAppearance="?android:attr/textAppearanceMedium"
-				android:textColor="@color/menu_entry"
-				android:visibility="gone"
-				android:paddingTop="2dp"
-				android:paddingBottom="2dp"/>
-
-            <TextView
-				android:id="@+id/menu_lablanca_gm_schedule"
-				android:layout_width="fill_parent"
-				android:layout_height="wrap_content"
-				android:layout_marginBottom="10dp"
-				android:layout_marginTop="10dp"
-				android:layout_marginStart="20dp"
-				android:layout_marginLeft="20dp"
-				android:gravity="center_vertical"
-				android:text="@string/menu_lablanca_gm_schedule"
-				android:textAppearance="?android:attr/textAppearanceMedium"
-				android:textColor="@color/menu_entry"
-				android:visibility="gone"
-				android:paddingBottom="2dp"
-				android:paddingTop="2dp"/>
-
-			<View
-				android:layout_width="fill_parent"
-				android:layout_height="1dp"
-				android:background="@color/background_separator"/>
+		<!-- The visible screen -->
 
-			<TextView
-				android:id="@+id/menu_activities"
-				android:layout_width="fill_parent"
-				android:layout_height="wrap_content"
-				android:layout_marginBottom="10dp"
-				android:layout_marginTop="10dp"
-				android:gravity="center_vertical"
-				android:text="@string/menu_activities"
-				android:textAppearance="?android:attr/textAppearanceLarge"
-				android:textStyle="bold"
-				android:textColor="@color/menu_entry"
-				android:paddingTop="4dp"
-				android:paddingBottom="4dp"/>
-
-			<View
-				android:layout_width="fill_parent"
-				android:layout_height="1dp"
-				android:background="@color/background_separator"/>
+		<LinearLayout
+			xmlns:android="http://schemas.android.com/apk/res/android"
+			android:layout_width="match_parent"
+			android:layout_height="match_parent"
+			android:background="@color/background_app"
+			android:orientation="vertical"
+			>
 
-			<TextView
-				android:id="@+id/menu_blog"
-				android:layout_width="fill_parent"
-				android:layout_height="wrap_content"
-				android:layout_marginBottom="10dp"
-				android:layout_marginTop="10dp"
-				android:gravity="center_vertical"
-				android:text="@string/menu_blog"
-				android:textAppearance="?android:attr/textAppearanceLarge"
-				android:textStyle="bold"
-				android:textColor="@color/menu_entry"
-				android:paddingBottom="4dp"
-				android:paddingTop="4dp"/>
-
-			<View
-				android:layout_width="fill_parent"
-				android:layout_height="1dp"
-				android:background="@color/background_separator"/>
+			<!-- The action bar -->
 
-			<TextView
-				android:id="@+id/menu_gallery"
+			<LinearLayout
 				android:layout_width="fill_parent"
 				android:layout_height="wrap_content"
-				android:layout_marginBottom="10dp"
-				android:layout_marginTop="10dp"
+				android:background="@drawable/titlebar"
 				android:gravity="center_vertical"
-				android:text="@string/menu_gallery"
-				android:textAppearance="?android:attr/textAppearanceLarge"
-				android:textStyle="bold"
-				android:textColor="@color/menu_entry"
-				android:paddingTop="4dp"
-				android:paddingBottom="4dp"/>
-
-			<View
-				android:layout_width="fill_parent"
-				android:layout_height="1dp"
-				android:background="@color/background_separator"/>
+				android:orientation="horizontal" >
 
-            <TextView
-				android:id="@+id/menu_settings"
-				android:layout_width="fill_parent"
-				android:layout_height="wrap_content"
-				android:layout_marginBottom="10dp"
-				android:layout_marginTop="10dp"
-				android:gravity="center_vertical"
-				android:text="@string/menu_settings"
-				android:textAppearance="?android:attr/textAppearanceLarge"
-				android:textStyle="bold"
-				android:textColor="@color/menu_entry"
-				android:paddingBottom="4dp"
-				android:paddingTop="4dp"/>
-
-			<TextView
-				android:layout_width="fill_parent"
-				android:layout_height="fill_parent"
-				android:textAppearance="?android:attr/textAppearanceMedium"
-				android:id="@+id/menu_space"
-				android:padding="5dp"/>
+				<!-- Button to open slider menu -->
 
-		</LinearLayout>
+				<ImageButton
+					android:id="@+id/bt_menu"
+					android:layout_width="wrap_content"
+					android:layout_height="wrap_content"
+					android:layout_weight=".2"
+					android:adjustViewBounds="true"
+					android:background="#00000000"
+					android:contentDescription="@string/app_name"
+					android:maxHeight="60dp"
+					android:maxWidth="60dp"
+					android:padding="2dp"
+					android:scaleType="fitCenter"
+					android:src="@drawable/ic_launcher" />
+
+				<!-- Layout with the app title and current section -->
+
+				<LinearLayout
+					android:layout_width="wrap_content"
+					android:layout_height="match_parent"
+					android:layout_gravity="center"
+					android:layout_weight=".8"
+					android:gravity="center"
+					android:orientation="vertical" >
+
+					<!-- App name. Remains unchanged -->
+
+					<TextView
+						android:layout_width="wrap_content"
+						android:layout_height="wrap_content"
+						android:gravity="center"
+						android:text="@string/app_name"
+						android:textSize="18sp"
+						android:textStyle="bold" />
+
+					<!-- Section title -->
+
+					<TextView
+						android:id="@+id/activity_main_content_title"
+						android:layout_width="wrap_content"
+						android:layout_height="wrap_content"
+						android:gravity="center"
+						android:text="@string/menu_home"
+						android:textSize="20sp" />
+
+				</LinearLayout>
+
+				<ProgressBar
+					android:id="@+id/pb_sync"
+					android:layout_width="wrap_content"
+					android:layout_height="wrap_content"
+					android:layout_weight=".2"
+					android:visibility="invisible" />
 
-    </ScrollView>
+			</LinearLayout>
 
-	<!-- The visible screen -->
+			<!-- The part where the fragments will be loaded -->
 
-	<LinearLayout
-		xmlns:android="http://schemas.android.com/apk/res/android"
-		android:layout_width="match_parent"
-		android:layout_height="match_parent"
-		android:background="@color/background_app"
-		android:orientation="vertical"
-		>
+			<FrameLayout
+				android:id="@+id/activity_main_content_fragment"
+				android:layout_width="match_parent"
+				android:layout_height="match_parent"
+				android:layout_marginLeft="9dp"
+				android:layout_marginRight="9dp">
 
-		<!-- The action bar -->
+			</FrameLayout>
 
-		<LinearLayout
-		    android:layout_width="fill_parent"
-		    android:layout_height="wrap_content"
-		    android:background="@drawable/titlebar"
-		    android:gravity="center_vertical"
-		    android:orientation="horizontal" >
-			
-		    <!-- Button to open slider menu -->
-
-			<ImageButton
-			    android:id="@+id/bt_menu"
-			    android:layout_width="wrap_content"
-			    android:layout_height="wrap_content"
-			    android:layout_weight=".2"
-			    android:adjustViewBounds="true"
-			    android:background="#00000000"
-			    android:contentDescription="@string/app_name"
-			    android:maxHeight="60dp"
-			    android:maxWidth="60dp"
-			    android:padding="2dp"
-			    android:scaleType="fitCenter"
-			    android:src="@drawable/ic_launcher" />
-
-			<!-- Layout with the app title and current section -->
+		</LinearLayout>
 
-			<LinearLayout
-			    android:layout_width="wrap_content"
-			    android:layout_height="match_parent"
-			    android:layout_gravity="center"
-			    android:layout_weight=".8"
-			    android:gravity="center"
-			    android:orientation="vertical" >
-
-			    <!-- App name. Remains unchanged -->
-
-			    <TextView
-			        android:layout_width="wrap_content"
-			        android:layout_height="wrap_content"
-			        android:gravity="center"
-			        android:text="@string/app_name"
-			        android:textSize="18sp"
-			        android:textStyle="bold" />
-			    
-			    <!-- Section title -->
+	</com.ivalentin.margolariak.MainLayout>
 
-				<TextView
-				    android:id="@+id/activity_main_content_title"
-				    android:layout_width="wrap_content"
-				    android:layout_height="wrap_content"
-				    android:gravity="center"
-				    android:text="@string/menu_home"
-				    android:textSize="20sp" />
+	<LinearLayout
+		android:orientation="vertical"
+		android:layout_width="match_parent"
+		android:layout_height="match_parent"
+		android:background="#003377"
+		android:alpha=".85"
+		android:id="@+id/ll_tutorial"
+		android:visibility="gone">
 
-			</LinearLayout>
+		<ImageView
+			android:layout_width="wrap_content"
+			android:layout_height="wrap_content"
+			android:id="@+id/imageView4"
+			android:src="@drawable/tutorial"/>
 
-			<ProgressBar
-			    android:id="@+id/pb_sync"
-			    android:layout_width="wrap_content"
-			    android:layout_height="wrap_content"
-			    android:layout_weight=".2"
-			    android:visibility="invisible" />
-			
-		</LinearLayout>	
-		
-		<!-- The part where the fragments will be loaded -->
-
-		<FrameLayout
-			android:id="@+id/activity_main_content_fragment"
-			android:layout_width="match_parent"
-			android:layout_height="match_parent"
-			android:layout_marginLeft="9dp"
-			android:layout_marginRight="9dp">
-		
-		</FrameLayout>
-		
+		<Button
+			android:layout_width="wrap_content"
+			android:layout_height="wrap_content"
+			android:text="@string/tutorial_button"
+			android:id="@+id/bt_tutorial"
+			android:layout_gravity="center_horizontal"
+			android:textColor="@color/input_button_color"
+			android:textStyle="bold"
+			android:background="@drawable/button_selector"/>
 	</LinearLayout>
 
-</com.ivalentin.margolariak.MainLayout>
+</FrameLayout>

+ 1 - 0
app/src/main/res/values-en/strings.xml

@@ -19,6 +19,7 @@
 	<string name="menu_blog">Blog</string>
 	<string name="menu_gallery">Gallery</string>
 	<string name="menu_settings">Settings</string>
+	<string name="tutorial_button">Entendido</string>
 
 	<!-- Schedule strings -->
 	<string name="schedule_filter">Search&#8230;</string>

+ 1 - 0
app/src/main/res/values-eu-rES/strings.xml

@@ -25,6 +25,7 @@
 	<string name="menu_blog">Blog</string>
 	<string name="menu_gallery">Galeria</string>
 	<string name="menu_settings">Ezarpenak</string>
+	<string name="tutorial_button">Entendido</string>
 
 	<!-- Schedule strings -->
 

+ 2 - 0
app/src/main/res/values/strings.xml

@@ -30,6 +30,8 @@
 	<string name="menu_gallery">Galería</string>
 	<string name="menu_settings">Preferencias</string>
 
+	<string name="tutorial_button">Entendido</string>
+
 	<!-- Schedule strings -->
 
 	<string name="schedule_filter">Buscar&#8230;</string>