gautrais 7 роки тому
батько
коміт
65af7711f9
45 змінених файлів з 376 додано та 553 видалено
  1. 12 18
      app/src/main/java/app/mar/activities/ARActivity.java
  2. 9 1
      app/src/main/java/app/mar/activities/ChallengeDriver.java
  3. 102 31
      app/src/main/java/app/mar/activities/ChallengeFragment.java
  4. 34 16
      app/src/main/java/app/mar/activities/HostActivity.java
  5. 1 4
      app/src/main/java/app/mar/activities/ImageViewerActivity.java
  6. 1 3
      app/src/main/java/app/mar/activities/MediaViewerAcitvity.java
  7. 1 8
      app/src/main/java/app/mar/activities/MenuActivity.java
  8. 1 3
      app/src/main/java/app/mar/activities/ModelViewerActivity.java
  9. 0 104
      app/src/main/java/app/mar/activities/QCMActivity.java
  10. 4 11
      app/src/main/java/app/mar/activities/QCMFragment.java
  11. 0 154
      app/src/main/java/app/mar/activities/QRCodeActivity.java
  12. 27 11
      app/src/main/java/app/mar/activities/QRCodeFragment.java
  13. 0 69
      app/src/main/java/app/mar/activities/QuestionActivity.java
  14. 2 10
      app/src/main/java/app/mar/activities/QuestionFragment.java
  15. 3 21
      app/src/main/java/app/mar/activities/ResourceListActivity.java
  16. 1 1
      app/src/main/java/app/mar/activities/SettingsActivity.java
  17. 13 10
      app/src/main/java/app/mar/game/Area.java
  18. 1 1
      app/src/main/java/app/mar/game/Bomb.java
  19. 6 12
      app/src/main/java/app/mar/game/Game.java
  20. 1 1
      app/src/main/java/app/mar/game/LocatedResources.java
  21. 2 1
      app/src/main/java/app/mar/game/Place.java
  22. 7 7
      app/src/main/java/app/mar/game/Player.java
  23. 1 1
      app/src/main/java/app/mar/game/QRCodeReturn.java
  24. 1 3
      app/src/main/java/app/mar/game/Resource.java
  25. 7 5
      app/src/main/java/app/mar/game/ResourceManager.java
  26. 2 3
      app/src/main/java/app/mar/game/Stage.java
  27. 5 5
      app/src/main/java/app/mar/game/challenges/ARTreasure.java
  28. 10 10
      app/src/main/java/app/mar/game/challenges/Challenge.java
  29. 1 3
      app/src/main/java/app/mar/game/challenges/ChallengeReturn.java
  30. 1 1
      app/src/main/java/app/mar/game/challenges/GeoIndice.java
  31. 7 0
      app/src/main/java/app/mar/game/challenges/IGeoTreasure.java
  32. 1 1
      app/src/main/java/app/mar/game/challenges/Indice.java
  33. 2 3
      app/src/main/java/app/mar/game/challenges/QCM.java
  34. 31 0
      app/src/main/java/app/mar/game/challenges/QRCodeGeoTreasure.java
  35. 3 5
      app/src/main/java/app/mar/game/challenges/QRCodeTreasure.java
  36. 2 5
      app/src/main/java/app/mar/game/challenges/Question.java
  37. 1 1
      app/src/main/java/app/mar/game/challenges/TextIndice.java
  38. 1 1
      app/src/main/java/app/mar/game/challenges/Treasure.java
  39. 0 1
      app/src/main/java/app/mar/ui/MediaView.java
  40. 1 1
      app/src/main/java/app/mar/ui/ResourceArrayAdapter.java
  41. 2 3
      app/src/main/java/app/mar/utils/AndroidResources.java
  42. 0 2
      app/src/main/java/app/mar/utils/GpsStub.java
  43. 69 0
      app/src/main/java/app/mar/utils/L.java
  44. 0 1
      app/src/main/java/app/mar/utils/files/FileManager.java
  45. 0 1
      app/src/main/java/min3d/parser/ObjParser.java

+ 12 - 18
app/src/main/java/app/mar/activities/ARActivity.java

@@ -6,7 +6,6 @@ import android.graphics.PixelFormat;
 import android.hardware.Camera;
 import android.os.Bundle;
 import android.os.Handler;
-import android.util.Log;
 import android.view.View;
 import android.view.ViewTreeObserver;
 import android.view.Window;
@@ -23,22 +22,17 @@ import java.text.NumberFormat;
 import java.util.ArrayList;
 
 import app.mar.ui.CameraPreview;
-import app.mar.utils.AndroidResources;
 import app.mar.utils.Settings;
-import app.mar.utils.game.Area;
-import app.mar.utils.game.Game;
-import app.mar.utils.game.LocatedResources;
-import app.mar.utils.game.Place;
-import app.mar.utils.game.Player;
-import app.mar.utils.game.Resource;
-import app.mar.utils.game.Stage;
-import app.mar.utils.game.challenges.Challenge;
-import app.mar.utils.game.challenges.ChallengeReturn;
-import app.mar.utils.game.challenges.GeoTreasure;
-import app.mar.utils.game.challenges.QRCodeTreasure;
+import app.mar.game.Area;
+import app.mar.game.Game;
+import app.mar.game.Place;
+import app.mar.game.Player;
+import app.mar.game.Resource;
+import app.mar.game.challenges.ARTreasure;
+import app.mar.game.challenges.Challenge;
+import app.mar.game.challenges.ChallengeReturn;
 import app.mar.utils.geometry.GPSPoint;
 import min3d.core.Object3d;
-import min3d.core.Object3dContainer;
 import min3d.core.RendererActivity;
 import min3d.vos.CameraVo;
 import min3d.vos.Light;
