mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-11 13:33:07 +02:00
Merge to head (non-trivial merge)
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
<classpathentry kind="lib" path="libs/google-common.jar"/>
|
<classpathentry kind="lib" path="libs/google-common.jar"/>
|
||||||
<classpathentry kind="lib" path="libs/accounts.jar"/>
|
<classpathentry kind="lib" path="libs/accounts.jar"/>
|
||||||
<classpathentry kind="lib" path="libs/google-api-client-1.2.2-alpha.jar"/>
|
<classpathentry kind="lib" path="libs/google-api-client-1.2.2-alpha.jar"/>
|
||||||
|
<classpathentry kind="lib" path="libs/libGoogleAnalytics.jar"/>
|
||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src"/>
|
||||||
<classpathentry kind="src" path="gen"/>
|
<classpathentry kind="src" path="gen"/>
|
||||||
<classpathentry exported="true" kind="lib" path="/MyTracksLib/libs/protobuf-java-2.3.0-lite.jar"/>
|
<classpathentry exported="true" kind="lib" path="/MyTracksLib/libs/protobuf-java-2.3.0-lite.jar"/>
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ limitations under the License.
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.google.android.maps.mytracks"
|
package="com.google.android.maps.mytracks"
|
||||||
android:installLocation="auto"
|
android:installLocation="auto"
|
||||||
android:versionCode="28"
|
android:versionCode="29"
|
||||||
android:versionName="1.1.5">
|
android:versionName="1.1.6">
|
||||||
<application android:icon="@drawable/arrow_icon"
|
<application android:icon="@drawable/arrow_icon"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:backupAgent="com.google.android.apps.mytracks.io.backup.MyTracksBackupAgent">
|
android:backupAgent="com.google.android.apps.mytracks.io.backup.MyTracksBackupAgent">
|
||||||
@@ -180,6 +180,7 @@ limitations under the License.
|
|||||||
<!-- Permissions for recording tracks and showing maps -->
|
<!-- Permissions for recording tracks and showing maps -->
|
||||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||||
|
|||||||
Binary file not shown.
@@ -170,6 +170,11 @@ limitations under the License.
|
|||||||
<item>inline skating</item>
|
<item>inline skating</item>
|
||||||
<item>skate boarding</item>
|
<item>skate boarding</item>
|
||||||
|
|
||||||
|
<item>roller skiing (classic)</item>
|
||||||
|
<item>roller skiing (skate)</item>
|
||||||
|
<item>cross-country skiing (classic)</item>
|
||||||
|
<item>cross-country skiing (skate)</item>
|
||||||
|
|
||||||
<item>snow shoeing</item>
|
<item>snow shoeing</item>
|
||||||
<item>skiing</item>
|
<item>skiing</item>
|
||||||
<item>snow boarding</item>
|
<item>snow boarding</item>
|
||||||
|
|||||||
@@ -40,6 +40,9 @@ limitations under the License.
|
|||||||
<string name="sendtogoogle_google_mymaps_url">maps.google.com</string>
|
<string name="sendtogoogle_google_mymaps_url">maps.google.com</string>
|
||||||
<string name="sendtogoogle_google_docs_url">docs.google.com</string>
|
<string name="sendtogoogle_google_docs_url">docs.google.com</string>
|
||||||
|
|
||||||
|
<!-- ID for Google Analytics -->
|
||||||
|
<string name="google_analytics_id">UA-7222692-2</string>
|
||||||
|
|
||||||
<!-- Intent actions -->
|
<!-- Intent actions -->
|
||||||
<string name="save_intent_action">android.intent.action.SAVE</string>
|
<string name="save_intent_action">android.intent.action.SAVE</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -145,6 +145,7 @@ public class ChartActivity extends Activity implements TrackDataListener {
|
|||||||
dataHub = TrackDataHub.getStartedInstance();
|
dataHub = TrackDataHub.getStartedInstance();
|
||||||
dataHub.registerTrackDataListener(this, EnumSet.of(
|
dataHub.registerTrackDataListener(this, EnumSet.of(
|
||||||
ListenerDataType.SELECTED_TRACK_CHANGED,
|
ListenerDataType.SELECTED_TRACK_CHANGED,
|
||||||
|
ListenerDataType.TRACK_UPDATES,
|
||||||
ListenerDataType.POINT_UPDATES,
|
ListenerDataType.POINT_UPDATES,
|
||||||
ListenerDataType.SAMPLED_OUT_POINT_UPDATES,
|
ListenerDataType.SAMPLED_OUT_POINT_UPDATES,
|
||||||
ListenerDataType.WAYPOINT_UPDATES,
|
ListenerDataType.WAYPOINT_UPDATES,
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ public class ExportAllTracks {
|
|||||||
Log.i(Constants.TAG, "ExportAllTracks: Releasing wake lock.");
|
Log.i(Constants.TAG, "ExportAllTracks: Releasing wake lock.");
|
||||||
}
|
}
|
||||||
Log.i(Constants.TAG, "ExportAllTracks: Done");
|
Log.i(Constants.TAG, "ExportAllTracks: Done");
|
||||||
Toast.makeText(activity, R.string.export_done, Toast.LENGTH_SHORT).show();
|
showToast(R.string.export_done, Toast.LENGTH_SHORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void makeProgressDialog(final int trackCount) {
|
private void makeProgressDialog(final int trackCount) {
|
||||||
@@ -189,12 +189,16 @@ public class ExportAllTracks {
|
|||||||
Log.i(Constants.TAG, "ExportAllTracks: exporting: " + id);
|
Log.i(Constants.TAG, "ExportAllTracks: exporting: " + id);
|
||||||
TrackWriter writer =
|
TrackWriter writer =
|
||||||
TrackWriterFactory.newWriter(activity, providerUtils, id, format);
|
TrackWriterFactory.newWriter(activity, providerUtils, id, format);
|
||||||
|
if (writer == null) {
|
||||||
|
showToast(R.string.error_track_does_not_exist, Toast.LENGTH_LONG);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
writer.writeTrack();
|
writer.writeTrack();
|
||||||
|
|
||||||
if (!writer.wasSuccess()) {
|
if (!writer.wasSuccess()) {
|
||||||
// Abort the whole export on the first error.
|
// Abort the whole export on the first error.
|
||||||
int error = writer.getErrorMessage();
|
showToast(writer.getErrorMessage(), Toast.LENGTH_LONG);
|
||||||
Toast.makeText(activity, error, Toast.LENGTH_LONG).show();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -210,4 +214,13 @@ public class ExportAllTracks {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showToast(final int messageId, final int length) {
|
||||||
|
activity.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Toast.makeText(activity, messageId, length).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ import android.widget.ImageButton;
|
|||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
|
||||||
@@ -480,21 +481,21 @@ public class MapActivity extends com.google.android.maps.MapActivity
|
|||||||
@Override
|
@Override
|
||||||
public void onProviderStateChange(ProviderState state) {
|
public void onProviderStateChange(ProviderState state) {
|
||||||
final int messageId;
|
final int messageId;
|
||||||
final boolean bindClick;
|
final boolean isGpsDisabled;
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case DISABLED:
|
case DISABLED:
|
||||||
messageId = R.string.status_enable_gps;
|
messageId = R.string.status_enable_gps;
|
||||||
bindClick = true;
|
isGpsDisabled = true;
|
||||||
break;
|
break;
|
||||||
case NO_FIX:
|
case NO_FIX:
|
||||||
case BAD_FIX:
|
case BAD_FIX:
|
||||||
messageId = R.string.wait_for_fix;
|
messageId = R.string.wait_for_fix;
|
||||||
bindClick = false;
|
isGpsDisabled = false;
|
||||||
break;
|
break;
|
||||||
case GOOD_FIX:
|
case GOOD_FIX:
|
||||||
// Nothing to show.
|
// Nothing to show.
|
||||||
messageId = -1;
|
messageId = -1;
|
||||||
bindClick = false;
|
isGpsDisabled = false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Unexpected state: " + state);
|
throw new IllegalArgumentException("Unexpected state: " + state);
|
||||||
@@ -507,7 +508,13 @@ public class MapActivity extends com.google.android.maps.MapActivity
|
|||||||
messageText.setText(messageId);
|
messageText.setText(messageId);
|
||||||
messagePane.setVisibility(View.VISIBLE);
|
messagePane.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
if (bindClick) {
|
if (isGpsDisabled) {
|
||||||
|
// Give a warning about this state.
|
||||||
|
Toast.makeText(MapActivity.this,
|
||||||
|
R.string.error_no_gps_location_provider,
|
||||||
|
Toast.LENGTH_LONG).show();
|
||||||
|
|
||||||
|
// Make clicking take the user to the location settings.
|
||||||
messagePane.setOnClickListener(MapActivity.this);
|
messagePane.setOnClickListener(MapActivity.this);
|
||||||
} else {
|
} else {
|
||||||
messagePane.setOnClickListener(null);
|
messagePane.setOnClickListener(null);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ package com.google.android.apps.mytracks;
|
|||||||
|
|
||||||
import static com.google.android.apps.mytracks.Constants.TAG;
|
import static com.google.android.apps.mytracks.Constants.TAG;
|
||||||
|
|
||||||
|
import com.google.android.apps.analytics.GoogleAnalyticsTracker;
|
||||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||||
import com.google.android.apps.mytracks.content.TrackDataHub;
|
import com.google.android.apps.mytracks.content.TrackDataHub;
|
||||||
import com.google.android.apps.mytracks.content.TracksColumns;
|
import com.google.android.apps.mytracks.content.TracksColumns;
|
||||||
@@ -79,6 +80,11 @@ public class MyTracks extends TabActivity implements OnTouchListener {
|
|||||||
*/
|
*/
|
||||||
private MyTracksProviderUtils providerUtils;
|
private MyTracksProviderUtils providerUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Google Analytics tracker
|
||||||
|
*/
|
||||||
|
private GoogleAnalyticsTracker tracker;
|
||||||
|
|
||||||
private TrackRecordingServiceBinder serviceBinder;
|
private TrackRecordingServiceBinder serviceBinder;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -125,6 +131,13 @@ public class MyTracks extends TabActivity implements OnTouchListener {
|
|||||||
apiFeatures.getApiPlatformAdapter().enableStrictMode();
|
apiFeatures.getApiPlatformAdapter().enableStrictMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tracker = GoogleAnalyticsTracker.getInstance();
|
||||||
|
// Start the tracker in manual dispatch mode...
|
||||||
|
tracker.start(getString(R.string.google_analytics_id), getApplicationContext());
|
||||||
|
tracker.setProductVersion("android-mytracks", SystemUtils.getMyTracksVersion(this));
|
||||||
|
tracker.trackPageView("/appstart");
|
||||||
|
tracker.dispatch();
|
||||||
|
|
||||||
providerUtils = MyTracksProviderUtils.Factory.get(this);
|
providerUtils = MyTracksProviderUtils.Factory.get(this);
|
||||||
preferences = getSharedPreferences(Constants.SETTINGS_NAME, 0);
|
preferences = getSharedPreferences(Constants.SETTINGS_NAME, 0);
|
||||||
dataHub = TrackDataHub.newInstance(this);
|
dataHub = TrackDataHub.newInstance(this);
|
||||||
@@ -179,6 +192,9 @@ public class MyTracks extends TabActivity implements OnTouchListener {
|
|||||||
|
|
||||||
dataHub.stop();
|
dataHub.stop();
|
||||||
|
|
||||||
|
tracker.dispatch();
|
||||||
|
tracker.stop();
|
||||||
|
|
||||||
// Clean up any temporary track files.
|
// Clean up any temporary track files.
|
||||||
TempFileCleaner.clean();
|
TempFileCleaner.clean();
|
||||||
super.onStop();
|
super.onStop();
|
||||||
@@ -464,10 +480,10 @@ public class MyTracks extends TabActivity implements OnTouchListener {
|
|||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
serviceBinder.stopService();
|
serviceBinder.stopService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void clearSelectedTrack() {
|
void clearSelectedTrack() {
|
||||||
dataHub.unloadCurrentTrack();
|
dataHub.unloadCurrentTrack();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,15 +76,18 @@ public class WaypointsList extends ListActivity
|
|||||||
contextPosition = info.position;
|
contextPosition = info.position;
|
||||||
waypointId = WaypointsList.this.listView.getAdapter()
|
waypointId = WaypointsList.this.listView.getAdapter()
|
||||||
.getItemId(contextPosition);
|
.getItemId(contextPosition);
|
||||||
int type = providerUtils.getWaypoint(info.id).getType();
|
Waypoint waypoint = providerUtils.getWaypoint(info.id);
|
||||||
menu.add(0, Constants.MENU_SHOW, 0,
|
if (waypoint != null) {
|
||||||
R.string.waypointslist_show_waypoint);
|
int type = waypoint.getType();
|
||||||
menu.add(0, Constants.MENU_EDIT, 0,
|
menu.add(0, Constants.MENU_SHOW, 0,
|
||||||
R.string.waypointslist_edit_waypoint);
|
R.string.waypointslist_show_waypoint);
|
||||||
menu.add(0, Constants.MENU_DELETE, 0,
|
menu.add(0, Constants.MENU_EDIT, 0,
|
||||||
R.string.waypointslist_delete_waypoint).setEnabled(
|
R.string.waypointslist_edit_waypoint);
|
||||||
recordingTrackId < 0 || type == Waypoint.TYPE_WAYPOINT ||
|
menu.add(0, Constants.MENU_DELETE, 0,
|
||||||
info.id != providerUtils.getLastWaypointId(recordingTrackId));
|
R.string.waypointslist_delete_waypoint).setEnabled(
|
||||||
|
recordingTrackId < 0 || type == Waypoint.TYPE_WAYPOINT ||
|
||||||
|
info.id != providerUtils.getLastWaypointId(recordingTrackId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ import android.location.LocationManager;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.HandlerThread;
|
import android.os.HandlerThread;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
@@ -684,9 +683,6 @@ public class TrackDataHub {
|
|||||||
final TrackDataListener.ProviderState state;
|
final TrackDataListener.ProviderState state;
|
||||||
if (!hasProviderEnabled) {
|
if (!hasProviderEnabled) {
|
||||||
state = ProviderState.DISABLED;
|
state = ProviderState.DISABLED;
|
||||||
|
|
||||||
// Give a global warning about this state.
|
|
||||||
Toast.makeText(context, R.string.error_no_gps_location_provider, Toast.LENGTH_LONG).show();
|
|
||||||
} else if (!hasFix) {
|
} else if (!hasFix) {
|
||||||
state = ProviderState.NO_FIX;
|
state = ProviderState.NO_FIX;
|
||||||
} else if (!hasGoodFix) {
|
} else if (!hasGoodFix) {
|
||||||
@@ -824,10 +820,6 @@ public class TrackDataHub {
|
|||||||
public void run() {
|
public void run() {
|
||||||
for (TrackDataListener listener : listeners) {
|
for (TrackDataListener listener : listeners) {
|
||||||
listener.onSelectedTrackChanged(track, isRecordingSelected());
|
listener.onSelectedTrackChanged(track, isRecordingSelected());
|
||||||
|
|
||||||
if (track != null) {
|
|
||||||
listener.onTrackUpdated(track);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -180,6 +180,11 @@ public class SendToFusionTables implements Runnable {
|
|||||||
|
|
||||||
// Get the track meta-data
|
// Get the track meta-data
|
||||||
Track track = providerUtils.getTrack(trackId);
|
Track track = providerUtils.getTrack(trackId);
|
||||||
|
if (track == null) {
|
||||||
|
Log.w(Constants.TAG, "Cannot get track.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String originalDescription = track.getDescription();
|
String originalDescription = track.getDescription();
|
||||||
|
|
||||||
// Create a new table:
|
// Create a new table:
|
||||||
@@ -208,7 +213,6 @@ public class SendToFusionTables implements Runnable {
|
|||||||
Log.d(Constants.TAG, "SendToFusionTables: Done: " + success);
|
Log.d(Constants.TAG, "SendToFusionTables: Done: " + success);
|
||||||
progressIndicator.setProgressValue(PROGRESS_COMPLETE);
|
progressIndicator.setProgressValue(PROGRESS_COMPLETE);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
||||||
final boolean finalSuccess = success;
|
final boolean finalSuccess = success;
|
||||||
final int finalStatusMessageId = statusMessageId;
|
final int finalStatusMessageId = statusMessageId;
|
||||||
context.runOnUiThread(new Runnable() {
|
context.runOnUiThread(new Runnable() {
|
||||||
@@ -305,7 +309,7 @@ public class SendToFusionTables implements Runnable {
|
|||||||
|
|
||||||
Cursor locationsCursor = providerUtils.getLocationsCursor(track.getId(), 0, -1, false);
|
Cursor locationsCursor = providerUtils.getLocationsCursor(track.getId(), 0, -1, false);
|
||||||
try {
|
try {
|
||||||
if (!locationsCursor.moveToFirst()) {
|
if (locationsCursor == null || !locationsCursor.moveToFirst()) {
|
||||||
Log.w(Constants.TAG, "Unable to get any points to upload");
|
Log.w(Constants.TAG, "Unable to get any points to upload");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -392,7 +396,9 @@ public class SendToFusionTables implements Runnable {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
} finally {
|
} finally {
|
||||||
locationsCursor.close();
|
if (locationsCursor != null) {
|
||||||
|
locationsCursor.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -106,6 +106,11 @@ public class SendToMyMaps implements Runnable {
|
|||||||
|
|
||||||
// Get the track meta-data
|
// Get the track meta-data
|
||||||
Track track = providerUtils.getTrack(trackId);
|
Track track = providerUtils.getTrack(trackId);
|
||||||
|
if (track == null) {
|
||||||
|
Log.w(Constants.TAG, "Cannot get track.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String originalDescription = track.getDescription();
|
String originalDescription = track.getDescription();
|
||||||
track.setDescription("<p>" + track.getDescription() + "</p><p>"
|
track.setDescription("<p>" + track.getDescription() + "</p><p>"
|
||||||
+ stringUtils.generateTrackDescription(track, null, null) + "</p>");
|
+ stringUtils.generateTrackDescription(track, null, null) + "</p>");
|
||||||
@@ -206,7 +211,7 @@ public class SendToMyMaps implements Runnable {
|
|||||||
Cursor locationsCursor =
|
Cursor locationsCursor =
|
||||||
providerUtils.getLocationsCursor(track.getId(), 0, -1, false);
|
providerUtils.getLocationsCursor(track.getId(), 0, -1, false);
|
||||||
try {
|
try {
|
||||||
if (!locationsCursor.moveToFirst()) {
|
if (locationsCursor == null || !locationsCursor.moveToFirst()) {
|
||||||
Log.w(TAG, "Unable to get any points to upload");
|
Log.w(TAG, "Unable to get any points to upload");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -297,7 +302,9 @@ public class SendToMyMaps implements Runnable {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
} finally {
|
} finally {
|
||||||
locationsCursor.close();
|
if (locationsCursor != null) {
|
||||||
|
locationsCursor.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ public class TcxTrackWriter implements TrackFormatWriter {
|
|||||||
&& sensorData.getCadence().getState() == Sensor.SensorState.SENDING
|
&& sensorData.getCadence().getState() == Sensor.SensorState.SENDING
|
||||||
&& sensorData.getCadence().hasValue()) {
|
&& sensorData.getCadence().hasValue()) {
|
||||||
pw.print(" <Cadence>");
|
pw.print(" <Cadence>");
|
||||||
pw.print(sensorData.getCadence().getValue());
|
pw.print(Math.min(254, sensorData.getCadence().getValue()));
|
||||||
pw.println("</Cadence>");
|
pw.println("</Cadence>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,10 +16,13 @@
|
|||||||
|
|
||||||
package com.google.android.apps.mytracks.io.file;
|
package com.google.android.apps.mytracks.io.file;
|
||||||
|
|
||||||
|
import static com.google.android.apps.mytracks.Constants.TAG;
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||||
import com.google.android.apps.mytracks.content.Track;
|
import com.google.android.apps.mytracks.content.Track;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A factory to produce track writers for any format.
|
* A factory to produce track writers for any format.
|
||||||
@@ -90,6 +93,11 @@ public class TrackWriterFactory {
|
|||||||
MyTracksProviderUtils providerUtils,
|
MyTracksProviderUtils providerUtils,
|
||||||
long trackId, TrackFileFormat format) {
|
long trackId, TrackFileFormat format) {
|
||||||
Track track = providerUtils.getTrack(trackId);
|
Track track = providerUtils.getTrack(trackId);
|
||||||
|
if (track == null) {
|
||||||
|
Log.w(TAG, "Trying to create a writer for an invalid track, id=" + trackId);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return newWriter(context, providerUtils, track, format);
|
return newWriter(context, providerUtils, track, format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package com.google.android.apps.mytracks.io.sendtogoogle;
|
|||||||
import static com.google.android.apps.mytracks.Constants.TAG;
|
import static com.google.android.apps.mytracks.Constants.TAG;
|
||||||
|
|
||||||
import com.google.android.accounts.Account;
|
import com.google.android.accounts.Account;
|
||||||
|
import com.google.android.apps.analytics.GoogleAnalyticsTracker;
|
||||||
import com.google.android.apps.mytracks.AccountChooser;
|
import com.google.android.apps.mytracks.AccountChooser;
|
||||||
import com.google.android.apps.mytracks.Constants;
|
import com.google.android.apps.mytracks.Constants;
|
||||||
import com.google.android.apps.mytracks.DialogManager;
|
import com.google.android.apps.mytracks.DialogManager;
|
||||||
@@ -34,6 +35,7 @@ import com.google.android.apps.mytracks.io.SendToFusionTables.OnSendCompletedLis
|
|||||||
import com.google.android.apps.mytracks.io.SendToMyMaps;
|
import com.google.android.apps.mytracks.io.SendToMyMaps;
|
||||||
import com.google.android.apps.mytracks.io.mymaps.MapsFacade;
|
import com.google.android.apps.mytracks.io.mymaps.MapsFacade;
|
||||||
import com.google.android.apps.mytracks.io.mymaps.MyMapsConstants;
|
import com.google.android.apps.mytracks.io.mymaps.MyMapsConstants;
|
||||||
|
import com.google.android.apps.mytracks.util.SystemUtils;
|
||||||
import com.google.android.apps.mytracks.util.UriUtils;
|
import com.google.android.apps.mytracks.util.UriUtils;
|
||||||
import com.google.android.maps.mytracks.R;
|
import com.google.android.maps.mytracks.R;
|
||||||
|
|
||||||
@@ -69,6 +71,8 @@ public class SendActivity extends Activity implements ProgressIndicator {
|
|||||||
private MyTracksProviderUtils providerUtils;
|
private MyTracksProviderUtils providerUtils;
|
||||||
private SharedPreferences sharedPreferences;
|
private SharedPreferences sharedPreferences;
|
||||||
|
|
||||||
|
private GoogleAnalyticsTracker tracker;
|
||||||
|
|
||||||
// Authentication
|
// Authentication
|
||||||
private AuthManager lastAuth;
|
private AuthManager lastAuth;
|
||||||
private final HashMap<String, AuthManager> authMap =
|
private final HashMap<String, AuthManager> authMap =
|
||||||
@@ -111,6 +115,11 @@ public class SendActivity extends Activity implements ProgressIndicator {
|
|||||||
super.onStart();
|
super.onStart();
|
||||||
resetState();
|
resetState();
|
||||||
|
|
||||||
|
tracker = GoogleAnalyticsTracker.getInstance();
|
||||||
|
// Start the tracker in manual dispatch mode...
|
||||||
|
tracker.start(getString(R.string.google_analytics_id), getApplicationContext());
|
||||||
|
tracker.setProductVersion("android-mytracks", SystemUtils.getMyTracksVersion(this));
|
||||||
|
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
String type = intent.getType();
|
String type = intent.getType();
|
||||||
@@ -141,6 +150,14 @@ public class SendActivity extends Activity implements ProgressIndicator {
|
|||||||
sendDialog.show();
|
sendDialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop() {
|
||||||
|
tracker.dispatch();
|
||||||
|
tracker.stop();
|
||||||
|
|
||||||
|
super.onStop();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initiates the process to send tracks to google.
|
* Initiates the process to send tracks to google.
|
||||||
* This is called once the user has selected sending options via the
|
* This is called once the user has selected sending options via the
|
||||||
@@ -193,6 +210,8 @@ public class SendActivity extends Activity implements ProgressIndicator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void sendToGoogleMaps(String mapId) {
|
private void sendToGoogleMaps(String mapId) {
|
||||||
|
tracker.trackPageView("/send/maps");
|
||||||
|
|
||||||
SendToMyMaps.OnSendCompletedListener onCompletion = new SendToMyMaps.OnSendCompletedListener() {
|
SendToMyMaps.OnSendCompletedListener onCompletion = new SendToMyMaps.OnSendCompletedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onSendCompleted(String mapId, boolean success, int statusMessage) {
|
public void onSendCompleted(String mapId, boolean success, int statusMessage) {
|
||||||
@@ -247,6 +266,8 @@ public class SendActivity extends Activity implements ProgressIndicator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void sendToFusionTables() {
|
private void sendToFusionTables() {
|
||||||
|
tracker.trackPageView("/send/fusion_tables");
|
||||||
|
|
||||||
OnSendCompletedListener onCompletion = new OnSendCompletedListener() {
|
OnSendCompletedListener onCompletion = new OnSendCompletedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onSendCompleted(String tableId, boolean success,
|
public void onSendCompleted(String tableId, boolean success,
|
||||||
@@ -310,6 +331,8 @@ public class SendActivity extends Activity implements ProgressIndicator {
|
|||||||
|
|
||||||
private void sendToGoogleDocs() {
|
private void sendToGoogleDocs() {
|
||||||
Log.d(TAG, "Sending to Docs....");
|
Log.d(TAG, "Sending to Docs....");
|
||||||
|
tracker.trackPageView("/send/docs");
|
||||||
|
|
||||||
setProgressValue(50);
|
setProgressValue(50);
|
||||||
setProgressMessage(R.string.progress_message_sending_docs);
|
setProgressMessage(R.string.progress_message_sending_docs);
|
||||||
final SendToDocs sender = new SendToDocs(this,
|
final SendToDocs sender = new SendToDocs(this,
|
||||||
@@ -336,6 +359,8 @@ public class SendActivity extends Activity implements ProgressIndicator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void onSendToGoogleDone() {
|
private void onSendToGoogleDone() {
|
||||||
|
tracker.dispatch();
|
||||||
|
|
||||||
final boolean sentToMyMaps = sendDialog.getSendToMyMaps();
|
final boolean sentToMyMaps = sendDialog.getSendToMyMaps();
|
||||||
final boolean sentToFusionTables = sendDialog.getSendToFusionTables();
|
final boolean sentToFusionTables = sendDialog.getSendToFusionTables();
|
||||||
List<SendResult> results = makeSendToGoogleResults();
|
List<SendResult> results = makeSendToGoogleResults();
|
||||||
|
|||||||
+40
@@ -660,6 +660,10 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Waypoint getFirstWaypoint(long trackId) {
|
public Waypoint getFirstWaypoint(long trackId) {
|
||||||
|
if (trackId < 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
Cursor cursor = contentResolver.query(
|
Cursor cursor = contentResolver.query(
|
||||||
WaypointsColumns.CONTENT_URI,
|
WaypointsColumns.CONTENT_URI,
|
||||||
null /*projection*/,
|
null /*projection*/,
|
||||||
@@ -682,6 +686,10 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Waypoint getWaypoint(long waypointId) {
|
public Waypoint getWaypoint(long waypointId) {
|
||||||
|
if (waypointId < 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
Cursor cursor = contentResolver.query(
|
Cursor cursor = contentResolver.query(
|
||||||
WaypointsColumns.CONTENT_URI,
|
WaypointsColumns.CONTENT_URI,
|
||||||
null /*projection*/,
|
null /*projection*/,
|
||||||
@@ -704,6 +712,10 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getLastLocationId(long trackId) {
|
public long getLastLocationId(long trackId) {
|
||||||
|
if (trackId < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
final String[] projection = {"_id"};
|
final String[] projection = {"_id"};
|
||||||
Cursor cursor = contentResolver.query(
|
Cursor cursor = contentResolver.query(
|
||||||
TrackPointsColumns.CONTENT_URI,
|
TrackPointsColumns.CONTENT_URI,
|
||||||
@@ -728,6 +740,10 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getFirstWaypointId(long trackId) {
|
public long getFirstWaypointId(long trackId) {
|
||||||
|
if (trackId < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
final String[] projection = {"_id"};
|
final String[] projection = {"_id"};
|
||||||
Cursor cursor = contentResolver.query(
|
Cursor cursor = contentResolver.query(
|
||||||
WaypointsColumns.CONTENT_URI,
|
WaypointsColumns.CONTENT_URI,
|
||||||
@@ -752,6 +768,10 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getLastWaypointId(long trackId) {
|
public long getLastWaypointId(long trackId) {
|
||||||
|
if (trackId < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
final String[] projection = {"_id"};
|
final String[] projection = {"_id"};
|
||||||
Cursor cursor = contentResolver.query(
|
Cursor cursor = contentResolver.query(
|
||||||
WaypointsColumns.CONTENT_URI,
|
WaypointsColumns.CONTENT_URI,
|
||||||
@@ -815,6 +835,10 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location getLocation(long id) {
|
public Location getLocation(long id) {
|
||||||
|
if (id < 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
String selection = TrackPointsColumns._ID + "=" + id;
|
String selection = TrackPointsColumns._ID + "=" + id;
|
||||||
return findLocationBy(selection);
|
return findLocationBy(selection);
|
||||||
}
|
}
|
||||||
@@ -822,6 +846,10 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
@Override
|
@Override
|
||||||
public Cursor getLocationsCursor(long trackId, long minTrackPointId,
|
public Cursor getLocationsCursor(long trackId, long minTrackPointId,
|
||||||
int maxLocations, boolean descending) {
|
int maxLocations, boolean descending) {
|
||||||
|
if (trackId < 0 || maxLocations < 1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
String selection;
|
String selection;
|
||||||
if (minTrackPointId >= 0) {
|
if (minTrackPointId >= 0) {
|
||||||
selection = String.format("%s=%d AND %s%s%d",
|
selection = String.format("%s=%d AND %s%s%d",
|
||||||
@@ -842,6 +870,10 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
@Override
|
@Override
|
||||||
public Cursor getWaypointsCursor(long trackId, long minWaypointId,
|
public Cursor getWaypointsCursor(long trackId, long minWaypointId,
|
||||||
int maxWaypoints) {
|
int maxWaypoints) {
|
||||||
|
if (trackId < 0 || maxWaypoints < 1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
String selection;
|
String selection;
|
||||||
if (minWaypointId > 0) {
|
if (minWaypointId > 0) {
|
||||||
selection = String.format("%s=%d AND %s>=%d",
|
selection = String.format("%s=%d AND %s>=%d",
|
||||||
@@ -863,6 +895,10 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Track getTrack(long id) {
|
public Track getTrack(long id) {
|
||||||
|
if (id < 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
String select = TracksColumns._ID + "=" + id;
|
String select = TracksColumns._ID + "=" + id;
|
||||||
return findTrackBy(select);
|
return findTrackBy(select);
|
||||||
}
|
}
|
||||||
@@ -929,6 +965,10 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean trackExists(long id) {
|
public boolean trackExists(long id) {
|
||||||
|
if (id < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Cursor cursor = null;
|
Cursor cursor = null;
|
||||||
try {
|
try {
|
||||||
final String[] projection = { TracksColumns._ID };
|
final String[] projection = { TracksColumns._ID };
|
||||||
|
|||||||
Reference in New Issue
Block a user