Commit 0c3834bb3ee11fc10304d8cc79f9191993613dac

Authored by florian staine
1 parent 60729503

Use string ressources, follow some Android best practices

app/src/main/AndroidManifest.xml
... ... @@ -22,6 +22,7 @@
22 22 <action android:name="android.intent.action.MAIN" />
23 23  
24 24 <category android:name="android.intent.category.LAUNCHER" />
  25 +
25 26 </intent-filter>
26 27 </activity>
27 28 <activity
... ...
app/src/main/java/fr/utbm/lo53/p2017/positionningapp/AppCompatPreferenceActivity.java
... ... @@ -4,6 +4,7 @@ import android.content.res.Configuration;
4 4 import android.os.Bundle;
5 5 import android.preference.PreferenceActivity;
6 6 import android.support.annotation.LayoutRes;
  7 +import android.support.annotation.NonNull;
7 8 import android.support.annotation.Nullable;
8 9 import android.support.v7.app.ActionBar;
9 10 import android.support.v7.app.AppCompatDelegate;
... ... @@ -42,6 +43,7 @@ public abstract class AppCompatPreferenceActivity extends PreferenceActivity {
42 43 }
43 44  
44 45 @Override
  46 + @NonNull
45 47 public MenuInflater getMenuInflater() {
46 48 return getDelegate().getMenuInflater();
47 49 }
... ...
app/src/main/java/fr/utbm/lo53/p2017/positionningapp/PositioningActivity.java
1 1 package fr.utbm.lo53.p2017.positionningapp;
2 2  
3   -import android.content.Context;
4 3 import android.graphics.Bitmap;
5   -import android.net.wifi.WifiInfo;
6   -import android.net.wifi.WifiManager;
7   -import android.os.Build;
8 4 import android.os.Bundle;
9 5 import android.os.Handler;
10 6 import android.support.constraint.ConstraintLayout;
... ... @@ -18,7 +14,6 @@ import android.view.animation.AccelerateInterpolator;
18 14 import android.view.animation.AlphaAnimation;
19 15 import android.view.animation.Animation;
20 16 import android.view.animation.AnimationUtils;
21   -import android.view.animation.RotateAnimation;
22 17 import android.widget.ImageView;
23 18  
24 19 import com.android.volley.Request;
... ... @@ -32,10 +27,6 @@ import com.android.volley.toolbox.Volley;
32 27 import org.json.JSONException;
33 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 30 import java.util.Random;
40 31  
41 32 public class PositioningActivity extends BaseActivity {
... ... @@ -183,13 +174,14 @@ public class PositioningActivity extends BaseActivity {
183 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 178 mapView.setVisibility(View.INVISIBLE);
188 179 ImageRequest mapRequest = new ImageRequest(
189 180 getURLSolver().mapBytesURL(mapId),
190 181 new Response.Listener<Bitmap>() {
191 182 @Override
192 183 public void onResponse(Bitmap bitmap) {
  184 + PositioningActivity.this.mapId = mapId;
193 185 mapView.setImageBitmap(bitmap);
194 186 mapView.setVisibility(View.VISIBLE);
195 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 18 android:layout_marginStart="8dp"
19 19 android:layout_marginTop="50dp"
20 20 android:adjustViewBounds="true"
21   - android:paddingLeft="0dp"
  21 + android:paddingStart="0dp"
22 22 android:paddingTop="0dp"
23 23 android:scaleType="fitXY"
24 24 app:layout_constraintHorizontal_bias="0.0"
... ... @@ -52,7 +52,7 @@
52 52 android:layout_marginLeft="8dp"
53 53 android:layout_marginRight="8dp"
54 54 android:layout_marginStart="8dp"
55   - android:text="Set Point"
  55 + android:text="@string/set_point"
56 56 app:layout_constraintHorizontal_bias="0.0"
57 57 app:layout_constraintLeft_toLeftOf="parent"
58 58 app:layout_constraintRight_toRightOf="parent"
... ... @@ -67,7 +67,7 @@
67 67 android:layout_marginLeft="8dp"
68 68 android:layout_marginRight="8dp"
69 69 android:layout_marginStart="8dp"
70   - android:text="Cancel"
  70 + android:text="@string/Cancel"
71 71 app:layout_constraintLeft_toLeftOf="parent"
72 72 app:layout_constraintRight_toRightOf="parent"
73 73 app:layout_constraintHorizontal_bias="0.0"
... ... @@ -83,7 +83,7 @@
83 83 android:layout_marginRight="8dp"
84 84 android:layout_marginStart="8dp"
85 85 android:onClick="sendCalibrateRequest"
86   - android:text="Measure"
  86 + android:text="@string/Measure"
87 87 app:layout_constraintLeft_toLeftOf="parent"
88 88 app:layout_constraintRight_toRightOf="parent"
89 89 app:layout_constraintHorizontal_bias="0.0"
... ...
app/src/main/res/layout/content_positioning.xml
... ... @@ -73,9 +73,10 @@
73 73 android:layout_marginLeft="8dp"
74 74 android:layout_marginRight="8dp"
75 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 78 android:textColor="@color/colorAccent"
  79 + android:textSize="40sp"
79 80 app:layout_constraintBottom_toBottomOf="@+id/hiding_image"
80 81 app:layout_constraintLeft_toLeftOf="parent"
81 82 app:layout_constraintRight_toRightOf="parent"
... ...
app/src/main/res/values/colors.xml
... ... @@ -2,5 +2,5 @@
2 2 <resources>
3 3 <color name="colorPrimary">#3F51B5</color>
4 4 <color name="colorPrimaryDark">#303F9F</color>
5   - <color name="colorAccent">#FF4081</color>
  5 + <color name="colorAccent">#ff4081</color>
6 6 </resources>
... ...
app/src/main/res/values/strings.xml
1 1 <resources>
2   - <string name="app_name">PositionningApp</string>
  2 + <string name="app_name">PositioningApp</string>
3 3 <string name="action_settings">Settings</string>
4 4 <string name="title_activity_settings">Settings</string>
5 5  
... ... @@ -91,4 +91,10 @@
91 91  
92 92 <string name="pref_title_port">Port</string>
93 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 100 </resources>
... ...