diff --git a/app/src/main/java/com/example/myapplication/OverlayDialogFragmentForm.java b/app/src/main/java/com/example/myapplication/OverlayDialogFragmentForm.java index b213f426dd5593809171f006fa789a896ec1822b..66be8c49f7c091e4d26f722a5675cc59752d5db1 100644 --- a/app/src/main/java/com/example/myapplication/OverlayDialogFragmentForm.java +++ b/app/src/main/java/com/example/myapplication/OverlayDialogFragmentForm.java @@ -1,6 +1,8 @@ package com.example.myapplication; import android.app.Activity; +import android.app.AlertDialog; +import android.content.DialogInterface; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -8,6 +10,8 @@ import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.Spinner; +import android.widget.TextView; +import android.widget.TimePicker; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -44,4 +48,30 @@ public class OverlayDialogFragmentForm extends DialogFragment { private void goBack() { this.getDialog().dismiss(); } + + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + + // Select the dropdown menu + Spinner zoneSelector = view.findViewById(R.id.zone_selector); + + // Create the list of options + String[] items = new String[]{"Zone 1\n","Zone 2\n","Zone 3\n","Zone 4\n", + "Je ne suis pas dans la rade de Lorient"}; + ArrayAdapter<String> adapter = new ArrayAdapter<>(this.getContext(), + android.R.layout.simple_spinner_item, items); + + // Set the list of options in the dropdown menu + zoneSelector.setAdapter(adapter); + + // Set the time picker settings + TimePicker timePicker = view.findViewById(R.id.time_picker); + timePicker.setIs24HourView(true); + + // Display the result in the form + TextView predictionDisplay = view.findViewById(R.id.prediction_output); + String predictionText = "Nous avons détecté sur votre photo :\n" + PhotoPage.getPredictionOutput(); + predictionDisplay.setText(predictionText); + } } diff --git a/app/src/main/java/com/example/myapplication/PhotoPage.java b/app/src/main/java/com/example/myapplication/PhotoPage.java index fb56c744069fa6e074cceacf564feaca08d73ec9..f75e461223aefb288edf24f3d3ea427e87cb42dc 100644 --- a/app/src/main/java/com/example/myapplication/PhotoPage.java +++ b/app/src/main/java/com/example/myapplication/PhotoPage.java @@ -34,6 +34,8 @@ public class PhotoPage extends Fragment { private static final int GALLERY_REQUEST_CODE = 1; private static final int CAMERA_PERMISSION_REQUEST_CODE = 100; + private static String predictionOutput; + Button cameraButton, folderButton; TextView textPredictionOutput, textProbabilityOutput; ImageView imageView; @@ -109,7 +111,8 @@ public class PhotoPage extends Fragment { Bitmap cameraImage = (Bitmap) data.getExtras().get("data"); if (cameraImage != null) { imageView.setImageBitmap(cameraImage); - processImage(cameraImage); // Pass the image for further processing + processImage(cameraImage); + showOverlayForm();// Pass the image for further processing } break; @@ -130,7 +133,6 @@ public class PhotoPage extends Fragment { } break; } - showOverlayForm(); } private void processImage(Bitmap bitmap) { @@ -150,8 +152,9 @@ public class PhotoPage extends Fragment { scaledBitmap = Bitmap.createScaledBitmap(annotatedImage, (int) width, (int) height, true); imageView.setImageBitmap(scaledBitmap); //TextView textView = getView().findViewById(R.id.textView2); - textPredictionOutput.setText(outputPredictedImage.toString()); + predictionOutput=outputPredictedImage.toString(); + textPredictionOutput.setText(outputPredictedImage.toString()); } catch (IOException e) { throw new RuntimeException(e); } @@ -173,8 +176,13 @@ public class PhotoPage extends Fragment { } } + public void showOverlayForm() { OverlayDialogFragmentForm overlayDialogForm = new OverlayDialogFragmentForm(); overlayDialogForm.show(getParentFragmentManager(), "overlayDialogForm"); } + + public static String getPredictionOutput() { + return predictionOutput; + } } diff --git a/app/src/main/res/layout/fragment_form.xml b/app/src/main/res/layout/fragment_form.xml index 48e806cbff52fd6687723df126792b5bd8744d88..c255bdde0c891209c34e89d2dd4fccda25bce9e8 100644 --- a/app/src/main/res/layout/fragment_form.xml +++ b/app/src/main/res/layout/fragment_form.xml @@ -1,96 +1,103 @@ - -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" +<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" - android:id="@+id/form_layout" android:layout_width="match_parent" android:layout_height="match_parent" - android:orientation="vertical" - android:background="@drawable/shape" - android:padding="20dp" tools:context=".PhotoPage"> - <!-- Title for the form --> - <TextView - android:id="@+id/form_title" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Saisissez les détails du localisation" - android:textSize="18sp" - android:textColor="#333333" - android:textStyle="bold" - android:layout_gravity="center_horizontal" - android:layout_marginTop="20dp" /> - - <!-- Location Input --> - <EditText - android:id="@+id/location_input" + <LinearLayout + android:id="@+id/form_layout" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="15dp" - android:hint="Localisation (qu'est ce que vous voyez?)" - android:padding="20dp" - android:textColor="#000000" /> + android:background="@drawable/shape_transparent" + android:orientation="vertical" + android:padding="20dp"> - <TextView - android:id="@+id/form_zonage" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Saisissez la zone correspondante" - android:textSize="18sp" - android:textColor="#333333" - android:textStyle="bold" - android:layout_gravity="center_horizontal" - android:layout_marginTop="20dp" /> + <TextView + android:id="@+id/prediction_output" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/display_prediction_text" /> - <EditText - android:id="@+id/zone_input" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginTop="15dp" - android:hint="Dans quelle zone vous situez" - android:padding="20dp" - android:textColor="#000000" /> - <Button - android:id="@+id/form_zoneInfo" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Plus d'info sur les zones" - android:textSize="12sp" - android:textColor="#4B0076" - android:layout_gravity="right" - android:backgroundTint="#FFFFFF" - android:layout_marginTop="5dp" /> + <TextView + android:id="@+id/form_zonage" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:layout_marginTop="20dp" + android:text="@string/corresponding_zone_text" + android:textColor="#333333" + android:textSize="18sp" + android:textStyle="bold" /> - <!-- Date Picker (Optional) --> + <Spinner + android:id="@+id/zone_selector" + android:layout_width="match_parent" + android:layout_height="40dp" + android:layout_marginTop="15dp" /> - <!-- Submit Button --> - <TextView - android:id="@+id/form_date" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Saisissez la date de la prise de la photo" - android:textSize="18sp" - android:textColor="#333333" - android:textStyle="bold" - android:layout_gravity="center_horizontal" - android:layout_marginTop="5dp" /> + <Button + android:id="@+id/form_zoneInfo" + style="@style/ButtonAppearance" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="end" + android:layout_marginTop="5dp" + android:text="@string/zone_info_text" + android:textSize="12sp" /> - <DatePicker - android:id="@+id/date_picker" - android:layout_width="wrap_content" - android:layout_height="250dp" - android:layout_gravity="center_horizontal" - android:layout_marginTop="20dp" /> + <!-- Title for the form --> + <TextView + android:id="@+id/form_title" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:layout_marginTop="20dp" + android:text="@string/desc_text" + android:textColor="#333333" + android:textSize="18sp" + android:textStyle="bold" /> + + <!-- Location Input --> + <EditText + android:id="@+id/location_input" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="15dp" + android:hint="@string/locate_text" + android:padding="20dp" + android:textColor="#000000" /> + + <!-- Date Picker (Optional) --> + + <!-- Submit Button --> + <TextView + android:id="@+id/form_date" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:layout_marginTop="15dp" + android:text="@string/photo_time_text" + android:textColor="#333333" + android:textSize="18sp" + android:textStyle="bold" /> + + <TimePicker + + android:id="@+id/time_picker" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="15dp" /> + + <Button + android:id="@+id/submit_form_button" + style="@style/ButtonAppearance" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:layout_marginTop="30dp" + android:backgroundTint="#517293" + android:text="@string/send" + android:textColor="#FFFFFF" /> + </LinearLayout> +</ScrollView> - <Button - android:id="@+id/submit_form_button" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="center_horizontal" - android:layout_marginTop="30dp" - android:text="Envoyer" - android:textColor="#FFFFFF" - android:backgroundTint="#517293" - style="@style/ButtonAppearance" /> -</LinearLayout> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 80d188bf8431d280cfbd3a7e864b5e020505ed5d..c745eda540a938bfb46308fc92dead537b9e5d02 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -81,6 +81,13 @@ <string name="mode_sombre">Mode sombre</string> <string name="mode_sombre_texte">Le mode sombre économise votre batterie et lutte contre la fatigue visuelle</string> <string name="download_text">Télécharge un guide d’utilisation approfondi de l’application au format pdf</string> + <string name="photo_time_text">Confirmez l\'heure de la prise de la photo</string> + <string name="locate_text">Localisation (qu\'est ce que vous voyez?)</string> + <string name="send">Envoyer</string> + <string name="desc_text">Que voyez-vous autour de vous ?</string> + <string name="zone_info_text">Plus d\'info sur les zones</string> + <string name="corresponding_zone_text">Saisissez la zone correspondante</string> + <string name="display_prediction_text">Si rien ne s\'affiche ici, c\'est que la détection d\'espèces n\'a pas fonctionné.</string> <string-array name="zone_array"> <item>Zone 1</item> <item>Zone 2</item>