[#786] Hide circular progress bar on home screen
This commit is contained in:
parent
a857f20be7
commit
595b6ad34f
|
@ -11,7 +11,8 @@ import java.util.concurrent.atomic.AtomicInteger
|
|||
class HomeTestSetup(
|
||||
private val composeTestRule: ComposeContentTestRule,
|
||||
private val walletSnapshot: WalletSnapshot,
|
||||
private val isShowFiatConversion: Boolean
|
||||
private val isShowFiatConversion: Boolean,
|
||||
private val isCircularProgressBar: Boolean
|
||||
) {
|
||||
private val onAboutCount = AtomicInteger(0)
|
||||
private val onSeedCount = AtomicInteger(0)
|
||||
|
@ -65,6 +66,7 @@ class HomeTestSetup(
|
|||
isUpdateAvailable = false,
|
||||
isKeepScreenOnDuringSync = false,
|
||||
isFiatConversionEnabled = isShowFiatConversion,
|
||||
isCircularProgressBarEnabled = isCircularProgressBar,
|
||||
isDebugMenuEnabled = false,
|
||||
goSettings = {
|
||||
onSettingsCount.incrementAndGet()
|
||||
|
|
|
@ -26,7 +26,8 @@ class HomeActivityTest : UiTestPrerequisites() {
|
|||
private fun newTestSetup(walletSnapshot: WalletSnapshot) = HomeTestSetup(
|
||||
composeTestRule,
|
||||
walletSnapshot,
|
||||
isShowFiatConversion = false
|
||||
isShowFiatConversion = false,
|
||||
isCircularProgressBar = false
|
||||
)
|
||||
|
||||
@Test
|
||||
|
|
|
@ -27,7 +27,8 @@ class HomeViewIntegrationTest : UiTestPrerequisites() {
|
|||
private fun newTestSetup(walletSnapshot: WalletSnapshot) = HomeTestSetup(
|
||||
composeTestRule,
|
||||
walletSnapshot,
|
||||
isShowFiatConversion = false
|
||||
isShowFiatConversion = false,
|
||||
isCircularProgressBar = true
|
||||
)
|
||||
|
||||
// This is just basic sanity check that we still have UI set up as expected after the state restore
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package co.electriccoin.zcash.ui.screen.home.view
|
||||
|
||||
import androidx.compose.ui.test.assertHeightIsAtLeast
|
||||
import androidx.compose.ui.test.assertIsDisplayed
|
||||
import androidx.compose.ui.test.junit4.ComposeContentTestRule
|
||||
import androidx.compose.ui.test.junit4.createComposeRule
|
||||
|
@ -8,12 +9,16 @@ import androidx.compose.ui.test.onNodeWithTag
|
|||
import androidx.compose.ui.test.onNodeWithText
|
||||
import androidx.compose.ui.test.performClick
|
||||
import androidx.compose.ui.test.performScrollTo
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.test.filters.MediumTest
|
||||
import cash.z.ecc.android.sdk.Synchronizer
|
||||
import cash.z.ecc.android.sdk.model.PercentDecimal
|
||||
import co.electriccoin.zcash.test.UiTestPrerequisites
|
||||
import co.electriccoin.zcash.ui.R
|
||||
import co.electriccoin.zcash.ui.fixture.WalletSnapshotFixture
|
||||
import co.electriccoin.zcash.ui.screen.home.HomeTag
|
||||
import co.electriccoin.zcash.ui.screen.home.HomeTestSetup
|
||||
import co.electriccoin.zcash.ui.screen.home.model.WalletSnapshot
|
||||
import co.electriccoin.zcash.ui.test.getStringResource
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Rule
|
||||
|
@ -59,6 +64,39 @@ class HomeViewTest : UiTestPrerequisites() {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@MediumTest
|
||||
fun show_circular_progress_bar() {
|
||||
newTestSetup(
|
||||
isCircularProgressBar = true,
|
||||
walletSnapshot = WalletSnapshotFixture.new(
|
||||
status = Synchronizer.Status.SCANNING,
|
||||
progress = PercentDecimal.ONE_HUNDRED_PERCENT
|
||||
)
|
||||
)
|
||||
|
||||
composeTestRule.onNodeWithTag(HomeTag.PROGRESS).also {
|
||||
it.assertExists()
|
||||
it.assertHeightIsAtLeast(1.dp)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@MediumTest
|
||||
fun hide_circular_progress_bar() {
|
||||
newTestSetup(
|
||||
isCircularProgressBar = false,
|
||||
walletSnapshot = WalletSnapshotFixture.new(
|
||||
status = Synchronizer.Status.SCANNING,
|
||||
progress = PercentDecimal.ONE_HUNDRED_PERCENT
|
||||
)
|
||||
)
|
||||
|
||||
composeTestRule.onNodeWithTag(HomeTag.PROGRESS).also {
|
||||
it.assertDoesNotExist()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@MediumTest
|
||||
fun click_receive_button() {
|
||||
|
@ -147,10 +185,15 @@ class HomeViewTest : UiTestPrerequisites() {
|
|||
assertEquals(1, testSetup.getOnAboutCount())
|
||||
}
|
||||
|
||||
private fun newTestSetup(isShowFiatConversion: Boolean = true) = HomeTestSetup(
|
||||
private fun newTestSetup(
|
||||
isShowFiatConversion: Boolean = true,
|
||||
isCircularProgressBar: Boolean = true,
|
||||
walletSnapshot: WalletSnapshot = WalletSnapshotFixture.new()
|
||||
) = HomeTestSetup(
|
||||
composeTestRule,
|
||||
WalletSnapshotFixture.new(),
|
||||
isShowFiatConversion = isShowFiatConversion
|
||||
walletSnapshot = walletSnapshot,
|
||||
isShowFiatConversion = isShowFiatConversion,
|
||||
isCircularProgressBar = isCircularProgressBar
|
||||
).apply {
|
||||
setDefaultContent()
|
||||
}
|
||||
|
|
|
@ -25,4 +25,11 @@ object ConfigurationEntries {
|
|||
* A troubleshooting step. If we fix our bugs, this should be unnecessary.
|
||||
*/
|
||||
val IS_RESCAN_ENABLED = BooleanConfigurationEntry(ConfigKey("is_rescan_enabled"), true)
|
||||
|
||||
/*
|
||||
* Circular progress bar's scaffolding on the Home screen is done, but it is disabled by default for the initial
|
||||
* minimal feature set.
|
||||
*/
|
||||
val IS_HOME_CIRCULAR_PROGRESS_BAR_ENABLED =
|
||||
BooleanConfigurationEntry(ConfigKey("is_home_circular_progress_bar_enabled"), false)
|
||||
}
|
||||
|
|
|
@ -77,6 +77,8 @@ internal fun WrapHome(
|
|||
|
||||
val isKeepScreenOnWhileSyncing = settingsViewModel.isKeepScreenOnWhileSyncing.collectAsStateWithLifecycle().value
|
||||
val isFiatConversionEnabled = ConfigurationEntries.IS_FIAT_CONVERSION_ENABLED.getValue(RemoteConfig.current)
|
||||
val isCircularProgressBarEnabled =
|
||||
ConfigurationEntries.IS_HOME_CIRCULAR_PROGRESS_BAR_ENABLED.getValue(RemoteConfig.current)
|
||||
|
||||
if (null == walletSnapshot) {
|
||||
// Display loading indicator
|
||||
|
@ -99,6 +101,7 @@ internal fun WrapHome(
|
|||
isUpdateAvailable = updateAvailable,
|
||||
isKeepScreenOnDuringSync = isKeepScreenOnWhileSyncing,
|
||||
isFiatConversionEnabled = isFiatConversionEnabled,
|
||||
isCircularProgressBarEnabled = isCircularProgressBarEnabled,
|
||||
isDebugMenuEnabled = isDebugMenuEnabled,
|
||||
goSeedPhrase = goSeedPhrase,
|
||||
goSettings = goSettings,
|
||||
|
|
|
@ -89,6 +89,7 @@ fun ComposablePreview() {
|
|||
isKeepScreenOnDuringSync = false,
|
||||
isDebugMenuEnabled = false,
|
||||
isFiatConversionEnabled = false,
|
||||
isCircularProgressBarEnabled = false,
|
||||
goSeedPhrase = {},
|
||||
goSettings = {},
|
||||
goSupport = {},
|
||||
|
@ -112,6 +113,7 @@ fun Home(
|
|||
isUpdateAvailable: Boolean,
|
||||
isKeepScreenOnDuringSync: Boolean?,
|
||||
isFiatConversionEnabled: Boolean,
|
||||
isCircularProgressBarEnabled: Boolean,
|
||||
isDebugMenuEnabled: Boolean,
|
||||
goSeedPhrase: () -> Unit,
|
||||
goSettings: () -> Unit,
|
||||
|
@ -149,6 +151,7 @@ fun Home(
|
|||
isUpdateAvailable = isUpdateAvailable,
|
||||
isKeepScreenOnDuringSync = isKeepScreenOnDuringSync,
|
||||
isFiatConversionEnabled = isFiatConversionEnabled,
|
||||
isCircularProgressBarEnabled = isCircularProgressBarEnabled,
|
||||
goReceive = goReceive,
|
||||
goSend = goSend,
|
||||
)
|
||||
|
@ -291,6 +294,7 @@ private fun HomeMainContent(
|
|||
isUpdateAvailable: Boolean,
|
||||
isKeepScreenOnDuringSync: Boolean?,
|
||||
isFiatConversionEnabled: Boolean,
|
||||
isCircularProgressBarEnabled: Boolean,
|
||||
goReceive: () -> Unit,
|
||||
goSend: () -> Unit,
|
||||
) {
|
||||
|
@ -299,7 +303,7 @@ private fun HomeMainContent(
|
|||
.verticalScroll(rememberScrollState())
|
||||
.padding(top = paddingValues.calculateTopPadding())
|
||||
) {
|
||||
Status(walletSnapshot, isUpdateAvailable, isFiatConversionEnabled)
|
||||
Status(walletSnapshot, isUpdateAvailable, isFiatConversionEnabled, isCircularProgressBarEnabled)
|
||||
|
||||
Spacer(modifier = Modifier.height(24.dp))
|
||||
|
||||
|
@ -326,7 +330,8 @@ private fun isSyncing(status: Synchronizer.Status): Boolean {
|
|||
private fun Status(
|
||||
walletSnapshot: WalletSnapshot,
|
||||
updateAvailable: Boolean,
|
||||
isFiatConversionEnabled: Boolean
|
||||
isFiatConversionEnabled: Boolean,
|
||||
isCircularProgressBarEnabled: Boolean
|
||||
) {
|
||||
val configuration = LocalConfiguration.current
|
||||
val contentSizeRatioRatio = if (configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
|
@ -361,18 +366,19 @@ private fun Status(
|
|||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
// progress circle
|
||||
if (walletDisplayValues.progress.decimal > PercentDecimal.ZERO_PERCENT.decimal) {
|
||||
CircularProgressIndicator(
|
||||
progress = walletDisplayValues.progress.decimal,
|
||||
color = Color.Gray,
|
||||
strokeWidth = progressCircleStroke,
|
||||
modifier = Modifier
|
||||
.matchParentSize()
|
||||
.padding(progressCirclePadding)
|
||||
.testTag(HomeTag.PROGRESS)
|
||||
)
|
||||
if (isCircularProgressBarEnabled) {
|
||||
if (walletDisplayValues.progress.decimal > PercentDecimal.ZERO_PERCENT.decimal) {
|
||||
CircularProgressIndicator(
|
||||
progress = walletDisplayValues.progress.decimal,
|
||||
color = Color.Gray,
|
||||
strokeWidth = progressCircleStroke,
|
||||
modifier = Modifier
|
||||
.matchParentSize()
|
||||
.padding(progressCirclePadding)
|
||||
.testTag(HomeTag.PROGRESS)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// texts
|
||||
Column(
|
||||
modifier = Modifier
|
||||
|
|
Loading…
Reference in New Issue