gautrais 7 سال پیش
والد
کامیت
33c9d9d7b7

+ 146 - 0
app/app.iml

@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" type="JAVA_MODULE" version="4">
+  <component name="FacetManager">
+    <facet type="android-gradle" name="Android-Gradle">
+      <configuration>
+        <option name="GRADLE_PROJECT_PATH" value=":app" />
+      </configuration>
+    </facet>
+    <facet type="android" name="Android">
+      <configuration>
+        <option name="SELECTED_BUILD_VARIANT" value="debug" />
+        <option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
+        <option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
+        <afterSyncTasks>
+          <task>generateDebugSources</task>
+        </afterSyncTasks>
+        <option name="ALLOW_USER_CONFIGURATION" value="false" />
+        <option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
+        <option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
+        <option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
+        <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
+      </configuration>
+    </facet>
+  </component>
+  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7">
+    <output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
+    <output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/debug" isTestSource="false" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/debug" isTestSource="true" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/test/debug" isTestSource="true" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/shaders" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/testDebug/resources" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/testDebug/aidl" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/testDebug/java" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/testDebug/rs" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/testDebug/shaders" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/res" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/resources" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/assets" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/aidl" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/java" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/rs" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/shaders" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
+      <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/assets" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/build-info" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-manifest" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-classes" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-runtime-classes" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-verifier" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-apk" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-resources" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaPrecompile" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifest-checker" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/prebuild" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/resources" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/split-apk" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/splits-support" />
+      <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/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.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.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: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-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: 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" />
+    <orderEntry type="module" module-name="base" />
+  </component>
+</module>

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

@@ -81,6 +81,10 @@
         <activity
             android:name=".QRCodeActivity"
             android:label="@string/title_activity_qrcode"
+            android:theme="@style/AppTheme.NoActionBar" />
+        <activity
+            android:name=".HostActivity"
+            android:label="@string/title_activity_host"
             android:theme="@style/AppTheme.NoActionBar"></activity>
     </application>
 

+ 2 - 0
app/src/main/assets/game_medium

