From f670e222c6bcf8b1d033d14445aa846124491463 Mon Sep 17 00:00:00 2001 From: davidoskky Date: Sun, 21 Aug 2022 23:32:41 +0200 Subject: [PATCH] Localize strings --- .../readerforselfossv2/android/viewmodel/AppViewModel.kt | 7 ++++--- androidApp/src/main/res/values/strings.xml | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/viewmodel/AppViewModel.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/viewmodel/AppViewModel.kt index cc7c21d..9320762 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/viewmodel/AppViewModel.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/viewmodel/AppViewModel.kt @@ -2,13 +2,14 @@ package bou.amine.apps.readerforselfossv2.android.viewmodel import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope +import bou.amine.apps.readerforselfossv2.android.R import bou.amine.apps.readerforselfossv2.repository.Repository import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.launch class AppViewModel(private val repository: Repository) : ViewModel() { - private val _toastMessageProvider = MutableSharedFlow() + private val _toastMessageProvider = MutableSharedFlow() val toastMessageProvider = _toastMessageProvider.asSharedFlow() private var wasConnected = true @@ -16,10 +17,10 @@ class AppViewModel(private val repository: Repository) : ViewModel() { viewModelScope.launch { repository.isConnectionAvailable.collect { isConnected -> if (isConnected && !wasConnected && repository.connectionMonitored) { - _toastMessageProvider.emit("Network connection is now available") + _toastMessageProvider.emit(R.string.network_connectivity_retrieved) wasConnected = true } else if (!isConnected && wasConnected && repository.connectionMonitored){ - _toastMessageProvider.emit("Network connection lost") + _toastMessageProvider.emit(R.string.network_connectivity_lost) wasConnected = false } } diff --git a/androidApp/src/main/res/values/strings.xml b/androidApp/src/main/res/values/strings.xml index fc20983..a83ab53 100644 --- a/androidApp/src/main/res/values/strings.xml +++ b/androidApp/src/main/res/values/strings.xml @@ -143,6 +143,8 @@ Check for new sources and tags Disable this if your server is receiving excessive amounts of database queries. Not connected ! + "Network connection lost" + "Network connection is now available" Sync articles Articles will not be synced in the background Articles will periodically be synced