Localize Troubleshoot notification feature.
This commit is contained in:
parent
33526db485
commit
09b2cbaaf5
26 changed files with 221 additions and 64 deletions
|
|
@ -24,6 +24,8 @@ import io.element.android.libraries.core.notifications.TestFilterData
|
|||
import io.element.android.libraries.di.AppScope
|
||||
import io.element.android.libraries.pushproviders.firebase.FirebaseConfig
|
||||
import io.element.android.libraries.pushproviders.firebase.IsPlayServiceAvailable
|
||||
import io.element.android.libraries.pushproviders.firebase.R
|
||||
import io.element.android.services.toolbox.api.strings.StringProvider
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import javax.inject.Inject
|
||||
|
|
@ -31,11 +33,12 @@ import javax.inject.Inject
|
|||
@ContributesMultibinding(AppScope::class)
|
||||
class FirebaseAvailabilityTest @Inject constructor(
|
||||
private val isPlayServiceAvailable: IsPlayServiceAvailable,
|
||||
private val stringProvider: StringProvider,
|
||||
) : NotificationTroubleshootTest {
|
||||
override val order = 300
|
||||
private val delegate = NotificationTroubleshootTestDelegate(
|
||||
defaultName = "Check Firebase",
|
||||
defaultDescription = "Ensure that Firebase is available.",
|
||||
defaultName = stringProvider.getString(R.string.troubleshoot_notifications_test_firebase_availability_title),
|
||||
defaultDescription = stringProvider.getString(R.string.troubleshoot_notifications_test_firebase_availability_description),
|
||||
visibleWhenIdle = false,
|
||||
fakeDelay = NotificationTroubleshootTestDelegate.LONG_DELAY,
|
||||
)
|
||||
|
|
@ -50,12 +53,12 @@ class FirebaseAvailabilityTest @Inject constructor(
|
|||
val result = isPlayServiceAvailable.isAvailable()
|
||||
if (result) {
|
||||
delegate.updateState(
|
||||
description = "Firebase is available",
|
||||
description = stringProvider.getString(R.string.troubleshoot_notifications_test_firebase_availability_success),
|
||||
status = NotificationTroubleshootTestState.Status.Success
|
||||
)
|
||||
} else {
|
||||
delegate.updateState(
|
||||
description = "Firebase is not available",
|
||||
description = stringProvider.getString(R.string.troubleshoot_notifications_test_firebase_availability_failure),
|
||||
status = NotificationTroubleshootTestState.Status.Failure(false)
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ import io.element.android.libraries.di.AppScope
|
|||
import io.element.android.libraries.pushproviders.firebase.FirebaseConfig
|
||||
import io.element.android.libraries.pushproviders.firebase.FirebaseStore
|
||||
import io.element.android.libraries.pushproviders.firebase.FirebaseTroubleshooter
|
||||
import io.element.android.libraries.pushproviders.firebase.R
|
||||
import io.element.android.services.toolbox.api.strings.StringProvider
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import javax.inject.Inject
|
||||
|
|
@ -33,11 +35,12 @@ import javax.inject.Inject
|
|||
class FirebaseTokenTest @Inject constructor(
|
||||
private val firebaseStore: FirebaseStore,
|
||||
private val firebaseTroubleshooter: FirebaseTroubleshooter,
|
||||
private val stringProvider: StringProvider,
|
||||
) : NotificationTroubleshootTest {
|
||||
override val order = 310
|
||||
private val delegate = NotificationTroubleshootTestDelegate(
|
||||
defaultName = "Check Firebase token",
|
||||
defaultDescription = "Ensure that Firebase token is available.",
|
||||
defaultName = stringProvider.getString(R.string.troubleshoot_notifications_test_firebase_token_title),
|
||||
defaultDescription = stringProvider.getString(R.string.troubleshoot_notifications_test_firebase_token_description),
|
||||
visibleWhenIdle = false,
|
||||
fakeDelay = NotificationTroubleshootTestDelegate.LONG_DELAY,
|
||||
)
|
||||
|
|
@ -52,12 +55,15 @@ class FirebaseTokenTest @Inject constructor(
|
|||
val token = firebaseStore.getFcmToken()
|
||||
if (token != null) {
|
||||
delegate.updateState(
|
||||
description = "Firebase token: ${token.take(8)}*****",
|
||||
description = stringProvider.getString(
|
||||
R.string.troubleshoot_notifications_test_firebase_token_success,
|
||||
"${token.take(8)}*****"
|
||||
),
|
||||
status = NotificationTroubleshootTestState.Status.Success
|
||||
)
|
||||
} else {
|
||||
delegate.updateState(
|
||||
description = "Firebase token is not known",
|
||||
description = stringProvider.getString(R.string.troubleshoot_notifications_test_firebase_token_failure),
|
||||
status = NotificationTroubleshootTestState.Status.Failure(true)
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
<string name="troubleshoot_notifications_test_firebase_availability_description">"Ensure that Firebase is available."</string>
|
||||
<string name="troubleshoot_notifications_test_firebase_availability_failure">"Firebase is not available."</string>
|
||||
<string name="troubleshoot_notifications_test_firebase_availability_success">"Firebase is available."</string>
|
||||
<string name="troubleshoot_notifications_test_firebase_availability_title">"Check Firebase"</string>
|
||||
<string name="troubleshoot_notifications_test_firebase_token_description">"Ensure that Firebase token is available."</string>
|
||||
<string name="troubleshoot_notifications_test_firebase_token_failure">"Firebase token is not known."</string>
|
||||
<string name="troubleshoot_notifications_test_firebase_token_success">"Firebase token: %1$s."</string>
|
||||
<string name="troubleshoot_notifications_test_firebase_token_title">"Check Firebase token"</string>
|
||||
</resources>
|
||||
|
|
@ -20,6 +20,7 @@ import app.cash.turbine.test
|
|||
import com.google.common.truth.Truth.assertThat
|
||||
import io.element.android.libraries.core.notifications.NotificationTroubleshootTestState
|
||||
import io.element.android.libraries.pushproviders.firebase.IsPlayServiceAvailable
|
||||
import io.element.android.services.toolbox.test.strings.FakeStringProvider
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Test
|
||||
|
|
@ -32,7 +33,8 @@ class FirebaseAvailabilityTestTest {
|
|||
override fun isAvailable(): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
||||
},
|
||||
stringProvider = FakeStringProvider(),
|
||||
)
|
||||
launch {
|
||||
sut.run(this)
|
||||
|
|
@ -52,7 +54,8 @@ class FirebaseAvailabilityTestTest {
|
|||
override fun isAvailable(): Boolean {
|
||||
return false
|
||||
}
|
||||
}
|
||||
},
|
||||
stringProvider = FakeStringProvider(),
|
||||
)
|
||||
launch {
|
||||
sut.run(this)
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import com.google.common.truth.Truth.assertThat
|
|||
import io.element.android.libraries.core.notifications.NotificationTroubleshootTestState
|
||||
import io.element.android.libraries.pushproviders.firebase.FakeFirebaseTroubleshooter
|
||||
import io.element.android.libraries.pushproviders.firebase.InMemoryFirebaseStore
|
||||
import io.element.android.services.toolbox.test.strings.FakeStringProvider
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Test
|
||||
|
|
@ -31,6 +32,7 @@ class FirebaseTokenTestTest {
|
|||
val sut = FirebaseTokenTest(
|
||||
firebaseStore = InMemoryFirebaseStore(FAKE_TOKEN),
|
||||
firebaseTroubleshooter = FakeFirebaseTroubleshooter(),
|
||||
stringProvider = FakeStringProvider(),
|
||||
)
|
||||
launch {
|
||||
sut.run(this)
|
||||
|
|
@ -56,6 +58,7 @@ class FirebaseTokenTestTest {
|
|||
Result.success(Unit)
|
||||
}
|
||||
),
|
||||
stringProvider = FakeStringProvider(),
|
||||
)
|
||||
launch {
|
||||
sut.run(this)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue