François Gautrais 8 rokov pred
rodič
commit
e3de1d1c9b
50 zmenil súbory, kde vykonal 1151 pridanie a 221 odobranie
  1. 6 3
      app/src/main/AndroidManifest.xml
  2. 1 0
      app/src/main/java/app/brest/app/brest/ui/CameraPreview.java
  3. 31 0
      app/src/main/java/app/brest/app/brest/ui/CustomListView.java
  4. 103 0
      app/src/main/java/app/brest/app/brest/ui/CustomToggleButton.java
  5. 12 0
      app/src/main/java/app/brest/app/brest/ui/OnToggleListener.java
  6. 24 8
      app/src/main/java/app/brest/app/brest/ui/ResourceArrayAdapter.java
  7. 82 0
      app/src/main/java/app/brest/app/brest/ui/SelectButton.java
  8. 62 81
      app/src/main/java/app/brest/testmin3d/ARActivity.java
  9. 33 2
      app/src/main/java/app/brest/testmin3d/NewMenuActivity.java
  10. 163 0
      app/src/main/java/app/brest/testmin3d/PuzzleActivity.java
  11. 33 6
      app/src/main/java/app/brest/testmin3d/ResourceListActivity.java
  12. 183 31
      app/src/main/java/app/brest/testmin3d/SettingsActivity.java
  13. 113 8
      app/src/main/java/app/brest/testmin3d/ViewerActivity.java
  14. 21 2
      app/src/main/java/app/brest/utils/ResourceManager.java
  15. 65 9
      app/src/main/java/app/brest/utils/SensorsManager.java
  16. 38 5
      app/src/main/java/app/brest/utils/Settings.java
  17. 11 4
      app/src/main/java/app/brest/utils/SlideBuffer.java
  18. 26 2
      app/src/main/java/app/brest/utils/app/brest/game/Game.java
  19. 12 0
      app/src/main/java/app/brest/utils/app/brest/game/Resource.java
  20. 17 3
      app/src/main/java/min3d/core/RendererActivity.java
  21. BIN
      app/src/main/res/drawable/aa.jpg
  22. BIN
      app/src/main/res/drawable/ab.jpg
  23. BIN
      app/src/main/res/drawable/ac.jpg
  24. BIN
      app/src/main/res/drawable/ad.jpg
  25. BIN
      app/src/main/res/drawable/ae.jpg
  26. BIN
      app/src/main/res/drawable/af.jpg
  27. BIN
      app/src/main/res/drawable/ag.jpg
  28. BIN
      app/src/main/res/drawable/ag_texture.jpg
  29. BIN
      app/src/main/res/drawable/ah.jpg
  30. BIN
      app/src/main/res/drawable/ah_texture.jpg
  31. BIN
      app/src/main/res/drawable/ba.jpg
  32. BIN
      app/src/main/res/drawable/bb.jpg
  33. BIN
      app/src/main/res/drawable/bc.jpg
  34. BIN
      app/src/main/res/drawable/bd.jpg
  35. BIN
      app/src/main/res/drawable/be.jpg
  36. BIN
      app/src/main/res/drawable/bf.jpg
  37. BIN
      app/src/main/res/drawable/bg.jpg
  38. BIN
      app/src/main/res/drawable/bg_texture.jpg
  39. BIN
      app/src/main/res/drawable/title.png
  40. 7 20
      app/src/main/res/layout/activity_main.xml
  41. 50 0
      app/src/main/res/layout/activity_puzzle.xml
  42. 7 5
      app/src/main/res/layout/activity_resource_list.xml
  43. 40 23
      app/src/main/res/layout/activity_settings.xml
  44. 1 1
      app/src/main/res/raw/bh_res
  45. 1 1
      app/src/main/res/raw/ca_res
  46. 1 1
      app/src/main/res/raw/cb_res
  47. 1 1
      app/src/main/res/raw/ce_res
  48. 2 2
      app/src/main/res/raw/cf_res
  49. 3 3
      app/src/main/res/raw/cg_res
  50. 2 0
      app/src/main/res/values/strings.xml

+ 6 - 3
app/src/main/AndroidManifest.xml

@@ -31,9 +31,7 @@
             android:label="@string/title_activity_resource_list" />
         <activity
             android:name=".MenuActivity"
-            android:label="@string/title_activity_menu">
-
-        </activity>
+            android:label="@string/title_activity_menu"></activity>
         <activity
             android:name=".SettingsActivity"
             android:label="@string/title_activity_settings" />
@@ -46,6 +44,11 @@
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>
+        <activity
+            android:name=".PuzzleActivity"
+            android:configChanges="orientation|keyboardHidden|screenSize"
+            android:label="@string/title_activity_puzzle"
+            android:theme="@style/FullscreenTheme"></activity>
     </application>
 
 </manifest>

+ 1 - 0
app/src/main/java/app/brest/app/brest/ui/CameraPreview.java

@@ -27,6 +27,7 @@ public class CameraPreview extends SurfaceView implements SurfaceHolder.Callback
     public CameraPreview(Context context, Camera camera) {
         super(context);
         this.mCamera = camera;
+        Log.e("______", camera+" camera");
         this.mHolder = getHolder();
         this.mHolder.addCallback(this);
     }

+ 31 - 0
app/src/main/java/app/brest/app/brest/ui/CustomListView.java

@@ -0,0 +1,31 @@
+package app.brest.app.brest.ui;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.widget.ListView;
+
+/**
+ * Created by ptitcois on 31/10/16.
+ */
+
+public class CustomListView  extends ListView {
+
+    public CustomListView  (Context context, AttributeSet attrs) {
+        super(context, attrs);
+    }
+
+    public CustomListView  (Context context) {
+        super(context);
+    }
+
+    public CustomListView  (Context context, AttributeSet attrs, int defStyle) {
+        super(context, attrs, defStyle);
+    }
+
+    @Override
+    public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+        int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
+                MeasureSpec.AT_MOST);
+        super.onMeasure(widthMeasureSpec, expandSpec);
+    }
+}

+ 103 - 0
app/src/main/java/app/brest/app/brest/ui/CustomToggleButton.java

@@ -0,0 +1,103 @@
+package app.brest.app.brest.ui;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.Button;
+
+import app.brest.testmin3d.R;
+
+/**
+ * Created by ptitcois on 31/10/16.
+ */
+public class CustomToggleButton extends Button implements View.OnClickListener {
+
+    protected boolean mState=false;
+    protected OnToggleListener mListener = null;
+
+
+    public CustomToggleButton(Context context, boolean state) {
+        super(context);
+        mState=state;
+        init();
+    }
+
+    public CustomToggleButton(Context context) {
+        super(context);
+        init();
+    }
+
+    public CustomToggleButton(Context context, boolean state, OnToggleListener l) {
+        super(context);
+        mState=state;
+        mListener=l;
+        init();
+
+    }
+
+    public CustomToggleButton(Context context, AttributeSet attrs) {
+        super(context, attrs);
+        init();
+    }
+
+    public CustomToggleButton(Context context, AttributeSet attrs, int defStyleAttr) {
+        super(context, attrs, defStyleAttr);
+        init();
+    }
+
+    protected void init()
+    {
+        super.setOnClickListener(this);
+        setHeight(50);
+        update();
+    }
+
+    protected void update()
+    {
+        if(mState) onOn();
+        else onOff();
+    }
+
+    protected void onOn()
+    {
+        setText("On");
+        setTextColor(getResources().getColor(R.color.dull_4));
+        setBackgroundResource(R.drawable.togglebutton_on);
+        setHeight(50);
+        if(mListener!=null) mListener.onOn(this);
+    }
+
+    protected void onOff()
+    {
+        setText("Off");
+        setTextColor(getResources().getColor(R.color.dull_4));
+        setBackgroundResource(R.drawable.togglebutton_off);
+        setHeight(50);
+
+        if(mListener!=null) mListener.onOff(this);
+    }
+
+    public boolean getState()
+    {
+        return mState;
+    }
+
+    public void setState(boolean s)
+    {
+        mState=s;
+        update();
+    }
+
+
+    public void setOnClickListener(app.brest.app.brest.ui.OnToggleListener l)
+    {
+        mListener=l;
+    }
+
+    @Override
+    public void onClick(View view) {
+        mState=!mState;
+        update();
+        if(mListener!=null) mListener.onToggle(this);
+    }
+}

+ 12 - 0
app/src/main/java/app/brest/app/brest/ui/OnToggleListener.java

@@ -0,0 +1,12 @@
+package app.brest.app.brest.ui;
+
+import android.view.View;
+
+/**
+ * Created by ptitcois on 31/10/16.
+ */
+public interface OnToggleListener {
+    public void onToggle(View v);
+    public void onOn(View v);
+    public void onOff(View v);
+}

+ 24 - 8
app/src/main/java/app/brest/app/brest/ui/ResourceArrayAdapter.java

@@ -4,6 +4,7 @@ import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
 import android.graphics.Color;
+import android.graphics.Typeface;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.AdapterView;
@@ -19,13 +20,13 @@ import app.brest.utils.app.brest.game.Resource;
 /**
  * Created by ptitcois on 22/08/16.
  */
