gautrais 7 роки тому
батько
коміт
d5453b8409

+ 0 - 1
app/app.iml

@@ -98,7 +98,6 @@
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-resources" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaPrecompile" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
-      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifest-checker" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/prebuild" />

+ 0 - 11
app/src/main/AndroidManifest.xml

@@ -52,17 +52,6 @@
         <activity
             android:name=".CreditsActivity"
             android:theme="@style/AppTheme.NoActionBar.Fullscreen" />
-        <activity
-            android:name=".QuestionActivity"
-            android:label="@string/title_activity_question" />
-        <activity
-            android:name=".QCMActivity"
-            android:label="@string/title_activity_qcm"
-            android:theme="@style/AppTheme.NoActionBar" />
-        <activity
-            android:name=".QRCodeActivity"
-            android:label="@string/title_activity_qrcode"
-            android:theme="@style/AppTheme.NoActionBar" />
         <activity
             android:name=".MenuActivity"
             android:label="@string/title_activity_qrcode"

+ 2 - 1
app/src/main/assets/a_res

@@ -21,5 +21,6 @@
 	],
 	"stage" : 0,
 	"title" : "Une photo ... ",
-	"type" : "Image"
+	"type" : "Image",
+	"display" : true
 }

+ 2 - 1
app/src/main/assets/b_res

@@ -21,5 +21,6 @@
 	],
 	"stage" : 1,
 	"title" : "Une autre photo",
-	"type" : "Image"
+	"type" : "Image",
+	"display" : true
 }

+ 2 - 1
app/src/main/assets/c_res

@@ -21,5 +21,6 @@
 	],
 	"stage" : 2,
 	"title" : "Putin uneautre photo",
-	"type" : "Image"
+	"type" : "Image",
+	"display" : true
 }

+ 101 - 47
app/src/main/assets/game_medium

