gautrais 7 tahun lalu
induk
melakukan
b56bbd2581
48 mengubah file dengan 1079 tambahan dan 1008 penghapusan
  1. 7 9
      app/app.iml
  2. 1 0
      app/build.gradle
  3. 4 19
      app/src/main/AndroidManifest.xml
  4. 70 29
      app/src/main/assets/game_medium
  5. 13 0
      app/src/main/java/app/mar/activities/ChallengeDriver.java
  6. 192 0
      app/src/main/java/app/mar/activities/ChallengeFragment.java
  7. 0 16
      app/src/main/java/app/mar/activities/EndActivity.java
  8. 117 8
      app/src/main/java/app/mar/activities/HostActivity.java
  9. 0 7
      app/src/main/java/app/mar/activities/IViewerActivity.java
  10. 2 6
      app/src/main/java/app/mar/activities/ImageViewerActivity.java
  11. 0 37
      app/src/main/java/app/mar/activities/InfoActivity.java
  12. 0 60
      app/src/main/java/app/mar/activities/MARMenuActivity.java
  13. 2 4
      app/src/main/java/app/mar/activities/MediaViewerAcitvity.java
  14. 1 36
      app/src/main/java/app/mar/activities/MenuActivity.java
  15. 2 3
      app/src/main/java/app/mar/activities/ModelViewerActivity.java
  16. 7 7
      app/src/main/java/app/mar/activities/PermissionActivity.java
  17. 0 163
      app/src/main/java/app/mar/activities/PuzzleActivity.java
  18. 0 3
      app/src/main/java/app/mar/activities/QCMActivity.java
  19. 125 0
      app/src/main/java/app/mar/activities/QCMFragment.java
  20. 210 0
      app/src/main/java/app/mar/activities/QRCodeFragment.java
  21. 26 41
      app/src/main/java/app/mar/activities/QuestionFragment.java
  22. 0 90
      app/src/main/java/app/mar/activities/SEMenuActivity.java
  23. 0 102
      app/src/main/java/app/mar/ui/ResourceArrayAdapter.java
  24. 0 8
      app/src/main/java/app/mar/utils/AndroidResources.java
  25. 0 2
      app/src/main/java/app/mar/utils/game/Bomb.java
  26. 0 1
      app/src/main/java/app/mar/utils/game/Resource.java
  27. 1 0
      app/src/main/java/app/mar/utils/game/Stage.java
  28. 62 7
      app/src/main/java/app/mar/utils/game/challenges/Challenge.java
  29. 11 0
      app/src/main/java/app/mar/utils/game/challenges/GeoIndice.java
  30. 38 0
      app/src/main/java/app/mar/utils/game/challenges/Indice.java
  31. 2 1
      app/src/main/java/app/mar/utils/game/challenges/QCM.java
  32. 2 1
      app/src/main/java/app/mar/utils/game/challenges/QRCodeTreasure.java
  33. 2 1
      app/src/main/java/app/mar/utils/game/challenges/Question.java
  34. 21 0
      app/src/main/java/app/mar/utils/game/challenges/TextIndice.java
  35. 0 52
      app/src/main/res/layout/activity_end.xml
  36. 3 3
      app/src/main/res/layout/activity_host.xml
  37. 0 50
      app/src/main/res/layout/activity_info.xml
  38. 0 33
      app/src/main/res/layout/activity_main.xml
  39. 6 7
      app/src/main/res/layout/activity_new_menu.xml
  40. 0 56
      app/src/main/res/layout/activity_splash.xml
  41. 0 63
      app/src/main/res/layout/activity_transfer.xml
  42. 0 20
      app/src/main/res/layout/array_layout.xml
  43. 0 11
      app/src/main/res/layout/content_main.xml
  44. 76 0
      app/src/main/res/layout/fragment_qcm.xml
  45. 54 0
      app/src/main/res/layout/fragment_qrcode.xml
  46. 22 1
      app/src/main/res/layout/fragment_question.xml
  47. 0 21
      app/src/main/res/layout/zxing_barcode_scanner.xml
  48. 0 30
      app/src/main/res/layout/zxing_capture.xml

+ 7 - 9
app/app.iml

@@ -84,7 +84,6 @@
       <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
       <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
       <sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
-      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/applicationId" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/build-info" />
@@ -113,33 +112,32 @@
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
       <excludeFolder url="file://$MODULE_DIR$/build/outputs" />
-      <excludeFolder url="file://$MODULE_DIR$/build/reports" />
       <excludeFolder url="file://$MODULE_DIR$/build/tmp" />
     </content>
     <orderEntry type="jdk" jdkName="Android API 27 Platform" jdkType="Android SDK" />
     <orderEntry type="sourceFolder" forTests="false" />
     <orderEntry type="library" name="Gradle: com.android.support.constraint:constraint-layout-solver:1.0.2@jar" level="project" />
     <orderEntry type="library" name="Gradle: com.android.support:transition-27.1.0" level="project" />
+    <orderEntry type="library" name="Gradle: com.android.support:support-v4-27.1.1" level="project" />
     <orderEntry type="library" name="Gradle: com.journeyapps:zxing-android-embedded-3.6.0" level="project" />
     <orderEntry type="library" name="Gradle: android.arch.lifecycle:common:1.1.0@jar" level="project" />
-    <orderEntry type="library" name="Gradle: com.android.support:support-fragment-27.1.0" level="project" />
+    <orderEntry type="library" name="Gradle: com.android.support:support-fragment-27.1.1" level="project" />
+    <orderEntry type="library" name="Gradle: com.android.support:support-annotations:27.1.1@jar" level="project" />
     <orderEntry type="library" name="Gradle: com.android.support.constraint:constraint-layout-1.0.2" level="project" />
     <orderEntry type="library" name="Gradle: com.android.support:design-27.1.0" level="project" />
     <orderEntry type="library" name="Gradle: android.arch.core:runtime-1.1.0" level="project" />
+    <orderEntry type="library" name="Gradle: com.android.support:support-compat-27.1.1" level="project" />
     <orderEntry type="library" name="Gradle: com.android.support:animated-vector-drawable-27.1.0" level="project" />
     <orderEntry type="library" name="Gradle: com.android.support:appcompat-v7-27.1.0" level="project" />
     <orderEntry type="library" name="Gradle: android.arch.lifecycle:viewmodel-1.1.0" level="project" />
-    <orderEntry type="library" name="Gradle: com.android.support:support-v4-27.1.0" level="project" />
-    <orderEntry type="library" name="Gradle: com.android.support:support-compat-27.1.0" level="project" />
     <orderEntry type="library" name="Gradle: com.google.zxing:core:3.3.0@jar" level="project" />
     <orderEntry type="library" name="Gradle: com.android.support:recyclerview-v7-27.1.0" level="project" />
     <orderEntry type="library" name="Gradle: android.arch.lifecycle:livedata-core-1.1.0" level="project" />
-    <orderEntry type="library" name="Gradle: com.android.support:support-media-compat-27.1.0" level="project" />
+    <orderEntry type="library" name="Gradle: com.android.support:support-media-compat-27.1.1" level="project" />
+    <orderEntry type="library" name="Gradle: com.android.support:support-core-ui-27.1.1" level="project" />
     <orderEntry type="library" name="Gradle: com.android.support:support-vector-drawable-27.1.0" level="project" />
-    <orderEntry type="library" name="Gradle: com.android.support:support-annotations:27.1.0@jar" level="project" />
-    <orderEntry type="library" name="Gradle: com.android.support:support-core-utils-27.1.0" level="project" />
     <orderEntry type="library" name="Gradle: android.arch.core:common:1.1.0@jar" level="project" />
-    <orderEntry type="library" name="Gradle: com.android.support:support-core-ui-27.1.0" level="project" />
+    <orderEntry type="library" name="Gradle: com.android.support:support-core-utils-27.1.1" level="project" />
     <orderEntry type="library" name="Gradle: android.arch.lifecycle:runtime-1.1.0" level="project" />
     <orderEntry type="library" name="Gradle: com.android.support:gridlayout-v7-27.1.0" level="project" />
     <orderEntry type="module" module-name="feature" />

+ 1 - 0
app/build.gradle

@@ -32,4 +32,5 @@ dependencies {
     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'
+    implementation 'com.android.support:support-v4:27.1.1'
 }

+ 4 - 19
app/src/main/AndroidManifest.xml

@@ -36,22 +36,6 @@
             android:configChanges="orientation|keyboardHidden"
             android:label="@string/title_activity_settings"
             android:screenOrientation="portrait" />
-        <activity android:name=".EndActivity" />
-        <activity
-            android:name=".MARMenuActivity"
-            android:configChanges="orientation|keyboardHidden"
-            android:screenOrientation="portrait" />
-        <activity
-            android:name=".SEMenuActivity"
-            android:configChanges="orientation|keyboardHidden"
-            android:screenOrientation="portrait">
-            >
-        </activity>
-        <activity
-            android:name=".PuzzleActivity"
-            android:configChanges="orientation|keyboardHidden|screenSize"
-            android:label="@string/title_activity_puzzle"
-            android:theme="@style/FullscreenTheme" />
         <activity android:name=".PermissionActivity">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
@@ -65,9 +49,6 @@
         <activity
             android:name=".ModelViewerActivity"
             android:theme="@style/AppTheme.NoActionBar.Fullscreen" />
-        <activity
-            android:name=".InfoActivity"
-            android:theme="@style/AppTheme.NoActionBar.Fullscreen" />
         <activity
             android:name=".CreditsActivity"
             android:theme="@style/AppTheme.NoActionBar.Fullscreen" />
@@ -82,6 +63,10 @@
             android:name=".QRCodeActivity"
             android:label="@string/title_activity_qrcode"
             android:theme="@style/AppTheme.NoActionBar" />
+        <activity
+            android:name=".MenuActivity"
+            android:label="@string/title_activity_qrcode"
+            android:theme="@style/AppTheme.NoActionBar" />
         <activity
             android:name=".HostActivity"
             android:label="@string/title_activity_host"

+ 70 - 29
app/src/main/assets/game_medium

@@ -12,17 +12,20 @@
 						"name" : "A trouver",
 						"bad_message" : "Essaye encore",
 						"qr_value" : "1",
-						"resource" : "b"
+						"resource" : "b",
+						"indices" : [
+						    {
+						        "type" : "text",
+						        "text" : "Entre le 0 et le 2",
+						        "penality": 1
+						    },
+						    {
+						        "type" : "text",
+						        "text" : "sqrt(x) = x",
+                                 "penality": 5
+						    }
+						]
 					},
-                    {
-                       "type" : "QCM",
-                       "name" : "Joconde",
-                       "question" : "Qui a peint la Joconde ?",
-                       "answer" : "Léonard De Vinci",
-                       "choices" : ["Léonard De Vinci", "Jean Ferrat", "Patrick Timsit", "BHL"],
-                       "good_message" : "Bien joué !",
-                       "bad_message" : "T'es nul !"
-                    },
                     {
                          "type" : "QCM",
                          "name" : "MontagneEstBelle",
@@ -30,34 +33,72 @@
                          "answer" : "Jean Ferrat",
                          "choices" : ["Jacques Chirac", "Jean Ferrat", "Patrick Timsit", "BHL"],
                          "good_message" : "Bien joué !",
-                         "bad_message" : "T'es nul !"
-                    },
-                    {
-                          "type" : "Question",
-                          "name" : "Question A tous",
-                          "question" : "Quelle est la réponse à la vie l'univers et le reste ?",
-                          "answer" : "42",
-                          "good_message" : "Bien joué !",
-                          "bad_message" : "T'es nul !"
+                         "bad_message" : "T'es nul !",
+						"indices" : [
+						    {
+						        "type" : "text",
+						        "text" : "Un chanteur",
+                                "penality": 3
+						    },
+						    {
+						        "type" : "text",
+						        "text" : "Un Communiste",
+                                 "penality": 2
+						    }
+						]
                     }
 
 				],
-			"resources" : "a"
+			"resources" : ["a"]
 		},
 		{
 			"name" : "Le Premier",
 			"challenges" : 
 				[
-					{
-						"type" : "Question",
-						"name" : "Henri 4",
-						"question" : "Comment s'appelait le cheval blanc d'Henri IV ?",
-						"answer" : "Chirac",
-						"good_message" : "Bien joué !",
-						"bad_message" : "Trop nul"
-					}
+
+                    {
+                       "type" : "QCM",
+                       "name" : "Joconde",
+                       "question" : "Qui a peint la Joconde ?",
+                       "answer" : "Léonard De Vinci",
+                       "choices" : ["Léonard De Vinci", "Jean Ferrat", "Patrick Timsit", "BHL"],
+                       "good_message" : "Bien joué !",
+                       "bad_message" : "T'es nul !",
+                        "indices" : [
+                            {
+                                "type" : "text",
+                                "text" : "Un italien",
+                                   "penality": 3
+                            },
+                            {
+                                "type" : "text",
+                                "text" : "Un vieu !",
+                                    "penality": 2
+                            }
+                        ]
+                    },
+                    {
+                          "type" : "Question",
+                          "name" : "Question A tous",
+                          "question" : "Quelle est la réponse à la vie l'univers et le reste ?",
+                          "answer" : "42",
+                          "good_message" : "Bien joué !",
+                          "bad_message" : "T'es nul !",
+                          "indices" : [
+                              {
+                                  "type" : "text",
+                                  "text" : "Dans H2G2",
+                                     "penality": 3
+                              },
+                              {
+                                  "type" : "text",
+                                  "text" : "6 x 7 = ?",
+                                   "penality": 2
+                              }
+                          ]
+                    }
 				],
-			"resources" : "a"
+			"resources" : ["a"]
 		}
 	],
 	"credits" : 

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

@@ -0,0 +1,13 @@
+package app.mar.activities;
+
+import android.net.Uri;
+
+import app.mar.utils.game.challenges.Challenge;
+
+public interface ChallengeDriver extends ChallengeFragment.OnFragmentInteractionListener {
+    public void challengeValidate(Challenge c);
+    public Challenge currentChallenge();
+    public void setFragment(Class c);
+    public void onFragmentInteraction(Uri uri);
+
+}

+ 192 - 0
app/src/main/java/app/mar/activities/ChallengeFragment.java

@@ -0,0 +1,192 @@
+package app.mar.activities;
+
+import android.app.Fragment;
+import android.content.Context;
+import android.net.Uri;
+import android.os.Bundle;
+import android.support.annotation.CallSuper;
+import android.util.Log;
+import android.util.TypedValue;
+import android.view.KeyEvent;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import java.util.ArrayList;
+
+import app.mar.utils.game.Game;
+import app.mar.utils.game.challenges.Challenge;
+import app.mar.utils.game.challenges.GeoIndice;
+import app.mar.utils.game.challenges.Indice;
+import app.mar.utils.game.challenges.TextIndice;
+
+public abstract class ChallengeFragment extends Fragment {
+    public abstract boolean check();
+    protected abstract void onInitChallenge(Challenge c);
+    protected abstract  void onResetUi();
+
+
+
+    protected LinearLayout  mUITextIndices;
+    protected TextView      mUIGeoIndice;
+    protected LinearLayout  mUIGlobalIndice;
+
+    protected Challenge      mChallenge;
+
+
+    public void resetUi()
+    {
+        if(mUIGeoIndice!=null)
+        {
+            mUIGeoIndice.setVisibility(View.GONE);
+        }
+        if(mUITextIndices!=null)
+        {
+            mUITextIndices.removeAllViews();
+        }
+        if(mUIGlobalIndice!=null)
+        {
+            mUIGlobalIndice.setVisibility(View.GONE);
+        }
+        onResetUi();
+    }
+
+    private void updateIndices()
+    {
+        ArrayList<Indice> inds = mChallenge.getIndices();
+        if(mUIGlobalIndice!=null && inds.size()>0) mUIGlobalIndice.setVisibility(View.VISIBLE);
+        for(int i=0; i<inds.size(); i++)
+        {
+            Indice ind = inds.get(i);
+            if(ind instanceof GeoIndice && mUIGeoIndice!=null)
+            {
+                mUIGeoIndice.setVisibility(View.VISIBLE);
+            }else if(ind instanceof TextIndice && mUITextIndices!=null)
+            {
+                TextView tv = new TextView(getActivity());
+                tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
+                tv.setText(((TextIndice) ind).getText());
+            }
+        }
+    }
+
+    public Indice showIndice()
+    {
+        Indice ind = mChallenge.nextIndice();
+        if(ind!=null)
+        {
+            if(getActivity() instanceof  ChallengeDriver)
+            {
+                if(ind instanceof GeoIndice)
+                {
+                    if(mUIGeoIndice!=null)
+                    {
+                        mUIGeoIndice.setVisibility(View.VISIBLE);
+                        ind.discover();
+                        return ind;
+                    }
+                    return null;
+                }else if(ind instanceof TextIndice)
+                {
+                    if(mUITextIndices!=null)
+                    {
+                        TextView tv = new TextView(getActivity());
+                        tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
+                        tv.setText(((TextIndice) ind).getText());
+                        ind.discover();
+                        return ind;
+                    }
+                }
+            }
+        }
+        return null;
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        Log.e("______", "Calling onCreate ______________ : "+getClass().toString());
+    }
+
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,int res) {
+        // Inflate the layout for this fragment
+        View v = inflater.inflate(res, container, false);
+        Log.e("______________", "super.onCreateView: "+mUIGlobalIndice);
+        mUITextIndices= (LinearLayout) v.findViewById(R.id.ll_textIndices);
+        mUIGeoIndice= (TextView) v.findViewById(R.id.tv_geoIndice);
+        mUIGlobalIndice = (LinearLayout) v.findViewById(R.id.ll_rootIndices);
+        Log.e("______________", "Ici: "+mUIGlobalIndice);
+        Log.e("#########", "setFragment Commit : false");
+        return v;
+    }
+
+
+    public void initChallenge(Challenge c)
+    {
+        Log.e("#########", "initChallenges");
+        mChallenge=c;
+        updateIndices();
+        onInitChallenge(c);
+    }
+
+    public void onStart() {
+        super.onStart();
+        Log.e("---------", "OnStart !");
+    }
+
+    public boolean onKeyDown(int keyCode, KeyEvent event) {
+        return false;
+    }
+
+    private OnFragmentInteractionListener mListener;
+
+    /**
+     * This interface must be implemented by activities that contain this
+     * fragment to allow an interaction in this fragment to be communicated
+     * to the activity and potentially other fragments contained in that
+     * activity.
+     * <p>
+     * See the Android Training lesson <a href=
+     * "http://developer.android.com/training/basics/fragments/communicating.html"
+     * >Communicating with Other Fragments</a> for more information.
+     */
+    public interface OnFragmentInteractionListener {
+        // TODO: Update argument type and name
+        void onFragmentInteraction(Uri uri);
+    }
+
+    // TODO: Rename method, update argument and hook method into UI event
+    public void onButtonPressed(Uri uri) {
+        if (mListener != null) {
+            mListener.onFragmentInteraction(uri);
+        }
+    }
+
+    @Override
+    public void onAttach(Context context) {
+        super.onAttach(context);
+        if (context instanceof OnFragmentInteractionListener) {
+            mListener = (OnFragmentInteractionListener) context;
+        } else {
+            throw new RuntimeException(context.toString()
+                    + " must implement OnFragmentInteractionListener");
+        }
+
+        Log.e("______", "Calling class ______________ : "+getClass().toString());
+    }
+
+    @Override
+    public void onDetach() {
+        super.onDetach();
+        mListener = null;
+    }
+
+    public Challenge getChallenge() {
+        return mChallenge;
+    }
+}

+ 0 - 16
app/src/main/java/app/mar/activities/EndActivity.java

@@ -1,16 +0,0 @@
-package app.mar.activities;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-import app.mar.utils.FontChangeCrawler;
-
-public class EndActivity extends Activity {
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.activity_end);
-        FontChangeCrawler.setFont(this);
-    }
-}

+ 117 - 8
app/src/main/java/app/mar/activities/HostActivity.java

@@ -1,26 +1,43 @@
 package app.mar.activities;
 
 import android.app.Activity;
+import android.app.Fragment;
 import android.app.FragmentManager;
 import android.app.FragmentTransaction;
+import android.net.Uri;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Message;
+import android.util.Log;
 import android.view.View;
+import android.widget.Button;
 import android.widget.TextView;
+import android.widget.Toast;
 
 import java.util.Timer;
 import java.util.TimerTask;
 
 import app.mar.utils.game.Game;
+import app.mar.utils.game.Stage;
+import app.mar.utils.game.challenges.Challenge;
+import app.mar.utils.game.challenges.Indice;
+import app.mar.utils.game.challenges.Question;
 
 
-public class HostActivity extends Activity {
+public class HostActivity extends Activity implements ChallengeDriver{
     protected Game mGame;
     protected TextView mUITimeLeft;
     protected TextView mUICode;
+    protected Button   mUIButtonVideos;
+    protected Button   mUIButtonIndice;
+    protected Button   mUIButtonValid;
     private Timer mTimer;
 
+    protected QCMFragment mQCMFragment;
+    protected QRCodeFragment mQRCodeFragment;
+    protected QuestionFragment mQuestionFragment;
+    protected ChallengeFragment mCurrentFragment;
+
     private Runnable mTimerTick = new Runnable() {
         public void run() {
             if(!mGame.getBomb().hasExplosed())
@@ -40,13 +57,16 @@ public class HostActivity extends Activity {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_host);
 
-        FragmentManager fm = getFragmentManager();
-        FragmentTransaction ft = fm.beginTransaction();
-        ft.replace(R.id.container, QuestionFragment.newInstance());
-        ft.commit();
+        mQCMFragment = QCMFragment.newInstance();
+        mQuestionFragment = QuestionFragment.newInstance();
+        mQRCodeFragment = QRCodeFragment.newInstance();
+        mUIButtonVideos = (Button) findViewById(R.id.btn_videos);
+        mUIButtonIndice = (Button) findViewById(R.id.btn_indice);
+        mUIButtonValid = (Button) findViewById(R.id.btn_valid);
 
         mGame=Game.game();
 
+
         mUITimeLeft = findViewById(R.id.tv_car);
         mUICode = findViewById(R.id.tv_code);
 
@@ -58,8 +78,46 @@ public class HostActivity extends Activity {
             }
 
         }, 0, 1000);
+
         updateCode();
 
+        startChallenge();
+
+    }
+
+    public   void setFragment(Class type)
+    {
+        ChallengeFragment f = null;
+        final Challenge chall = mGame.getCurrentChallenge();
+
+        if(type.isInstance(mQCMFragment))
+            f= mQCMFragment;
+        else if(type.isInstance(mQRCodeFragment))
+            f= mQRCodeFragment;
+        else if(type.isInstance(mQuestionFragment))
+            f= mQuestionFragment;
+        else {
+            throw new RuntimeException("Erreur: La classe de fragment est null");
+        }
+
+        if(f!=mCurrentFragment)
+        {
+            mCurrentFragment=f;
+            FragmentManager fm = getFragmentManager();
+            FragmentTransaction ft = fm.beginTransaction();
+            ft.replace(R.id.container, mCurrentFragment);
+            ft.commit();
+            fm.executePendingTransactions();
+            Log.e("#########", "setFragment Commit : true");
+        }
+        else Log.e("#########", "setFragment Commit : false");
+        mCurrentFragment.initChallenge(chall);
+
+    }
+
+    @Override
+    public void onFragmentInteraction(Uri uri) {
+
     }
 
     private void timerCallback()
@@ -74,8 +132,13 @@ public class HostActivity extends Activity {
 
     public void onClickValid(View v)
     {
-        mGame.getBomb().addTime(-1);
-        timerCallback();
+        if(mCurrentFragment!=null)
+        {
+            if(mCurrentFragment.check())
+            {
+                challengeValidate(mCurrentFragment.getChallenge());
+            }
+        }
     }
 
 
@@ -91,11 +154,57 @@ public class HostActivity extends Activity {
 
     public void onClickIndice(View v)
     {
-
+        if(mCurrentFragment!=null)
+        {
+            Indice ind = mCurrentFragment.showIndice();
+            if(ind!=null && ind.getPenality()>0)
+                mGame.getBomb().addTime(-ind.getPenality());
+
+            if(!mCurrentFragment.getChallenge().hasNextIndice())
+                mUIButtonIndice.setVisibility(View.INVISIBLE);
+        }
     }
 
     public void onExplose()
     {
 
     }
+
+
+
+    public void nextChallenge() {
+        Stage s = mGame.getCurrentStage();
+        Challenge c = s.nextChallenge();
+        if(c!=null)
+        {
+            startChallenge();
+        }else //new stage
+        {
+            if(mGame.nextStage()!=null)
+                startChallenge();
+        }
+    }
+
+    @Override
+    public void challengeValidate(Challenge c) {
+        c.setDone();
+        nextChallenge();
+    }
+
+    public Challenge currentChallenge() {
+        return mGame.getCurrentChallenge();
+    }
+
+    private boolean startChallenge()
+    {
+        Challenge c = mGame.getCurrentChallenge();
+        Log.e("_____", "startChallenge : c : "+c);
+        if(c!=null) {
+            c.exec(this);
+            return true;
+        }
+        return false;
+    }
+
+
 }

+ 0 - 7
app/src/main/java/app/mar/activities/IViewerActivity.java

@@ -1,7 +0,0 @@
-package app.mar.activities;
-
-/**
- * Created by ptitcois on 04/07/17.
- */
-public interface IViewerActivity {
-}

+ 2 - 6
app/src/main/java/app/mar/activities/ImageViewerActivity.java

@@ -21,7 +21,7 @@ import uk.co.senab.photoview.PhotoViewAttacher;
  * An example full-screen activity that shows and hides the system UI (i.e.
  * status bar and navigation/system bar) with user interaction.
  */
-public class ImageViewerActivity extends AppCompatActivity implements IViewerActivity{
+public class ImageViewerActivity extends AppCompatActivity {
 
 
     private Resource mResource;
@@ -54,7 +54,6 @@ public class ImageViewerActivity extends AppCompatActivity implements IViewerAct
 
         if(mResource != null && !getIntent().hasExtra("information") && !getIntent().hasExtra("map"))
         {
-            Log.e("__________", "Info loaded");
             title.setText(mResource.getTitle());
             if(mResource.isImage())
             {
@@ -76,7 +75,6 @@ public class ImageViewerActivity extends AppCompatActivity implements IViewerAct
 
         } else if(getIntent().hasExtra("map") )
         {
-            Log.e("__________", "Map loaded");
             mContent=CONTENT_MAP;
             Bitmap bmp=null;
             try {
@@ -91,7 +89,6 @@ public class ImageViewerActivity extends AppCompatActivity implements IViewerAct
             mButton.setVisibility(View.GONE);
         }else
         {
-            Log.e("__________", "Erreur");
             title.setText("Erreur");
         }
         FontChangeCrawler.setFont(this);
@@ -100,8 +97,7 @@ public class ImageViewerActivity extends AppCompatActivity implements IViewerAct
 
     public void onClickInfo(View v)
     {
-        Intent intent = AndroidResources.getInfoIntent(this, mResource);
-        startActivity(intent);
+
     }
 
 

+ 0 - 37
app/src/main/java/app/mar/activities/InfoActivity.java

@@ -1,37 +0,0 @@
-package app.mar.activities;
-
-import android.support.v7.app.AppCompatActivity;
-import android.os.Bundle;
-import android.widget.TextView;
-
-import app.mar.utils.FontChangeCrawler;
-import app.mar.utils.game.Resource;
-
-public class InfoActivity extends AppCompatActivity  implements IViewerActivity{
-
-    private Resource mResource;
-    private TextView mTitle;
-    private TextView mText;
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.activity_info);
-
-        mTitle = (TextView) findViewById(R.id.title);
-        mText = (TextView) findViewById(R.id.tv_comment);
-
-        if(getIntent().hasExtra("resource"))
-        {
-            mResource = (Resource) getIntent().getSerializableExtra("resource");
-            if(mResource!=null) setTitle(mResource.getTitle());
-            mTitle.setText(mResource.getTitle());
-            mText.setText(mResource.getComment());
-        }else
-        {
-            mTitle.setText("Error: Res not found");
-        }
-        FontChangeCrawler.setFont(this);
-
-    }
-}

+ 0 - 60
app/src/main/java/app/mar/activities/MARMenuActivity.java

@@ -1,60 +0,0 @@
-package app.mar.activities;
-
-import android.content.res.Resources;
-import android.util.TypedValue;
-import android.widget.Button;
-
-/**
- * Created by ptitcois on 06/06/17.
- */
-public class MARMenuActivity extends MenuActivity{
-    protected  void refreshMenuStyle()
-    {
-        mRootLayout.setBackgroundResource(R.drawable.background);
-        int h4 = mHeight/3;
-        int w4 = mWidth/3;
-        int w = (int)(w4*1.25);
-        int h = dpToPx((int)(mBBriefing.getTextSize()*1.5));
-
-        moveView(mBBriefing, w4-2*w/3, mHOffset+h4-h,w,h);
-        moveView(mBInvotory, 2*w4-w/3, mHOffset+h4-h,w,h);
-        moveView(mBMap, w4-2*w/3, mHOffset+2*h4,w,h);
-        moveView(mBOptions, 2*w4-w/3, mHOffset+2*h4,w,h);
-        moveView(mBSend, mWidth/2-w, mHOffset+2*h4+4*h/3, 2*w, h);
-        ((Button)mBMenu).setTextSize(25);
-        //mBMenu.setTypeface(null,Typeface.BOLD);
-
-
-    }
-
-
-
-    protected void setUpMenuStyle()
-    {
-        mIbScanner = new Button(this);
-        //mIbScanner.setImageResource(R.drawable.scanner);
-        //mIbScanner.setScaleType(ImageView.ScaleType.FIT_CENTER);
-        mRootLayout.addView(mIbScanner);
-        mIbScanner.setBackgroundResource(R.drawable.uibuttoncircle);
-        mIbScanner.setText("Scanner");
-        mIbScanner.setTextColor(getResources().getColor(R.color.dull_4));
-        mIbScanner.setTextSize(22);
-        mIbScanner.setOnClickListener(this);
-
-        moveView(mIbScanner, mWidth / 2 - mHeight / 8, mHOffset + mHeight / 2 - mHeight / 8, mHeight / 4, mHeight / 4);
-
-        mBBriefing = newButton("Briefing");
-        mBInvotory = newButton("Inventaire");
-        mBMap = newButton("Carte");
-        mBOptions = newButton("Options");
-        mBMenu = newButton("Menu Principal");
-        mBMenu.setBackgroundResource(R.drawable.title);
-        mBSend = newButton("Envoyer les données");
-        Resources r = getResources();
-        float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 70, r.getDisplayMetrics());
-        moveView(mBMenu, 0, 0, mWidth, (int) px);
-
-
-
-    }
-}

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

@@ -20,8 +20,7 @@ import app.mar.utils.game.Resource;
 
 public class MediaViewerAcitvity extends AppCompatActivity implements MediaPlayer.OnSeekCompleteListener,
                                                                 MediaView.OnStartListener,
-                                                                SeekBar.OnSeekBarChangeListener,
-                                                                IViewerActivity{
+                                                                SeekBar.OnSeekBarChangeListener {
     private Resource mResource;
     private Button mInfo;
     private TextView mTitle;
@@ -116,8 +115,7 @@ public class MediaViewerAcitvity extends AppCompatActivity implements MediaPlaye
 
     public void onInfos(View v)
     {
-        Intent intent = AndroidResources.getInfoIntent(this, mResource);
-        startActivity(intent);
+
     }
 
     @Override

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

@@ -15,9 +15,7 @@ import android.widget.Toast;
 
 import app.mar.ui.RotateButton;
 import app.mar.utils.AndroidResources;
-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;
@@ -25,7 +23,7 @@ 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{
+public  class  MenuActivity extends Activity implements View.OnClickListener {
 
     protected int mWidth;
     protected int mHeight;
@@ -145,39 +143,6 @@ 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)
     {

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

@@ -19,7 +19,7 @@ import min3d.vos.CameraVo;
 import min3d.vos.Light;
 import min3d.vos.LightType;
 
-public class ModelViewerActivity extends RendererActivity  implements View.OnTouchListener, IViewerActivity {
+public class ModelViewerActivity extends RendererActivity  implements View.OnTouchListener {
 
     private Resource mResource;
     private Button mInfo;
@@ -59,8 +59,7 @@ public class ModelViewerActivity extends RendererActivity  implements View.OnTou
 
     public void onClickInfo(View v)
     {
-        Intent intent = AndroidResources.getInfoIntent(this, mResource);
-        startActivity(intent);
+
     }
 
     public void initScene()

+ 7 - 7
app/src/main/java/app/mar/activities/PermissionActivity.java

@@ -23,16 +23,16 @@ public class PermissionActivity extends AppCompatActivity {
     static final int PERM_COARSE_LOCATION=1339;
     protected TextView mText;
 
-    private static final String DISCLAMER="<h1><font color=\"#00ccff\">Attention :</font></h1> \n" +
-            "<h2><font color=\"#0099cc\">Ce jeu nécessite des déplacement en ville.</font></h2>\n" +
-            "<font color=\"#0099cc\">Veillez à respecter les règles suivantes : <br>\n" +
+    private static final String DISCLAMER="<h1>Attention :</h1> \n" +
+            "<h2>Ce jeu nécessite des déplacement en ville.</h2>\n" +
+            "Veillez à respecter les règles suivantes : <br>\n" +
             "Les enfants doivent être accompagnés d’un adulte. <br>\n" +
             "Faites attention à la circulation. <br>\n" +
             "Soyez vigilant sur l’environnement (altitude, marches, etc). <br>\n" +
-            "Ne jouer pas en conduisant. <br></font>\n" +
+            "Ne jouer pas en conduisant. <br>\n" +
             "\n" +
-            "<h3><font color=\"#00ccff\">Restez toujours conscient de votre environnement.</font></h3>\n" +
-            "<h3><font color=\"#00ccff\">En continuant, vous convenez que l’utilisation du jeu est à vos propres risques et responsabilités.</font></h3>";
+            "<h3>Restez toujours conscient de votre environnement.</h3>\n" +
+            "<h3>En continuant, vous convenez que l’utilisation du jeu est à vos propres risques et responsabilités.</h3>";
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -99,7 +99,7 @@ public class PermissionActivity extends AppCompatActivity {
     {
         if(m_nPerm==0)
         {
-            Intent intent = new Intent(this, MARMenuActivity.class);
+            Intent intent = new Intent(this, MenuActivity.class);
             startActivity(intent);
         }
     }

+ 0 - 163
app/src/main/java/app/mar/activities/PuzzleActivity.java

@@ -1,163 +0,0 @@
-package app.mar.activities;
-
-import android.annotation.SuppressLint;
-import android.support.v7.app.ActionBar;
-import android.support.v7.app.AppCompatActivity;
-import android.os.Bundle;
-import android.os.Handler;
-import android.view.MotionEvent;
-import android.view.View;
-
-/**
- * An example full-screen activity that shows and hides the system UI (i.e.
- * status bar and navigation/system bar) with user interaction.
- */
-public class PuzzleActivity extends AppCompatActivity {
-    /**
-     * Whether or not the system UI should be auto-hidden after
-     * {@link #AUTO_HIDE_DELAY_MILLIS} milliseconds.
-     */
-    private static final boolean AUTO_HIDE = true;
-
-    /**
-     * If {@link #AUTO_HIDE} is set, the number of milliseconds to wait after
-     * user interaction before hiding the system UI.
-     */
-    private static final int AUTO_HIDE_DELAY_MILLIS = 3000;
-
-    /**
-     * Some older devices needs a small delay between UI widget updates
-     * and a change of the status and navigation bar.
-     */
-    private static final int UI_ANIMATION_DELAY = 300;
-    private final Handler mHideHandler = new Handler();
-    private View mContentView;
-    private final Runnable mHidePart2Runnable = new Runnable() {
-        @SuppressLint("InlinedApi")
-        @Override
-        public void run() {
-            // Delayed removal of status and navigation bar
-
-            // Note that some of these constants are new as of API 16 (Jelly Bean)
-            // and API 19 (KitKat). It is safe to use them, as they are inlined
-            // at compile-time and do nothing on earlier devices.
-            mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE
-                    | View.SYSTEM_UI_FLAG_FULLSCREEN
-                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
-                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
-                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
-                    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
-        }
-    };
-    private View mControlsView;
-    private final Runnable mShowPart2Runnable = new Runnable() {
-        @Override
-        public void run() {
-            // Delayed display of UI elements
-            ActionBar actionBar = getSupportActionBar();
-            if (actionBar != null) {
-                actionBar.show();
-            }
-            mControlsView.setVisibility(View.VISIBLE);
-        }
-    };
-    private boolean mVisible;
-    private final Runnable mHideRunnable = new Runnable() {
-        @Override
-        public void run() {
-            hide();
-        }
-    };
-    /**
-     * Touch listener to use for in-layout UI controls to delay hiding the
-     * system UI. This is to prevent the jarring behavior of controls going away
-     * while interacting with activity UI.
-     */
-    private final View.OnTouchListener mDelayHideTouchListener = new View.OnTouchListener() {
-        @Override
-        public boolean onTouch(View view, MotionEvent motionEvent) {
-            if (AUTO_HIDE) {
-                delayedHide(AUTO_HIDE_DELAY_MILLIS);
-            }
-            return false;
-        }
-    };
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-
-        setContentView(R.layout.activity_puzzle);
-
-        mVisible = true;
-        mControlsView = findViewById(R.id.fullscreen_content_controls);
-        mContentView = findViewById(R.id.fullscreen_content);
-
-
-        // Set up the user interaction to manually show or hide the system UI.
-        mContentView.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View view) {
-                toggle();
-            }
-        });
-
-        // Upon interacting with UI controls, delay any scheduled hide()
-        // operations to prevent the jarring behavior of controls going away
-        // while interacting with the UI.
-        findViewById(R.id.dummy_button).setOnTouchListener(mDelayHideTouchListener);
-    }
-
-    @Override
-    protected void onPostCreate(Bundle savedInstanceState) {
-        super.onPostCreate(savedInstanceState);
-
-        // Trigger the initial hide() shortly after the activity has been
-        // created, to briefly hint to the user that UI controls
-        // are available.
-        delayedHide(100);
-    }
-
-    private void toggle() {
-        if (mVisible) {
-            hide();
-        } else {
-            show();
-        }
-    }
-
-    private void hide() {
-        // Hide UI first
-        ActionBar actionBar = getSupportActionBar();
-        if (actionBar != null) {
-            actionBar.hide();
-        }
-        mControlsView.setVisibility(View.GONE);
-        mVisible = false;
-
-        // Schedule a runnable to remove the status and navigation bar after a delay
-        mHideHandler.removeCallbacks(mShowPart2Runnable);
-        mHideHandler.postDelayed(mHidePart2Runnable, UI_ANIMATION_DELAY);
-    }
-
-    @SuppressLint("InlinedApi")
-    private void show() {
-        // Show the system bar
-        mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
-                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
-        mVisible = true;
-
-        // Schedule a runnable to display UI elements after a delay
-        mHideHandler.removeCallbacks(mHidePart2Runnable);
-        mHideHandler.postDelayed(mShowPart2Runnable, UI_ANIMATION_DELAY);
-    }
-
-    /**
-     * Schedules a call to hide() in [delay] milliseconds, canceling any
-     * previously scheduled calls.
-     */
-    private void delayedHide(int delayMillis) {
-        mHideHandler.removeCallbacks(mHideRunnable);
-        mHideHandler.postDelayed(mHideRunnable, delayMillis);
-    }
-}

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

@@ -45,8 +45,6 @@ public class QCMActivity extends AppCompatActivity {
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_qcm);
-        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
-        setSupportActionBar(toolbar);
 
 
 
@@ -85,7 +83,6 @@ public class QCMActivity extends AppCompatActivity {
     public void onValid(View v)
     {
         int x = mUIGoupQCM.getCheckedRadioButtonId()-mIdOffset;
-        Log.e("_______", "Id = "+x);
 
         if(x<0 || x>=mChoices.size())
         {

+ 125 - 0
app/src/main/java/app/mar/activities/QCMFragment.java

@@ -0,0 +1,125 @@
+package app.mar.activities;
+
+import android.app.ActionBar;
+import android.content.Context;
+import android.net.Uri;
+import android.os.Bundle;
+import android.app.Fragment;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.RadioButton;
+import android.widget.RadioGroup;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import java.util.ArrayList;
+
+import app.mar.activities.R;
+import app.mar.utils.game.Game;
+import app.mar.utils.game.challenges.Challenge;
+import app.mar.utils.game.challenges.QCM;
+
+/**
+ * A simple {@link Fragment} subclass.
+ * Activities that contain this fragment must implement the
+ * to handle interaction events.
+ * Use the {@link QCMFragment#newInstance} factory method to
+ * create an instance of this fragment.
+ */
+public class QCMFragment extends ChallengeFragment {
+    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;
+
+
+    public QCMFragment() {
+
+    }
+
+
+    public static QCMFragment newInstance() {
+        QCMFragment fragment = new QCMFragment();
+        Bundle args = new Bundle();
+        fragment.setArguments(args);
+        return fragment;
+    }
+
+    @Override
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+                             Bundle savedInstanceState) {
+        // Inflate the layout for this fragment
+        View v = super.onCreateView(inflater, container, R.layout.fragment_qcm);
+
+        mUIImage = (ImageView) v.findViewById(R.id.iv_img);
+        mUIQuestion = (TextView) v.findViewById(R.id.tv_question);
+        mUiValid = (Button) v.findViewById(R.id.btn_ok);
+        mUIGoupQCM = (RadioGroup) v.findViewById(R.id.rg_qcm);
+        Log.e("-------", "onCreateView");
+        return v;
+    }
+
+
+    @Override
+    public boolean check() {
+        int x = mUIGoupQCM.getCheckedRadioButtonId()-mIdOffset;
+
+        if(x<0 || x>=mChoices.size())
+        {
+            Toast.makeText(getActivity(), "Vous devez sélectionner une réponse ! "+x, Toast.LENGTH_LONG).show();
+            return false;
+        }else
+        {
+            String resp = mChoices.get(x);
+            if(mQCM.checkAnswer(resp))
+            {
+                Toast.makeText(getActivity(), mQCM.getGoodMessage(), Toast.LENGTH_LONG).show();
+                return true;
+            }else
+            {
+                Toast.makeText(getActivity(), mQCM.getBadMessage(), Toast.LENGTH_LONG).show();
+                return false;
+            }
+        }
+    }
+
+
+
+    @Override
+    public void onInitChallenge(Challenge c) {
+        mUIGoupQCM.removeAllViews();
+        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(getActivity());
+                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(getActivity(), "Error l'entrée n'est pas une question ! ", Toast.LENGTH_LONG).show();
+        }
+    }
+
+    @Override
+    protected void onResetUi() {
+
+    }
+
+}

+ 210 - 0
app/src/main/java/app/mar/activities/QRCodeFragment.java

@@ -0,0 +1,210 @@
+package app.mar.activities;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.net.Uri;
+import android.os.Bundle;
+import android.app.Fragment;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+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.QRCodeTreasure;
+
+
+/**
+ * A simple {@link Fragment} subclass.
+ * Activities that contain this fragment must implement the
+ * {@link QRCodeFragment.OnFragmentInteractionListener} interface
+ * to handle interaction events.
+ * Use the {@link QRCodeFragment#newInstance} factory method to
+ * create an instance of this fragment.
+ */
+public class QRCodeFragment extends ChallengeFragment  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;
+    private OnFragmentInteractionListener mListener;
+
+    public QRCodeFragment() {
+        // Required empty public constructor
+    }
+
+    /**
+     * Use this factory method to create a new instance of
+     * this fragment using the provided parameters.
+     *
+     * @return A new instance of fragment QRCodeFragment.
+     */
+    public static QRCodeFragment newInstance() {
+        QRCodeFragment fragment = new QRCodeFragment();
+        Bundle args = new Bundle();
+        fragment.setArguments(args);
+        return fragment;
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        if (getArguments() != null) {
+        }
+    }
+
+    @Override
+    protected void onInitChallenge(Challenge c) {
+        if(c instanceof QRCodeTreasure) {
+            mQr = (QRCodeTreasure) c;
+        }else
+        {
+            mQr=null;
+        }
+    }
+
+    @Override
+    protected void onResetUi() {
+
+    }
+
+    @Override
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+                             Bundle savedInstanceState) {
+        // Inflate the layout for this fragment
+        View v = super.onCreateView(inflater, container, R.layout.fragment_qrcode);
+        Log.e("#########", "setFragment onCreateView ");
+        barcodeScannerView = (DecoratedBarcodeView)v.findViewById(R.id.zxing_barcode_scanner);
+        barcodeScannerView.setTorchListener(this);
+        beepManager=new BeepManager(getActivity());
+
+        switchFlashlightButton = (Button)v.findViewById(R.id.switch_flashlight);
+
+
+        if (!hasFlash()) {
+            switchFlashlightButton.setVisibility(View.GONE);
+        }
+
+        capture = new CaptureManager(getActivity(), barcodeScannerView);
+        capture.initializeFromIntent(getActivity().getIntent(), savedInstanceState);
+
+        barcodeScannerView.decodeContinuous(this);
+
+        return v;
+    }
+
+
+
+
+
+
+
+    @Override
+    public void onResume() {
+        super.onResume();
+        capture.onResume();
+    }
+
+    @Override
+    public void onPause() {
+        super.onPause();
+        capture.onPause();
+    }
+
+    @Override
+    public void onDestroy() {
+        super.onDestroy();
+        capture.onDestroy();
+    }
+
+    @Override
+    public void onSaveInstanceState(Bundle outState) {
+        super.onSaveInstanceState(outState);
+        capture.onSaveInstanceState(outState);
+    }
+
+
+    public boolean onKeyDown(int keyCode, KeyEvent event) {
+        return barcodeScannerView.onKeyDown(keyCode, event) || getActivity().onKeyDown(keyCode, event);
+    }
+
+    /**
+     * Check if the device's camera has a Flashlight.
+     * @return true if there is Flashlight, otherwise false.
+     */
+    private boolean hasFlash() {
+        return getActivity().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(getActivity(),"Text: '"+result.getText()+"'", Toast.LENGTH_LONG).show();
+
+        if(result.getText().compareTo(mQr.getQRValue())==0)
+        {
+            barcodeScannerView.pause();
+            Activity act = getActivity();
+            if(act instanceof ChallengeDriver)
+            {
+                ChallengeDriver a = (ChallengeDriver) act;
+                a.challengeValidate(mChallenge);
+            }
+
+        }else
+        {
+            Toast.makeText(getActivity(), mQr.getBadQRMessage(), Toast.LENGTH_LONG).show();
+            barcodeScannerView.decodeContinuous(this);
+        }
+
+    }
+
+    @Override
+    public void possibleResultPoints(List<ResultPoint> resultPoints) {
+
+    }
+
+    @Override
+    public boolean check() {
+        return false;
+    }
+
+
+}

+ 26 - 41
app/src/main/java/app/mar/activities/QuestionFragment.java

@@ -25,31 +25,18 @@ import app.mar.utils.game.challenges.Question;
  * Use the {@link QuestionFragment#newInstance} factory method to
  * create an instance of this fragment.
  */
-public class QuestionFragment extends Fragment  {
-    // TODO: Rename parameter arguments, choose names that match
-    // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
-    private static final String ARG_PARAM1 = "param1";
-    private static final String ARG_PARAM2 = "param2";
+public class QuestionFragment extends ChallengeFragment  {
     protected ImageView mUIImage;
     protected EditText  mUIResponse;
     protected TextView  mUIQuestion;
     protected Button    mUiValid;
     protected Question  mQuestion=null;
-    protected Game      mGame;
 
 
     public QuestionFragment() {
         // Required empty public constructor
     }
 
-    /**
-     * Use this factory method to create a new instance of
-     * this fragment using the provided parameters.
-     *
-
-     * @return A new instance of fragment QuestionFragment.
-     */
-    // TODO: Rename and change types and number of parameters
     public static QuestionFragment newInstance() {
         QuestionFragment fragment = new QuestionFragment();
         Bundle args = new Bundle();
@@ -57,55 +44,53 @@ public class QuestionFragment extends Fragment  {
         return fragment;
     }
 
-    @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
 
-    }
 
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container,
                              Bundle savedInstanceState) {
-        // Inflate the layout for this fragment
-        View v = inflater.inflate(R.layout.fragment_question, container, false);
+        View v = super.onCreateView(inflater, container, R.layout.fragment_question);
         mUIImage = (ImageView) v.findViewById(R.id.iv_img);
         mUIQuestion = (TextView) v.findViewById(R.id.tv_question);
         mUIResponse = (EditText) v.findViewById(R.id.et_response);
         mUiValid = (Button) v.findViewById(R.id.btn_ok);
 
+        return v;
+    }
 
 
-        mGame = Game.game();
-        Challenge c = mGame.getCurrentChallenge();
+    @Override
+    public boolean check() {
+        String resp = mUIResponse.getText().toString();
+        if(mQuestion.checkAnswer(resp))
+        {
+            Toast.makeText(getActivity(), mQuestion.getGoodMessage(), Toast.LENGTH_LONG).show();
+            mUIResponse.getText().clear();
+            return true;
+        }else
+        {
+            Toast.makeText(getActivity(), mQuestion.getBadMessage(), Toast.LENGTH_LONG).show();
+            mUIResponse.getText().clear();
+            return false;
+        }
+    }
+
+
+    @Override
+    protected void onInitChallenge(Challenge c) {
         if(c instanceof Question)
         {
             mQuestion=(Question)c;
-
             mUIQuestion.setText(mQuestion.getQuestion());
         }
         else
         {
-            Toast.makeText(v.getContext(), "Error l'entrée n'est pas une question ! ", Toast.LENGTH_LONG).show();
+            Toast.makeText(getActivity(), "Error l'entrée n'est pas une question ! ", Toast.LENGTH_LONG).show();
         }
-        return v;
-    }
-
-    // TODO: Rename method, update argument and hook method into UI event
-    public void onButtonPressed(Uri uri) {
-
-    }
-
-    @Override
-    public void onAttach(Context context) {
-        super.onAttach(context);
-
     }
 
     @Override
-    public void onDetach() {
-        super.onDetach();
+    protected void onResetUi() {
+        mUIResponse.setHint("Entrer votre réponse");
     }
-
-
-
 }

+ 0 - 90
app/src/main/java/app/mar/activities/SEMenuActivity.java

@@ -1,90 +0,0 @@
-package app.mar.activities;
-
-import android.content.res.Resources;
-import android.util.TypedValue;
-import android.view.Gravity;
-import android.view.View;
-import android.widget.TextView;
-
-/**
- * Created by ptitcois on 26/06/17.
- */
-public class SEMenuActivity extends MenuActivity {
-
-    protected TextView mTVmenu;
-
-    protected  void refreshMenuStyle()
-    {
-        int size =  15;
-        int offset=mWidth/8;
-        mRootLayout.setBackgroundResource(R.drawable.background);
-        int h4 = mHeight/3-mHeight/26;
-        int w = (int)(mHeight/ 4);
-        int h = dpToPx((int)(mBBriefing.getTextSize()*1.5));
-        int H = (int)(h*1.24);
-
-        moveView(mBBriefing, mWidth/8, offset+h4,          w*2,h);
-        moveView(mBInvotory, mWidth/8, offset+h4+H,        w*2,h);
-        moveView(mBMap, mWidth/8, offset+h4+2*H,           w*2,h);
-        moveView(mBOptions, mWidth/8, offset+h4+3*H,       w*2,h);
-        moveView(mIbScanner, mWidth/8, offset+h4+4*H,      w*2, h);
-        moveView(mBSend, mWidth/8, offset+h4+5*H,          w*2, h);
-        ((TextView)mBMenu).setTextSize(25);
-        moveView(mBMenu, mWidth/10, 0, mWidth, mHeight/3);
-        moveView(mTVmenu, mWidth/7, h4);
-
-        mBBriefing.setTextSize(size);
-        mBInvotory.setTextSize(size);
-        mBMap.setTextSize(size);
-        mBOptions.setTextSize(size);
-        mIbScanner.setTextSize(size);
-        mBSend.setTextSize(size);
-        ((TextView)mBMenu).setTextSize(30);
-        ((TextView)mBMenu).setGravity(Gravity.CENTER);
-        //mBMenu.setTypeface(null,Typeface.BOLD);
-        //sendVisibility();
-        mBSend.setVisibility(View.INVISIBLE);
-
-    }
-
-    protected void setUpMenuStyle()
-    {
-        /*mIbScanner = new Button(this);
-        //mIbScanner.setImageResource(R.drawable.scanner);
-        //mIbScanner.setScaleType(ImageView.ScaleType.FIT_CENTER);
-        mRootLayout.addView(mIbScanner);
-        mIbScanner.setBackgroundResource(R.drawable.uibuttoncircle);
-        mIbScanner.setText("Scanner");
-        mIbScanner.setTextColor(getResources().getColor(R.color.dull_4));
-        mIbScanner.setTextSize(22);
-        mIbScanner.setOnClickListener(this);*/
-
-        //moveView(mIbScanner, mWidth / 2 - mHeight / 8, mHOffset + mHeight / 2 - mHeight / 8, mHeight / 4, mHeight / 4);
-        mTVmenu = new TextView(this);
-        mTVmenu.setText("Menu");
-        moveView(mTVmenu, mWidth/7, mHeight/7);
-        mRootLayout.addView(mTVmenu);
-        mTVmenu.setTextSize(20);
-
-        mBMenu = new TextView(this);
-        ((TextView)mBMenu).setText("Une terreur dans la ville");
-        mRootLayout.addView(((TextView)mBMenu));
-        moveView(mBMenu, mWidth/10, 0, mWidth, 600);
-        ((TextView)mBMenu).setTextSize(30);
-
-        mIbScanner = newButton("Rechercher");
-        mBBriefing = newButton("Résumé");
-        mBInvotory = newButton("Inventaire");
-        mBMap = newButton("Carte");
-        mBOptions = newButton("Options");
-        //mBMenu = newButton("Menu Principal");
-        mBSend = newButton("Envoyer les données");
-        Resources r = getResources();
-        float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 70, r.getDisplayMetrics());
-        //moveView(mBMenu, 0, 0, mWidth, (int) px);
-
-        if(!mGame.hasResource("start"))
-            mGame.pickResource("start");
-
-    }
-}

+ 0 - 102
app/src/main/java/app/mar/ui/ResourceArrayAdapter.java

@@ -65,105 +65,3 @@ public class ResourceArrayAdapter extends ArrayAdapter<Object> implements  Adapt
     }
 }
 
-
-/*package app.mar.ui;
-
-import android.content.Context;
-import android.content.Intent;
-import android.graphics.Color;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.TextView;
-
-import java.util.List;
-
-import app.mar.activities.R;
-import app.mar.utils.AndroidResources;
-import app.mar.utils.FontChangeCrawler;
-import app.mar.utils.game.Resource;
-
-//
- // Created by ptitcois on 22/08/16.
- //
-public class ResourceArrayAdapter extends ArrayAdapter<Object> implements  AdapterView.OnItemClickListener{
-    protected Context mContext;
-    protected List<Object> mList;
-    public ResourceArrayAdapter(Context context, int resource, List<Object> objects) {
-        super(context, R.layout.array_layout, objects);
-        mContext=context;
-        mList=objects;
-
-    }
-
-    @Override
-    public View getView(int position, View convertView,
-                        ViewGroup parent) {
-
-
-        if(convertView == null){
-            //Nous récupérons notre row_tweet via un LayoutInflater,
-            //qui va charger un layout xml dans un objet View
-            convertView = LayoutInflater.from(getContext()).inflate(R.layout.array_layout, parent, false);
-        }
-
-        TextView textView=(TextView) convertView.findViewById(R.id.textObject);
-
-        textView.setTextColor(Color.rgb(0, 0, 0));
-
-        if(mList.get(position) instanceof String){
-            textView.setTextSize(30);
-            String title  = (String) mList.get(position);
-            textView.setText(title);
-            //textView.setTypeface(null, Typeface.BOLD);
-        }else{
-            textView.setTextSize(22);
-            final Resource re  = (Resource) mList.get(position);
-            //textView.setTypeface(null, Typeface.NORMAL);
-            textView.setText(re.getTitle());
-            convertView.setOnClickListener(new View.OnClickListener(){
-
-                @Override
-                public void onClick(View view) {
-                    Intent intent = AndroidResources.getViewerIntent(mContext, re);
-                    mContext.startActivity(intent);
-                }
-            });
-
-        }
-        FontChangeCrawler.setFont(textView, mContext);
-
-
-        //nous renvoyons notre vue à l'adapter, afin qu'il l'affiche
-        //et qu'il puisse la mettre à recycler lorsqu'elle sera sortie de l'écran
-        return convertView;
-
-
-    }
-
-    @Override
-    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
-        Log.e("__________", "OK");
-        if (adapterView.getItemAtPosition(i) instanceof Resource) {
-            Resource item = (Resource) adapterView.getItemAtPosition(i);
-            Log.e("__________", "ItemClick: "+i+" "+l+ " Ressource");
-
-            Intent intent =AndroidResources.getViewerIntent(mContext, item);
-            mContext.startActivity(intent);
-
-        }else if(adapterView.getItemAtPosition(i) instanceof String)
-        {
-            Log.e("__________", "ItemClick: "+i+" "+l+ " String");
-
-        }
-        else
-        {
-
-            Log.e("__________", "ItemClick: "+i+" "+l+ " Autre");
-        }
-    }
-}
-*/

+ 0 - 8
app/src/main/java/app/mar/utils/AndroidResources.java

@@ -7,7 +7,6 @@ import android.graphics.drawable.Drawable;
 import android.net.Uri;
 
 import app.mar.activities.ImageViewerActivity;
-import app.mar.activities.InfoActivity;
 import app.mar.activities.MediaViewerAcitvity;
 import app.mar.activities.ModelViewerActivity;
 import app.mar.utils.game.Game;
@@ -66,13 +65,6 @@ public class AndroidResources {
         return intent;
     }
 
-    public static Intent getInfoIntent(Context c, Resource re)
-    {
-        Intent intent = new Intent(c, InfoActivity.class);
-        intent.putExtra("resource", re);
-
-        return intent;
-    }
 
 
     public static Intent getMapIntent(Context c, Game g)

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

@@ -20,7 +20,6 @@ public class Bomb {
         for(int i=0; i<mPassword.length(); i++)
             mPasswordKnown[i]='_';
         mDeadLine = Calendar.getInstance().getTimeInMillis()+min*60*1000;
-        Log.e("_____", "Deadline: "+mDeadLine);
     }
 
     public void addKnownCharacter(int pos, char c)
@@ -68,7 +67,6 @@ public class Bomb {
 
         if(s<10) ret+="0";
         ret+=s;
-        Log.e("_____", "Deadline: "+mDeadLine+" now:"+Calendar.getInstance().getTimeInMillis()+" time"+now);
 
         return ret;
     }

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

@@ -128,7 +128,6 @@ public class Resource implements Serializable {
             m3DModel = myParser.getParsedObject();
             m3DModel.position().x = mPosition.x; m3DModel.position().y = mPosition.y; m3DModel.position().z = mPosition.z;
             m3DModel.rotation().x = mRotation.x; m3DModel.rotation().y = mRotation.y; m3DModel.rotation().z = mRotation.z;
-            Log.e("____","Rotation ("+m3DModel.rotation().x+","+m3DModel.rotation().y+","+m3DModel.rotation().z+")");
             m3DModel.rotation().x+=45;
             //m3DModel.rotation().y+=-180;
 

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

@@ -40,6 +40,7 @@ public class Stage  implements Serializable {
 
         } catch (JSONException e) {
             e.printStackTrace();
+            throw new RuntimeException(e.getMessage());
         }
     }
 

+ 62 - 7
app/src/main/java/app/mar/utils/game/challenges/Challenge.java

@@ -4,14 +4,17 @@ import android.app.Activity;
 import android.content.Intent;
 import android.util.Log;
 
+import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
 
 import java.io.Serializable;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
 
 import app.mar.activities.ARActivity;
+import app.mar.activities.ChallengeDriver;
 import app.mar.activities.QuestionActivity;
 import app.mar.utils.game.Game;
 
@@ -22,28 +25,52 @@ public abstract class Challenge implements Serializable{
 
     protected String mType=CHALLENGE_NULL;
     protected String mName="null";
+
+    protected char mCharPassword;
+    protected int  mCharPasswordIndex;
     protected boolean mDone=false;
     protected Class  mStartWith = null;
+    protected ArrayList<Indice> mIndices = new ArrayList<Indice>();
 
     public Challenge(JSONObject root, Class start)
     {
         mStartWith=start;
+        mDone = false;
         try {
             mType = root.getString("type");
+        } catch (JSONException e) {
+            e.printStackTrace();
+        }
+
+        try {
             mName = root.getString("name");
-            mDone = false;
+        } catch (JSONException e) {
+            e.printStackTrace();
+        }
+
+        try {
+            String s = root.getString("password_char");
+            if(s.length()==0) throw new JSONException("password_char is an empty string");
+            mCharPassword = s.charAt(0);
+            mCharPasswordIndex = root.getInt("password_index");
+        } catch (JSONException e) {
+            mCharPassword=0;
+            mCharPasswordIndex=-1;
+        }
+
+        try {
+            JSONArray arr = root.getJSONArray("indices");
+            for(int i=0; i<arr.length(); i++)
+                mIndices.add(Indice.fromJSONObject(arr.getJSONObject(i)));
         } catch (JSONException e) {
             e.printStackTrace();
         }
     }
 
-    public void exec(Game game, Activity act)
+    public void exec(ChallengeDriver 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());
+        Log.e("_____________", "Classe: "+mStartWith);
+        act.setFragment(mStartWith);
     }
 
     public String getType() {
@@ -105,4 +132,32 @@ public abstract class Challenge implements Serializable{
         return null;
     }
 
+    public char getCharPassword() {
+        return mCharPassword;
+    }
+
+    public int getCharPasswordIndex() {
+        return mCharPasswordIndex;
+    }
+
+    public boolean hasNextIndice()
+    {
+        int i=0;
+        for(i=0; i<mIndices.size(); i++)
+            if(!mIndices.get(i).isDiscovered())
+                return true;
+        return false;
+    }
+
+    public Indice nextIndice()
+    {
+        int i=0;
+        for(i=0; i<mIndices.size(); i++)
+            if(!mIndices.get(i).isDiscovered())
+                return mIndices.get(i);
+        return null;
+    }
+
+    public ArrayList<Indice> getIndices() { return mIndices; }
+
 }

+ 11 - 0
app/src/main/java/app/mar/utils/game/challenges/GeoIndice.java

@@ -0,0 +1,11 @@
+package app.mar.utils.game.challenges;
+
+import org.json.JSONObject;
+
+public class GeoIndice extends Indice {
+
+    public GeoIndice(JSONObject root) {
+        super(root);
+    }
+
+}

+ 38 - 0
app/src/main/java/app/mar/utils/game/challenges/Indice.java

@@ -0,0 +1,38 @@
+package app.mar.utils.game.challenges;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+public abstract class Indice {
+    protected  int mPenality=-1;
+    protected  boolean mIsDiscovered=false;
+
+    public Indice(JSONObject root)
+    {
+        try {
+            mPenality = root.getInt("penality");
+        } catch (JSONException e) {
+        }
+    }
+
+
+
+    public static Indice fromJSONObject(JSONObject root)
+    {
+        String type=null;
+        try {
+            type = root.getString("type");
+        } catch (JSONException e) {
+        }
+        if(type.compareToIgnoreCase("text")==0) return new TextIndice(root);
+        else if(type.compareToIgnoreCase("geo")==0) return new GeoIndice(root);
+        else return null;
+    }
+
+    public boolean isDiscovered() { return mIsDiscovered; }
+    public void     discover() { mIsDiscovered=true; }
+
+    public int getPenality() {
+        return mPenality;
+    }
+}

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

@@ -9,6 +9,7 @@ import org.json.JSONObject;
 import java.util.ArrayList;
 
 import app.mar.activities.QCMActivity;
+import app.mar.activities.QCMFragment;
 import app.mar.utils.game.Game;
 
 public class QCM extends Question{
@@ -23,7 +24,7 @@ public class QCM extends Question{
 
     public QCM(Game g, JSONObject root, Activity a) {
         super(g, root, a);
-        mStartWith= QCMActivity.class;
+        mStartWith= QCMFragment.class;
         try {
             JSONArray arr = root.getJSONArray("choices");
             for(int i=0; i<arr.length(); i++)

+ 2 - 1
app/src/main/java/app/mar/utils/game/challenges/QRCodeTreasure.java

@@ -7,6 +7,7 @@ import org.json.JSONObject;
 
 import app.mar.activities.ARActivity;
 import app.mar.activities.QRCodeActivity;
+import app.mar.activities.QRCodeFragment;
 import app.mar.utils.game.Game;
 import app.mar.utils.game.Resource;
 
@@ -20,7 +21,7 @@ public class QRCodeTreasure extends Treasure {
     public int getResultCode() { return REQUEST_CODE; }
 
     public QRCodeTreasure(Game g, JSONObject root, Activity a) {
-        super(root, QRCodeActivity.class);
+        super(root, QRCodeFragment.class);
 
         try {
             mQRValue = root.getString("qr_value");

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

@@ -8,6 +8,7 @@ import org.json.JSONObject;
 
 import app.mar.activities.ARActivity;
 import app.mar.activities.QuestionActivity;
+import app.mar.activities.QuestionFragment;
 import app.mar.utils.game.Game;
 
 public class Question extends Challenge {
@@ -23,7 +24,7 @@ public class Question extends Challenge {
 
 
     public Question(Game g,JSONObject root, Activity a) {
-        super(root, QuestionActivity.class);
+        super(root, QuestionFragment.class);
 
         try {
             mQuestion = root.getString("question");

+ 21 - 0
app/src/main/java/app/mar/utils/game/challenges/TextIndice.java

@@ -0,0 +1,21 @@
+package app.mar.utils.game.challenges;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+public class TextIndice extends Indice {
+    protected String mText="";
+
+    public TextIndice(JSONObject root) {
+        super(root);
+
+        try {
+            mText = root.getString("text");
+        } catch (JSONException e) {
+        }
+    }
+
+    public String getText() {
+        return mText;
+    }
+}

+ 0 - 52
app/src/main/res/layout/activity_end.xml

@@ -1,52 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:paddingBottom="@dimen/activity_vertical_margin"
-    android:paddingLeft="@dimen/activity_horizontal_margin"
-    android:paddingRight="@dimen/activity_horizontal_margin"
-    android:paddingTop="@dimen/activity_vertical_margin"
-    tools:context="app.mar.activities.EndActivity"
-    android:background="@drawable/background">
-
-    <TextView
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:textAppearance="?android:attr/textAppearanceLarge"
-        android:text="Félicitation !"
-        android:id="@+id/textView2"
-        android:layout_centerVertical="true"
-        android:layout_centerHorizontal="true"
-        android:textColor="#33b5e5"
-        android:textSize="60dp"
-        android:textStyle="bold" />
-
-    <Button
-        android:layout_width="match_parent"
-        android:layout_height="70dp"
-        android:text="FIN !"
-        android:id="@+id/button8"
-        android:background="@drawable/title"
-        android:textColor="@color/dull_4"
-        android:textSize="30dp"
-        android:textStyle="bold"
-        android:layout_alignParentBottom="true"
-        android:layout_alignRight="@+id/textView2" />
-
-    <ProgressBar
-        style="?android:attr/progressBarStyleSmall"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:id="@+id/progressBar"
-        android:layout_alignParentTop="true"
-        android:layout_alignLeft="@+id/textView2" />
-
-    <CheckBox
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:text="New CheckBox"
-        android:id="@+id/checkBox"
-        android:layout_alignParentTop="true"
-        android:layout_toRightOf="@+id/progressBar" />
-</RelativeLayout>

+ 3 - 3
app/src/main/res/layout/activity_host.xml

@@ -141,7 +141,7 @@
             android:orientation="horizontal">
 
             <Button
-                android:id="@+id/button10"
+                android:id="@+id/btn_indice"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_weight="1"
@@ -151,7 +151,7 @@
                 android:textSize="12sp" />
 
             <Button
-                android:id="@+id/button9"
+                android:id="@+id/btn_videos"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_weight="1"
@@ -161,7 +161,7 @@
                 android:textSize="12sp" />
 
             <Button
-                android:id="@+id/button4"
+                android:id="@+id/btn_valid"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_weight="1"

+ 0 - 50
app/src/main/res/layout/activity_info.xml

@@ -1,50 +0,0 @@
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    tools:context=".ImageViewerActivity"
-    android:background="@drawable/background"
-    android:id="@+id/rl_screen">
-
-    <!-- The primary full-screen view. This can be replaced with whatever view
-         is needed to present your content, e.g. VideoView, SurfaceView,
-         TextureView, etc. -->
-
-    <!-- This FrameLayout insets its children based on system windows using
-         android:fitsSystemWindows. -->
-
-    <FrameLayout
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:id="@+id/frame_viewer"
-        android:layout_below="@+id/title">
-
-        <TextView
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:textAppearance="?android:attr/textAppearanceMedium"
-            android:text="Medium Text"
-            android:id="@+id/tv_comment"
-            android:layout_gravity="center"
-            android:textColor="#33b5e5"
-            android:textSize="20dp"
-            android:visibility="visible" />
-    </FrameLayout>
-
-    <TextView
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:textAppearance="?android:attr/textAppearanceLarge"
-        android:text="Large Text"
-        android:id="@+id/title"
-        android:layout_alignParentTop="true"
-        android:layout_alignParentRight="true"
-        android:layout_alignParentEnd="true"
-        android:layout_alignParentLeft="true"
-        android:layout_alignParentStart="true"
-        android:textColor="@color/dull_2"
-        android:textStyle="bold"
-        android:textSize="25dp"
-        android:textAlignment="center" />
-
-</RelativeLayout>

+ 0 - 33
app/src/main/res/layout/activity_main.xml

@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
-    xmlns:tools="http://schemas.android.com/tools"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    tools:context=".MainActivity">
-
-    <android.support.design.widget.AppBarLayout
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:theme="@style/AppTheme.AppBarOverlay">
-
-        <android.support.v7.widget.Toolbar
-            android:id="@+id/toolbar"
-            android:layout_width="match_parent"
-            android:layout_height="?attr/actionBarSize"
-            android:background="?attr/colorPrimary"
-            app:popupTheme="@style/AppTheme.PopupOverlay" />
-
-    </android.support.design.widget.AppBarLayout>
-
-    <include layout="@layout/content_main" />
-
-    <android.support.design.widget.FloatingActionButton
-        android:id="@+id/fab"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_gravity="bottom|end"
-        android:layout_margin="@dimen/fab_margin"
-        app:srcCompat="@android:drawable/ic_dialog_email" />
-
-</android.support.design.widget.CoordinatorLayout>

+ 6 - 7
app/src/main/res/layout/activity_new_menu.xml

@@ -1,24 +1,23 @@
 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/menu_root"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:paddingBottom="0dp"
     android:paddingLeft="0dp"
     android:paddingRight="0dp"
     android:paddingTop="0dp"
-    tools:context=".MenuActivity"
-    android:id="@+id/menu_root"
-    android:background="@drawable/background">
+    tools:context=".MenuActivity">
 
     <Button
+        android:id="@+id/button3"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:text="Credits"
-        android:id="@+id/button3"
         android:layout_alignParentBottom="true"
-        android:layout_alignParentRight="true"
         android:layout_alignParentEnd="true"
+        android:layout_alignParentRight="true"
+        android:background="#00000000"
         android:onClick="onCredits"
-        android:background="#00000000" />
+        android:text="Credits" />
 </RelativeLayout>

+ 0 - 56
app/src/main/res/layout/activity_splash.xml

@@ -1,56 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    tools:context=".SplashActivity"
-    android:baselineAligned="false"
-    android:weightSum="1"
-    android:background="@drawable/background">
-
-    <Button
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:text="Start new"
-        android:id="@+id/button2"
-        android:onClick="onClickNew"
-        android:background="#000000"
-        android:textColor="#33b5e5"
-        android:textStyle="bold"
-        style="@style/Base.ThemeOverlay.AppCompat.Light"
-        android:layout_marginTop="76dp"
-        android:textSize="30dp"
-        android:layout_alignParentTop="true"
-        android:layout_centerHorizontal="true" />
-
-    <Button
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:text="Continue"
-        android:id="@+id/button_continue"
-        android:onClick="onClickContinue"
-        android:longClickable="false"
-        android:background="#000000"
-        android:textColor="#33b5e5"
-        android:textStyle="bold"
-        android:textSize="30dp"
-        android:layout_alignParentBottom="true"
-        android:layout_alignLeft="@+id/button2"
-        android:layout_alignStart="@+id/button2"
-        android:layout_marginBottom="165dp" />
-
-    <Button
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:text="ListItems"
-        android:id="@+id/button"
-        android:textColor="#33b5e5"
-        android:textSize="30dp"
-        android:background="#000000"
-        android:textStyle="bold"
-        android:layout_below="@+id/button2"
-        android:layout_alignLeft="@+id/button2"
-        android:layout_alignStart="@+id/button2"
-        android:layout_marginTop="63dp"
-        android:onClick="onClickList" />
-</RelativeLayout>

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

@@ -1,63 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:paddingBottom="@dimen/activity_vertical_margin"
-    android:paddingLeft="@dimen/activity_horizontal_margin"
-    android:paddingRight="@dimen/activity_horizontal_margin"
-    android:paddingTop="@dimen/activity_vertical_margin"
-    android:background="@drawable/background">
-
-    <ProgressBar
-        style="?android:attr/progressBarStyleHorizontal"
-        android:layout_width="match_parent"
-        android:layout_height="60dp"
-        android:id="@+id/pb_bar"
-        android:max="100"
-        android:progress="20"
-        android:layout_alignParentBottom="true"
-        android:layout_alignParentLeft="true"
-        android:layout_alignParentStart="true"
-        android:layout_marginBottom="196dp" />
-
-    <ImageButton
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:id="@+id/ib_logo"
-        android:src="@drawable/send"
-        android:scaleType="fitCenter"
-        android:clickable="false"
-        android:background="@null"
-        android:layout_alignParentBottom="true"
-        android:layout_centerHorizontal="true" />
-
-    <TextView
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:textAppearance="?android:attr/textAppearanceLarge"
-        android:text="Envoi des données au professeur"
-        android:id="@+id/textView"
-        android:layout_marginBottom="47dp"
-        android:textColor="#33b5e5"
-        android:textSize="25dp"
-        android:textStyle="bold"
-        android:singleLine="false"
-        android:gravity="center_horizontal"
-        android:layout_above="@+id/pb_bar"
-        android:layout_alignParentLeft="true"
-        android:layout_alignParentStart="true" />
-
-    <Button
-        android:layout_width="match_parent"
-        android:layout_height="70dp"
-        android:text="Envoi"
-        android:id="@+id/button6"
-        android:layout_alignParentTop="true"
-        android:layout_centerHorizontal="true"
-        android:background="@drawable/title"
-        android:textSize="30dp"
-        android:textColor="@color/dull_4"
-        android:textStyle="bold" />
-
-</RelativeLayout>

+ 0 - 20
app/src/main/res/layout/array_layout.xml

@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:orientation="horizontal" android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:weightSum="1">
-
-    <!--><ImageButton
-        android:layout_width="60dp"
-        android:layout_height="match_parent"
-        android:id="@+id/imageButton"
-        android:background="@drawable/fleche" /><-->
-
-    <TextView
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:textAppearance="?android:attr/textAppearanceMedium"
-        android:text="Medium Text"
-        android:id="@+id/textObject"
-        android:layout_gravity="center_vertical" />
-</LinearLayout>

+ 0 - 11
app/src/main/res/layout/content_main.xml

@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<android.support.constraint.ConstraintLayout 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"
-    app:layout_behavior="@string/appbar_scrolling_view_behavior"
-    tools:context=".MainActivity"
-    tools:showIn="@layout/activity_main">
-
-</android.support.constraint.ConstraintLayout>

+ 76 - 0
app/src/main/res/layout/fragment_qcm.xml

@@ -0,0 +1,76 @@
+<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.QCMFragment">
+
+    <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:id="@+id/ll_rootIndices"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                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" />
+
+                <LinearLayout
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:orientation="vertical">
+
+                    <TextView
+                        android:id="@+id/textView"
+                        android:layout_width="match_parent"
+                        android:layout_height="wrap_content"
+                        android:text="Indices:" />
+
+                    <LinearLayout
+                        android:id="@+id/ll_textIndices"
+                        android:layout_width="match_parent"
+                        android:layout_height="wrap_content"
+                        android:orientation="vertical"></LinearLayout>
+
+                </LinearLayout>
+
+                <RadioGroup
+                    android:id="@+id/rg_qcm"
+                    android:layout_width="match_parent"
+                    android:layout_height="match_parent">
+
+                </RadioGroup>
+
+            </LinearLayout>
+
+        </FrameLayout>
+
+
+    </LinearLayout>
+</LinearLayout>

+ 54 - 0
app/src/main/res/layout/fragment_qrcode.xml

@@ -0,0 +1,54 @@
+<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
+xmlns:app="http://schemas.android.com/apk/res-auto"
+xmlns:tools="http://schemas.android.com/tools"
+android:layout_width="match_parent"
+android:layout_height="match_parent"
+tools:context="app.mar.activities.QRCodeFragment">
+
+    <LinearLayout
+        android:id="@+id/ll_rootIndices"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:orientation="vertical">
+
+        <TextView
+            android:id="@+id/tv_geoIndice"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:gravity="center"
+            android:text="130 m"
+            android:textSize="14sp" />
+
+        <TextView
+            android:id="@+id/textView3"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:text="Indices" />
+
+        <LinearLayout
+            android:id="@+id/ll_textIndices"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:orientation="vertical"></LinearLayout>
+    </LinearLayout>
+
+    <com.journeyapps.barcodescanner.DecoratedBarcodeView
+    android:id="@+id/zxing_barcode_scanner"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    app:zxing_scanner_layout="@layout/custom_barcode_scanner">
+
+    </com.journeyapps.barcodescanner.DecoratedBarcodeView>
+
+    <Button
+        android:id="@+id/switch_flashlight"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentTop="true"
+        android:layout_centerHorizontal="true"
+        android:onClick="switchFlashlight"
+        android:text="On"
+        app:layout_anchor="@+id/zxing_barcode_scanner"
+        app:layout_anchorGravity="bottom|center" />
+
+</android.support.design.widget.CoordinatorLayout>

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

@@ -29,8 +29,9 @@ tools:context="app.mar.activities.QuestionFragment">
         android:layout_weight="1">
 
         <LinearLayout
+            android:id="@+id/ll_rootIndices"
             android:layout_width="match_parent"
-            android:layout_height="match_parent"
+            android:layout_height="wrap_content"
             android:orientation="vertical">
 
             <TextView
@@ -41,6 +42,25 @@ tools:context="app.mar.activities.QuestionFragment">
                 android:text="Qui a tué le cheval blanc d'Henri IV ?"
                 android:textSize="18sp" />
 
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:orientation="vertical">
+
+                <TextView
+                    android:id="@+id/textView"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:text="Indices:" />
+
+                <LinearLayout
+                    android:id="@+id/ll_textIndices"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:orientation="vertical"></LinearLayout>
+
+            </LinearLayout>
+
         </LinearLayout>
 
     </FrameLayout>
@@ -51,6 +71,7 @@ tools:context="app.mar.activities.QuestionFragment">
         android:layout_height="wrap_content"
         android:layout_weight="0"
         android:ems="10"
+        android:hint="Entrer votre réponse"
         android:inputType="textPersonName" />
 
 </LinearLayout>

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

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

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

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