persist map type from apoorvnaik

This commit is contained in:
Jimmy Shih
2013-02-27 12:20:03 -08:00
parent e8e99dc3d0
commit 6bf211a5c6
3 changed files with 25 additions and 20 deletions
+1
View File
@@ -37,6 +37,7 @@ limitations under the License.
<string name="default_table_public_key">defaultTablePublic</string>
<string name="drive_sync_key">driveSync</string>
<string name="google_account_key">googleAccount</string>
<string name="map_type_key">mapType</string>
<string name="max_recording_distance_key">maxRecordingDistance</string>
<string name="metric_units_key">metricUnits</string>
<string name="min_recording_distance_key">minRecordingDistance</string>
@@ -31,6 +31,7 @@ import com.google.android.apps.mytracks.util.ApiAdapterFactory;
import com.google.android.apps.mytracks.util.GoogleLocationUtils;
import com.google.android.apps.mytracks.util.IntentUtils;
import com.google.android.apps.mytracks.util.LocationUtils;
import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
@@ -80,8 +81,7 @@ 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
@@ -125,7 +125,6 @@ public class MyTracksMapFragment extends SupportMapFragment implements TrackData
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
setHasOptionsMenu(true);
ApiAdapterFactory.getApiAdapter().invalidMenu(getActivity());
mapOverlay = new MapOverlay(getActivity());
}
@@ -224,15 +223,18 @@ 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));
}
}
}
@Override
public void onResume() {
super.onResume();
if (googleMap != null) {
int mapType = PreferencesUtils.getInt(
getActivity(), R.string.map_type_key, PreferencesUtils.MAP_TYPE_DEFAUlT);
googleMap.setMapType(mapType);
ApiAdapterFactory.getApiAdapter().invalidMenu(getActivity());
}
resumeTrackDataHub();
}
@@ -244,9 +246,6 @@ 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
@@ -333,6 +332,7 @@ public class MyTracksMapFragment extends SupportMapFragment implements TrackData
if (googleMap != null) {
googleMap.setMapType(type);
menuItem.setChecked(true);
PreferencesUtils.setInt(getActivity(), R.string.map_type_key, type);
}
return true;
}
@@ -637,12 +637,13 @@ public class MyTracksMapFragment extends SupportMapFragment implements TrackData
tripStatistics.getTopDegrees(), tripStatistics.getRightDegrees());
LatLngBounds bounds = LatLngBounds.builder()
.include(southWest).include(northEast).build();
/**
* Note cannot call CameraUpdate.newLatLngBounds(LatLngBounds bounds, int padding)
* if the map view has not undergone layout. Thus calling
* CameraUpdate.newLatLngBounds(LatLngBounds bounds, int width, int height, int padding)
* after making sure that mapView is valid in the above code.
* Note cannot call CameraUpdate.newLatLngBounds(LatLngBounds bounds,
* int padding) if the map view has not undergone layout. Thus calling
* CameraUpdate.newLatLngBounds(LatLngBounds bounds, int width, int
* height, int padding) after making sure that mapView is valid in the
* above code.
*/
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngBounds(
bounds, mapView.getWidth(), mapView.getHeight(), MAP_VIEW_PADDING);
@@ -59,12 +59,15 @@ public class PreferencesUtils {
public static final boolean DEFAULT_TABLE_PUBLIC_DEFAULT = false;
public static final String DRIVE_DELETED_LIST_DEFAULT = "";
public static final long DRIVE_LARGEST_CHANGE_ID_DEFAULT = -1L;
public static final boolean DRIVE_SYNC_DEFAULT = false;
public static final boolean DRIVE_SYNC_DEFAULT = false;
// Value for split_frequency_key and voice_frequency_key
public static final int FREQUENCY_OFF = 0;
public static final String GOOGLE_ACCOUNT_DEFAULT = "";
public static final int MAP_TYPE_DEFAUlT = 1;
public static final int MAX_RECORDING_DISTANCE_DEFAULT = 200;
public static final boolean METRIC_UNITS_DEFAULT = true;
public static final int MIN_RECORDING_DISTANCE_DEFAULT = 5;
@@ -84,13 +87,13 @@ public class PreferencesUtils {
public static final boolean RECORDING_TRACK_PAUSED_DEFAULT = true;
public static final boolean REPORT_SPEED_DEFAULT = true;
public static final long SELECTED_TRACK_ID_DEFAULT = -1L;
public static final boolean SEND_TO_DRIVE_DEFAULT = false;
public static final boolean SEND_TO_FUSION_TABLES_DEFAULT = false;
public static final boolean SEND_TO_MAPS_DEFAULT = false;
public static final boolean SEND_TO_SPREADSHEETS_DEFAULT = false;
public static final String SENSOR_TYPE_DEFAULT = "NONE";
public static final String SENSOR_TYPE_DEFAULT = "NONE";
public static final int SPLIT_FREQUENCY_DEFAULT = 0;
public static final boolean STATS_SHOW_COORDINATE_DEFAULT = false;
public static final boolean STATS_SHOW_ELEVATION_DEFAULT = false;