|
|
|
@ -301,6 +301,7 @@ abstract class BaseReadAloudService : BaseService(), |
|
|
|
|
* 更新通知 |
|
|
|
|
*/ |
|
|
|
|
private fun upNotification() { |
|
|
|
|
execute { |
|
|
|
|
var nTitle: String = when { |
|
|
|
|
pause -> getString(R.string.read_aloud_pause) |
|
|
|
|
timeMinute > 0 -> getString( |
|
|
|
@ -313,7 +314,8 @@ abstract class BaseReadAloudService : BaseService(), |
|
|
|
|
var nSubtitle = ReadBook.curTextChapter?.title |
|
|
|
|
if (nSubtitle.isNullOrBlank()) |
|
|
|
|
nSubtitle = getString(R.string.read_aloud_s) |
|
|
|
|
val builder = NotificationCompat.Builder(this, AppConst.channelIdReadAloud) |
|
|
|
|
val builder = NotificationCompat |
|
|
|
|
.Builder(this@BaseReadAloudService, AppConst.channelIdReadAloud) |
|
|
|
|
.setSmallIcon(R.drawable.ic_volume_up) |
|
|
|
|
.setOngoing(true) |
|
|
|
|
.setContentTitle(nTitle) |
|
|
|
@ -322,7 +324,10 @@ abstract class BaseReadAloudService : BaseService(), |
|
|
|
|
activityPendingIntent<ReadBookActivity>("activity") |
|
|
|
|
) |
|
|
|
|
kotlin.runCatching { |
|
|
|
|
ImageLoader.loadBitmap(this, ReadBook.book?.getDisplayCover()).submit().get() |
|
|
|
|
ImageLoader |
|
|
|
|
.loadBitmap(this@BaseReadAloudService, ReadBook.book?.getDisplayCover()) |
|
|
|
|
.submit() |
|
|
|
|
.get() |
|
|
|
|
}.getOrElse { |
|
|
|
|
BitmapFactory.decodeResource(resources, R.drawable.icon_read_book) |
|
|
|
|
}.let { |
|
|
|
@ -356,8 +361,10 @@ abstract class BaseReadAloudService : BaseService(), |
|
|
|
|
.setShowActionsInCompactView(0, 1, 2) |
|
|
|
|
) |
|
|
|
|
builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC) |
|
|
|
|
val notification = builder.build() |
|
|
|
|
startForeground(AppConst.notificationIdRead, notification) |
|
|
|
|
builder |
|
|
|
|
}.onSuccess { |
|
|
|
|
startForeground(AppConst.notificationIdRead, it.build()) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
abstract fun aloudServicePendingIntent(actionStr: String): PendingIntent? |
|
|
|
|