diff --git a/app/src/main/java/org/xdty/callerinfo/worker/UpgradeWorker.kt b/app/src/main/java/org/xdty/callerinfo/worker/UpgradeWorker.kt index 9e2a4654..c977daa1 100644 --- a/app/src/main/java/org/xdty/callerinfo/worker/UpgradeWorker.kt +++ b/app/src/main/java/org/xdty/callerinfo/worker/UpgradeWorker.kt @@ -6,7 +6,6 @@ import android.app.PendingIntent import android.content.Context import android.content.Intent import android.os.Build -import android.util.Log import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat import androidx.work.Worker @@ -43,7 +42,6 @@ class UpgradeWorker(context: Context, workerParams: WorkerParameters) : Worker(c } override fun doWork(): Result { - Log.d(tag, "doWork") return mPresenter.upgradeOfflineData(applicationContext) } @@ -54,21 +52,21 @@ class UpgradeWorker(context: Context, workerParams: WorkerParameters) : Worker(c override fun showSucceedNotification(status: Status) { val info = applicationContext.getString(R.string.offline_data_version_summary, status.version, status.count, Utils.getDate(status.timestamp * 1000)) - showNotification(applicationContext, applicationContext.getString(R.string.offline_data_upgrade_success, info)) + showNotification(applicationContext, applicationContext.getString(R.string.offline_data_upgrade_success), info) } override fun showFailedNotification(error: Exception) { - showNotification(applicationContext, applicationContext.getString(R.string.offline_data_upgrade_failed, error.message)) + showNotification(applicationContext, applicationContext.getString(R.string.offline_data_upgrade_failed), error.message) } - private fun showNotification(context: Context, message: String) { + private fun showNotification(context: Context, title: String, message: String?) { // Make a channel if necessary if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { // Create the NotificationChannel, but only on API 26+ because // the NotificationChannel class is new and not in the support library val name = Constants.VERBOSE_NOTIFICATION_CHANNEL_NAME val description = Constants.VERBOSE_NOTIFICATION_CHANNEL_DESCRIPTION - val importance = NotificationManager.IMPORTANCE_HIGH + val importance = NotificationManager.IMPORTANCE_LOW val channel = NotificationChannel(Constants.CHANNEL_ID, name, importance) channel.description = description @@ -86,6 +84,7 @@ class UpgradeWorker(context: Context, workerParams: WorkerParameters) : Worker(c .setSmallIcon(R.drawable.ic_call_disconnected_24dp) .setContentIntent(intent) .setPriority(NotificationCompat.PRIORITY_LOW) + .setContentTitle(title) .setStyle(NotificationCompat.BigTextStyle().bigText(message)) .setAutoCancel(true) .setVibrate(LongArray(0)) diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index ccd59d0a..4baf668b 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -206,8 +206,8 @@ 隐藏插件桌面图标 忽略电池优化 您将跳转到系统电池优化选项,请在所有应用列表中找到应用并选择忽略 - 离线数据已经更新到最新: %s - 离线数据更新失败: %s + 离线数据已更新到最新版本 + 离线数据更新失败 立即更新离线数据 自动更新离线数据 \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index bd2f8e89..165b60c9 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -193,8 +193,8 @@ Offline data update failed, please try again later. Offline data has been updated to latest Offline data status - Offline data has been updated to latest: %s - Offline data upgrade failed: %s + Offline data has been updated to latest version + Offline data upgrade failed Version %1$d, count %2$d, updated at %3$s Automatic offline data update Update offline data now