@@ -49,7 +43,7 @@ import min3d.vos.Number3d;
 public class ARActivity extends RendererActivity
 {
 
-    protected GeoTreasure   mTreasure=null;
+    protected ARTreasure    mTreasure=null;
     protected Area          mArea=null;
 
     private final Object mLock = new Object();
@@ -399,9 +393,9 @@ public class ARActivity extends RendererActivity
         Challenge c = mGame.getCurrentChallenge();
         if(c!=null)
         {
-            if(c instanceof GeoTreasure)
+            if(c instanceof ARTreasure)
             {
-                mTreasure = (GeoTreasure)c;
+                mTreasure = (ARTreasure)c;
                 mArea = mTreasure.getArea();
             }else
             {
@@ -492,7 +486,7 @@ public class ARActivity extends RendererActivity
     protected  void onResume() {
         super.onResume();
         init();
-        mGame.onResume(this);
+        mGame.onResume();
         scene.clear();
         synchronized (mLock)
         {

+ 9 - 1
app/src/main/java/app/mar/activities/ChallengeDriver.java

@@ -2,12 +2,20 @@ package app.mar.activities;
 
 import android.net.Uri;
 
-import app.mar.utils.game.challenges.Challenge;
+import app.mar.game.Area;
+import app.mar.game.challenges.Challenge;
 
 public interface ChallengeDriver extends ChallengeFragment.OnFragmentInteractionListener {
     public void challengeValidate(Challenge c);
     public Challenge currentChallenge();
     public void setFragment(Class c);
     public void onFragmentInteraction(Uri uri);
+    public void onReady();
+
+
+    public void   startLocalisation();
+    public void   resumeLocalisation();
+    public void   pauseLocalisation();
+    public double getDistanceWith(Area a);
 
 }

+ 102 - 31
app/src/main/java/app/mar/activities/ChallengeFragment.java

@@ -1,29 +1,28 @@
 package app.mar.activities;
 
+import android.app.Activity;
 import android.app.Fragment;
 import android.content.Context;
 import android.net.Uri;
 import android.os.Bundle;
-import android.support.annotation.CallSuper;
-import android.util.Log;
 import android.util.TypedValue;
 import android.view.KeyEvent;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
-import android.widget.Button;
-import android.widget.EditText;
-import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.TextView;
 
 import java.util.ArrayList;
+import java.util.Timer;
+import java.util.TimerTask;
 
-import app.mar.utils.game.Game;
-import app.mar.utils.game.challenges.Challenge;
-import app.mar.utils.game.challenges.GeoIndice;
-import app.mar.utils.game.challenges.Indice;
-import app.mar.utils.game.challenges.TextIndice;
+import app.mar.game.Area;
+import app.mar.game.challenges.Challenge;
+import app.mar.game.challenges.GeoIndice;
+import app.mar.game.challenges.IGeoTreasure;
+import app.mar.game.challenges.Indice;
+import app.mar.game.challenges.TextIndice;
 
 public abstract class ChallengeFragment extends Fragment {
     public abstract boolean check();
@@ -35,8 +34,15 @@ public abstract class ChallengeFragment extends Fragment {
     protected LinearLayout  mUITextIndices;
     protected TextView      mUIGeoIndice;
     protected LinearLayout  mUIGlobalIndice;
+    protected Challenge     mChallenge;
 
-    protected Challenge      mChallenge;
+    protected Timer         mTimer;
+
+    private Runnable mTimerTick = new Runnable() {
+        public void run() {
+            onGeoUpdateTimer();
+        }
+    };
 
 
     public void resetUi()
@@ -59,7 +65,7 @@ public abstract class ChallengeFragment extends Fragment {
     private void updateIndices()
     {
         ArrayList<Indice> inds = mChallenge.getIndices();
-        if(mUIGlobalIndice!=null && inds.size()>0) mUIGlobalIndice.setVisibility(View.VISIBLE);
+        if(inds.size()>0) mUIGlobalIndice.setVisibility(View.VISIBLE);
         for(int i=0; i<inds.size(); i++)
         {
             Indice ind = inds.get(i);
@@ -78,6 +84,7 @@ public abstract class ChallengeFragment extends Fragment {
     public Indice showIndice()
     {
         Indice ind = mChallenge.nextIndice();
+        int indInd = mChallenge.getIndiceIndex();
         if(ind!=null)
         {
             if(getActivity() instanceof  ChallengeDriver)
@@ -86,7 +93,9 @@ public abstract class ChallengeFragment extends Fragment {
                 {
                     if(mUIGeoIndice!=null)
                     {
+                        mUIGlobalIndice.setVisibility(View.VISIBLE);
                         mUIGeoIndice.setVisibility(View.VISIBLE);
+                        startGeoUpdateTimer();
                         ind.discover();
                         return ind;
                     }
@@ -95,9 +104,11 @@ public abstract class ChallengeFragment extends Fragment {
                 {
                     if(mUITextIndices!=null)
                     {
+                        mUIGlobalIndice.setVisibility(View.VISIBLE);
                         TextView tv = new TextView(getActivity());
                         tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
-                        tv.setText(((TextIndice) ind).getText());
+                        tv.setText("  Indice "+(indInd+1)+" : "+((TextIndice) ind).getText());
+                        mUITextIndices.addView(tv);
                         ind.discover();
                         return ind;
                     }
@@ -107,36 +118,59 @@ public abstract class ChallengeFragment extends Fragment {
         return null;
     }
 
+
+
+
+
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        Log.e("______", "Calling onCreate ______________ : "+getClass().toString());
     }
 
     public View onCreateView(LayoutInflater inflater, ViewGroup container,int res) {
         // Inflate the layout for this fragment
         View v = inflater.inflate(res, container, false);
-        Log.e("______________", "super.onCreateView: "+mUIGlobalIndice);
         mUITextIndices= (LinearLayout) v.findViewById(R.id.ll_textIndices);
         mUIGeoIndice= (TextView) v.findViewById(R.id.tv_geoIndice);
         mUIGlobalIndice = (LinearLayout) v.findViewById(R.id.ll_rootIndices);
-        Log.e("______________", "Ici: "+mUIGlobalIndice);
-        Log.e("#########", "setFragment Commit : false");
         return v;
     }
 
 
     public void initChallenge(Challenge c)
     {
-        Log.e("#########", "initChallenges");
         mChallenge=c;
-        updateIndices();
+        resetUi();
         onInitChallenge(c);
     }
 
+
+    protected void ready()
+    {
+        Activity act = getActivity();
+        if(act instanceof ChallengeDriver)
+        {
+            ChallengeDriver cd = (ChallengeDriver)act;
+            cd.onReady();
+        }
+    }
+
+    @Override
     public void onStart() {
         super.onStart();
-        Log.e("---------", "OnStart !");
+        ready();
+    }
+
+    @Override
+    public void onStop() {
+        super.onStop();
+        stopGeoUpdateTimer();
+    }
+
+
+    public void onResume() {
+        super.onResume();
+        updateIndices();
     }
 
     public boolean onKeyDown(int keyCode, KeyEvent event) {
@@ -145,16 +179,7 @@ public abstract class ChallengeFragment extends Fragment {
 
     private OnFragmentInteractionListener mListener;
 
-    /**
-     * This interface must be implemented by activities that contain this
-     * fragment to allow an interaction in this fragment to be communicated
-     * to the activity and potentially other fragments contained in that
-     * activity.
-     * <p>
-     * See the Android Training lesson <a href=
-     * "http://developer.android.com/training/basics/fragments/communicating.html"
-     * >Communicating with Other Fragments</a> for more information.
-     */
+
     public interface OnFragmentInteractionListener {
         // TODO: Update argument type and name
         void onFragmentInteraction(Uri uri);
@@ -177,7 +202,6 @@ public abstract class ChallengeFragment extends Fragment {
                     + " must implement OnFragmentInteractionListener");
         }
 
-        Log.e("______", "Calling class ______________ : "+getClass().toString());
     }
 
     @Override
@@ -189,4 +213,51 @@ public abstract class ChallengeFragment extends Fragment {
     public Challenge getChallenge() {
         return mChallenge;
     }
+
+
+
+    //
+    // Timer géolocalisation
+    //
+
+    protected void onGeoUpdateTimer()
+    {
+        IGeoTreasure gt = null;
+        ChallengeDriver cd = (ChallengeDriver) getActivity();
+        if(!(mChallenge instanceof IGeoTreasure))
+            throw new RuntimeException("Erreur l'indice géographique est demandé, mais le challenge n'est pas compatible");
+        gt=(IGeoTreasure) mChallenge;
+
+        Area a = gt.getArea();
+        mUIGeoIndice.setText("Distance "+(int)cd.getDistanceWith(a)+" m");
+    }
+
+    protected void stopGeoUpdateTimer()
+    {
+        mTimer.cancel();
+    }
+
+    protected void startGeoUpdateTimer()
+    {
+        mTimer = new Timer();
+        mTimer.schedule(new TimerTask() {
+            @Override
+            public void run() {
+                timerCallback();
+            }
+
+        }, 0, 1000);
+    }
+
+    private void timerCallback()
+    {
+        getActivity().runOnUiThread(mTimerTick);
+    }
+
+
+    //
+    // Fin de Timer géolacalisation
+    //
+
+
 }

+ 34 - 16
app/src/main/java/app/mar/activities/HostActivity.java

@@ -1,27 +1,22 @@
 package app.mar.activities;
 
 import android.app.Activity;
-import android.app.Fragment;
 import android.app.FragmentManager;
 import android.app.FragmentTransaction;
 import android.net.Uri;
 import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.util.Log;
 import android.view.View;
 import android.widget.Button;
 import android.widget.TextView;
-import android.widget.Toast;
 
 import java.util.Timer;
 import java.util.TimerTask;
 
-import app.mar.utils.game.Game;
-import app.mar.utils.game.Stage;
-import app.mar.utils.game.challenges.Challenge;
-import app.mar.utils.game.challenges.Indice;
-import app.mar.utils.game.challenges.Question;
+import app.mar.game.Area;
+import app.mar.game.Game;
+import app.mar.game.Stage;
+import app.mar.game.challenges.Challenge;
+import app.mar.game.challenges.Indice;
 
 
 public class HostActivity extends Activity implements ChallengeDriver{
@@ -88,7 +83,6 @@ public class HostActivity extends Activity implements ChallengeDriver{
     public   void setFragment(Class type)
     {
         ChallengeFragment f = null;
-        final Challenge chall = mGame.getCurrentChallenge();
 
         if(type.isInstance(mQCMFragment))
             f= mQCMFragment;
@@ -107,19 +101,29 @@ public class HostActivity extends Activity implements ChallengeDriver{
             FragmentTransaction ft = fm.beginTransaction();
             ft.replace(R.id.container, mCurrentFragment);
             ft.commit();
-            fm.executePendingTransactions();
-            Log.e("#########", "setFragment Commit : true");
         }
-        else Log.e("#########", "setFragment Commit : false");
+    }
+
+    @Override
+    public void onReady() {
+        Challenge chall = mGame.getCurrentChallenge();
         mCurrentFragment.initChallenge(chall);
+    }
+
 
+
+    @Override
+    public double getDistanceWith(Area a) {
+        return a.getDistance(mGame.getPlayer());
     }
 
+
     @Override
     public void onFragmentInteraction(Uri uri) {
 
     }
 
+
     private void timerCallback()
     {
         this.runOnUiThread(mTimerTick);
@@ -171,7 +175,6 @@ public class HostActivity extends Activity implements ChallengeDriver{
     }
 
 
-
     public void nextChallenge() {
         Stage s = mGame.getCurrentStage();
         Challenge c = s.nextChallenge();
@@ -198,7 +201,6 @@ public class HostActivity extends Activity implements ChallengeDriver{
     private boolean startChallenge()
     {
         Challenge c = mGame.getCurrentChallenge();
-        Log.e("_____", "startChallenge : c : "+c);
         if(c!=null) {
             c.exec(this);
             return true;
@@ -207,4 +209,20 @@ public class HostActivity extends Activity implements ChallengeDriver{
     }
 
 
+    @Override
+    public void startLocalisation() {
+        mGame.newSensorManager(this);
+    }
+
+    @Override
+    public void resumeLocalisation() {
+        mGame.onResume();
+    }
+
+    @Override
+    public void pauseLocalisation() {
+        mGame.onPause(this);
+    }
+
+
 }

+ 1 - 4
app/src/main/java/app/mar/activities/ImageViewerActivity.java

@@ -1,19 +1,16 @@
 package app.mar.activities;
 
-import android.content.Intent;
 import android.graphics.Bitmap;
 import android.os.Bundle;
 import android.support.v7.app.AppCompatActivity;
-import android.util.Log;
 import android.view.View;
 import android.widget.Button;
 import android.widget.ImageView;
 import android.widget.TextView;
 import android.widget.Toast;
 
-import app.mar.utils.AndroidResources;
 import app.mar.utils.FontChangeCrawler;
-import app.mar.utils.game.Resource;
+import app.mar.game.Resource;
 import app.mar.utils.files.FileManager;
 import uk.co.senab.photoview.PhotoViewAttacher;
 

+ 1 - 3
app/src/main/java/app/mar/activities/MediaViewerAcitvity.java

@@ -1,6 +1,5 @@
 package app.mar.activities;
 
-import android.content.Intent;
 import android.media.MediaPlayer;
 import android.os.Handler;
 import android.support.v7.app.AppCompatActivity;
@@ -14,9 +13,8 @@ import android.widget.SeekBar;
 import android.widget.TextView;
 
 import app.mar.ui.MediaView;
-import app.mar.utils.AndroidResources;
 import app.mar.utils.FontChangeCrawler;
-import app.mar.utils.game.Resource;
+import app.mar.game.Resource;
 
 public class MediaViewerAcitvity extends AppCompatActivity implements MediaPlayer.OnSeekCompleteListener,
                                                                 MediaView.OnStartListener,

+ 1 - 8
app/src/main/java/app/mar/activities/MenuActivity.java

@@ -15,13 +15,7 @@ import android.widget.Toast;
 
 import app.mar.ui.RotateButton;
 import app.mar.utils.AndroidResources;
-import app.mar.utils.game.Game;
-import app.mar.utils.game.Stage;
-import app.mar.utils.game.challenges.Challenge;
-import app.mar.utils.game.challenges.GeoTreasure;
-import app.mar.utils.game.challenges.QCM;
-import app.mar.utils.game.challenges.QRCodeTreasure;
-import app.mar.utils.game.challenges.Question;
+import app.mar.game.Game;
 
 public  class  MenuActivity extends Activity implements View.OnClickListener {
 
@@ -103,7 +97,6 @@ public  class  MenuActivity extends Activity implements View.OnClickListener {
         if(Game.game()==null)
         {
             Game g = null;// Game.load(this);
-            System.out.println( (g != null) + " == " + (mGame == null) );
             if (g != null && mGame == null) {
                 mGame = g;
                 Game.setGame(mGame);

+ 1 - 3
app/src/main/java/app/mar/activities/ModelViewerActivity.java

@@ -1,6 +1,5 @@
 package app.mar.activities;
 
-import android.content.Intent;
 import android.support.v4.view.MotionEventCompat;
 import android.os.Bundle;
 import android.view.MotionEvent;
@@ -9,9 +8,8 @@ import android.widget.Button;
 import android.widget.FrameLayout;
 import android.widget.TextView;
 
-import app.mar.utils.AndroidResources;
 import app.mar.utils.FontChangeCrawler;
-import app.mar.utils.game.Resource;
+import app.mar.game.Resource;
 import app.mar.utils.geometry.Point;
 import min3d.core.Object3d;
 import min3d.core.RendererActivity;

+ 0 - 104
app/src/main/java/app/mar/activities/QCMActivity.java

@@ -1,104 +0,0 @@
-package app.mar.activities;
-
-import android.app.ActionBar;
-import android.os.Bundle;
-import android.provider.MediaStore;
-import android.support.design.widget.FloatingActionButton;
-import android.support.design.widget.Snackbar;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.Toolbar;
-import android.util.Log;
-import android.view.View;
-import android.widget.Button;
-import android.widget.EditText;
-import android.widget.ImageView;
-import android.widget.RadioButton;
-import android.widget.RadioGroup;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import java.util.ArrayList;
-
-import app.mar.utils.game.Game;
-import app.mar.utils.game.challenges.Challenge;
-import app.mar.utils.game.challenges.ChallengeReturn;
-import app.mar.utils.game.challenges.QCM;
-import app.mar.utils.game.challenges.Question;
-
-
-public class QCMActivity extends AppCompatActivity {
-
-    protected ImageView     mUIImage;
-    protected TextView      mUIQuestion;
-    protected Button        mUiValid;
-    protected RadioGroup    mUIGoupQCM;
-    protected ArrayList<String> mChoices;
-
-    protected int           mIdOffset = 1234;
-
-    protected Game      mGame;
-    protected QCM       mQCM;
-    public static final int REQUEST_CODE = 2000;
-
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.activity_qcm);
-
-
-
-        mUIImage = (ImageView) findViewById(R.id.iv_img);
-        mUIQuestion = (TextView) findViewById(R.id.tv_question);
-        mUiValid = (Button) findViewById(R.id.btn_ok);
-        mUIGoupQCM = (RadioGroup) findViewById(R.id.rg_qcm);
-
-        mGame = Game.game();
-        Challenge c = mGame.getCurrentChallenge();
-        if(c instanceof QCM)
-        {
-            mQCM=(QCM)c;
-
-
-            mUIQuestion.setText(mQCM.getQuestion());
-
-            mChoices = mQCM.getChoices();
-            for(int i=0; i<mChoices.size(); i++){
-                RadioButton radioButton = new RadioButton(this);
-                radioButton.setText(mChoices.get(i));
-                radioButton.setId(i+mIdOffset);
-                RadioGroup.LayoutParams rprms= new RadioGroup.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT, RadioGroup.LayoutParams.WRAP_CONTENT);
-                rprms.gravity=1;
-                mUIGoupQCM.addView(radioButton, rprms);
-            }
-        }
-        else
-        {
-            Toast.makeText(this, "Error l'entrée n'est pas une question ! ", Toast.LENGTH_LONG).show();
-        }
-
-    }
-
-
-    public void onValid(View v)
-    {
-        int x = mUIGoupQCM.getCheckedRadioButtonId()-mIdOffset;
-
-        if(x<0 || x>=mChoices.size())
-        {
-            Toast.makeText(this, "Vous devez sélectionner une réponse ! "+x, Toast.LENGTH_LONG).show();
-        }else
-        {
-            String resp = mChoices.get(x);
-            if(mQCM.checkAnswer(resp))
-            {
-                setResult(RESULT_OK);
-                Toast.makeText(this, mQCM.getGoodMessage(), Toast.LENGTH_LONG).show();
-                finish();
-            }else
-            {
-                Toast.makeText(this, mQCM.getBadMessage(), Toast.LENGTH_LONG).show();
-            }
-        }
-    }
-}

+ 4 - 11
app/src/main/java/app/mar/activities/QCMFragment.java

@@ -1,15 +1,11 @@
 package app.mar.activities;
 
 import android.app.ActionBar;
-import android.content.Context;
-import android.net.Uri;
 import android.os.Bundle;
 import android.app.Fragment;
-import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
-import android.widget.Button;
 import android.widget.ImageView;
 import android.widget.RadioButton;
 import android.widget.RadioGroup;
@@ -18,10 +14,9 @@ import android.widget.Toast;
 
 import java.util.ArrayList;
 
-import app.mar.activities.R;
-import app.mar.utils.game.Game;
-import app.mar.utils.game.challenges.Challenge;
-import app.mar.utils.game.challenges.QCM;
+import app.mar.game.Game;
+import app.mar.game.challenges.Challenge;
+import app.mar.game.challenges.QCM;
 
 /**
  * A simple {@link Fragment} subclass.
@@ -33,7 +28,6 @@ import app.mar.utils.game.challenges.QCM;
 public class QCMFragment extends ChallengeFragment {
     protected ImageView mUIImage;
     protected TextView mUIQuestion;
-    protected Button mUiValid;
     protected RadioGroup mUIGoupQCM;
     protected ArrayList<String> mChoices;
 
@@ -64,13 +58,12 @@ public class QCMFragment extends ChallengeFragment {
 
         mUIImage = (ImageView) v.findViewById(R.id.iv_img);
         mUIQuestion = (TextView) v.findViewById(R.id.tv_question);
-        mUiValid = (Button) v.findViewById(R.id.btn_ok);
         mUIGoupQCM = (RadioGroup) v.findViewById(R.id.rg_qcm);
-        Log.e("-------", "onCreateView");
         return v;
     }
 
 
+
     @Override
     public boolean check() {
         int x = mUIGoupQCM.getCheckedRadioButtonId()-mIdOffset;

+ 0 - 154
app/src/main/java/app/mar/activities/QRCodeActivity.java

@@ -1,154 +0,0 @@
-package app.mar.activities;
-
-import android.os.Bundle;
-import android.os.Handler;
-import android.support.design.widget.FloatingActionButton;
-import android.support.design.widget.Snackbar;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.Toolbar;
-import android.view.View;
-import android.app.Activity;
-import android.content.pm.PackageManager;
-import android.os.Bundle;
-import android.view.KeyEvent;
-import android.view.View;
-import android.widget.Button;
-import android.widget.Toast;
-
-import com.google.zxing.ResultPoint;
-import com.google.zxing.client.android.BeepManager;
-import com.journeyapps.barcodescanner.BarcodeCallback;
-import com.journeyapps.barcodescanner.BarcodeResult;
-import com.journeyapps.barcodescanner.CaptureManager;
-import com.journeyapps.barcodescanner.DecoratedBarcodeView;
-
-import java.util.List;
-
-import app.mar.utils.game.Game;
-import app.mar.utils.game.challenges.Challenge;
-import app.mar.utils.game.challenges.QCM;
-import app.mar.utils.game.challenges.QRCodeTreasure;
-
-public class QRCodeActivity extends AppCompatActivity  implements
-        DecoratedBarcodeView.TorchListener, BarcodeCallback {
-
-    private CaptureManager capture;
-    private DecoratedBarcodeView barcodeScannerView;
-    private Button switchFlashlightButton;
-    private BeepManager beepManager;
-    private Game mGame;
-    public static final int REQUEST_CODE = 2001;
-    private QRCodeTreasure mQr;
-
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.activity_qrcode);
-
-        barcodeScannerView = (DecoratedBarcodeView)findViewById(R.id.zxing_barcode_scanner);
-        barcodeScannerView.setTorchListener(this);
-        beepManager=new BeepManager(this);
-
-        switchFlashlightButton = (Button)findViewById(R.id.switch_flashlight);
-
-        // if the device does not have flashlight in its camera,
-        // then remove the switch flashlight button...
-        if (!hasFlash()) {
-            switchFlashlightButton.setVisibility(View.GONE);
-        }
-
-
-        mGame = Game.game();
-        Challenge c = mGame.getCurrentChallenge();
-        if(c instanceof QRCodeTreasure) {
-            mQr = (QRCodeTreasure) c;
-        }else
-        {
-            mQr=null;
-        }
-
-        capture = new CaptureManager(this, barcodeScannerView);
-        capture.initializeFromIntent(getIntent(), savedInstanceState);
-        barcodeScannerView.decodeContinuous(this);
-    }
-
-    @Override
-    protected void onResume() {
-        super.onResume();
-        capture.onResume();
-    }
-
-    @Override
-    protected void onPause() {
-        super.onPause();
-        capture.onPause();
-    }
-
-    @Override
-    protected void onDestroy() {
-        super.onDestroy();
-        capture.onDestroy();
-    }
-
-    @Override
-    protected void onSaveInstanceState(Bundle outState) {
-        super.onSaveInstanceState(outState);
-        capture.onSaveInstanceState(outState);
-    }
-
-    @Override
-    public boolean onKeyDown(int keyCode, KeyEvent event) {
-        return barcodeScannerView.onKeyDown(keyCode, event) || super.onKeyDown(keyCode, event);
-    }
-
-    /**
-     * Check if the device's camera has a Flashlight.
-     * @return true if there is Flashlight, otherwise false.
-     */
-    private boolean hasFlash() {
-        return getApplicationContext().getPackageManager()
-                .hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH);
-    }
-
-    public void switchFlashlight(View view) {
-        if ("on".equals(switchFlashlightButton.getText())) {
-            barcodeScannerView.setTorchOn();
-        } else {
-            barcodeScannerView.setTorchOff();
-        }
-    }
-
-    @Override
-    public void onTorchOn() {
-        switchFlashlightButton.setText("Off");
-    }
-
-    @Override
-    public void onTorchOff() {
-        switchFlashlightButton.setText("On");
-    }
-
-    public void barcodeResult(final BarcodeResult result) {
-        beepManager.playBeepSoundAndVibrate();
-
-        Toast.makeText(this,"Text: '"+result.getText()+"'", Toast.LENGTH_LONG).show();
-
-        if(result.getText().compareTo(mQr.getQRValue())==0)
-        {
-            barcodeScannerView.pause();
-            setResult(RESULT_OK);
-            finish();
-        }else
-        {
-            Toast.makeText(this, mQr.getBadQRMessage(), Toast.LENGTH_LONG).show();
-            barcodeScannerView.decodeContinuous(this);
-        }
-
-    }
-
-    @Override
-    public void possibleResultPoints(List<ResultPoint> resultPoints) {
-
-    }
-}

+ 27 - 11
app/src/main/java/app/mar/activities/QRCodeFragment.java

@@ -1,12 +1,9 @@
 package app.mar.activities;
 
 import android.app.Activity;
-import android.content.Context;
 import android.content.pm.PackageManager;
-import android.net.Uri;
 import android.os.Bundle;
 import android.app.Fragment;
-import android.util.Log;
 import android.view.KeyEvent;
 import android.view.LayoutInflater;
 import android.view.View;
@@ -23,9 +20,10 @@ import com.journeyapps.barcodescanner.DecoratedBarcodeView;
 
 import java.util.List;
 
-import app.mar.utils.game.Game;
-import app.mar.utils.game.challenges.Challenge;
-import app.mar.utils.game.challenges.QRCodeTreasure;
+import app.mar.game.Game;
+import app.mar.game.challenges.Challenge;
+import app.mar.game.challenges.QRCodeGeoTreasure;
+import app.mar.game.challenges.QRCodeTreasure;
 
 
 /**
@@ -79,6 +77,11 @@ public class QRCodeFragment extends ChallengeFragment  implements
         {
             mQr=null;
         }
+        if( (c instanceof QRCodeGeoTreasure) && (getActivity() instanceof  ChallengeDriver))
+        {
+            ChallengeDriver cd = (ChallengeDriver) getActivity();
+            cd.startLocalisation();
+        }
     }
 
     @Override
@@ -91,7 +94,6 @@ public class QRCodeFragment extends ChallengeFragment  implements
                              Bundle savedInstanceState) {
         // Inflate the layout for this fragment
         View v = super.onCreateView(inflater, container, R.layout.fragment_qrcode);
-        Log.e("#########", "setFragment onCreateView ");
         barcodeScannerView = (DecoratedBarcodeView)v.findViewById(R.id.zxing_barcode_scanner);
         barcodeScannerView.setTorchListener(this);
         beepManager=new BeepManager(getActivity());
@@ -107,15 +109,29 @@ public class QRCodeFragment extends ChallengeFragment  implements
         capture.initializeFromIntent(getActivity().getIntent(), savedInstanceState);
 
         barcodeScannerView.decodeContinuous(this);
-
         return v;
     }
 
 
+    @Override
+    public void onStart() {
+        super.onStart();
+        if(getActivity() instanceof  ChallengeDriver)
+        {
+            ChallengeDriver cd = (ChallengeDriver) getActivity();
+            cd.resumeLocalisation();
+        }
+    }
 
-
-
-
+    @Override
+    public void onStop() {
+        super.onStop();
+        if(getActivity() instanceof  ChallengeDriver)
+        {
+            ChallengeDriver cd = (ChallengeDriver) getActivity();
+            cd.pauseLocalisation();
+        }
+    }
 
     @Override
     public void onResume() {

+ 0 - 69
app/src/main/java/app/mar/activities/QuestionActivity.java

@@ -1,69 +0,0 @@
-package app.mar.activities;
-
-import android.os.Bundle;
-import android.app.Activity;
-import android.view.View;
-import android.widget.Button;
-import android.widget.EditText;
-import android.widget.ImageView;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import app.mar.utils.game.Game;
-import app.mar.utils.game.challenges.Challenge;
-import app.mar.utils.game.challenges.Question;
-
-
-public class QuestionActivity extends Activity  {
-
-    protected ImageView mUIImage;
-    protected EditText  mUIResponse;
-    protected TextView  mUIQuestion;
-    protected Button    mUiValid;
-    protected Question  mQuestion=null;
-    protected Game      mGame;
-    public static final int REQUEST_CODE = 2002;
-
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.activity_question);
-
-        mUIImage = (ImageView) findViewById(R.id.iv_img);
-        mUIQuestion = (TextView) findViewById(R.id.tv_question);
-        mUIResponse = (EditText) findViewById(R.id.et_response);
-        mUiValid = (Button) findViewById(R.id.btn_ok);
-
-
-
-        mGame = Game.game();
-        Challenge c = mGame.getCurrentChallenge();
-        if(c instanceof Question)
-        {
-            mQuestion=(Question)c;
-
-            mUIQuestion.setText(mQuestion.getQuestion());
-        }
-        else
-        {
-            Toast.makeText(this, "Error l'entrée n'est pas une question ! ", Toast.LENGTH_LONG).show();
-        }
-    }
-
-
-    public void onValid(View v)
-    {
-        String resp = mUIResponse.getText().toString();
-        if(mQuestion.checkAnswer(resp))
-        {
-            Toast.makeText(this, mQuestion.getGoodMessage(), Toast.LENGTH_LONG).show();
-
-            finish();
-        }else
-        {
-            Toast.makeText(this, mQuestion.getBadMessage(), Toast.LENGTH_LONG).show();
-            mUIResponse.getText().clear();
-        }
-    }
-}

+ 2 - 10
app/src/main/java/app/mar/activities/QuestionFragment.java

@@ -1,22 +1,17 @@
 package app.mar.activities;
 
-import android.app.Activity;
-import android.content.Context;
-import android.net.Uri;
 import android.os.Bundle;
 import android.app.Fragment;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
-import android.widget.Button;
 import android.widget.EditText;
 import android.widget.ImageView;
 import android.widget.TextView;
 import android.widget.Toast;
 
-import app.mar.utils.game.Game;
-import app.mar.utils.game.challenges.Challenge;
-import app.mar.utils.game.challenges.Question;
+import app.mar.game.challenges.Challenge;
+import app.mar.game.challenges.Question;
 
 /**
  * A simple {@link Fragment} subclass.
@@ -29,7 +24,6 @@ public class QuestionFragment extends ChallengeFragment  {
     protected ImageView mUIImage;
     protected EditText  mUIResponse;
     protected TextView  mUIQuestion;
-    protected Button    mUiValid;
     protected Question  mQuestion=null;
 
 
@@ -53,8 +47,6 @@ public class QuestionFragment extends ChallengeFragment  {
         mUIImage = (ImageView) v.findViewById(R.id.iv_img);
         mUIQuestion = (TextView) v.findViewById(R.id.tv_question);
         mUIResponse = (EditText) v.findViewById(R.id.et_response);
-        mUiValid = (Button) v.findViewById(R.id.btn_ok);
-
         return v;
     }
 

+ 3 - 21
app/src/main/java/app/mar/activities/ResourceListActivity.java

@@ -1,30 +1,12 @@
 package app.mar.activities;
 
-import android.annotation.SuppressLint;
 import android.app.Activity;
-import android.content.Intent;
-import android.graphics.Color;
-import android.graphics.Typeface;
-import android.support.v7.app.ActionBar;
-import android.support.v7.app.AppCompatActivity;
 import android.os.Bundle;
-import android.os.Handler;
-import android.util.Log;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.Button;
-import android.widget.LinearLayout;
 import android.widget.ListView;
-import android.widget.ScrollView;
-import android.widget.TextView;
-import java.util.ArrayList;
-import java.util.List;
-import app.mar.ui.*;
+
+import app.mar.game.Game;
 import app.mar.utils.*;
-import app.mar.utils.game.*;
+import app.mar.game.*;
 /**
  * An example full-screen activity that shows and hides the system UI (i.e.
  * status bar and navigation/system bar) with user interaction.

+ 1 - 1
app/src/main/java/app/mar/activities/SettingsActivity.java

@@ -17,7 +17,7 @@ import app.mar.ui.SelectButton;
 import app.mar.ui.OnToggleListener;
 import app.mar.utils.FontChangeCrawler;
 import app.mar.utils.Settings;
-import app.mar.utils.game.Game;
+import app.mar.game.Game;
 
 /**
  * A {@link PreferenceActivity} that presents a set of application settings. On

+ 13 - 10
app/src/main/java/app/mar/utils/game/Area.java → app/src/main/java/app/mar/game/Area.java

@@ -1,4 +1,4 @@
-package app.mar.utils.game;
+package app.mar.game;
 
 import android.app.Activity;
 
@@ -9,6 +9,7 @@ import org.json.JSONObject;
 import java.io.Serializable;
 import java.util.ArrayList;
 
+import app.mar.utils.L;
 import app.mar.utils.geometry.GPSPoint;
 import app.mar.utils.geometry.Shape;
 
@@ -35,18 +36,23 @@ public class Area  implements Serializable {
                 mShape.add(new GPSPoint(jaa.getDouble(0), jaa.getDouble(1)));
             }
 
-            String res [] = root.getString("resource").split(";");
+            mPlaces = new Place(root.getJSONObject("point"));
+
+        } catch (JSONException e) {
+            e.printStackTrace();
+        }
+
+        try {
+            String res []  = root.getString("resource").split(";");
             for(int i=0; i<res.length; i++)
             {
                 g.registerResource(res[i], act);
                 mResourceName.add(res[i]);
             }
-
-            mPlaces = new Place(root.getJSONObject("points"));
-
         } catch (JSONException e) {
-            e.printStackTrace();
+            L.info("In Area '"+mName+"' : resource field not found");
         }
+
     }
 
     public String getName() {
@@ -120,10 +126,7 @@ public class Area  implements Serializable {
 
     public double getDistance(Player p)
     {
-        double min = 32*1000*1000*1000;
-        if(mPlaces.getDistance(p)<min)
-                min=mPlaces.getDistance(p);
-        return min;
+        return mPlaces.getDistance(p);
     }
 
     public String toString(Player p)

+ 1 - 1
app/src/main/java/app/mar/utils/game/Bomb.java → app/src/main/java/app/mar/game/Bomb.java

@@ -1,4 +1,4 @@
-package app.mar.utils.game;
+package app.mar.game;
 
 import android.util.Log;
 

+ 6 - 12
app/src/main/java/app/mar/utils/game/Game.java → app/src/main/java/app/mar/game/Game.java

@@ -1,8 +1,7 @@
-package app.mar.utils.game;
+package app.mar.game;
 
 import android.app.Activity;
 import android.content.Context;
-import android.util.Log;
 import android.widget.Toast;
 
 import org.json.JSONArray;
@@ -15,17 +14,14 @@ import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.io.Serializable;
-import java.text.DecimalFormat;
-import java.text.NumberFormat;
 import java.util.ArrayList;
 
-import app.mar.activities.ARActivity;
+import app.mar.game.challenges.Challenge;
+import app.mar.game.challenges.ChallengeReturn;
+import app.mar.game.challenges.Treasure;
 import app.mar.utils.SensorsManager;
 import app.mar.utils.Settings;
 import app.mar.utils.files.JSONAssetsManager;
-import app.mar.utils.game.challenges.Challenge;
-import app.mar.utils.game.challenges.ChallengeReturn;
-import app.mar.utils.game.challenges.Treasure;
 
 /**
  * Created by ptitcois on 19/08/16.
@@ -140,10 +136,8 @@ public class Game  implements Serializable {
             fos.close();
         } catch (IOException e) {
             e.printStackTrace();
-            Log.e("SAVING", "Save failed:"+e.getMessage());
             return false;
         }
-        Log.e("SAVING", "Save OK");
         return true;
     }
 
@@ -196,9 +190,9 @@ public class Game  implements Serializable {
     }
 
 
-    public void onResume(ARActivity context)
+    public void onResume()
     {
-        mPlayer.onResume(context);
+        mPlayer.onResume();
     }
 
     public void setSensorsManager(SensorsManager sm)

+ 1 - 1
app/src/main/java/app/mar/utils/game/LocatedResources.java → app/src/main/java/app/mar/game/LocatedResources.java

@@ -1,4 +1,4 @@
-package app.mar.utils.game;
+package app.mar.game;
 
 import java.util.ArrayList;
 

+ 2 - 1
app/src/main/java/app/mar/utils/game/Place.java → app/src/main/java/app/mar/game/Place.java

@@ -1,4 +1,4 @@
-package app.mar.utils.game;
+package app.mar.game;
 
 import org.json.JSONArray;
 import org.json.JSONException;
@@ -126,6 +126,7 @@ public class Place  implements Serializable {
 
     public double getDistance(Player p)
     {
+        if(mLocation==null) return -1;
         return mLocation.getDistanceWith(p.getPosition());
     }
 

+ 7 - 7
app/src/main/java/app/mar/utils/game/Player.java → app/src/main/java/app/mar/game/Player.java

@@ -1,10 +1,9 @@
-package app.mar.utils.game;
+package app.mar.game;
 
 import android.app.Activity;
 
 import java.io.Serializable;
 
-import app.mar.activities.ARActivity;
 import app.mar.utils.SensorsManager;
 import app.mar.utils.geometry.GPSPoint;
 
@@ -47,27 +46,28 @@ public class Player implements Serializable{
         return mSensors.hasAcceleromter();
     }
 
-    public void onResume(ARActivity act)
+    public void onResume()
     {
-        mSensors.onResume();
+        if(mSensors!=null)
+            mSensors.onResume();
     }
 
 
     public float getOrientation()
     {
-        System.out.println("Orientation = "+mSensors.getOrientation()); return mSensors.getOrientation();
+        return mSensors.getOrientation();
     }
 
     public float getOrientationX()
     {
 
-        System.out.println("Orientation x = "+mSensors.getAzimuth());return mSensors.getAzimuth();
+        return mSensors.getAzimuth();
     }
 
     public float getOrientationY()
     {
 
-        System.out.println("Orientation y = "+mSensors.getAngleY()); return mSensors.getAngleY();
+        return mSensors.getAngleY();
     }
 
 

+ 1 - 1
app/src/main/java/app/mar/utils/game/QRCodeReturn.java → app/src/main/java/app/mar/game/QRCodeReturn.java

@@ -1,4 +1,4 @@
-package app.mar.utils.game;
+package app.mar.game;
 
 public class QRCodeReturn {
 

+ 1 - 3
app/src/main/java/app/mar/utils/game/Resource.java → app/src/main/java/app/mar/game/Resource.java

@@ -1,4 +1,4 @@
-package app.mar.utils.game;
+package app.mar.game;
 
 import android.app.Activity;
 import android.util.Log;
@@ -32,7 +32,6 @@ public class Resource implements Serializable {
 
     protected void loadResourceData(Activity act)
     {
-        System.out.println("Loading ressource res/raw/"+mName+"_res");
         JSONObject obj = JSONAssetsManager.load(act, mName+"_res");
         try {
             mComment=obj.getString("comment");
@@ -121,7 +120,6 @@ public class Resource implements Serializable {
     {
         if(m3DModel==null)
         {
-            Log.e("resource.get3Model", "app.brest.testmin3d:raw/"+mName+"_obj");
             IParser myParser = Parser.createParser(context, Parser.Type.OBJ,  mName+"_obj",true);
             myParser.parse();
 

+ 7 - 5
app/src/main/java/app/mar/utils/game/ResourceManager.java → app/src/main/java/app/mar/game/ResourceManager.java

@@ -1,13 +1,10 @@
-package app.mar.utils.game;
+package app.mar.game;
 
 import android.app.Activity;
 
 import java.io.Serializable;
-import java.util.ArrayList;
 import java.util.HashMap;
 
-import app.mar.utils.game.Resource;
-
 /**
  * Created by ptitcois on 18/08/16.
  * Cette classe gère les differentes ressources
@@ -41,7 +38,12 @@ public class ResourceManager implements Serializable{
 
     public String[] getResourceList()
     {
-        return (String[])mResources.keySet().toArray();
+        Object[] x = mResources.keySet().toArray();
+        String[] s = new String[mResources.size()];
+        for(int i=0; i<mResources.size(); i++)
+            s[i]=(String) x[i];
+
+        return s;
     }
 
     /**

+ 2 - 3
app/src/main/java/app/mar/utils/game/Stage.java → app/src/main/java/app/mar/game/Stage.java

@@ -1,4 +1,4 @@
-package app.mar.utils.game;
+package app.mar.game;
 
 import android.app.Activity;
 
@@ -9,8 +9,7 @@ import org.json.JSONObject;
 import java.io.Serializable;
 import java.util.ArrayList;
 
-import app.mar.utils.game.Resource;
-import app.mar.utils.game.challenges.Challenge;
+import app.mar.game.challenges.Challenge;
 
 public class Stage  implements Serializable {
     protected String mName;

+ 5 - 5
app/src/main/java/app/mar/utils/game/challenges/GeoTreasure.java → app/src/main/java/app/mar/game/challenges/ARTreasure.java

@@ -1,4 +1,4 @@
-package app.mar.utils.game.challenges;
+package app.mar.game.challenges;
 
 import android.app.Activity;
 
@@ -6,16 +6,16 @@ import org.json.JSONException;
 import org.json.JSONObject;
 
 import app.mar.activities.ARActivity;
-import app.mar.utils.game.Area;
-import app.mar.utils.game.Game;
+import app.mar.game.Area;
+import app.mar.game.Game;
 
-public class GeoTreasure extends Treasure {
+public class ARTreasure extends Treasure implements IGeoTreasure {
     protected Area mArea;
     public static final int REQUEST_CODE=2001;
 
     public int getResultCode() { return REQUEST_CODE; }
 
-    public GeoTreasure(Game g, JSONObject root, Activity act) {
+    public ARTreasure(Game g, JSONObject root, Activity act) {
         super(root, ARActivity.class);
 
         try

+ 10 - 10
app/src/main/java/app/mar/utils/game/challenges/Challenge.java → app/src/main/java/app/mar/game/challenges/Challenge.java

@@ -1,8 +1,6 @@
-package app.mar.utils.game.challenges;
+package app.mar.game.challenges;
 
 import android.app.Activity;
-import android.content.Intent;
-import android.util.Log;
 
 import org.json.JSONArray;
 import org.json.JSONException;
@@ -13,10 +11,8 @@ import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 
-import app.mar.activities.ARActivity;
 import app.mar.activities.ChallengeDriver;
-import app.mar.activities.QuestionActivity;
-import app.mar.utils.game.Game;
+import app.mar.game.Game;
 
 public abstract class Challenge implements Serializable{
 
@@ -31,6 +27,7 @@ public abstract class Challenge implements Serializable{
     protected boolean mDone=false;
     protected Class  mStartWith = null;
     protected ArrayList<Indice> mIndices = new ArrayList<Indice>();
+    protected int mLastIndiceDiscoveredIndex = 0;
 
     public Challenge(JSONObject root, Class start)
     {
@@ -69,7 +66,6 @@ public abstract class Challenge implements Serializable{
 
     public void exec(ChallengeDriver act)
     {
-        Log.e("_____________", "Classe: "+mStartWith);
         act.setFragment(mStartWith);
     }
 
@@ -95,8 +91,7 @@ public abstract class Challenge implements Serializable{
     public static Class getChallengeClass(String classe)
     {
         try {
-            Log.e("_____", "Trying to open class 'app.mar.utils.game.challenges."+classe+"'");
-            Class cls = Class.forName("app.mar.utils.game.challenges."+classe);
+            Class cls = Class.forName("app.mar.game.challenges."+classe);
             return cls;
         }
         catch(ClassNotFoundException cnfe)
@@ -154,10 +149,15 @@ public abstract class Challenge implements Serializable{
         int i=0;
         for(i=0; i<mIndices.size(); i++)
             if(!mIndices.get(i).isDiscovered())
-                return mIndices.get(i);
+                return mIndices.get(mLastIndiceDiscoveredIndex=i);
+        mLastIndiceDiscoveredIndex=-1;
         return null;
     }
 
+    public int getIndiceIndex(){
+        return mLastIndiceDiscoveredIndex;
+    }
+
     public ArrayList<Indice> getIndices() { return mIndices; }
 
 }

+ 1 - 3
app/src/main/java/app/mar/utils/game/challenges/ChallengeReturn.java → app/src/main/java/app/mar/game/challenges/ChallengeReturn.java

@@ -1,6 +1,4 @@
-package app.mar.utils.game.challenges;
-
-import app.mar.utils.game.Resource;
+package app.mar.game.challenges;
 
 public class ChallengeReturn {
     public  static final int BAD_RESPONS = -3;

+ 1 - 1
app/src/main/java/app/mar/utils/game/challenges/GeoIndice.java → app/src/main/java/app/mar/game/challenges/GeoIndice.java

@@ -1,4 +1,4 @@
-package app.mar.utils.game.challenges;
+package app.mar.game.challenges;
 
 import org.json.JSONObject;
 

+ 7 - 0
app/src/main/java/app/mar/game/challenges/IGeoTreasure.java

@@ -0,0 +1,7 @@
+package app.mar.game.challenges;
+
+import app.mar.game.Area;
+
+public interface IGeoTreasure {
+    public Area getArea();
+}

+ 1 - 1
app/src/main/java/app/mar/utils/game/challenges/Indice.java → app/src/main/java/app/mar/game/challenges/Indice.java

@@ -1,4 +1,4 @@
-package app.mar.utils.game.challenges;
+package app.mar.game.challenges;
 
 import org.json.JSONException;
 import org.json.JSONObject;

+ 2 - 3
app/src/main/java/app/mar/utils/game/challenges/QCM.java → app/src/main/java/app/mar/game/challenges/QCM.java

@@ -1,4 +1,4 @@
-package app.mar.utils.game.challenges;
+package app.mar.game.challenges;
 
 import android.app.Activity;
 
@@ -8,9 +8,8 @@ import org.json.JSONObject;
 
 import java.util.ArrayList;
 
-import app.mar.activities.QCMActivity;
 import app.mar.activities.QCMFragment;
-import app.mar.utils.game.Game;
+import app.mar.game.Game;
 
 public class QCM extends Question{
 

+ 31 - 0
app/src/main/java/app/mar/game/challenges/QRCodeGeoTreasure.java

@@ -0,0 +1,31 @@
+package app.mar.game.challenges;
+
+import android.app.Activity;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import app.mar.game.Area;
+import app.mar.game.Game;
+
+public class QRCodeGeoTreasure extends QRCodeTreasure implements IGeoTreasure {
+    protected Area mArea;
+
+
+    public QRCodeGeoTreasure(Game g, JSONObject root, Activity a) {
+        super(g, root, a);
+        try
+        {
+            mArea = new Area(g, root.getJSONObject("area"), a);
+        }
+        catch(JSONException e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    @Override
+    public Area getArea() {
+        return mArea;
+    }
+}

+ 3 - 5
app/src/main/java/app/mar/utils/game/challenges/QRCodeTreasure.java → app/src/main/java/app/mar/game/challenges/QRCodeTreasure.java

@@ -1,15 +1,13 @@
-package app.mar.utils.game.challenges;
+package app.mar.game.challenges;
 
 import android.app.Activity;
 
 import org.json.JSONException;
 import org.json.JSONObject;
 
-import app.mar.activities.ARActivity;
-import app.mar.activities.QRCodeActivity;
 import app.mar.activities.QRCodeFragment;
-import app.mar.utils.game.Game;
-import app.mar.utils.game.Resource;
+import app.mar.game.Game;
+import app.mar.game.Resource;
 
 public class QRCodeTreasure extends Treasure {
 

+ 2 - 5
app/src/main/java/app/mar/utils/game/challenges/Question.java → app/src/main/java/app/mar/game/challenges/Question.java

@@ -1,15 +1,12 @@
-package app.mar.utils.game.challenges;
+package app.mar.game.challenges;
 
 import android.app.Activity;
-import android.content.Intent;
 
 import org.json.JSONException;
 import org.json.JSONObject;
 
-import app.mar.activities.ARActivity;
-import app.mar.activities.QuestionActivity;
 import app.mar.activities.QuestionFragment;
-import app.mar.utils.game.Game;
+import app.mar.game.Game;
 
 public class Question extends Challenge {
 

+ 1 - 1
app/src/main/java/app/mar/utils/game/challenges/TextIndice.java → app/src/main/java/app/mar/game/challenges/TextIndice.java

@@ -1,4 +1,4 @@
-package app.mar.utils.game.challenges;
+package app.mar.game.challenges;
 
 import org.json.JSONException;
 import org.json.JSONObject;

+ 1 - 1
app/src/main/java/app/mar/utils/game/challenges/Treasure.java → app/src/main/java/app/mar/game/challenges/Treasure.java

@@ -1,4 +1,4 @@
-package app.mar.utils.game.challenges;
+package app.mar.game.challenges;
 
 import org.json.JSONObject;
 

+ 0 - 1
app/src/main/java/app/mar/ui/MediaView.java

@@ -68,7 +68,6 @@ public class MediaView extends SurfaceView implements View.OnClickListener,Surfa
         final MediaView x=this;
         AssetFileDescriptor afd;
         mPlayer = new MediaPlayer();
-        Log.e("MediaPlayer", "Play: '"+path+"'");
         afd = FileManager.getAfdMedia(mContext, path);
         try {
             mPlayer.setDataSource(afd.getFileDescriptor(),afd.getStartOffset(), afd.getLength());

+ 1 - 1
app/src/main/java/app/mar/ui/ResourceArrayAdapter.java

@@ -13,7 +13,7 @@ import android.widget.TextView;
 import java.util.List;
 
 import app.mar.utils.AndroidResources;
-import app.mar.utils.game.Resource;
+import app.mar.game.Resource;
 
 
 /**

+ 2 - 3
app/src/main/java/app/mar/utils/AndroidResources.java

@@ -9,8 +9,8 @@ import android.net.Uri;
 import app.mar.activities.ImageViewerActivity;
 import app.mar.activities.MediaViewerAcitvity;
 import app.mar.activities.ModelViewerActivity;
-import app.mar.utils.game.Game;
-import app.mar.utils.game.Resource;
+import app.mar.game.Game;
+import app.mar.game.Resource;
 import min3d.core.Object3d;
 import min3d.parser.IParser;
 import min3d.parser.Parser;
@@ -52,7 +52,6 @@ public class AndroidResources {
     public static Intent getViewerIntent(Context c, Resource re)
     {
         Intent intent =null ;
-        System.err.println("Ici !!!!!!!!!!");
         if(re.isAudio() || re.isVideo())
             intent = new Intent(c, MediaViewerAcitvity.class);
         else if(re.is3D())

+ 0 - 2
app/src/main/java/app/mar/utils/GpsStub.java

@@ -48,14 +48,12 @@ public class GpsStub {
             if (res.length > 1) lat = (double) Double.parseDouble(res[1]);
         }catch (Exception e)
         {
-            Log.e("GPSStub", "Stub reading error (first) on '"+str+"'");
         }
 
         try {
             if (res.length > 2) acc = (double) Double.parseDouble(res[2]);
         }catch (Exception e)
         {
-            Log.e("GPSStub", "Stub reading error (second) on '"+str+"'");
         }
 
         add(new GPSPoint(lon, lat,(float) acc));

+ 69 - 0
app/src/main/java/app/mar/utils/L.java

@@ -0,0 +1,69 @@
+package app.mar.utils;
+
+import android.util.Log;
+
+public class L {
+    public static String PREFIXE = "app.mar.activity";
+
+    public static void debug(String prefix, String a)
+    {
+        Log.d(prefix, P()+a);
+    }
+
+    public static void debug(String a)
+    {
+        Log.d(PREFIXE, P()+a);
+    }
+
+    public static void warn(String prefix, String a)
+    {
+        Log.w(prefix, P()+a);
+    }
+
+    public static void warn(String a)
+    {
+        Log.w(PREFIXE, P()+a);
+    }
+
+    public static void error(String prefix, String a)
+    {
+        Log.e(prefix, P()+a);
+    }
+
+    public static void error(String a)
+    {
+        Log.e(PREFIXE, P()+a);
+    }
+
+
+    public static void info(String prefix, String a)
+    {
+        Log.i(prefix, P()+a);
+    }
+
+    public static void info(String a)
+    {
+        Log.i(PREFIXE, P()+a);
+    }
+
+    public static String P()
+    {
+        return functionName()+": ";
+    }
+
+    public static String stackTrace(int i)
+    {
+        StackTraceElement[] stack = Thread.currentThread().getStackTrace();
+        String str="";
+        for(; i<stack.length; i++)
+            str+=i+" "+stack[i]+"\n";
+        return str;
+    }
+
+    public static String functionName()
+    {
+        StackTraceElement[] stack = Thread.currentThread().getStackTrace();
+        return stack[5]+"";
+    }
+
+}

+ 0 - 1
app/src/main/java/app/mar/utils/files/FileManager.java

@@ -33,7 +33,6 @@ public class FileManager {
     public static InputStream openFile(Context a, String path) throws Exception {
         isInit();
         InputStream is = null;
-        System.err.println("ICIIIIIIIIIIIIII '"+path+"'");
         try {
             is = a.getAssets().open(path);
         } catch (IOException e) {

+ 0 - 1
app/src/main/java/min3d/parser/ObjParser.java

@@ -186,7 +186,6 @@ public class ObjParser extends AParser implements IParser {
 
 			resourceID.append(":raw/");
 			resourceID.append(libIDSbuf.toString());
-			Log.e("OBJParser", "Load MTL '" + resourceID.toString() + "'");
 			fileIn = resources.openRawResource(resources.getIdentifier(
 					resourceID.toString(), null, null));
 		}else {