[#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(
|
class HomeTestSetup(
|
||||||
private val composeTestRule: ComposeContentTestRule,
|
private val composeTestRule: ComposeContentTestRule,
|
||||||
private val walletSnapshot: WalletSnapshot,
|
private val walletSnapshot: WalletSnapshot,
|
||||||
private val isShowFiatConversion: Boolean
|
private val isShowFiatConversion: Boolean,
|
||||||
|
private val isCircularProgressBar: Boolean
|
||||||
) {
|
) {
|
||||||
private val onAboutCount = AtomicInteger(0)
|
private val onAboutCount = AtomicInteger(0)
|
||||||
private val onSeedCount = AtomicInteger(0)
|
private val onSeedCount = AtomicInteger(0)
|
||||||
|
@ -65,6 +66,7 @@ class HomeTestSetup(
|
||||||
isUpdateAvailable = false,
|
isUpdateAvailable = false,
|
||||||
isKeepScreenOnDuringSync = false,
|
isKeepScreenOnDuringSync = false,
|
||||||
isFiatConversionEnabled = isShowFiatConversion,
|
isFiatConversionEnabled = isShowFiatConversion,
|
||||||
|
isCircularProgressBarEnabled = isCircularProgressBar,
|
||||||
isDebugMenuEnabled = false,
|
isDebugMenuEnabled = false,
|
||||||
goSettings = {
|
goSettings = {
|
||||||
onSettingsCount.incrementAndGet()
|
onSettingsCount.incrementAndGet()
|
||||||
|
|
|
@ -26,7 +26,8 @@ class HomeActivityTest : UiTestPrerequisites() {
|
||||||
private fun newTestSetup(walletSnapshot: WalletSnapshot) = HomeTestSetup(
|
private fun newTestSetup(walletSnapshot: WalletSnapshot) = HomeTestSetup(
|
||||||
composeTestRule,
|
composeTestRule,
|
||||||
walletSnapshot,
|
walletSnapshot,
|
||||||
isShowFiatConversion = false
|
isShowFiatConversion = false,
|
||||||
|
isCircularProgressBar = false
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -27,7 +27,8 @@ class HomeViewIntegrationTest : UiTestPrerequisites() {
|
||||||
private fun newTestSetup(walletSnapshot: WalletSnapshot) = HomeTestSetup(
|
private fun newTestSetup(walletSnapshot: WalletSnapshot) = HomeTestSetup(
|
||||||
composeTestRule,
|
composeTestRule,
|
||||||
walletSnapshot,
|
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
|
// 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
|
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.assertIsDisplayed
|
||||||
import androidx.compose.ui.test.junit4.ComposeContentTestRule
|
import androidx.compose.ui.test.junit4.ComposeContentTestRule
|
||||||
import androidx.compose.ui.test.junit4.createComposeRule
|
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.onNodeWithText
|
||||||
import androidx.compose.ui.test.performClick
|
import androidx.compose.ui.test.performClick
|
||||||
import androidx.compose.ui.test.performScrollTo
|
import androidx.compose.ui.test.performScrollTo
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.test.filters.MediumTest
|
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.test.UiTestPrerequisites
|
||||||
import co.electriccoin.zcash.ui.R
|
import co.electriccoin.zcash.ui.R
|
||||||
import co.electriccoin.zcash.ui.fixture.WalletSnapshotFixture
|
import co.electriccoin.zcash.ui.fixture.WalletSnapshotFixture
|
||||||
import co.electriccoin.zcash.ui.screen.home.HomeTag
|
import co.electriccoin.zcash.ui.screen.home.HomeTag
|
||||||
import co.electriccoin.zcash.ui.screen.home.HomeTestSetup
|
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 co.electriccoin.zcash.ui.test.getStringResource
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Rule
|
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
|
@Test
|
||||||
@MediumTest
|
@MediumTest
|
||||||
fun click_receive_button() {
|
fun click_receive_button() {
|
||||||
|
@ -147,10 +185,15 @@ class HomeViewTest : UiTestPrerequisites() {
|
||||||
assertEquals(1, testSetup.getOnAboutCount())
|
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,
|
composeTestRule,
|
||||||
WalletSnapshotFixture.new(),
|
walletSnapshot = walletSnapshot,
|
||||||
isShowFiatConversion = isShowFiatConversion
|
isShowFiatConversion = isShowFiatConversion,
|
||||||
|
isCircularProgressBar = isCircularProgressBar
|
||||||
).apply {
|
).apply {
|
||||||
setDefaultContent()
|
setDefaultContent()
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,4 +25,11 @@ object ConfigurationEntries {
|
||||||
* A troubleshooting step. If we fix our bugs, this should be unnecessary.
|
* A troubleshooting step. If we fix our bugs, this should be unnecessary.
|
||||||
*/
|
*/
|
||||||
val IS_RESCAN_ENABLED = BooleanConfigurationEntry(ConfigKey("is_rescan_enabled"), true)
|
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 isKeepScreenOnWhileSyncing = settingsViewModel.isKeepScreenOnWhileSyncing.collectAsStateWithLifecycle().value
|
||||||
val isFiatConversionEnabled = ConfigurationEntries.IS_FIAT_CONVERSION_ENABLED.getValue(RemoteConfig.current)
|
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) {
|
if (null == walletSnapshot) {
|
||||||
// Display loading indicator
|
// Display loading indicator
|
||||||
|
@ -99,6 +101,7 @@ internal fun WrapHome(
|
||||||
isUpdateAvailable = updateAvailable,
|
isUpdateAvailable = updateAvailable,
|
||||||
isKeepScreenOnDuringSync = isKeepScreenOnWhileSyncing,
|
isKeepScreenOnDuringSync = isKeepScreenOnWhileSyncing,
|
||||||
isFiatConversionEnabled = isFiatConversionEnabled,
|
isFiatConversionEnabled = isFiatConversionEnabled,
|
||||||
|
isCircularProgressBarEnabled = isCircularProgressBarEnabled,
|
||||||
isDebugMenuEnabled = isDebugMenuEnabled,
|
isDebugMenuEnabled = isDebugMenuEnabled,
|
||||||
goSeedPhrase = goSeedPhrase,
|
goSeedPhrase = goSeedPhrase,
|
||||||
goSettings = goSettings,
|
goSettings = goSettings,
|
||||||
|
|
|
@ -89,6 +89,7 @@ fun ComposablePreview() {
|
||||||
isKeepScreenOnDuringSync = false,
|
isKeepScreenOnDuringSync = false,
|
||||||
isDebugMenuEnabled = false,
|
isDebugMenuEnabled = false,
|
||||||
isFiatConversionEnabled = false,
|
isFiatConversionEnabled = false,
|
||||||
|
isCircularProgressBarEnabled = false,
|
||||||
goSeedPhrase = {},
|
goSeedPhrase = {},
|
||||||
goSettings = {},
|
goSettings = {},
|
||||||
goSupport = {},
|
goSupport = {},
|
||||||
|
@ -112,6 +113,7 @@ fun Home(
|
||||||
isUpdateAvailable: Boolean,
|
isUpdateAvailable: Boolean,
|
||||||
isKeepScreenOnDuringSync: Boolean?,
|
isKeepScreenOnDuringSync: Boolean?,
|
||||||
isFiatConversionEnabled: Boolean,
|
isFiatConversionEnabled: Boolean,
|
||||||
|
isCircularProgressBarEnabled: Boolean,
|
||||||
isDebugMenuEnabled: Boolean,
|
isDebugMenuEnabled: Boolean,
|
||||||
goSeedPhrase: () -> Unit,
|
goSeedPhrase: () -> Unit,
|
||||||
goSettings: () -> Unit,
|
goSettings: () -> Unit,
|
||||||
|
@ -149,6 +151,7 @@ fun Home(
|
||||||
isUpdateAvailable = isUpdateAvailable,
|
isUpdateAvailable = isUpdateAvailable,
|
||||||
isKeepScreenOnDuringSync = isKeepScreenOnDuringSync,
|
isKeepScreenOnDuringSync = isKeepScreenOnDuringSync,
|
||||||
isFiatConversionEnabled = isFiatConversionEnabled,
|
isFiatConversionEnabled = isFiatConversionEnabled,
|
||||||
|
isCircularProgressBarEnabled = isCircularProgressBarEnabled,
|
||||||
goReceive = goReceive,
|
goReceive = goReceive,
|
||||||
goSend = goSend,
|
goSend = goSend,
|
||||||
)
|
)
|
||||||
|
@ -291,6 +294,7 @@ private fun HomeMainContent(
|
||||||
isUpdateAvailable: Boolean,
|
isUpdateAvailable: Boolean,
|
||||||
isKeepScreenOnDuringSync: Boolean?,
|
isKeepScreenOnDuringSync: Boolean?,
|
||||||
isFiatConversionEnabled: Boolean,
|
isFiatConversionEnabled: Boolean,
|
||||||
|
isCircularProgressBarEnabled: Boolean,
|
||||||
goReceive: () -> Unit,
|
goReceive: () -> Unit,
|
||||||
goSend: () -> Unit,
|
goSend: () -> Unit,
|
||||||
) {
|
) {
|
||||||
|
@ -299,7 +303,7 @@ private fun HomeMainContent(
|
||||||
.verticalScroll(rememberScrollState())
|
.verticalScroll(rememberScrollState())
|
||||||
.padding(top = paddingValues.calculateTopPadding())
|
.padding(top = paddingValues.calculateTopPadding())
|
||||||
) {
|
) {
|
||||||
Status(walletSnapshot, isUpdateAvailable, isFiatConversionEnabled)
|
Status(walletSnapshot, isUpdateAvailable, isFiatConversionEnabled, isCircularProgressBarEnabled)
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(24.dp))
|
Spacer(modifier = Modifier.height(24.dp))
|
||||||
|
|
||||||
|
@ -326,7 +330,8 @@ private fun isSyncing(status: Synchronizer.Status): Boolean {
|
||||||
private fun Status(
|
private fun Status(
|
||||||
walletSnapshot: WalletSnapshot,
|
walletSnapshot: WalletSnapshot,
|
||||||
updateAvailable: Boolean,
|
updateAvailable: Boolean,
|
||||||
isFiatConversionEnabled: Boolean
|
isFiatConversionEnabled: Boolean,
|
||||||
|
isCircularProgressBarEnabled: Boolean
|
||||||
) {
|
) {
|
||||||
val configuration = LocalConfiguration.current
|
val configuration = LocalConfiguration.current
|
||||||
val contentSizeRatioRatio = if (configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
val contentSizeRatioRatio = if (configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||||
|
@ -361,6 +366,7 @@ private fun Status(
|
||||||
contentAlignment = Alignment.Center
|
contentAlignment = Alignment.Center
|
||||||
) {
|
) {
|
||||||
// progress circle
|
// progress circle
|
||||||
|
if (isCircularProgressBarEnabled) {
|
||||||
if (walletDisplayValues.progress.decimal > PercentDecimal.ZERO_PERCENT.decimal) {
|
if (walletDisplayValues.progress.decimal > PercentDecimal.ZERO_PERCENT.decimal) {
|
||||||
CircularProgressIndicator(
|
CircularProgressIndicator(
|
||||||
progress = walletDisplayValues.progress.decimal,
|
progress = walletDisplayValues.progress.decimal,
|
||||||
|
@ -372,7 +378,7 @@ private fun Status(
|
||||||
.testTag(HomeTag.PROGRESS)
|
.testTag(HomeTag.PROGRESS)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// texts
|
// texts
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
|
Loading…
Reference in New Issue