@@ -2,18 +2,27 @@
     "password" : "123456",
     "max_time" : 30,
 	"stages" : [
-		
+		{
+            "name" : "QrCode",
+            "challenges" : [],
+            "resources" : ["a"]
+        },
+
 		{
 			"name" : "QrCode",
 			"challenges" :
 				[
 					{
-						"type" : "QRCodeTreasure",
+						"type" : "QRCodeGeoTreasure",
 						"name" : "A trouver",
 						"bad_message" : "Essaye encore",
 						"qr_value" : "1",
 						"resource" : "b",
 						"indices" : [
+						    {
+						        "type" : "geo",
+						        "penality": 1
+						    },
 						    {
 						        "type" : "text",
 						        "text" : "Entre le 0 et le 2",
@@ -24,7 +33,49 @@
 						        "text" : "sqrt(x) = x",
                                  "penality": 5
 						    }
-						]
+						],
+						"area" : {
+                            "coordinates" :
+                            [
+                                [
+                                    0.14911472797393799,
+                                    45.629791259765625
+                                ],
+                                [
+                                    0.15027344226837158,
+                                    45.62957763671875
+                                ],
+                                [
+                                    0.1496511697769165,
+                                    45.628990173339844
+                                ],
+                                [
+                                    0.14827251434326172,
+                                    45.628894805908203
+                                ],
+                                [
+                                    0.14798820018768311,
+                                    45.629344940185547
+                                ],
+                                [
+                                    0.14833688735961914,
+                                    45.629764556884766
+                                ]
+                            ],
+                            "name" : "a",
+                            "point" :
+                                {
+                                    "angle" : 180.0,
+                                    "coordinates" :
+                                    [
+                                        0.14913618564605713,
+                                        45.629505157470703
+                                    ],
+                                    "field" : 90.0,
+                                    "radius" : 100.0,
+                                    "useAngle" : false
+                                }
+                        }
 					},
                     {
                          "type" : "QCM",
@@ -49,57 +100,60 @@
                     }
 
 				],
-			"resources" : ["a"]
+			"resources" : ["b"]
 		},
 		{
 			"name" : "Le Premier",
-			"challenges" : 
+			"challenges" :
 				[
-
-                    {
-                       "type" : "QCM",
-                       "name" : "Joconde",
-                       "question" : "Qui a peint la Joconde ?",
-                       "answer" : "Léonard De Vinci",
-                       "choices" : ["Léonard De Vinci", "Jean Ferrat", "Patrick Timsit", "BHL"],
+                 {
+                    "type" : "QCM",
+                    "name" : "Joconde",
+                    "question" : "Qui a peint la Joconde ?",
+                    "answer" : "Léonard De Vinci",
+                    "choices" : ["Léonard De Vinci", "Jean Ferrat", "Patrick Timsit", "BHL"],
+                    "good_message" : "Bien joué !",
+                    "bad_message" : "T'es nul !",
+                     "indices" : [
+                         {
+                             "type" : "text",
+                             "text" : "Un italien",
+                                "penality": 3
+                         },
+                         {
+                             "type" : "text",
+                             "text" : "Un vieu !",
+                                 "penality": 2
+                         }
+                     ]
+                 },
+                 {
+                       "type" : "Question",
+                       "name" : "Question A tous",
+                       "question" : "Quelle est la réponse à la vie l'univers et le reste ?",
+                       "answer" : "42",
                        "good_message" : "Bien joué !",
                        "bad_message" : "T'es nul !",
-                        "indices" : [
-                            {
-                                "type" : "text",
-                                "text" : "Un italien",
-                                   "penality": 3
-                            },
-                            {
-                                "type" : "text",
-                                "text" : "Un vieu !",
-                                    "penality": 2
-                            }
-                        ]
-                    },
-                    {
-                          "type" : "Question",
-                          "name" : "Question A tous",
-                          "question" : "Quelle est la réponse à la vie l'univers et le reste ?",
-                          "answer" : "42",
-                          "good_message" : "Bien joué !",
-                          "bad_message" : "T'es nul !",
-                          "indices" : [
-                              {
-                                  "type" : "text",
-                                  "text" : "Dans H2G2",
-                                     "penality": 3
-                              },
-                              {
-                                  "type" : "text",
-                                  "text" : "6 x 7 = ?",
-                                   "penality": 2
-                              }
-                          ]
-                    }
+                       "indices" : [
+                           {
+                               "type" : "text",
+                               "text" : "Dans H2G2",
+                                  "penality": 3
+                           },
+                           {
+                               "type" : "text",
+                               "text" : "6 x 7 = ?",
+                                "penality": 2
+                           }
+                       ]
+                 }
 				],
-			"resources" : ["a"]
-		}
+			"resources" : ["c"]
+		},
+		{
+            "name" : "QrCode",
+            "challenges" : []
+        },
 	],
 	"credits" : 
 	{

+ 5 - 0
app/src/main/java/app/mar/activities/ChallengeDriver.java

@@ -1,6 +1,7 @@
 package app.mar.activities;
 
 import android.net.Uri;
+import android.view.View;
 
 import app.mar.game.Area;
 import app.mar.game.challenges.Challenge;
@@ -18,4 +19,8 @@ public interface ChallengeDriver extends ChallengeFragment.OnFragmentInteraction
     public void   pauseLocalisation();
     public double getDistanceWith(Area a);
 
+
+    public void setVisibilityView(int res, int state);
+    public void setVisibilityView(int[] res, int state);
+
 }

+ 30 - 12
app/src/main/java/app/mar/activities/ChallengeFragment.java

@@ -23,6 +23,7 @@ import app.mar.game.challenges.GeoIndice;
 import app.mar.game.challenges.IGeoTreasure;
 import app.mar.game.challenges.Indice;
 import app.mar.game.challenges.TextIndice;
