573 include free disk space in the contact support information (#607)
* [#174]added warning screen + StorageChecker.kt * [#174]added warning screen + StorageChecker.kt * added manual test * added manual test * [#573] Include free disk space in the Contact Support information * resolved merge conflicts * code review fixes * [#573] Include free disk space in the Contact Support information * added vector drawable * fixed merge issues * fixed support info test * code review fixes * SupportInfoTest fix * Remove trailing comma Co-authored-by: Carter Jernigan <git@carterjernigan.com>
This commit is contained in:
parent
42f3348a9e
commit
3475ea545e
|
@ -3,19 +3,25 @@ package co.electriccoin.zcash.ui.screen.support.model
|
|||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import cash.z.ecc.sdk.ext.ui.model.MonetarySeparators
|
||||
import co.electriccoin.zcash.global.StorageChecker
|
||||
import co.electriccoin.zcash.spackle.AndroidApiVersion
|
||||
import java.util.Locale
|
||||
|
||||
class EnvironmentInfo(val locale: Locale, val monetarySeparators: MonetarySeparators) {
|
||||
class EnvironmentInfo(val locale: Locale, val monetarySeparators: MonetarySeparators, val usableStorageMegabytes: Int) {
|
||||
|
||||
fun toSupportString() = buildString {
|
||||
appendLine("Locale: ${locale.androidResName()}")
|
||||
appendLine("Currency grouping separator: ${monetarySeparators.grouping}")
|
||||
appendLine("Currency decimal separator: ${monetarySeparators.decimal}")
|
||||
appendLine("Usable storage: $usableStorageMegabytes MB")
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun new(context: Context) = EnvironmentInfo(currentLocale(context), MonetarySeparators.current())
|
||||
suspend fun new(context: Context): EnvironmentInfo {
|
||||
val usableStorage = StorageChecker.checkAvailableStorageMegabytes()
|
||||
|
||||
return EnvironmentInfo(currentLocale(context), MonetarySeparators.current(), usableStorage)
|
||||
}
|
||||
|
||||
private fun currentLocale(context: Context) = if (AndroidApiVersion.isAtLeastN) {
|
||||
currentLocaleNPlus(context)
|
||||
|
|
|
@ -16,6 +16,8 @@ class SupportViewModel(application: Application) : AndroidViewModel(application)
|
|||
// Technically, some of the support info could be invalidated after a configuration change,
|
||||
// such as the user's current locale. However it really doesn't matter here since all we
|
||||
// care about is capturing a snapshot of the app, OS, and device state.
|
||||
val supportInfo: StateFlow<SupportInfo?> = flow<SupportInfo?> { emit(SupportInfo.new(application)) }
|
||||
val supportInfo: StateFlow<SupportInfo?> = flow<SupportInfo?> {
|
||||
emit(SupportInfo.new(application))
|
||||
}
|
||||
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(ANDROID_STATE_FLOW_TIMEOUT, Duration.ZERO), null)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue