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