소스 검색

Froms MystereARecouvrance

François Gautrais 7 년 전
부모
커밋
9356cf676c
45개의 변경된 파일1578개의 추가작업 그리고 1014개의 파일을 삭제
  1. 35 0
      app/build.gradle
  2. 27 16
      app/src/main/AndroidManifest.xml
  3. 90 108
      app/src/main/java/app/mar/activities/ARActivity.java
  4. 5 0
      app/src/main/java/app/mar/activities/IRequestCode.java
  5. 2 4
      app/src/main/java/app/mar/activities/MARMenuActivity.java
  6. 57 37
      app/src/main/java/app/mar/activities/MenuActivity.java
  7. 107 0
      app/src/main/java/app/mar/activities/QCMActivity.java
  8. 154 0
      app/src/main/java/app/mar/activities/QRCodeActivity.java
  9. 69 0
      app/src/main/java/app/mar/activities/QuestionActivity.java
  10. 2 2
      app/src/main/java/app/mar/activities/ResourceListActivity.java
  11. 14 15
      app/src/main/java/app/mar/activities/SettingsActivity.java
  12. 0 81
      app/src/main/java/app/mar/activities/TransferActivity.java
  13. 0 249
      app/src/main/java/app/mar/utils/ResourceManager.java
  14. 32 54
      app/src/main/java/app/mar/utils/game/Area.java
  15. 54 392
      app/src/main/java/app/mar/utils/game/Game.java
  16. 1 0
      app/src/main/java/app/mar/utils/game/Place.java
  17. 12 0
      app/src/main/java/app/mar/utils/game/QRCodeReturn.java
  18. 5 9
      app/src/main/java/app/mar/utils/game/Resource.java
  19. 57 0
      app/src/main/java/app/mar/utils/game/ResourceManager.java
  20. 62 45
      app/src/main/java/app/mar/utils/game/Stage.java
  21. 108 0
      app/src/main/java/app/mar/utils/game/challenges/Challenge.java
  22. 65 0
      app/src/main/java/app/mar/utils/game/challenges/ChallengeReturn.java
  23. 36 0
      app/src/main/java/app/mar/utils/game/challenges/GeoTreasure.java
  24. 41 0
      app/src/main/java/app/mar/utils/game/challenges/QCM.java
  25. 53 0
      app/src/main/java/app/mar/utils/game/challenges/QRCodeTreasure.java
  26. 62 0
      app/src/main/java/app/mar/utils/game/challenges/Question.java
  27. 13 0
      app/src/main/java/app/mar/utils/game/challenges/Treasure.java
  28. 63 0
      app/src/main/res/layout/activity_qcm.xml
  29. 25 0
      app/src/main/res/layout/activity_qrcode.xml
  30. 64 0
      app/src/main/res/layout/activity_question.xml
  31. 0 1
      app/src/main/res/layout/activity_transfer.xml
  32. 31 0
      app/src/main/res/layout/custom_barcode_scanner.xml
  33. 21 0
      app/src/main/res/layout/zxing_barcode_scanner.xml
  34. 30 0
      app/src/main/res/layout/zxing_capture.xml
  35. 9 0
      app/src/main/res/values/strings.xml
  36. 26 0
      app/src/main/res/values/zxing_attrs.xml
  37. 29 0
      app/src/main/res/values/zxing_colors.xml
  38. 27 0
      app/src/main/res/values/zxing_ids.xml
  39. 5 0
      app/src/main/res/values/zxing_themes.xml
  40. 24 0
      base/build.gradle
  41. 2 1
      build.gradle
  42. 26 0
      feature/build.gradle
  43. 21 0
      feature/proguard-rules.pro
  44. 6 0
      gradle/wrapper/gradle-wrapper.properties
  45. 6 0
      instantapp/build.gradle

+ 35 - 0
app/build.gradle

@@ -0,0 +1,35 @@
+apply plugin: 'com.android.application'
+
+android {
+    compileSdkVersion 27
+
+
+
+    defaultConfig {
+        applicationId "app.brest.projetmjc.app"
+        minSdkVersion 14
+        targetSdkVersion 27
+        versionCode 1
+        versionName "1.0"
+
+
+    }
+
+    buildTypes {
+        release {
+            minifyEnabled false
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+        }
+    }
+
+}
+
+dependencies {
+    implementation project(':feature')
+    implementation project(':base')
+    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
+    implementation 'com.android.support:design:27.1.0'
+    implementation 'com.android.support:gridlayout-v7:27.1.0'
+    implementation('com.journeyapps:zxing-android-embedded:3.6.0') { transitive = false }
+    implementation 'com.google.zxing:core:3.3.0'
+}

+ 27 - 16
app/src/main/AndroidManifest.xml

@@ -15,7 +15,6 @@
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
 
-
     <application
         android:allowBackup="true"
         android:icon="@drawable/logo"
@@ -23,38 +22,37 @@
         android:supportsRtl="true"
         android:theme="@style/AppTheme"
         tools:replace="android:icon">
-        <activity android:name="app.mar.activities.ARActivity" />
+        <activity android:name=".ARActivity" />
         <activity
-            android:name="app.mar.activities.ImageViewerActivity"
+            android:name=".ImageViewerActivity"
             android:theme="@style/AppTheme.NoActionBar.Fullscreen" />
         <activity
-            android:name="app.mar.activities.ResourceListActivity"
+            android:name=".ResourceListActivity"
             android:configChanges="orientation|keyboardHidden|screenSize"
             android:label="@string/title_activity_resource_list"
             android:screenOrientation="portrait" />
         <activity
-            android:name="app.mar.activities.SettingsActivity"
+            android:name=".SettingsActivity"
             android:configChanges="orientation|keyboardHidden"
             android:label="@string/title_activity_settings"
             android:screenOrientation="portrait" />
-        <activity android:name="app.mar.activities.TransferActivity" />
-        <activity android:name="app.mar.activities.EndActivity" />
+        <activity android:name=".EndActivity" />
         <activity
-            android:name="app.mar.activities.MARMenuActivity"
+            android:name=".MARMenuActivity"
             android:configChanges="orientation|keyboardHidden"
             android:screenOrientation="portrait" />
         <activity
-            android:name="app.mar.activities.SEMenuActivity"
+            android:name=".SEMenuActivity"
             android:configChanges="orientation|keyboardHidden"
             android:screenOrientation="portrait">
             >
         </activity>
         <activity
-            android:name="app.mar.activities.PuzzleActivity"
+            android:name=".PuzzleActivity"
             android:configChanges="orientation|keyboardHidden|screenSize"
             android:label="@string/title_activity_puzzle"
             android:theme="@style/FullscreenTheme" />
-        <activity android:name="app.mar.activities.PermissionActivity">
+        <activity android:name=".PermissionActivity">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
 
@@ -62,15 +60,28 @@
             </intent-filter>
         </activity>
         <activity
-            android:name="app.mar.activities.MediaViewerAcitvity"
+            android:name=".MediaViewerAcitvity"
+            android:theme="@style/AppTheme.NoActionBar.Fullscreen" />
+        <activity
+            android:name=".ModelViewerActivity"
             android:theme="@style/AppTheme.NoActionBar.Fullscreen" />
         <activity
-            android:name="app.mar.activities.ModelViewerActivity"
+            android:name=".InfoActivity"
             android:theme="@style/AppTheme.NoActionBar.Fullscreen" />
         <activity
-            android:name="app.mar.activities.InfoActivity"
+            android:name=".CreditsActivity"
             android:theme="@style/AppTheme.NoActionBar.Fullscreen" />
-        <activity android:name="app.mar.activities.CreditsActivity"
-            android:theme="@style/AppTheme.NoActionBar.Fullscreen" ></activity>
+        <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>
     </application>
+
 </manifest>

+ 90 - 108
app/src/main/java/app/mar/activities/ARActivity.java

@@ -16,6 +16,7 @@ import android.widget.FrameLayout;
 import android.widget.ImageView;
 import android.widget.RelativeLayout;
 import android.widget.TextView;
+import android.widget.Toast;
 
 import java.text.DecimalFormat;
 import java.text.NumberFormat;
@@ -28,8 +29,13 @@ 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.utils.geometry.GPSPoint;
 import min3d.core.Object3d;
 import min3d.core.Object3dContainer;