+import app.mar.utils.L;
 
 public abstract class ChallengeFragment extends Fragment {
     public abstract boolean check();
@@ -65,20 +66,27 @@ public abstract class ChallengeFragment extends Fragment {
     private void updateIndices()
     {
         ArrayList<Indice> inds = mChallenge.getIndices();
+        int indInd = mChallenge.getIndiceIndex();
         if(inds.size()>0) mUIGlobalIndice.setVisibility(View.VISIBLE);
         for(int i=0; i<inds.size(); i++)
         {
             Indice ind = inds.get(i);
+            if(!ind.isDiscovered()) return;
             if(ind instanceof GeoIndice && mUIGeoIndice!=null)
             {
+                mUIGlobalIndice.setVisibility(View.VISIBLE);
                 mUIGeoIndice.setVisibility(View.VISIBLE);
+                startGeoUpdateTimer();
             }else if(ind instanceof TextIndice && mUITextIndices!=null)
             {
                 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);
             }
         }
+        //si on arrive ici, ca veut dire que tous les indices ont ete découvert
+        getDriver().setVisibilityView(R.id.btn_indice, View.INVISIBLE);
     }
 
     public Indice showIndice()
@@ -141,18 +149,25 @@ public abstract class ChallengeFragment extends Fragment {
     {
         mChallenge=c;
         resetUi();
+        if(!mChallenge.hasNextIndice())
+        {
+            getDriver().setVisibilityView(R.id.btn_indice, View.INVISIBLE);
+        }
         onInitChallenge(c);
     }
 
-
-    protected void ready()
+    public ChallengeDriver getDriver()
     {
         Activity act = getActivity();
         if(act instanceof ChallengeDriver)
-        {
-            ChallengeDriver cd = (ChallengeDriver)act;
-            cd.onReady();
-        }
+            return (ChallengeDriver)act;
+        throw new RuntimeException("Error Activty hosting this Fragment ("+getClass()+") is not a ChallengeDriver");
+    }
+
+
+    protected void ready()
+    {
+        getDriver().onReady();
     }
 
     @Override
@@ -173,6 +188,10 @@ public abstract class ChallengeFragment extends Fragment {
         updateIndices();
     }
 
+    public void onPause() {
+        super.onPause();
+    }
+
     public boolean onKeyDown(int keyCode, KeyEvent event) {
         return false;
     }
@@ -223,18 +242,17 @@ public abstract class ChallengeFragment extends Fragment {
     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");
+        int d= (int)getDriver().getDistanceWith(a);
+        if(d>=0) mUIGeoIndice.setText("Distance "+d+" m");
+        else mUIGeoIndice.setText("Géolocalisation ...");
     }
 
     protected void stopGeoUpdateTimer()
     {
-        mTimer.cancel();
+        if(mTimer!=null) mTimer.cancel();
     }
 
     protected void startGeoUpdateTimer()

+ 46 - 3
app/src/main/java/app/mar/activities/HostActivity.java

@@ -3,6 +3,7 @@ package app.mar.activities;
 import android.app.Activity;
 import android.app.FragmentManager;
 import android.app.FragmentTransaction;
+import android.content.Intent;
 import android.net.Uri;
 import android.os.Bundle;
 import android.view.View;
@@ -14,9 +15,12 @@ import java.util.TimerTask;
 
 import app.mar.game.Area;
 import app.mar.game.Game;
+import app.mar.game.Resource;
 import app.mar.game.Stage;
 import app.mar.game.challenges.Challenge;
 import app.mar.game.challenges.Indice;
+import app.mar.utils.AndroidResources;
+import app.mar.utils.L;
 
 
 public class HostActivity extends Activity implements ChallengeDriver{
@@ -102,6 +106,10 @@ public class HostActivity extends Activity implements ChallengeDriver{
             ft.replace(R.id.container, mCurrentFragment);
             ft.commit();
         }
+        else
+        {
+            onReady();
+        }
     }
 
     @Override
@@ -148,7 +156,9 @@ public class HostActivity extends Activity implements ChallengeDriver{
 
     public void onClickVideos(View v)
     {
-
+        Intent intent = new Intent(this, ResourceListActivity.class);
+        intent.putExtra("inventaire", mGame.getInventaire());
+        startActivity(intent);
     }
 
     public void onClickDisarm(View v)
@@ -175,6 +185,20 @@ public class HostActivity extends Activity implements ChallengeDriver{
     }
 
 
+    public void setVisibilityView(int res, int state)
+    {
+        View v = findViewById(res);
+        if(v!=null) v.setVisibility(state);
+    }
+
+
+    public void setVisibilityView(int[] res, int state)
+    {
+        for(int i=0; i<res.length; i++)
+            setVisibilityView(res[i], state);
+    }
+
+
     public void nextChallenge() {
         Stage s = mGame.getCurrentStage();
         Challenge c = s.nextChallenge();
@@ -188,6 +212,16 @@ public class HostActivity extends Activity implements ChallengeDriver{
         }
     }
 
+    public void startResourceFound()
+    {
+        Resource r = null;
+        while( (r=mGame.popLastResource())!=null )
+        {
+            Intent intent = AndroidResources.getViewerIntent(this, r);
+            startActivity(intent);
+        }
+    }
+
     @Override
     public void challengeValidate(Challenge c) {
         c.setDone();
@@ -200,12 +234,21 @@ public class HostActivity extends Activity implements ChallengeDriver{
 
     private boolean startChallenge()
     {
+        boolean b=false;
+        int res[] = {R.id.btn_indice, R.id.btn_valid, R.id.btn_videos};
+        for(int i=0; i<res.length; i++)
+        {
+            View v = findViewById(res[i]);
+            v.setVisibility(View.VISIBLE);
+        }
+
         Challenge c = mGame.getCurrentChallenge();
         if(c!=null) {
             c.exec(this);
-            return true;
+            b=true;
         }
-        return false;
+        startResourceFound();
+        return b;
     }
 
 

+ 7 - 19
app/src/main/java/app/mar/activities/QRCodeFragment.java

@@ -77,11 +77,12 @@ public class QRCodeFragment extends ChallengeFragment  implements
         {
             mQr=null;
         }
-        if( (c instanceof QRCodeGeoTreasure) && (getActivity() instanceof  ChallengeDriver))
+        if( (c instanceof QRCodeGeoTreasure) )
         {
-            ChallengeDriver cd = (ChallengeDriver) getActivity();
-            cd.startLocalisation();
+            getDriver().startLocalisation();
         }
+
+        getDriver().setVisibilityView(R.id.btn_valid, View.INVISIBLE);
     }
 
     @Override
@@ -116,21 +117,13 @@ public class QRCodeFragment extends ChallengeFragment  implements
     @Override
     public void onStart() {
         super.onStart();
-        if(getActivity() instanceof  ChallengeDriver)
-        {
-            ChallengeDriver cd = (ChallengeDriver) getActivity();
-            cd.resumeLocalisation();
-        }
+        getDriver().resumeLocalisation();
     }
 
     @Override
     public void onStop() {
         super.onStop();
-        if(getActivity() instanceof  ChallengeDriver)
-        {
-            ChallengeDriver cd = (ChallengeDriver) getActivity();
-            cd.pauseLocalisation();
-        }
+        getDriver().pauseLocalisation();
     }
 
     @Override
@@ -198,12 +191,7 @@ public class QRCodeFragment extends ChallengeFragment  implements
         {
             barcodeScannerView.pause();
             Activity act = getActivity();
-            if(act instanceof ChallengeDriver)
-            {
-                ChallengeDriver a = (ChallengeDriver) act;
-                a.challengeValidate(mChallenge);
-            }
-
+            getDriver().challengeValidate(mChallenge);
         }else
         {
             Toast.makeText(getActivity(), mQr.getBadQRMessage(), Toast.LENGTH_LONG).show();

+ 12 - 40
app/src/main/java/app/mar/activities/ResourceListActivity.java

@@ -4,7 +4,10 @@ import android.app.Activity;
 import android.os.Bundle;
 import android.widget.ListView;
 
+import java.util.ArrayList;
+
 import app.mar.game.Game;
+import app.mar.ui.ResourceArrayAdapter;
 import app.mar.utils.*;
 import app.mar.game.*;
 /**
@@ -12,63 +15,32 @@ import app.mar.game.*;
  * status bar and navigation/system bar) with user interaction.
  */
 public class ResourceListActivity extends Activity {
-    protected Game mGame;
+    protected Inventaire mInventaire;
     protected ListView mList;
-    /*
-    protected void addStage(ArrayList<Object> ar, int stage)
-    {
-        LinearLayout nl = new LinearLayout(this);
-        CustomListView lv = new CustomListView(this);
-        ScrollView sv = new ScrollView(this);
-        TextView b = new TextView(this);
-        ResourceArrayAdapter aa;
-        b.setText("Etape "+stage);
-        b.setTextColor(Color.rgb(0x33, 0xb5, 0xe5));
-        b.setTextSize(30);
-        b.setTypeface(null, Typeface.BOLD);
-        aa = new ResourceArrayAdapter(this, android.R.layout.simple_list_item_1, ar);
-        lv.setOnItemClickListener(aa);
-        lv.setAdapter(aa);
-        nl.setOrientation(LinearLayout.VERTICAL);
-        nl.addView(b);
-        nl.addView(sv);
-        sv.addView(lv);
-        //lv.setLayoutParams(new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT,  LinearLayout.LayoutParams.MATCH_PARENT));
-        mLayout.addView(nl);
-    }
-    protected void fill()
-    {
-        if(mGame!=null)
-        {
-            ArrayList< ArrayList<Resource> > resources = mGame.getResourceByStage();
-            for(int i = 0; i< resources.size(); i++)
-                addStage(resources.get(i), i);
-        }
-    }*/
+
+
     protected void fill()
     {
-        if(mGame!=null)
+        if(mInventaire!=null)
         {
-          /*  ArrayList< ArrayList<Resource> > resources = mGame.getResourceByStage();
+            ArrayList<Resource> resources = mInventaire.getDisplayResources();
             ArrayList<Object> obs = new ArrayList<Object>();
             for(int i = 0; i< resources.size(); i++) {
-                obs.add("Étape "+i);
-                for(int j=0; j<resources.get(i).size(); j++) {
-                    obs.add(resources.get(i).get(j));
-                }
+                obs.add(resources.get(i));
             }
             ResourceArrayAdapter aa;
             aa = new ResourceArrayAdapter(this, android.R.layout.simple_list_item_1, obs);
             mList.setOnItemClickListener(aa);
-            mList.setAdapter(aa);*/
+            mList.setAdapter(aa);
         }
     }
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_resource_list);
         FontChangeCrawler.setFont(this);
-        mGame = (Game)getIntent().getSerializableExtra("game");
+        mInventaire = (Inventaire)getIntent().getSerializableExtra("inventaire");
         mList = (ListView) findViewById(R.id.list_layout);
         fill();
     }

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

@@ -4,11 +4,12 @@ import android.util.Log;
 
 import com.google.zxing.common.StringUtils;
 
+import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
 
-public class Bomb {
+public class Bomb implements Serializable{
     protected long      mDeadLine;
     protected String   mPassword;
     protected char    mPasswordKnown[];

+ 39 - 2
app/src/main/java/app/mar/game/Game.java

@@ -30,7 +30,7 @@ public class Game  implements Serializable {
     private static Game gGame = null;
 
     protected String           mName;
-
+    protected ArrayList<Resource>   mResourceQueue = new ArrayList<Resource>();
     protected ArrayList<Stage> mStages = new ArrayList<Stage>();
     protected Stage            mCurrentStage=null;
     protected int              mCurrentStageIndex=0;
@@ -38,6 +38,7 @@ public class Game  implements Serializable {
     protected Player           mPlayer;
     protected Settings         mSettings = new Settings();
     protected String           mMap=null;
+    protected Inventaire       mInventaire;
 
     protected ResourceManager mResources = new ResourceManager();
     protected ChallengeReturn mLastReturn = null;
@@ -49,6 +50,7 @@ public class Game  implements Serializable {
     {
         JSONObject root = JSONAssetsManager.load(act, name);
         mName=name;
+        mInventaire=new Inventaire();
         mPlayer = new Player(act);
         try {
             JSONArray arr = root.getJSONArray("stages");
@@ -90,7 +92,30 @@ public class Game  implements Serializable {
     public Challenge getCurrentChallenge()
     {
         if(mCurrentStage==null) return null;
-        return mCurrentStage.getCurrentChallenge();
+        Challenge c = mCurrentStage.getCurrentChallenge();
+        if(c==null)
+        {
+            ArrayList<Resource> res = mCurrentStage.getResources();
+            mInventaire.addResource(res);
+
+            for(int i=0; i<res.size(); i++)
+                mResourceQueue.add(res.get(i));
+
+            nextStage();
+            return getCurrentChallenge();
+        }
+        return c;
+    }
+
+    public Resource popLastResource()
+    {
+        if(mResourceQueue.size()>0)
+        {
+            Resource x = mResourceQueue.get(0);
+            mResourceQueue.remove(0);
+            return x;
+        }
+        return null;
     }
 
     public void registerResource(String name, Activity act)
@@ -303,11 +328,23 @@ public class Game  implements Serializable {
     public Stage nextStage() {
         mCurrentStageIndex++;
         if(mCurrentStageIndex<mStages.size())
+        {
+            ArrayList<Resource> res = mCurrentStage.getResources();
+            mInventaire.addResource(res);
+
+            for(int i=0; i<res.size(); i++)
+                mResourceQueue.add(res.get(i));
+
             return mCurrentStage=mStages.get(mCurrentStageIndex);
+        }
         return mCurrentStage=null;
     }
 
     public Bomb getBomb() {
         return mBomb;
     }
+
+    public Inventaire getInventaire() {
+        return mInventaire;
+    }
 }

+ 53 - 0
app/src/main/java/app/mar/game/Inventaire.java

@@ -0,0 +1,53 @@
+package app.mar.game;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+
+public class Inventaire implements Serializable {
+    protected ArrayList<Resource>   mAllResources = new ArrayList<Resource>();
+    protected ArrayList<Resource>   mDisplayResources = new ArrayList<Resource>();
+
+    public Inventaire()
+    {
+
+    }
+
+    public void addResource(Resource r)
+    {
+        if(mAllResources.contains(r))
+            return;
+
+        mAllResources.add(r);
+        if(r.isDisplay())
+            mDisplayResources.add(r);
+    }
+
+    public void addResource(ArrayList<Resource> r)
+    {
+        for(int i=0; i<r.size(); i++)
+            addResource(r.get(i));
+    }
+
+    public boolean contains(Resource r)
+    {
+        return mAllResources.contains(r);
+    }
+
+    public Resource get(int i)
+    {
+        return mAllResources.get(i);
+    }
+
+    public int size()
+    {
+        return getAllResources().size();
+    }
+
+    public ArrayList<Resource> getAllResources() {
+        return mAllResources;
+    }
+
+    public ArrayList<Resource> getDisplayResources() {
+        return mDisplayResources;
+    }
+}

+ 10 - 0
app/src/main/java/app/mar/game/Resource.java

@@ -26,6 +26,7 @@ public class Resource implements Serializable {
     protected Number3d mScale = new Number3d(1,1,1);
     protected String mComment = "null";
     protected boolean isLoaded = false;
+    protected boolean mIsDisplay = false;
     protected int   mStage;
     protected String mType = ""; //3D Image Audio Video
     protected String mTitle= ""; //3D Image Audio Video
@@ -57,6 +58,12 @@ public class Resource implements Serializable {
         } catch (JSONException e) {
             e.printStackTrace();
         }
+
+        try {
+            mIsDisplay=(boolean) obj.getBoolean("display");
+        } catch (JSONException e) {
+            mIsDisplay=false;
+        }
     }
 
     public void loadModel(Activity context)
@@ -178,4 +185,7 @@ public class Resource implements Serializable {
         return mType.toLowerCase().compareTo("image")==0;
     }
 
+    public boolean isDisplay() {
+        return mIsDisplay;
+    }
 }

+ 8 - 3
app/src/main/java/app/mar/game/Stage.java

@@ -32,15 +32,20 @@ public class Stage  implements Serializable {
                 mChallenge.add(c);
             }
 
-            chall = root.getJSONArray("resources");
-            for(int i=0; i<chall.length(); i++)
-                mResources.add(new Resource(chall.getString(i), act));
 
 
         } catch (JSONException e) {
             e.printStackTrace();
             throw new RuntimeException(e.getMessage());
         }
+
+        try{
+
+            JSONArray chall = root.getJSONArray("resources");
+            for(int i=0; i<chall.length(); i++)
+                mResources.add(new Resource(chall.getString(i), act));
+        } catch (JSONException e) {
+        }
     }
 
 

+ 3 - 1
app/src/main/java/app/mar/utils/geometry/GPSPoint.java

@@ -2,6 +2,8 @@ package app.mar.utils.geometry;
 
 import java.io.Serializable;
 
+import app.mar.utils.L;
+
 /**
  * Created by ptitcois on 16/08/16.
  */
@@ -51,6 +53,7 @@ public class GPSPoint extends app.mar.utils.geometry.Point  implements Serializa
 
     public double getDistanceWith(Point b)
     {
+        if(b==null) return -1;
 		double theta = mY - b.mY;
 		double dist = Math.sin(deg2rad(mX)) * Math.sin(deg2rad(b.mX)) + Math.cos(deg2rad(mX)) * Math.cos(deg2rad(b.mX)) * Math.cos(deg2rad(theta));
 		dist = Math.acos(dist);
@@ -59,7 +62,6 @@ public class GPSPoint extends app.mar.utils.geometry.Point  implements Serializa
 		dist = dist * 1.609344 *1000;
 
 		return (dist);
-
 	}
     
     private static double rad2deg(double rad) {

+ 0 - 63
app/src/main/res/layout/activity_qcm.xml

@@ -1,63 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout 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="app.mar.activities.QuestionActivity">
-
-    <LinearLayout
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:orientation="vertical">
-
-        <FrameLayout
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_weight="1">
-
-            <ImageView
-                android:id="@+id/iv_img"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:src="@drawable/bscanner_tap" />
-        </FrameLayout>
-
-        <FrameLayout
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:layout_weight="1">
-
-            <LinearLayout
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:orientation="vertical">
-
-                <TextView
-                    android:id="@+id/tv_question"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:editable="false"
-                    android:text="Comment s'appelait le joli cheval blanc d'Henri IV ?"
-                    android:textSize="18sp" />
-
-                <RadioGroup
-                    android:id="@+id/rg_qcm"
-                    android:layout_width="match_parent"
-                    android:layout_height="match_parent">
-
-                </RadioGroup>
-
-            </LinearLayout>
-
-        </FrameLayout>
-
-        <Button
-            android:id="@+id/btn_ok"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_weight="0"
-            android:onClick="onValid"
-            android:text="Valider" />
-    </LinearLayout>
-</LinearLayout>

+ 0 - 25
app/src/main/res/layout/activity_qrcode.xml

@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<android.support.design.widget.CoordinatorLayout 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="app.mar.activities.QRCodeActivity">
-
-    <com.journeyapps.barcodescanner.DecoratedBarcodeView
-        android:id="@+id/zxing_barcode_scanner"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        app:zxing_scanner_layout="@layout/custom_barcode_scanner">
-    </com.journeyapps.barcodescanner.DecoratedBarcodeView>
-
-    <Button
-        android:id="@+id/switch_flashlight"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:text="On"
-        android:layout_alignParentTop="true"
-        android:layout_centerHorizontal="true"
-        android:onClick="switchFlashlight"/>
-
-</android.support.design.widget.CoordinatorLayout>

+ 0 - 64
app/src/main/res/layout/activity_question.xml

@@ -1,64 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout 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="app.mar.activities.QuestionActivity">
-
-    <LinearLayout
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:orientation="vertical">
-
-        <FrameLayout
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_weight="1">
-
-            <ImageView
-                android:id="@+id/iv_img"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:src="@drawable/bscanner_tap" />
-        </FrameLayout>
-
-        <FrameLayout
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:layout_weight="1">
-
-            <LinearLayout
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:orientation="vertical">
-
-                <TextView
-                    android:id="@+id/tv_question"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:editable="false"
-                    android:text="Qui a tué le cheval blanc d'Henri IV ?"
-                    android:textSize="18sp" />
-
-            </LinearLayout>
-
-        </FrameLayout>
-
-        <EditText
-            android:id="@+id/et_response"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_weight="0"
-            android:ems="10"
-            android:inputType="textPersonName" />
-
-        <Button
-            android:id="@+id/btn_ok"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_weight="0"
-            android:onClick="onValid"
-            android:text="Valider" />
-    </LinearLayout>
-</LinearLayout>

+ 8 - 9
app/src/main/res/layout/activity_resource_list.xml

@@ -2,7 +2,6 @@
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:background="@drawable/background"
     android:orientation="vertical"
     tools:context="app.mar.activities.ResourceListActivity">
 
@@ -14,24 +13,24 @@
          android:fitsSystemWindows. -->
 
     <Button
+        android:id="@+id/button5"
         android:layout_width="match_parent"
         android:layout_height="70dp"
-        android:text="Inventaire"
-        android:id="@+id/button5"
         android:layout_gravity="center_horizontal"
         android:background="@drawable/title"
+        android:text="Inventaire"
         android:textColor="@color/dull_4"
-        android:textStyle="bold"
-        android:textSize="30dp" />
+        android:textSize="30dp"
+        android:textStyle="bold" />
 
     <ListView
+        android:id="@+id/list_layout"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:id="@+id/list_layout"
-        android:scrollingCache="true"
         android:choiceMode="singleChoice"
-        android:fastScrollEnabled="true"
         android:fastScrollAlwaysVisible="true"
-        android:longClickable="false" />
+        android:fastScrollEnabled="true"
+        android:longClickable="false"
+        android:scrollingCache="true" />
 
 </LinearLayout>

+ 1 - 7
app/src/main/res/layout/fragment_qcm.xml

@@ -28,7 +28,6 @@ tools:context="app.mar.activities.QCMFragment">
             android:layout_weight="1">
 
             <LinearLayout
-                android:id="@+id/ll_rootIndices"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:orientation="vertical">
@@ -42,16 +41,11 @@ tools:context="app.mar.activities.QCMFragment">
                     android:textSize="18sp" />
 
                 <LinearLayout
+                    android:id="@+id/ll_rootIndices"
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
                     android:orientation="vertical">
 
-                    <TextView
-                        android:id="@+id/textView"
-                        android:layout_width="match_parent"
-                        android:layout_height="wrap_content"
-                        android:text="Indices:" />
-
                     <LinearLayout
                         android:id="@+id/ll_textIndices"
                         android:layout_width="match_parent"

+ 77 - 33
app/src/main/res/layout/fragment_qrcode.xml

@@ -1,54 +1,98 @@
-<android.support.design.widget.CoordinatorLayout 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="app.mar.activities.QRCodeFragment">
+<LinearLayout 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"
+    android:orientation="horizontal"
+    tools:context="app.mar.activities.QRCodeFragment">
+
+
+    <android.support.design.widget.CoordinatorLayout
+        android:id="@+id/root_qr"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:visibility="gone">
+
+        <com.journeyapps.barcodescanner.DecoratedBarcodeView
+            android:id="@+id/zxing_barcode_scanner"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            app:zxing_scanner_layout="@layout/custom_barcode_scanner">
+
+        </com.journeyapps.barcodescanner.DecoratedBarcodeView>
+
+        <Button
+            android:id="@+id/switch_flashlight"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignParentTop="true"
+            android:layout_centerHorizontal="true"
+            android:onClick="switchFlashlight"
+            android:text="On"
+            app:layout_anchor="@+id/zxing_barcode_scanner"
+            app:layout_anchorGravity="bottom|center" />
+
+        <LinearLayout
+            android:id="@+id/ll_rootIndices"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical">
+
+            <TextView
+                android:id="@+id/tv_geoIndice"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:gravity="center"
+                android:text="130 m"
+                android:textSize="14sp" />
+
+            <LinearLayout
+                android:id="@+id/ll_textIndices"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:orientation="vertical"></LinearLayout>
+        </LinearLayout>
+
+    </android.support.design.widget.CoordinatorLayout>
 
     <LinearLayout
-        android:id="@+id/ll_rootIndices"
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
+        android:layout_height="match_parent"
         android:orientation="vertical">
 
         <TextView
-            android:id="@+id/tv_geoIndice"
+            android:id="@+id/tv_geoIndice2"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:gravity="center"
             android:text="130 m"
             android:textSize="14sp" />
 
+        <ImageView
+            android:id="@+id/imageView2"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            android:src="@drawable/bscanner_tap" />
+
         <TextView
-            android:id="@+id/textView3"
+            android:id="@+id/tv_question"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:text="Indices" />
+            android:text="TextView"
+            android:textSize="14sp" />
 
         <LinearLayout
-            android:id="@+id/ll_textIndices"
+            android:id="@+id/ll_textIndices2"
             android:layout_width="match_parent"
-            android:layout_height="match_parent"
+            android:layout_height="wrap_content"
             android:orientation="vertical"></LinearLayout>
+
+        <Button
+            android:id="@+id/btn_scan"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:text="Scanner le code" />
     </LinearLayout>
 
-    <com.journeyapps.barcodescanner.DecoratedBarcodeView
-    android:id="@+id/zxing_barcode_scanner"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    app:zxing_scanner_layout="@layout/custom_barcode_scanner">
-
-    </com.journeyapps.barcodescanner.DecoratedBarcodeView>
-
-    <Button
-        android:id="@+id/switch_flashlight"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_alignParentTop="true"
-        android:layout_centerHorizontal="true"
-        android:onClick="switchFlashlight"
-        android:text="On"
-        app:layout_anchor="@+id/zxing_barcode_scanner"
-        app:layout_anchorGravity="bottom|center" />
-
-</android.support.design.widget.CoordinatorLayout>
+</LinearLayout>

+ 1 - 7
app/src/main/res/layout/fragment_question.xml

@@ -29,7 +29,6 @@ tools:context="app.mar.activities.QuestionFragment">
         android:layout_weight="1">
 
         <LinearLayout
-            android:id="@+id/ll_rootIndices"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:orientation="vertical">
@@ -43,16 +42,11 @@ tools:context="app.mar.activities.QuestionFragment">
                 android:textSize="18sp" />
 
             <LinearLayout
+                android:id="@+id/ll_rootIndices"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
                 android:orientation="vertical">
 
-                <TextView
-                    android:id="@+id/textView"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:text="Indices:" />
-
                 <LinearLayout
                     android:id="@+id/ll_textIndices"
                     android:layout_width="match_parent"