mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-02 09:33:06 +02:00
Merging
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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()) {
|
||||
// Stop speaking if we are
|
||||
tts.stop();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructs the announcer and start the TTS engine.
|
||||
*/
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user