@@ -43,25 +49,15 @@ import min3d.vos.Number3d;
 public class ARActivity extends RendererActivity
 {
 
-    private CameraPreview mImageSurfaceView;
-    private Camera camera;
-    private FrameLayout cameraPreviewLayout;
+    protected GeoTreasure   mTreasure=null;
+    protected Area          mArea=null;
 
-
-    private Object3dContainer faceObject3D;
-    private Button mOkButton;
     private final Object mLock = new Object();
     protected boolean isPausing=false;
     protected static GPSPoint mLocation;
     protected static boolean mLocationUpdated=false;
-    protected TextView mTvDistance;
-    protected TextView mTvAngle;
-    protected TextView mTvGPS;
-    protected RelativeLayout mRlRoot;
-    protected ImageView mIvWhite;
-    protected ImageView mIvRed;
-    protected ImageView mIvGreen;
-    protected ImageView mIvNone;
+
+
     protected int mViewWidth;
     protected int mViewHeight;
     protected boolean mDetect=false;
@@ -72,6 +68,21 @@ public class ARActivity extends RendererActivity
 
     private boolean mIsResource = false;
 
+    //UI
+    private CameraPreview mImageSurfaceView;
+    private Camera camera;
+    private FrameLayout cameraPreviewLayout;
+    private Button mOkButton;
+    protected TextView mTvDistance;
+    protected TextView mTvAngle;
+    protected TextView mTvGPS;
+    protected RelativeLayout mRlRoot;
+    protected ImageView mIvWhite;
+    protected ImageView mIvRed;
+    protected ImageView mIvGreen;
+    protected ImageView mIvNone;
+    public static final int REQUEST_CODE = 2003;
+
     public void init()
     {
         setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
@@ -210,7 +221,7 @@ public class ARActivity extends RendererActivity
         Object3d oo = rr.get3DModel(this);
         CameraVo v = new CameraVo();
 
-        if(mGame.getmSettings().isARMode()) {
+        if(mGame.getSettings().isARMode()) {
             double distCoef = (p.getDistance(mGame.getPlayer()) / 50) * 0.8;
             distCoef += 0.2;
             double x = 0;
@@ -229,7 +240,7 @@ public class ARActivity extends RendererActivity
 
 
 
-            if (mGame.getmSettings().isAreaDebug()) {
+            if (mGame.getSettings().isAreaDebug()) {
 
                 toDisplay += "Azimuth: " + dts(alpha) + "°\nAngle:"+mGame.getPlayer().getAngleWith(p) +"\nPosition (" + dts(oo.position().x) + ", " + dts(oo.position().y)
                         + ", " + dts(oo.position().z) + ")\nAngle Rel:"+dts(alpha)+" : "+dts(mGame.getPlayer().getAngleWith(p))+" - "+dts(mGame.getPlayer().getOrientationX())+"\n";
@@ -253,46 +264,49 @@ public class ARActivity extends RendererActivity
     protected boolean updateSceneResource()
     {
 
-        ArrayList<LocatedResources> res = mGame.getResourcesNextToPlayer();
+        ArrayList<Resource> res = mGame.getResourcesNextToPlayer(mArea);
+        Place place = mArea.getPlace();
+        Player player = mGame.getPlayer();
+        double distance = -1;
+
         String toDisplay ="";
         boolean detected = false;
-        boolean isAR = mGame.getmSettings().isARMode();
+        boolean isAR = mGame.getSettings().isARMode();
         // String dete = "Detected:\n";
         scene.clear();
 
 
-       // if(mGame.getmSettings().isAreaDebug())
+        if(mGame.getSettings().isAreaDebug())
         {
-            ArrayList<Area> ar = mGame.getAreaNextToPlayer();
-            String ttxt = "Zones trouvées:\n";
-            for(int i=0; i<ar.size(); i++)
-                ttxt+="\t"+ar.get(i).getName()+"\n";
-            toDisplay+=ttxt+"\n\n";
-            String str = "Stage : "+mGame.getCurrentStage()+"\nZones les plus proches ("+mGame.getCurrentStageAreas().size()+"):\n"+ "--->";
-            ArrayList<Area> arr = mGame.getCurrentStageAreas();
-            for(int i=0; i<arr.size(); i++)
-                if(mGame.getPlayer().getPosition()!=null)
-                    str+="\t"+arr.get(i).getName()+" : "+arr.get(i).getDistanceToNextPlace(mGame.getPlayer())+" m\n";
-                else
-                    str+="\t"+arr.get(i).getName()+" : ?\n";
-            toDisplay+=str+"\n";
+            String str = "Zone : ";
+            if(player.getPosition()!=null)
+            {
+                distance=mArea.getDistance(player);
+                str+="\t"+mArea.getName()+" : "+((int)mArea.getDistance(player))+" m";
+            }
+            else
+                str+="\t"+mArea.getName()+" : ?";
+
+            if(mGame.getSettings().isARMode())
+            {
+                str+=player.getAngleWith(place)+" °";
+            }
+            toDisplay+=str+"\n\n";
 
         }
 
-        if(mGame.getmSettings().isAreaDebug()) toDisplay+="Resources détectées: \n";
 
-        for (int i = 0; i < res.size(); i++) {
-            Resource rr = res.get(i).getResource(0);
-            Place p = res.get(i).getPlace();
-            if (rr != null) {
-                detected = true;
-                if(isAR) mGame.getPlayer().freezePosition(p.getLocation());
-                toDisplay=updateArSceneResource(rr, p, toDisplay);
-            }
+        if (mArea.isOnArea(player)) {
+            if(mGame.getSettings().isAreaDebug()) toDisplay+="Resources détectées: \n";
+            detected = true;
+            if(mGame.getSettings().isARMode()) mGame.getPlayer().freezePosition(place.getLocation());
+
+            toDisplay=updateArSceneResource(res.get(0), place, toDisplay);
         }
+
         if(isAR && res.size()==0) mGame.getPlayer().releasePosition();
 
-        updateLed(detected, mGame.getResourcesNextToPlayerDistDouble());
+        updateLed(detected, distance);
 
 
 
@@ -303,14 +317,14 @@ public class ARActivity extends RendererActivity
 
 
         //affichage de la distance dans l'HUD
-        final String dete2 = mGame.getResourcesNextToPlayerDist();
+        final String dete2 = String.format ("%.1f", distance);
         mTvDistance.getHandler().post(new Runnable() {
             public void run() {
                 mTvDistance.setText(dete2);
             }
         });
 
-        if(mGame.getmSettings().isARMode())
+        if(mGame.getSettings().isARMode())
             return scene.numChildren()>0;
         else
             return res.size()>0;
@@ -332,18 +346,9 @@ public class ARActivity extends RendererActivity
     }
 
 
-    @Override
-    protected void onCreate(Bundle savedInstanceState)
-    {
-        super.onCreate(savedInstanceState);
 
-        requestWindowFeature(Window.FEATURE_NO_TITLE);
-        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
-        setContentView(R.layout.activity_ar);
-        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
-        //mGame = (Game) getIntent().getSerializableExtra("game");
-        mGame = Game.game();
-        mGame.newSensorManager(this);
+    private void loadUI()
+    {
         mTvDistance=(TextView)findViewById(R.id.tv_distance);
         mTvAngle=(TextView)findViewById(R.id.tv_angle);
         mTvGPS=(TextView)findViewById(R.id.tv_gps);
@@ -353,8 +358,6 @@ public class ARActivity extends RendererActivity
         mIvGreen=(ImageView)findViewById(R.id.iv_green);
         mIvNone=(ImageView)findViewById(R.id.iv_none);
 
-
-
         ViewTreeObserver vto = mRlRoot.getViewTreeObserver();
         vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
             @Override
@@ -378,14 +381,37 @@ public class ARActivity extends RendererActivity
                 moveView(mIvGreen, (int)(w*0.702), (int)(0.034*h), (int)(w*0.03333), (int)(0.02286f*h));
             }
         });
+    }
 
+    @Override
+    protected void onCreate(Bundle savedInstanceState)
+    {
+        super.onCreate(savedInstanceState);
+        requestWindowFeature(Window.FEATURE_NO_TITLE);
+        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
+        setContentView(R.layout.activity_ar);
+        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
 
+        mGame = Game.game();
+        mGame.newSensorManager(this);
+        loadUI();
 
-        int w = mRlRoot.getWidth();
-        int h = mRlRoot.getHeight();
-
-        mGame.printStage();
-
+        Challenge c = mGame.getCurrentChallenge();
+        if(c!=null)
+        {
+            if(c instanceof GeoTreasure)
+            {
+                mTreasure = (GeoTreasure)c;
+                mArea = mTreasure.getArea();
+            }else
+            {
+                Toast.makeText(this,"Erreur interne: Pas de Trésor a chercher", Toast.LENGTH_LONG).show();
+            }
+        }
+        else
+        {
+            Toast.makeText(this,"Erreur interne: Pas de Challenge a effectuer", Toast.LENGTH_LONG).show();
+        }
     }
 
 
@@ -404,7 +430,7 @@ public class ARActivity extends RendererActivity
             //Precache du modèle 3D
             synchronized (mLock) {
                 if (!isPausing) {
-                    boolean b = mGame.precache3DResource(this);
+                    mGame.precache3DResource(this);
                     mIsResource = updateSceneResource();
                 }else
                 {
@@ -523,51 +549,7 @@ public class ARActivity extends RendererActivity
     public void onClickPickUp(View v)
     {
         synchronized (mUpdate) {mUpdate=false;}
-        Stage s = mGame.getCurrentStageObj();
-        ArrayList<Resource> res = null;
-        boolean stageFinished = mGame.pickResource();
-        boolean finished = false;
-        res=mGame.getPickedUpResources();
-
-
-        if(stageFinished)
-        {
-            finished = mGame.nextStage();
-        }
-
-        if(finished)
-        {
-            Log.e("Finished", "Finished");
-        }
-
-        if(stageFinished)
-        {
-            Resource stageRes = s.getResource();
-
-            if(finished)
-            {
-                Intent intent2 = new Intent(this, EndActivity.class);
-                startActivity(intent2);
-            }
-            System.out.println("Ressource: '"+s.getResourceName()+"' : "+!s.getResourceName().isEmpty());
-            if(!s.getResourceName().isEmpty() && s.isTransition())
-            {
-                Intent intent = AndroidResources.getViewerIntent(this, stageRes);
-                startActivity(intent);
-            }
-
-            System.out.println("Transition: '"+s.isTransition());
-            if(s.isTransition())
-            {
-                Intent intent2 = new Intent(this, TransferActivity.class);
-                startActivity(intent2);
-            }
-        }
-        for(int i=0; i<res.size(); i++)
-        {
-            Intent intent = AndroidResources.getViewerIntent(this, res.get(i));
-            startActivity(intent);
-        }
+        mGame.setReturn(new ChallengeReturn(mTreasure, ChallengeReturn.SUCCESS, "Très bien !"));
         finish();
     }
 

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

@@ -0,0 +1,5 @@
+package app.mar.activities;
+
+public interface IRequestCode {
+    public int getRequestCode();
+}

+ 2 - 4
app/src/main/java/app/mar/activities/MARMenuActivity.java

@@ -23,7 +23,7 @@ public class MARMenuActivity extends MenuActivity{
         moveView(mBSend, mWidth/2-w, mHOffset+2*h4+4*h/3, 2*w, h);
         ((Button)mBMenu).setTextSize(25);
         //mBMenu.setTypeface(null,Typeface.BOLD);
-        sendVisibility();
+
 
     }
 
@@ -54,9 +54,7 @@ public class MARMenuActivity extends MenuActivity{
         float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 70, r.getDisplayMetrics());
         moveView(mBMenu, 0, 0, mWidth, (int) px);
 
-        //mGame.pickResource("intro", false);
-        //mGame.pickResource("a", false);
-        mGame.pickUpOtherResources();
+
 
     }
 }

+ 57 - 37
app/src/main/java/app/mar/activities/MenuActivity.java

@@ -19,6 +19,11 @@ import app.mar.utils.Settings;
 import app.mar.utils.game.Game;
 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.GeoTreasure;
+import app.mar.utils.game.challenges.QCM;
+import app.mar.utils.game.challenges.QRCodeTreasure;
+import app.mar.utils.game.challenges.Question;
 
 public abstract class  MenuActivity extends Activity implements View.OnClickListener, IViewerActivity{
 
@@ -43,6 +48,7 @@ public abstract class  MenuActivity extends Activity implements View.OnClickList
     protected Button mBSend;
     protected int mHOffset=0;
 
+
     protected  void refreshMenuStyle(){}
 
     protected void setUpMenuStyle(){}
@@ -113,8 +119,22 @@ public abstract class  MenuActivity extends Activity implements View.OnClickList
             throw new Error("Le jeu n'est pas sauvegardé");
         }
 
+
+
+
         updateSize();
-        Settings.setSettings(mGame.getmSettings());
+        Settings.setSettings(mGame.getSettings());
+
+
+        ////// A virer dela
+
+        startChallenge();
+
+        //Intent intent = new Intent(this, QRCodeActivity.class);
+        //startActivity(intent);
+
+        /// a dela
+
 
         setUpMenuStyle();
         refreshMenuStyle();
@@ -122,6 +142,40 @@ public abstract class  MenuActivity extends Activity implements View.OnClickList
         mCustomHandler.postDelayed(updateTimerThread, 10);
     }
 
+    public void startChallenge()
+    {
+        Challenge c = mGame.getCurrentChallenge();
+        if(c!=null)
+            c.exec(mGame, this);
+    }
+
+    public void onActivityResult(int requestCode, int resultCode, Intent data) {
+        if (resultCode != RESULT_OK)  return;
+
+        if (requestCode == Question.REQUEST_CODE) {
+
+        }
+        else if (requestCode == QCM.REQUEST_CODE) {
+
+        }
+        else if (requestCode == QRCodeTreasure.REQUEST_CODE) {
+
+        }
+        else if (requestCode == GeoTreasure.REQUEST_CODE) {
+
+        }
+        Stage s = mGame.getCurrentStage();
+        Challenge c = s.nextChallenge();
+        if(c!=null)
+        {
+            startChallenge();
+        }else //new stage
+        {
+            if(mGame.nextStage()!=null)
+                startChallenge();
+        }
+    }
+
     public void onOptionsClick(View v)
     {
         Intent intent = new Intent(this, SettingsActivity.class);
@@ -160,46 +214,20 @@ public abstract class  MenuActivity extends Activity implements View.OnClickList
 
 
     public void onInfoClick(View v) {
-        Stage s = mGame.getCurrentStageObj();
+        /*Stage s = mGame.getCurrentStage();
         Resource r = (s!=null)?s.getResource(): null;
 
         Intent intent = AndroidResources.getViewerIntent(this, r);
-        startActivity(intent);
+        startActivity(intent);*/
     }
 
 
-    public void onSendClick(View v)
-    {
-        Stage s = mGame.getCurrentStageObj();
-        boolean finished = mGame.nextStage();
-
-        Resource stageRes = s.getResource();
-        System.out.println("Ressource: '"+s.toString());
-        if(finished)
-        {
-            Intent intent2 = new Intent(this, EndActivity.class);
-            startActivity(intent2);
-        }
-
-        if(!s.getResourceName().isEmpty() && s.isTransition())
-        {
-            Intent intent = AndroidResources.getViewerIntent(this, stageRes);
-            startActivity(intent);
-        }
-
-        if(s.isTransition())
-        {
-            Intent intent2 = new Intent(this, TransferActivity.class);
-            startActivity(intent2);
-        }
-    }
 
     @Override
     public void onClick(View view) {
         if(view == mBBriefing) onInfoClick(view);
         else if(view == mIbScanner) onScannerClick(view);
         else if(view == mBMap) onCarteClick(view);
-        else if(view == mBSend) onSendClick(view);
         else if(view == mBInvotory) onInventaireClick(view);
         else if(view == mBOptions) onOptionsClick(view);
     }
@@ -211,11 +239,6 @@ public abstract class  MenuActivity extends Activity implements View.OnClickList
         refreshMenuStyle();
     }
 
-    protected void sendVisibility()
-    {
-        if(mGame.canSendData()) mBSend.setVisibility(View.VISIBLE);
-        else mBSend.setVisibility(View.INVISIBLE);
-    }
 
     private Runnable updateTimerThread = new Runnable() {
 
@@ -235,7 +258,4 @@ public abstract class  MenuActivity extends Activity implements View.OnClickList
     {
         return (int) (px / Resources.getSystem().getDisplayMetrics().density);
     }
-
-
-
 }

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

@@ -0,0 +1,107 @@
+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);
+        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+        setSupportActionBar(toolbar);
+
+
+
+        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;
+        Log.e("_______", "Id = "+x);
+
+        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();
+            }
+        }
+    }
+}

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

