Skip to content

Commit 78c278a

Browse files
committed
Grahpical changes on locationFragment.java
1 parent 9b88169 commit 78c278a

File tree

6 files changed

+202
-15
lines changed

6 files changed

+202
-15
lines changed

‎app/src/main/java/it/unimib/pickapp/ui/locationFragment.java‎

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import android.content.Context;
77
import android.content.Intent;
88
import android.content.pm.PackageManager;
9+
import android.content.res.Resources;
910
import android.graphics.Bitmap;
1011
import android.graphics.Canvas;
1112
import android.graphics.drawable.Drawable;
@@ -43,6 +44,7 @@
4344
import com.google.android.gms.maps.model.BitmapDescriptor;
4445
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
4546
import com.google.android.gms.maps.model.LatLng;
47+
import com.google.android.gms.maps.model.MapStyleOptions;
4648
import com.google.android.gms.maps.model.Marker;
4749
import com.google.android.gms.maps.model.MarkerOptions;
4850
import com.google.firebase.auth.FirebaseAuth;
@@ -156,10 +158,24 @@ public void onSaveInstanceState(@NonNull Bundle outState) {
156158
});
157159

158160

159-
@SuppressLint("MissingPermission")
161+
160162
@RequiresApi(api = Build.VERSION_CODES.N)
161163
@Override
162164
public void onMapReady(@NonNull GoogleMap map) {
165+
try {
166+
// Customise the styling of the base map using a JSON object defined
167+
// in a raw resource file.
168+
boolean success = map.setMapStyle(
169+
MapStyleOptions.loadRawResourceStyle(
170+
getContext(), R.raw.map_style_json));
171+
172+
if (!success) {
173+
Log.e(TAG, "Style parsing failed.");
174+
}
175+
} catch (Resources.NotFoundException e) {
176+
Log.e(TAG, "Can't find style. Error: ", e);
177+
}
178+
163179
FusedLocationProviderClient client = LocationServices.getFusedLocationProviderClient(requireContext());
164180

165181
// Controllo se l'utente ha già accettato i permessi
@@ -179,7 +195,6 @@ public void onMapReady(@NonNull GoogleMap map) {
179195

180196
}
181197

182-
183198
@SuppressLint("MissingPermission")
184199
public void setupMap(GoogleMap map, FusedLocationProviderClient client) {
185200
map.setMyLocationEnabled(true);
@@ -190,24 +205,23 @@ public void setupMap(GoogleMap map, FusedLocationProviderClient client) {
190205
LatLng lastPosition = new LatLng(latitude, longitude);
191206
MapsInitializer.initialize(getContext());
192207
createRandomMarkers(listaPartite.size(), map, latitude, longitude);
193-
//map.setInfoWindowAdapter();
194-
map.moveCamera(CameraUpdateFactory.newLatLngZoom(lastPosition, 13));
208+
map.setOnInfoWindowClickListener(this);
209+
map.moveCamera(CameraUpdateFactory.newLatLngZoom(lastPosition, 14));
195210
} else {
196211
Toast.makeText(getActivity(), R.string.enable_gps, Toast.LENGTH_SHORT).show();
197212
}
198213
});
199-
map.setOnInfoWindowClickListener(this);
200214
}
201215

202216

