merge heads

This commit is contained in:
Jimmy Shih
2013-04-29 17:43:37 -07:00
7 changed files with 179 additions and 201 deletions
+17 -11
View File
@@ -2252,17 +2252,28 @@ limitations under the License.
Recording your track… Recording your track…
</string> </string>
<!-- Track Delete -->
<string name="track_delete_all_confirm_message"
translation_description="When deleting all the tracks, the confirmation message.">
All tracks and markers will be permanently deleted from the device. If Google Drive sync is
enabled, this will disable it. No tracks will be deleted on Google Drive.
</string>
<string name="track_delete_one_confirm_message"
translation_description="When deleting one track, the confirmation message.">
The track and its markers will be permanently deleted from the device. If Google Drive sync is
enabled, this will also delete the track on Google Drive.
</string>
<string name="track_delete_multiple_confirm_message"
translation_description="When deleting multiple tracks, the confirmation message.">
The tracks and their markers will be permanently deleted from the device. If Google Drive sync
is enabled, this will also delete the tracks on Google Drive.
</string>
<!-- Track Detail --> <!-- Track Detail -->
<string name="track_detail_chart_tab" <string name="track_detail_chart_tab"
translation_description="In the track detail page, the title of the tab showing the chart."> translation_description="In the track detail page, the title of the tab showing the chart.">
Chart Chart
</string> </string>
<string name="track_detail_delete_confirm_message"
translation_description="When deleting a track, the confirmation message informing the user that
the track and its markers will be permanently deleted from the device.">
The track and its markers will be permanently deleted from the device. If Google Drive sync is
enabled, this will also delete the track on Google Drive.
</string>
<string name="track_detail_install_earth_message" <string name="track_detail_install_earth_message"
translation_description="When playing a track, the message informing the user that he needs translation_description="When playing a track, the message informing the user that he needs
Google Earth to play the track and asking him if he wants to install Google Earth from the Google Earth to play the track and asking him if he wants to install Google Earth from the
@@ -2304,11 +2315,6 @@ limitations under the License.
</string> </string>
<!-- Track List --> <!-- Track List -->
<string name="track_list_delete_all_confirm_message"
translation_description="When deleting all the tracks, the confirmation dialog message.">
All tracks and markers will be permanently deleted from the device. If Google Drive sync is
enabled, this will disable it. No tracks will be deleted on Google Drive.
</string>
<string name="track_list_empty_message" <string name="track_list_empty_message"
translation_description="When the track list is empty, the message informing the user to click translation_description="When the track list is empty, the message informing the user to click
on the record button to start a new recording"> on the record button to start a new recording">
@@ -26,8 +26,8 @@ import com.google.android.apps.mytracks.content.Waypoint;
import com.google.android.apps.mytracks.content.Waypoint.WaypointType; import com.google.android.apps.mytracks.content.Waypoint.WaypointType;
import com.google.android.apps.mytracks.fragments.DeleteOneMarkerDialogFragment; import com.google.android.apps.mytracks.fragments.DeleteOneMarkerDialogFragment;
import com.google.android.apps.mytracks.fragments.DeleteOneMarkerDialogFragment.DeleteOneMarkerCaller; import com.google.android.apps.mytracks.fragments.DeleteOneMarkerDialogFragment.DeleteOneMarkerCaller;
import com.google.android.apps.mytracks.fragments.DeleteOneTrackDialogFragment; import com.google.android.apps.mytracks.fragments.DeleteTrackDialogFragment;
import com.google.android.apps.mytracks.fragments.DeleteOneTrackDialogFragment.DeleteOneTrackCaller; import com.google.android.apps.mytracks.fragments.DeleteTrackDialogFragment.DeleteTrackCaller;
import com.google.android.apps.mytracks.services.MyTracksLocationManager; import com.google.android.apps.mytracks.services.MyTracksLocationManager;
import com.google.android.apps.mytracks.services.TrackRecordingServiceConnection; import com.google.android.apps.mytracks.services.TrackRecordingServiceConnection;
import com.google.android.apps.mytracks.stats.TripStatistics; import com.google.android.apps.mytracks.stats.TripStatistics;
@@ -75,7 +75,7 @@ import java.util.SortedSet;
* @author Rodrigo Damazio * @author Rodrigo Damazio
*/ */
public class SearchListActivity extends AbstractSendToGoogleActivity public class SearchListActivity extends AbstractSendToGoogleActivity
implements DeleteOneTrackCaller, DeleteOneMarkerCaller { implements DeleteTrackCaller, DeleteOneMarkerCaller {
private static final String TAG = SearchListActivity.class.getSimpleName(); private static final String TAG = SearchListActivity.class.getSimpleName();
@@ -355,8 +355,8 @@ public class SearchListActivity extends AbstractSendToGoogleActivity
getSupportFragmentManager(), getSupportFragmentManager(),
DeleteOneMarkerDialogFragment.DELETE_ONE_MARKER_DIALOG_TAG); DeleteOneMarkerDialogFragment.DELETE_ONE_MARKER_DIALOG_TAG);
} else { } else {
DeleteOneTrackDialogFragment.newInstance(trackId).show(getSupportFragmentManager(), DeleteTrackDialogFragment.newInstance(false, new long[] { trackId })
DeleteOneTrackDialogFragment.DELETE_ONE_TRACK_DIALOG_TAG); .show(getSupportFragmentManager(), DeleteTrackDialogFragment.DELETE_TRACK_DIALOG_TAG);
} }
return true; return true;
default: default:
@@ -509,7 +509,7 @@ public class SearchListActivity extends AbstractSendToGoogleActivity
} }
@Override @Override
public void onDeleteOneTrackDone() { public void onDeleteTrackDone() {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
@@ -25,8 +25,8 @@ import com.google.android.apps.mytracks.fragments.ChartFragment;
import com.google.android.apps.mytracks.fragments.ChooseUploadServiceDialogFragment; import com.google.android.apps.mytracks.fragments.ChooseUploadServiceDialogFragment;
import com.google.android.apps.mytracks.fragments.ChooseUploadServiceDialogFragment.ChooseUploadServiceCaller; import com.google.android.apps.mytracks.fragments.ChooseUploadServiceDialogFragment.ChooseUploadServiceCaller;
import com.google.android.apps.mytracks.fragments.ConfirmDialogFragment; import com.google.android.apps.mytracks.fragments.ConfirmDialogFragment;
import com.google.android.apps.mytracks.fragments.DeleteOneTrackDialogFragment; import com.google.android.apps.mytracks.fragments.DeleteTrackDialogFragment;
import com.google.android.apps.mytracks.fragments.DeleteOneTrackDialogFragment.DeleteOneTrackCaller; import com.google.android.apps.mytracks.fragments.DeleteTrackDialogFragment.DeleteTrackCaller;
import com.google.android.apps.mytracks.fragments.FrequencyDialogFragment; import com.google.android.apps.mytracks.fragments.FrequencyDialogFragment;
import com.google.android.apps.mytracks.fragments.InstallEarthDialogFragment; import com.google.android.apps.mytracks.fragments.InstallEarthDialogFragment;
import com.google.android.apps.mytracks.fragments.MyTracksMapFragment; import com.google.android.apps.mytracks.fragments.MyTracksMapFragment;
@@ -72,7 +72,7 @@ import java.util.Locale;
* @author Rodrigo Damazio * @author Rodrigo Damazio
*/ */
public class TrackDetailActivity extends AbstractSendToGoogleActivity public class TrackDetailActivity extends AbstractSendToGoogleActivity
implements ChooseUploadServiceCaller, DeleteOneTrackCaller { implements ChooseUploadServiceCaller, DeleteTrackCaller {
public static final String EXTRA_TRACK_ID = "track_id"; public static final String EXTRA_TRACK_ID = "track_id";
public static final String EXTRA_MARKER_ID = "marker_id"; public static final String EXTRA_MARKER_ID = "marker_id";
@@ -405,8 +405,8 @@ public class TrackDetailActivity extends AbstractSendToGoogleActivity
startActivity(intent); startActivity(intent);
return true; return true;
case R.id.track_detail_delete: case R.id.track_detail_delete:
DeleteOneTrackDialogFragment.newInstance(trackId).show( DeleteTrackDialogFragment.newInstance(false, new long[] { trackId })
getSupportFragmentManager(), DeleteOneTrackDialogFragment.DELETE_ONE_TRACK_DIALOG_TAG); .show(getSupportFragmentManager(), DeleteTrackDialogFragment.DELETE_TRACK_DIALOG_TAG);
return true; return true;
case R.id.track_detail_sensor_state: case R.id.track_detail_sensor_state:
intent = IntentUtils.newIntent(this, SensorStateActivity.class); intent = IntentUtils.newIntent(this, SensorStateActivity.class);
@@ -486,7 +486,7 @@ public class TrackDetailActivity extends AbstractSendToGoogleActivity
} }
@Override @Override
public void onDeleteOneTrackDone() { public void onDeleteTrackDone() {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
@@ -23,9 +23,8 @@ import com.google.android.apps.mytracks.content.TrackDataListener;
import com.google.android.apps.mytracks.content.TrackDataType; import com.google.android.apps.mytracks.content.TrackDataType;
import com.google.android.apps.mytracks.content.TracksColumns; import com.google.android.apps.mytracks.content.TracksColumns;
import com.google.android.apps.mytracks.content.Waypoint; import com.google.android.apps.mytracks.content.Waypoint;
import com.google.android.apps.mytracks.fragments.DeleteAllTrackDialogFragment; import com.google.android.apps.mytracks.fragments.DeleteTrackDialogFragment;
import com.google.android.apps.mytracks.fragments.DeleteOneTrackDialogFragment; import com.google.android.apps.mytracks.fragments.DeleteTrackDialogFragment.DeleteTrackCaller;
import com.google.android.apps.mytracks.fragments.DeleteOneTrackDialogFragment.DeleteOneTrackCaller;
import com.google.android.apps.mytracks.fragments.EnableSyncDialogFragment; import com.google.android.apps.mytracks.fragments.EnableSyncDialogFragment;
import com.google.android.apps.mytracks.fragments.EnableSyncDialogFragment.EnableSyncCaller; import com.google.android.apps.mytracks.fragments.EnableSyncDialogFragment.EnableSyncCaller;
import com.google.android.apps.mytracks.fragments.EulaDialogFragment; import com.google.android.apps.mytracks.fragments.EulaDialogFragment;
@@ -94,7 +93,7 @@ import java.util.Locale;
* @author Leif Hendrik Wilden * @author Leif Hendrik Wilden
*/ */
public class TrackListActivity extends AbstractSendToGoogleActivity public class TrackListActivity extends AbstractSendToGoogleActivity
implements EulaCaller, EnableSyncCaller, DeleteOneTrackCaller { implements EulaCaller, EnableSyncCaller, DeleteTrackCaller {
private static final String TAG = TrackListActivity.class.getSimpleName(); private static final String TAG = TrackListActivity.class.getSimpleName();
private static final String START_GPS_KEY = "start_gps_key"; private static final String START_GPS_KEY = "start_gps_key";
@@ -602,8 +601,8 @@ public class TrackListActivity extends AbstractSendToGoogleActivity
startSaveActivity(TrackFileFormat.TCX); startSaveActivity(TrackFileFormat.TCX);
return true; return true;
case R.id.track_list_delete_all: case R.id.track_list_delete_all:
new DeleteAllTrackDialogFragment().show( DeleteTrackDialogFragment.newInstance(true, new long[] {})
getSupportFragmentManager(), DeleteAllTrackDialogFragment.DELETE_ALL_TRACK_DIALOG_TAG); .show(getSupportFragmentManager(), DeleteTrackDialogFragment.DELETE_TRACK_DIALOG_TAG);
return true; return true;
case R.id.track_list_aggregated_statistics: case R.id.track_list_aggregated_statistics:
intent = IntentUtils.newIntent(this, AggregatedStatsActivity.class); intent = IntentUtils.newIntent(this, AggregatedStatsActivity.class);
@@ -659,7 +658,7 @@ public class TrackListActivity extends AbstractSendToGoogleActivity
} }
@Override @Override
public void onDeleteOneTrackDone() { public void onDeleteTrackDone() {
// Do nothing // Do nothing
} }
@@ -827,8 +826,8 @@ public class TrackListActivity extends AbstractSendToGoogleActivity
startActivity(intent); startActivity(intent);
return true; return true;
case R.id.list_context_menu_delete: case R.id.list_context_menu_delete:
DeleteOneTrackDialogFragment.newInstance(trackId).show( DeleteTrackDialogFragment.newInstance(false, new long[] { trackId })
getSupportFragmentManager(), DeleteOneTrackDialogFragment.DELETE_ONE_TRACK_DIALOG_TAG); .show(getSupportFragmentManager(), DeleteTrackDialogFragment.DELETE_TRACK_DIALOG_TAG);
return true; return true;
default: default:
return false; return false;
@@ -1,62 +0,0 @@
/*
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.android.apps.mytracks.fragments;
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
import com.google.android.apps.mytracks.io.sync.SyncUtils;
import com.google.android.apps.mytracks.util.DialogUtils;
import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.maps.mytracks.R;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentActivity;
/**
* A DialogFragment to delete all tracks.
*
* @author Jimmy Shih
*/
public class DeleteAllTrackDialogFragment extends DialogFragment {
public static final String DELETE_ALL_TRACK_DIALOG_TAG = "deleteAllTrackDialog";
private FragmentActivity fragmentActivity;
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
fragmentActivity = getActivity();
return DialogUtils.createConfirmationDialog(fragmentActivity,
R.string.track_list_delete_all_confirm_message, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
new Thread(new Runnable() {
@Override
public void run() {
PreferencesUtils.setBoolean(
fragmentActivity, R.string.drive_sync_key, PreferencesUtils.DRIVE_SYNC_DEFAULT);
SyncUtils.disableSync(fragmentActivity);
SyncUtils.clearSyncState(fragmentActivity);
MyTracksProviderUtils.Factory.get(fragmentActivity).deleteAllTracks();
}
}).start();
}
});
}
}
@@ -1,107 +0,0 @@
/*
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.android.apps.mytracks.fragments;
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
import com.google.android.apps.mytracks.services.TrackRecordingServiceConnection;
import com.google.android.apps.mytracks.util.DialogUtils;
import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.apps.mytracks.util.TrackRecordingServiceConnectionUtils;
import com.google.android.maps.mytracks.R;
import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentActivity;
/**
* A DialogFragment to delete one track.
*
* @author Jimmy Shih
*/
public class DeleteOneTrackDialogFragment extends DialogFragment {
/**
* Interface for caller of this dialog fragment.
*
* @author Jimmy Shih
*/
public interface DeleteOneTrackCaller {
/**
* Gets the track recording service connection.
*/
public TrackRecordingServiceConnection getTrackRecordingServiceConnection();
/**
* Called when delete one track is done.
*/
public void onDeleteOneTrackDone();
}
public static final String DELETE_ONE_TRACK_DIALOG_TAG = "deleteOneTrackDialog";
private static final String KEY_TRACK_ID = "trackId";
public static DeleteOneTrackDialogFragment newInstance(long trackId) {
Bundle bundle = new Bundle();
bundle.putLong(KEY_TRACK_ID, trackId);
DeleteOneTrackDialogFragment deleteOneTrackDialogFragment = new DeleteOneTrackDialogFragment();
deleteOneTrackDialogFragment.setArguments(bundle);
return deleteOneTrackDialogFragment;
}
private DeleteOneTrackCaller caller;
private FragmentActivity fragmentActivity;
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
try {
caller = (DeleteOneTrackCaller) activity;
} catch (ClassCastException e) {
throw new ClassCastException(
activity.toString() + " must implement " + DeleteOneTrackCaller.class.getSimpleName());
}
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
fragmentActivity = getActivity();
return DialogUtils.createConfirmationDialog(fragmentActivity,
R.string.track_detail_delete_confirm_message, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
final long trackId = getArguments().getLong(KEY_TRACK_ID);
if (trackId
== PreferencesUtils.getLong(fragmentActivity, R.string.recording_track_id_key)) {
TrackRecordingServiceConnectionUtils.stopRecording(
fragmentActivity, caller.getTrackRecordingServiceConnection(), false);
}
new Thread(new Runnable() {
@Override
public void run() {
MyTracksProviderUtils.Factory.get(fragmentActivity).deleteTrack(trackId);
caller.onDeleteOneTrackDone();
}
}).start();
}
});
}
}
@@ -0,0 +1,142 @@
/*
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.android.apps.mytracks.fragments;
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
import com.google.android.apps.mytracks.io.sync.SyncUtils;
import com.google.android.apps.mytracks.services.TrackRecordingServiceConnection;
import com.google.android.apps.mytracks.util.DialogUtils;
import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.apps.mytracks.util.TrackRecordingServiceConnectionUtils;
import com.google.android.maps.mytracks.R;
import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentActivity;
/**
* A DialogFragment to track.
*
* @author Jimmy Shih
*/
public class DeleteTrackDialogFragment extends DialogFragment {
/**
* Interface for caller of this dialog fragment.
*
* @author Jimmy Shih
*/
public interface DeleteTrackCaller {
/**
* Gets the track recording service connection.
*/
public TrackRecordingServiceConnection getTrackRecordingServiceConnection();
/**
* Called when delete track is done.
*/
public void onDeleteTrackDone();
}
public static final String DELETE_TRACK_DIALOG_TAG = "deleteTrackDialog";
private static final String KEY_DELETE_ALL = "deleteAll";
private static final String KEY_TRACK_IDS = "trackIds";
/**
* Create a new instance.
*
* @param deleteAll true to delete all tracks
* @param trackIds list of track ids to delete when deleteAll if false
*/
public static DeleteTrackDialogFragment newInstance(boolean deleteAll, long[] trackIds) {
Bundle bundle = new Bundle();
bundle.putBoolean(KEY_DELETE_ALL, deleteAll);
bundle.putLongArray(KEY_TRACK_IDS, trackIds);
DeleteTrackDialogFragment deleteTrackDialogFragment = new DeleteTrackDialogFragment();
deleteTrackDialogFragment.setArguments(bundle);
return deleteTrackDialogFragment;
}
private DeleteTrackCaller caller;
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
try {
caller = (DeleteTrackCaller) activity;
} catch (ClassCastException e) {
throw new ClassCastException(
activity.toString() + " must implement " + DeleteTrackCaller.class.getSimpleName());
}
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
boolean deleteAll = getArguments().getBoolean(KEY_DELETE_ALL);
final FragmentActivity fragmentActivity = getActivity();
if (deleteAll) {
return DialogUtils.createConfirmationDialog(fragmentActivity,
R.string.track_delete_all_confirm_message, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
new Thread(new Runnable() {
@Override
public void run() {
PreferencesUtils.setBoolean(fragmentActivity, R.string.drive_sync_key,
PreferencesUtils.DRIVE_SYNC_DEFAULT);
SyncUtils.disableSync(fragmentActivity);
SyncUtils.clearSyncState(fragmentActivity);
MyTracksProviderUtils.Factory.get(fragmentActivity).deleteAllTracks();
caller.onDeleteTrackDone();
}
}).start();
}
});
} else {
final long[] trackIds = getArguments().getLongArray(KEY_TRACK_IDS);
int messageId = trackIds.length > 1 ? R.string.track_delete_multiple_confirm_message
: R.string.track_delete_one_confirm_message;
return DialogUtils.createConfirmationDialog(
fragmentActivity, messageId, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
for (long trackId : trackIds) {
if (trackId == PreferencesUtils.getLong(
fragmentActivity, R.string.recording_track_id_key)) {
TrackRecordingServiceConnectionUtils.stopRecording(
fragmentActivity, caller.getTrackRecordingServiceConnection(), false);
}
}
new Thread(new Runnable() {
@Override
public void run() {
for (long id : trackIds) {
MyTracksProviderUtils.Factory.get(fragmentActivity).deleteTrack(id);
}
caller.onDeleteTrackDone();
}
}).start();
}
});
}
}
}