@@ -1,4 +1,6 @@
 {
+    "password" : "123456",
+    "max_time" : 30,
 	"stages" : [
 		
 		{

+ 101 - 0
app/src/main/java/app/mar/activities/HostActivity.java

@@ -0,0 +1,101 @@
+package app.mar.activities;
+
+import android.app.Activity;
+import android.app.FragmentManager;
+import android.app.FragmentTransaction;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.View;
+import android.widget.TextView;
+
+import java.util.Timer;
+import java.util.TimerTask;
+
+import app.mar.utils.game.Game;
+
+
+public class HostActivity extends Activity {
+    protected Game mGame;
+    protected TextView mUITimeLeft;
+    protected TextView mUICode;
+    private Timer mTimer;
+
+    private Runnable mTimerTick = new Runnable() {
+        public void run() {
+            if(!mGame.getBomb().hasExplosed())
+            {
+                mUITimeLeft.setText(mGame.getBomb().getTimeBeforeBoom());
+            }else
+            {
+                mUITimeLeft.setText("BOOM !");
+                onExplose();
+                mTimer.cancel();
+            }
+        }
+    };
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_host);
+
+        FragmentManager fm = getFragmentManager();
+        FragmentTransaction ft = fm.beginTransaction();
+        ft.replace(R.id.container, QuestionFragment.newInstance());
+        ft.commit();
+
+        mGame=Game.game();
+
+        mUITimeLeft = findViewById(R.id.tv_car);
+        mUICode = findViewById(R.id.tv_code);
+
+        mTimer = new Timer();
+        mTimer.schedule(new TimerTask() {
+            @Override
+            public void run() {
+                timerCallback();
+            }
+
+        }, 0, 1000);
+        updateCode();
+
+    }
+
+    private void timerCallback()
+    {
+        this.runOnUiThread(mTimerTick);
+    }
+
+    private void updateCode()
+    {
+        mUICode.setText(mGame.getBomb().getPasswordKnown());
+    }
+
+    public void onClickValid(View v)
+    {
+        mGame.getBomb().addTime(-1);
+        timerCallback();
+    }
+
+
+    public void onClickVideos(View v)
+    {
+
+    }
+
+    public void onClickDisarm(View v)
+    {
+
+    }
+
+    public void onClickIndice(View v)
+    {
+
+    }
+
+    public void onExplose()
+    {
+
+    }
+}

+ 22 - 19
app/src/main/java/app/mar/activities/MenuActivity.java

@@ -102,36 +102,39 @@ public abstract class  MenuActivity extends Activity implements View.OnClickList
 
         setContentView(R.layout.activity_new_menu);
         mRootLayout = (RelativeLayout) findViewById(R.id.menu_root);
-
-        Game g = null;// Game.load(this);
-        System.out.println( (g != null) + " == " + (mGame == null) );
-        if (g != null && mGame == null) {
-            mGame = g;
-            Game.setGame(mGame);
-            mGame.newSensorManager(this);
-            Toast.makeText(this, "Chargement", Toast.LENGTH_LONG).show();
-        } else if (mGame == null) {
-            mGame = new Game("game_medium", this);
-            Game.setGame(mGame);
-            Toast.makeText(this, "Nouveau Jeu", Toast.LENGTH_LONG).show();
-        } else if (mGame == null) {
-            Toast.makeText(this, "Erreur", Toast.LENGTH_LONG).show();
-            throw new Error("Le jeu n'est pas sauvegardé");
+        if(Game.game()==null)
+        {
+            Game g = null;// Game.load(this);
+            System.out.println( (g != null) + " == " + (mGame == null) );
+            if (g != null && mGame == null) {
+                mGame = g;
+                Game.setGame(mGame);
+                mGame.newSensorManager(this);
+                Toast.makeText(this, "Chargement", Toast.LENGTH_LONG).show();
+            } else if (mGame == null) {
+                mGame = new Game("game_medium", this);
+                Game.setGame(mGame);
+                Toast.makeText(this, "Nouveau Jeu", Toast.LENGTH_LONG).show();
+            } else if (mGame == null) {
+                Toast.makeText(this, "Erreur", Toast.LENGTH_LONG).show();
+                throw new Error("Le jeu n'est pas sauvegardé");
+            }
         }
 
 
 
 
+
         updateSize();
-        Settings.setSettings(mGame.getSettings());
+        //Settings.setSettings(mGame.getSettings());
 
 
         ////// A virer dela
 
-        startChallenge();
+        //startChallenge();
 
-        //Intent intent = new Intent(this, QRCodeActivity.class);
-        //startActivity(intent);
+        Intent intent = new Intent(this, HostActivity.class);
+        startActivity(intent);
 
         /// a dela
 

+ 135 - 0
app/src/main/java/app/mar/activities/QuestionFragment.java

@@ -0,0 +1,135 @@
+package app.mar.activities;
+
+import android.app.Activity;
+import android.content.Context;
+import android.net.Uri;
+import android.os.Bundle;
+import android.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import app.mar.utils.game.Game;
+import app.mar.utils.game.challenges.Challenge;
+import app.mar.utils.game.challenges.Question;
+
+/**
+ * A simple {@link Fragment} subclass.
+ * Activities that contain this fragment must implement the
+ * {@link QuestionFragment.OnFragmentInteractionListener} interface
+ * to handle interaction events.
+ * 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";
+    protected ImageView mUIImage;
+    protected EditText  mUIResponse;
+    protected TextView  mUIQuestion;
+    protected Button    mUiValid;
+    protected Question  mQuestion=null;
+    protected Game      mGame;
+
+    private OnFragmentInteractionListener mListener;
+
+    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();
+        fragment.setArguments(args);
+        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);
+        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);
+
+
+
+        mGame = Game.game();
+        Challenge c = mGame.getCurrentChallenge();
+        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();
+        }
+        return v;
+    }
+
+    // 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");
+        }
+    }
+
+    @Override
+    public void onDetach() {
+        super.onDetach();
+        mListener = null;
+    }
+
+
+
+    /**
+     * 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);
+    }
+}

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

@@ -0,0 +1,80 @@
+package app.mar.utils.game;
+
+import android.util.Log;
+
+import com.google.zxing.common.StringUtils;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+
+public class Bomb {
+    protected long      mDeadLine;
+    protected String   mPassword;
+    protected char    mPasswordKnown[];
+
+    public Bomb(String pwd, int min)
+    {
+        mPassword=pwd;
+        mPasswordKnown=new char[mPassword.length()];
+        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)
+    {
+        mPasswordKnown[pos]=c;
+    }
+
+    public String getPasswordKnown()
+    {
+        String s = "";
+        for(int i=0; i<mPassword.length(); i++)
+        {
+            if(i>=0) s+=" ";
+            s+=mPasswordKnown[i];
+        }
+        return s;
+    }
+
+    public void addTime(int minutes)
+    {
+        mDeadLine+=minutes*60*1000;
+    }
+
+    public String getTimeBeforeBoom()
+    {
+        long now = (mDeadLine - Calendar.getInstance().getTimeInMillis())/1000;
+        int h=0,m=0,s=0;
+        String ret = "";
+
+        s=(int)now%60;
+        m=(int) (now%3600)/60;
+        h=(int) now/3600;
+
+        if(h>0)
+        {
+            if(h<10) ret+="0";
+            ret+=h;
+            ret+=" : ";
+        }
+
+        if(m<10) ret+="0";
+        ret+=m;
+
+        ret+=" : ";
+
+        if(s<10) ret+="0";
+        ret+=s;
+        Log.e("_____", "Deadline: "+mDeadLine+" now:"+Calendar.getInstance().getTimeInMillis()+" time"+now);
+
+        return ret;
+    }
+
+    public boolean hasExplosed()
+    {
+        return mDeadLine < Calendar.getInstance().getTimeInMillis();
+    }
+}

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

@@ -46,6 +46,8 @@ public class Game  implements Serializable {
     protected ResourceManager mResources = new ResourceManager();
     protected ChallengeReturn mLastReturn = null;
 
+    protected Bomb            mBomb;
+
 
     public Game(String name, Activity act)
     {
@@ -66,6 +68,12 @@ public class Game  implements Serializable {
             e.printStackTrace();
         }
 
+        try {
+            mBomb=new Bomb(root.getString("password"), root.getInt("max_time"));
+        } catch (JSONException e) {
+            e.printStackTrace();
+        }
+
         mCurrentStageIndex=0;
         if(mStages.size()>0)
             mCurrentStage=mStages.get(0);
@@ -304,4 +312,8 @@ public class Game  implements Serializable {
             return mCurrentStage=mStages.get(mCurrentStageIndex);
         return mCurrentStage=null;
     }
+
+    public Bomb getBomb() {
+        return mBomb;
+    }
 }

+ 175 - 0
app/src/main/res/layout/activity_host.xml

@@ -0,0 +1,175 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context="app.mar.activities.HostActivity">
+
+
+    <LinearLayout
+        android:id="@+id/linearLayout"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:orientation="vertical"
+        android:padding="10sp"
+        app:layout_anchor="@+id/linearLayout"
+        app:layout_anchorGravity="left|top">
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="60sp"
+            android:onClick="onClickDisarm"
+            android:orientation="horizontal"
+            android:showDividers="beginning|middle|end">
+
+            <android.support.constraint.ConstraintLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_weight="1">
+
+
+                <TextView
+                    android:id="@+id/textView9"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginEnd="8dp"
+                    android:layout_marginLeft="8dp"
+                    android:layout_marginRight="8dp"
+                    android:layout_marginStart="8dp"
+                    android:layout_marginTop="2dp"
+                    android:text="Code de la bombe"
+                    android:textSize="14sp"
+                    app:layout_constraintEnd_toEndOf="parent"
+                    app:layout_constraintStart_toEndOf="@+id/divider4"
+                    app:layout_constraintTop_toTopOf="parent" />
+
+                <TextView
+                    android:id="@+id/textView6"
+                    android:layout_width="wrap_content"
+                    android:layout_height="0dp"
+                    android:layout_marginEnd="8dp"
+                    android:layout_marginLeft="8dp"
+                    android:layout_marginRight="8dp"
+                    android:layout_marginStart="8dp"
+                    android:layout_marginTop="2dp"
+                    android:text="Temps restant:"
+                    android:textSize="14sp"
+                    app:layout_constraintEnd_toStartOf="@+id/divider4"
+                    app:layout_constraintHorizontal_bias="0.512"
+                    app:layout_constraintStart_toStartOf="parent"
+                    app:layout_constraintTop_toTopOf="parent" />
+
+                <View
+                    android:id="@+id/divider4"
+                    android:layout_width="10sp"
+                    android:layout_height="match_parent"
+                    android:layout_marginLeft="8dp"
+                    android:layout_marginStart="8dp"
+                    android:background="?android:attr/listDivider"
+                    app:layout_constraintStart_toEndOf="@+id/tv_car" />
+
+                <TextView
+                    android:id="@+id/tv_code"
+                    android:layout_width="wrap_content"
+                    android:layout_height="0dp"
+                    android:layout_marginBottom="2dp"
+                    android:layout_marginEnd="8dp"
+                    android:layout_marginLeft="8dp"
+                    android:layout_marginRight="8dp"
+                    android:layout_marginStart="8dp"
+                    android:layout_marginTop="2dp"
+                    android:layout_weight="1"
+                    android:gravity="center"
+                    android:text=" _ _  _ 2"
+                    android:textSize="18sp"
+                    app:layout_constraintBottom_toBottomOf="parent"
+                    app:layout_constraintEnd_toEndOf="parent"
+                    app:layout_constraintStart_toEndOf="@+id/divider4"
+                    app:layout_constraintTop_toBottomOf="@+id/textView9" />
+
+                <TextView
+                    android:id="@+id/tv_car"
+                    android:layout_width="wrap_content"
+                    android:layout_height="0dp"
+                    android:layout_marginBottom="2dp"
+                    android:layout_marginLeft="8dp"
+                    android:layout_marginStart="8dp"
+                    android:layout_marginTop="2dp"
+                    android:layout_weight="1"
+                    android:gravity="center"
+                    android:text="21 : 02"
+                    android:textSize="30sp"
+                    android:textStyle="bold"
+                    app:layout_constraintBottom_toBottomOf="parent"
+                    app:layout_constraintStart_toStartOf="parent"
+                    app:layout_constraintTop_toBottomOf="@+id/textView6" />
+
+            </android.support.constraint.ConstraintLayout>
+
+        </LinearLayout>
+
+        <View
+            android:id="@+id/divider2"
+            android:layout_width="match_parent"
+            android:layout_height="1dp"
+            android:layout_weight="0"
+            android:background="?android:attr/listDivider" />
+
+
+        <FrameLayout
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_weight="1"
+            android:padding="10sp">
+
+            <FrameLayout
+                android:id="@+id/container"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"></FrameLayout>
+        </FrameLayout>
+
+        <View
+            android:id="@+id/divider3"
+            android:layout_width="match_parent"
+            android:layout_height="1dp"
+            android:background="?android:attr/listDivider" />
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="horizontal">
+
+            <Button
+                android:id="@+id/button10"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:gravity="center"
+                android:onClick="onClickIndice"
+                android:text="Indice"
+                android:textSize="12sp" />
+
+            <Button
+                android:id="@+id/button9"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:gravity="center"
+                android:onClick="onClickVideos"
+                android:text="Vidéos"
+                android:textSize="12sp" />
+
+            <Button
+                android:id="@+id/button4"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:gravity="center"
+                android:onClick="onClickValid"
+                android:text="Valider"
+                android:textSize="12sp" />
+        </LinearLayout>
+
+    </LinearLayout>
+</android.support.design.widget.CoordinatorLayout>

+ 17 - 18
app/src/main/res/layout/activity_permission.xml

@@ -7,45 +7,44 @@
     android:paddingLeft="@dimen/activity_horizontal_margin"
     android:paddingRight="@dimen/activity_horizontal_margin"
     android:paddingTop="@dimen/activity_vertical_margin"
-    tools:context="app.mar.activities.PermissionActivity"
-    android:background="@drawable/background">
+    tools:context="app.mar.activities.PermissionActivity">
 
     <Button
+        android:id="@+id/understood"
         android:layout_width="wrap_content"
         android:layout_height="60dp"
-        android:id="@+id/understood"
-        android:textSize="25dp"
-        android:textColor="#000000"
-        android:textStyle="bold"
-        android:layout_alignParentRight="true"
-        android:layout_alignParentEnd="true"
         android:layout_alignParentBottom="true"
-        android:text="J&apos;ai compris"
-        android:onClick="onUnderstood"
+        android:layout_alignParentEnd="true"
         android:layout_alignParentLeft="true"
-        android:layout_alignParentStart="true" />
+        android:layout_alignParentRight="true"
+        android:layout_alignParentStart="true"
+        android:onClick="onUnderstood"
+        android:text="J&apos;ai compris"
+        android:textColor="#000000"
+        android:textSize="25dp"
+        android:textStyle="bold" />
 
     <ScrollView
+        android:id="@+id/scrollView2"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:id="@+id/scrollView2"
-        android:layout_alignParentRight="true"
+        android:layout_above="@+id/understood"
         android:layout_alignParentEnd="true"
         android:layout_alignParentLeft="true"
+        android:layout_alignParentRight="true"
         android:layout_alignParentStart="true"
-        android:layout_above="@+id/understood"
         android:layout_alignParentTop="true">
 
         <TextView
+            android:id="@+id/disclamer"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:text="disclamer"
-            android:id="@+id/disclamer"
-            android:layout_alignParentTop="true"
+            android:layout_alignEnd="@+id/understood"
             android:layout_alignParentLeft="true"
             android:layout_alignParentStart="true"
+            android:layout_alignParentTop="true"
             android:layout_alignRight="@+id/understood"
-            android:layout_alignEnd="@+id/understood"
+            android:text="disclamer"
             android:textColor="#000000"
             android:textSize="16dp" />
     </ScrollView>

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

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

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

@@ -90,4 +90,8 @@
     <string name="zxing_msg_camera_framework_bug">Désolé, la caméra Android a rencontré un problème. Un redémarrage de l\'appareil est peut-être nécessaire.</string>
     <string name="zxing_msg_default_status">Encadrez un code-barres avec le viseur pour le balayer.</string>
     <string name="title_activity_qrcode">QRCodeActivity</string>
+    <string name="title_activity_host">HostActivity</string>
+
+    <!-- TODO: Remove or change this placeholder text -->
+    <string name="hello_blank_fragment">Hello blank fragment</string>
 </resources>