diff --git a/MyTracks/src/com/google/android/apps/mytracks/DialogManager.java b/MyTracks/src/com/google/android/apps/mytracks/DialogManager.java index a79df4864..5aeeb3e23 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/DialogManager.java +++ b/MyTracks/src/com/google/android/apps/mytracks/DialogManager.java @@ -27,18 +27,18 @@ import android.view.View; import android.view.WindowManager.BadTokenException; /** - * A class to handle a dialog related events for My Tracks. + * A class to handle all dialog related events for My Tracks. * * @author Sandor Dornbush */ public class DialogManager { - public static final int DIALOG_PROGRESS = 1; + public static final int DIALOG_CHART_SETTINGS = 1; public static final int DIALOG_IMPORT_PROGRESS = 2; - public static final int DIALOG_WRITE_PROGRESS = 3; + public static final int DIALOG_PROGRESS = 3; public static final int DIALOG_SEND_TO_GOOGLE = 4; public static final int DIALOG_SEND_TO_GOOGLE_RESULT = 5; - public static final int DIALOG_CHART_SETTINGS = 6; + public static final int DIALOG_WRITE_PROGRESS = 6; private ProgressDialog progressDialog; private ProgressDialog importProgressDialog; @@ -55,15 +55,9 @@ public class DialogManager { protected Dialog onCreateDialog(int id, Bundle args) { switch (id) { - case DIALOG_PROGRESS: - progressDialog = new ProgressDialog(activity); - progressDialog.setIcon(android.R.drawable.ic_dialog_info); - progressDialog.setTitle(activity.getString(R.string.progress_title)); - progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); - progressDialog.setMessage(""); - progressDialog.setMax(100); - progressDialog.setProgress(10); - return progressDialog; + case DIALOG_CHART_SETTINGS: + chartSettingsDialog = new ChartSettingsDialog(activity); + return chartSettingsDialog; case DIALOG_IMPORT_PROGRESS: importProgressDialog = new ProgressDialog(activity); importProgressDialog.setIcon(android.R.drawable.ic_dialog_info); @@ -73,15 +67,15 @@ public class DialogManager { importProgressDialog.setMessage( activity.getString(R.string.import_progress_message)); return importProgressDialog; - case DIALOG_WRITE_PROGRESS: - writeProgressDialog = new ProgressDialog(activity); - writeProgressDialog.setIcon(android.R.drawable.ic_dialog_info); - writeProgressDialog.setTitle( - activity.getString(R.string.progress_title)); - writeProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); - writeProgressDialog.setMessage( - activity.getString(R.string.write_progress_message)); - return writeProgressDialog; + case DIALOG_PROGRESS: + progressDialog = new ProgressDialog(activity); + progressDialog.setIcon(android.R.drawable.ic_dialog_info); + progressDialog.setTitle(activity.getString(R.string.progress_title)); + progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); + progressDialog.setMessage(""); + progressDialog.setMax(100); + progressDialog.setProgress(10); + return progressDialog; case DIALOG_SEND_TO_GOOGLE: sendToGoogleDialog = new SendToGoogleDialog(activity); return sendToGoogleDialog; @@ -100,9 +94,15 @@ public class DialogManager { }); sendToGoogleResultDialog = builder.create(); return sendToGoogleResultDialog; - case DIALOG_CHART_SETTINGS: - chartSettingsDialog = new ChartSettingsDialog(activity); - return chartSettingsDialog; + case DIALOG_WRITE_PROGRESS: + writeProgressDialog = new ProgressDialog(activity); + writeProgressDialog.setIcon(android.R.drawable.ic_dialog_info); + writeProgressDialog.setTitle( + activity.getString(R.string.progress_title)); + writeProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); + writeProgressDialog.setMessage( + activity.getString(R.string.write_progress_message)); + return writeProgressDialog; } return null; } diff --git a/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java b/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java index 756afa7ad..be2e75360 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java +++ b/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java @@ -1,12 +1,12 @@ /* * Copyright 2008 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 @@ -102,9 +102,9 @@ public class MyTracks extends TabActivity implements OnTouchListener, private static MyTracks instance; private ChartActivity chartActivity; - + /* - * Authentication. + * Authentication */ private AuthManager auth; private final HashMap authMap = @@ -159,7 +159,7 @@ public class MyTracks extends TabActivity implements OnTouchListener, * Utilities to deal with the database. */ private MyTracksProviderUtils providerUtils; - + private SharedPreferences sharedPreferences; /** @@ -190,7 +190,7 @@ public class MyTracks extends TabActivity implements OnTouchListener, trackRecordingService = null; } }; - + /** * Whether {@link #serviceConnection} is bound or not. */ @@ -226,11 +226,11 @@ public class MyTracks extends TabActivity implements OnTouchListener, /** * Checks whether we have a track recording session in progress. * In some cases, when the service has crashed or has been restarted - * by the system, we fall back to the shared preferences. - * + * by the system, we fall back to the shared preferences. + * * @return true if the activity is bound to the track recording service and * the service is recording a track or in case the service is down, - * based on settings from the shared preferences. + * based on settings from the shared preferences. */ public boolean isRecording() { if (trackRecordingService == null) { @@ -241,12 +241,12 @@ public class MyTracks extends TabActivity implements OnTouchListener, return trackRecordingService.isRecording(); } catch (RemoteException e) { Log.e(MyTracksConstants.TAG, "MyTracks: Remote exception.", e); - + // Fall back to alternative check method. return isRecordingBasedOnSharedPreferences(); } } - + private boolean isRecordingBasedOnSharedPreferences() { // TrackRecordingServices guarantees that recordingTrackId is set to // -1 if the track has been stopped. @@ -345,7 +345,7 @@ public class MyTracks extends TabActivity implements OnTouchListener, Log.d(MyTracksConstants.TAG, "Received an intent with no action."); } } - + @Override protected void onDestroy() { Log.d(MyTracksConstants.TAG, "MyTracks.onDestroy"); @@ -1046,7 +1046,7 @@ public class MyTracks extends TabActivity implements OnTouchListener, doLogin(results, requestCode, service, null); } } - + private void doLogin(final Intent results, final int requestCode, final String service, final Account account) { auth.doLogin(new Runnable() { @@ -1056,7 +1056,7 @@ public class MyTracks extends TabActivity implements OnTouchListener, } }, account); } - + private void startRecordingNewTrack( ITrackRecordingService trackRecordingService) { try { @@ -1324,11 +1324,11 @@ public class MyTracks extends TabActivity implements OnTouchListener, public String getSendToMyMapsMapId() { return sendToMyMapsMapId; } - + public boolean getSendToGoogleSuccess() { return sendToMyMapsSuccess && sendToDocsSuccess; } - + // @VisibleForTesting long getRecordingTrackId() { return recordingTrackId;