Skip to content

Commit

Permalink
Merge pull request #390 from mysteriumnetwork/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
ArtemHryhorovGeniusee authored Jun 18, 2021
2 parents 413de00 + 4026772 commit 80f16bf
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 75 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ android {
buildConfigField "String", "BUGFENDER_KEY", "\"76DAzZtiLE5AYx7uvIWD8I16EqgReOHc\""
buildConfigField "String", "INTERCOM_API_KEY", "\"android_sdk-e480f3fce4f2572742b13c282c453171c1715516\""
buildConfigField "String", "INTERCOM_APP_ID", "\"h7hlm9on\""
buildConfigField "String", "NODE_VERSION", "\"0.47.0\""
buildConfigField "String", "NODE_VERSION", "\"0.47.2\""

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

Expand Down Expand Up @@ -223,7 +223,7 @@ dependencies {

//Mysterium
implementation "network.mysterium:terms:0.0.32"
implementation "network.mysterium:mobile-node:0.47.0"
implementation "network.mysterium:mobile-node:0.47.2"
// Change NODE_VERSION in defaultConfig if updating version of mobile-node
// Comment network.mysterium:mobile-node and replace with your local path to use local node build.
//implementation files('/Users/macbook/AndroidStudioProjects/Mysterium.aar')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.*
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import mysterium.GetBalanceRequest
import updated.mysterium.vpn.core.DeferredNode
import updated.mysterium.vpn.core.MysteriumCoreService
import updated.mysterium.vpn.model.wallet.IdentityModel
import updated.mysterium.vpn.model.wallet.IdentityRegistrationStatus
import updated.mysterium.vpn.network.provider.usecase.UseCaseProvider
import updated.mysterium.vpn.ui.connection.ConnectionViewModel

class BalanceViewModel(useCaseProvider: UseCaseProvider) : ViewModel() {

Expand All @@ -33,7 +35,7 @@ class BalanceViewModel(useCaseProvider: UseCaseProvider) : ViewModel() {
val handler = CoroutineExceptionHandler { _, exception ->
Log.i(TAG, exception.localizedMessage ?: exception.toString())
}
viewModelScope.launch(handler) {
viewModelScope.launch(Dispatchers.IO + handler) {
startDeferredNode(mysteriumCoreService)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package updated.mysterium.vpn.ui.splash

import android.animation.Animator
import android.app.Activity
import android.content.ActivityNotFoundException
import android.content.Intent
Expand All @@ -18,14 +17,14 @@ import com.google.android.play.core.appupdate.AppUpdateManager
import com.google.android.play.core.appupdate.AppUpdateManagerFactory
import com.google.android.play.core.install.model.AppUpdateType
import com.google.android.play.core.install.model.UpdateAvailability
import network.mysterium.vpn.BuildConfig
import network.mysterium.vpn.R
import network.mysterium.vpn.databinding.ActivitySplashBinding
import network.mysterium.vpn.databinding.PopUpNewVersionBinding
import org.koin.android.ext.android.inject
import updated.mysterium.vpn.App
import updated.mysterium.vpn.analitics.AnalyticEvent
import updated.mysterium.vpn.analitics.AnalyticWrapper
import updated.mysterium.vpn.common.animation.OnAnimationCompletedListener
import updated.mysterium.vpn.common.network.NetworkUtil
import updated.mysterium.vpn.model.manual.connect.ConnectionState
import updated.mysterium.vpn.model.pushy.PushyTopic
Expand Down Expand Up @@ -56,10 +55,9 @@ class SplashActivity : BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivitySplashBinding.inflate(layoutInflater)
applyDarkMode()
setContentView(binding.root)
applyDarkMode()
ensureVpnServicePermission()
configure()
subscribeViewModel()
setUpPushyNotifications()
}
Expand All @@ -81,26 +79,12 @@ class SplashActivity : BaseActivity() {
}
}

private fun configure() {
binding.onceAnimationView.addAnimatorListener(object : OnAnimationCompletedListener() {

override fun onAnimationEnd(animation: Animator?) {
viewModel.animationLoaded()
binding.onceAnimationView.visibility = View.GONE
binding.onceAnimationView.cancelAnimation()
binding.loopAnimationView.visibility = View.VISIBLE
binding.loopAnimationView.playAnimation()
}
})
}

private fun subscribeViewModel() {
viewModel.navigateForward.observe(this, {
establishConnectionListeners()
navigateForward()
})
viewModel.preloadFinished.observe(this, {
binding.onceAnimationView.playAnimation()
viewModel.initRepository()
})
}
Expand All @@ -123,13 +107,21 @@ class SplashActivity : BaseActivity() {
}

private fun checkForGoogleMarketUpdates(afterAction: () -> Unit) {
appUpdateManager.appUpdateInfo.addOnSuccessListener { appUpdateInfo ->
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE &&
appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)
) {
showNewVersionAvailablePopUp()
} else {
afterAction.invoke()
if (BuildConfig.DEBUG) {
afterAction.invoke()
} else {
appUpdateManager.appUpdateInfo.addOnSuccessListener { appUpdateInfo ->
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE &&
appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)
) {
showNewVersionAvailablePopUp()
} else {
afterAction.invoke()
}
}
appUpdateManager.appUpdateInfo.addOnFailureListener {
showPlayMarketErrorToast()
finish()
}
}
}
Expand Down Expand Up @@ -214,6 +206,16 @@ class SplashActivity : BaseActivity() {
}
}

private fun showPlayMarketErrorToast() {
Toast.makeText(
this,
getString(R.string.error_play_account),
Toast.LENGTH_LONG
).apply {
(view.findViewById<View>(android.R.id.message) as TextView).gravity = Gravity.CENTER
}.show()
}

private fun showPermissionErrorToast() {
Toast.makeText(
this,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ class SplashViewModel(useCaseProvider: UseCaseProvider) : ViewModel() {
private val termsUseCase = useCaseProvider.terms()
private val settingsUseCase = useCaseProvider.settings()
private val pushyUseCase = useCaseProvider.pushy()
private var isAnimationLoaded = false
private var isDataLoaded = false
private var deferredNode = DeferredNode()

fun startLoading(
Expand Down Expand Up @@ -69,26 +67,14 @@ class SplashViewModel(useCaseProvider: UseCaseProvider) : ViewModel() {

fun isNewUser() = loginUseCase.isNewUser()

fun animationLoaded() {
if (isDataLoaded) {
_navigateForward.postValue(Unit)
} else {
isAnimationLoaded = true
}
}

fun initRepository() {
val handler = CoroutineExceptionHandler { _, exception ->
Log.e(TAG, exception.localizedMessage ?: exception.toString())
}
viewModelScope.launch(Dispatchers.IO + handler) {
balanceUseCase.initDeferredNode(deferredNode)
connectionUseCase.initDeferredNode(deferredNode)
if (isAnimationLoaded) {
_navigateForward.postValue(Unit)
} else {
isDataLoaded = true
}
_navigateForward.postValue(Unit)
}
}

Expand Down
Binary file removed android/app/src/main/res/drawable/splash_logo.png
Binary file not shown.
9 changes: 9 additions & 0 deletions android/app/src/main/res/drawable/splash_logo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="228dp"
android:height="120dp"
android:viewportWidth="228"
android:viewportHeight="120">
<path
android:pathData="M226.16,74.637L153.552,0.836C153.015,0.295 152.281,0 151.499,0C150.716,0 149.983,0.295 149.445,0.836L116.442,34.391C115.073,35.769 112.921,35.769 111.552,34.391L78.549,0.836C77.473,-0.246 75.566,-0.246 74.49,0.836L1.834,74.588C-0.611,77.048 -0.611,81.033 1.834,83.493L36.94,119.164C38.015,120.246 39.922,120.246 40.998,119.164L74.001,85.609C75.37,84.231 77.522,84.231 78.891,85.609L111.943,119.114C112.481,119.656 113.215,119.951 113.997,119.951C114.779,119.951 115.513,119.656 116.05,119.114L149.103,85.609C150.472,84.231 152.623,84.231 153.992,85.609L186.996,119.164C187.534,119.705 188.267,120 189.05,120C189.832,120 190.565,119.705 191.103,119.164L226.209,83.493C228.605,81.082 228.605,77.097 226.16,74.637ZM153.552,77.048L144.996,68.143C143.285,66.371 143.92,63.37 146.267,62.485L160.006,57.269C162.451,56.335 165.043,58.401 164.602,61.058L162.06,77.835C161.62,80.64 158.197,81.771 156.193,79.754L153.552,77.048ZM59.333,43.542L39.238,49.988C37.331,50.578 35.864,48.216 37.282,46.79L59.724,24.01C61.24,22.435 63.88,23.764 63.587,25.929L61.68,40.689C61.533,42.066 60.604,43.149 59.333,43.542ZM63.391,51.759L69.797,69.176C70.579,71.291 68.574,73.407 66.423,72.669L48.234,66.568C46.865,66.126 45.936,64.846 45.887,63.37L45.741,56.581C45.692,55.055 46.67,53.678 48.136,53.186L59.138,49.643C60.898,49.102 62.756,50.037 63.391,51.759ZM50.777,73.456L65.983,78.573C68.427,79.41 69.112,82.46 67.352,84.28L50.386,101.501C49.065,102.829 46.816,101.943 46.767,100.074L46.229,76.9C46.181,74.44 48.479,72.718 50.777,73.456ZM76.251,53.333L95.27,61.304C97.128,62.091 97.911,64.256 97.031,66.076L89.354,81.525C88.279,83.641 85.492,84.084 83.829,82.411L79.526,78.032C79.184,77.688 78.891,77.245 78.744,76.802L71.752,57.761C70.677,54.908 73.464,52.153 76.251,53.333ZM162.744,50.135L148.761,55.4C146.903,56.089 144.849,55.105 144.262,53.186L143.04,49.25C142.649,48.02 142.991,46.642 143.92,45.757L157.953,32.029C159.077,30.898 160.984,31.439 161.424,33.014L164.847,46.002C165.287,47.724 164.407,49.545 162.744,50.135ZM136.977,59.877L122.309,65.387C121.478,65.683 120.598,65.683 119.766,65.338L117.42,64.354C116.05,63.764 115.219,62.386 115.317,60.861L116.686,43.444C116.735,42.608 117.077,41.87 117.664,41.279L126.514,32.276C128.323,30.406 131.452,31.193 132.234,33.702L138.982,55.597C139.569,57.368 138.64,59.237 136.977,59.877ZM105.196,59.237L100.502,57.269C99.475,56.827 98.742,55.941 98.497,54.908L92.435,30.012C91.799,27.454 94.928,25.683 96.786,27.552L109.939,40.886C110.623,41.624 111.014,42.608 110.917,43.592L109.939,56.285C109.743,58.696 107.347,60.172 105.196,59.237ZM106.907,66.224L116.735,70.357C117.811,70.799 118.593,71.734 118.789,72.915L120.647,82.657C121.087,84.822 118.886,86.593 116.882,85.707L101.089,78.868C99.28,78.081 98.497,75.916 99.378,74.145L102.507,67.897C103.338,66.224 105.245,65.486 106.907,66.224ZM126.954,69.815L133.359,67.405C134.63,66.913 136.097,67.257 137.026,68.241L145.143,76.654C146.463,78.032 146.414,80.148 145.094,81.525L133.897,92.891C131.941,94.859 128.616,93.825 128.078,91.119L124.754,73.801C124.46,72.03 125.389,70.406 126.954,69.815ZM174.43,53.579L180.346,53.432C181.667,53.382 182.889,54.12 183.476,55.301L191.201,70.111C191.837,71.291 191.69,72.768 190.908,73.85L175.653,93.973C174.381,95.646 171.937,95.793 170.47,94.317L167.292,91.07C166.509,90.283 166.167,89.201 166.314,88.118L171.105,56.581C171.35,54.859 172.768,53.629 174.43,53.579ZM170.568,45.264L166.265,28.831C165.58,26.273 168.71,24.453 170.568,26.322L185.676,41.673C187.778,43.838 186.36,47.479 183.329,47.577L173.99,47.823C172.377,47.872 170.959,46.79 170.568,45.264ZM153.944,9.446L155.068,10.578C155.508,11.021 155.801,11.562 155.948,12.153L158.344,21.255C158.686,22.485 158.295,23.764 157.415,24.649L144.556,37.196C142.698,39.016 139.618,38.229 138.884,35.72L135.755,25.584C135.364,24.354 135.706,23.026 136.586,22.091L149.054,9.397C150.423,8.069 152.623,8.069 153.944,9.446ZM78.94,9.446L81.727,12.251C82.167,12.694 82.46,13.235 82.607,13.875L90.674,47.183C91.359,49.938 88.621,52.3 85.98,51.218L69.552,44.28C68.134,43.69 67.254,42.165 67.45,40.64L70.921,13.628C71.019,12.891 71.361,12.153 71.899,11.611L74.05,9.397C75.419,8.069 77.62,8.069 78.94,9.446ZM23.885,60.959L35.619,57.171C37.82,56.482 40.069,58.057 40.118,60.369L40.411,71.931C40.46,73.21 39.776,74.391 38.7,75.031L17.431,87.479C16.062,88.266 14.351,88.02 13.275,86.937L7.945,81.525C6.625,80.197 6.625,77.983 7.945,76.654L22.516,61.845C22.858,61.402 23.347,61.107 23.885,60.959ZM37.38,111.439L22.467,96.285C20.902,94.662 21.244,92.005 23.2,90.873L35.619,83.592C37.869,82.263 40.753,83.887 40.802,86.494L41.34,109.766C41.34,110.406 41.096,110.996 40.656,111.439C39.727,112.325 38.26,112.325 37.38,111.439ZM111.552,110.603L93.168,91.907C92.141,90.873 91.897,89.25 92.532,87.921L93.755,85.461C94.586,83.838 96.542,83.1 98.204,83.838L121.331,93.825C122.358,94.268 123.14,95.203 123.336,96.335L124.167,100.615C124.363,101.747 124.02,102.878 123.238,103.715L116.491,110.603C115.073,111.98 112.921,111.98 111.552,110.603ZM186.556,110.603L179.417,103.321C178.195,102.091 178.097,100.172 179.124,98.795L191.885,81.968C193.401,79.951 196.482,80.197 197.655,82.46L203.962,94.465C204.647,95.793 204.402,97.466 203.376,98.499L191.494,110.603C190.125,111.98 187.925,111.98 186.556,110.603ZM207.189,88.266L190.614,56.581C189.783,55.006 190.908,53.087 192.668,53.087L195.308,53.038C196.237,52.989 197.166,53.382 197.851,54.071L220.097,76.654C221.418,77.983 221.418,80.197 220.097,81.525L212.665,89.053C211.003,90.726 208.265,90.332 207.189,88.266Z"
android:fillColor="#ffffff"/>
</vector>
28 changes: 4 additions & 24 deletions android/app/src/main/res/layout/activity_splash.xml
Original file line number Diff line number Diff line change
@@ -1,38 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.airbnb.lottie.LottieAnimationView
android:id="@+id/onceAnimationView"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_marginVertical="@dimen/margin_padding_size_small"
android:alpha="0.3"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:lottie_autoPlay="false"
app:lottie_loop="false"
app:lottie_rawRes="@raw/splash_once_animation" />

<com.airbnb.lottie.LottieAnimationView
android:id="@+id/loopAnimationView"
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginVertical="@dimen/margin_padding_size_small"
android:visibility="gone"
android:alpha="0.3"
android:src="@drawable/splash_logo"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:lottie_autoPlay="false"
app:lottie_loop="true"
app:lottie_rawRes="@raw/splash_loop_animation" />
tools:ignore="ContentDescription" />

</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 1 addition & 0 deletions android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@

<!-- Error -->
<string name="error_vpn_permission">VPN connection has to be granted for MysteriumVPN to work</string>
<string name="error_play_account">You have to have Google Play account</string>

<!-- HomeSelection -->
<string name="home_selection_smart_connect">Smart Connect is coming soon</string>
Expand Down
15 changes: 10 additions & 5 deletions android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@

<!-- RoundedSemiTransparentButton -->
<style name="Widget.RoundedSemiTransparentButton" parent="Widget.MaterialComponents.Button">
<item name="android:textAppearance">@style/TextAppearance.RoundedSemiTransparentButton</item>
<item name="android:textAppearance">@style/TextAppearance.RoundedSemiTransparentButton
</item>
<item name="android:background">@drawable/shape_rounded_semi_transparent</item>
<item name="backgroundTint">@null</item>
<item name="android:textColor">@color/manual_connect_subtitle_white</item>
Expand All @@ -156,7 +157,8 @@

<!-- RoundedUnfocusedButton -->
<style name="Widget.RoundedUnfocusedButton" parent="Widget.MaterialComponents.Button">
<item name="android:textAppearance">@style/TextAppearance.RoundedSemiTransparentButton</item>
<item name="android:textAppearance">@style/TextAppearance.RoundedSemiTransparentButton
</item>
<item name="android:background">@drawable/shape_rounded_grey_blue</item>
<item name="backgroundTint">@null</item>
<item name="android:textColor">@android:color/white</item>
Expand All @@ -174,7 +176,8 @@

<!-- SecondaryButton -->
<style name="Widget.SecondaryButton" parent="Widget.MaterialComponents.Button">
<item name="android:textAppearance">@style/TextAppearance.RoundedSemiTransparentButton</item>
<item name="android:textAppearance">@style/TextAppearance.RoundedSemiTransparentButton
</item>
<item name="android:background">@drawable/secondary_button_background</item>
<item name="backgroundTint">@null</item>
<item name="android:textColor">@color/primary_text_color</item>
Expand All @@ -192,7 +195,8 @@

<!-- GradientButton -->
<style name="Widget.GradientButton" parent="Widget.MaterialComponents.Button">
<item name="android:textAppearance">@style/TextAppearance.RoundedSemiTransparentButton</item>
<item name="android:textAppearance">@style/TextAppearance.RoundedSemiTransparentButton
</item>
<item name="android:background">@drawable/shape_menu_button</item>
<item name="backgroundTint">@null</item>
<item name="android:textColor">@android:color/white</item>
Expand All @@ -210,7 +214,8 @@

<!-- ReportButton -->
<style name="Widget.ReportButton" parent="Widget.MaterialComponents.Button">
<item name="android:textAppearance">@style/TextAppearance.RoundedSemiTransparentButton</item>
<item name="android:textAppearance">@style/TextAppearance.RoundedSemiTransparentButton
</item>
<item name="android:background">@drawable/shape_report_button</item>
<item name="backgroundTint">@null</item>
<item name="android:textColor">@android:color/white</item>
Expand Down
2 changes: 1 addition & 1 deletion fastlane/android_version_code
Original file line number Diff line number Diff line change
@@ -1 +1 @@
107104
107105

0 comments on commit 80f16bf

Please sign in to comment.