forked from upstream-mirrors/OpenTracks
Merge heads
This commit is contained in:
@@ -37,6 +37,7 @@ limitations under the License.
|
|||||||
<string name="default_table_public_key">defaultTablePublic</string>
|
<string name="default_table_public_key">defaultTablePublic</string>
|
||||||
<string name="drive_sync_key">driveSync</string>
|
<string name="drive_sync_key">driveSync</string>
|
||||||
<string name="google_account_key">googleAccount</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="max_recording_distance_key">maxRecordingDistance</string>
|
||||||
<string name="metric_units_key">metricUnits</string>
|
<string name="metric_units_key">metricUnits</string>
|
||||||
<string name="min_recording_distance_key">minRecordingDistance</string>
|
<string name="min_recording_distance_key">minRecordingDistance</string>
|
||||||
|
|||||||
@@ -275,7 +275,7 @@ public class ChartView extends View {
|
|||||||
double[] dataPoint = dataPoints.get(i);
|
double[] dataPoint = dataPoints.get(i);
|
||||||
xExtremityMonitor.update(dataPoint[0]);
|
xExtremityMonitor.update(dataPoint[0]);
|
||||||
for (int j = 0; j < series.length; j++) {
|
for (int j = 0; j < series.length; j++) {
|
||||||
if (!Double.isNaN(dataPoint[j])) {
|
if (!Double.isNaN(dataPoint[j + 1])) {
|
||||||
series[j].update(dataPoint[j + 1]);
|
series[j].update(dataPoint[j + 1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -225,6 +225,7 @@ public class MyTracksProvider extends ContentProvider {
|
|||||||
} finally {
|
} finally {
|
||||||
db.endTransaction();
|
db.endTransaction();
|
||||||
}
|
}
|
||||||
|
getContext().getContentResolver().notifyChange(url, null, false);
|
||||||
|
|
||||||
if (driveSync && table.equals(TracksColumns.TABLE_NAME)) {
|
if (driveSync && table.equals(TracksColumns.TABLE_NAME)) {
|
||||||
String driveDeletedList = PreferencesUtils.getString(getContext(),
|
String driveDeletedList = PreferencesUtils.getString(getContext(),
|
||||||
@@ -237,8 +238,6 @@ public class MyTracksProvider extends ContentProvider {
|
|||||||
PreferencesUtils.setString(getContext(), R.string.drive_deleted_list_key, driveDeletedList);
|
PreferencesUtils.setString(getContext(), R.string.drive_deleted_list_key, driveDeletedList);
|
||||||
}
|
}
|
||||||
|
|
||||||
getContext().getContentResolver().notifyChange(url, null, true);
|
|
||||||
|
|
||||||
if (shouldVacuum) {
|
if (shouldVacuum) {
|
||||||
// If a potentially large amount of data was deleted, reclaim its space.
|
// If a potentially large amount of data was deleted, reclaim its space.
|
||||||
Log.i(TAG, "Vacuuming the database.");
|
Log.i(TAG, "Vacuuming the database.");
|
||||||
@@ -286,6 +285,7 @@ public class MyTracksProvider extends ContentProvider {
|
|||||||
} finally {
|
} finally {
|
||||||
db.endTransaction();
|
db.endTransaction();
|
||||||
}
|
}
|
||||||
|
getContext().getContentResolver().notifyChange(url, null, false);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,6 +311,7 @@ public class MyTracksProvider extends ContentProvider {
|
|||||||
} finally {
|
} finally {
|
||||||
db.endTransaction();
|
db.endTransaction();
|
||||||
}
|
}
|
||||||
|
getContext().getContentResolver().notifyChange(url, null, false);
|
||||||
return numInserted;
|
return numInserted;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -408,7 +409,7 @@ public class MyTracksProvider extends ContentProvider {
|
|||||||
} finally {
|
} finally {
|
||||||
db.endTransaction();
|
db.endTransaction();
|
||||||
}
|
}
|
||||||
getContext().getContentResolver().notifyChange(url, null, true);
|
getContext().getContentResolver().notifyChange(url, null, false);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -468,9 +469,7 @@ public class MyTracksProvider extends ContentProvider {
|
|||||||
}
|
}
|
||||||
long rowId = db.insert(TrackPointsColumns.TABLE_NAME, TrackPointsColumns._ID, values);
|
long rowId = db.insert(TrackPointsColumns.TABLE_NAME, TrackPointsColumns._ID, values);
|
||||||
if (rowId >= 0) {
|
if (rowId >= 0) {
|
||||||
Uri uri = ContentUris.appendId(TrackPointsColumns.CONTENT_URI.buildUpon(), rowId).build();
|
return ContentUris.appendId(TrackPointsColumns.CONTENT_URI.buildUpon(), rowId).build();
|
||||||
getContext().getContentResolver().notifyChange(url, null, true);
|
|
||||||
return uri;
|
|
||||||
}
|
}
|
||||||
throw new SQLiteException("Failed to insert a track point " + url);
|
throw new SQLiteException("Failed to insert a track point " + url);
|
||||||
}
|
}
|
||||||
@@ -489,9 +488,7 @@ public class MyTracksProvider extends ContentProvider {
|
|||||||
}
|
}
|
||||||
long rowId = db.insert(TracksColumns.TABLE_NAME, TracksColumns._ID, contentValues);
|
long rowId = db.insert(TracksColumns.TABLE_NAME, TracksColumns._ID, contentValues);
|
||||||
if (rowId >= 0) {
|
if (rowId >= 0) {
|
||||||
Uri uri = ContentUris.appendId(TracksColumns.CONTENT_URI.buildUpon(), rowId).build();
|
return ContentUris.appendId(TracksColumns.CONTENT_URI.buildUpon(), rowId).build();
|
||||||
getContext().getContentResolver().notifyChange(url, null, true);
|
|
||||||
return uri;
|
|
||||||
}
|
}
|
||||||
throw new SQLException("Failed to insert a track " + url);
|
throw new SQLException("Failed to insert a track " + url);
|
||||||
}
|
}
|
||||||
@@ -505,9 +502,7 @@ public class MyTracksProvider extends ContentProvider {
|
|||||||
private Uri insertWaypoint(Uri url, ContentValues contentValues) {
|
private Uri insertWaypoint(Uri url, ContentValues contentValues) {
|
||||||
long rowId = db.insert(WaypointsColumns.TABLE_NAME, WaypointsColumns._ID, contentValues);
|
long rowId = db.insert(WaypointsColumns.TABLE_NAME, WaypointsColumns._ID, contentValues);
|
||||||
if (rowId >= 0) {
|
if (rowId >= 0) {
|
||||||
Uri uri = ContentUris.appendId(WaypointsColumns.CONTENT_URI.buildUpon(), rowId).build();
|
return ContentUris.appendId(WaypointsColumns.CONTENT_URI.buildUpon(), rowId).build();
|
||||||
getContext().getContentResolver().notifyChange(url, null, true);
|
|
||||||
return uri;
|
|
||||||
}
|
}
|
||||||
throw new SQLException("Failed to insert a waypoint " + url);
|
throw new SQLException("Failed to insert a waypoint " + url);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.GoogleLocationUtils;
|
||||||
import com.google.android.apps.mytracks.util.IntentUtils;
|
import com.google.android.apps.mytracks.util.IntentUtils;
|
||||||
import com.google.android.apps.mytracks.util.LocationUtils;
|
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.CameraUpdate;
|
||||||
import com.google.android.gms.maps.CameraUpdateFactory;
|
import com.google.android.gms.maps.CameraUpdateFactory;
|
||||||
import com.google.android.gms.maps.GoogleMap;
|
import com.google.android.gms.maps.GoogleMap;
|
||||||
@@ -80,7 +81,6 @@ 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;
|
||||||
|
|
||||||
@@ -125,7 +125,6 @@ public class MyTracksMapFragment extends SupportMapFragment implements TrackData
|
|||||||
public void onCreate(Bundle bundle) {
|
public void onCreate(Bundle bundle) {
|
||||||
super.onCreate(bundle);
|
super.onCreate(bundle);
|
||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
ApiAdapterFactory.getApiAdapter().invalidMenu(getActivity());
|
|
||||||
mapOverlay = new MapOverlay(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);
|
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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.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();
|
resumeTrackDataHub();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,9 +246,6 @@ 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
|
||||||
@@ -333,6 +332,7 @@ public class MyTracksMapFragment extends SupportMapFragment implements TrackData
|
|||||||
if (googleMap != null) {
|
if (googleMap != null) {
|
||||||
googleMap.setMapType(type);
|
googleMap.setMapType(type);
|
||||||
menuItem.setChecked(true);
|
menuItem.setChecked(true);
|
||||||
|
PreferencesUtils.setInt(getActivity(), R.string.map_type_key, type);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -639,10 +639,11 @@ public class MyTracksMapFragment extends SupportMapFragment implements TrackData
|
|||||||
.include(southWest).include(northEast).build();
|
.include(southWest).include(northEast).build();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Note cannot call CameraUpdate.newLatLngBounds(LatLngBounds bounds, int padding)
|
* Note cannot call CameraUpdate.newLatLngBounds(LatLngBounds bounds,
|
||||||
* if the map view has not undergone layout. Thus calling
|
* int padding) if the map view has not undergone layout. Thus calling
|
||||||
* CameraUpdate.newLatLngBounds(LatLngBounds bounds, int width, int height, int padding)
|
* CameraUpdate.newLatLngBounds(LatLngBounds bounds, int width, int
|
||||||
* after making sure that mapView is valid in the above code.
|
* height, int padding) after making sure that mapView is valid in the
|
||||||
|
* above code.
|
||||||
*/
|
*/
|
||||||
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngBounds(
|
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngBounds(
|
||||||
bounds, mapView.getWidth(), mapView.getHeight(), MAP_VIEW_PADDING);
|
bounds, mapView.getWidth(), mapView.getHeight(), MAP_VIEW_PADDING);
|
||||||
|
|||||||
@@ -240,7 +240,8 @@ public class TrackWriter {
|
|||||||
wroteSegment = false;
|
wroteSegment = false;
|
||||||
}
|
}
|
||||||
if (wroteTrack) {
|
if (wroteTrack) {
|
||||||
trackFormatWriter.writeEndTrack(locationFactory.lastLocation);
|
Location lastValidTrackPoint = myTracksProviderUtils.getLastValidTrackPoint(track.getId());
|
||||||
|
trackFormatWriter.writeEndTrack(lastValidTrackPoint);
|
||||||
} else {
|
} else {
|
||||||
// Write an empty track
|
// Write an empty track
|
||||||
trackFormatWriter.writeBeginTrack(null);
|
trackFormatWriter.writeBeginTrack(null);
|
||||||
|
|||||||
@@ -65,6 +65,9 @@ public class PreferencesUtils {
|
|||||||
public static final int FREQUENCY_OFF = 0;
|
public static final int FREQUENCY_OFF = 0;
|
||||||
|
|
||||||
public static final String GOOGLE_ACCOUNT_DEFAULT = "";
|
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 int MAX_RECORDING_DISTANCE_DEFAULT = 200;
|
||||||
public static final boolean METRIC_UNITS_DEFAULT = true;
|
public static final boolean METRIC_UNITS_DEFAULT = true;
|
||||||
public static final int MIN_RECORDING_DISTANCE_DEFAULT = 5;
|
public static final int MIN_RECORDING_DISTANCE_DEFAULT = 5;
|
||||||
|
|||||||
@@ -82,15 +82,30 @@ public class TrackWidgetProvider extends AppWidgetProvider {
|
|||||||
|| context.getString(R.string.track_stopped_broadcast_action).equals(action)
|
|| context.getString(R.string.track_stopped_broadcast_action).equals(action)
|
||||||
|| context.getString(R.string.track_update_broadcast_action).equals(action)) {
|
|| context.getString(R.string.track_update_broadcast_action).equals(action)) {
|
||||||
long trackId = intent.getLongExtra(context.getString(R.string.track_id_broadcast_extra), -1L);
|
long trackId = intent.getLongExtra(context.getString(R.string.track_id_broadcast_extra), -1L);
|
||||||
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
|
updateAllWidgets(context, trackId);
|
||||||
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(
|
}
|
||||||
new ComponentName(context, TrackWidgetProvider.class));
|
}
|
||||||
for (int appWidgetId : appWidgetIds) {
|
|
||||||
int size = ApiAdapterFactory.getApiAdapter()
|
@Override
|
||||||
.getAppWidgetSize(appWidgetManager, appWidgetId);
|
public void onEnabled(Context context) {
|
||||||
RemoteViews remoteViews = getRemoteViews(context, trackId, size);
|
// Need to update all widgets after phone reboot
|
||||||
appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
|
updateAllWidgets(context, -1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates all widgets.
|
||||||
|
*
|
||||||
|
* @param context the context
|
||||||
|
* @param trackId track id
|
||||||
|
*/
|
||||||
|
private void updateAllWidgets(Context context, long trackId) {
|
||||||
|
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
|
||||||
|
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(
|
||||||
|
new ComponentName(context, TrackWidgetProvider.class));
|
||||||
|
for (int appWidgetId : appWidgetIds) {
|
||||||
|
int size = ApiAdapterFactory.getApiAdapter().getAppWidgetSize(appWidgetManager, appWidgetId);
|
||||||
|
RemoteViews remoteViews = getRemoteViews(context, trackId, size);
|
||||||
|
appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user