diff --git a/android/app/src/main/java/updated/mysterium/vpn/ui/base/BaseViewModel.kt b/android/app/src/main/java/updated/mysterium/vpn/ui/base/BaseViewModel.kt
index 4c68b86f2..ca1573d69 100644
--- a/android/app/src/main/java/updated/mysterium/vpn/ui/base/BaseViewModel.kt
+++ b/android/app/src/main/java/updated/mysterium/vpn/ui/base/BaseViewModel.kt
@@ -13,8 +13,8 @@ import java.util.Locale
class BaseViewModel(useCaseProvider: UseCaseProvider) : ViewModel() {
private companion object {
- const val BALANCE_LIMIT = 1.0
- const val MIN_BALANCE_LIMIT = BALANCE_LIMIT * 0.1
+ const val BALANCE_LIMIT = 0.5
+ const val MIN_BALANCE_LIMIT = BALANCE_LIMIT * 0.2
const val PING_A_SERVER_COMMAND = "/system/bin/ping -c 1 8.8.8.8"
}
diff --git a/android/app/src/main/java/updated/mysterium/vpn/ui/favourites/FavouritesActivity.kt b/android/app/src/main/java/updated/mysterium/vpn/ui/favourites/FavouritesActivity.kt
index aa2bd61ae..746405fc8 100644
--- a/android/app/src/main/java/updated/mysterium/vpn/ui/favourites/FavouritesActivity.kt
+++ b/android/app/src/main/java/updated/mysterium/vpn/ui/favourites/FavouritesActivity.kt
@@ -6,10 +6,12 @@ import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import network.mysterium.vpn.databinding.ActivityFavouritesBinding
import org.koin.android.ext.android.inject
+import updated.mysterium.vpn.model.manual.connect.ConnectionState
import updated.mysterium.vpn.model.manual.connect.Proposal
import updated.mysterium.vpn.ui.base.AllNodesViewModel
import updated.mysterium.vpn.ui.base.BaseActivity
import updated.mysterium.vpn.ui.connection.ConnectionActivity
+import updated.mysterium.vpn.ui.home.selection.HomeSelectionActivity
import updated.mysterium.vpn.ui.search.SearchActivity
class FavouritesActivity : BaseActivity() {
@@ -45,6 +47,9 @@ class FavouritesActivity : BaseActivity() {
}
private fun bindsAction() {
+ binding.manualConnectToolbar.onConnectClickListener {
+ navigateToHome()
+ }
binding.manualConnectToolbar.onLeftButtonClicked {
finish()
}
@@ -55,7 +60,7 @@ class FavouritesActivity : BaseActivity() {
private fun initSavedListRecycler() {
favouritesAdapter.onProposalClicked = {
- navigateToHome(it)
+ navigateToConnection(it)
}
favouritesAdapter.onDeleteClicked = { proposal ->
viewModel.deleteNodeFromFavourite(proposal).observe(this, { result ->
@@ -93,10 +98,25 @@ class FavouritesActivity : BaseActivity() {
binding.qualityTextView.visibility = View.INVISIBLE
}
- private fun navigateToHome(proposal: Proposal) {
+ private fun navigateToConnection(proposal: Proposal) {
val intent = Intent(this, ConnectionActivity::class.java)
intent.putExtra(ConnectionActivity.EXTRA_PROPOSAL_MODEL, proposal)
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP
startActivity(intent)
}
+
+ private fun navigateToHome() {
+ val intent = if (
+ connectionState == ConnectionState.CONNECTED ||
+ connectionState == ConnectionState.CONNECTING
+ ) {
+ Intent(this, ConnectionActivity::class.java)
+ } else {
+ Intent(this, HomeSelectionActivity::class.java)
+ }
+ intent.apply {
+ flags = Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK
+ }
+ startActivity(intent)
+ }
}
diff --git a/android/app/src/main/java/updated/mysterium/vpn/ui/top/up/TopUpViewModel.kt b/android/app/src/main/java/updated/mysterium/vpn/ui/top/up/TopUpViewModel.kt
index a512693e6..0e98e16f7 100644
--- a/android/app/src/main/java/updated/mysterium/vpn/ui/top/up/TopUpViewModel.kt
+++ b/android/app/src/main/java/updated/mysterium/vpn/ui/top/up/TopUpViewModel.kt
@@ -1,15 +1,32 @@
package updated.mysterium.vpn.ui.top.up
+import android.util.Log
import androidx.lifecycle.ViewModel
+import androidx.lifecycle.viewModelScope
+import kotlinx.coroutines.CoroutineExceptionHandler
+import kotlinx.coroutines.launch
import updated.mysterium.vpn.common.extensions.liveDataResult
import updated.mysterium.vpn.network.provider.usecase.UseCaseProvider
class TopUpViewModel(useCaseProvider: UseCaseProvider) : ViewModel() {
+ private companion object {
+ const val TAG = "TopUpViewModel"
+ }
+
private val balanceUseCase = useCaseProvider.balance()
private val loginUseCase = useCaseProvider.login()
private var usdEquivalent: Double? = null
+ init {
+ val handler = CoroutineExceptionHandler { _, exception ->
+ Log.e(TAG, exception.localizedMessage ?: exception.toString())
+ }
+ viewModelScope.launch(handler) {
+ usdEquivalent = balanceUseCase.getUsdEquivalent()
+ }
+ }
+
fun getUsdEquivalent(value: Int) = liveDataResult {
if (usdEquivalent == null) {
usdEquivalent = balanceUseCase.getUsdEquivalent()
diff --git a/android/app/src/main/java/updated/mysterium/vpn/ui/wallet/WalletActivity.kt b/android/app/src/main/java/updated/mysterium/vpn/ui/wallet/WalletActivity.kt
index c93c00b82..b5f3583d1 100644
--- a/android/app/src/main/java/updated/mysterium/vpn/ui/wallet/WalletActivity.kt
+++ b/android/app/src/main/java/updated/mysterium/vpn/ui/wallet/WalletActivity.kt
@@ -71,6 +71,9 @@ class WalletActivity : BaseActivity() {
}
private fun configure() {
+ balanceViewModel.balanceLiveData.value?.let {
+ handleBalance(it)
+ }
initToolbar(binding.manualConnectToolbar)
initViewPager()
initTabLayout(resources.configuration.layoutDirection == View.LAYOUT_DIRECTION_RTL)
@@ -78,9 +81,7 @@ class WalletActivity : BaseActivity() {
private fun subscribeViewModel() {
balanceViewModel.balanceLiveData.observe(this, {
- binding.balanceTextView.text = getString(R.string.wallet_current_balance, it)
- getWalletEquivalent(it)
- getUsdEquivalent(it)
+ handleBalance(it)
})
}
@@ -107,6 +108,12 @@ class WalletActivity : BaseActivity() {
}
}
+ private fun handleBalance(balance: Double) {
+ binding.balanceTextView.text = getString(R.string.wallet_current_balance, balance)
+ getWalletEquivalent(balance)
+ getUsdEquivalent(balance)
+ }
+
@SuppressLint("InflateParams")
private fun initTabLayout(isRTL: Boolean) {
for (index in 0 until binding.chooseListTabLayout.tabCount) {
diff --git a/android/app/src/main/res/layout/activity_top_up_amount.xml b/android/app/src/main/res/layout/activity_top_up_amount.xml
index 9a7c9c857..af6b0be28 100644
--- a/android/app/src/main/res/layout/activity_top_up_amount.xml
+++ b/android/app/src/main/res/layout/activity_top_up_amount.xml
@@ -18,6 +18,20 @@
android:orientation="vertical"
app:layout_constraintGuide_percent="0.5" />
+
+
+
+
diff --git a/android/app/src/main/res/layout/crypto_animation.xml b/android/app/src/main/res/layout/crypto_animation.xml
index 3003b458f..0735e990f 100644
--- a/android/app/src/main/res/layout/crypto_animation.xml
+++ b/android/app/src/main/res/layout/crypto_animation.xml
@@ -1,8 +1,9 @@
+ android:alpha="0.7">
diff --git a/android/app/src/main/res/layout/toolbar_base_connect.xml b/android/app/src/main/res/layout/toolbar_base_connect.xml
index 02bf738cc..52e20fcd1 100644
--- a/android/app/src/main/res/layout/toolbar_base_connect.xml
+++ b/android/app/src/main/res/layout/toolbar_base_connect.xml
@@ -23,13 +23,14 @@
android:id="@+id/connectionCardView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_marginHorizontal="@dimen/margin_padding_size_xxsmall"
android:layout_marginTop="@dimen/margin_padding_size_large"
android:background="@drawable/shape_toolbar_connect"
android:clickable="true"
android:focusable="true"
app:layout_constraintBottom_toBottomOf="@+id/leftButton"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toStartOf="@+id/rightButton"
+ app:layout_constraintStart_toEndOf="@+id/leftButton"
app:layout_constraintTop_toTopOf="parent">
#ED5BAC
#A469A9
+ #50FFFFFF
+
#883A7A
#703C3857