forked from upstream-mirrors/OpenTracks
Add satellite with streets layer
Add checkbox next to the map layer item Remember map layer across screen rotation
This commit is contained in:
@@ -21,15 +21,20 @@ limitations under the License.
|
|||||||
android:showAsAction="ifRoom"
|
android:showAsAction="ifRoom"
|
||||||
android:title="@string/menu_map_layer">
|
android:title="@string/menu_map_layer">
|
||||||
<menu>
|
<menu>
|
||||||
<item
|
<group android:checkableBehavior="single" >
|
||||||
android:id="@+id/menu_map"
|
<item
|
||||||
android:title="@string/menu_map"/>
|
android:id="@+id/menu_map"
|
||||||
<item
|
android:title="@string/menu_map"/>
|
||||||
android:id="@+id/menu_satellite"
|
<item
|
||||||
android:title="@string/menu_satellite"/>
|
android:id="@+id/menu_satellite"
|
||||||
<item
|
android:title="@string/menu_satellite"/>
|
||||||
android:id="@+id/menu_terrain"
|
<item
|
||||||
android:title="@string/menu_terrain"/>
|
android:id="@+id/menu_satellite_with_streets"
|
||||||
|
android:title="@string/menu_satellite_with_streets"/>
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_terrain"
|
||||||
|
android:title="@string/menu_terrain"/>
|
||||||
|
</group>
|
||||||
</menu>
|
</menu>
|
||||||
</item>
|
</item>
|
||||||
</menu>
|
</menu>
|
||||||
@@ -1189,6 +1189,13 @@ limitations under the License.
|
|||||||
Character limit: ~20 (1 line)">
|
Character limit: ~20 (1 line)">
|
||||||
Satellite
|
Satellite
|
||||||
</string>
|
</string>
|
||||||
|
<string name="menu_satellite_with_streets"
|
||||||
|
translation_description="In the menu, under the map layer option, the submenu to display
|
||||||
|
satellite with major streets.
|
||||||
|
|
||||||
|
Character limit: ~20 (1 line)">
|
||||||
|
Satellite with streets
|
||||||
|
</string>
|
||||||
<string name="menu_save"
|
<string name="menu_save"
|
||||||
translation_description="In the menu, to save a track to the external storage.
|
translation_description="In the menu, to save a track to the external storage.
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,8 @@ public class MyTracksMapFragment extends SupportMapFragment implements TrackData
|
|||||||
private static final String
|
private static final String
|
||||||
KEEP_CURRENT_LOCATION_VISIBLE_KEY = "keep_current_location_visible_key";
|
KEEP_CURRENT_LOCATION_VISIBLE_KEY = "keep_current_location_visible_key";
|
||||||
private static final String ZOOM_TO_CURRENT_LOCATION_KEY = "zoom_to_current_location_key";
|
private static final String ZOOM_TO_CURRENT_LOCATION_KEY = "zoom_to_current_location_key";
|
||||||
|
private static final String MAP_TYPE = "map_type";
|
||||||
|
|
||||||
private static final float DEFAULT_ZOOM_LEVEL = 18f;
|
private static final float DEFAULT_ZOOM_LEVEL = 18f;
|
||||||
|
|
||||||
// Google's latitude and longitude
|
// Google's latitude and longitude
|
||||||
@@ -148,12 +149,7 @@ public class MyTracksMapFragment extends SupportMapFragment implements TrackData
|
|||||||
});
|
});
|
||||||
messageTextView = (TextView) layout.findViewById(R.id.map_message);
|
messageTextView = (TextView) layout.findViewById(R.id.map_message);
|
||||||
|
|
||||||
onMapInitialize(getMap());
|
googleMap = getMap();
|
||||||
return layout;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onMapInitialize(GoogleMap map) {
|
|
||||||
googleMap = map;
|
|
||||||
googleMap.setMyLocationEnabled(true);
|
googleMap.setMyLocationEnabled(true);
|
||||||
googleMap.getUiSettings().setMyLocationButtonEnabled(false);
|
googleMap.getUiSettings().setMyLocationButtonEnabled(false);
|
||||||
googleMap.setIndoorEnabled(true);
|
googleMap.setIndoorEnabled(true);
|
||||||
@@ -199,6 +195,7 @@ public class MyTracksMapFragment extends SupportMapFragment implements TrackData
|
|||||||
});
|
});
|
||||||
googleMap.moveCamera(
|
googleMap.moveCamera(
|
||||||
CameraUpdateFactory.newLatLngZoom(getDefaultLatLng(), googleMap.getMinZoomLevel()));
|
CameraUpdateFactory.newLatLngZoom(getDefaultLatLng(), googleMap.getMinZoomLevel()));
|
||||||
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -210,6 +207,9 @@ public class MyTracksMapFragment extends SupportMapFragment implements TrackData
|
|||||||
zoomToCurrentLocation = savedInstanceState.getBoolean(ZOOM_TO_CURRENT_LOCATION_KEY, false);
|
zoomToCurrentLocation = savedInstanceState.getBoolean(ZOOM_TO_CURRENT_LOCATION_KEY, false);
|
||||||
currentLocation = (Location) savedInstanceState.getParcelable(CURRENT_LOCATION_KEY);
|
currentLocation = (Location) savedInstanceState.getParcelable(CURRENT_LOCATION_KEY);
|
||||||
updateCurrentLocation();
|
updateCurrentLocation();
|
||||||
|
if (googleMap != null) {
|
||||||
|
googleMap.setMapType(savedInstanceState.getInt(MAP_TYPE, GoogleMap.MAP_TYPE_NORMAL));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,6 +227,9 @@ public class MyTracksMapFragment extends SupportMapFragment implements TrackData
|
|||||||
}
|
}
|
||||||
outState.putBoolean(KEEP_CURRENT_LOCATION_VISIBLE_KEY, keepCurrentLocationVisible);
|
outState.putBoolean(KEEP_CURRENT_LOCATION_VISIBLE_KEY, keepCurrentLocationVisible);
|
||||||
outState.putBoolean(ZOOM_TO_CURRENT_LOCATION_KEY, zoomToCurrentLocation);
|
outState.putBoolean(ZOOM_TO_CURRENT_LOCATION_KEY, zoomToCurrentLocation);
|
||||||
|
if (googleMap != null) {
|
||||||
|
outState.putInt(MAP_TYPE, googleMap.getMapType());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -263,6 +266,34 @@ public class MyTracksMapFragment extends SupportMapFragment implements TrackData
|
|||||||
menuInflator.inflate(R.menu.map, menu);
|
menuInflator.inflate(R.menu.map, menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPrepareOptionsMenu(Menu menu) {
|
||||||
|
if (googleMap != null) {
|
||||||
|
int id;
|
||||||
|
switch (googleMap.getMapType()) {
|
||||||
|
case GoogleMap.MAP_TYPE_NORMAL:
|
||||||
|
id = R.id.menu_map;
|
||||||
|
break;
|
||||||
|
case GoogleMap.MAP_TYPE_SATELLITE:
|
||||||
|
id = R.id.menu_satellite;
|
||||||
|
break;
|
||||||
|
case GoogleMap.MAP_TYPE_HYBRID:
|
||||||
|
id = R.id.menu_satellite_with_streets;
|
||||||
|
break;
|
||||||
|
case GoogleMap.MAP_TYPE_TERRAIN:
|
||||||
|
id = R.id.menu_terrain;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
id = R.id.menu_map;
|
||||||
|
}
|
||||||
|
MenuItem menuItem = menu.findItem(id);
|
||||||
|
if (menuItem != null) {
|
||||||
|
menuItem.setChecked(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.onPrepareOptionsMenu(menu);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem menuItem) {
|
public boolean onOptionsItemSelected(MenuItem menuItem) {
|
||||||
int type = GoogleMap.MAP_TYPE_NORMAL;
|
int type = GoogleMap.MAP_TYPE_NORMAL;
|
||||||
@@ -273,6 +304,9 @@ public class MyTracksMapFragment extends SupportMapFragment implements TrackData
|
|||||||
case R.id.menu_satellite:
|
case R.id.menu_satellite:
|
||||||
type = GoogleMap.MAP_TYPE_SATELLITE;
|
type = GoogleMap.MAP_TYPE_SATELLITE;
|
||||||
break;
|
break;
|
||||||
|
case R.id.menu_satellite_with_streets:
|
||||||
|
type = GoogleMap.MAP_TYPE_HYBRID;
|
||||||
|
break;
|
||||||
case R.id.menu_terrain:
|
case R.id.menu_terrain:
|
||||||
type = GoogleMap.MAP_TYPE_TERRAIN;
|
type = GoogleMap.MAP_TYPE_TERRAIN;
|
||||||
break;
|
break;
|
||||||
@@ -281,6 +315,7 @@ public class MyTracksMapFragment extends SupportMapFragment implements TrackData
|
|||||||
}
|
}
|
||||||
if (googleMap != null) {
|
if (googleMap != null) {
|
||||||
googleMap.setMapType(type);
|
googleMap.setMapType(type);
|
||||||
|
menuItem.setChecked(true);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,8 +45,7 @@ public class Api9Adapter extends Api8Adapter {
|
|||||||
public void enableStrictMode() {
|
public void enableStrictMode() {
|
||||||
Log.d(Constants.TAG, "Enabling strict mode");
|
Log.d(Constants.TAG, "Enabling strict mode");
|
||||||
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
|
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
|
||||||
.detectDiskWrites()
|
.detectAll()
|
||||||
.detectNetwork()
|
|
||||||
.penaltyLog()
|
.penaltyLog()
|
||||||
.build());
|
.build());
|
||||||
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
|
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
|
||||||
|
|||||||
Reference in New Issue
Block a user