203217
public void createRandomMarkers(int markersQuantity, GoogleMap map, double latitude, double longitude) {
204-
Random rand = new Random();
205-
218+
// Randomizziamo la posizione delle partite per test, altrimenti basta prendere le coordinate dal db
219+
Random rand = new Random(3);
206220
for(int i=0; i < markersQuantity; i++) {
207221
switch(listaPartite.get(i).getSport()) {
208222
case "TENNIS":
209223
map.addMarker(new MarkerOptions()
210-
.position(new LatLng(latitude+((rand.nextDouble()/90)-(rand.nextDouble()/90)), longitude+((rand.nextDouble()/90)-(rand.nextDouble()/90))))
224+
.position(new LatLng(latitude+((rand.nextDouble()/50)-(rand.nextDouble()/50)), longitude+((rand.nextDouble()/90)-(rand.nextDouble()/90))))
211225
.icon(bitmapDescriptorFromVector(getActivity(), R.drawable.ic_baseline_sports_tennis_24)) // null = default icon
212226
.title(listaPartite.get(i).getTitolo())
213227
.alpha(1f)

‎app/src/main/res/drawable/ic_baseline_sports_tennis_24.xml‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
android:width="24dp"
33
android:height="24dp"
44
android:viewportWidth="24"
5-
android:viewportHeight="24"
6-
android:tint="@color/green_tennis">
5+
android:viewportHeight="24">
76
<path
8-
android:fillColor="@android:color/white"
7+
android:fillColor="@color/item_color_active"
98
android:pathData="M19.52,2.49c-2.34,-2.34 -6.62,-1.87 -9.55,1.06c-1.6,1.6 -2.52,3.87 -2.54,5.46c-0.02,1.58 0.26,3.89 -1.35,5.5l-4.24,4.24l1.42,1.42l4.24,-4.24c1.61,-1.61 3.92,-1.33 5.5,-1.35s3.86,-0.94 5.46,-2.54C21.38,9.11 21.86,4.83 19.52,2.49zM10.32,11.68c-1.53,-1.53 -1.05,-4.61 1.06,-6.72s5.18,-2.59 6.72,-1.06c1.53,1.53 1.05,4.61 -1.06,6.72S11.86,13.21 10.32,11.68z"/>
109
<path
11-
android:fillColor="@android:color/white"
10+
android:fillColor="#B1EA13"
1211
android:pathData="M18,17c0.53,0 1.04,0.21 1.41,0.59c0.78,0.78 0.78,2.05 0,2.83C19.04,20.79 18.53,21 18,21s-1.04,-0.21 -1.41,-0.59c-0.78,-0.78 -0.78,-2.05 0,-2.83C16.96,17.21 17.47,17 18,17M18,15c-1.02,0 -2.05,0.39 -2.83,1.17c-1.56,1.56 -1.56,4.09 0,5.66C15.95,22.61 16.98,23 18,23s2.05,-0.39 2.83,-1.17c1.56,-1.56 1.56,-4.09 0,-5.66C20.05,15.39 19.02,15 18,15L18,15z"/>
1312
</vector>
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
[
2+
{
3+
"elementType": "labels.text.fill",
4+
"stylers": [
5+
{
6+
"color": "#477746"
7+
}
8+
]
9+
},
10+
{
11+
"featureType": "landscape.man_made",
12+
"stylers": [
13+
{
14+
"color": "#f8f5ee"
15+
}
16+
]
17+
},
18+
{
19+
"featureType": "poi",
20+
"elementType": "labels.text",
21+
"stylers": [
22+
{
23+
"visibility": "off"
24+
}
25+
]
26+
},
27+
{
28+
"featureType": "poi.business",
29+
"stylers": [
30+
{
31+
"visibility": "off"
32+
}
33+
]
34+
},
35+
{
36+
"featureType": "poi.medical",
37+
"stylers": [
38+
{
39+
"visibility": "off"
40+
}
41+
]
42+
},
43+
{
44+
"featureType": "poi.park",
45+
"stylers": [
46+
{
47+
"color": "#cee4bd"
48+
}
49+
]
50+
},
51+
{
52+
"featureType": "poi.sports_complex",
53+
"stylers": [
54+
{
55+
"visibility": "on"
56+
},
57+
{
58+
"weight": 0.5
59+
}
60+
]
61+
},
62+
{
63+
"featureType": "poi.sports_complex",
64+
"elementType": "geometry.fill",
65+
"stylers": [
66+
{
67+
"color": "#cee4bd"
68+
}
69+
]
70+
},
71+
{
72+
"featureType": "poi.sports_complex",
73+
"elementType": "labels.icon",
74+
"stylers": [
75+
{
76+
"color": "#60b22a"
77+
}
78+
]
79+
},
80+
{
81+
"featureType": "poi.sports_complex",
82+
"elementType": "labels.text.fill",
83+
"stylers": [
84+
{
85+
"color": "#8eb177"
86+
}
87+
]
88+
},
89+
{
90+
"featureType": "poi.sports_complex",
91+
"elementType": "labels.text.stroke",
92+
"stylers": [
93+
{
94+
"visibility": "off"
95+
}
96+
]
97+
},
98+
{
99+
"featureType": "road",
100+
"elementType": "labels.icon",
101+
"stylers": [
102+
{
103+
"visibility": "off"
104+
}
105+
]
106+
},
107+
{
108+
"featureType": "road.arterial",
109+
"elementType": "geometry.fill",
110+
"stylers": [
111+
{
112+
"color": "#ffffff"
113+
}
114+
]
115+
},
116+
{
117+
"featureType": "road.highway",
118+
"elementType": "geometry.fill",
119+
"stylers": [
120+
{
121+
"color": "#c7c7c7"
122+
},
123+
{
124+
"weight": 3
125+
}
126+
]
127+
},
128+
{
129+
"featureType": "road.highway",
130+
"elementType": "geometry.stroke",
131+
"stylers": [
132+
{
133+
"color": "#ffffff"
134+
},
135+
{
136+
"visibility": "on"
137+
},
138+
{
139+
"weight": 0.5
140+
}
141+
]
142+
},
143+
{
144+
"featureType": "road.local",
145+
"elementType": "geometry.fill",
146+
"stylers": [
147+
{
148+
"color": "#ffffff"
149+
}
150+
]
151+
},
152+
{
153+
"featureType": "transit",
154+
"stylers": [
155+
{
156+
"color": "#7aca44"
157+
},
158+
{
159+
"visibility": "on"
160+
}
161+
]
162+
},
163+
{
164+
"featureType": "water",
165+
"elementType": "geometry.fill",
166+
"stylers": [
167+
{
168+
"color": "#b9dff2"
169+
}
170+
]
171+
}
172+
]

‎app/src/main/res/values-it-rIT/strings.xml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<string name="Logo">Logo</string>
1818
<string name="intermediate">Intermedio</string>
1919
<string name="Field">Campo</string>
20-
<string name="myGames">Le mie partite</string>
20+
<string name="myGames">Calendario</string>
2121
<string name="send">Invia</string>
2222
<string name="forgotPasswordLogin">Recupera la tua password</string>
2323
<string name="welcomeText">Benvenuto</string>
@@ -68,4 +68,6 @@
6868
<string name="invalidCost">Costo non valido</string>
6969
<string name="invalidNumOfTeams">Numero squadre non valido</string>
7070
<string name="invalidTitle">Titolo vuoto</string>
71+
<string name="experience">Esperienza</string>
72+
<string name="reliability">Affidabilità</string>
7173
</resources>

‎app/src/main/res/values/colors.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
<color name="orange_basketball">#DD5D09</color>
3232
<color name="blue_soccer">#3F51B5</color>
33-
<color name="green_tennis">#8BC34A</color>
33+
<color name="green_tennis">#37914D</color>
3434
<color name="brown_football">#714400</color>
3535

3636
</resources>

‎app/src/main/res/values/strings.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<string name="Field">Field</string>
4040
<string name="send">Send</string>
4141
<string name="forgotPasswordLogin">Recover your password</string>
42-
<string name="myGames">My games</string>
42+
<string name="myGames">Calendar</string>
4343
<string name="welcomeText">Welcome</string>
4444
<string name="backgroundProfile">background profile image</string>
4545
<string name="accountName">account name</string>

0 commit comments

Comments
 (0)