From af763d432249d7a379005faa4f178dae74dadb69 Mon Sep 17 00:00:00 2001 From: Rafael Muhamedzyanov Date: Tue, 26 Sep 2023 18:02:24 +0600 Subject: [PATCH] Move Contact, Tell Friends, Rate Us to Main Settings page --- .../modules/settings/about/AboutFragment.kt | 50 ++--------------- .../settings/main/MainSettingsScreen.kt | 53 ++++++++++++++++--- .../settings/main/MainSettingsService.kt | 1 + .../settings/main/MainSettingsViewModel.kt | 1 + 4 files changed, 52 insertions(+), 53 deletions(-) diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/settings/about/AboutFragment.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/settings/about/AboutFragment.kt index 9e9f85169c1..9c690a006c0 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/settings/about/AboutFragment.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/settings/about/AboutFragment.kt @@ -1,7 +1,5 @@ package io.horizontalsystems.bankwallet.modules.settings.about -import android.content.Context -import android.content.Intent import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column @@ -31,8 +29,6 @@ import io.horizontalsystems.bankwallet.R import io.horizontalsystems.bankwallet.core.BaseComposeFragment import io.horizontalsystems.bankwallet.core.composablePage import io.horizontalsystems.bankwallet.core.composablePopup -import io.horizontalsystems.bankwallet.core.managers.RateAppManager -import io.horizontalsystems.bankwallet.core.providers.Translator import io.horizontalsystems.bankwallet.core.slideFromBottom import io.horizontalsystems.bankwallet.modules.releasenotes.ReleaseNotesScreen import io.horizontalsystems.bankwallet.modules.settings.appstatus.AppStatusScreen @@ -45,6 +41,7 @@ import io.horizontalsystems.bankwallet.ui.compose.components.CellSingleLineLawre import io.horizontalsystems.bankwallet.ui.compose.components.CellUniversalLawrenceSection import io.horizontalsystems.bankwallet.ui.compose.components.HsBackButton import io.horizontalsystems.bankwallet.ui.compose.components.InfoTextBody +import io.horizontalsystems.bankwallet.ui.compose.components.VSpacer import io.horizontalsystems.bankwallet.ui.compose.components.subhead2_grey import io.horizontalsystems.bankwallet.ui.helpers.LinkHelper import io.horizontalsystems.core.findNavController @@ -194,36 +191,8 @@ private fun SettingSections( ) }) ) - - Spacer(Modifier.height(32.dp)) - - CellUniversalLawrenceSection( - listOf({ - HsSettingCell( - R.string.Settings_RateUs, - R.drawable.ic_star_20, - onClick = { RateAppManager.openPlayMarket(context) } - ) - }, { - HsSettingCell( - R.string.Settings_ShareThisWallet, - R.drawable.ic_share_20, - onClick = { shareAppLink(viewModel.appWebPageLink, context) } - ) - }) - ) - - Spacer(Modifier.height(32.dp)) - - CellUniversalLawrenceSection( - listOf { - HsSettingCell( - R.string.SettingsContact_Title, - R.drawable.ic_mail_24, - onClick = showContactOptions - ) - } - ) + + VSpacer(32.dp) } @Composable @@ -257,19 +226,6 @@ fun AboutHeader(appVersion: String) { } } -private fun shareAppLink(appLink: String, context: Context) { - val shareMessage = Translator.getString(R.string.SettingsShare_Text) + "\n" + appLink + "\n" - val shareIntent = Intent(Intent.ACTION_SEND) - shareIntent.type = "text/plain" - shareIntent.putExtra(Intent.EXTRA_TEXT, shareMessage) - context.startActivity( - Intent.createChooser( - shareIntent, - Translator.getString(R.string.SettingsShare_Title) - ) - ) -} - @Preview @Composable private fun previewAboutScreen() { diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/settings/main/MainSettingsScreen.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/settings/main/MainSettingsScreen.kt index 68adb1581b2..1320dc1b4f3 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/settings/main/MainSettingsScreen.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/settings/main/MainSettingsScreen.kt @@ -1,5 +1,7 @@ package io.horizontalsystems.bankwallet.modules.settings.main +import android.content.Context +import android.content.Intent import androidx.annotation.DrawableRes import androidx.annotation.StringRes import androidx.compose.foundation.Image @@ -30,6 +32,7 @@ import androidx.core.os.bundleOf import androidx.lifecycle.viewmodel.compose.viewModel import androidx.navigation.NavController import io.horizontalsystems.bankwallet.R +import io.horizontalsystems.bankwallet.core.managers.RateAppManager import io.horizontalsystems.bankwallet.core.providers.Translator import io.horizontalsystems.bankwallet.core.slideFromBottom import io.horizontalsystems.bankwallet.core.slideFromRight @@ -85,6 +88,7 @@ private fun SettingSections( val wcCounter by viewModel.wcCounterLiveData.observeAsState() val baseCurrency by viewModel.baseCurrencyLiveData.observeAsState() val language by viewModel.languageLiveData.observeAsState() + val context = LocalContext.current CellUniversalLawrenceSection( listOf { @@ -124,7 +128,7 @@ private fun SettingSections( }) ) - Spacer(Modifier.height(32.dp)) + VSpacer(32.dp) CellUniversalLawrenceSection( listOf { @@ -160,7 +164,7 @@ private fun SettingSections( } ) - Spacer(Modifier.height(32.dp)) + VSpacer(32.dp) CellUniversalLawrenceSection( listOf( @@ -215,7 +219,7 @@ private fun SettingSections( ) ) - Spacer(Modifier.height(32.dp)) + VSpacer(32.dp) CellUniversalLawrenceSection( listOf { @@ -229,7 +233,7 @@ private fun SettingSections( } ) - Spacer(Modifier.height(32.dp)) + VSpacer(32.dp) CellUniversalLawrenceSection( listOf({ @@ -251,7 +255,7 @@ private fun SettingSections( }) ) - Spacer(Modifier.height(32.dp)) + VSpacer(32.dp) CellUniversalLawrenceSection( listOf { @@ -266,7 +270,31 @@ private fun SettingSections( } ) - Spacer(Modifier.height(32.dp)) + VSpacer(32.dp) + + CellUniversalLawrenceSection( + listOf({ + HsSettingCell( + R.string.Settings_RateUs, + R.drawable.ic_star_20, + onClick = { RateAppManager.openPlayMarket(context) } + ) + }, { + HsSettingCell( + R.string.Settings_ShareThisWallet, + R.drawable.ic_share_20, + onClick = { shareAppLink(viewModel.appWebPageLink, context) } + ) + }, { + HsSettingCell( + R.string.SettingsContact_Title, + R.drawable.ic_mail_24, + onClick = { navController.slideFromBottom(R.id.contactOptionsDialog) }, + ) + }) + ) + + VSpacer(32.dp) } @Composable @@ -360,6 +388,19 @@ private fun SettingsFooter(appVersion: String, companyWebPage: String) { } } +private fun shareAppLink(appLink: String, context: Context) { + val shareMessage = Translator.getString(R.string.SettingsShare_Text) + "\n" + appLink + "\n" + val shareIntent = Intent(Intent.ACTION_SEND) + shareIntent.type = "text/plain" + shareIntent.putExtra(Intent.EXTRA_TEXT, shareMessage) + context.startActivity( + Intent.createChooser( + shareIntent, + Translator.getString(R.string.SettingsShare_Title) + ) + ) +} + @Preview @Composable private fun previewSettingsScreen() { diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/settings/main/MainSettingsService.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/settings/main/MainSettingsService.kt index 11086745744..31ba7f2b919 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/settings/main/MainSettingsService.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/settings/main/MainSettingsService.kt @@ -30,6 +30,7 @@ class MainSettingsService( private val appConfigProvider: AppConfigProvider ) { + val appWebPageLink = appConfigProvider.appWebPageLink private val backedUpSubject = BehaviorSubject.create() val backedUpObservable: Observable get() = backedUpSubject diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/settings/main/MainSettingsViewModel.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/settings/main/MainSettingsViewModel.kt index cba06f98046..7f2adda658d 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/settings/main/MainSettingsViewModel.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/settings/main/MainSettingsViewModel.kt @@ -23,6 +23,7 @@ class MainSettingsViewModel( val baseCurrencyLiveData = MutableLiveData(service.baseCurrency) val languageLiveData = MutableLiveData(service.currentLanguageDisplayName) val appVersion by service::appVersion + val appWebPageLink by service::appWebPageLink private var wcSessionsCount = service.walletConnectSessionCount private var wc2PendingRequestCount = 0