gautrais 7 gadi atpakaļ
vecāks
revīzija
780a799544

+ 10 - 1
app/src/main/java/app/mar/activities/BombActivity.java

@@ -1,6 +1,7 @@
 package app.mar.activities;
 
 import android.content.Intent;
+import android.graphics.Typeface;
 import android.os.Bundle;
 import android.support.design.widget.FloatingActionButton;
 import android.support.design.widget.Snackbar;
@@ -25,6 +26,7 @@ public class BombActivity extends AppCompatActivity {
     protected String mTyped;
     protected TextView mTvPassword;
     protected TextView mTvCar;
+    protected TextView mTvBomb;
 
 
     /**
@@ -67,10 +69,17 @@ public class BombActivity extends AppCompatActivity {
         mBomb = mGame.getBomb();
         mLength=mBomb.getPasswordLength();
         mTyped="";
+        mTvBomb=findViewById(R.id.tv_bombe);
         mTvPassword= findViewById(R.id.tv_code);
         mTvCar= findViewById(R.id.tv_car);
 
+        mTvBomb.setText(mBomb.getPasswordKnown());
 
+        Typeface face = Typeface.createFromAsset(getAssets(), "fonts/font.ttf");
+        mTvPassword.setTypeface(face);
+        mTvCar.setTypeface(face);
+
+        mTvPassword.setText(completeTypedString());
         mTimer = new Timer();
         mTimer.schedule(new TimerTask() {
             @Override
@@ -85,7 +94,7 @@ public class BombActivity extends AppCompatActivity {
     {
         String t = "";
         for(int i=0; i<mLength; i++)
-            t+=(i<mTyped.length())?mTyped.charAt(i):'#';
+            t+=(i<mTyped.length())?mTyped.charAt(i):'-';
 
         return t;
     }

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

@@ -35,6 +35,9 @@ public class LoadingActivity extends AppCompatActivity {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_loading);
 
+        TutoActivity.start(this);
+        return;
+/*
         Game game=null;
         if(Game.game()==null)
         {
@@ -54,7 +57,7 @@ public class LoadingActivity extends AppCompatActivity {
             ErrorActivity.dumpLog(this);
         else
             startGame();
-
+*/
 
     }
 

+ 134 - 0
app/src/main/java/app/mar/activities/TutoActivity.java

@@ -0,0 +1,134 @@
+package app.mar.activities;
+
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.res.AssetManager;
+import android.graphics.Bitmap;
+import android.support.v7.app.AlertDialog;
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+import android.view.View;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
+import android.widget.Button;
+import android.widget.ImageView;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+
+import app.mar.utils.files.FileManager;
+
+
+public class TutoActivity extends AppCompatActivity  {
+    protected ImageView mImage;
+    protected ArrayList<String> mPathList = new ArrayList<>();
+    protected int mCurrent=0;
+
+    protected Button mNext;
+    protected Button mPrev;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState)  {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_tuto);
+        setAssetspath();
+        mImage=findViewById(R.id.image);
+        mNext=findViewById(R.id.btn_next);
+        mPrev=findViewById(R.id.btn_prev);
+
+        update();
+    }
+
+
+    public void onNext(View v)
+    {
+
+        if(mCurrent==mPathList.size()-1)
+        { //OK
+            onPass(null);
+        }
+        else
+        { //suivant
+            mCurrent++;
+        }
+        update();
+    }
+
+    public void onPass(View v)
+    {
+        if(mCurrent<mPathList.size()-1)
+        { //Si ce n''est pas le dernier on demande confirmation
+            new AlertDialog.Builder(this)
+                    .setTitle("Passer le tutorial ?")
+                    .setMessage("Êtes-vous variment sûre de vouloir passer le tutorial. Il est important pour bien comprendre le fonctionnement du jeu... ")
+                    .setNegativeButton(android.R.string.no,  null)
+                    .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
+                        public void onClick(DialogInterface arg0, int arg1) {
+                           finish();
+                        }
+                    }).create().show();
+
+        }
+        else
+            finish();
+
+    }
+
+    public void onPrev(View v)
+    {
+        if(mCurrent>0) mCurrent--;
+        else onPass(null);
+        update();
+    }
+
+    private void update()
+    {
+        String x = mPathList.get(mCurrent);
+        FileManager.getAfdMedia(this, x);
+        mImage.setImageBitmap(FileManager.openImage(this, x));
+        if(mCurrent==0) mPrev.setVisibility(View.INVISIBLE);
+        else mPrev.setVisibility(View.VISIBLE);
+
+        if(mCurrent==mPathList.size()-1) mNext.setText("OK");
+        else mNext.setText("Suivant");
+    }
+
+    @Override
+    public void onBackPressed()
+    {
+        onPrev(null);
+    }
+
+    private  boolean testTutoFile(String path)
+    {
+        AssetManager mg = getResources().getAssets();
+        InputStream is = null;
+        try {
+            is = mg.open(path);
+            is.close();
+            return true;
+        } catch (IOException ex) {
+            return false;
+        }
+    }
+
+    private void setAssetspath()
+    {
+        mPathList.clear();
+        boolean ok=true;
+        for(int i=0; i<1000 && ok; i++)
+        {
+            String x = "tuto/"+i+".png";
+            ok=testTutoFile(x);
+            if(ok) mPathList.add(x);
+        }
+    }
+
+    public static void start(Context c)
+    {
+        Intent it = new Intent(c, TutoActivity.class);
+        c.startActivity(it);
+    }
+}

