mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-02 17:43:06 +02:00
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:title="@string/menu_map_layer">
|
||||
<menu>
|
||||
<item
|
||||
android:id="@+id/menu_map"
|
||||
android:title="@string/menu_map"/>
|
||||
<item
|
||||
android:id="@+id/menu_satellite"
|
||||
android:title="@string/menu_satellite"/>
|
||||
<item
|
||||
android:id="@+id/menu_terrain"
|
||||
android:title="@string/menu_terrain"/>
|
||||
<group android:checkableBehavior="single" >
|
||||
<item
|
||||
android:id="@+id/menu_map"
|
||||
android:title="@string/menu_map"/>
|
||||
<item
|
||||
android:id="@+id/menu_satellite"
|
||||
android:title="@string/menu_satellite"/>
|
||||
<item
|
||||
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>
|
||||
</item>
|
||||
</menu>
|
||||
@@ -1189,6 +1189,13 @@ limitations under the License.
|
||||
Character limit: ~20 (1 line)">
|
||||
Satellite
|
||||
</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"
|
||||
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
|
||||
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 MAP_TYPE = "map_type";
|
||||
|
||||
private static final float DEFAULT_ZOOM_LEVEL = 18f;
|
||||
|
||||
// Google's latitude and longitude
|
||||
@@ -148,12 +149,7 @@ public class MyTracksMapFragment extends SupportMapFragment implements TrackData
|
||||
});
|
||||
messageTextView = (TextView) layout.findViewById(R.id.map_message);
|
||||
|
||||
onMapInitialize(getMap());
|
||||
return layout;
|
||||
}
|
||||
|
||||
private void onMapInitialize(GoogleMap map) {
|
||||
googleMap = map;
|
||||
googleMap = getMap();
|
||||
googleMap.setMyLocationEnabled(true);
|
||||
googleMap.getUiSettings().setMyLocationButtonEnabled(false);
|
||||
googleMap.setIndoorEnabled(true);
|
||||
@@ -199,6 +195,7 @@ public class MyTracksMapFragment extends SupportMapFragment implements TrackData
|
||||
});
|
||||
googleMap.moveCamera(
|
||||
CameraUpdateFactory.newLatLngZoom(getDefaultLatLng(), googleMap.getMinZoomLevel()));
|
||||
return layout;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -210,6 +207,9 @@ public class MyTracksMapFragment extends SupportMapFragment implements TrackData
|
||||
zoomToCurrentLocation = savedInstanceState.getBoolean(ZOOM_TO_CURRENT_LOCATION_KEY, false);
|
||||
currentLocation = (Location) savedInstanceState.getParcelable(CURRENT_LOCATION_KEY);
|
||||
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(ZOOM_TO_CURRENT_LOCATION_KEY, zoomToCurrentLocation);
|
||||
if (googleMap != null) {
|
||||
outState.putInt(MAP_TYPE, googleMap.getMapType());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -263,6 +266,34 @@ public class MyTracksMapFragment extends SupportMapFragment implements TrackData
|
||||
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
|
||||
public boolean onOptionsItemSelected(MenuItem menuItem) {
|
||||
int type = GoogleMap.MAP_TYPE_NORMAL;
|
||||
@@ -273,6 +304,9 @@ public class MyTracksMapFragment extends SupportMapFragment implements TrackData
|
||||
case R.id.menu_satellite:
|
||||
type = GoogleMap.MAP_TYPE_SATELLITE;
|
||||
break;
|
||||
case R.id.menu_satellite_with_streets:
|
||||
type = GoogleMap.MAP_TYPE_HYBRID;
|
||||
break;
|
||||
case R.id.menu_terrain:
|
||||
type = GoogleMap.MAP_TYPE_TERRAIN;
|
||||
break;
|
||||
@@ -281,6 +315,7 @@ public class MyTracksMapFragment extends SupportMapFragment implements TrackData
|
||||
}
|
||||
if (googleMap != null) {
|
||||
googleMap.setMapType(type);
|
||||
menuItem.setChecked(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -45,8 +45,7 @@ public class Api9Adapter extends Api8Adapter {
|
||||
public void enableStrictMode() {
|
||||
Log.d(Constants.TAG, "Enabling strict mode");
|
||||
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
|
||||
.detectDiskWrites()
|
||||
.detectNetwork()
|
||||
.detectAll()
|
||||
.penaltyLog()
|
||||
.build());
|
||||
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
|
||||
|
||||
Reference in New Issue
Block a user