diff --git a/app/src/main/java/com/example/myhabitat/ModeConceptionActivity.java b/app/src/main/java/com/example/myhabitat/ModeConceptionActivity.java index a2120bb61880d89f341cb0f5361e97e8ba1d5f96..0824489f7500899751421b6d88ead65a57db6513 100644 --- a/app/src/main/java/com/example/myhabitat/ModeConceptionActivity.java +++ b/app/src/main/java/com/example/myhabitat/ModeConceptionActivity.java @@ -76,7 +76,7 @@ public class ModeConceptionActivity extends AppCompatActivity { Bitmap photoBitmap = (Bitmap) extras.get("data"); //On vérifie que la photo a bien été prise - Log.i("testPhotoBitmap", "hauteur de l'image : " + photoBitmap.getHeight()); + //Log.i("testPhotoBitmap", "hauteur de l'image : " + photoBitmap.getHeight()); Mur murAssocie = gestionnaire.getMur(photoEnCours); if(murAssocie != null){ @@ -97,8 +97,14 @@ public class ModeConceptionActivity extends AppCompatActivity { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy"); String date = simpleDateFormat.format(calendar.getTime()); murAssocie.setDate(date); - Toast.makeText(getBaseContext(), murAssocie.getDate(), Toast.LENGTH_SHORT).show(); - Log.i("testDateJSON", habitat.toJSON().toString()); + for(Piece piece :habitat.getPieces()){ + for(Mur mur : piece.getMurs()){ + if(mur.equals(murAssocie)){ + mur.setDate(date); + } + } + } + majHabitat(); } affichePieces(); } diff --git a/app/src/main/java/com/example/myhabitat/ModeImmersionActivity.java b/app/src/main/java/com/example/myhabitat/ModeImmersionActivity.java index 79e55354af7a43b4b7362beeaa77188ea3cfe255..044d32bbfca3ffe7cb380ca5431f819e7f0c8515 100644 --- a/app/src/main/java/com/example/myhabitat/ModeImmersionActivity.java +++ b/app/src/main/java/com/example/myhabitat/ModeImmersionActivity.java @@ -41,6 +41,7 @@ public class ModeImmersionActivity extends AppCompatActivity implements SensorEv private Piece goToPiece; private Rect goToRect; private GrapheHabitat grapheHabitat; + private ImageView imageViewFleche; /** * onCreate de ModeImmersionActivity @@ -66,6 +67,8 @@ public class ModeImmersionActivity extends AppCompatActivity implements SensorEv setContentView(R.layout.activity_mode_immersion); grapheHabitat = new GrapheHabitat(habitat); + imageViewFleche = findViewById(R.id.imageViewFleche); + imageViewFleche.setVisibility(View.INVISIBLE); rectangles = new ArrayList<Rect>(); pieceArriveeRect = new HashMap<Rect, Piece>(); @@ -255,7 +258,7 @@ public class ModeImmersionActivity extends AppCompatActivity implements SensorEv public void onSensorChanged(SensorEvent event) { // On récupère l'angle - float angle = -(Math.round(event.values[0]))-60; + float angle = -(Math.round(event.values[0])); //On créé l'animation de rotation RotateAnimation rotateAnimation = new RotateAnimation(debut, angle, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); @@ -368,20 +371,97 @@ public class ModeImmersionActivity extends AppCompatActivity implements SensorEv //On recupere la prochaine piece et le mur à partir duquel on y accede Piece pieceEnsuite = chemin.get(1); + //On recuperera la direction pour la fleche + Orientation orientation = null; for (Ouverture ouverture : habitat.getOuvertures()) { Piece pieceDepart = ouverture.getMurDepart().getPiece(); Piece pieceArrivee = ouverture.getMurArrivee().getPiece(); Log.i("testGraphe", "pieceDepart = " + pieceDepart.getNom() + " pieceArrivee = " + pieceArrivee.getNom() + " pieceEnCours = " + pieceEnCours.getNom() + " pieceEnsuite = " + pieceEnsuite.getNom()); if (pieceDepart.equals(pieceEnCours) && pieceArrivee.equals(pieceEnsuite)) { goToRect = ouverture.getRectDepart(); + orientation = ouverture.getMurDepart().getOrientation(); } else if (pieceArrivee.equals(pieceEnCours) && pieceDepart.equals(pieceEnsuite)) { goToRect = ouverture.getRectArrivee(); + orientation = ouverture.getMurArrivee().getOrientation(); } } afficheOuvertures(); + + //Log.i("testFleche", orientation.toString()); + imageViewFleche.setVisibility(View.VISIBLE); + imageViewFleche.animate().cancel(); + switch (orientation){ + case EST: + switch(murEnCours.getOrientation()){ + case OUEST: + imageViewFleche.animate().rotation(180); + break; + case SUD: + imageViewFleche.animate().rotation(-90); + break; + case NORD: + imageViewFleche.animate().rotation(90); + break; + default: + imageViewFleche.animate().rotation(0); + break; + } + break; + case OUEST: + switch(murEnCours.getOrientation()){ + case EST: + imageViewFleche.animate().rotation(180); + break; + case SUD: + imageViewFleche.animate().rotation(90); + break; + case NORD: + imageViewFleche.animate().rotation(-90); + break; + default: + imageViewFleche.animate().rotation(0); + break; + } + break; + case SUD: + switch(murEnCours.getOrientation()){ + case EST: + imageViewFleche.animate().rotation(90); + break; + case OUEST: + imageViewFleche.animate().rotation(-90); + break; + case NORD: + imageViewFleche.animate().rotation(180); + break; + default: + imageViewFleche.animate().rotation(0); + break; + } + break; + case NORD: + switch(murEnCours.getOrientation()){ + case EST: + imageViewFleche.animate().rotation(-90); + break; + case OUEST: + imageViewFleche.animate().rotation(90); + break; + case SUD: + imageViewFleche.animate().rotation(180); + break; + default: + imageViewFleche.animate().rotation(0); + break; + } + break; + } + }else{ goToRect = null; goToPiece = null; + imageViewFleche.setVisibility(View.INVISIBLE); + Toast.makeText(getBaseContext(), "Vous êtes arrivé !", Toast.LENGTH_SHORT).show(); } } } \ No newline at end of file diff --git a/app/src/main/java/habitat/Habitat.java b/app/src/main/java/habitat/Habitat.java index 77ccfc4c14c352580c463d66462d5227d6c296c9..6e7e801e3cc78e5fbb44d277dda560f289c05d42 100644 --- a/app/src/main/java/habitat/Habitat.java +++ b/app/src/main/java/habitat/Habitat.java @@ -2,6 +2,7 @@ package habitat; import android.os.Parcel; import android.os.Parcelable; +import android.util.Log; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; diff --git a/app/src/main/java/habitat/Mur.java b/app/src/main/java/habitat/Mur.java index b890662ac8f6bf47cb96785dd255029e13ec0854..928e694c829bb1e7a01caf913cbb76019a73a364 100644 --- a/app/src/main/java/habitat/Mur.java +++ b/app/src/main/java/habitat/Mur.java @@ -205,16 +205,12 @@ public class Mur implements Parcelable { return jsonObject; } - /** - * Fonction equals du mur - * @param o - * @return true si egaux, false sinon - */ @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - return id == ((Mur) o).getId() && Objects.equals(piece, ((Mur) o).getPiece()) && orientation == ((Mur) o).getOrientation(); + Mur mur = (Mur) o; + return id == mur.id; } /** diff --git a/app/src/main/res/layout/activity_mode_immersion.xml b/app/src/main/res/layout/activity_mode_immersion.xml index 1a61583d7762c9aafb305f3a09693c39aee260f7..c6e95e62465e953a4abfe39ba5c6a460c30def5d 100644 --- a/app/src/main/res/layout/activity_mode_immersion.xml +++ b/app/src/main/res/layout/activity_mode_immersion.xml @@ -29,7 +29,9 @@ android:layout_marginTop="52dp" app:layout_constraintStart_toStartOf="parent" android:layout_marginBottom="117dp" - app:layout_constraintBottom_toTopOf="@+id/imageViewMur"/> + app:layout_constraintBottom_toTopOf="@+id/imageViewMur" + app:layout_constraintHorizontal_bias="0.498" + app:layout_constraintVertical_bias="0.617"/> <SurfaceView android:layout_width="414dp" @@ -75,4 +77,14 @@ app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"/> + + <ImageView + android:layout_width="59dp" + android:layout_height="51dp" + app:srcCompat="@android:drawable/arrow_up_float" + android:id="@+id/imageViewFleche" + app:layout_constraintTop_toTopOf="@+id/imageViewMur" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + android:layout_marginTop="12dp"/> </androidx.constraintlayout.widget.ConstraintLayout> \ No newline at end of file