Localize strings
This commit is contained in:
parent
df4903cae5
commit
1d5ab3205e
@ -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<String>()
|
||||
private val _toastMessageProvider = MutableSharedFlow<Int>()
|
||||
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
|
||||
}
|
||||
}
|
||||
|
@ -143,6 +143,8 @@
|
||||
<string name="pref_switch_update_sources">Check for new sources and tags</string>
|
||||
<string name="pref_switch_update_sources_summary">Disable this if your server is receiving excessive amounts of database queries.</string>
|
||||
<string name="no_network_connectivity">Not connected !</string>
|
||||
<string name="network_connectivity_lost">"Network connection lost"</string>
|
||||
<string name="network_connectivity_retrieved">"Network connection is now available"</string>
|
||||
<string name="pref_switch_periodic_refresh">Sync articles</string>
|
||||
<string name="pref_switch_periodic_refresh_off">Articles will not be synced in the background</string>
|
||||
<string name="pref_switch_periodic_refresh_on">Articles will periodically be synced</string>
|
||||
|
Loading…
Reference in New Issue
Block a user