@@ -0,0 +1,154 @@
+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) {
+
+    }
+}

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

@@ -0,0 +1,69 @@
+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 - 2
app/src/main/java/app/mar/activities/ResourceListActivity.java

@@ -67,7 +67,7 @@ public class ResourceListActivity extends Activity {
     {
         if(mGame!=null)
         {
-            ArrayList< ArrayList<Resource> > resources = mGame.getResourceByStage();
+          /*  ArrayList< ArrayList<Resource> > resources = mGame.getResourceByStage();
             ArrayList<Object> obs = new ArrayList<Object>();
             for(int i = 0; i< resources.size(); i++) {
                 obs.add("Étape "+i);
@@ -78,7 +78,7 @@ public class ResourceListActivity extends Activity {
             ResourceArrayAdapter aa;
             aa = new ResourceArrayAdapter(this, android.R.layout.simple_list_item_1, obs);
             mList.setOnItemClickListener(aa);
-            mList.setAdapter(aa);
+            mList.setAdapter(aa);*/
         }
     }
     @Override

+ 14 - 15
app/src/main/java/app/mar/activities/SettingsActivity.java

@@ -101,7 +101,6 @@ public class SettingsActivity extends Activity implements OnToggleListener, View
                 new DialogInterface.OnClickListener() {
                     public void onClick(DialogInterface dialog, int id) {
                         Game.setGame(new Game("game_medium", context));
-                        mGame.pickUpOtherResources();
                         Toast.makeText(context, "Suppression effectuée", Toast.LENGTH_SHORT);
                         dialog.cancel();
                     }
@@ -132,7 +131,7 @@ public class SettingsActivity extends Activity implements OnToggleListener, View
             setResults();
         }else if(v==mCheat)
         {
-            mGame.pickAllResoucres();
+            //mGame.pickAllResoucres();
         }
     }
 
@@ -206,13 +205,13 @@ public class SettingsActivity extends Activity implements OnToggleListener, View
 
     private void setResults()
     {
-        mGame.getmSettings().setDevelopperMode(mDev.getState());
-        mGame.getmSettings().setGPSDebug(mGPS.getState());
-        mGame.getmSettings().setAreaDebug(mAreas.getState());
-        mGame.getmSettings().setARMode(mRA.getState());
-        mGame.getmSettings().setResourceDebug(mPlaces.getState());
-        mGame.getmSettings().setSensorLatency(mSensorLatency.getState());
-        Settings.setSettings(mGame.getmSettings());
+        mGame.getSettings().setDevelopperMode(mDev.getState());
+        mGame.getSettings().setGPSDebug(mGPS.getState());
+        mGame.getSettings().setAreaDebug(mAreas.getState());
+        mGame.getSettings().setARMode(mRA.getState());
+        mGame.getSettings().setResourceDebug(mPlaces.getState());
+        mGame.getSettings().setSensorLatency(mSensorLatency.getState());
+        Settings.setSettings(mGame.getSettings());
         mGame.save(this);
         mGame.getPlayer().newSensorManager(this);
     }
@@ -225,12 +224,12 @@ public class SettingsActivity extends Activity implements OnToggleListener, View
 
     private void preset()
     {
-        mDev.setState(mGame.getmSettings().isDevelopperMode());
-        mGPS.setState(mGame.getmSettings().isGPSDebug());
-        mAreas.setState(mGame.getmSettings().isAreaDebug());
-        mPlaces.setState(mGame.getmSettings().isResourceDebug());
-        mRA.setState(mGame.getmSettings().isARMode());
-        mSensorLatency.setState(mGame.getmSettings().getSensorLatency());
+        mDev.setState(mGame.getSettings().isDevelopperMode());
+        mGPS.setState(mGame.getSettings().isGPSDebug());
+        mAreas.setState(mGame.getSettings().isAreaDebug());
+        mPlaces.setState(mGame.getSettings().isResourceDebug());
+        mRA.setState(mGame.getSettings().isARMode());
+        mSensorLatency.setState(mGame.getSettings().getSensorLatency());
         updateVisibility();
     }
 

+ 0 - 81
app/src/main/java/app/mar/activities/TransferActivity.java

@@ -1,81 +0,0 @@
-package app.mar.activities;
-
-import android.app.Activity;
-import android.content.DialogInterface;
-import android.graphics.Color;
-import android.os.Handler;
-import android.support.v7.app.AlertDialog;
-import android.os.Bundle;
-import android.widget.ImageButton;
-import android.widget.ProgressBar;
-import android.widget.Toast;
-
-import app.mar.utils.FontChangeCrawler;
-import app.mar.utils.game.Game;
-
-public class TransferActivity extends Activity {
-
-    private Handler mCustomHandler = new Handler();
-    private ProgressBar mBar;
-    private ImageButton mImage;
-    private int mCurrentPos = 0;
-    private final int MAX_POS=210;
-    private final int PERIODE_SEND=35;
-    private Activity mSelf;
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.activity_transfer);
-        FontChangeCrawler.setFont(this);
-        mBar = (ProgressBar) findViewById(R.id.pb_bar);
-        mImage = (ImageButton) findViewById(R.id.ib_logo);
-        mBar.setMax(MAX_POS);
-        mBar.getProgressDrawable().setColorFilter(
-                Color.BLUE, android.graphics.PorterDuff.Mode.SRC_IN);
-        mSelf=this;
-        mCustomHandler.postDelayed(updateTimerThread, 10);
-    }
-
-    private Runnable updateTimerThread = new Runnable() {
-
-        public void run() {
-
-            mBar.setProgress(mCurrentPos++);
-            mImage.setAlpha(alpha());
-            if(mCurrentPos < MAX_POS) mCustomHandler.postDelayed(this, 10);
-            else
-            {
-                AlertDialog.Builder builder = new AlertDialog.Builder(mSelf);
-
-                builder.setMessage("Données, envoyées, le professeur à envoyer un message")
-                        .setTitle("Données, envoyée");
-                builder.setPositiveButton("Voir", new DialogInterface.OnClickListener() {
-                    public void onClick(DialogInterface dialog, int id) {
-                        if(Game.game().getCurrentStage()-1==Game.game().getNStages())
-                        {
-                            Game.game().finish();
-                            Toast.makeText(mSelf, "Finished !!!!!!!", Toast.LENGTH_LONG).show();
-                        }
-                        finish();
-                    }
-                });
-
-                AlertDialog dialog = builder.create();
-                try{
-                    dialog.show();
-                }catch(Exception e) {
-                }
-            }
-        }
-
-    };
-
-
-    private float alpha()
-    {
-        int ix = mCurrentPos % PERIODE_SEND;
-        float x= ((float)mCurrentPos)/ ((float)PERIODE_SEND);
-        return (float)(Math.cos(x)*0.4+0.6);
-    }
-}

+ 0 - 249
app/src/main/java/app/mar/utils/ResourceManager.java

