Skip to content

Commit

Permalink
Merge pull request #337 from mysteriumnetwork/feature/Added_new_anima…
Browse files Browse the repository at this point in the history
…tions

Added new animations
  • Loading branch information
ArtemHryhorovGeniusee authored May 14, 2021
2 parents 16fbf49 + 7225957 commit e09e034
Show file tree
Hide file tree
Showing 17 changed files with 84 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -45,6 +47,9 @@ class FavouritesActivity : BaseActivity() {
}

private fun bindsAction() {
binding.manualConnectToolbar.onConnectClickListener {
navigateToHome()
}
binding.manualConnectToolbar.onLeftButtonClicked {
finish()
}
Expand All @@ -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 ->
Expand Down Expand Up @@ -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)
}
}
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,17 @@ class WalletActivity : BaseActivity() {
}

private fun configure() {
balanceViewModel.balanceLiveData.value?.let {
handleBalance(it)
}
initToolbar(binding.manualConnectToolbar)
initViewPager()
initTabLayout(resources.configuration.layoutDirection == View.LAYOUT_DIRECTION_RTL)
}

private fun subscribeViewModel() {
balanceViewModel.balanceLiveData.observe(this, {
binding.balanceTextView.text = getString(R.string.wallet_current_balance, it)
getWalletEquivalent(it)
getUsdEquivalent(it)
handleBalance(it)
})
}

Expand All @@ -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) {
Expand Down
20 changes: 17 additions & 3 deletions android/app/src/main/res/layout/activity_top_up_amount.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@
android:orientation="vertical"
app:layout_constraintGuide_percent="0.5" />

<androidx.constraintlayout.widget.Guideline
android:id="@+id/leftGuideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.15" />

<androidx.constraintlayout.widget.Guideline
android:id="@+id/rightGuideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.85" />

<ImageButton
android:id="@+id/backButton"
style="@style/Widget.SemiTransparentButton"
Expand All @@ -35,10 +49,11 @@
style="@style/TextAppearance.HeadTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/margin_padding_size_xxsmall"
android:text="@string/top_up_amount_title"
android:textColor="@android:color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="@id/rightGuideline"
app:layout_constraintStart_toStartOf="@id/leftGuideline"
app:layout_constraintTop_toTopOf="@+id/backButton" />

<ImageView
Expand Down Expand Up @@ -184,7 +199,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_padding_size_small_medium"
android:text="@string/top_up_usd_equivalent"
android:textColor="@color/manual_connect_divider_grey_blue"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down
3 changes: 1 addition & 2 deletions android/app/src/main/res/layout/activity_wallet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="@dimen/margin_padding_size_medium"
android:text="@string/wallet_start_balance"
android:textColor="@android:color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down Expand Up @@ -127,7 +126,7 @@
android:layout_height="wrap_content"
android:layout_marginVertical="@dimen/margin_padding_size_small"
android:text="@string/wallet_buys_for_you"
android:textColor="@color/onboarding_faded_screen_white"
android:textColor="@color/wallet_description"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/usdEquivalentTextView" />
Expand Down
3 changes: 2 additions & 1 deletion android/app/src/main/res/layout/crypto_animation.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
android:alpha="0.7">

<com.airbnb.lottie.LottieAnimationView
android:id="@+id/mystAnimation"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_padding_size_medium"
android:layout_marginStart="@dimen/margin_padding_size_small_medium"
android:src="@drawable/icon_language"
app:layout_constraintBottom_toBottomOf="@+id/spinner"
app:layout_constraintStart_toEndOf="@+id/spinner"
app:layout_constraintTop_toTopOf="@+id/spinner"
app:layout_goneMarginStart="@dimen/margin_padding_size_small"
tools:ignore="ContentDescription" />

</androidx.constraintlayout.widget.ConstraintLayout>
5 changes: 3 additions & 2 deletions android/app/src/main/res/layout/toolbar_base_connect.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">

<TextView
Expand Down
Loading

0 comments on commit e09e034

Please sign in to comment.