forked from upstream-mirrors/OpenTracks
Merging Bart's changes.
This commit is contained in:
@@ -3,3 +3,4 @@ syntax:glob
|
|||||||
*/bin
|
*/bin
|
||||||
*/gen/**
|
*/gen/**
|
||||||
.metadata
|
.metadata
|
||||||
|
MyTracksTest/annotations.log
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
android:value="AEdPqrEAAAAIi-_QiwoRSc9_bAC9cmuNXTQyU8ajJmGtKdhskQ" />
|
android:value="AEdPqrEAAAAIi-_QiwoRSc9_bAC9cmuNXTQyU8ajJmGtKdhskQ" />
|
||||||
|
|
||||||
<provider android:name="com.google.android.apps.mytracks.content.MyTracksProvider"
|
<provider android:name="com.google.android.apps.mytracks.content.MyTracksProvider"
|
||||||
android:multiprocess="true"
|
android:process=":trackrecord"
|
||||||
android:authorities="com.google.android.maps.mytracks" />
|
android:authorities="com.google.android.maps.mytracks" />
|
||||||
|
|
||||||
<activity android:name="com.google.android.apps.mytracks.MyTracks"
|
<activity android:name="com.google.android.apps.mytracks.MyTracks"
|
||||||
@@ -102,6 +102,9 @@
|
|||||||
<uses-permission android:name="com.google.android.googleapps.permission.GOOGLE_AUTH.writely" />
|
<uses-permission android:name="com.google.android.googleapps.permission.GOOGLE_AUTH.writely" />
|
||||||
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
|
<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"/>
|
<uses-sdk android:minSdkVersion="3"/>
|
||||||
<supports-screens
|
<supports-screens
|
||||||
android:largeScreens="true"
|
android:largeScreens="true"
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ import android.content.Context;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.speech.tts.TextToSpeech;
|
import android.speech.tts.TextToSpeech;
|
||||||
import android.speech.tts.TextToSpeech.OnInitListener;
|
import android.speech.tts.TextToSpeech.OnInitListener;
|
||||||
|
import android.telephony.PhoneStateListener;
|
||||||
|
import android.telephony.TelephonyManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@@ -63,6 +65,26 @@ public class StatusAnnouncerTask implements PeriodicTask {
|
|||||||
*/
|
*/
|
||||||
private boolean ready = false;
|
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.
|
* Constructs the announcer and start the TTS engine.
|
||||||
*/
|
*/
|
||||||
@@ -94,8 +116,8 @@ public class StatusAnnouncerTask implements PeriodicTask {
|
|||||||
int languageAvailability = tts.isLanguageAvailable(speechLanguage);
|
int languageAvailability = tts.isLanguageAvailable(speechLanguage);
|
||||||
if (languageAvailability == TextToSpeech.LANG_MISSING_DATA ||
|
if (languageAvailability == TextToSpeech.LANG_MISSING_DATA ||
|
||||||
languageAvailability == TextToSpeech.LANG_NOT_SUPPORTED) {
|
languageAvailability == TextToSpeech.LANG_NOT_SUPPORTED) {
|
||||||
// English is probably supported
|
// English is probably supported.
|
||||||
// TODO: Somehow use announcement strings from English too
|
// TODO: Somehow use announcement strings from English too.
|
||||||
Log.w(MyTracksConstants.TAG, "Default language not available, using English.");
|
Log.w(MyTracksConstants.TAG, "Default language not available, using English.");
|
||||||
speechLanguage = Locale.ENGLISH;
|
speechLanguage = Locale.ENGLISH;
|
||||||
}
|
}
|
||||||
@@ -116,6 +138,12 @@ public class StatusAnnouncerTask implements PeriodicTask {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!speechAllowed) {
|
||||||
|
Log.i(MyTracksConstants.TAG,
|
||||||
|
"Not making announcement - not allowed at this time");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (service == null || service.getTripStatistics() == null) {
|
if (service == null || service.getTripStatistics() == null) {
|
||||||
Log.e(MyTracksConstants.TAG, "StatusAnnouncer stats not initialized.");
|
Log.e(MyTracksConstants.TAG, "StatusAnnouncer stats not initialized.");
|
||||||
return;
|
return;
|
||||||
@@ -193,12 +221,23 @@ public class StatusAnnouncerTask implements PeriodicTask {
|
|||||||
context.getString(speedLabel));
|
context.getString(speedLabel));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown() {
|
@Override
|
||||||
tts.shutdown();
|
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
|
@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() {
|
public static int getVolumeStream() {
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
<factorypath>
|
<factorypath>
|
||||||
<factorypathentry kind="PLUGIN" id="org.eclipse.jst.ws.annotations.core" enabled="true" runInBatchMode="false"/>
|
<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="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>
|
</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
|
eclipse.preferences.version=1
|
||||||
org.eclipse.jdt.apt.aptEnabled=true
|
org.eclipse.jdt.apt.aptEnabled=true
|
||||||
org.eclipse.jdt.apt.genSrcDir=.apt_generated
|
org.eclipse.jdt.apt.genSrcDir=.apt_generated
|
||||||
org.eclipse.jdt.apt.processorOptions/bin_dir=MyTracksTest/bin
|
org.eclipse.jdt.apt.processorOptions/bin_dir=%PROJECT.DIR%/bin
|
||||||
org.eclipse.jdt.apt.processorOptions/logfile=MyTracksTest/annotations.log
|
org.eclipse.jdt.apt.processorOptions/logfile=%PROJECT.DIR%/annotations.log
|
||||||
org.eclipse.jdt.apt.reconcileEnabled=false
|
org.eclipse.jdt.apt.reconcileEnabled=false
|
||||||
|
|||||||
Reference in New Issue
Block a user