From fd3192e2abdb921c5a02d666e1bbdb25aec77662 Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 11 Sep 2019 19:16:47 +0800 Subject: [PATCH] up --- .../java/io/legado/app/service/BaseReadAloudService.kt | 9 +++------ .../java/io/legado/app/service/HttpReadAloudService.kt | 9 +++++++++ .../java/io/legado/app/service/TTSReadAloudService.kt | 9 +++++++++ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt b/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt index b41fa1c54..c4a0f23e4 100644 --- a/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt @@ -321,15 +321,12 @@ abstract class BaseReadAloudService : BaseService(), startForeground(112201, notification) } - fun readBookActivityPendingIntent(context: Context): PendingIntent { + private fun readBookActivityPendingIntent(context: Context): PendingIntent { val intent = Intent(context, ReadBookActivity::class.java) intent.action = "readBookActivity" return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT) } - fun aloudServicePendingIntent(context: Context, actionStr: String): PendingIntent { - val intent = Intent(context, TTSReadAloudService::class.java) - intent.action = actionStr - return PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT) - } + abstract fun aloudServicePendingIntent(context: Context, actionStr: String): PendingIntent + } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt b/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt index 1de2f030a..2d8b15820 100644 --- a/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt @@ -1,5 +1,8 @@ package io.legado.app.service +import android.app.PendingIntent +import android.content.Context +import android.content.Intent import android.media.MediaPlayer import io.legado.app.constant.Bus import io.legado.app.utils.postEvent @@ -90,4 +93,10 @@ class HttpReadAloudService : BaseReadAloudService(), postEvent(Bus.TTS_TURN_PAGE, 2) } } + + override fun aloudServicePendingIntent(context: Context, actionStr: String): PendingIntent { + val intent = Intent(context, HttpReadAloudService::class.java) + intent.action = actionStr + return PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT) + } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt b/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt index 7f0ea7e0b..1b9078371 100644 --- a/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt @@ -1,5 +1,8 @@ package io.legado.app.service +import android.app.PendingIntent +import android.content.Context +import android.content.Intent import android.os.Build import android.speech.tts.TextToSpeech import android.speech.tts.UtteranceProgressListener @@ -185,4 +188,10 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener } + override fun aloudServicePendingIntent(context: Context, actionStr: String): PendingIntent { + val intent = Intent(context, TTSReadAloudService::class.java) + intent.action = actionStr + return PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT) + } + } \ No newline at end of file