Nothing: add option to read aloud incoming notifications.
Also fixes a bug where the call would be accepted twice if the tts was not bound.
This commit is contained in:
parent
1a8689d4bf
commit
ff9207cd9a
|
@ -440,4 +440,5 @@ public class DeviceSettingsPreferenceConst {
|
||||||
|
|
||||||
public static final String PREF_AUTO_REPLY_INCOMING_CALL = "pref_auto_reply_phonecall";
|
public static final String PREF_AUTO_REPLY_INCOMING_CALL = "pref_auto_reply_phonecall";
|
||||||
public static final String PREF_AUTO_REPLY_INCOMING_CALL_DELAY = "pref_auto_reply_phonecall_delay";
|
public static final String PREF_AUTO_REPLY_INCOMING_CALL_DELAY = "pref_auto_reply_phonecall_delay";
|
||||||
|
public static final String PREF_SPEAK_NOTIFICATIONS_ALOUD = "pref_speak_notifications_aloud";
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
|
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.serial.AbstractSerialDeviceSupport;
|
import nodomain.freeyourgadget.gadgetbridge.service.serial.AbstractSerialDeviceSupport;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.serial.GBDeviceIoThread;
|
import nodomain.freeyourgadget.gadgetbridge.service.serial.GBDeviceIoThread;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.serial.GBDeviceProtocol;
|
import nodomain.freeyourgadget.gadgetbridge.service.serial.GBDeviceProtocol;
|
||||||
|
@ -57,6 +58,8 @@ public class Ear1Support extends AbstractSerialDeviceSupport {
|
||||||
callCmd.event = GBDeviceEventCallControl.Event.ACCEPT;
|
callCmd.event = GBDeviceEventCallControl.Event.ACCEPT;
|
||||||
evaluateGBDeviceEvent(callCmd);
|
evaluateGBDeviceEvent(callCmd);
|
||||||
}, delayMillis); //15s
|
}, delayMillis); //15s
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
String speechText = callSpec.name;
|
String speechText = callSpec.name;
|
||||||
if (callSpec.name.equals(callSpec.number)) {
|
if (callSpec.name.equals(callSpec.number)) {
|
||||||
|
@ -70,6 +73,26 @@ public class Ear1Support extends AbstractSerialDeviceSupport {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNotification(NotificationSpec notificationSpec) {
|
||||||
|
SharedPreferences prefs = GBApplication.getDeviceSpecificSharedPrefs(getDevice().getAddress());
|
||||||
|
|
||||||
|
if (!prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_SPEAK_NOTIFICATIONS_ALOUD, false))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (gbTextToSpeech.isConnected()) {
|
||||||
|
|
||||||
|
String notificationSpeller = new StringBuilder()
|
||||||
|
.append(notificationSpec.sourceName == null ? "" : notificationSpec.sourceName).append(". ")
|
||||||
|
.append(notificationSpec.title == null ? "" : notificationSpec.title).append(": ")
|
||||||
|
.append(notificationSpec.body == null ? "" : notificationSpec.body).toString();
|
||||||
|
|
||||||
|
|
||||||
|
gbTextToSpeech.speakNotification(notificationSpeller);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSendConfiguration(String config) {
|
public void onSendConfiguration(String config) {
|
||||||
super.onSendConfiguration(config);
|
super.onSendConfiguration(config);
|
||||||
|
@ -122,6 +145,7 @@ public class Ear1Support extends AbstractSerialDeviceSupport {
|
||||||
@Override
|
@Override
|
||||||
public void onDone(String utteranceId) {
|
public void onDone(String utteranceId) {
|
||||||
// LOG.debug("UtteranceProgressListener onDone.");
|
// LOG.debug("UtteranceProgressListener onDone.");
|
||||||
|
if (utteranceId.equals("call")) {
|
||||||
SharedPreferences prefs = GBApplication.getDeviceSpecificSharedPrefs(getDevice().getAddress());
|
SharedPreferences prefs = GBApplication.getDeviceSpecificSharedPrefs(getDevice().getAddress());
|
||||||
final int delayMillis = Integer.parseInt(prefs.getString(DeviceSettingsPreferenceConst.PREF_AUTO_REPLY_INCOMING_CALL_DELAY, "15")) * 1000;
|
final int delayMillis = Integer.parseInt(prefs.getString(DeviceSettingsPreferenceConst.PREF_AUTO_REPLY_INCOMING_CALL_DELAY, "15")) * 1000;
|
||||||
|
|
||||||
|
@ -133,6 +157,7 @@ public class Ear1Support extends AbstractSerialDeviceSupport {
|
||||||
evaluateGBDeviceEvent(callCmd);
|
evaluateGBDeviceEvent(callCmd);
|
||||||
}, delayMillis); //15s
|
}, delayMillis); //15s
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(String utteranceId) {
|
public void onError(String utteranceId) {
|
||||||
|
|
|
@ -47,7 +47,13 @@ public class GBTextToSpeech {
|
||||||
Bundle params = new Bundle();
|
Bundle params = new Bundle();
|
||||||
// Put the audio stream type into the Bundle
|
// Put the audio stream type into the Bundle
|
||||||
params.putInt(TextToSpeech.Engine.KEY_PARAM_STREAM, AudioManager.STREAM_RING);
|
params.putInt(TextToSpeech.Engine.KEY_PARAM_STREAM, AudioManager.STREAM_RING);
|
||||||
textToSpeech.speak(text, TextToSpeech.QUEUE_FLUSH, params, "utteranceId");
|
textToSpeech.speak(text, TextToSpeech.QUEUE_FLUSH, params, "call");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void speakNotification(String text) {
|
||||||
|
Bundle params = new Bundle();
|
||||||
|
params.putInt(TextToSpeech.Engine.KEY_PARAM_STREAM, AudioManager.STREAM_MUSIC);
|
||||||
|
textToSpeech.speak(text, TextToSpeech.QUEUE_FLUSH, params, "notification");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
|
|
|
@ -2782,4 +2782,6 @@
|
||||||
<string name="pref_auto_reply_calls_title">Automatically answer phone calls</string>
|
<string name="pref_auto_reply_calls_title">Automatically answer phone calls</string>
|
||||||
<string name="pref_auto_reply_calls_delay_summary">Number of seconds after which the call is automatically picked up</string>
|
<string name="pref_auto_reply_calls_delay_summary">Number of seconds after which the call is automatically picked up</string>
|
||||||
<string name="pref_auto_reply_calls_delay_title">Automatic Answer Delay</string>
|
<string name="pref_auto_reply_calls_delay_title">Automatic Answer Delay</string>
|
||||||
|
<string name="pref_speak_notifications_aloud_summary">Notifications will be read aloud through the headphones</string>
|
||||||
|
<string name="pref_speak_notifications_aloud_title">Speak Notifications Aloud</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -29,4 +29,10 @@
|
||||||
android:summary="@string/pref_auto_reply_calls_delay_summary"
|
android:summary="@string/pref_auto_reply_calls_delay_summary"
|
||||||
android:title="@string/pref_auto_reply_calls_delay_title"
|
android:title="@string/pref_auto_reply_calls_delay_title"
|
||||||
app:defaultValue="15" />
|
app:defaultValue="15" />
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:icon="@drawable/ic_voice"
|
||||||
|
android:key="pref_speak_notifications_aloud"
|
||||||
|
android:summary="@string/pref_speak_notifications_aloud_summary"
|
||||||
|
android:title="@string/pref_speak_notifications_aloud_title" />
|
||||||
</androidx.preference.PreferenceScreen>
|
</androidx.preference.PreferenceScreen>
|
||||||
|
|
Loading…
Reference in New Issue