@@ -1,249 +0,0 @@
-package app.mar.utils;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-
-import app.mar.utils.game.Resource;
-
-/**
- * Created by ptitcois on 18/08/16.
- * Cette classe gère les differentes ressources
- */
-public class ResourceManager implements Serializable{
-    protected ArrayList<Resource> mAllResources = new ArrayList<Resource>();
-    protected ArrayList< ArrayList<Resource> > mResourcesAquiered  = new ArrayList<ArrayList<Resource> >();
-    protected ArrayList<Resource> mResourcesLeft  = new ArrayList<Resource>();
-    protected ArrayList<Resource> m_otherResources = new ArrayList<Resource>();
-    protected Resource mLatestResource = null;
-    protected ArrayList<Resource> mResourcesPickedUp = new ArrayList<Resource>();
-    protected int mNStages;
-
-
-    public ResourceManager(ArrayList<Resource> x, int n)
-    {
-        mAllResources =x;
-        mNStages = n;
-    }
-
-    /**
-     * Constructeur par defaut.
-     * ATTENTION: doit être initialise par la fonction set(ArrayList<Resource> x, int n)
-     */
-    public ResourceManager()
-    {
-    }
-
-    /**
-     * Initialise les ressources
-     * @param x La liste des ressources
-     * @param n Le nombre d'étapes dans le jeu
-     */
-    public void set(ArrayList<Resource> x, int n)
-    {
-        mAllResources =x;
-        mNStages = n;
-    }
-
-    /**
-     * Ajout d'une ressource hors zone
-     * @param r ressource hors zone
-     */
-    public void addOtherResource(Resource r)
-    {
-        m_otherResources.add(r);
-    }
-
-    /**
-     * Récupere une ressource hors zone
-     * @return
-     */
-    public ArrayList<Resource> getOtherResource()
-    {
-        return m_otherResources;
-    }
-
-
-    /**
-     * Recupere une ressource de l'étape  courante qui nest pas encore trouvée
-     * par son nom
-     * @param name Le nom de la ressource
-     * @return Null si inexistante sinon la ressource
-     */
-    public Resource getResourceLeftByName(String name)
-    {
-        for(int i=0; i<mResourcesLeft.size(); i++)
-        {
-            if(mResourcesLeft.get(i).getName().compareTo(name)==0)
-                return mResourcesLeft.get(i);
-        }
-
-        for(int i=0; i<m_otherResources.size(); i++)
-        {
-            if(m_otherResources.get(i).getName().compareTo(name)==0)
-                return m_otherResources.get(i);
-        }
-        return null;
-    }
-
-    public void clearPickedUpResources()
-    {
-        mResourcesPickedUp.clear();
-    }
-
-    public ArrayList<Resource> getResourceLeftByName(ArrayList<String> names)
-    {
-        ArrayList<Resource> res = new ArrayList<Resource>();
-        for(int i=names.size()-1; i>=0; i--) {
-            res.add(getResourceLeftByName(names.get(i)));
-        }
-        return res;
-    }
-
-    /**
-     * Passe à l'étape N
-     * @param stage Le numero de la prochaine etape
-     */
-    public void nextStage(int stage)
-    {
-        mResourcesAquiered.add(new ArrayList<Resource>());
-        mResourcesLeft.clear();
-        for(int i=0; i<mAllResources.size(); i++)
-            if(mAllResources.get(i).getStage()==stage)
-                mResourcesLeft.add(mAllResources.get(i));
-    }
-
-    /**
-     * Recupere une ressource:
-     *  -Ajout dans la liste des ressources (indifferent des etapes)
-     *  -Ajout dans la liste d'inventaire (liste de liste par etape): mResourcesAquiered
-     *  -Suppression de la liste des ressource à trouver (sauf si c'est une ressource hors zone)
-     *
-     * @param name
-     * @return
-     */
-    public boolean pickUpResource(String name)
-    {
-        for(int i=0; i<mResourcesLeft.size(); i++)
-        {
-            if(mResourcesLeft.get(i).getName().compareTo(name)==0)
-            {
-                mResourcesPickedUp.add(mResourcesLeft.get(i));
-                mResourcesAquiered.get(mResourcesAquiered.size()-1).add(mResourcesLeft.get(i));
-                mLatestResource = mResourcesLeft.get(i);
-                mResourcesLeft.remove(i);
-                return true;
-            }
-        }
-
-        for(int i=0; i<m_otherResources.size(); i++)
-            if(m_otherResources.get(i).getName().compareTo(name)==0)
-            {
-                mResourcesPickedUp.add(m_otherResources.get(i));
-                if(mResourcesAquiered.size()>0)mResourcesAquiered.get(mResourcesAquiered.size()-1).add(m_otherResources.get(i));
-            }
-
-        return false;
-    }
-
-    public ArrayList<Resource> getPickedUpResources()
-    {
-        return mResourcesPickedUp;
-    }
-
-    public ArrayList<Resource> getResourceLeft()
-    {
-        return mResourcesLeft;
-    }
-
-    public ArrayList<Resource> getResourceAquiered(int stage)
-    {
-        return mResourcesAquiered.get(stage-1);
-    }
-
-
-    public ArrayList< ArrayList<Resource> > getResourceAquiered()
-    {
-        return mResourcesAquiered;
-    }
-
-    /**
-     * Renvoie le nombre de ressource acquise par le joueur depuis le debut de la partie
-     * @return
-     */
-    public int getNResourceAquired()
-    {
-        int n=0;
-        for(int i=0; i<mResourcesAquiered.size(); i++)
-            n+=mResourcesAquiered.get(i).size();
-        return n;
-    }
-
-    /**
-     * Récupre toutes les ressources en un coups
-     */
-    public void pickAllResoucres()
-    {
-        mResourcesLeft.clear();
-        mResourcesAquiered.clear();
-
-        mResourcesAquiered.add(new ArrayList<Resource>());
-
-        for(int i=0; i<m_otherResources.size(); i++)
-            mResourcesAquiered.get(0).add(m_otherResources.get(i));
-
-        for(int i=0; i<mNStages; i++)
-        {
-            ArrayList<Resource> ar = new ArrayList<Resource>();
-            for(int j=0; j<mAllResources.size(); j++) {
-                if (mAllResources.get(j).getStage() == i + 1)
-                    ar.add(mAllResources.get(j));
-            }
-            mResourcesAquiered.add(ar);
-        }
-
-
-    }
-
-    /**
-     * Enleve le Modele 3D de la cache
-     */
-    public void deleteAll3DModel()
-    {
-        for(int i=0; i<mAllResources.size(); i++)
-            mAllResources.get(i).delete3DModel();
-    }
-
-    /**
-     * Le nombre de ressources acquise dans l'étape courante
-     * @return
-     */
-    public int getNResourceAquiredByStage()
-    {
-        if(mResourcesAquiered.size()>0)
-            return mResourcesAquiered.get(mResourcesAquiered.size()-1).size();
-        return 0;
-    }
-
-
-    public int getNResourceLeft()
-    {
-        return mResourcesLeft.size();
-    }
-
-    public Resource getLatestResource()
-    {
-        return mLatestResource;
-    }
-
-
-    public boolean hasResource(String name)
-    {
-        for(int i=0; i<mResourcesAquiered.size(); i++)
-        {
-            for(int j=0; j<mResourcesAquiered.get(i).size(); j++)
-                if(mResourcesAquiered.get(i).get(j).getName().compareTo(name)==0)
-                    return true;
-        }
-        return false;
-    }
-}

+ 32 - 54
app/src/main/java/app/mar/utils/game/Area.java

