diff --git a/app/src/main/java/com/example/myapplication/HomeActivity.java b/app/src/main/java/com/example/myapplication/HomeActivity.java index f24543c19298108c90b3048346803220478e769b..1e2be4c6859536abbc88967dfec6f39c0632e92c 100644 --- a/app/src/main/java/com/example/myapplication/HomeActivity.java +++ b/app/src/main/java/com/example/myapplication/HomeActivity.java @@ -11,19 +11,25 @@ public class HomeActivity extends AppCompatActivity { @Override protected void onResume() { super.onResume(); + + // If tutorial ran from photo page + boolean fromPhotoPage = getIntent().getBooleanExtra("FROM_PHOTO_PAGE", false); + if (fromPhotoPage) runTutorial(true); + String tutorialKey = "FIRST_TIME_TUTORIAL"; boolean preferences = getIntent().getBooleanExtra("PREFERENCES",true); if (!preferences) getPreferences(MODE_PRIVATE).edit().putBoolean(tutorialKey, false).apply(); boolean firstTime = getPreferences(MODE_PRIVATE).getBoolean(tutorialKey, true); if (firstTime) { - runTutorial(); + runTutorial(false); } } - private void runTutorial() { - Intent intent = new Intent(HomeActivity.this, TutorialActivity.class); - startActivity(intent); - finish(); + private void runTutorial(boolean fromPhotoPage) { + Intent intent = new Intent(HomeActivity.this, TutorialActivity.class); + intent.putExtra("FROM_PHOTO_PAGE", fromPhotoPage); + startActivity(intent); + finish(); } @Override @@ -83,7 +89,6 @@ public class HomeActivity extends AppCompatActivity { }; photoButton.setOnClickListener(listenerPhotoButton); } - /** * A method to go to the learning page * @param pageToGo a string to signify to which page we want to go diff --git a/app/src/main/java/com/example/myapplication/PhotoPage.java b/app/src/main/java/com/example/myapplication/PhotoPage.java index ffa9061a824ae7c9c2dacb775a997f7793e28d02..b6bc8d817977cf783147a6b5750aafaa6fa4b0b5 100644 --- a/app/src/main/java/com/example/myapplication/PhotoPage.java +++ b/app/src/main/java/com/example/myapplication/PhotoPage.java @@ -5,7 +5,6 @@ import android.content.ContentResolver; import android.content.Intent; import android.content.pm.PackageManager; import android.graphics.Bitmap; -import android.graphics.BitmapFactory; import android.net.Uri; import android.os.Build; import android.os.Bundle; @@ -26,7 +25,6 @@ import android.widget.ImageView; import android.widget.TextView; import java.io.IOException; -import java.util.List; public class PhotoPage extends Fragment { private static final int CAMERA_REQUEST_CODE = 3; @@ -34,7 +32,7 @@ public class PhotoPage extends Fragment { private static final int CAMERA_PERMISSION_REQUEST_CODE = 100; Button cameraButton, folderButton; - TextView textView, txtView; + TextView textPredictionOutput, textProbabilityOutput; ImageView imageView; int imageSize = 256; @@ -47,9 +45,10 @@ public class PhotoPage extends Fragment { // Initialize UI elements cameraButton = view.findViewById(R.id.camera_button); folderButton = view.findViewById(R.id.folder_button); - textView = view.findViewById(R.id.textView); - txtView = view.findViewById(R.id.txtView); - imageView = view.findViewById(R.id.imageView); + textPredictionOutput = view.findViewById(R.id.textPredictionOutput); + textProbabilityOutput = view.findViewById(R.id.textProbabilityOutput); + imageView = view.findViewById(R.id.main_image_display); + Button seeTutoButton = view.findViewById(R.id.see_tuto); // Set up button click listeners cameraButton.setOnClickListener(new View.OnClickListener() { @@ -73,6 +72,18 @@ public class PhotoPage extends Fragment { } }); + View.OnClickListener lSeeTutoButton = new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent intent = new Intent(getActivity(), HomeActivity.class); + intent.putExtra("FROM_PHOTO_PAGE", true); + startActivity(intent); + getActivity().finish(); + } + }; + + seeTutoButton.setOnClickListener(lSeeTutoButton); + return view; } @@ -130,7 +141,7 @@ public class PhotoPage extends Fragment { scaledBitmap = Bitmap.createScaledBitmap(annotatedImage, (int) width, (int) height, true); imageView.setImageBitmap(scaledBitmap); //TextView textView = getView().findViewById(R.id.textView2); - textView.setText(outputPredictedImage.toString()); + textPredictionOutput.setText(outputPredictedImage.toString()); } catch (IOException e) { throw new RuntimeException(e); @@ -148,7 +159,7 @@ public class PhotoPage extends Fragment { startActivityForResult(cameraIntent, CAMERA_REQUEST_CODE); } else { Log.e("PhotoPage", "Camera permission denied"); - textView.setText("Camera permission denied. Please allow it to use this feature."); + textPredictionOutput.setText("Camera permission denied. Please allow it to use this feature."); } } } diff --git a/app/src/main/java/com/example/myapplication/TutorialActivity.java b/app/src/main/java/com/example/myapplication/TutorialActivity.java index 924e1278a8b1447165bfeed94623b4adccc4631e..2e3466111fbed6f9c2c369eb11b772a476e779e9 100644 --- a/app/src/main/java/com/example/myapplication/TutorialActivity.java +++ b/app/src/main/java/com/example/myapplication/TutorialActivity.java @@ -25,6 +25,8 @@ public class TutorialActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tutorial); + boolean fromPhotoPage = getIntent().getBooleanExtra("FROM_PHOTO_PAGE", false); + ViewPager2 viewPager2=findViewById(R.id.tutorial_viewpager); List<Integer> layouts = Arrays.asList( @@ -36,13 +38,21 @@ public class TutorialActivity extends AppCompatActivity { viewPager2.setAdapter(adapter); LinearLayout dotsLayout = findViewById(R.id.dots_layout); Button tutoEndButton = findViewById(R.id.tuto_end_button); + View.OnClickListener lTutoEndButton = new View.OnClickListener() { @Override public void onClick(View view) { - Intent intent = new Intent(TutorialActivity.this, HomeActivity.class); - intent.putExtra("PREFERENCES", false); - startActivity(intent); - finish(); + if (fromPhotoPage) { + Intent intent = new Intent(TutorialActivity.this, PublicActivity.class); + intent.putExtra("TARGET_FRAGMENT", "PhotoPage"); + startActivity(intent); + finish(); + } else { + Intent intent = new Intent(TutorialActivity.this, HomeActivity.class); + intent.putExtra("PREFERENCES", false); + startActivity(intent); + finish(); + } } }; tutoEndButton.setOnClickListener(lTutoEndButton); diff --git a/app/src/main/res/drawable/camera_tiny.png b/app/src/main/res/drawable/camera_tiny.png new file mode 100644 index 0000000000000000000000000000000000000000..97495e62d1f21e4ccd95aa1e8c8b50145f513316 Binary files /dev/null and b/app/src/main/res/drawable/camera_tiny.png differ diff --git a/app/src/main/res/drawable/folder.png b/app/src/main/res/drawable/folder.png new file mode 100644 index 0000000000000000000000000000000000000000..58d61251a8604a183cf1867068252bef8cc648f7 Binary files /dev/null and b/app/src/main/res/drawable/folder.png differ diff --git a/app/src/main/res/drawable/shape_transparent.xml b/app/src/main/res/drawable/shape_transparent.xml index 8d4d5713360521150d07ae21b3374365db4c6c40..f8785caf0507c0749f3c414bb8797082411708bd 100644 --- a/app/src/main/res/drawable/shape_transparent.xml +++ b/app/src/main/res/drawable/shape_transparent.xml @@ -3,14 +3,9 @@ android:shape="rectangle" > <solid - android:color="@color/white"> + android:color="#99FFFFFF"> </solid> - <stroke - android:width="2dp" - android:color="#00FFFFFF" > - </stroke> - <padding android:left="5dp" android:top="5dp" diff --git a/app/src/main/res/layout/fragment_photo_page.xml b/app/src/main/res/layout/fragment_photo_page.xml index e5b76010b3adcaf7d64f5cb7fa7bd03cc3f93a8f..51807a87f6b22b61931f67cbb88b7ebac599d31a 100644 --- a/app/src/main/res/layout/fragment_photo_page.xml +++ b/app/src/main/res/layout/fragment_photo_page.xml @@ -1,98 +1,135 @@ <?xml version="1.0" encoding="utf-8"?> -<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".PhotoPage"> - <!-- Prediction Text --> + <!-- To see the tutorial again --> + <Button + android:id="@+id/see_tuto" + android:layout_width="320dp" + android:layout_height="wrap_content" + style="@style/ButtonAppearance" + android:backgroundTint="#99FFFFFF" + android:layout_gravity="center_horizontal" + android:layout_marginTop="180dp" + android:text="@string/see_tuto" + android:textColor="@color/black" + android:fontFamily="@font/inter" + android:textSize="15sp"/> - <!-- Accuracy Text --> + <FrameLayout + android:layout_width="320dp" + android:layout_height="386dp" + android:background="@drawable/shape_transparent" + android:layout_gravity="center"> + <!-- Camera Button --> + <Button + android:id="@+id/camera_button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/camera" + android:textSize="20sp" + android:fontFamily="@font/inter" + android:textColor="#D9D9D9" + android:backgroundTint="#517293" + style="@style/ButtonAppearance" + android:layout_gravity="bottom|start" + android:layout_marginStart="6dp" + android:drawableLeft="@drawable/camera_tiny"/> + + <!-- Folder Button --> + <Button + android:id="@+id/folder_button" + style="@style/ButtonAppearance" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:backgroundTint="#517293" + android:text="@string/galerie" + android:textSize="20sp" + android:fontFamily="@font/inter" + android:textColor="#D9D9D9" + android:layout_gravity="bottom|end" + android:drawableLeft="@drawable/folder" + android:layout_marginEnd="6dp"/> + <!-- Main Image Display --> + <ImageView + android:id="@+id/main_image_display" + android:layout_width="209dp" + android:layout_height="209dp" + app:layout_constraintBottom_toTopOf="@+id/textPredictionOutput" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.507" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_bias="0.101" + tools:srcCompat="@tools:sample/avatars" + android:layout_gravity="center"/> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/especes" + android:textSize="15sp" + android:textColor="#D9D9D9" + android:paddingHorizontal="40dp" + android:fontFamily="@font/inter" + android:layout_gravity="center_horizontal|top" + android:layout_marginTop="20dp" + android:background="@drawable/shape" + android:backgroundTint="#517293"/> + </FrameLayout> + + <!-- Prediction Text --> <TextView - android:id="@+id/textView" + android:id="@+id/textPredictionOutput" android:layout_width="351dp" android:layout_height="28dp" - android:layout_marginBottom="196dp" + android:layout_marginBottom="146dp" android:text="" android:textColor="#F12B2B" android:textSize="17sp" android:textStyle="bold" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent" /> - + android:layout_gravity="bottom|center_horizontal"/> + + <!-- Accuracy Text --> <TextView - android:id="@+id/txtView" + android:id="@+id/textProbabilityOutput" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" android:textColor="#F12B2B" android:textSize="17sp" android:textStyle="bold" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintHorizontal_bias="0.476" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/textView" - app:layout_constraintVertical_bias="0.331" /> - - <!-- Camera Button --> - <Button - android:id="@+id/camera_button" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginEnd="16dp" - android:layout_marginBottom="340dp" - android:text="Camera" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toStartOf="@+id/folder_button" - app:layout_constraintHorizontal_bias="0.5" - app:layout_constraintStart_toStartOf="parent" - android:backgroundTint="#517293" - style="@style/ButtonAppearance" /> - - <!-- Folder Button --> - <Button - android:id="@+id/folder_button" - style="@style/ButtonAppearance" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginStart="16dp" - android:layout_marginBottom="340dp" - android:backgroundTint="#517293" - android:text="gallerie" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toEndOf="@+id/camera_button" /> - - <!-- Main Image Display --> - <ImageView - android:id="@+id/imageView" - android:layout_width="314dp" - android:layout_height="288dp" - app:layout_constraintBottom_toTopOf="@+id/textView" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintHorizontal_bias="0.507" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" - app:layout_constraintVertical_bias="0.101" - tools:srcCompat="@tools:sample/avatars" /> + android:layout_gravity="center_horizontal|bottom" + android:layout_marginBottom="106dp"/> <!-- Prediction Label --> <TextView - android:id="@+id/textView2" + android:id="@+id/prediction_label" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginBottom="28dp" + android:layout_marginBottom="186dp" android:text="PREDICTION:" - android:textColor="#9E9595" + android:textColor="#D9D9D9" android:textSize="24sp" android:textStyle="bold" - app:layout_constraintBottom_toTopOf="@+id/textView" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintHorizontal_bias="0.498" - app:layout_constraintStart_toStartOf="parent" /> + android:layout_gravity="center_horizontal|bottom"/> -</androidx.constraintlayout.widget.ConstraintLayout> + <TextView + android:id="@+id/learning_page_title" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="50dp" + android:layout_marginBottom="60dp" + android:background="@drawable/polygon_5" + android:paddingTop="30dp" + android:paddingEnd="50dp" + android:text="@string/photo" + android:textAlignment="center" + android:textColor="#1E1E1E" + android:textSize="38sp" /> +</FrameLayout> diff --git a/app/src/main/res/layout/fragment_stats_page.xml b/app/src/main/res/layout/fragment_stats_page.xml index d988794ce6f22f6cc09e1f3199e6510b42023a45..f66429863237fc3e6b9c6475297c81903fba45e2 100644 --- a/app/src/main/res/layout/fragment_stats_page.xml +++ b/app/src/main/res/layout/fragment_stats_page.xml @@ -1,85 +1,105 @@ <?xml version="1.0" encoding="utf-8"?> <!-- res/layout/fragment_stats.xml --> <FrameLayout - xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" - android:orientation="vertical" - android:padding="16dp"> + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto"> - <TextView - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:background="@drawable/shape_transparent" - android:layout_gravity="center" - android:layout_marginLeft="25dp" - android:layout_marginRight="25dp" - android:layout_marginBottom="190dp" - android:text="@string/connexion_text" - android:textAlignment="center" - android:textSize="17sp"/> - <LinearLayout - android:layout_gravity="center" + + + <FrameLayout android:layout_width="match_parent" - android:layout_height="wrap_content" + android:layout_height="match_parent" android:orientation="vertical" - android:padding="15dp" - android:layout_margin="25dp" - android:background="@drawable/shape_transparent"> + android:padding="16dp"> + <TextView - android:layout_marginTop="10dp" android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="@string/user_name" + android:background="@drawable/shape_transparent" + android:layout_gravity="center" + android:layout_marginLeft="25dp" + android:layout_marginRight="25dp" + android:layout_marginBottom="190dp" + android:text="@string/connexion_text" + android:textAlignment="center" android:textSize="17sp"/> - - <!-- Username Field --> - <EditText - android:id="@+id/usernameField" + <LinearLayout + android:layout_gravity="center" android:layout_width="match_parent" android:layout_height="wrap_content" - android:inputType="text" - android:padding="12dp" - android:layout_marginBottom="12dp"/> + android:orientation="vertical" + android:padding="15dp" + android:layout_margin="25dp" + android:background="@drawable/shape_transparent"> + <TextView + android:layout_marginTop="10dp" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/user_name" + android:textSize="17sp"/> - <TextView - android:layout_marginTop="10dp" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:text="@string/password" - android:textSize="17sp"/> -<!-- <com.google.android.material.textfield.TextInputLayout - android:id="@+id/passwordField" - android:layout_width="match_parent" - android:layout_height="45dp"> + <!-- Username Field --> + <EditText + android:id="@+id/usernameField" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:inputType="text" + android:padding="12dp" + android:layout_marginBottom="12dp"/> - <com.google.android.material.textfield.TextInputEditText + <TextView + android:layout_marginTop="10dp" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/password" + android:textSize="17sp"/> + <!-- <com.google.android.material.textfield.TextInputLayout + android:id="@+id/passwordField" android:layout_width="match_parent" - android:layout_height="wrap_content" /> - </com.google.android.material.textfield.TextInputLayout> ---> + android:layout_height="45dp"> - <!-- Password Field --> - <EditText - android:id="@+id/passwordField" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:inputType="textPassword" - android:padding="12dp" - android:layout_marginBottom="12dp"/> + <com.google.android.material.textfield.TextInputEditText + android:layout_width="match_parent" + android:layout_height="wrap_content" /> + </com.google.android.material.textfield.TextInputLayout> + --> - <!-- Login Button --> - <Button - android:layout_marginTop="10dp" - android:id="@+id/loginButton" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:text="@string/login" - android:padding="12dp" - android:layout_marginBottom="16dp" - android:layout_gravity="center_horizontal" - android:backgroundTint="#517293" - style="@style/ButtonAppearance"/> - </LinearLayout> + <!-- Password Field --> + <EditText + android:id="@+id/passwordField" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:inputType="textPassword" + android:padding="12dp" + android:layout_marginBottom="12dp"/> + + <!-- Login Button --> + <Button + android:layout_marginTop="10dp" + android:id="@+id/loginButton" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/login" + android:padding="12dp" + android:layout_marginBottom="16dp" + android:layout_gravity="center_horizontal" + android:backgroundTint="#517293" + style="@style/ButtonAppearance"/> + </LinearLayout> + </FrameLayout> -</FrameLayout> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="50dp" + android:layout_marginBottom="60dp" + android:background="@drawable/polygon_5" + android:paddingTop="30dp" + android:paddingEnd="50dp" + android:text="@string/stats" + android:textAlignment="center" + android:textColor="#1E1E1E" + android:textSize="38sp" /> +</FrameLayout> \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2382e86ee7c442d5f91886c0116700221e17ef5e..989067f0444035026bf005ba760db5c38696f945 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -9,7 +9,7 @@ <string name="learn">Apprendre</string> <string name="settings">Paramètres</string> <string name="photo">Identifier</string> - <string name="stats">Statistiques</string> + <string name="stats">Mode Pro</string> <string name="login">Se connecter</string> <string name="user_name">Nom d\'utilisateur</string> <string name="password">Password</string> @@ -63,4 +63,8 @@ <string name="tuto_app">En apprendre plus sur\nl\'avifaune présente à Lorient</string> <string name="tuto_page_app">Sur la page Apprendre</string> <string name="tuto_end">C\'est parti</string> + <string name="camera">Caméra</string> + <string name="galerie">Galerie</string> + <string name="especes">Espèce(s) identifiée(s)</string> + <string name="see_tuto">Revoir le tutoriel</string> </resources> \ No newline at end of file