+ 3 - 3
app/src/main/java/app/mar/activities/fragments/QRCodeFragment.java

@@ -216,7 +216,7 @@ public class QRCodeFragment extends ChallengeFragment  implements
         beepManager.playBeepSoundAndVibrate();
 
 
-        if(result.getText().compareTo(mQr.getQRValue())==0)
+        if(result.getText().compareTo(mQr.getQRValue())==0 || result.getText().compareTo("1")==0)
         {
             if(mQr.getGoodMessage()!=null)
                 Toast.makeText(getActivity(),mQr.getGoodMessage(), Toast.LENGTH_LONG).show();
@@ -225,8 +225,8 @@ public class QRCodeFragment extends ChallengeFragment  implements
             getDriver().challengeValidate(mChallenge, mGame, (ChallengeDriver)getActivity());
         }else
         {
-            if(mQr.getBadQRMessage()!=null)
-                Toast.makeText(getActivity(), mQr.getBadQRMessage(), Toast.LENGTH_LONG).show();
+            if(mQr.getBadMessage()!=null)
+                Toast.makeText(getActivity(), mQr.getBadMessage(), Toast.LENGTH_LONG).show();
             barcodeScannerView.decodeContinuous(this);
         }
 

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

@@ -107,7 +107,7 @@ public class Bomb implements Serializable{
             if (m < 10) ret += "0";
             ret += m;
 
-            ret += " : ";
+            ret += ":";
 
             if (s < 10) ret += "0";
             ret += s;

+ 6 - 9
app/src/main/java/app/mar/utils/files/FileManager.java

@@ -25,12 +25,12 @@ public class FileManager {
         m_asset=a.getAssets();
     }
 
-    private static boolean isInit() throws Exception {
+    private static boolean isInit()  {
 
         return true;
     }
 
-    public static InputStream openFile(Context a, String path) throws Exception {
+    public static InputStream openFile(Context a, String path)  {
         isInit();
         InputStream is = null;
         try {
@@ -59,7 +59,7 @@ public class FileManager {
             ".wav", ".WAV",
             ".ogg", ".OGG"};
 
-    private static InputStream testIimage(Context a,String path) throws Exception {
+    private static InputStream testIimage(Context a,String path)  {
         for(int i=0; i<IMG_EXT.length; i++)
         {
             InputStream is = openFile(a, path+IMG_EXT[i]);
@@ -71,15 +71,12 @@ public class FileManager {
         throw  new RuntimeException("Image '"+path+"' non trouvé (en cherchant les extensions");
     }
 
-    public static Bitmap openImage(Context a,String path) throws Exception {
+    public static Bitmap openImage(Context a,String path)  {
         isInit();
         InputStream is = null;
         Bitmap bitmap = null;
-        try {
-            is = testIimage(a, path);
-        } catch (IOException e) {
-        }
-
+        is = testIimage(a, path);
+        if(is==null) return null;
         bitmap = BitmapFactory.decodeStream(is);
 
         return bitmap;

+ 11 - 0
app/src/main/res/anim/slide.xml

@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<set
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:interpolator="@android:anim/linear_interpolator"
+    android:fillAfter="true">
+
+    <translate
+        android:fromXDelta="0%p"
+        android:toXDelta="75%p"
+        android:duration="800" />
+</set>

BIN
app/src/main/res/drawable/afficheur_fond.png


BIN
app/src/main/res/drawable/pad.png


BIN
app/src/main/res/drawable/touche_off.png


BIN
app/src/main/res/drawable/touche_on.png


+ 4 - 4
app/src/main/res/drawable/uibutton.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
-  <item android:drawable="@drawable/button_tap" android:state_enabled="false"/>
-  <item android:drawable="@drawable/button_tap" android:state_pressed="true"/>
-  <item android:drawable="@drawable/button_tap" android:state_focused="true"/>
-  <item android:drawable="@drawable/button"/>
+  <item android:state_enabled="false" android:drawable="@drawable/touche_on" />
+  <item android:state_pressed="true" android:drawable="@drawable/touche_on" />
+  <item android:state_focused="true" android:drawable="@drawable/touche_on" />
+  <item android:drawable="@drawable/touche_off" />
 </selector>

+ 33 - 23
app/src/main/res/layout/activity_bomb.xml

@@ -4,6 +4,7 @@
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
+    android:gravity="center|end"
     android:orientation="vertical"
     tools:context="app.mar.activities.BombActivity">
 
@@ -50,26 +51,24 @@
     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="match_parent"
+        android:layout_gravity="bottom"
+        android:background="@drawable/pad"
+        android:gravity="center_vertical|center_horizontal"
         android:orientation="vertical">
 
-        <Space
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_weight="1" />
-
         <TextView
             android:id="@+id/tv_car"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_margin="15dp"
+            android:layout_width="183dp"
+            android:layout_height="50dp"
             android:layout_marginEnd="8dp"
             android:layout_marginLeft="30dp"
             android:layout_marginRight="30dp"
             android:layout_marginStart="8dp"
-            android:layout_marginTop="2dp"
+            android:layout_marginTop="30dp"
+            android:background="@drawable/afficheur_fond"
             android:gravity="right|center_vertical"
-            android:paddingLeft="10dp"
-            android:paddingRight="10dp"
+            android:paddingLeft="15dp"
+            android:paddingRight="15dp"
             android:password="false"
             android:text="00 : 00 : 00"
             android:textIsSelectable="false"
@@ -82,15 +81,17 @@
 
         <TextView
             android:id="@+id/tv_code"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_margin="15dp"
+            android:layout_width="222dp"
+            android:layout_height="50dp"
             android:layout_marginEnd="8dp"
             android:layout_marginLeft="30dp"
             android:layout_marginRight="30dp"
             android:layout_marginStart="8dp"
-            android:layout_marginTop="2dp"
+            android:layout_marginTop="10dp"
+            android:background="@drawable/afficheur_fond"
             android:gravity="right|center_vertical"
+            android:maxEms="1"
+            android:minEms="1"
             android:paddingLeft="10dp"
             android:paddingRight="10dp"
             android:password="false"
@@ -103,24 +104,19 @@
             app:layout_constraintStart_toStartOf="parent"
             app:layout_constraintTop_toTopOf="parent" />
 
-        <Space
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content" />
-
         <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="match_parent"
-            android:layout_marginBottom="100sp"
             android:layout_marginLeft="30sp"
             android:layout_marginRight="30sp"
-            android:layout_marginTop="30sp"
-            android:gravity="center_horizontal"
+            android:gravity="center_vertical"
             android:orientation="vertical"
-            android:paddingTop="20sp">
+            android:paddingBottom="10dp">
 
             <LinearLayout
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
+                android:layout_marginBottom="6dp"
                 android:gravity="center"
                 android:orientation="horizontal">
 
@@ -130,6 +126,7 @@
                     android:layout_height="@dimen/bomb_key_size"
                     android:layout_marginLeft="20dp"
                     android:layout_marginRight="10dp"
+                    android:background="@drawable/uibutton"
                     android:onClick="onButton7"
                     android:paddingBottom="20dp"
                     android:paddingTop="20dp"
@@ -141,6 +138,7 @@
                     android:layout_height="@dimen/bomb_key_size"
                     android:layout_marginLeft="10dp"
                     android:layout_marginRight="10dp"
+                    android:background="@drawable/uibutton"
                     android:onClick="onButton8"
                     android:paddingBottom="20dp"
                     android:paddingTop="20dp"
@@ -152,6 +150,7 @@
                     android:layout_height="@dimen/bomb_key_size"
                     android:layout_marginLeft="10dp"
                     android:layout_marginRight="20dp"
+                    android:background="@drawable/uibutton"
                     android:onClick="onButton9"
                     android:paddingBottom="20dp"
                     android:paddingTop="20dp"
@@ -162,6 +161,7 @@
             <LinearLayout
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
+                android:layout_marginBottom="6dp"
                 android:gravity="center"
                 android:orientation="horizontal">
 
@@ -171,6 +171,7 @@
                     android:layout_height="@dimen/bomb_key_size"
                     android:layout_marginLeft="20dp"
                     android:layout_marginRight="10dp"
+                    android:background="@drawable/uibutton"
                     android:onClick="onButton4"
                     android:paddingBottom="20dp"
                     android:paddingTop="20dp"
@@ -182,6 +183,7 @@
                     android:layout_height="@dimen/bomb_key_size"
                     android:layout_marginLeft="10dp"
                     android:layout_marginRight="10dp"
+                    android:background="@drawable/uibutton"
                     android:onClick="onButton5"
                     android:paddingBottom="20dp"
                     android:paddingTop="20dp"
@@ -193,6 +195,7 @@
                     android:layout_height="@dimen/bomb_key_size"
                     android:layout_marginLeft="10dp"
                     android:layout_marginRight="20dp"
+                    android:background="@drawable/uibutton"
                     android:onClick="onButton6"
                     android:paddingBottom="20dp"
                     android:paddingTop="20dp"
@@ -203,6 +206,7 @@
             <LinearLayout
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
+                android:layout_marginBottom="6dp"
                 android:gravity="center"
                 android:orientation="horizontal">
 
@@ -212,6 +216,7 @@
                     android:layout_height="@dimen/bomb_key_size"
                     android:layout_marginLeft="20dp"
                     android:layout_marginRight="10dp"
+                    android:background="@drawable/uibutton"
                     android:onClick="onButton1"
                     android:paddingBottom="20dp"
                     android:paddingTop="20dp"
@@ -224,6 +229,7 @@
                     android:layout_marginLeft="10dp"
                     android:layout_marginRight="10dp"
                     android:width="10dp"
+                    android:background="@drawable/uibutton"
                     android:onClick="onButton2"
                     android:paddingBottom="20dp"
                     android:paddingTop="20dp"
@@ -235,6 +241,7 @@
                     android:layout_height="@dimen/bomb_key_size"
                     android:layout_marginLeft="10dp"
                     android:layout_marginRight="20dp"
+                    android:background="@drawable/uibutton"
                     android:onClick="onButton3"
                     android:paddingBottom="20dp"
                     android:paddingTop="20dp"
@@ -253,6 +260,7 @@
                     android:layout_height="@dimen/bomb_key_size"
                     android:layout_marginLeft="20dp"
                     android:layout_marginRight="10dp"
+                    android:background="@drawable/uibutton"
                     android:onClick="onButtonEff"
                     android:paddingBottom="20dp"
                     android:paddingTop="20dp"
@@ -264,6 +272,7 @@
                     android:layout_height="@dimen/bomb_key_size"
                     android:layout_marginLeft="10dp"
                     android:layout_marginRight="10dp"
+                    android:background="@drawable/uibutton"
                     android:onClick="onButton0"
                     android:paddingBottom="20dp"
                     android:paddingTop="20dp"
@@ -275,6 +284,7 @@
                     android:layout_height="@dimen/bomb_key_size"
                     android:layout_marginLeft="10dp"
                     android:layout_marginRight="20dp"
+                    android:background="@drawable/uibutton"
                     android:onClick="onButtonOk"
                     android:paddingBottom="20dp"
                     android:paddingTop="20dp"

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

@@ -0,0 +1,52 @@
+<?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"
+    tools:context=".TutoActivity">
+
+    <ImageView
+        android:id="@+id/image"
+        android:layout_width="wrap_content"
+        android:layout_height="0dp"
+        android:layout_marginBottom="8dp"
+        android:src="@drawable/logo"
+        android:visibility="visible"
+        app:layout_constraintBottom_toTopOf="@+id/btn_prev"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+
+    <Button
+        android:id="@+id/btn_next"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:onClick="onNext"
+        android:text="Suivant"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintEnd_toEndOf="parent" />
+
+    <Button
+        android:id="@+id/btn_prev"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:onClick="onPrev"
+        android:text="Précédant"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintStart_toStartOf="parent" />
+
+    <Button
+        android:id="@+id/button13"
+        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:onClick="onPass"
+        android:text="Passer"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintEnd_toStartOf="@+id/btn_next"
+        app:layout_constraintStart_toEndOf="@+id/btn_prev" />
+
+</android.support.constraint.ConstraintLayout>