diff --git a/android/res/values-de/strings.xml b/android/res/values-de/strings.xml index f6d65c5f27..783252fda3 100644 --- a/android/res/values-de/strings.xml +++ b/android/res/values-de/strings.xml @@ -2,7 +2,7 @@ UnCiv Unciv - Du bist am Zug! - Deine Freunde warten auf deinen Zug. + Deine Freunde warten auf deinen Zug in [gameName]. Ein Fehler ist aufgetreten Multiplayer Zug Benachrichtigungsdienst wurde beendet. Letzter online Zugcheck: diff --git a/android/res/values-fr/strings.xml b/android/res/values-fr/strings.xml index d8567e7796..90e9dfb4e8 100644 --- a/android/res/values-fr/strings.xml +++ b/android/res/values-fr/strings.xml @@ -2,7 +2,7 @@ UnCiv Unciv - C\'est à vous ! - Vos amis attendent votre action. + Vos amis attendent votre action dans [gameName]. Service de notification du tour multijoueur terminé Une erreur est survenue Configurable dans le menu des options de Unciv diff --git a/android/res/values/strings.xml b/android/res/values/strings.xml index 57614a8612..64c019ecb2 100644 --- a/android/res/values/strings.xml +++ b/android/res/values/strings.xml @@ -2,7 +2,7 @@ UnCiv Unciv - It\'s your turn! - Your friends are waiting on your turn. + Your friends are waiting for your turn in [gameName]. An error has occurred Multiplayer turn notifier service terminated. Last online turn check: diff --git a/android/src/com/unciv/app/AndroidLauncher.kt b/android/src/com/unciv/app/AndroidLauncher.kt index 8abbd41294..bc913496b1 100644 --- a/android/src/com/unciv/app/AndroidLauncher.kt +++ b/android/src/com/unciv/app/AndroidLauncher.kt @@ -69,7 +69,7 @@ open class AndroidLauncher : AndroidApplication() { if (UncivGame.Companion.isCurrentInitialized() && UncivGame.Current.isGameInfoInitialized() && UncivGame.Current.settings.multiplayerTurnCheckerEnabled - && UncivGame.Current.gameInfo.gameParameters.isOnlineMultiplayer) { + && GameSaver.getSaves(true).any()) { MultiplayerTurnCheckWorker.startTurnChecker(applicationContext, UncivGame.Current.gameInfo, UncivGame.Current.settings) } super.onPause() diff --git a/android/src/com/unciv/app/MultiplayerTurnCheckWorker.kt b/android/src/com/unciv/app/MultiplayerTurnCheckWorker.kt index d724daec6c..4719bd816e 100644 --- a/android/src/com/unciv/app/MultiplayerTurnCheckWorker.kt +++ b/android/src/com/unciv/app/MultiplayerTurnCheckWorker.kt @@ -42,6 +42,7 @@ class MultiplayerTurnCheckWorker(appContext: Context, workerParams: WorkerParame private const val FAIL_COUNT = "FAIL_COUNT" private const val GAME_ID = "GAME_ID" + private const val GAME_NAME = "GAME_NAME" private const val USER_ID = "USER_ID" private const val CONFIGURED_DELAY = "CONFIGURED_DELAY" private const val PERSISTENT_NOTIFICATION_ENABLED = "PERSISTENT_NOTIFICATION_ENABLED" @@ -136,7 +137,7 @@ class MultiplayerTurnCheckWorker(appContext: Context, workerParams: WorkerParame } } - fun notifyUserAboutTurn(applicationContext: Context) { + fun notifyUserAboutTurn(applicationContext: Context, gameName: String) { val pendingIntent: PendingIntent = Intent(applicationContext, AndroidLauncher::class.java).let { notificationIntent -> PendingIntent.getActivity(applicationContext, 0, notificationIntent, 0) @@ -146,7 +147,7 @@ class MultiplayerTurnCheckWorker(appContext: Context, workerParams: WorkerParame val notification: NotificationCompat.Builder = NotificationCompat.Builder(applicationContext, NOTIFICATION_CHANNEL_ID_INFO) .setPriority(NotificationManagerCompat.IMPORTANCE_HIGH) // people are waiting! .setContentTitle(contentTitle) - .setContentText(applicationContext.resources.getString(R.string.Notify_YourTurn_Long)) + .setContentText(applicationContext.resources.getString(R.string.Notify_YourTurn_Long).replace("[gameName]", gameName)) .setTicker(contentTitle) // without at least vibrate, some Android versions don't show a heads-up notification .setDefaults(DEFAULT_VIBRATE) @@ -181,9 +182,9 @@ class MultiplayerTurnCheckWorker(appContext: Context, workerParams: WorkerParame if (currentGameInfo.currentPlayerCiv.playerId == settings.userId) { // May be useful to remind a player that he forgot to complete his turn. - notifyUserAboutTurn(applicationContext) + notifyUserAboutTurn(applicationContext, gameNames[gameIds.indexOf(currentGameInfo.gameId)]) } else { - val inputData = workDataOf(Pair(FAIL_COUNT, 0), Pair(GAME_ID, gameIds), + val inputData = workDataOf(Pair(FAIL_COUNT, 0), Pair(GAME_ID, gameIds), Pair(GAME_NAME, gameNames), Pair(USER_ID, settings.userId), Pair(CONFIGURED_DELAY, settings.multiplayerTurnCheckerDelayInMinutes), Pair(PERSISTENT_NOTIFICATION_ENABLED, settings.multiplayerTurnCheckerPersistentNotificationEnabled)) @@ -226,6 +227,7 @@ class MultiplayerTurnCheckWorker(appContext: Context, workerParams: WorkerParame try { val gameIds = inputData.getStringArray(GAME_ID)!! + val gameNames = inputData.getStringArray(GAME_NAME)!! var arrayIndex = 0 // We only want to notify the user or update persisted notification once but still want // to download all games to update the files hence this bool @@ -250,12 +252,14 @@ class MultiplayerTurnCheckWorker(appContext: Context, workerParams: WorkerParame if (currentTurnPlayer.playerId == inputData.getString(USER_ID)!!) { foundGame = true + //As we do not need to look any further we can just break here + break } arrayIndex++ } if (foundGame){ - notifyUserAboutTurn(applicationContext) + notifyUserAboutTurn(applicationContext, gameNames[arrayIndex]) with(NotificationManagerCompat.from(applicationContext)) { cancel(NOTIFICATION_ID_SERVICE) }