Commit 0c3834bb3ee11fc10304d8cc79f9191993613dac
1 parent
60729503
Use string ressources, follow some Android best practices
Showing
7 changed files
with
20 additions
and
18 deletions
Show diff stats
app/src/main/AndroidManifest.xml
@@ -22,6 +22,7 @@ | @@ -22,6 +22,7 @@ | ||
22 | <action android:name="android.intent.action.MAIN" /> | 22 | <action android:name="android.intent.action.MAIN" /> |
23 | 23 | ||
24 | <category android:name="android.intent.category.LAUNCHER" /> | 24 | <category android:name="android.intent.category.LAUNCHER" /> |
25 | + | ||
25 | </intent-filter> | 26 | </intent-filter> |
26 | </activity> | 27 | </activity> |
27 | <activity | 28 | <activity |
app/src/main/java/fr/utbm/lo53/p2017/positionningapp/AppCompatPreferenceActivity.java
@@ -4,6 +4,7 @@ import android.content.res.Configuration; | @@ -4,6 +4,7 @@ import android.content.res.Configuration; | ||
4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
5 | import android.preference.PreferenceActivity; | 5 | import android.preference.PreferenceActivity; |
6 | import android.support.annotation.LayoutRes; | 6 | import android.support.annotation.LayoutRes; |
7 | +import android.support.annotation.NonNull; | ||
7 | import android.support.annotation.Nullable; | 8 | import android.support.annotation.Nullable; |
8 | import android.support.v7.app.ActionBar; | 9 | import android.support.v7.app.ActionBar; |
9 | import android.support.v7.app.AppCompatDelegate; | 10 | import android.support.v7.app.AppCompatDelegate; |
@@ -42,6 +43,7 @@ public abstract class AppCompatPreferenceActivity extends PreferenceActivity { | @@ -42,6 +43,7 @@ public abstract class AppCompatPreferenceActivity extends PreferenceActivity { | ||
42 | } | 43 | } |
43 | 44 | ||
44 | @Override | 45 | @Override |
46 | + @NonNull | ||
45 | public MenuInflater getMenuInflater() { | 47 | public MenuInflater getMenuInflater() { |
46 | return getDelegate().getMenuInflater(); | 48 | return getDelegate().getMenuInflater(); |
47 | } | 49 | } |
app/src/main/java/fr/utbm/lo53/p2017/positionningapp/PositioningActivity.java
1 | package fr.utbm.lo53.p2017.positionningapp; | 1 | package fr.utbm.lo53.p2017.positionningapp; |
2 | 2 | ||
3 | -import android.content.Context; | ||
4 | import android.graphics.Bitmap; | 3 | import android.graphics.Bitmap; |
5 | -import android.net.wifi.WifiInfo; | ||
6 | -import android.net.wifi.WifiManager; | ||
7 | -import android.os.Build; | ||
8 | import android.os.Bundle; | 4 | import android.os.Bundle; |
9 | import android.os.Handler; | 5 | import android.os.Handler; |
10 | import android.support.constraint.ConstraintLayout; | 6 | import android.support.constraint.ConstraintLayout; |
@@ -18,7 +14,6 @@ import android.view.animation.AccelerateInterpolator; | @@ -18,7 +14,6 @@ import android.view.animation.AccelerateInterpolator; | ||
18 | import android.view.animation.AlphaAnimation; | 14 | import android.view.animation.AlphaAnimation; |
19 | import android.view.animation.Animation; | 15 | import android.view.animation.Animation; |
20 | import android.view.animation.AnimationUtils; | 16 | import android.view.animation.AnimationUtils; |
21 | -import android.view.animation.RotateAnimation; | ||
22 | import android.widget.ImageView; | 17 | import android.widget.ImageView; |
23 | 18 | ||
24 | import com.android.volley.Request; | 19 | import com.android.volley.Request; |
@@ -32,10 +27,6 @@ import com.android.volley.toolbox.Volley; | @@ -32,10 +27,6 @@ import com.android.volley.toolbox.Volley; | ||
32 | import org.json.JSONException; | 27 | import org.json.JSONException; |
33 | import org.json.JSONObject; | 28 | import org.json.JSONObject; |
34 | 29 | ||
35 | -import java.net.NetworkInterface; | ||
36 | -import java.net.SocketException; | ||
37 | -import java.util.Collections; | ||
38 | -import java.util.List; | ||
39 | import java.util.Random; | 30 | import java.util.Random; |
40 | 31 | ||
41 | public class PositioningActivity extends BaseActivity { | 32 | public class PositioningActivity extends BaseActivity { |
@@ -183,13 +174,14 @@ public class PositioningActivity extends BaseActivity { | @@ -183,13 +174,14 @@ public class PositioningActivity extends BaseActivity { | ||
183 | return (this.mapId != null && this.mapId.equals(mapId)); | 174 | return (this.mapId != null && this.mapId.equals(mapId)); |
184 | } | 175 | } |
185 | 176 | ||
186 | - private void getMap(int mapId) { | 177 | + private void getMap(final int mapId) { |
187 | mapView.setVisibility(View.INVISIBLE); | 178 | mapView.setVisibility(View.INVISIBLE); |
188 | ImageRequest mapRequest = new ImageRequest( | 179 | ImageRequest mapRequest = new ImageRequest( |
189 | getURLSolver().mapBytesURL(mapId), | 180 | getURLSolver().mapBytesURL(mapId), |
190 | new Response.Listener<Bitmap>() { | 181 | new Response.Listener<Bitmap>() { |
191 | @Override | 182 | @Override |
192 | public void onResponse(Bitmap bitmap) { | 183 | public void onResponse(Bitmap bitmap) { |
184 | + PositioningActivity.this.mapId = mapId; | ||
193 | mapView.setImageBitmap(bitmap); | 185 | mapView.setImageBitmap(bitmap); |
194 | mapView.setVisibility(View.VISIBLE); | 186 | mapView.setVisibility(View.VISIBLE); |
195 | Snackbar.make(mapView, "You need to set a point before measurement.", Snackbar.LENGTH_LONG) | 187 | Snackbar.make(mapView, "You need to set a point before measurement.", Snackbar.LENGTH_LONG) |
app/src/main/res/layout/content_calibration.xml
@@ -18,7 +18,7 @@ | @@ -18,7 +18,7 @@ | ||
18 | android:layout_marginStart="8dp" | 18 | android:layout_marginStart="8dp" |
19 | android:layout_marginTop="50dp" | 19 | android:layout_marginTop="50dp" |
20 | android:adjustViewBounds="true" | 20 | android:adjustViewBounds="true" |
21 | - android:paddingLeft="0dp" | 21 | + android:paddingStart="0dp" |
22 | android:paddingTop="0dp" | 22 | android:paddingTop="0dp" |
23 | android:scaleType="fitXY" | 23 | android:scaleType="fitXY" |
24 | app:layout_constraintHorizontal_bias="0.0" | 24 | app:layout_constraintHorizontal_bias="0.0" |
@@ -52,7 +52,7 @@ | @@ -52,7 +52,7 @@ | ||
52 | android:layout_marginLeft="8dp" | 52 | android:layout_marginLeft="8dp" |
53 | android:layout_marginRight="8dp" | 53 | android:layout_marginRight="8dp" |
54 | android:layout_marginStart="8dp" | 54 | android:layout_marginStart="8dp" |
55 | - android:text="Set Point" | 55 | + android:text="@string/set_point" |
56 | app:layout_constraintHorizontal_bias="0.0" | 56 | app:layout_constraintHorizontal_bias="0.0" |
57 | app:layout_constraintLeft_toLeftOf="parent" | 57 | app:layout_constraintLeft_toLeftOf="parent" |
58 | app:layout_constraintRight_toRightOf="parent" | 58 | app:layout_constraintRight_toRightOf="parent" |
@@ -67,7 +67,7 @@ | @@ -67,7 +67,7 @@ | ||
67 | android:layout_marginLeft="8dp" | 67 | android:layout_marginLeft="8dp" |
68 | android:layout_marginRight="8dp" | 68 | android:layout_marginRight="8dp" |
69 | android:layout_marginStart="8dp" | 69 | android:layout_marginStart="8dp" |
70 | - android:text="Cancel" | 70 | + android:text="@string/Cancel" |
71 | app:layout_constraintLeft_toLeftOf="parent" | 71 | app:layout_constraintLeft_toLeftOf="parent" |
72 | app:layout_constraintRight_toRightOf="parent" | 72 | app:layout_constraintRight_toRightOf="parent" |
73 | app:layout_constraintHorizontal_bias="0.0" | 73 | app:layout_constraintHorizontal_bias="0.0" |
@@ -83,7 +83,7 @@ | @@ -83,7 +83,7 @@ | ||
83 | android:layout_marginRight="8dp" | 83 | android:layout_marginRight="8dp" |
84 | android:layout_marginStart="8dp" | 84 | android:layout_marginStart="8dp" |
85 | android:onClick="sendCalibrateRequest" | 85 | android:onClick="sendCalibrateRequest" |
86 | - android:text="Measure" | 86 | + android:text="@string/Measure" |
87 | app:layout_constraintLeft_toLeftOf="parent" | 87 | app:layout_constraintLeft_toLeftOf="parent" |
88 | app:layout_constraintRight_toRightOf="parent" | 88 | app:layout_constraintRight_toRightOf="parent" |
89 | app:layout_constraintHorizontal_bias="0.0" | 89 | app:layout_constraintHorizontal_bias="0.0" |
app/src/main/res/layout/content_positioning.xml
@@ -73,9 +73,10 @@ | @@ -73,9 +73,10 @@ | ||
73 | android:layout_marginLeft="8dp" | 73 | android:layout_marginLeft="8dp" |
74 | android:layout_marginRight="8dp" | 74 | android:layout_marginRight="8dp" |
75 | android:layout_marginTop="8dp" | 75 | android:layout_marginTop="8dp" |
76 | - android:text="Start locating" | ||
77 | - android:textAppearance="@android:style/TextAppearance.Material.Display2" | 76 | + android:text="@string/start_locating" |
77 | + android:textAppearance="@style/TextAppearance.AppCompat.Large" | ||
78 | android:textColor="@color/colorAccent" | 78 | android:textColor="@color/colorAccent" |
79 | + android:textSize="40sp" | ||
79 | app:layout_constraintBottom_toBottomOf="@+id/hiding_image" | 80 | app:layout_constraintBottom_toBottomOf="@+id/hiding_image" |
80 | app:layout_constraintLeft_toLeftOf="parent" | 81 | app:layout_constraintLeft_toLeftOf="parent" |
81 | app:layout_constraintRight_toRightOf="parent" | 82 | app:layout_constraintRight_toRightOf="parent" |
app/src/main/res/values/colors.xml
@@ -2,5 +2,5 @@ | @@ -2,5 +2,5 @@ | ||
2 | <resources> | 2 | <resources> |
3 | <color name="colorPrimary">#3F51B5</color> | 3 | <color name="colorPrimary">#3F51B5</color> |
4 | <color name="colorPrimaryDark">#303F9F</color> | 4 | <color name="colorPrimaryDark">#303F9F</color> |
5 | - <color name="colorAccent">#FF4081</color> | 5 | + <color name="colorAccent">#ff4081</color> |
6 | </resources> | 6 | </resources> |
app/src/main/res/values/strings.xml
1 | <resources> | 1 | <resources> |
2 | - <string name="app_name">PositionningApp</string> | 2 | + <string name="app_name">PositioningApp</string> |
3 | <string name="action_settings">Settings</string> | 3 | <string name="action_settings">Settings</string> |
4 | <string name="title_activity_settings">Settings</string> | 4 | <string name="title_activity_settings">Settings</string> |
5 | 5 | ||
@@ -91,4 +91,10 @@ | @@ -91,4 +91,10 @@ | ||
91 | 91 | ||
92 | <string name="pref_title_port">Port</string> | 92 | <string name="pref_title_port">Port</string> |
93 | <string name="pref_default_port">8080</string> | 93 | <string name="pref_default_port">8080</string> |
94 | + | ||
95 | + | ||
96 | + <string name="set_point">Set point</string> | ||
97 | + <string name="Cancel">Cancel</string> | ||
98 | + <string name="Measure">Measure</string> | ||
99 | + <string name="start_locating">Start locating</string> | ||
94 | </resources> | 100 | </resources> |