-public class ResourceArrayAdapter extends ArrayAdapter<Resource> implements  AdapterView.OnItemClickListener{
+public class ResourceArrayAdapter extends ArrayAdapter<Object> implements  AdapterView.OnItemClickListener{
     protected Context mContext;
-
-    public ResourceArrayAdapter(Context context, int resource, List<Resource> objects) {
+    protected List<Object> mList;
+    public ResourceArrayAdapter(Context context, int resource, List<Object> objects) {
         super(context, resource, objects);
         mContext=context;
-
+        mList=objects;
     }
 
     @Override
@@ -38,15 +39,30 @@ public class ResourceArrayAdapter extends ArrayAdapter<Resource> implements  Ada
             /*YOUR CHOICE OF COLOR*/
         textView.setTextColor(Color.rgb(0x33, 0xb5, 0xe5));
 
+        if(mList.get(position) instanceof String){
+            textView.setTextSize(30);
+            textView.setTypeface(null, Typeface.BOLD);
+        }else{
+            textView.setTextSize(15);
+            textView.setTypeface(null, Typeface.NORMAL);
+        }
+
+
         return view;
     }
 
     @Override
     public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
-        Resource item = (Resource)adapterView.getItemAtPosition(i);
+        if (adapterView.getItemAtPosition(i) instanceof Resource) {
+            Resource item = (Resource) adapterView.getItemAtPosition(i);
+
+            Intent intent = new Intent(mContext, ViewerActivity.class);
+            intent.putExtra("resource", item);
+            mContext.startActivity(intent);
+
+        }else if(adapterView.getItemAtPosition(i) instanceof String)
+        {
 
-        Intent intent = new Intent(mContext, ViewerActivity.class);
-        intent.putExtra("resource", item);
-        mContext.startActivity(intent);
+        }
     }
 }

+ 82 - 0
app/src/main/java/app/brest/app/brest/ui/SelectButton.java

@@ -0,0 +1,82 @@
+package app.brest.app.brest.ui;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.Gravity;
+import android.view.View;
+import android.widget.Button;
+import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import java.util.ArrayList;
+
+import app.brest.testmin3d.R;
+
+/**
+ * Created by ptitcois on 31/10/16.
+ */
+public class SelectButton extends LinearLayout implements View.OnClickListener {
+    protected String[] mData;
+    protected Button mLeft;
+    protected Button mRight;
+    protected TextView mText;
+    protected int mState = 0;
+    protected int mHeight=60;
+    protected void setLParams(View v, int w, int h)
+    {
+        LayoutParams l =new LayoutParams(w,h);
+        l.setMargins(0,0,0,0);
+        v.setLayoutParams(l);
+    }
+
+    public SelectButton(Context context, String[] m) {
+        super(context);
+        setOrientation(HORIZONTAL);
+        mData=m;
+        mLeft = new Button(context);
+        mLeft.setBackgroundResource(R.drawable.arrow_left);
+        mLeft.setOnClickListener(this);
+
+        mRight = new Button(context);
+        mRight.setBackgroundResource(R.drawable.arrow_right);
+        mRight.setOnClickListener(this);
+
+        mText = new TextView(context);
+        if(mData.length>0)
+            mText.setText(mData[mState]);
+
+
+        addView(mLeft);
+        addView(mText);
+        addView(mRight);
+        setLParams(mLeft, mHeight, mHeight);
+        setLParams(mRight, mHeight, mHeight);
+        setLParams(mText, 200 , mHeight);
+        mText.setTextColor(getResources().getColor(R.color.dull_4));
+
+    }
+
+    public void setState(int i)
+    {
+        if(mData.length>i)
+            mText.setText(mData[mState=i]);
+    }
+
+    public int getState()
+    {
+        return mState;
+    }
+
+    @Override
+    public void onClick(View view) {
+        if(view==mLeft)
+        {
+            mState=(mState-1<0) ? (mData.length-1) : (mState-1);
+        }else if(view==mRight)
+        {
+            mState=(mState==mData.length-1) ? 0 : (mState+1);
+        }
+        mText.setText(mData[mState]);
+    }
+}

+ 62 - 81
app/src/main/java/app/brest/testmin3d/ARActivity.java

@@ -1,12 +1,16 @@
 package app.brest.testmin3d;
+import android.Manifest;
 import android.app.Activity;
 import android.content.Intent;
 import android.content.pm.ActivityInfo;
+import android.content.pm.PackageManager;
 import android.content.res.Resources;
 import android.graphics.PixelFormat;
 import android.hardware.Camera;
 import android.os.Bundle;
 import android.os.Handler;
+import android.support.v4.app.ActivityCompat;
+import android.support.v4.content.ContextCompat;
 import android.util.Log;
 import android.view.View;
 import android.view.ViewTreeObserver;
@@ -21,8 +25,10 @@ import android.widget.Toast;
 import java.text.DecimalFormat;
 import java.text.NumberFormat;
 import java.util.ArrayList;
+import java.util.List;
 
 import app.brest.app.brest.ui.CameraPreview;
+import app.brest.utils.app.brest.game.Area;
 import app.brest.utils.app.brest.game.Game;
 import app.brest.utils.app.brest.game.LocatedResources;
 import app.brest.utils.app.brest.game.Place;
@@ -46,8 +52,6 @@ public class ARActivity extends RendererActivity
 
     private Object3dContainer faceObject3D;
     private Button mOkButton;
-    private TextView mAngle;
-    private TextView mGps;
     private final Object mLock = new Object();
     protected boolean isPausing=false;
     protected static GPSPoint mLocation;
@@ -73,14 +77,12 @@ public class ARActivity extends RendererActivity
         setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
 
 
-        cameraPreviewLayout = (FrameLayout)findViewById(R.id.camera_preview);
 
+        cameraPreviewLayout = (FrameLayout)findViewById(R.id.camera_preview);
+        Log.e("____", "Camera:");
         camera = checkDeviceCamera();
         mImageSurfaceView = new CameraPreview(ARActivity.this, camera);
 
-        mAngle = (TextView) findViewById(R.id.angle);
-        mGps = (TextView) findViewById(R.id.gps);
-
 
         mOkButton = (Button) findViewById(R.id.button_catch);
         mOkButton.setVisibility(View.INVISIBLE);
@@ -96,7 +98,10 @@ public class ARActivity extends RendererActivity
         Camera mCamera = null;
         try {
             mCamera = Camera.open();
+            Log.e("____", "Camera OK "+mCamera);
+
         } catch (Exception e) {
+            Log.e("____", "Camera Fail "+mCamera);
             e.printStackTrace();
         }
         return mCamera;
