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