Skip to content

Commit 54e915a

Browse files
committed
Merge branch '3.91' into 'develop'
updated to v3.91 See merge request ws/client/androidapp!332
2 parents 090e946 + 2bfe8b5 commit 54e915a

File tree

9 files changed

+69
-9
lines changed

9 files changed

+69
-9
lines changed

base/src/main/java/com/windscribe/vpn/apppreference/AppPreferenceHelper.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,12 @@ class AppPreferenceHelper(
4444
private val securePreferences: SecurePreferences
4545
) : PreferencesHelper {
4646
override fun clearAllData() {
47+
val installation = getResponseString(PreferencesKeyConstants.NEW_INSTALLATION)
4748
preference.clear()
4849
securePreferences.clear()
50+
if (PreferencesKeyConstants.I_OLD == installation) {
51+
saveResponseStringData(PreferencesKeyConstants.NEW_INSTALLATION, PreferencesKeyConstants.I_OLD)
52+
}
4953
}
5054

5155
override fun clearOldSessionAuth() {

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ project.ext {
66
appTargetSdk = 35
77
appCompiledSdk = 35
88
appBuildTool = "35.0.0"
9-
appVersionCode = 1737
10-
appVersionName = "3.90"
9+
appVersionCode = 1769
10+
appVersionName = "3.91"
1111
java = "17"
1212
}
1313

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
v3.91(Mobile)
2+
* Fixed invalid captcha payload.
3+
* Fixed mobile not registering app install.
4+
* Several minor performance and stability enhancements
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
v3.91(TV)
2+
* Several minor performance and stability enhancements

mobile/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ android {
2828
applicationId rootProject.AppId
2929
minSdkVersion rootProject.appMinSdk
3030
targetSdkVersion rootProject.appTargetSdk
31-
versionName System.getenv().getOrDefault("VERSION_NAME", "3.90")
32-
versionCode 1737
31+
versionName System.getenv().getOrDefault("VERSION_NAME", "3.91")
32+
versionCode 1769
3333
vectorDrawables.useSupportLibrary = true
3434

3535
testInstrumentationRunner "com.windscribe.vpn.CustomRunner"

mobile/src/main/java/com/windscribe/mobile/di/ComposeModule.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ class ComposeModule {
181181
} else if (modelClass.isAssignableFrom(EditCustomConfigViewmodel::class.java)) {
182182
return EditCustomConfigViewmodelImpl(localDbInterface, windVpnController) as T
183183
} else if (modelClass.isAssignableFrom(AppStartActivityViewModel::class.java)) {
184-
return AppStartActivityViewModelImpl(appPreferenceHelper) as T
184+
return AppStartActivityViewModelImpl(appPreferenceHelper, apiCallManager) as T
185185
} else if (modelClass.isAssignableFrom(MainMenuViewModel::class.java)) {
186186
return MainMenuViewModelImpl(userRepository) as T
187187
} else if (modelClass.isAssignableFrom(GeneralViewModel::class.java)) {

mobile/src/main/java/com/windscribe/mobile/ui/AppStartActivityViewModel.kt

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,21 @@ package com.windscribe.mobile.ui
22

33
import androidx.annotation.DrawableRes
44
import androidx.lifecycle.ViewModel
5+
import androidx.lifecycle.viewModelScope
6+
import com.windscribe.vpn.api.ApiCallManager
7+
import com.windscribe.vpn.api.IApiCallManager
58
import com.windscribe.vpn.apppreference.PreferencesHelper
69
import com.windscribe.vpn.autoconnection.AutoConnectionModeCallback
710
import com.windscribe.vpn.autoconnection.ProtocolInformation
11+
import com.windscribe.vpn.commonutils.Ext.result
12+
import com.windscribe.vpn.constants.PreferencesKeyConstants
13+
import com.windscribe.vpn.repository.CallResult
814
import kotlinx.coroutines.flow.MutableStateFlow
915
import kotlinx.coroutines.flow.StateFlow
16+
import kotlinx.coroutines.launch
1017
import net.grandcentrix.tray.core.OnTrayPreferenceChangeListener
18+
import org.slf4j.LoggerFactory
19+
import kotlin.math.log
1120

1221
abstract class DialogCallback {
1322
abstract fun onDismiss()
@@ -40,19 +49,41 @@ abstract class AppStartActivityViewModel : ViewModel() {
4049
abstract fun setDialogCallback(data: DialogData, dialogCallback: DialogCallback)
4150
}
4251

43-
class AppStartActivityViewModelImpl(val preferencesHelper: PreferencesHelper) :
52+
class AppStartActivityViewModelImpl(val preferencesHelper: PreferencesHelper, val apiCalManager: IApiCallManager) :
4453
AppStartActivityViewModel() {
4554
private var _hapticFeedback = MutableStateFlow(preferencesHelper.isHapticFeedbackEnabled)
4655
override val hapticFeedback: StateFlow<Boolean> = _hapticFeedback
56+
private val logger = LoggerFactory.getLogger("ui")
4757

4858
private val trayPreferenceChangeListener = OnTrayPreferenceChangeListener {
4959
_hapticFeedback.value = preferencesHelper.isHapticFeedbackEnabled
5060
}
5161

5262
init {
5363
preferencesHelper.addObserver(trayPreferenceChangeListener)
64+
recordInstall()
5465
}
5566

67+
private fun recordInstall() {
68+
viewModelScope.launch {
69+
if (preferencesHelper.isNewApplicationInstance) {
70+
preferencesHelper.isNewApplicationInstance = false
71+
val installation = preferencesHelper.getResponseString(PreferencesKeyConstants.NEW_INSTALLATION)
72+
if (PreferencesKeyConstants.I_NEW == installation) {
73+
preferencesHelper.saveResponseStringData(PreferencesKeyConstants.NEW_INSTALLATION, PreferencesKeyConstants.I_OLD)
74+
val result = apiCalManager.recordAppInstall().result<String?>()
75+
when(result) {
76+
is CallResult.Success -> {
77+
logger.info("App install recorded successfully.")
78+
}
79+
is CallResult.Error -> {
80+
logger.error("Failed to record app install ${result.errorMessage}")
81+
}
82+
}
83+
}
84+
}
85+
}
86+
}
5687
override fun setConnectionCallback(
5788
protocolInformationList: List<ProtocolInformation>,
5889
autoConnectionModeCallback: AutoConnectionModeCallback,

mobile/src/main/java/com/windscribe/mobile/ui/common/CaptchaDialog.kt

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,26 @@ fun CaptchaDebugView(
211211
0f,
212212
backgroundSize.value.height - scaledSliderHeight.toFloat()
213213
)
214-
dragHistory.add(Pair(newX, newY - (initialY.floatValue * scaleFactor)))
214+
val newPoint = Pair(newX, newY - (initialY.floatValue * scaleFactor))
215+
216+
// Only add point if it's at least 0.5 pixels away from the last recorded point
217+
val shouldRecord = if (dragHistory.isEmpty()) {
218+
true
219+
} else {
220+
val lastPoint = dragHistory.last()
221+
val distance = kotlin.math.sqrt(
222+
(newPoint.first - lastPoint.first) * (newPoint.first - lastPoint.first) +
223+
(newPoint.second - lastPoint.second) * (newPoint.second - lastPoint.second)
224+
)
225+
distance >= 0.5f
226+
}
227+
228+
if (shouldRecord) {
229+
dragHistory.add(newPoint)
230+
if (dragHistory.size > 50) {
231+
dragHistory.removeAt(0)
232+
}
233+
}
215234
sliderPositionX.floatValue = newX
216235
sliderPositionY.floatValue = newY
217236
dragJob?.cancel()

tv/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ android {
2727
applicationId rootProject.AppId
2828
minSdkVersion rootProject.appMinSdk
2929
targetSdkVersion rootProject.appTargetSdk
30-
versionName System.getenv().getOrDefault("VERSION_NAME", "3.90")
31-
versionCode 1738
30+
versionName System.getenv().getOrDefault("VERSION_NAME", "3.91")
31+
versionCode 1770
3232
vectorDrawables.useSupportLibrary = true
3333

3434
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

0 commit comments

Comments
 (0)