forked from upstream-mirrors/OpenTracks
Merge with head and address comments.
This commit is contained in:
@@ -3,3 +3,4 @@ syntax:glob
|
||||
*/bin
|
||||
*/gen/**
|
||||
.metadata
|
||||
MyTracksTest/annotations.log
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
android:value="AEdPqrEAAAAIi-_QiwoRSc9_bAC9cmuNXTQyU8ajJmGtKdhskQ" />
|
||||
|
||||
<provider android:name="com.google.android.apps.mytracks.content.MyTracksProvider"
|
||||
android:multiprocess="true"
|
||||
android:process=":trackrecord"
|
||||
android:authorities="com.google.android.maps.mytracks" />
|
||||
|
||||
<activity android:name="com.google.android.apps.mytracks.MyTracks"
|
||||
@@ -101,6 +101,9 @@
|
||||
<uses-permission android:name="com.google.android.googleapps.permission.GOOGLE_AUTH.writely" />
|
||||
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
|
||||
|
||||
<!-- Permissions for misc services -->
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
|
||||
<uses-sdk android:minSdkVersion="3"/>
|
||||
<supports-screens
|
||||
android:largeScreens="true"
|
||||
|
||||
@@ -21,6 +21,7 @@ import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
@@ -51,7 +52,7 @@ public class DialogManager {
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
protected Dialog onCreateDialog(int id) {
|
||||
protected Dialog onCreateDialog(int id, Bundle args) {
|
||||
switch (id) {
|
||||
case DIALOG_PROGRESS:
|
||||
progressDialog = new ProgressDialog(activity);
|
||||
|
||||
@@ -18,6 +18,10 @@ package com.google.android.apps.mytracks;
|
||||
import com.google.android.accounts.Account;
|
||||
import com.google.android.apps.mymaps.MyMapsConstants;
|
||||
import com.google.android.apps.mymaps.MyMapsList;
|
||||
import static com.google.android.apps.mytracks.DialogManager.DIALOG_PROGRESS;
|
||||
import static com.google.android.apps.mytracks.DialogManager.DIALOG_SEND_TO_GOOGLE;
|
||||
import static com.google.android.apps.mytracks.DialogManager.DIALOG_IMPORT_PROGRESS;
|
||||
import static com.google.android.apps.mytracks.DialogManager.DIALOG_WRITE_PROGRESS;
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.Track;
|
||||
import com.google.android.apps.mytracks.content.Waypoint;
|
||||
@@ -107,9 +111,8 @@ public class MyTracks extends TabActivity implements OnTouchListener,
|
||||
}
|
||||
|
||||
/*
|
||||
* Authentication:
|
||||
* Authentication
|
||||
*/
|
||||
|
||||
private AuthManager auth;
|
||||
private final HashMap<String, AuthManager> authMap =
|
||||
new HashMap<String, AuthManager>();
|
||||
@@ -277,7 +280,7 @@ public class MyTracks extends TabActivity implements OnTouchListener,
|
||||
new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
|
||||
layout.setLayoutParams(params);
|
||||
navControls =
|
||||
new NavControls(this, layout, leftIcons, rightIcons, changeTab);
|
||||
new NavControls(this, layout, leftIcons, rightIcons, changeTab);
|
||||
navControls.show();
|
||||
tabHost.addView(layout);
|
||||
layout.setOnTouchListener(this);
|
||||
@@ -345,7 +348,7 @@ public class MyTracks extends TabActivity implements OnTouchListener,
|
||||
@Override
|
||||
protected void onStop() {
|
||||
Log.d(MyTracksConstants.TAG, "MyTracks.onStop");
|
||||
// Clean up any temporary GPX and KML files.
|
||||
// Clean up any temporary track files.
|
||||
(new TempFileCleaner()).clean();
|
||||
super.onStop();
|
||||
}
|
||||
@@ -381,8 +384,8 @@ public class MyTracks extends TabActivity implements OnTouchListener,
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected Dialog onCreateDialog(int id) {
|
||||
return dialogManager.onCreateDialog(id);
|
||||
protected Dialog onCreateDialog(int id, Bundle args) {
|
||||
return dialogManager.onCreateDialog(id, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -423,17 +426,17 @@ public class MyTracks extends TabActivity implements OnTouchListener,
|
||||
authenticate(results, MyTracksConstants.SEND_TO_GOOGLE,
|
||||
MyMapsConstants.MAPSHOP_SERVICE);
|
||||
} else {
|
||||
dismissDialogSafely(DialogManager.DIALOG_PROGRESS);
|
||||
dismissDialogSafely(DIALOG_PROGRESS);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MyTracksConstants.GET_LOGIN: {
|
||||
if (resultCode == RESULT_OK && auth != null) {
|
||||
if (!auth.authResult(resultCode, results)) {
|
||||
dismissDialogSafely(DialogManager.DIALOG_PROGRESS);
|
||||
dismissDialogSafely(DIALOG_PROGRESS);
|
||||
}
|
||||
} else {
|
||||
dismissDialogSafely(DialogManager.DIALOG_PROGRESS);
|
||||
dismissDialogSafely(DIALOG_PROGRESS);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -489,7 +492,7 @@ public class MyTracks extends TabActivity implements OnTouchListener,
|
||||
authenticate(results,
|
||||
MyTracksConstants.AUTHENTICATE_TO_TRIX, "writely");
|
||||
} else {
|
||||
dismissDialogSafely(DialogManager.DIALOG_PROGRESS);
|
||||
dismissDialogSafely(DIALOG_PROGRESS);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -500,7 +503,7 @@ public class MyTracks extends TabActivity implements OnTouchListener,
|
||||
R.string.progress_message_authenticating_docs);
|
||||
authenticate(results, MyTracksConstants.SEND_TO_DOCS, "wise");
|
||||
} else {
|
||||
dismissDialogSafely(DialogManager.DIALOG_PROGRESS);
|
||||
dismissDialogSafely(DIALOG_PROGRESS);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -515,7 +518,7 @@ public class MyTracks extends TabActivity implements OnTouchListener,
|
||||
Runnable onCompletion = new Runnable() {
|
||||
public void run() {
|
||||
setProgressValue(100);
|
||||
dismissDialogSafely(DialogManager.DIALOG_PROGRESS);
|
||||
dismissDialogSafely(DIALOG_PROGRESS);
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
sendToDocsMessage = sender.getStatusMessage();
|
||||
@@ -528,13 +531,13 @@ public class MyTracks extends TabActivity implements OnTouchListener,
|
||||
sender.setOnCompletion(onCompletion);
|
||||
sender.run();
|
||||
} else {
|
||||
dismissDialogSafely(DialogManager.DIALOG_PROGRESS);
|
||||
dismissDialogSafely(DIALOG_PROGRESS);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MyTracksConstants.SEND_TO_GOOGLE_DIALOG: {
|
||||
shareRequested = false;
|
||||
showDialogSafely(DialogManager.DIALOG_SEND_TO_GOOGLE);
|
||||
showDialogSafely(DIALOG_SEND_TO_GOOGLE);
|
||||
break;
|
||||
}
|
||||
case MyTracksConstants.SEND_TO_GOOGLE: {
|
||||
@@ -575,7 +578,7 @@ public class MyTracks extends TabActivity implements OnTouchListener,
|
||||
onActivityResult(MyTracksConstants.AUTHENTICATE_TO_DOCS,
|
||||
RESULT_OK, new Intent());
|
||||
} else {
|
||||
dismissDialogSafely(DialogManager.DIALOG_PROGRESS);
|
||||
dismissDialogSafely(DIALOG_PROGRESS);
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
handleMapsFinish();
|
||||
@@ -592,7 +595,7 @@ public class MyTracks extends TabActivity implements OnTouchListener,
|
||||
Handler handler = new Handler(handlerThread.getLooper());
|
||||
handler.post(sender);
|
||||
} else {
|
||||
dismissDialogSafely(DialogManager.DIALOG_PROGRESS);
|
||||
dismissDialogSafely(DIALOG_PROGRESS);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -622,7 +625,7 @@ public class MyTracks extends TabActivity implements OnTouchListener,
|
||||
shareLinkToMyMap(selectedTrack.getMapId());
|
||||
} else {
|
||||
shareRequested = true;
|
||||
showDialogSafely(DialogManager.DIALOG_SEND_TO_GOOGLE);
|
||||
showDialogSafely(DIALOG_SEND_TO_GOOGLE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -736,7 +739,7 @@ public class MyTracks extends TabActivity implements OnTouchListener,
|
||||
}
|
||||
|
||||
private void importGpxFile(final String fileName) {
|
||||
showDialogSafely(DialogManager.DIALOG_IMPORT_PROGRESS);
|
||||
showDialogSafely(DIALOG_IMPORT_PROGRESS);
|
||||
Thread t = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -773,7 +776,7 @@ public class MyTracks extends TabActivity implements OnTouchListener,
|
||||
} finally {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
dismissDialog(DialogManager.DIALOG_IMPORT_PROGRESS);
|
||||
dismissDialog(DIALOG_IMPORT_PROGRESS);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1048,7 +1051,7 @@ public class MyTracks extends TabActivity implements OnTouchListener,
|
||||
@Override
|
||||
public void handleAccountSelected(Account account) {
|
||||
if (account == null) {
|
||||
dismissDialogSafely(DialogManager.DIALOG_PROGRESS);
|
||||
dismissDialogSafely(DIALOG_PROGRESS);
|
||||
return;
|
||||
}
|
||||
doLogin(results, requestCode, service, account);
|
||||
@@ -1141,7 +1144,7 @@ public class MyTracks extends TabActivity implements OnTouchListener,
|
||||
}
|
||||
setProgressValue(0);
|
||||
clearProgressMessage();
|
||||
showDialogSafely(DialogManager.DIALOG_PROGRESS);
|
||||
showDialogSafely(DIALOG_PROGRESS);
|
||||
if (sendToGoogleDialog.getSendToMyMaps()) {
|
||||
if (!sendToGoogleDialog.getCreateNewMap()) {
|
||||
Intent listIntent = new Intent(this, MyMapsList.class);
|
||||
@@ -1282,12 +1285,12 @@ public class MyTracks extends TabActivity implements OnTouchListener,
|
||||
* @param trackId The id of the track to be sent
|
||||
*/
|
||||
public void saveTrack(long trackId, TrackFileFormat format) {
|
||||
showDialogSafely(DialogManager.DIALOG_WRITE_PROGRESS);
|
||||
showDialogSafely(DIALOG_WRITE_PROGRESS);
|
||||
final TrackWriter writer =
|
||||
TrackWriterFactory.newWriter(this, providerUtils, trackId, format);
|
||||
writer.setOnCompletion(new Runnable() {
|
||||
public void run() {
|
||||
dismissDialogSafely(DialogManager.DIALOG_WRITE_PROGRESS);
|
||||
dismissDialogSafely(DIALOG_WRITE_PROGRESS);
|
||||
showMessageDialog(writer.getErrorMessage(), writer.wasSuccess());
|
||||
}
|
||||
});
|
||||
@@ -1302,7 +1305,7 @@ public class MyTracks extends TabActivity implements OnTouchListener,
|
||||
* @param trackId The id of the track to be sent
|
||||
*/
|
||||
public void sendTrack(long trackId, final TrackFileFormat format) {
|
||||
showDialogSafely(DialogManager.DIALOG_WRITE_PROGRESS);
|
||||
showDialogSafely(DIALOG_WRITE_PROGRESS);
|
||||
final TrackWriter writer =
|
||||
TrackWriterFactory.newWriter(this, providerUtils, trackId, format);
|
||||
|
||||
@@ -1314,7 +1317,7 @@ public class MyTracks extends TabActivity implements OnTouchListener,
|
||||
writer.setDirectory(dir);
|
||||
writer.setOnCompletion(new Runnable() {
|
||||
public void run() {
|
||||
dismissDialogSafely(DialogManager.DIALOG_WRITE_PROGRESS);
|
||||
dismissDialogSafely(DIALOG_WRITE_PROGRESS);
|
||||
if (!writer.wasSuccess()) {
|
||||
showMessageDialog(writer.getErrorMessage(), writer.wasSuccess());
|
||||
} else {
|
||||
@@ -1372,9 +1375,6 @@ public class MyTracks extends TabActivity implements OnTouchListener,
|
||||
return accountChooser;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the sendToMyMapsMapId
|
||||
*/
|
||||
public String getSendToMyMapsMapId() {
|
||||
return sendToMyMapsMapId;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,10 @@ public class TempFileCleaner {
|
||||
}
|
||||
|
||||
public void clean() {
|
||||
if (!Environment.getExternalStorageState().equals(
|
||||
Environment.MEDIA_MOUNTED)) {
|
||||
return; // Can't do anything now.
|
||||
}
|
||||
cleanTmpDirectory("csv");
|
||||
cleanTmpDirectory("gpx");
|
||||
cleanTmpDirectory("kml");
|
||||
@@ -36,13 +40,14 @@ public class TempFileCleaner {
|
||||
}
|
||||
|
||||
private void cleanTmpDirectory(String name) {
|
||||
if (!Environment.getExternalStorageState().equals(
|
||||
Environment.MEDIA_MOUNTED)) {
|
||||
return; // Can't do anything now.
|
||||
}
|
||||
String sep = System.getProperty("file.separator");
|
||||
File dir = new File(
|
||||
Environment.getExternalStorageDirectory() + sep + name + sep + "tmp");
|
||||
cleanTmpDirectory(
|
||||
new File(
|
||||
Environment.getExternalStorageDirectory() + sep + name + sep
|
||||
+ "tmp"));
|
||||
}
|
||||
|
||||
private void cleanTmpDirectory(File dir) {
|
||||
if (!dir.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.speech.tts.TextToSpeech;
|
||||
import android.speech.tts.TextToSpeech.OnInitListener;
|
||||
import android.telephony.PhoneStateListener;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.Locale;
|
||||
@@ -63,6 +65,26 @@ public class StatusAnnouncerTask implements PeriodicTask {
|
||||
*/
|
||||
private boolean ready = false;
|
||||
|
||||
/**
|
||||
* Whether we're allowed to speak right now.
|
||||
*/
|
||||
private boolean speechAllowed;
|
||||
|
||||
/**
|
||||
* Listener which updates {@link #speechAllowed} when the phone state changes.
|
||||
*/
|
||||
private final PhoneStateListener phoneListener = new PhoneStateListener() {
|
||||
@Override
|
||||
public void onCallStateChanged(int state, String incomingNumber) {
|
||||
speechAllowed = state == TelephonyManager.CALL_STATE_IDLE;
|
||||
|
||||
if (!speechAllowed && tts.isSpeaking()) {
|
||||
// If we're already speaking, stop it.
|
||||
tts.stop();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructs the announcer and start the TTS engine.
|
||||
*/
|
||||
@@ -94,8 +116,8 @@ public class StatusAnnouncerTask implements PeriodicTask {
|
||||
int languageAvailability = tts.isLanguageAvailable(speechLanguage);
|
||||
if (languageAvailability == TextToSpeech.LANG_MISSING_DATA ||
|
||||
languageAvailability == TextToSpeech.LANG_NOT_SUPPORTED) {
|
||||
// English is probably supported
|
||||
// TODO: Somehow use announcement strings from English too
|
||||
// English is probably supported.
|
||||
// TODO: Somehow use announcement strings from English too.
|
||||
Log.w(MyTracksConstants.TAG, "Default language not available, using English.");
|
||||
speechLanguage = Locale.ENGLISH;
|
||||
}
|
||||
@@ -116,6 +138,12 @@ public class StatusAnnouncerTask implements PeriodicTask {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!speechAllowed) {
|
||||
Log.i(MyTracksConstants.TAG,
|
||||
"Not making announcement - not allowed at this time");
|
||||
return;
|
||||
}
|
||||
|
||||
if (service == null || service.getTripStatistics() == null) {
|
||||
Log.e(MyTracksConstants.TAG, "StatusAnnouncer stats not initialized.");
|
||||
return;
|
||||
@@ -193,12 +221,23 @@ public class StatusAnnouncerTask implements PeriodicTask {
|
||||
context.getString(speedLabel));
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
tts.shutdown();
|
||||
@Override
|
||||
public void start() {
|
||||
// Register ourselves as a listener so we won't speak during a call.
|
||||
speechAllowed = true;
|
||||
TelephonyManager telephony =
|
||||
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
telephony.listen(phoneListener, PhoneStateListener.LISTEN_CALL_STATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
public void shutdown() {
|
||||
// Stop listening to phone state.
|
||||
TelephonyManager telephony =
|
||||
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
telephony.listen(phoneListener, PhoneStateListener.LISTEN_NONE);
|
||||
|
||||
tts.shutdown();
|
||||
}
|
||||
|
||||
public static int getVolumeStream() {
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<factorypath>
|
||||
<factorypathentry kind="PLUGIN" id="org.eclipse.jst.ws.annotations.core" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="WKSPJAR" id="/MyTracksTest/libs/AndroidMockGenerator.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="ANDROID_SDK/platforms/android-8/android.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="ANDROID_SDK/add-ons/addon_google_apis_google_inc_8/libs/maps.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="MYTRACKS_BIN" enabled="true" runInBatchMode="false"/>
|
||||
</factorypath>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#Thu Aug 12 19:30:48 BRT 2010
|
||||
#Mon Nov 01 02:42:03 BRST 2010
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.apt.aptEnabled=true
|
||||
org.eclipse.jdt.apt.genSrcDir=.apt_generated
|
||||
org.eclipse.jdt.apt.processorOptions/bin_dir=MyTracksTest/bin
|
||||
org.eclipse.jdt.apt.processorOptions/logfile=MyTracksTest/annotations.log
|
||||
org.eclipse.jdt.apt.processorOptions/bin_dir=%PROJECT.DIR%/bin
|
||||
org.eclipse.jdt.apt.processorOptions/logfile=%PROJECT.DIR%/annotations.log
|
||||
org.eclipse.jdt.apt.reconcileEnabled=false
|
||||
|
||||
Reference in New Issue
Block a user