Commit d97143003beb84c7c302d1e0bab2ec23cb39d51d

Authored by FatBaz
1 parent 8f4ef1c3

Change Map + the way to put the map marker on the Map (X is still to fix but is almost good)

app/src/main/java/fr/utbm/lo53/p2017/positionningapp/Calibration.java
@@ -14,7 +14,7 @@ import android.widget.Button; @@ -14,7 +14,7 @@ import android.widget.Button;
14 import android.widget.ImageView; 14 import android.widget.ImageView;
15 15
16 public class Calibration extends BaseActivity { 16 public class Calibration extends BaseActivity {
17 - 17 + float height,width;
18 @Override 18 @Override
19 protected void onCreate(Bundle savedInstanceState) { 19 protected void onCreate(Bundle savedInstanceState) {
20 20
@@ -23,15 +23,6 @@ public class Calibration extends BaseActivity { @@ -23,15 +23,6 @@ public class Calibration extends BaseActivity {
23 Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 23 Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
24 setSupportActionBar(toolbar); 24 setSupportActionBar(toolbar);
25 25
26 - FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);  
27 - fab.setOnClickListener(new View.OnClickListener() {  
28 - @Override  
29 - public void onClick(View view) {  
30 - Snackbar.make(view, "Salut ! :) Ce bouton ne sert à rien.", Snackbar.LENGTH_LONG)  
31 - .setAction("Action", null).show();  
32 - }  
33 - });  
34 -  
35 final ImageView Map = (ImageView) findViewById(R.id.Map); 26 final ImageView Map = (ImageView) findViewById(R.id.Map);
36 final ImageView MapMarker = (ImageView) findViewById(R.id.MapMarker); 27 final ImageView MapMarker = (ImageView) findViewById(R.id.MapMarker);
37 final Button setPointButton = (Button) findViewById(R.id.setPointButton); 28 final Button setPointButton = (Button) findViewById(R.id.setPointButton);
@@ -42,16 +33,20 @@ public class Calibration extends BaseActivity { @@ -42,16 +33,20 @@ public class Calibration extends BaseActivity {
42 cancelButton.setVisibility(cancelButton.INVISIBLE); 33 cancelButton.setVisibility(cancelButton.INVISIBLE);
43 measureButton.setVisibility(measureButton.INVISIBLE); 34 measureButton.setVisibility(measureButton.INVISIBLE);
44 35
  36 + //Map.setMaxHeight(50);
  37 +
45 Map.setOnTouchListener(new View.OnTouchListener() { 38 Map.setOnTouchListener(new View.OnTouchListener() {
46 @Override 39 @Override
47 public boolean onTouch(View view, MotionEvent motionEvent) { 40 public boolean onTouch(View view, MotionEvent motionEvent) {
48 /*motionEvent.getAction()==motionEvent.ACTION_MOVE &&*/ 41 /*motionEvent.getAction()==motionEvent.ACTION_MOVE &&*/
49 if( setPointButton.getVisibility() == setPointButton.INVISIBLE && motionEvent.getX() <= Map.getWidth() && motionEvent.getY() <= Map.getHeight() && motionEvent.getX() >= 0 && motionEvent.getY() >= 0) { 42 if( setPointButton.getVisibility() == setPointButton.INVISIBLE && motionEvent.getX() <= Map.getWidth() && motionEvent.getY() <= Map.getHeight() && motionEvent.getX() >= 0 && motionEvent.getY() >= 0) {
50 MapMarker.setVisibility(MapMarker.VISIBLE); 43 MapMarker.setVisibility(MapMarker.VISIBLE);
51 - Snackbar.make(view, " X : " + motionEvent.getX() + " Y : " + motionEvent.getY(), Snackbar.LENGTH_LONG) 44 + height = motionEvent.getX();
  45 + width = motionEvent.getY();
  46 + Snackbar.make(view, " X : " + height + " Y : " + width, Snackbar.LENGTH_LONG)
52 .setAction("Action", null).show(); 47 .setAction("Action", null).show();
53 - MapMarker.setX(motionEvent.getX()-(MapMarker.getWidth()/4));  
54 - MapMarker.setY(motionEvent.getY()); 48 + MapMarker.setX(motionEvent.getX()- (view.getWidth()- Map.getWidth())/2 -40);//- MapMarker.getWidth()/2);
  49 + MapMarker.setY(motionEvent.getY()+ (view.getHeight()/5));//+(MapMarker.getWidth()/(5/4)));
55 } 50 }
56 return true; 51 return true;
57 } 52 }
@@ -84,7 +79,7 @@ public class Calibration extends BaseActivity { @@ -84,7 +79,7 @@ public class Calibration extends BaseActivity {
84 } 79 }
85 }); 80 });
86 } 81 }
87 - 82 +
88 @Override 83 @Override
89 public boolean onCreateOptionsMenu(Menu menu) { 84 public boolean onCreateOptionsMenu(Menu menu) {
90 super.onCreateOptionsMenu(menu); 85 super.onCreateOptionsMenu(menu);
@@ -93,18 +88,8 @@ public class Calibration extends BaseActivity { @@ -93,18 +88,8 @@ public class Calibration extends BaseActivity {
93 return true; 88 return true;
94 } 89 }
95 90
96 - @Override  
97 - public boolean onOptionsItemSelected(MenuItem item) {  
98 - // Handle action bar item clicks here. The action bar will  
99 - // automatically handle clicks on the Home/Up button, so long  
100 - // as you specify a parent activity in AndroidManifest.xml.  
101 - int id = item.getItemId();  
102 -  
103 - //noinspection SimplifiableIfStatement  
104 - if (id == R.id.action_settings) {  
105 - return true;  
106 - }  
107 -  
108 - return super.onOptionsItemSelected(item); 91 + public void sendCalibrateRequest(View v) {
  92 + Snackbar.make(v, "Coucou, X :" + height + " Y : " + width, Snackbar.LENGTH_LONG)
  93 + .setAction("Action", null).show();
109 } 94 }
110 } 95 }
app/src/main/java/fr/utbm/lo53/p2017/positionningapp/TranslateCoordinate.java 0 → 100644
  1 +package fr.utbm.lo53.p2017.positionningapp;
  2 +
  3 +/**
  4 + * Created by Valentin on 14/06/2017.
  5 + */
  6 +
  7 +public class TranslateCoordinate {
  8 + private int mapWidth, mapHeight;
  9 + public class Point {
  10 + float x,y;
  11 + }
  12 + public Point PointToGeo(float xA, float yA)
  13 + {
  14 + Point p = new Point();
  15 + p.x = (xA/mapWidth)*100;
  16 + p.y = (yA/mapWidth)*100;
  17 + return p;
  18 + }
  19 +}
0 \ No newline at end of file 20 \ No newline at end of file
app/src/main/res/drawable/map.png

4.55 KB | W: | H:

24.3 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
app/src/main/res/drawable/map2.png 0 → 100644

4.55 KB

app/src/main/res/layout/activity_calibration.xml
@@ -23,12 +23,4 @@ @@ -23,12 +23,4 @@
23 23
24 <include layout="@layout/content_calibration"/> 24 <include layout="@layout/content_calibration"/>
25 25
26 - <android.support.design.widget.FloatingActionButton  
27 - android:id="@+id/fab"  
28 - android:layout_width="wrap_content"  
29 - android:layout_height="wrap_content"  
30 - android:layout_gravity="bottom|end"  
31 - android:layout_margin="@dimen/fab_margin"  
32 - app:srcCompat="@android:drawable/ic_dialog_email" />  
33 -  
34 </android.support.design.widget.CoordinatorLayout> 26 </android.support.design.widget.CoordinatorLayout>
app/src/main/res/layout/content_calibration.xml
@@ -12,78 +12,85 @@ @@ -12,78 +12,85 @@
12 android:id="@+id/Map" 12 android:id="@+id/Map"
13 android:layout_width="0dp" 13 android:layout_width="0dp"
14 android:layout_height="wrap_content" 14 android:layout_height="wrap_content"
  15 + android:layout_marginBottom="6dp"
  16 + android:layout_marginEnd="8dp"
15 android:layout_marginLeft="8dp" 17 android:layout_marginLeft="8dp"
16 android:layout_marginRight="8dp" 18 android:layout_marginRight="8dp"
17 - android:layout_marginTop="50dp"  
18 - android:paddingLeft="0dp"  
19 - android:paddingTop="0dp"  
20 - android:scaleType="fitXY" 19 + android:layout_marginStart="8dp"
  20 + android:layout_marginTop="8dp"
  21 + android:adjustViewBounds="true"
  22 + app:layout_constraintBottom_toTopOf="@+id/measureButton"
21 app:layout_constraintHorizontal_bias="0.0" 23 app:layout_constraintHorizontal_bias="0.0"
22 app:layout_constraintLeft_toLeftOf="parent" 24 app:layout_constraintLeft_toLeftOf="parent"
23 app:layout_constraintRight_toRightOf="parent" 25 app:layout_constraintRight_toRightOf="parent"
24 app:layout_constraintTop_toTopOf="parent" 26 app:layout_constraintTop_toTopOf="parent"
25 - app:srcCompat="@drawable/map"  
26 - android:layout_marginStart="8dp"  
27 - android:layout_marginEnd="8dp" /> 27 + app:layout_constraintVertical_bias="0.505"
  28 + app:srcCompat="@drawable/map" />
28 29
29 <ImageView 30 <ImageView
30 android:id="@+id/MapMarker" 31 android:id="@+id/MapMarker"
31 - android:layout_width="42dp"  
32 - android:layout_height="46dp"  
33 - app:srcCompat="@drawable/map_marker"  
34 - android:layout_marginRight="8dp"  
35 - app:layout_constraintRight_toRightOf="parent" 32 + android:layout_width="0dp"
  33 + android:layout_height="50dp"
  34 + android:layout_marginEnd="8dp"
36 android:layout_marginLeft="8dp" 35 android:layout_marginLeft="8dp"
  36 + android:layout_marginRight="8dp"
  37 + android:layout_marginStart="8dp"
  38 + android:adjustViewBounds="false"
  39 + android:cropToPadding="false"
  40 + app:layout_constraintHorizontal_bias="0.15"
37 app:layout_constraintLeft_toLeftOf="parent" 41 app:layout_constraintLeft_toLeftOf="parent"
  42 + app:layout_constraintRight_toRightOf="parent"
  43 + app:srcCompat="@drawable/map_marker"
38 app:layout_constraintTop_toTopOf="@+id/Map" 44 app:layout_constraintTop_toTopOf="@+id/Map"
39 android:layout_marginTop="8dp" 45 android:layout_marginTop="8dp"
40 app:layout_constraintBottom_toBottomOf="@+id/Map" 46 app:layout_constraintBottom_toBottomOf="@+id/Map"
41 - android:layout_marginBottom="8dp"  
42 - android:layout_marginStart="8dp"  
43 - android:layout_marginEnd="8dp" /> 47 + android:layout_marginBottom="8dp" />
44 48
45 <Button 49 <Button
46 android:id="@+id/setPointButton" 50 android:id="@+id/setPointButton"
47 style="@style/Widget.AppCompat.Button" 51 style="@style/Widget.AppCompat.Button"
48 - android:layout_width="match_parent" 52 + android:layout_width="0dp"
49 android:layout_height="wrap_content" 53 android:layout_height="wrap_content"
50 android:layout_marginEnd="8dp" 54 android:layout_marginEnd="8dp"
51 android:layout_marginLeft="8dp" 55 android:layout_marginLeft="8dp"
52 android:layout_marginRight="8dp" 56 android:layout_marginRight="8dp"
53 android:layout_marginStart="8dp" 57 android:layout_marginStart="8dp"
54 - android:layout_marginTop="50dp"  
55 android:text="Set Point" 58 android:text="Set Point"
56 app:layout_constraintHorizontal_bias="0.0" 59 app:layout_constraintHorizontal_bias="0.0"
57 app:layout_constraintLeft_toLeftOf="parent" 60 app:layout_constraintLeft_toLeftOf="parent"
58 app:layout_constraintRight_toRightOf="parent" 61 app:layout_constraintRight_toRightOf="parent"
59 - app:layout_constraintTop_toBottomOf="@+id/Map" /> 62 + android:layout_marginBottom="8dp"
  63 + app:layout_constraintBottom_toTopOf="@+id/cancelButton" />
60 64
61 <Button 65 <Button
62 android:id="@+id/cancelButton" 66 android:id="@+id/cancelButton"
63 - android:layout_width="match_parent" 67 + android:layout_width="0dp"
64 android:layout_height="wrap_content" 68 android:layout_height="wrap_content"
65 android:layout_marginEnd="8dp" 69 android:layout_marginEnd="8dp"
66 android:layout_marginLeft="8dp" 70 android:layout_marginLeft="8dp"
67 android:layout_marginRight="8dp" 71 android:layout_marginRight="8dp"
68 android:layout_marginStart="8dp" 72 android:layout_marginStart="8dp"
69 - android:layout_marginTop="8dp"  
70 android:text="Cancel" 73 android:text="Cancel"
71 app:layout_constraintLeft_toLeftOf="parent" 74 app:layout_constraintLeft_toLeftOf="parent"
72 app:layout_constraintRight_toRightOf="parent" 75 app:layout_constraintRight_toRightOf="parent"
73 - app:layout_constraintTop_toBottomOf="@+id/measureButton" /> 76 + app:layout_constraintHorizontal_bias="0.0"
  77 + app:layout_constraintBottom_toBottomOf="parent"
  78 + android:layout_marginBottom="8dp" />
74 79
75 <Button 80 <Button
76 android:id="@+id/measureButton" 81 android:id="@+id/measureButton"
77 - android:layout_width="match_parent" 82 + android:layout_width="0dp"
78 android:layout_height="wrap_content" 83 android:layout_height="wrap_content"
79 android:layout_marginEnd="8dp" 84 android:layout_marginEnd="8dp"
80 android:layout_marginLeft="8dp" 85 android:layout_marginLeft="8dp"
81 android:layout_marginRight="8dp" 86 android:layout_marginRight="8dp"
82 android:layout_marginStart="8dp" 87 android:layout_marginStart="8dp"
83 - android:layout_marginTop="50dp" 88 + android:onClick="sendCalibrateRequest"
84 android:text="Measure" 89 android:text="Measure"
85 app:layout_constraintLeft_toLeftOf="parent" 90 app:layout_constraintLeft_toLeftOf="parent"
86 app:layout_constraintRight_toRightOf="parent" 91 app:layout_constraintRight_toRightOf="parent"
87 - app:layout_constraintTop_toBottomOf="@+id/Map" /> 92 + app:layout_constraintHorizontal_bias="0.0"
  93 + android:layout_marginBottom="8dp"
  94 + app:layout_constraintBottom_toTopOf="@+id/cancelButton" />
88 95
89 </android.support.constraint.ConstraintLayout> 96 </android.support.constraint.ConstraintLayout>