@@ -17,29 +17,33 @@ import app.mar.utils.geometry.Shape;
  */
 public class Area  implements Serializable {
 
-    protected String            mName;
-    protected ArrayList<String>            mResourceName = new ArrayList<String>();
-    protected Shape             mShape = new Shape();
-    protected ArrayList<Place>  mPlaces = new ArrayList<Place>();
-    protected ArrayList<Resource>          mResource = new ArrayList<Resource>();
+    protected String                mName;
+    protected Shape                 mShape = new Shape();
+    protected Place                 mPlaces;
 
-    public Area(JSONObject root, Activity act)
+    protected ArrayList<String>     mResourceName = new ArrayList<String>();
+
+
+    public Area(Game g, JSONObject root, Activity act)
     {
         try {
+            mName = root.getString("name");
+
             JSONArray ja = root.getJSONArray("coordinates");
             for(int i=0; i<ja.length(); i++) {
                 JSONArray jaa = ja.getJSONArray(i);
                 mShape.add(new GPSPoint(jaa.getDouble(0), jaa.getDouble(1)));
             }
-            mName = root.getString("name");
+
             String res [] = root.getString("resource").split(";");
-            for(int i=0; i<res.length; i++) mResourceName.add(res[i]);
-            ja = root.getJSONArray("points");
-            for(int i=0; i<ja.length(); i++) {
-                mPlaces.add(new Place(ja.getJSONObject(i)));
+            for(int i=0; i<res.length; i++)
+            {
+                g.registerResource(res[i], act);
+                mResourceName.add(res[i]);
             }
-            for(int i=0; i<mResourceName.size(); i++)
-                mResource.add(new Resource(mResourceName.get(i), act));
+
+            mPlaces = new Place(root.getJSONObject("points"));
+
         } catch (JSONException e) {
             e.printStackTrace();
         }
@@ -53,53 +57,30 @@ public class Area  implements Serializable {
         return mResourceName;
     }
 
-    public ArrayList<Resource> getResource() {
-        return mResource;
-    }
-    public Resource getResource(int i) {
-        return mResource.get(i);
-    }
-    public int countResource() {
-        return mResource.size();
-    }
 
+    public String getResourceName(int i) {
+        return mResourceName.get(i);
+    }
 
-    public int getStage()
-    {
-        if(mResource==null || mResource.size()<=0) return -1;
-        int max=0;
-        for(int i=0; i<mResource.size(); i++)
-            if(mResource.get(i).getStage()>max)
-                max=mResource.get(i).getStage();
-        return max;
+    public int countResource() {
+        return mResourceName.size();
     }
 
     public Shape getShape() {
         return mShape;
     }
 
-    public ArrayList<Place> getPlaces() {
+    public Place getPlace() {
         return mPlaces;
     }
 
-    public int placesCount()
-    {
-        return mPlaces.size();
-    }
-
-    public Place getPlace(int i)
-    {
-        return mPlaces.get(i);
-    }
-
+    /*
     public JSONObject getJson()
     {
         JSONObject jo = new JSONObject();
-        JSONArray ja = new JSONArray();
 
         try {
-            for(int i=0; i<mPlaces.size(); i++)
-                ja.put(mPlaces.get(i).getJson());
+            jo.put(mPlaces.getJson());
             jo.put("points", ja);
             jo.put("coordinates", mShape.getJson());
             jo.put("name", mName);
@@ -109,7 +90,7 @@ public class Area  implements Serializable {
             e.printStackTrace();
         }
         return jo;
-    }
+    }*/
 
     public boolean isOnArea(Player p)
     {
@@ -124,8 +105,7 @@ public class Area  implements Serializable {
 
     public boolean isOnPlace(Player p)
     {
-        for(int i=0; i<mPlaces.size(); i++)
-            if(mPlaces.get(i).isPlayerOn(p))
+        if(mPlaces.isPlayerOn(p))
                 return true;
         return false;
     }
@@ -133,25 +113,23 @@ public class Area  implements Serializable {
     public boolean isOnDirection(Player p)
     {
 
-        for(int i=0; i<mPlaces.size(); i++)
-            if(mPlaces.get(i).isOnDirection(p))
+        if(mPlaces.isOnDirection(p))
                 return true;
         return false;
     }
 
-    public double getDistanceToNextPlace(Player p)
+    public double getDistance(Player p)
     {
         double min = 32*1000*1000*1000;
-        for(int i=0; i<mPlaces.size(); i++)
-            if(mPlaces.get(i).getDistance(p)<min)
-                min=mPlaces.get(i).getDistance(p);
+        if(mPlaces.getDistance(p)<min)
+                min=mPlaces.getDistance(p);
         return min;
     }
 
     public String toString(Player p)
     {
         String str = "";
-        str+="["+mName+" "+mPlaces.get(0).getDistance(p)+"m ]";
+        str+="["+mName+" "+mPlaces.getDistance(p)+" m ]";
         return str;
     }
 }

+ 54 - 392
app/src/main/java/app/mar/utils/game/Game.java

@@ -1,7 +1,6 @@
 package app.mar.utils.game;
 
 import android.app.Activity;
-import android.app.admin.SystemUpdatePolicy;
 import android.content.Context;
 import android.util.Log;
 import android.widget.Toast;
@@ -21,77 +20,55 @@ import java.text.NumberFormat;
 import java.util.ArrayList;
 
 import app.mar.activities.ARActivity;
-import app.mar.utils.ResourceManager;
 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.
  */
 public class Game  implements Serializable {
     private static Game gGame = null;
-    protected ArrayList<Area>  mAreas = new ArrayList<Area>();
-    protected ArrayList<Area>  mCurrentStageAreas = new ArrayList<Area>();
+
+    protected String           mName;
+
     protected ArrayList<Stage> mStages = new ArrayList<Stage>();
-    protected int              mNStages;
-    protected int              mCurrentStage=0;
+    protected Stage            mCurrentStage=null;
+    protected int              mCurrentStageIndex=0;
+
     protected Player           mPlayer;
-    public ResourceManager     mResources;
-    protected String           mName;
     protected Settings         mSettings = new Settings();
-    protected boolean          mFinished= false;
-    protected boolean          mFirstLaunch=true;
-
     protected String           mMap=null;
 
+    protected ResourceManager mResources = new ResourceManager();
+    protected ChallengeReturn mLastReturn = null;
+
+
     public Game(String name, Activity act)
     {
         JSONObject root = JSONAssetsManager.load(act, name);
         mName=name;
-        mResources = new ResourceManager();
         mPlayer = new Player(act);
         try {
-            /* Listes des zones */
-            JSONArray areas = root.getJSONArray("areas");
-
-            /* Listes des étapes */
-            JSONArray stages = root.getJSONArray("stages_list");
-
-            /* Nom (uniquement) d'autres ressources utilisés (hors zones) */
-            JSONArray others = root.getJSONArray("others");
-
-
-            for(int i=0; i<others.length(); i++)
-                mResources.addOtherResource(new Resource(others.getString(i), act));
-
-            for(int i=0; i<areas.length(); i++)
-                mAreas.add(new Area(areas.getJSONObject(i), act));
-
-            for(int i=0; i<stages.length(); i++) {
-                Stage s = new Stage(stages.getJSONObject(i));
-                Resource r = findResource(s.getResourceName());
-                Log.e("_______", "Res = "+r+" "+s.getResourceName());
-                s.setResource(r);
-                mStages.add(s);
-            }
-            findMaxStage();
-            mResources.set( getAllResources(), mNStages);
-
-            nextStage();
-        } catch (Exception e) {
-            System.err.println("_________________ B\n");
+            JSONArray arr = root.getJSONArray("stages");
+            for(int i=0; i<arr.length(); i++)
+                mStages.add(new Stage(this, arr.getJSONObject(i), act));
+        } catch (JSONException e) {
             e.printStackTrace();
         }
 
         try {
-            System.err.println("_________________ C\n");
             mMap=root.getString("map");
         } catch (Exception e) {
             e.printStackTrace();
-            System.err.println("_________________ C\n");
         }
 
+        mCurrentStageIndex=0;
+        if(mStages.size()>0)
+            mCurrentStage=mStages.get(0);
 
         if(!mPlayer.hasMagneticField() || !mPlayer.hasAcceleromter())
         {
@@ -99,151 +76,32 @@ public class Game  implements Serializable {
             if(!mPlayer.hasMagneticField()) Toast.makeText(act, "Votre dispositif n'a pas de boussole. Le mode RA ne peut fonctionner et a été désactivé", Toast.LENGTH_LONG).show();
             else if(!mPlayer.hasAcceleromter()) Toast.makeText(act, "Votre dispositif n'a pas d'accélerometre. Le mode RA ne peut fonctionner et a été désactivé", Toast.LENGTH_LONG).show();
         }
-
-        System.err.println("___________||||| "+mCurrentStageAreas.size());
     }
 
-    public Stage getCurrentStageObj()
+    public Stage getCurrentStage()
     {
-        return mCurrentStage<=mStages.size()?mStages.get(mCurrentStage-1):null;
+        return mCurrentStage;
     }
 
-    public void checkFirstLaunch()
+    public Challenge getCurrentChallenge()
     {
-        if(mFirstLaunch) {
-            mFirstLaunch=false;
-        }
+        if(mCurrentStage==null) return null;
+        return mCurrentStage.getCurrentChallenge();
     }
 
-    public Stage getStage(int i)
+    public void registerResource(String name, Activity act)
     {
-        return mStages.get(i);
+        mResources.addResource(name, act);
     }
 
-    public Settings getmSettings(){return mSettings;}
+
+    public Settings getSettings(){return mSettings;}
     public void setSettings(Settings s){ mSettings=s;}
 
-    public int getNStages() {
-        return mNStages;
-    }
     public String getName() {
         return mName;
     }
 
-    public int getCurrentStage() {
-        return mCurrentStage;
-    }
-
-    public void findMaxStage()
-    {
-        mNStages=0;
-        for(int i=0; i<mAreas.size(); i++) {
-            if (mAreas.get(i).getStage() > mNStages)
-                mNStages = mAreas.get(i).getStage();
-        }
-    }
-
-    public boolean nextStage()
-    {
-        mCurrentStage++;
-        Log.e("------------", "Is Finished : "+mCurrentStage+" > "+mNStages+" = "+(mCurrentStage>mNStages));
-        if(mCurrentStage>mNStages) return true;
-    System.out.println("La");
-        loadStageAreasResources();
-        mResources.nextStage(mCurrentStage);
-
-        return false;
-    }
-
-    public void loadStageAreasResources()
-    {
-        mCurrentStageAreas.clear();
-        for(int i=0; i<mAreas.size(); i++)
-        {
-            if(mAreas.get(i).getStage() == mCurrentStage)
-                mCurrentStageAreas.add(mAreas.get(i));
-        }
-        System.err.println("================================ ICI =======================" + mCurrentStageAreas.size());
-    }
-
-    public int currentAreasCount()
-    {
-        return mCurrentStageAreas.size();
-    }
-
-    public Area getAreaStage(int i)
-    {
-        return mCurrentStageAreas.get(i);
-    }
-
-    public void removeArea(String name)
-    {
-        for(int i=0; i<mCurrentStageAreas.size(); i++)
-            if(mCurrentStageAreas.get(i).getName().compareTo(name)==0)
-                mCurrentStageAreas.remove(i);
-    }
-
-    private void removeArea(int index)
-    {
-        mCurrentStageAreas.remove(index);
-    }
-
-    /**
-     * Récupere les ressources pouvant être "physiquement" (positionnement et
-     * orientation) prise par le joueur.
-     * @return true si l'étape est finie, sinon false
-     */
-    public boolean pickResource()
-    {
-        mResources.clearPickedUpResources();
-        ArrayList<LocatedResources> r = getResourcesNextToPlayer();
-
-        // recupere toutes les ressource "proche" (prenables)
-        // du joueur
-        for(int i=0; i<r.size(); i++) {
-            for (int j = 0; j < mCurrentStageAreas.size(); j++) {
-                if (r.get(i).getResource(0).getName().compareTo(mCurrentStageAreas.get(j).getResourceNames().get(0)) == 0 &&
-                        r.get(i).getResource(0).getStage() == mCurrentStage) {
-                    removeArea(j);
-                }
-            }
-            for(int k=0; k<r.get(i).count(); k++)
-                pickResource(r.get(i).getResource(k).getName());
-        }
-
-        //retourne vrai si l'etape est finie
-        return mCurrentStageAreas.size()==0;
-    }
-
-    /**
-     * Retourne la liste de toutes les ressources acquises par le joueur
-     * @return la liste de toutes les ressources acquises par le joueur
-     */
-    public ArrayList<Resource> getPickedUpResources()
-    {
-        return mResources.getPickedUpResources();
-    }
-
-
-    /**
-     * Récupere une ressource par son nom, sans besoin de localisation ou d'orientation
-     * @param name Le nom de la ressource
-     * @return  true si l'étape est finie, sinon false
-     */
-    public boolean pickResource(String name, boolean otherRes)
-    {
-
-        if(otherRes)
-        {
-            for (int j = 0; j < mCurrentStageAreas.size(); j++)
-                if (name.compareTo(mCurrentStageAreas.get(j).getName())==0) {
-                    removeArea(j);
-                }
-        }
-        mResources.pickUpResource(name);
-
-        return mCurrentStageAreas.size()==0;
-    }
 
 
     /**
@@ -253,55 +111,10 @@ public class Game  implements Serializable {
      */
     public boolean pickResource(String name)
     {
-
-        return pickResource(name, true);
-    }
-
-    /**
-     * Récupere toutes les ressources du jeu
-     */
-    public void pickAllResoucres()
-    {
-        mResources.pickAllResoucres();
-        mCurrentStage=mNStages;
-    }
-
-    /**
-     * La derniere ressource acquise
-     * @return La derniere ressource acquise
-     */
-    public Resource getLatestResource()
-    {
-        return mResources.getLatestResource();
-    }
-
-
-    public String toString()
-    {
-        String out = "Game : "+super.toString();
-        out+="mAreas[]:\n";
-        for(int i=0; i<mAreas.size(); i++)
-            out+="\tmAres["+i+"] = "+mAreas.get(i).getJson().toString()+"\n";
-        out+="\nmResourcesAcquired[] : \n";
-        for(int i=0; i<mResources.getResourceAquiered().size(); i++) {
-            out+="\tmResourcesAcquired["+i+"][] : \n";
-            for (int j = 0; j < mResources.getResourceAquiered().get(i).size(); j++)
-                out += "\t\tmResourcesAcquired[" + i + "]["+j+"] = " + mResources.getResourceAquiered().get(i).get(j).getJson().toString() + "\n";
-        }
-        out+="mNStages :" +mNStages +"\n";
-        out+="mCurrentStage" + mCurrentStage +"\n";
-        if(mMap!=null) out+="mMap : '"+mMap+"'\n";
-        else out+="mMap : null\n";
-        return out;
+        return true;
     }
 
-    public String toString2()
-    {
-        String out = "Game : "+mResources.getResourceLeft()+" : "+mCurrentStageAreas+";";
-        ArrayList<Resource> arr= mResources.getResourceLeft();
 
-        return out+";";
-    }
 
 
     /**
@@ -346,37 +159,6 @@ public class Game  implements Serializable {
         }
     }
 
-    /**
-     *
-     * @return Retourne toutes les ressources
-     */
-    public ArrayList<Resource> getAllResources()
-    {
-        ArrayList<Resource> tmp = new ArrayList<Resource>();
-        for(int i=0; i<mAreas.size(); i++)
-        {
-            ArrayList<Resource> c = mAreas.get(i).getResource();
-            for(int j=0; j<c.size(); j++)
-                if(!tmp.contains(c.get(j)))
-                    tmp.add(c.get(j));
-        }
-
-        return tmp;
-    }
-
-    public void pickUpOtherResources()
-    {
-        ArrayList<Resource> r = mResources.getOtherResource();
-        for(int i=0; i<r.size(); i++) {
-            pickResource(r.get(i).getName(), false);
-        }
-    }
-
-
-    public ArrayList<Area> getCurrentStageAreas()
-    {
-        return mCurrentStageAreas;
-    }
 
     /**
      * Teste si le jeu est déja sauvé
@@ -423,15 +205,7 @@ public class Game  implements Serializable {
      */
     public Resource findResource(String name)
     {
-        for(int i=0; i<mAreas.size(); i++)
-            for(int j=0; j<mAreas.get(i).countResource(); j++)
-                if(mAreas.get(i).getResourceNames().get(j).compareTo(name)==0)
-                 return mAreas.get(i).getResource(j);
-        if(mResources !=null)
-            for(int i=0; i<mResources.getOtherResource().size(); i++)
-                if(mResources.getOtherResource().get(i).getName().compareTo(name)==0)
-                    return mResources.getOtherResource().get(i);
-        return null;
+        return mResources.get(name);
     }
 
     /**
@@ -439,47 +213,16 @@ public class Game  implements Serializable {
      * @param contecxt Contexte
      * @return Vrai en cas de succes, faux pour une erreur
      */
-    synchronized public boolean precache3DResource(Activity contecxt)
+    synchronized public void precache3DResource(Activity contecxt)
     {
-        boolean b =false;
-        for(int i=0; i<mAreas.size(); i++)
+        Challenge c = getCurrentChallenge();
+        if(c instanceof Treasure)
         {
-            if(mAreas.get(i).getStage()==mCurrentStage &&  mAreas.get(i).isOnArea(mPlayer)) {
-                b = true;
-                ArrayList<Resource> rs = mResources.getResourceLeftByName(mAreas.get(i).getResourceNames());
-                try {
-                    for (int j = 0; j < rs.size(); j++) {
-                        if(rs.get(j)!=null) rs.get(j).get3DModel(contecxt);
-                    }
-
-                }catch(Exception e)
-                {
-                    e.printStackTrace();
-                }
-            }
+
         }
-        return b;
     }
 
 
-    /**
-     *
-     * Fonction principale de positionnnemnt et orientation:
-     * renvoie la liste des zones sur lesquelles le joueur est présent
-     * @return la liste des zones sur lesquelles le joueur est présent
-     */
-    public ArrayList<Area> getAreaNextToPlayer()
-    {
-        ArrayList<Area> r = new ArrayList<Area>();
-        for(int i=0; i<mCurrentStageAreas.size(); i++)
-        {
-            //probleme de GPS..
-            if(mCurrentStageAreas.get(i).isOnArea(mPlayer))
-                r.add(mCurrentStageAreas.get(i));
-
-        }
-        return r;
-    }
 
 
     /**
@@ -487,81 +230,17 @@ public class Game  implements Serializable {
      * renvoie la liste des ressources sur lesquelles le joueur est présent
      * @return la liste des ressources sur lesquelles le joueur est présent
      */
-    public ArrayList<LocatedResources> getResourcesNextToPlayer()
+    public ArrayList<Resource> getResourcesNextToPlayer(Area a)
     {
-        ArrayList<LocatedResources> r = new ArrayList<LocatedResources>();
-
-        for(int i=0; i<mCurrentStageAreas.size(); i++)
-        {
-            //probleme de GPS..
-            boolean b = mCurrentStageAreas.get(i).isOnArea(mPlayer);
-
-            if(b)
-            {
-
-                if(i<mCurrentStageAreas.size() /*&& mCurrentStageAreas.get(i).isOnDirection(mPlayer)*/ &&
-                        mCurrentStageAreas.get(i).isOnPlace(mPlayer))
-                {
-                    ArrayList<Resource> rs = mResources.getResourceLeftByName(mCurrentStageAreas.get(i).getResourceNames());
-                    r.add(new LocatedResources(
-                            rs,
-                            mCurrentStageAreas.get(i).getPlace(0)
-                    ));
-                }
-            }
-        }
-        return r;
-    }
-
-
-    /**
-     * Renvoie dans une chaine la distance entre le joueur et la ressource la plus proche
-     * @return La distance en metres
-     */
-    public String getResourcesNextToPlayerDist()
-    {
-        double min=1000000000;
-        ArrayList<Resource> r = new ArrayList<Resource>();
-        for(int i=0; i<mCurrentStageAreas.size(); i++)
-        {
-            //probleme de GPS..
-            if(mCurrentStageAreas.get(i).isOnArea(mPlayer))
-            {
-                if(mCurrentStageAreas.get(i).getDistanceToNextPlace(mPlayer)<min)
-                    min=mCurrentStageAreas.get(i).getDistanceToNextPlace(mPlayer);
-
-            }
-        }
-        if(min>10000000) return " --.- m";
-        NumberFormat formatter = new DecimalFormat("#0.0");
-        return formatter.format(min)+" m";
-    }
-
-    /**
-     * Renvoie la distance entre le joueur et la ressource la plus proche
-     * @return La distance en metres
-     */
-    public double getResourcesNextToPlayerDistDouble()
-    {
-        double min=1000000000;
         ArrayList<Resource> r = new ArrayList<Resource>();
-        for(int i=0; i<mCurrentStageAreas.size(); i++)
-        {
-            //probleme de GPS..
-            if(mCurrentStageAreas.get(i).isOnArea(mPlayer))
-            {
-                if(mCurrentStageAreas.get(i).getDistanceToNextPlace(mPlayer)<min)
-                    min=mCurrentStageAreas.get(i).getDistanceToNextPlace(mPlayer);
+        ArrayList<String> rs = a.getResourceNames();
 
-            }
-        }
-        if(min>10000000) return -1;
-        return min;
+        for(int i=0; i<rs.size(); i++)
+            r.add(findResource(rs.get(i)));
 
+        return r;
     }
 
-
-
     public Player getPlayer()
     {
         return mPlayer;
@@ -580,10 +259,7 @@ public class Game  implements Serializable {
             mSettings.setARMode(false);
     }
 
-    public ArrayList< ArrayList<Resource> > getResourceByStage()
-    {
-        return mResources.getResourceAquiered();
-    }
+
 
     public void restartSensors()
     {
@@ -594,9 +270,7 @@ public class Game  implements Serializable {
     {
         mPlayer.getSensorsManager().stopSensors();
     }
-    public void printNResource(String str)
-    {
-    }
+
 
 
     public static void setGame(Game m)
@@ -610,36 +284,24 @@ public class Game  implements Serializable {
     }
 
 
-    public boolean canSendData() {
-        Stage s =getCurrentStageObj();
-        if(s==null ) return false;
-        if(!s.isTransition()) return false;
-        return mResources.getNResourceAquiredByStage()>=s.getNResourceStep() && !isFinished();
-        //return mResources.getNResourceLeft()<s.getNResourceStep() && !isFinished();
-    }
-
-    public boolean isFinished() { return mFinished; }
-
-    public void finish() { mFinished=true; }
-
-    public int getNResourcesAquired()
-    {
-        return mResources.getNResourceAquired();
-    }
 
     public boolean hasResource(String name)
     {
-        return mResources.hasResource(name);
+        return mResources.contains(name);
     }
 
+    public ChallengeReturn getReturn() {
+        return mLastReturn;
+    }
 
-    public void printStage()
-    {
-        Log.e("---------------", "Stage:"+getCurrentStage());
-        for(int i=0; i<mResources.getResourceLeft().size(); i++) {
-            Log.e("---------------", "   '" + mResources.getResourceLeft().get(i).getName() + "'");
-
-        }
+    public void setReturn(ChallengeReturn mLastReturn) {
+        this.mLastReturn = mLastReturn;
     }
 
+    public Stage nextStage() {
+        mCurrentStageIndex++;
+        if(mCurrentStageIndex<mStages.size())
+            return mCurrentStage=mStages.get(mCurrentStageIndex);
+        return mCurrentStage=null;
+    }
 }

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

@@ -75,6 +75,7 @@ public class Place  implements Serializable {
         return mLocation.getDistanceWith(pp)<=mRadius+p.getSensorsManager().getPosition().getAccuracy();
     }
 
+
     public boolean isOnDirection(Player p)
     {
         boolean ret;

+ 12 - 0
app/src/main/java/app/mar/utils/game/QRCodeReturn.java

@@ -0,0 +1,12 @@
+package app.mar.utils.game;
+
+public class QRCodeReturn {
+
+    public boolean status=false;
+    public String  value="";
+
+    public QRCodeReturn(){}
+
+    public QRCodeReturn(String v){ value=v; }
+
+}

+ 5 - 9
app/src/main/java/app/mar/utils/game/Resource.java

@@ -60,6 +60,11 @@ public class Resource implements Serializable {
         }
     }
 
+    public void loadModel(Activity context)
+    {
+        get3DModel(context);
+    }
+
     public Number3d getPosition() {
         return mPosition;
     }
@@ -78,15 +83,6 @@ public class Resource implements Serializable {
         loadResourceData(act);
     }
 
-    public Resource(JSONObject obj, Activity act)
-    {
-        try {
-            mName=obj.getString("name");
-            loadResourceData(act);
-        } catch (JSONException e) {
-            e.printStackTrace();
-        }
-    }
 
     public String getName() {
         return mName;

+ 57 - 0
app/src/main/java/app/mar/utils/game/ResourceManager.java

@@ -0,0 +1,57 @@
+package app.mar.utils.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
+ */
+public class ResourceManager implements Serializable{
+    protected HashMap<String, Resource> mResources = new HashMap<String, Resource>();
+    protected Resource mLatestResource = null;
+
+
+    public ResourceManager()
+    {
+    }
+
+    public void addResource(String name, Activity act)
+    {
+        Resource r = new Resource(name, act);
+        mResources.put(name, r);
+    }
+
+    public boolean contains(String name){return mResources.containsKey(name);}
+
+    public Resource get(String name)
+    {
+        return mResources.get(name);
+    }
+
+    public int count()
+    {
+        return mResources.keySet().size();
+    }
+
+    public String[] getResourceList()
+    {
+        return (String[])mResources.keySet().toArray();
+    }
+
+    /**
+     * Enleve le Modele 3D de la cache
+     */
+    public void deleteAll3DModel()
+    {
+        String[] keys = getResourceList();
+        for(int i=0; i<keys.length; i++)
+            mResources.get(keys[i]).delete3DModel();
+    }
+
+}

+ 62 - 45
app/src/main/java/app/mar/utils/game/Stage.java

@@ -1,82 +1,99 @@
 package app.mar.utils.game;
 
+import android.app.Activity;
+
+import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
 
 import java.io.Serializable;
+import java.util.ArrayList;
 
-/**
- * Created by ptitcois on 27/08/16.
- */
-public class Stage implements Serializable {
-    public Stage()
-    {
+import app.mar.utils.game.Resource;
+import app.mar.utils.game.challenges.Challenge;
 
-    }
+public class Stage  implements Serializable {
+    protected String mName;
+    protected ArrayList<Challenge> mChallenge = new ArrayList<Challenge>();
+    protected ArrayList<Resource> mResources = new ArrayList<Resource>();
+    protected boolean mDone=false;
+    protected int     mStep=0;
 
-    public Stage(JSONObject obj)
+    public Stage(Game g, JSONObject root, Activity act)
     {
         try {
-            System.out.println("Obj: "+obj.toString());
-            mStage=obj.getInt("stage");
-            mResourceName=obj.getString("resource");
-            mNResourceStep=obj.getInt("n_resource_step");
-            mIsTransition=obj.getBoolean("transition");
+            mName = root.getString("name");
+            mDone = false;
+            JSONArray chall = root.getJSONArray("challenges");
+            for(int i=0; i<chall.length(); i++)
+            {
+                JSONObject obj = chall.getJSONObject(i);
+                String name = obj.getString("type");
+                Challenge c = Challenge.callChallengeConstructor(name, g, obj, act);
+                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();
         }
     }
 
-    public  String toString()
-    {
-        String s = "";
-        s+="Stage="+mStage+"\n";
-        s+="Resource="+mResourceName+"\n";
-        s+="Step="+mNResourceStep+"\n";
-        s+="Transition="+mIsTransition+"\n";
-        return s;
+
+    public String getName() {
+        return mName;
     }
 
-    protected int mStage;
-    protected Resource mResource;
-    protected String mResourceName;
-    protected int mNResourceStep;
-    protected boolean mIsTransition=true;
+    public void setName(String mName) {
+        this.mName = mName;
+    }
 
-    public int getStage() {
-        return mStage;
+    public ArrayList<Resource> getResources() {
+        return mResources;
     }
 
-    public void setStage(int mStage) {
-        this.mStage = mStage;
+    public void setResources(ArrayList<Resource> mResources) {
+        this.mResources = mResources;
     }
 
-    public Resource getResource() {
-        return mResource;
+    public boolean ismDone() {
+        return mDone;
     }
 
-    public void setResource(Resource mResource) {
-        this.mResource = mResource;
+    public void setDone(boolean mDone) {
+        this.mDone = mDone;
     }
 
-    public int getNResourceStep()
-    {
-        return mNResourceStep;
+    public int getStep() {
+        return mStep;
     }
 
-    public String getResourceName() {
-        return mResourceName;
+    public int getStepCount() {
+        return mChallenge.size();
     }
 
-    public void setResourceName(String mResourceName) {
-        this.mResourceName = mResourceName;
+    public Challenge nextChallenge()
+    {
+        mStep++;
+        if(mStep<mChallenge.size())
+            return mChallenge.get(mStep);
+        return null;
     }
 
-    public boolean isTransition() {
-        return mIsTransition;
+    public boolean isFinished()
+    {
+        if(mStep>=mChallenge.size()) mDone=true;
+        return mDone;
     }
 
-    public void setIsTransition(boolean mIsTransition) {
-        this.mIsTransition = mIsTransition;
+    public Challenge getCurrentChallenge()
+    {
+        if(!isFinished()) return mChallenge.get(mStep);
+        return null;
     }
+
 }

+ 108 - 0
app/src/main/java/app/mar/utils/game/challenges/Challenge.java

@@ -0,0 +1,108 @@
+package app.mar.utils.game.challenges;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.util.Log;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.io.Serializable;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+import app.mar.activities.ARActivity;
+import app.mar.activities.QuestionActivity;
+import app.mar.utils.game.Game;
+
+public abstract class Challenge implements Serializable{
+
+    public static final String CHALLENGE_NULL="null";
+
+
+    protected String mType=CHALLENGE_NULL;
+    protected String mName="null";
+    protected boolean mDone=false;
+    protected Class  mStartWith = null;
+
+    public Challenge(JSONObject root, Class start)
+    {
+        mStartWith=start;
+        try {
+            mType = root.getString("type");
+            mName = root.getString("name");
+            mDone = false;
+        } catch (JSONException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void exec(Game game, Activity act)
+    {
+        Intent intent = new Intent(act, mStartWith);
+        intent.putExtra("challenge", this);
+        intent.putExtra("game", game);
+        Log.e("______","Starting class : '"+ mStartWith.getName()+"'");
+        act.startActivityForResult(intent, getResultCode());
+    }
+
+    public String getType() {
+        return mType;
+    }
+
+    public String getName() {
+        return mName;
+    }
+
+    public abstract int getResultCode();
+
+    public boolean isDone() {
+        return mDone;
+    }
+
+    public void setDone()
+    {
+        mDone=true;
+    }
+
+    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);
+            return cls;
+        }
+        catch(ClassNotFoundException cnfe)
+        {
+            cnfe.printStackTrace();
+            return null;
+        }
+    }
+
+    public static Constructor<?> getChallengeConstructor(String classe)
+    {
+        try {
+            Class[] type = { Game.class, JSONObject.class, Activity.class };
+            return getChallengeClass(classe).getConstructor(type);
+        } catch (NoSuchMethodException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    public static Challenge callChallengeConstructor(String classe, Game g,JSONObject o, Activity a)
+    {
+        Constructor constr = getChallengeConstructor(classe);
+        try {
+            return ((Challenge) constr.newInstance(g, o, a));
+        } catch (InstantiationException e) {
+            e.printStackTrace();
+        } catch (IllegalAccessException e) {
+            e.printStackTrace();
+        } catch (InvocationTargetException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+}

+ 65 - 0
app/src/main/java/app/mar/utils/game/challenges/ChallengeReturn.java

@@ -0,0 +1,65 @@
+package app.mar.utils.game.challenges;
+
+import app.mar.utils.game.Resource;
+
+public class ChallengeReturn {
+    public  static final int BAD_RESPONS = -3;
+    public  static final int WAITING = -2;
+    public  static final int ERROR = -1;
+    public  static final int SUCCESS = 0;
+
+    protected int mCode = WAITING;
+    protected String mMessage = "Success";
+    protected Challenge mFrom;
+
+    public ChallengeReturn(Challenge c)
+    {
+        mFrom=c;
+    }
+
+    public ChallengeReturn(Challenge c, String msg)
+    {
+        mFrom=c;
+        mMessage=msg;
+    }
+
+    public ChallengeReturn(Challenge c, int code, String msg)
+    {
+        mFrom=c;
+        mCode=code;
+        mMessage=msg;
+    }
+
+    public void set(Challenge c, int code, String msg)
+    {
+        mFrom=c;
+        mCode=code;
+        mMessage=msg;
+    }
+
+
+
+    public int getCode() {
+        return mCode;
+    }
+
+    public void setCode(int mCode) {
+        this.mCode = mCode;
+    }
+
+    public String getMessage() {
+        return mMessage;
+    }
+
+    public void setMessage(String mMessage) {
+        this.mMessage = mMessage;
+    }
+
+    public Challenge getFrom() {
+        return mFrom;
+    }
+
+    public void setFrom(Challenge mResource) {
+        this.mFrom = mResource;
+    }
+}

+ 36 - 0
app/src/main/java/app/mar/utils/game/challenges/GeoTreasure.java

@@ -0,0 +1,36 @@
+package app.mar.utils.game.challenges;
+
+import android.app.Activity;
+
+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;
+
+public class GeoTreasure extends Treasure {
+    protected Area mArea;
+    public static final int REQUEST_CODE=2001;
+
+    public int getResultCode() { return REQUEST_CODE; }
+
+    public GeoTreasure(Game g, JSONObject root, Activity act) {
+        super(root, ARActivity.class);
+
+        try
+        {
+            mArea = new Area(g, root.getJSONObject("area"), act);
+        }
+        catch(JSONException e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+
+
+    public Area getArea() {
+        return mArea;
+    }
+}

+ 41 - 0
app/src/main/java/app/mar/utils/game/challenges/QCM.java

@@ -0,0 +1,41 @@
+package app.mar.utils.game.challenges;
+
+import android.app.Activity;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+
+import app.mar.activities.QCMActivity;
+import app.mar.utils.game.Game;
+
+public class QCM extends Question{
+
+    public static final String CHALLENGE_QCM="qcm";
+    protected ArrayList<String> mChoices = new ArrayList<String>();
+    public static final int REQUEST_CODE=2002;
+
+
+
+    public int getResultCode() { return REQUEST_CODE; }
+
+    public QCM(Game g, JSONObject root, Activity a) {
+        super(g, root, a);
+        mStartWith= QCMActivity.class;
+        try {
+            JSONArray arr = root.getJSONArray("choices");
+            for(int i=0; i<arr.length(); i++)
+                mChoices.add(arr.getString(i));
+
+        }catch(JSONException e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    public ArrayList<String> getChoices() {
+        return mChoices;
+    }
+}

+ 53 - 0
app/src/main/java/app/mar/utils/game/challenges/QRCodeTreasure.java

@@ -0,0 +1,53 @@
+package app.mar.utils.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.utils.game.Game;
+import app.mar.utils.game.Resource;
+
+public class QRCodeTreasure extends Treasure {
+
+    protected String mQRValue;
+    protected String mBadQRMessage;
+    protected String mResource;
+    public static final int REQUEST_CODE=2003;
+
+    public int getResultCode() { return REQUEST_CODE; }
+
+    public QRCodeTreasure(Game g, JSONObject root, Activity a) {
+        super(root, QRCodeActivity.class);
+
+        try {
+            mQRValue = root.getString("qr_value");
+            mBadQRMessage = root.getString("bad_message");
+            mResource = root.getString("resource");
+            g.registerResource(mResource, a);
+        } catch (JSONException e) {
+            e.printStackTrace();
+        }
+    }
+
+
+    public String getQRValue() {
+        return mQRValue;
+    }
+
+    public String getBadQRMessage() {
+        return mBadQRMessage;
+    }
+
+    public String getmResourceName()
+    {
+        return mResource;
+    }
+
+    public Resource getResource(Game g)
+    {
+        return g.findResource(mResource);
+    }
+}

+ 62 - 0
app/src/main/java/app/mar/utils/game/challenges/Question.java

@@ -0,0 +1,62 @@
+package app.mar.utils.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.utils.game.Game;
+
+public class Question extends Challenge {
+
+    protected String mQuestion;
+    protected String mAnswer;
+    protected String mGoodMessage;
+    protected String mBadMessage;
+    public static final int REQUEST_CODE=2004;
+
+
+    public int getResultCode() { return REQUEST_CODE; }
+
+
+    public Question(Game g,JSONObject root, Activity a) {
+        super(root, QuestionActivity.class);
+
+        try {
+            mQuestion = root.getString("question");
+            mAnswer = root.getString("answer");
+            mGoodMessage = root.getString("good_message");
+            mBadMessage = root.getString("bad_message");
+        } catch (JSONException e) {
+            e.printStackTrace();
+        }
+    }
+
+
+
+
+    public boolean checkAnswer(String answer)
+    {
+        return answer.toLowerCase().compareTo(mAnswer.toLowerCase())==0;
+    }
+
+
+    public String getQuestion() {
+        return mQuestion;
+    }
+
+    public String getAnswer() {
+        return mAnswer;
+    }
+
+    public String getGoodMessage() {
+        return mGoodMessage;
+    }
+
+    public String getBadMessage() {
+        return mBadMessage;
+    }
+}

+ 13 - 0
app/src/main/java/app/mar/utils/game/challenges/Treasure.java

@@ -0,0 +1,13 @@
+package app.mar.utils.game.challenges;
+
+import org.json.JSONObject;
+
+public abstract class Treasure extends Challenge {
+
+
+    public Treasure(JSONObject root, Class c) {
+        super(root, c);
+
+    }
+
+}

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

@@ -0,0 +1,63 @@
+<?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>

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

@@ -0,0 +1,25 @@
+<?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>

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

@@ -0,0 +1,64 @@
+<?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>

+ 0 - 1
app/src/main/res/layout/activity_transfer.xml

@@ -7,7 +7,6 @@
     android:paddingLeft="@dimen/activity_horizontal_margin"
     android:paddingRight="@dimen/activity_horizontal_margin"
     android:paddingTop="@dimen/activity_vertical_margin"
-    tools:context="app.mar.activities.TransferActivity"
     android:background="@drawable/background">
 
     <ProgressBar

+ 31 - 0
app/src/main/res/layout/custom_barcode_scanner.xml

@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<merge xmlns:android="http://schemas.android.com/apk/res/android"
+       xmlns:tools="http://schemas.android.com/tools"
+       xmlns:app="http://schemas.android.com/apk/res-auto">
+
+    <com.journeyapps.barcodescanner.BarcodeView
+        android:id="@+id/zxing_barcode_surface"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        app:zxing_framing_rect_height="250dp"
+        app:zxing_framing_rect_width="250dp" />
+
+    <com.journeyapps.barcodescanner.ViewfinderView
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:id="@+id/zxing_viewfinder_view"
+        app:zxing_possible_result_points="@color/zxing_custom_possible_result_points"
+        app:zxing_result_view="@color/zxing_custom_result_view"
+        app:zxing_viewfinder_laser="@color/zxing_custom_viewfinder_laser"
+        app:zxing_viewfinder_mask="@color/zxing_custom_viewfinder_mask"/>
+
+    <TextView
+        android:id="@+id/zxing_status_view"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="bottom|center_horizontal"
+        android:background="@color/zxing_transparent"
+        android:text="@string/zxing_msg_default_status"
+        android:textColor="@color/zxing_status_text"/>
+
+</merge>

+ 21 - 0
app/src/main/res/layout/zxing_barcode_scanner.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<merge xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <com.journeyapps.barcodescanner.BarcodeView
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:id="@+id/zxing_barcode_surface"/>
+
+    <com.journeyapps.barcodescanner.ViewfinderView
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:id="@+id/zxing_viewfinder_view"/>
+
+    <TextView android:id="@+id/zxing_status_view"
+              android:layout_width="wrap_content"
+              android:layout_height="wrap_content"
+              android:layout_gravity="bottom|center_horizontal"
+              android:background="@color/zxing_transparent"
+              android:text="@string/zxing_msg_default_status"
+              android:textColor="@color/zxing_status_text"/>
+</merge>

+ 30 - 0
app/src/main/res/layout/zxing_capture.xml

@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (C) 2008 ZXing authors
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<merge xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto">
+
+    <!--
+    This Activity is typically full-screen. Therefore we can safely use centerCrop scaling with
+    a SurfaceView, without fear of weird artifacts. -->
+    <com.journeyapps.barcodescanner.DecoratedBarcodeView
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:id="@+id/zxing_barcode_scanner"
+        app:zxing_preview_scaling_strategy="centerCrop"
+        app:zxing_use_texture_view="false"/>
+
+</merge>

+ 9 - 0
app/src/main/res/values/strings.xml

@@ -81,4 +81,13 @@
     <string name="title_activity_puzzle">PuzzleActivity</string>
 
     <string name="informations">Plus</string>
+    <string name="title_activity_question">QuestionActivity</string>
+    <string name="title_activity_qcm">QCMActivity</string>
+
+
+    <string name="zxing_app_name">Barcode Scanner</string>
+    <string name="zxing_button_ok">OK</string>
+    <string name="zxing_msg_camera_framework_bug">Désolé, la caméra Android a rencontré un problème. Un redémarrage de l\'appareil est peut-être nécessaire.</string>
+    <string name="zxing_msg_default_status">Encadrez un code-barres avec le viseur pour le balayer.</string>
+    <string name="title_activity_qrcode">QRCodeActivity</string>
 </resources>

+ 26 - 0
app/src/main/res/values/zxing_attrs.xml

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+
+  <declare-styleable name="zxing_view">
+    <attr name="zxing_scanner_layout" format="reference"/>
+  </declare-styleable>
+
+  <declare-styleable name="zxing_camera_preview">
+    <attr name="zxing_framing_rect_width" format="dimension" />
+    <attr name="zxing_framing_rect_height" format="dimension" />
+    <attr name="zxing_use_texture_view" format="boolean" />
+    <attr name="zxing_preview_scaling_strategy" format="enum">
+      <enum name="centerCrop" value="1" />
+      <enum name="fitCenter" value="2" />
+      <enum name="fitXY" value="3" />
+    </attr>
+  </declare-styleable>
+
+  <declare-styleable name="zxing_finder">
+    <attr name="zxing_possible_result_points" format="color"/>
+    <attr name="zxing_result_view" format="color"/>
+    <attr name="zxing_viewfinder_laser" format="color"/>
+    <attr name="zxing_viewfinder_mask" format="color"/>
+  </declare-styleable>
+
+</resources>

+ 29 - 0
app/src/main/res/values/zxing_colors.xml

@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (C) 2008 ZXing authors
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<resources>
+  <color name="zxing_possible_result_points">#c0ffbd21</color> <!-- Android standard ICS color -->
+  <color name="zxing_result_view">#b0000000</color>
+  <color name="zxing_status_text">#ffffffff</color>
+  <color name="zxing_transparent">#00000000</color>
+  <color name="zxing_viewfinder_laser">#ffcc0000</color> <!-- Android standard ICS color -->
+  <color name="zxing_viewfinder_mask">#60000000</color>
+
+  <color name="zxing_custom_possible_result_points">#903A89CF</color>
+  <color name="zxing_custom_result_view">#b0000000</color>
+  <color name="zxing_custom_viewfinder_laser">#1976D2</color>
+  <color name="zxing_custom_viewfinder_mask">#60000000</color>
+</resources>

+ 27 - 0
app/src/main/res/values/zxing_ids.xml

@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (C) 2008 ZXing authors
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<resources>
+  <item type="id" name="zxing_decode"/>
+  <item type="id" name="zxing_preview_failed"/>
+  <item type="id" name="zxing_decode_failed"/>
+  <item type="id" name="zxing_decode_succeeded"/>
+  <item type="id" name="zxing_possible_result_points"/>
+  <item type="id" name="zxing_back_button"/>
+  <item type="id" name="zxing_prewiew_size_ready"/>
+  <item type="id" name="zxing_camera_error"/>
+  <item type="id" name="zxing_camera_closed"/>
+</resources>

+ 5 - 0
app/src/main/res/values/zxing_themes.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources>
+  <style name="zxing_CaptureTheme" parent="android:Theme.Holo.NoActionBar.Fullscreen">
+  </style>
+</resources>

+ 24 - 0
base/build.gradle

@@ -0,0 +1,24 @@
+apply plugin: 'com.android.feature'
+
+android {
+    compileSdkVersion 27
+    baseFeature true
+    defaultConfig {
+        minSdkVersion 14
+        targetSdkVersion 27
+        versionCode 1
+        versionName "1.0"
+    }
+    buildTypes {
+        release {
+            minifyEnabled false
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+        }
+    }
+}
+
+dependencies {
+    api 'com.android.support:appcompat-v7:27.1.0'
+    application project(':app')
+    feature project(':feature')
+}

+ 2 - 1
build.gradle

@@ -8,7 +8,7 @@ buildscript {
     }
     dependencies {
         classpath 'com.android.tools.build:gradle:3.1.0'
-        
+
 
         // NOTE: Do not place your application dependencies here; they belong
         // in the individual module build.gradle files
@@ -24,4 +24,5 @@ allprojects {
 
 task clean(type: Delete) {
     delete rootProject.buildDir
+
 }

+ 26 - 0
feature/build.gradle

@@ -0,0 +1,26 @@
+apply plugin: 'com.android.feature'
+
+android {
+    compileSdkVersion 27
+    defaultConfig {
+        minSdkVersion 14
+        targetSdkVersion 27
+        versionCode 1
+        versionName "1.0"
+        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+    }
+    buildTypes {
+        release {
+            minifyEnabled false
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+        }
+    }
+}
+
+dependencies {
+    implementation fileTree(dir: 'libs', include: ['*.jar'])
+    implementation project(':base')
+    testImplementation 'junit:junit:4.12'
+    androidTestImplementation 'com.android.support.test:runner:1.0.1'
+    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
+}

+ 21 - 0
feature/proguard-rules.pro

@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile

+ 6 - 0
gradle/wrapper/gradle-wrapper.properties

@@ -0,0 +1,6 @@
+#Thu Mar 29 14:44:47 GMT 2018
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

+ 6 - 0
instantapp/build.gradle

@@ -0,0 +1,6 @@
+apply plugin: 'com.android.instantapp'
+
+dependencies {
+    implementation project(':feature')
+    implementation project(':base')
+}