TTS notify cancel

pull/217/head
M66B 6 months ago
parent fe1f01adc0
commit 61e203eb8b

@ -55,6 +55,7 @@ public class ServiceTTS extends ServiceBase {
static final String ACTION_TTS_COMPLETED = BuildConfig.APPLICATION_ID + ".TTS"; static final String ACTION_TTS_COMPLETED = BuildConfig.APPLICATION_ID + ".TTS";
static final int PI_TTS = 1; static final int PI_TTS = 1;
static final int PI_FLUSH = 2;
@Override @Override
public void onCreate() { public void onCreate() {
@ -122,7 +123,7 @@ public class ServiceTTS extends ServiceBase {
NotificationCompat.Builder builder = NotificationCompat.Builder builder =
new NotificationCompat.Builder(this, "progress") new NotificationCompat.Builder(this, "progress")
.setForegroundServiceBehavior(Notification.FOREGROUND_SERVICE_DEFAULT) .setForegroundServiceBehavior(Notification.FOREGROUND_SERVICE_DEFAULT)
.setSmallIcon(R.drawable.twotone_play_arrow_24) .setSmallIcon(R.drawable.twotone_stop_24)
.setContentTitle(getString(R.string.title_rule_tts)) .setContentTitle(getString(R.string.title_rule_tts))
.setContentIntent(getPendingIntent(this)) .setContentIntent(getPendingIntent(this))
.setAutoCancel(false) .setAutoCancel(false)
@ -140,11 +141,14 @@ public class ServiceTTS extends ServiceBase {
} }
private static PendingIntent getPendingIntent(Context context) { private static PendingIntent getPendingIntent(Context context) {
Intent view = new Intent(context, ActivityView.class); Intent flush = new Intent(context, ServiceTTS.class)
view.setAction("unified"); .setAction("tts:" + 0)
view.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); .putExtra(ServiceTTS.EXTRA_FLUSH, true)
.putExtra(ServiceTTS.EXTRA_TEXT, "")
.putExtra(ServiceTTS.EXTRA_LANGUAGE, (String) null)
.putExtra(ServiceTTS.EXTRA_UTTERANCE_ID, "tts:" + 0);
return PendingIntentCompat.getActivity( return PendingIntentCompat.getActivity(
context, ActivityView.PI_UNIFIED, view, PendingIntent.FLAG_UPDATE_CURRENT); context, PI_FLUSH, flush, PendingIntent.FLAG_UPDATE_CURRENT);
} }
void onTts(Intent intent) { void onTts(Intent intent) {

Loading…
Cancel
Save