@@ -207,84 +212,70 @@ public class ARActivity extends RendererActivity
     {
 
         ArrayList<LocatedResources> res = mGame.getResourcesNextToPlayer();
-        final TextView tv = (TextView) findViewById(R.id.text_detected);
-        final TextView tv2 = (TextView)findViewById(R.id.text_place);
-        String toDisplay ="Detetected \n";
+        String toDisplay ="";
         float vX =0;
         boolean detected = false;
        // String dete = "Detected:\n";
         scene.clear();
-        for (int i = 0; i < res.size(); i++) {
-            Resource rr = res.get(i).getResource(0);
-            Place p = res.get(i).getPlace();
-            if(rr!=null) {
-                detected=true;
-                //toDisplay += "\t" + rr.getName() + " \n";
-                //dete += "\t" + rr.getName() + "\n";
-                Object3d oo = rr.get3DModel(this);
-                CameraVo v = new CameraVo();
-                double distCoef= (p.getDistance(mGame.getPlayer())/50)*0.8;
-                distCoef+=0.2;
-                if(distCoef>1)distCoef=1.0;
-
-                /*v.target.y=-mGame.getPlayer().getOrientationY()+315;
-                while(v.target.y<0) v.target.y+=360;
-                v.target.y%=360;
-                if(v.target.y>180) v.target.y-=360;*/
-                double theta=-(-mGame.getPlayer().getOrientationY()+135-(0.5*Math.atan(p.getDistance(mGame.getPlayer())/1.6)*180/Math.PI)%360);
-                while(theta<-180)theta+=360;
-                while(theta>180) theta-=360;
-
-                oo.position().y=-25+(float)(50*Math.sin(-theta*Math.PI/180.0));
-                //si utilisation de field et angle
-                if(p.isUseAngle())
-                    ;//v.target.x=(float)(mGame.getPlayer().getOrientationX()-p.getAngle())+mGame.getPlayer().getOrientationZ()-270f;
-                //si utilisation GPS pour l'angle
-                else {
-                    //v.target.x =
-                    double alpha = ((float) (mGame.getPlayer().getAngleWith(p) - mGame.getPlayer().getOrientationX()))- mGame.getPlayer().getOrientationZ();
-                    //oo.position().x=-(int)(99*Math.sin(alpha)/180*Math.PI);
-                    oo.position().z=-60;//(float)(90*distCoef*Math.cos(alpha*Math.PI/180.0));
-                    oo.position().x=-(float)(90*distCoef*Math.sin(alpha*Math.PI/180.0));
-
-
-                    //oo.position().z=0;
-                    //oo.position().z=-5;
-
-                    //while(v.target.x<0)v.target.x+=360;
-                    //if(v.target.x>180) v.target.x-=360;
-
-                    toDisplay += "Angle " + dts(alpha) + "°\nx,y = (" + dts(mGame.getPlayer().getRelXWith(p)*1000000) + " m, " + dts(mGame.getPlayer().getRelYWith(p)*1000000) +
-                            " m)\nPlayer :" + dts(mGame.getPlayer().getOrientationX()) + "°\nAngleWith:" + dts(mGame.getPlayer().getAngleWith(p)) +
-                            "°\nZ " + dts(mGame.getPlayer().getOrientationZ() - 270f) + "°\nTotal " + dts(v.target.x) + "°\nTarget x : "+dts(oo.position().x)
-                            + "°\nTarget y : "+dts(oo.position().y)+ "°\nTarget z : "+dts(v.position.z)+"°";
+
+        if(mGame.getmSettings().isAreaDebug())
+        {
+            ArrayList<Area> ar = mGame.getAreaNextToPlayer();
+            String ttxt = "Zones trouvées:\n";
+            for(int i=0; i<ar.size(); i++)
+                ttxt+="\t"+ar.get(i).getName()+"\n";
+            toDisplay+=ttxt+"\n";
+
+        }
+
+        if(mGame.getmSettings().isAreaDebug()) toDisplay+="Resources détectées: \n";
+
+        if(mGame.getmSettings().isARMode()) {
+            for (int i = 0; i < res.size(); i++) {
+                Resource rr = res.get(i).getResource(0);
+                Place p = res.get(i).getPlace();
+                if (rr != null) {
+                    detected = true;
+                    Object3d oo = rr.get3DModel(this);
+                    CameraVo v = new CameraVo();
+                    double distCoef = (p.getDistance(mGame.getPlayer()) / 50) * 0.8;
+                    distCoef += 0.2;
+                    if (distCoef > 1) distCoef = 1.0;
+
+                    double theta = -(-mGame.getPlayer().getOrientationY() + 135 - (0.5 * Math.atan(p.getDistance(mGame.getPlayer()) / 1.6) * 180 / Math.PI) % 360);
+                    while (theta < -180) theta += 360;
+                    while (theta > 180) theta -= 360;
+
+                    oo.position().y = -25 + (float) (50 * Math.sin(-theta * Math.PI / 180.0));
+
+                    double alpha = ((float) (mGame.getPlayer().getAngleWith(p) - mGame.getPlayer().getOrientationX())) - mGame.getPlayer().getOrientationZ();
+                    oo.position().z = -20;//(float)(90*distCoef*Math.cos(alpha*Math.PI/180.0));
+                    oo.position().x = -(float) (90 * distCoef * Math.sin(alpha * Math.PI / 180.0));
+
+                    if (mGame.getmSettings().isAreaDebug()) {
+
+                        toDisplay += "Azimuth: " + dts(alpha) + "°\nPosition (" + dts(oo.position().x) + ", " + dts(oo.position().y)
+                                + ", " + dts(oo.position().z) + ")\n\n";
+                    }
+
+                    vX = (float) (mGame.getPlayer().getAngleWith(p));
+                    scene.camera(v);
+                    scene.addChild(oo);
                 }
-                //v.target.x+=10;
-                //v.position.z=x-=0.5;
-                //oo.scale().x=oo.scale().y=oo.scale().z=x+=0.01;
-                //v.target.z=mGame.getPlayer().getOrientationZ()-270;
-                vX=(float)(mGame.getPlayer().getAngleWith(p));
-                scene.camera(v);
-                scene.addChild(oo);
             }
         }
-
         updateLed(detected, mGame.getResourcesNextToPlayerDistDouble());
 
 
+
+        //affichage en debug
         final String td = toDisplay;
-        mGps.getHandler().post(new Runnable() {
-            public void run() {
-                mGps.setText(td);
-            }
-        });
+        final TextView xv = (TextView)findViewById(R.id.text_area);
+        xv.getHandler().post(new Runnable() { public void run() { xv.setText(td);  } });
+
 
+        //affichage de la distance dans l'HUD
         final String dete2 = mGame.getResourcesNextToPlayerDist();
-        tv.getHandler().post(new Runnable() {
-            public void run() {
-                tv.setText(dete2);
-            }
-        });
         mTvDistance.getHandler().post(new Runnable() {
             public void run() {
                 mTvDistance.setText(dete2);
@@ -380,16 +371,6 @@ public class ARActivity extends RendererActivity
                 if (!isPausing) {
                     boolean b = mGame.precache3DResource(this);
                     isResource = updateSceneResource();
-                    if(b)
-                    {
-                        final Activity _this = this;
-                        mAngle.getHandler().post(new Runnable() {
-                            public void run() {
-                                Toast.makeText(_this,"Localisé dans la zone", Toast.LENGTH_LONG);
-                            }
-                        });
-
-                    }
                 }else
                 {
                     scene.clear();

+ 33 - 2
app/src/main/java/app/brest/testmin3d/NewMenuActivity.java

@@ -24,6 +24,7 @@ import android.widget.RelativeLayout;
 import android.widget.Toast;
 
 import app.brest.app.brest.ui.RotateButton;
+import app.brest.utils.Settings;
 import app.brest.utils.app.brest.game.Game;
 import app.brest.utils.app.brest.game.Resource;
 import app.brest.utils.app.brest.game.Stage;
@@ -70,6 +71,8 @@ public class NewMenuActivity extends Activity implements View.OnClickListener{
 
     }
 
+
+
     private void updateSize()
     {
         Display display = getWindowManager().getDefaultDisplay();
@@ -120,7 +123,7 @@ public class NewMenuActivity extends Activity implements View.OnClickListener{
         setContentView(R.layout.activity_new_menu);
         mRootLayout = (RelativeLayout)findViewById(R.id.menu_root);
 
-        Game g = null;//Game.load(this);
+        Game g = Game.load(this);
 
         if (g!= null && mGame==null) {
             mGame = g;
@@ -139,6 +142,7 @@ public class NewMenuActivity extends Activity implements View.OnClickListener{
             throw new Error("Le jeu n'est pas sauvegardé");
         }
         updateSize();
+        Settings.setSettings(mGame.getmSettings());
 
         mIbScanner = new Button(this);
         //mIbScanner.setImageResource(R.drawable.scanner);
@@ -167,7 +171,33 @@ public class NewMenuActivity extends Activity implements View.OnClickListener{
 
         setUpStyle();
         mCustomHandler.postDelayed(updateTimerThread, 10);
-
+/*
+        mGame.pickResource("aa");
+        mGame.pickResource("ab");
+        mGame.pickResource("ac");
+        mGame.pickResource("ad");
+        mGame.pickResource("ae");
+        mGame.pickResource("ag");
+        mGame.pickResource("ah");
+        mGame.pickResource("ai");
+        mGame.nextStage();
+        mGame.pickResource("ba");
+        mGame.pickResource("bb");
+        mGame.pickResource("bc");
+        mGame.pickResource("bd");
+        mGame.pickResource("be");
+        mGame.pickResource("bf");
+        mGame.pickResource("bg");
+        mGame.pickResource("bh");
+        mGame.nextStage();
+        mGame.pickResource("ca");
+        mGame.pickResource("cb");
+        mGame.pickResource("cc");
+        mGame.pickResource("cd");
+        mGame.pickResource("ce");
+        mGame.pickResource("cf");
+        mGame.pickResource("cg");
+*/
     }
 
     public void onOptionsClick(View v)
@@ -247,6 +277,7 @@ public class NewMenuActivity extends Activity implements View.OnClickListener{
     public void onResume()
     {
         super.onResume();
+        mGame = Game.game();
         setUpStyle();
     }
 

+ 163 - 0
app/src/main/java/app/brest/testmin3d/PuzzleActivity.java

@@ -0,0 +1,163 @@
+package app.brest.testmin3d;
+
+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);
+    }
+}

+ 33 - 6
app/src/main/java/app/brest/testmin3d/ResourceListActivity.java

@@ -18,10 +18,13 @@ import android.widget.ArrayAdapter;
 import android.widget.Button;
 import android.widget.LinearLayout;
 import android.widget.ListView;
+import android.widget.ScrollView;
 import android.widget.TextView;
 
 import java.util.ArrayList;
+import java.util.List;
 
+import app.brest.app.brest.ui.CustomListView;
 import app.brest.app.brest.ui.ResourceArrayAdapter;
 import app.brest.utils.app.brest.game.Game;
 import app.brest.utils.app.brest.game.Resource;
@@ -33,13 +36,14 @@ import app.brest.utils.app.brest.game.Resource;
 public class ResourceListActivity extends Activity {
 
     protected Game mGame;
-    protected LinearLayout mLayout;
+    protected ListView mList;
 
-
-    protected void addStage(ArrayList<Resource> ar, int stage)
+    /*
+    protected void addStage(ArrayList<Object> ar, int stage)
     {
         LinearLayout nl = new LinearLayout(this);
-        ListView lv = new ListView(this);
+        CustomListView lv = new CustomListView(this);
+        ScrollView sv = new ScrollView(this);
         TextView b = new TextView(this);
         ResourceArrayAdapter aa;
         b.setText("Etape "+stage);
@@ -54,7 +58,9 @@ public class ResourceListActivity extends Activity {
 
         nl.setOrientation(LinearLayout.VERTICAL);
         nl.addView(b);
-        nl.addView(lv);
+        nl.addView(sv);
+        sv.addView(lv);
+        //lv.setLayoutParams(new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT,  LinearLayout.LayoutParams.MATCH_PARENT));
         mLayout.addView(nl);
     }
 
@@ -66,15 +72,36 @@ public class ResourceListActivity extends Activity {
             for(int i = 0; i< resources.size(); i++)
                 addStage(resources.get(i), i);
         }
+    }*/
+
+
+    protected void fill()
+    {
+        if(mGame!=null)
+        {
+            ArrayList< ArrayList<Resource> > resources = mGame.getResourceByStage();
+            ArrayList<Object> obs = new ArrayList<Object>();
+            for(int i = 0; i< resources.size(); i++) {
+                obs.add("Étape "+i);
+                for(int j=0; j<resources.get(i).size(); j++)
+                    obs.add(resources.get(i).get(j));
+            }
+            ResourceArrayAdapter aa;
+            aa = new ResourceArrayAdapter(this, android.R.layout.simple_list_item_1, obs);
+            mList.setOnItemClickListener(aa);
+
+            mList.setAdapter(aa);
+        }
     }
 
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_resource_list);
         mGame = (Game)getIntent().getSerializableExtra("game");
 
-        mLayout = (LinearLayout) findViewById(R.id.list_layout);
+        mList = (ListView) findViewById(R.id.list_layout);
         fill();
     }
 

+ 183 - 31
app/src/main/java/app/brest/testmin3d/SettingsActivity.java

@@ -4,6 +4,7 @@ package app.brest.testmin3d;
 import android.annotation.TargetApi;
 import android.app.Activity;
 import android.content.Context;
+import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.res.Configuration;
 import android.media.Ringtone;
@@ -18,15 +19,22 @@ import android.support.v7.app.ActionBar;
 import android.preference.PreferenceFragment;
 import android.preference.PreferenceManager;
 import android.preference.RingtonePreference;
+import android.support.v7.app.AlertDialog;
 import android.text.TextUtils;
 import android.view.MenuItem;
 import android.view.View;
+import android.widget.Button;
 import android.widget.LinearLayout;
 import android.widget.TextView;
+import android.widget.Toast;
 import android.widget.ToggleButton;
 
 import java.util.List;
 
+import app.brest.app.brest.ui.CustomToggleButton;
+import app.brest.app.brest.ui.OnToggleListener;
+import app.brest.app.brest.ui.RotateButton;
+import app.brest.app.brest.ui.SelectButton;
 import app.brest.utils.Settings;
 import app.brest.utils.app.brest.game.Game;
 
@@ -41,75 +49,219 @@ import app.brest.utils.app.brest.game.Game;
  * href="http://developer.android.com/guide/topics/ui/settings.html">Settings
  * API Guide</a> for more information on developing a Settings UI.
  */
-public class SettingsActivity extends Activity {
+public class SettingsActivity extends Activity implements app.brest.app.brest.ui.OnToggleListener, View.OnClickListener {
 
     protected Game         mGame;
     protected LinearLayout mRoot;
-    protected ToggleButton mAccelerometer;
-    protected ToggleButton mGPS;
-    protected ToggleButton mPlaces;
-    protected ToggleButton mAreas;
+    protected LinearLayout mRootDev;
+    protected CustomToggleButton mAccelerometer;
+    protected CustomToggleButton mGPS;
+    protected CustomToggleButton mPlaces;
+    protected CustomToggleButton mAreas;
+    protected CustomToggleButton mDev;
+    protected CustomToggleButton mRA;
+    protected SelectButton mSensorLatency;
+    protected Button mReset;
+    protected Button mCheat;
+    protected Button mOk;
+
+
 
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_settings);
 
-        mGame = (Game) getIntent().getSerializableExtra("game");
-
-        mAccelerometer = new ToggleButton(this);
-        mGPS = new ToggleButton(this);
-        mPlaces=new ToggleButton(this);
-        mAreas=new ToggleButton(this);
+        mGame = Game.game();
+        mRootDev=new LinearLayout(this);
+        mRootDev.setOrientation(LinearLayout.VERTICAL);
+        mAccelerometer = new CustomToggleButton(this);
+        mGPS = new CustomToggleButton(this);
+        mDev = new CustomToggleButton(this);
+        mDev.setOnClickListener((app.brest.app.brest.ui.OnToggleListener)this);
+        mPlaces=new CustomToggleButton(this);
+        mRA=new CustomToggleButton(this);
+        mAreas=new CustomToggleButton(this);
+        mSensorLatency = new SelectButton(this, Settings.SENSORS_LATENCIES);
+        mCheat = newButton("Avoir toutes les ressources");
+        mReset = newButton("Supprimer la sauvegarde");
         mRoot = (LinearLayout)findViewById(R.id.root_layout);
-        addOptionBool("Données acceleromètre", mAccelerometer);
-        addOptionBool("Données GPS", mGPS);
-        addOptionBool("Distance Resources", mAreas);
-        addOptionBool("Resources affichés", mPlaces);
+        mOk = (Button)findViewById(R.id.sbutok);
+        addSelection("Latence des capteurs:", mSensorLatency, mRoot);
+        addAction("", mReset, mRoot);
+        addOptionBool("Mode Réalitée augmentée", mRA, mRoot);
+        addOptionBool("Mode développeur:", mDev, mRoot);
+        mRoot.addView(mRootDev);
+        addOptionBool("GPS préprogrammé:", mGPS, mRootDev);
+        addOptionBool("Afficher les zones:", mAreas, mRootDev);
+        addOptionBool("Afficher les ressources:", mPlaces, mRootDev);
+        addAction("", mCheat, mRootDev);
         preset();
     }
 
+    protected Button newButton(String text)
+    {
+        Button b = new Button(this);
+        b.setText(text);
+        b.setBackgroundResource(R.drawable.uibutton);
+        b.setTextColor(getResources().getColor(R.color.dull_4));
+        b.setOnClickListener(this);
+        return b;
+    }
 
+    private void reset()
+    {
+        final Activity context = this;
+        AlertDialog.Builder builder1 = new AlertDialog.Builder(this);
+        builder1.setMessage("Cette action va supprimer toute la sauvegarde. La progression dans le jeu reviendra donc a 0. Êtes-vous sûr de vouloir continuer ?");
+        builder1.setCancelable(true);
+
+        builder1.setPositiveButton(
+                "Supprimer",
+                new DialogInterface.OnClickListener() {
+                    public void onClick(DialogInterface dialog, int id) {
+                        Game.setGame(new Game("game_medium", context));
+                        Toast.makeText(context, "Suppression effectuée", Toast.LENGTH_SHORT);
+                        dialog.cancel();
+                    }
+                });
+
+        builder1.setNegativeButton(
+                "Ne pas supprimer",
+                new DialogInterface.OnClickListener() {
+                    public void onClick(DialogInterface dialog, int id) {
+                        dialog.cancel();
+                    }
+                });
+
+        AlertDialog alert11 = builder1.create();
+        alert11.show();
+    }
 
     public void onClick(View v)
     {
-        setResults();
-        finish();
+        if(v==mOk)
+        {
+            setResults();
+            finish();
+        }
+        else if(v==mReset)
+        {
+            reset();
+            setResults();
+        }else if(v==mCheat)
+        {
+            mGame.pickAllResoucres();
+        }
     }
 
-    public void addOptionBool(String name, ToggleButton v)
+    public void addOptionBool(String name, CustomToggleButton v, LinearLayout root)
     {
         LinearLayout ll = new LinearLayout(this);
         TextView tv = new TextView(this);
         tv.setText(name);
-        //tv.setBackgroundColor(0);
-        //tv.setTextSize(20);
-        //tv.setTextColor(0x33b5e5);
+        tv.setTextColor(getResources().getColor(R.color.dull_4));
 
         ll.setOrientation(LinearLayout.HORIZONTAL);
-        //v.setBackgroundColor(0);
         ll.addView(tv);
         ll.addView(v);
-        mRoot.addView(ll);
+        root.addView(ll);
+        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
+        lp.setMargins(30, 30, 25, 5);
+        ll.setLayoutParams(lp);
+        lp=new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
+        lp.setMargins(0, 0, 40 , 40);
+        tv.setLayoutParams(lp);
+        v.setLayoutParams(new LinearLayout.LayoutParams(150, 60));
+        newSeparator(root);
+    }
+
+    public void addAction(String name, Button v, LinearLayout root)
+    {
+        LinearLayout ll = new LinearLayout(this);
+        ll.setOrientation(LinearLayout.HORIZONTAL);
+        ll.addView(v);
+        root.addView(ll);
 
+        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
+        lp.setMargins(30, 30, 25, 5);
+        ll.setLayoutParams(lp);
+        v.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 60));
+        newSeparator(root);
     }
 
+    public void addSelection(String name, SelectButton v, LinearLayout root)
+    {
+        LinearLayout ll = new LinearLayout(this);
+        TextView tv = new TextView(this);
+        tv.setText(name);
+        tv.setTextColor(getResources().getColor(R.color.dull_4));
+
+        ll.setOrientation(LinearLayout.VERTICAL);
+        ll.addView(tv);
+        ll.addView(v);
+        root.addView(ll);
+        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
+        lp.setMargins(30, 30, 25, 5);
+        ll.setLayoutParams(lp);
+        lp=new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
+        lp.setMargins(90, 0, 0 , 0);
+        v.setLayoutParams(lp);
+        //v.setLayoutParams(new LinearLayout.LayoutParams(150, 60));
+        newSeparator(root);
+    }
 
+    public View newSeparator(LinearLayout root)
+    {
+        View v = new View(this);
+        v.setBackgroundColor(getResources().getColor(R.color.dull_3));
+        root.addView(v);
+        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 2);
+        lp.setMargins(30, 30, 0,0);
+        v.setLayoutParams(lp);
+        return v;
+    }
 
 
     private void setResults()
     {
-        mGame.getmSettings().setAccelerometerDebug(mAccelerometer.isChecked());
-        mGame.getmSettings().setAreaDebug(mAreas.isChecked());
-        mGame.getmSettings().setGPSDebug(mGPS.isChecked());
-        mGame.getmSettings().setResourceDebug(mPlaces.isChecked());
+        mGame.getmSettings().setDevelopperMode(mDev.getState());
+        mGame.getmSettings().setGPSDebug(mGPS.getState());
+        mGame.getmSettings().setAreaDebug(mAreas.getState());
+        mGame.getmSettings().setARMode(mRA.getState());
+        mGame.getmSettings().setResourceDebug(mPlaces.getState());
+        mGame.getmSettings().setSensorLatency(mSensorLatency.getState());
+        Settings.setSettings(mGame.getmSettings());
+        mGame.save(this);
+        mGame.getPlayer().newSensorManager(this);
+    }
+
+    private void updateVisibility()
+    {
+        int x = mDev.getState()?View.VISIBLE:View.GONE;
+        mRootDev.setVisibility(x);
     }
 
     private void preset()
     {
-        mAccelerometer.setChecked(mGame.getmSettings().isAccelerometerDebug());
-        mAreas.setChecked(mGame.getmSettings().isAreaDebug());
-        mGPS.setChecked(mGame.getmSettings().isGPSDebug());
-        mPlaces.setChecked(mGame.getmSettings().isResourceDebug());
+        mDev.setState(mGame.getmSettings().isDevelopperMode());
+        mGPS.setState(mGame.getmSettings().isGPSDebug());
+        mAreas.setState(mGame.getmSettings().isAreaDebug());
+        mPlaces.setState(mGame.getmSettings().isResourceDebug());
+        mRA.setState(mGame.getmSettings().isARMode());
+        mSensorLatency.setState(mGame.getmSettings().getSensorLatency());
+        updateVisibility();
+    }
+
+    @Override
+    public void onToggle(View v) {
+        if(v==mDev) updateVisibility();
     }
 
+    @Override
+    public void onOn(View v) {}
+
+    @Override
+    public void onOff(View v) {}
+
+
 }

+ 113 - 8
app/src/main/java/app/brest/testmin3d/ViewerActivity.java

@@ -4,12 +4,14 @@ import android.annotation.SuppressLint;
 import android.content.Intent;
 import android.net.Uri;
 import android.provider.ContactsContract;
+import android.support.v4.view.MotionEventCompat;
 import android.support.v7.app.ActionBar;
 import android.support.v7.app.AppCompatActivity;
 import android.os.Bundle;
 import android.os.Handler;
 import android.util.Log;
 import android.view.MotionEvent;
+import android.view.VelocityTracker;
 import android.view.View;
 import android.view.WindowManager;
 import android.widget.Button;
@@ -23,19 +25,23 @@ import java.io.InputStream;
 import java.util.ArrayList;
 
 import app.brest.utils.app.brest.game.Resource;
+import app.brest.utils.geometry.Point;
 import min3d.core.Object3d;
 import min3d.core.Object3dContainer;
 import min3d.core.RendererActivity;
 import min3d.parser.IParser;
 import min3d.parser.Parser;
+import min3d.vos.CameraVo;
 import min3d.vos.Light;
+import min3d.vos.Number3d;
 import uk.co.senab.photoview.PhotoViewAttacher;
+import uk.co.senab.photoview.log.LogManager;
 
 /**
  * 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 ViewerActivity extends RendererActivity {
+public class ViewerActivity extends RendererActivity implements View.OnTouchListener {
 
 
     private Resource mResource;
@@ -44,7 +50,12 @@ public class ViewerActivity extends RendererActivity {
     private Button mButton;
     private TextView mText;
     private PhotoViewAttacher mAttacher;
-
+    protected float mPreviousX;
+    protected float mPreviousY;
+    protected float mPreviousDist=0;
+    protected CameraVo mCamera = new CameraVo();
+    protected boolean mIsZooming = false;
+    protected boolean mIsMoving = false;
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -66,6 +77,7 @@ public class ViewerActivity extends RendererActivity {
         m_c.setVisibility(View.INVISIBLE);
         if(mResource != null && !getIntent().hasExtra("information") && !getIntent().hasExtra("map"))
         {
+            Log.e("______", "Type="+mResource.getType());
             title.setText(mResource.getTitle());
             if(mResource.getType().compareTo("Image")==0)
             {
@@ -73,9 +85,13 @@ public class ViewerActivity extends RendererActivity {
 
                 mImageView.setImageResource(id);
                 mAttacher = new PhotoViewAttacher(mImageView);
+                mAttacher.setMaximumScale(20);
             }
             else if(mResource.getType().compareTo("3D")==0) {
                 mFrameLayout.addView(_glSurfaceView);
+                mImageView.setVisibility(View.INVISIBLE);
+                VideoView mc = (VideoView)findViewById(R.id.vv_media);
+                mc.setVisibility(View.INVISIBLE);
             }else
             {
                 String path="android.resource://app.brest.testmin3d/raw/"+mResource.getName();
@@ -83,6 +99,7 @@ public class ViewerActivity extends RendererActivity {
                 else path+="_video";
                 mImageView.setVisibility(View.INVISIBLE);
                 _glSurfaceView.setVisibility(View.INVISIBLE);
+                _glSurfaceView.setOnTouchListener(this);
                 VideoView mc = (VideoView)findViewById(R.id.vv_media);
                 mc.setVisibility(View.VISIBLE);
                 Uri video = Uri.parse(path);
@@ -96,6 +113,7 @@ public class ViewerActivity extends RendererActivity {
             title.setText("Carte");
             mImageView.setImageResource(id);
             mAttacher = new PhotoViewAttacher(mImageView);
+            mAttacher.setMaximumScale(20);
             mButton.setVisibility(View.INVISIBLE);
         }
         else if(mResource != null && getIntent().hasExtra("information"))
@@ -106,10 +124,6 @@ public class ViewerActivity extends RendererActivity {
             mText.setText(mResource.getComment());
             //mFrameLayout.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT));
         }
-
-
-
-
     }
 
     public void onClickInfo(View v)
@@ -124,14 +138,18 @@ public class ViewerActivity extends RendererActivity {
     {
 
         scene.backgroundColor().setAll(0x00000000);
-        //scene.lights().add(new Light());
 
         Light myLight = new Light();
         myLight.position.setZ(150);
         myLight.position.setY(150);
         scene.lights().add(myLight);
         Object3d oo = mResource.get3DModel(this);
-        oo.position().z=-20;
+        oo.position().z=mResource.getPosition().z;
+        oo.position().y=mResource.getPosition().y;
+        oo.position().x=mResource.getPosition().x;
+        oo.position().z-=20;
+        mCamera.frustum.zFar(0.1f);
+        mCamera.frustum.zFar(1000);
         scene.addChild(mResource.get3DModel(this));
     }
 
@@ -140,4 +158,91 @@ public class ViewerActivity extends RendererActivity {
 
     }
 
+    public static String actionToString(int action) {
+        switch (action) {
+
+            case MotionEvent.ACTION_DOWN: return "Down";
+            case MotionEvent.ACTION_MOVE: return "Move";
+            case MotionEvent.ACTION_POINTER_DOWN: return "Pointer Down";
+            case MotionEvent.ACTION_UP: return "Up";
+            case MotionEvent.ACTION_POINTER_UP: return "Pointer Up";
+            case MotionEvent.ACTION_OUTSIDE: return "Outside";
+            case MotionEvent.ACTION_CANCEL: return "Cancel";
+        }
+        return "";
+    }
+
+    @Override
+    public boolean onTouch(View view, MotionEvent motionEvent) {
+        float x = motionEvent.getX();
+        float y = motionEvent.getY();
+        final int action = motionEvent.getAction()%256;
+        int index = MotionEventCompat.getActionIndex(motionEvent);
+        if (motionEvent.getPointerCount() > 1) {
+            switch (action) {
+                case MotionEvent.ACTION_MOVE:
+                {
+                    if(!mIsZooming) break;
+                    Point a = new Point(motionEvent.getX(0), motionEvent.getY(0));
+                    Point b = new Point(motionEvent.getX(1), motionEvent.getY(1));
+                    double d = a.getDistanceWith(b);
+                    double delta = d - mPreviousDist;
+                    mCamera.position.z+=delta/2;
+                    mPreviousDist = (float)a.getDistanceWith(b);
+                    scene.camera(mCamera);
+                    break;
+                }
+                case MotionEvent.ACTION_POINTER_DOWN:
+                case MotionEvent.ACTION_DOWN: {
+                    Point a = new Point(motionEvent.getX(0), motionEvent.getY(0));
+                    Point b = new Point(motionEvent.getX(1), motionEvent.getY(1));
+                    mPreviousDist = (float)a.getDistanceWith(b);
+                    mIsZooming=true;
+                    break;
+                }
+                case MotionEvent.ACTION_UP:
+                case MotionEvent.ACTION_POINTER_UP:
+                case MotionEvent.ACTION_CANCEL:
+                    mIsZooming=false;
+                    mIsMoving=false;
+                    break;
+            }
+
+
+        }
+        else {
+            mIsZooming=false;
+            switch (motionEvent.getAction()) {
+                case MotionEvent.ACTION_MOVE:
+                {
+                    if(!mIsMoving) break;
+                    float dx = x - mPreviousX;
+                    float dy = y - mPreviousY;
+                    Object3d oo = mResource.get3DModel(this);
+
+                    oo.rotation().y += dx / 3;
+                    oo.rotation().x += dy / 3;
+                    _glSurfaceView.requestRender();
+
+
+                    break;
+                }
+                case MotionEvent.ACTION_DOWN:
+                    mIsMoving=true;
+                    break;
+                case MotionEvent.ACTION_UP:
+                case MotionEvent.ACTION_CANCEL:
+                    mIsMoving=false;
+                    mIsZooming=false;
+                    break;
+            }
+            mPreviousX = x;
+            mPreviousY = y;
+        }
+
+
+        return true;
+
+    }
+
 }

+ 21 - 2
app/src/main/java/app/brest/utils/ResourceManager.java

@@ -23,11 +23,16 @@ public class ResourceManager implements Serializable{
     protected ArrayList<Resource> mResourcesLeft  = new ArrayList<Resource>();
     protected Resource mLatestResource = null;
     protected ArrayList<Resource> mResourcesPickedUp = new ArrayList<Resource>();
-    public ResourceManager(Game g, Activity act)
+    protected int mNStages;
+    public ResourceManager(ArrayList<Resource> x, int n)
     {
-        mAllResources = g.getAllResources(act);
+        mAllResources =x;
+        mNStages = n;
     }
 
+
+
+
     public Resource getResourceLeftByName(String name)
     {
         for(int i=0; i<mResourcesLeft.size(); i++)
@@ -98,6 +103,20 @@ public class ResourceManager implements Serializable{
         return mResourcesAquiered;
     }
 
+    public void pickAllResoucres()
+    {
+        mResourcesLeft.clear();
+        mResourcesAquiered.clear();
+        for(int i=0; i<mNStages; i++)
+        {
+            ArrayList<Resource> ar = new ArrayList<Resource>();
+            for(int j=0; j<mAllResources.size(); j++) {
+                if (mAllResources.get(j).getStage() == i + 1)
+                    ar.add(mAllResources.get(j));
+            }
+            mResourcesAquiered.add(ar);
+        }
+    }
 
     public void deleteAll3DModel()
     {

+ 65 - 9
app/src/main/java/app/brest/utils/SensorsManager.java

@@ -15,6 +15,7 @@ import android.os.Bundle;
 import android.provider.Settings;
 import android.support.v4.app.ActivityCompat;
 import android.support.v4.content.ContextCompat;
+import android.util.Log;
 import android.widget.Toast;
 
 import app.brest.testmin3d.ARActivity;
@@ -26,7 +27,7 @@ import app.brest.utils.geometry.GPSPoint;
  */
 public class SensorsManager implements SensorEventListener, LocationListener {
 
-    public final boolean USE_GPS_STUB=true;
+    //public final boolean USE_GPS_STUB=true;
     private SensorManager mSensorManager;
     private Sensor mAccelerometer;
     private Sensor mMagnetometer;
@@ -43,7 +44,6 @@ public class SensorsManager implements SensorEventListener, LocationListener {
     private SlideBuffer mBufferY;
     private SlideBuffer mBufferZ;
     private LocationManager mLocationManager;
-
     private double mLatitude;
     private double mLongitude;
     private float mAccuracy;
@@ -72,6 +72,11 @@ public class SensorsManager implements SensorEventListener, LocationListener {
         return getAzimuth();
     }
 
+    private boolean useGpsStub()
+    {
+        return app.brest.utils.Settings.getSettings().isGPSDebug();
+    }
+
     public GPSPoint getPosition()
     {
         if(!mIsLocalised) return null;
@@ -85,15 +90,66 @@ public class SensorsManager implements SensorEventListener, LocationListener {
         mSensorManager = (SensorManager) parent.getSystemService(parent.SENSOR_SERVICE);
         mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
         mMagnetometer = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
-        mBufferX = new SlideBuffer(64);
-        mBufferY = new SlideBuffer(8);
-        mBufferZ = new SlideBuffer(8);
+        mBufferX = new SlideBuffer(app.brest.utils.Settings.getSettings().getSensorLatency());
+        mBufferY = new SlideBuffer(app.brest.utils.Settings.getSettings().getSensorLatency());
+        mBufferZ = new SlideBuffer(app.brest.utils.Settings.getSettings().getSensorLatency());
 
         if (ActivityCompat.checkSelfPermission(mParent, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &&
                 ActivityCompat.checkSelfPermission(mParent, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
 
         }
-        if(!USE_GPS_STUB) {
+        if(!useGpsStub()) {
+            if (ContextCompat.checkSelfPermission(parent,
+                    Manifest.permission.CAMERA)
+                    != PackageManager.PERMISSION_GRANTED) {
+
+                // Should we show an explanation?
+                if (ActivityCompat.shouldShowRequestPermissionRationale(parent,
+                        Manifest.permission.CAMERA)) {
+                    Log.e("____", "OK");
+
+                    // Show an explanation to the user *asynchronously* -- don't block
+                    // this thread waiting for the user's response! After the user
+                    // sees the explanation, try again to request the permission.
+
+                } else {
+
+                    // No explanation needed, we can request the permission.
+                    Log.e("____", "Ask camera");
+                    ActivityCompat.requestPermissions(parent,
+                            new String[]{Manifest.permission.CAMERA},
+                            1338);
+
+                    // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
+                    // app-defined int constant. The callback method gets the
+                    // result of the request.
+                }
+            }
+            if (ContextCompat.checkSelfPermission(parent,
+                    Manifest.permission.ACCESS_FINE_LOCATION)
+                    != PackageManager.PERMISSION_GRANTED) {
+
+                // Should we show an explanation?
+                if (ActivityCompat.shouldShowRequestPermissionRationale(parent,
+                        Manifest.permission.ACCESS_FINE_LOCATION)) {
+
+                    // Show an explanation to the user *asynchronously* -- don't block
+                    // this thread waiting for the user's response! After the user
+                    // sees the explanation, try again to request the permission.
+
+                } else {
+
+                    // No explanation needed, we can request the permission.
+
+                    ActivityCompat.requestPermissions(parent,
+                            new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
+                            1337);
+
+                    // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
+                    // app-defined int constant. The callback method gets the
+                    // result of the request.
+                }
+            }
             if (ContextCompat.checkSelfPermission(parent, android.Manifest.permission.ACCESS_FINE_LOCATION) ==
                     PackageManager.PERMISSION_GRANTED &&
                     ContextCompat.checkSelfPermission(parent, android.Manifest.permission.ACCESS_COARSE_LOCATION) ==
@@ -104,7 +160,7 @@ public class SensorsManager implements SensorEventListener, LocationListener {
                 mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
             }
         }
-        if(USE_GPS_STUB) {
+        if(useGpsStub()) {
             mIsLocalised=true;
             mStub=new GpsStub(parent.getResources().getString(R.string.gps_stub));
             nextStub();
@@ -187,7 +243,7 @@ public class SensorsManager implements SensorEventListener, LocationListener {
     @Override
     public void onLocationChanged(Location location) {
         mIsLocalised=true;
-        if(!USE_GPS_STUB) {
+        if(!useGpsStub()) {
             mLongitude = location.getLongitude();
             mLatitude = location.getLatitude();
             mAccuracy = location.getAccuracy();
@@ -210,7 +266,7 @@ public class SensorsManager implements SensorEventListener, LocationListener {
 
     public void nextStub()
     {
-        if(USE_GPS_STUB)
+        if(useGpsStub())
         {
             GPSPoint stub = mStub.next();
             if(stub==null) return;

+ 38 - 5
app/src/main/java/app/brest/utils/Settings.java

@@ -9,12 +9,16 @@ import java.io.Serializable;
  */
 public class Settings implements Serializable{
 
+    transient static Settings mSettings = new Settings();
+
+    transient public static final String[] SENSORS_LATENCIES = {"Très rapide", "Rapide", "Normale", "Longue", "Très longue"};
     protected boolean mAccelerometerDebug = false;
     protected boolean mGPSDebug = false;
     protected boolean mAreaDebug = false;
     protected boolean mResourceDebug = false;
-
-
+    protected boolean mDevelopperMode = false;
+    protected int     mSensorLatency = 2; // 0 -> 4
+    protected boolean mARMode = true;
 
     public Settings()
     {
@@ -30,7 +34,7 @@ public class Settings implements Serializable{
     }
 
     public boolean isGPSDebug() {
-        return mGPSDebug;
+        return mDevelopperMode && mGPSDebug;
     }
 
     public void setGPSDebug(boolean mGPSDebug) {
@@ -38,7 +42,7 @@ public class Settings implements Serializable{
     }
 
     public boolean isAreaDebug() {
-        return mAreaDebug;
+        return mDevelopperMode && mAreaDebug;
     }
 
     public void setAreaDebug(boolean mAreaDebug) {
@@ -46,10 +50,39 @@ public class Settings implements Serializable{
     }
 
     public boolean isResourceDebug() {
-        return mResourceDebug;
+        return mDevelopperMode && mResourceDebug;
     }
 
     public void setResourceDebug(boolean mResourceDebug) {
         this.mResourceDebug = mResourceDebug;
     }
+
+    public boolean isDevelopperMode() {
+        return mDevelopperMode;
+    }
+
+    public void setDevelopperMode(boolean mDevelopperMode) {
+        this.mDevelopperMode = mDevelopperMode;
+    }
+
+    public int getSensorLatency() {
+        return mSensorLatency;
+    }
+
+    public void setSensorLatency(int mSensorLatency) {
+        this.mSensorLatency = mSensorLatency;
+    }
+
+    public boolean isARMode() {
+        return mARMode;
+    }
+
+    public void setARMode(boolean mARMode) {
+        this.mARMode = mARMode;
+    }
+
+    public static Settings getSettings() { return mSettings; }
+    public static void setSettings(Settings s){mSettings=s;}
+
+
 }

+ 11 - 4
app/src/main/java/app/brest/utils/SlideBuffer.java

@@ -32,23 +32,30 @@ public class SlideBuffer {
 public class SlideBuffer {
     private float mDataSin;
     private float mDataCos;
-    private final float COEF = 0.1f;
+    private float mCoef = 0.1f;
+    private final static float[] SENSORS_COEFS = {0.4f, 0.2f, 0.1f, 0.05f, 0.025f};
     private int mSize;
     private int mHead;
 
-    public SlideBuffer(int size)
+    public SlideBuffer(int latency_level)
     {
+        mCoef=SENSORS_COEFS[latency_level];
         mDataSin = 0;
         mDataCos = 0;
         mSize = 0;
         mHead =0;
     }
 
+    public void setLatencyLevel(int x)
+    {
+        mCoef=SENSORS_COEFS[x];
+    }
+
     public void enqueue(float _val)
     {
         float val = -_val-90;
-        mDataSin= mDataSin + COEF*((float)Math.sin(val*Math.PI/180)-mDataSin);
-        mDataCos= mDataCos + COEF*((float)Math.cos(val*Math.PI/180)-mDataCos);
+        mDataSin= mDataSin + mCoef*((float)Math.sin(val*Math.PI/180)-mDataSin);
+        mDataCos= mDataCos + mCoef*((float)Math.cos(val*Math.PI/180)-mDataCos);
     }
 
     public float average()

+ 26 - 2
app/src/main/java/app/brest/utils/app/brest/game/Game.java

@@ -50,7 +50,6 @@ public class Game  implements Serializable {
             JSONArray stages = root.getJSONArray("stages_list");
             for(int i=0; i<areas.length(); i++)
                 mAreas.add(new Area(areas.getJSONObject(i), act));
-            mResources = new ResourceManager(this, act);
             for(int i=0; i<stages.length(); i++) {
                 Stage s = new Stage(stages.getJSONObject(i));
                 Resource r = findResource(s.getResourceName());
@@ -58,6 +57,7 @@ public class Game  implements Serializable {
                 mStages.add(s);
             }
             findMaxStage();
+            mResources = new ResourceManager( getAllResources(act), mNStages);
             nextStage();
 
         } catch (JSONException e) {
@@ -174,6 +174,12 @@ public class Game  implements Serializable {
         return mCurrentStageAreas.size()==0;
     }
 
+    public void pickAllResoucres()
+    {
+        mResources.pickAllResoucres();
+        mCurrentStage=mNStages;
+    }
+
     public Resource getLatestResource()
     {
         return mResources.getLatestResource();
@@ -311,6 +317,25 @@ public class Game  implements Serializable {
     }
 
 
+    /*
+     *
+     * Fonction principale de positionnnemnt et orientation
+     *
+     */
+    public ArrayList<Area> getAreaNextToPlayer()
+    {
+        ArrayList<Area> r = new ArrayList<Area>();
+        for(int i=0; i<mCurrentStageAreas.size(); i++)
+        {
+            //probleme de GPS..
+            if(mCurrentStageAreas.get(i).isOnArea(mPlayer))
+                r.add(mCurrentStageAreas.get(i));
+
+        }
+        return r;
+    }
+
+
     /*
      *
      * Fonction principale de positionnnemnt et orientation
@@ -344,7 +369,6 @@ public class Game  implements Serializable {
 
     public String getResourcesNextToPlayerDist()
     {
-        String str = "Detected\n";
         double min=1000000000;
         ArrayList<Resource> r = new ArrayList<Resource>();
         for(int i=0; i<mCurrentStageAreas.size(); i++)

+ 12 - 0
app/src/main/java/app/brest/utils/app/brest/game/Resource.java

@@ -59,6 +59,18 @@ public class Resource implements Serializable {
         }
     }
 
+    public Number3d getPosition() {
+        return mPosition;
+    }
+
+    public Number3d getRotation() {
+        return mRotation;
+    }
+
+    public Number3d getScale() {
+        return mScale;
+    }
+
     public Resource(String name, Activity act)
     {
         mName=name;

+ 17 - 3
app/src/main/java/min3d/core/RendererActivity.java

@@ -7,6 +7,9 @@ import android.graphics.PixelFormat;
 import android.opengl.GLSurfaceView;
 import android.os.Bundle;
 import android.os.Handler;
+import android.util.Log;
+import android.view.MotionEvent;
+import android.view.View;
 
 /**
  * Extend this class when creating your min3d-based Activity. 
@@ -18,7 +21,7 @@ import android.os.Handler;
  * To update 3d scene-related variables from within the the main UI thread,  
  * override onUpdateScene() and onUpdateScene() as needed.
  */
-public class RendererActivity extends Activity implements ISceneController
+public class RendererActivity extends Activity implements ISceneController, View.OnTouchListener
 {
 	public Scene scene;
 	public Renderer mRender;
@@ -28,7 +31,8 @@ public class RendererActivity extends Activity implements ISceneController
 	protected Handler _updateSceneHander;
 	
     private boolean _renderContinuously;
-    
+    protected float mPreviousX;
+	protected float mPreviousY;
 
 	final Runnable _initSceneRunnable = new Runnable() 
 	{
@@ -69,7 +73,7 @@ public class RendererActivity extends Activity implements ISceneController
 		_glSurfaceView.setZOrderOnTop(true);
 		_glSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
 		_glSurfaceView.getHolder().setFormat(PixelFormat.RGBA_8888);
-
+		_glSurfaceView.setOnTouchListener(this);
 
 		//ici
 		Shared.context(this);
@@ -201,4 +205,14 @@ public class RendererActivity extends Activity implements ISceneController
     {
     	return _updateSceneRunnable;
     }
+
+	@Override
+	public boolean onTouch(View view, MotionEvent motionEvent) {
+		return true;
+	}
+
+	public void setOnToucheListener(View.OnTouchListener d)
+	{
+		_glSurfaceView.setOnTouchListener(d);
+	}
 }

BIN
app/src/main/res/drawable/aa.jpg


BIN
app/src/main/res/drawable/ab.jpg


BIN
app/src/main/res/drawable/ac.jpg


BIN
app/src/main/res/drawable/ad.jpg


BIN
app/src/main/res/drawable/ae.jpg


BIN
app/src/main/res/drawable/af.jpg


BIN
app/src/main/res/drawable/ag.jpg


BIN
app/src/main/res/drawable/ag_texture.jpg


BIN
app/src/main/res/drawable/ah.jpg


BIN
app/src/main/res/drawable/ah_texture.jpg


BIN
app/src/main/res/drawable/ba.jpg


BIN
app/src/main/res/drawable/bb.jpg


BIN
app/src/main/res/drawable/bc.jpg


BIN
app/src/main/res/drawable/bd.jpg


BIN
app/src/main/res/drawable/be.jpg


BIN
app/src/main/res/drawable/bf.jpg


BIN
app/src/main/res/drawable/bg.jpg


BIN
app/src/main/res/drawable/bg_texture.jpg


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


+ 7 - 20
app/src/main/res/layout/activity_main.xml

@@ -45,13 +45,16 @@
                 android:layout_height="191dp"
                 android:textAppearance="?android:attr/textAppearanceSmall"
                 android:text="Small Text"
-                android:id="@+id/text_place"
+                android:id="@+id/text_area"
                 android:layout_gravity="left|bottom"
                 android:textColor="#33b5e5"
-                android:layout_centerVertical="true"
                 android:layout_alignParentLeft="true"
                 android:layout_alignParentStart="true"
-                android:visibility="invisible" />
+                android:visibility="visible"
+                android:layout_below="@+id/angle"
+                android:layout_marginLeft="10dp"
+                android:layout_marginTop="-20dp"
+                android:lines="10" />
 
             <TextView
                 android:layout_width="match_parent"
@@ -61,27 +64,11 @@
                 android:id="@+id/text_detected"
                 android:layout_gravity="left|center_vertical"
                 android:textColor="#33b5e5"
-                android:layout_alignBottom="@+id/text_place"
+                android:layout_alignBottom="@+id/text_area"
                 android:layout_alignParentLeft="true"
                 android:layout_alignParentStart="true"
                 android:visibility="invisible" />
 
-            <TextView
-                android:layout_width="match_parent"
-                android:layout_height="60dp"
-                android:maxLines="3"
-                android:lines="15"
-                android:textAppearance="?android:attr/textAppearanceSmall"
-                android:text="Small Text"
-                android:id="@+id/gps"
-                android:layout_gravity="center_horizontal|bottom"
-                android:textColor="#33b5e5"
-                android:visibility="visible"
-                android:layout_alignTop="@+id/text_place"
-                android:layout_toRightOf="@+id/tv_angle"
-                android:layout_toEndOf="@+id/tv_angle"
-                android:layout_alignParentBottom="true" />
-
             <TextView
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"

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

@@ -0,0 +1,50 @@
+<FrameLayout 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:background="#0099cc"
+    tools:context="app.brest.testmin3d.PuzzleActivity">
+
+    <!-- The primary full-screen view. This can be replaced with whatever view
+         is needed to present your content, e.g. VideoView, SurfaceView,
+         TextureView, etc. -->
+    <TextView
+        android:id="@+id/fullscreen_content"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:gravity="center"
+        android:keepScreenOn="true"
+        android:text="@string/dummy_content"
+        android:textColor="#33b5e5"
+        android:textSize="50sp"
+        android:textStyle="bold" />
+
+    <!-- This FrameLayout insets its children based on system windows using
+         android:fitsSystemWindows. -->
+    <FrameLayout
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:fitsSystemWindows="true">
+
+        <LinearLayout
+            android:id="@+id/fullscreen_content_controls"
+            style="?metaButtonBarStyle"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_gravity="bottom|center_horizontal"
+            android:background="@color/black_overlay"
+            android:orientation="horizontal"
+            tools:ignore="UselessParent">
+
+            <Button
+                android:id="@+id/dummy_button"
+                style="?metaButtonBarButtonStyle"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:text="@string/dummy_button" />
+
+        </LinearLayout>
+    </FrameLayout>
+
+</FrameLayout>

+ 7 - 5
app/src/main/res/layout/activity_resource_list.xml

@@ -24,12 +24,14 @@
         android:textStyle="bold"
         android:textSize="30dp" />
 
-    <LinearLayout
-        android:orientation="vertical"
+    <ListView
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:id="@+id/list_layout">
-
-    </LinearLayout>
+        android:id="@+id/list_layout"
+        android:scrollingCache="true"
+        android:choiceMode="singleChoice"
+        android:fastScrollEnabled="true"
+        android:fastScrollAlwaysVisible="true"
+        android:longClickable="false" />
 
 </LinearLayout>

+ 40 - 23
app/src/main/res/layout/activity_settings.xml

@@ -9,35 +9,52 @@
         android:layout_width="match_parent"
         android:layout_height="match_parent">
 
-        <LinearLayout
-            android:orientation="vertical"
+        <Button
             android:layout_width="match_parent"
-            android:layout_height="493dp"
-            android:layout_gravity="center_horizontal"
-            android:id="@+id/root_layout"
-            android:layout_above="@+id/button3"
-            android:layout_alignParentTop="true"
-            android:measureWithLargestChild="false" >
+            android:layout_height="60dp"
+            android:text="OK"
+            android:id="@+id/sbutok"
+            android:layout_alignParentBottom="true"
+            android:layout_centerHorizontal="true"
+            android:onClick="onClick"
+            android:background="@drawable/uibutton"
+            android:textColor="#33b5e5"
+            android:textStyle="bold"
+            android:textSize="25dp" />
+
+        <ScrollView
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:id="@+id/scrollView"
+            android:layout_below="@+id/button7"
+            android:layout_alignParentLeft="true"
+            android:layout_alignParentStart="true"
+            android:layout_above="@+id/sbutok"
+            android:layout_alignParentRight="true"
+            android:layout_alignParentEnd="true">
 
-            <Button
+            <LinearLayout
+                android:orientation="vertical"
                 android:layout_width="match_parent"
-                android:layout_height="70dp"
-                android:text="Options"
-                android:id="@+id/button7"
+                android:layout_height="493dp"
                 android:layout_gravity="center_horizontal"
-                android:background="@drawable/title"
-                android:textStyle="bold"
-                android:textSize="30dp"
-                android:textColor="@color/dull_4" />
-        </LinearLayout>
+                android:id="@+id/root_layout"
+                android:layout_above="@+id/sbutok"
+                android:layout_alignParentTop="true"
+                android:measureWithLargestChild="false" >
+
+            </LinearLayout>
+        </ScrollView>
 
         <Button
             android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:text="OK"
-            android:id="@+id/button3"
-            android:layout_alignParentBottom="true"
-            android:layout_centerHorizontal="true"
-            android:onClick="onClick" />
+            android:layout_height="70dp"
+            android:text="Options"
+            android:id="@+id/button7"
+            android:layout_gravity="center_horizontal"
+            android:background="@drawable/title"
+            android:textStyle="bold"
+            android:textSize="30dp"
+            android:textColor="@color/dull_4" />
     </RelativeLayout>
 </LinearLayout>

+ 1 - 1
app/src/main/res/raw/bh_res

@@ -5,7 +5,7 @@
 	[
 		0,
 		0,
-		0
+		-30
 	],
 	"rotation" : 
 	[

+ 1 - 1
app/src/main/res/raw/ca_res

@@ -5,7 +5,7 @@
 	[
 		0,
 		0,
-		0
+		-5
 	],
 	"rotation" : 
 	[

+ 1 - 1
app/src/main/res/raw/cb_res

@@ -5,7 +5,7 @@
 	[
 		0,
 		0,
-		0
+		-10
 	],
 	"rotation" : 
 	[

+ 1 - 1
app/src/main/res/raw/ce_res

@@ -5,7 +5,7 @@
 	[
 		0,
 		0,
-		0
+		-15
 	],
 	"rotation" : 
 	[

+ 2 - 2
app/src/main/res/raw/cf_res

@@ -4,8 +4,8 @@
 	"position" : 
 	[
 		0,
-		0,
-		0
+		-5,
+		-10
 	],
 	"rotation" : 
 	[

+ 3 - 3
app/src/main/res/raw/cg_res

@@ -3,9 +3,9 @@
 	"name" : "cg",
 	"position" : 
 	[
-		0,
-		0,
-		0
+		-5,
+		-6,
+		-30
 	],
 	"rotation" : 
 	[

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

@@ -73,4 +73,6 @@
     <string name="gps_stub_bis">-1.6636940 48.0955401 ;</string>
     <string name="gps_stub">-4.4931557 48.3852982;-4.4907396 48.3822208;-4.4913189 48.3821055;-4.5009306 48.3812175;-4.4994088 48.3816246;-4.5001176 48.3829454;-4.4998877 48.3861891;-4.4993333 48.3843879;-4.4981522 48.3837466;-4.4940766 48.3855502;-4.4934548 48.3850800;-4.4920585 48.3832195;-4.4925920 48.3818895;-4.4974687 48.3831305;-4.4977893 48.3839475;-4.4936559 48.3832834;-4.4947957 48.3844682;-4.4944665 48.3851339;-4.4940462 48.3842496;-4.4926676 48.3835729;-4.4927382 48.3826774;-4.4972925 48.3835206;-4.4956640 48.3843096;-4.4980210 48.3844962;      </string>
     <string name="gps_stub_">-1.6636940 48.0955401 ;-1.6648474 48.0958025;-1.6649627 48.0958487;-1.6652739 48.0958718;-1.6658446 48.0954599;-1.6658503 48.0947939;-1.6649685 48.0953636;-1.6635852 48.0952597;-1.6637062 48.0954137;-1.6637927 48.0955215;-1.6639079 48.0956793;-1.6641270 48.0957178;-1.6642653 48.0956139;-1.6644785 48.0957216;</string>
+
+    <string name="title_activity_puzzle">PuzzleActivity</string>
 </resources>