From 5469051bbd74aa4afd0f4c8e974f79d4ec8a7e6f Mon Sep 17 00:00:00 2001 From: Kamo Spertsyan Date: Fri, 13 Sep 2024 17:52:22 +0300 Subject: [PATCH 1/5] The `setNotificationsToken` and `handleNotification` methods were marked as deprecated. --- .../sdk/internal/OutagerIntegrationTest.kt | 28 --- .../QonversionRepositoryIntegrationTest.kt | 28 --- .../android/sdk/automations/Automations.kt | 2 + .../internal/AutomationsInternal.kt | 4 +- .../internal/QAutomationsManager.kt | 55 ----- .../android/sdk/internal/Constants.kt | 2 - .../sdk/internal/QonversionInternal.kt | 4 +- .../android/sdk/internal/api/Api.kt | 3 - .../sdk/internal/di/module/ManagersModule.kt | 4 - .../internal/repository/DefaultRepository.kt | 22 -- .../sdk/internal/repository/QRepository.kt | 2 - .../repository/RepositoryWithRateLimits.kt | 4 - .../internal/QAutomationsManagerTest.kt | 218 ------------------ 13 files changed, 6 insertions(+), 370 deletions(-) diff --git a/sdk/src/androidTest/java/com/qonversion/android/sdk/internal/OutagerIntegrationTest.kt b/sdk/src/androidTest/java/com/qonversion/android/sdk/internal/OutagerIntegrationTest.kt index 6040f9042..574cc5afe 100644 --- a/sdk/src/androidTest/java/com/qonversion/android/sdk/internal/OutagerIntegrationTest.kt +++ b/sdk/src/androidTest/java/com/qonversion/android/sdk/internal/OutagerIntegrationTest.kt @@ -422,34 +422,6 @@ internal class OutagerIntegrationTest { signal.await() } - @Test - fun sendPushToken() { - // given - val signal = CountDownLatch(1) - - val token = "dt70kovLQdKymNnhIY6I94:APA91bGfg6m108VFio2ZdgLR6U0B2PtqAn0hIPVU7M4jKklkMxqDUrjoThpX_K60M7CfH8IVZqtku31ei2hmjdJZDfm-bdAl7uxLDWFU8yVcA6-3wBMn3nsYmUrhYWom-qgGC7yIUYzR" - - val uid = UID_PREFIX + "_sendPushToken" - val repository = initRepository(uid) - - // when - withNewUserCreated(repository) { error -> - error?.let { - fail("Failed to create user") - } - - repository.sendPushToken(token) - } - - // then - // check that nothing critical happens - Handler(Looper.getMainLooper()).postDelayed( - { signal.countDown() }, - 1000 - ) - signal.await() - } - @Test fun screens() { // given diff --git a/sdk/src/androidTest/java/com/qonversion/android/sdk/internal/QonversionRepositoryIntegrationTest.kt b/sdk/src/androidTest/java/com/qonversion/android/sdk/internal/QonversionRepositoryIntegrationTest.kt index 3fd282b79..6d995e82e 100644 --- a/sdk/src/androidTest/java/com/qonversion/android/sdk/internal/QonversionRepositoryIntegrationTest.kt +++ b/sdk/src/androidTest/java/com/qonversion/android/sdk/internal/QonversionRepositoryIntegrationTest.kt @@ -677,34 +677,6 @@ internal class QonversionRepositoryIntegrationTest { signal.await() } - @Test - fun sendPushToken() { - // given - val signal = CountDownLatch(1) - - val token = "dt70kovLQdKymNnhIY6I94:APA91bGfg6m108VFio2ZdgLR6U0B2PtqAn0hIPVU7M4jKklkMxqDUrjoThpX_K60M7CfH8IVZqtku31ei2hmjdJZDfm-bdAl7uxLDWFU8yVcA6-3wBMn3nsYmUrhYWom-qgGC7yIUYzR" - - val uid = UID_PREFIX + "_sendPushToken" - val repository = initRepository(uid) - - // when - withNewUserCreated(repository) { error -> - error?.let { - fail("Failed to create user") - } - - repository.sendPushToken(token) - } - - // then - // check that nothing critical happens - Handler(Looper.getMainLooper()).postDelayed( - { signal.countDown() }, - 1000 - ) - signal.await() - } - @Test fun screens() { // given diff --git a/sdk/src/main/java/com/qonversion/android/sdk/automations/Automations.kt b/sdk/src/main/java/com/qonversion/android/sdk/automations/Automations.kt index 2b0a2232f..9861d825b 100644 --- a/sdk/src/main/java/com/qonversion/android/sdk/automations/Automations.kt +++ b/sdk/src/main/java/com/qonversion/android/sdk/automations/Automations.kt @@ -63,6 +63,7 @@ interface Automations { /** * Set push token to Qonversion to enable Qonversion push notifications */ + @Deprecated("Consider removing this method as it isn't needed anymore") fun setNotificationsToken(token: String) /** @@ -71,6 +72,7 @@ interface Automations { * @return true when a push notification was received from Qonversion. * Otherwise returns false, so you need to handle a notification yourself. */ + @Deprecated("Consider removing this method. Qonversion is not working with push notifications anymore") fun handleNotification(messageData: Map): Boolean /** diff --git a/sdk/src/main/java/com/qonversion/android/sdk/automations/internal/AutomationsInternal.kt b/sdk/src/main/java/com/qonversion/android/sdk/automations/internal/AutomationsInternal.kt index f5b8ed2d6..f6e6cf5a3 100644 --- a/sdk/src/main/java/com/qonversion/android/sdk/automations/internal/AutomationsInternal.kt +++ b/sdk/src/main/java/com/qonversion/android/sdk/automations/internal/AutomationsInternal.kt @@ -23,10 +23,12 @@ internal class AutomationsInternal : Automations { automationsManager.loadScreen(withID, callback) } + @Deprecated("Consider removing this method as it isn't needed anymore") override fun setNotificationsToken(token: String) { - automationsManager.setPushToken(token) + } + @Deprecated("Consider removing this method. Qonversion is not working with push notifications anymore") override fun handleNotification(messageData: Map): Boolean { return automationsManager.handlePushIfPossible(messageData) } diff --git a/sdk/src/main/java/com/qonversion/android/sdk/automations/internal/QAutomationsManager.kt b/sdk/src/main/java/com/qonversion/android/sdk/automations/internal/QAutomationsManager.kt index 58fcd31af..7cffbcc07 100644 --- a/sdk/src/main/java/com/qonversion/android/sdk/automations/internal/QAutomationsManager.kt +++ b/sdk/src/main/java/com/qonversion/android/sdk/automations/internal/QAutomationsManager.kt @@ -4,13 +4,10 @@ import android.app.Activity import android.app.Application import android.content.Context import android.content.Intent.FLAG_ACTIVITY_NEW_TASK -import android.content.SharedPreferences import com.qonversion.android.sdk.automations.AutomationsDelegate import com.qonversion.android.sdk.automations.ScreenCustomizationDelegate import com.qonversion.android.sdk.automations.dto.QActionResult import com.qonversion.android.sdk.automations.dto.QScreenPresentationConfig -import com.qonversion.android.sdk.internal.Constants.PENDING_PUSH_TOKEN_KEY -import com.qonversion.android.sdk.internal.Constants.PUSH_TOKEN_KEY import com.qonversion.android.sdk.dto.QonversionError import com.qonversion.android.sdk.dto.QonversionErrorCode import com.qonversion.android.sdk.internal.repository.QRepository @@ -18,7 +15,6 @@ import com.qonversion.android.sdk.listeners.QonversionShowScreenCallback import com.qonversion.android.sdk.internal.toBoolean import com.qonversion.android.sdk.internal.logger.ConsoleLogger import com.qonversion.android.sdk.automations.mvp.ScreenActivity -import com.qonversion.android.sdk.internal.provider.AppStateProvider import com.qonversion.android.sdk.internal.toMap import java.lang.Exception import java.lang.ref.WeakReference @@ -28,11 +24,9 @@ import org.json.JSONObject internal class QAutomationsManager @Inject constructor( private val repository: QRepository, - private val preferences: SharedPreferences, private val eventMapper: AutomationsEventMapper, private val appContext: Application, private val activityProvider: ActivityProvider, - private val appStateProvider: AppStateProvider ) { @Volatile var automationsDelegate: WeakReference? = null @@ -45,14 +39,6 @@ internal class QAutomationsManager @Inject constructor( @Synchronized get private val logger = ConsoleLogger() - private var pendingToken: String? = null - internal var isLaunchFinished = false - - fun onAppForeground() { - pendingToken?.let { - sendPushToken(it) - } - } fun handlePushIfPossible(messageData: Map): Boolean { val pickScreen = messageData[PICK_SCREEN] @@ -86,32 +72,6 @@ internal class QAutomationsManager @Inject constructor( } } - fun setPushToken(token: String) { - val oldToken = loadToken() - if (token.isEmpty() || oldToken.equals(token)) { - return - } - - savePendingTokenToPref(token) - if (!isLaunchFinished || appStateProvider.appState.isBackground()) { - pendingToken = token - } else { - sendPushToken(token) - } - } - - private fun processPushToken() { - val token = getPendingToken() - if (!token.isNullOrEmpty()) { - sendPushToken(token) - } - } - - internal fun onLaunchProcessed() { - isLaunchFinished = true - processPushToken() - } - fun loadScreen(screenId: String, callback: QonversionShowScreenCallback? = null) { repository.screens(screenId, { screen -> @@ -218,21 +178,6 @@ internal class QAutomationsManager @Inject constructor( ) } - private fun sendPushToken(token: String) { - repository.sendPushToken(token) - - pendingToken = null - } - - private fun getPendingToken(): String? { - return preferences.getString(PENDING_PUSH_TOKEN_KEY, null) - } - - private fun savePendingTokenToPref(token: String) = - preferences.edit().putString(PENDING_PUSH_TOKEN_KEY, token).apply() - - private fun loadToken() = preferences.getString(PUSH_TOKEN_KEY, "") - companion object { private const val PICK_SCREEN = "qonv.pick_screen" private const val KEY_CUSTOM_PAYLOAD = "qonv.custom_payload" diff --git a/sdk/src/main/java/com/qonversion/android/sdk/internal/Constants.kt b/sdk/src/main/java/com/qonversion/android/sdk/internal/Constants.kt index 2ed1c5a16..79015f0b9 100644 --- a/sdk/src/main/java/com/qonversion/android/sdk/internal/Constants.kt +++ b/sdk/src/main/java/com/qonversion/android/sdk/internal/Constants.kt @@ -5,8 +5,6 @@ internal object Constants { const val PREFS_ORIGINAL_USER_ID_KEY = "$PREFS_PREFIX.originalUserID" const val PREFS_QONVERSION_USER_ID_KEY = "$PREFS_PREFIX.storedUserID" const val PREFS_PARTNER_IDENTITY_ID_KEY = "$PREFS_PREFIX.partnerIdentityUserID" - const val PUSH_TOKEN_KEY = "$PREFS_PREFIX.push_token_key" - const val PENDING_PUSH_TOKEN_KEY = "$PREFS_PREFIX.pending_push_token_key" const val USER_ID_PREFIX = "QON" const val USER_ID_SEPARATOR = "_" const val IS_HISTORICAL_DATA_SYNCED = "$PREFS_PREFIX.is_historical_data_synced" diff --git a/sdk/src/main/java/com/qonversion/android/sdk/internal/QonversionInternal.kt b/sdk/src/main/java/com/qonversion/android/sdk/internal/QonversionInternal.kt index f0b6b97d5..9d7986f47 100644 --- a/sdk/src/main/java/com/qonversion/android/sdk/internal/QonversionInternal.kt +++ b/sdk/src/main/java/com/qonversion/android/sdk/internal/QonversionInternal.kt @@ -128,14 +128,12 @@ internal class QonversionInternal( userPropertiesManager.onAppForeground() productCenterManager.onAppForeground() - automationsManager.onAppForeground() attributionManager.onAppForeground() } private fun launch() { productCenterManager.launch(object : QonversionLaunchCallback { - override fun onSuccess(launchResult: QLaunchResult) = - postToMainThread { automationsManager.onLaunchProcessed() } + override fun onSuccess(launchResult: QLaunchResult) {} override fun onError(error: QonversionError) {} }) diff --git a/sdk/src/main/java/com/qonversion/android/sdk/internal/api/Api.kt b/sdk/src/main/java/com/qonversion/android/sdk/internal/api/Api.kt index 7588bb0fa..219d4e865 100644 --- a/sdk/src/main/java/com/qonversion/android/sdk/internal/api/Api.kt +++ b/sdk/src/main/java/com/qonversion/android/sdk/internal/api/Api.kt @@ -39,9 +39,6 @@ internal interface Api { @POST("v1/user/init") fun init(@Body request: InitRequest): Call> - @POST("v1/user/push-token") - fun sendPushToken(@Body request: SendPushTokenRequest): Call - @POST("v1/user/purchase") fun purchase(@Body request: PurchaseRequest): Call> diff --git a/sdk/src/main/java/com/qonversion/android/sdk/internal/di/module/ManagersModule.kt b/sdk/src/main/java/com/qonversion/android/sdk/internal/di/module/ManagersModule.kt index 64ded192d..16c207e04 100644 --- a/sdk/src/main/java/com/qonversion/android/sdk/internal/di/module/ManagersModule.kt +++ b/sdk/src/main/java/com/qonversion/android/sdk/internal/di/module/ManagersModule.kt @@ -26,19 +26,15 @@ internal class ManagersModule { @Provides fun provideAutomationsManager( repository: QRepository, - preferences: SharedPreferences, eventMapper: AutomationsEventMapper, appContext: Application, activityProvider: ActivityProvider, - appStateProvider: AppStateProvider ): QAutomationsManager { return QAutomationsManager( repository, - preferences, eventMapper, appContext, activityProvider, - appStateProvider ) } diff --git a/sdk/src/main/java/com/qonversion/android/sdk/internal/repository/DefaultRepository.kt b/sdk/src/main/java/com/qonversion/android/sdk/internal/repository/DefaultRepository.kt index eda39d74c..ec2cc1fe9 100644 --- a/sdk/src/main/java/com/qonversion/android/sdk/internal/repository/DefaultRepository.kt +++ b/sdk/src/main/java/com/qonversion/android/sdk/internal/repository/DefaultRepository.kt @@ -8,8 +8,6 @@ import com.qonversion.android.sdk.listeners.QonversionEligibilityCallback import com.qonversion.android.sdk.dto.QonversionError import com.qonversion.android.sdk.dto.QonversionErrorCode import com.qonversion.android.sdk.listeners.QonversionLaunchCallback -import com.qonversion.android.sdk.internal.Constants.PENDING_PUSH_TOKEN_KEY -import com.qonversion.android.sdk.internal.Constants.PUSH_TOKEN_KEY import com.qonversion.android.sdk.internal.EnvironmentProvider import com.qonversion.android.sdk.internal.IncrementalDelayCalculator import com.qonversion.android.sdk.internal.InternalConfig @@ -27,7 +25,6 @@ import com.qonversion.android.sdk.internal.dto.purchase.History import com.qonversion.android.sdk.internal.dto.purchase.Inapp import com.qonversion.android.sdk.internal.dto.purchase.PurchaseDetails import com.qonversion.android.sdk.internal.dto.request.AttachUserRequest -import com.qonversion.android.sdk.internal.dto.request.SendPushTokenRequest import com.qonversion.android.sdk.internal.dto.request.AttributionRequest import com.qonversion.android.sdk.internal.dto.request.CrashRequest import com.qonversion.android.sdk.internal.dto.request.EligibilityRequest @@ -386,10 +383,6 @@ internal class DefaultRepository internal constructor( } } - override fun sendPushToken(token: String) { - sendPushTokenRequest(token) - } - override fun screens( screenId: String, onSuccess: (screen: Screen) -> Unit, @@ -660,21 +653,6 @@ internal class DefaultRepository internal constructor( } } - private fun sendPushTokenRequest(token: String) { - val device = environmentProvider.getInfo() - val request = SendPushTokenRequest(key, uid, device.deviceId, token) - - api.sendPushToken(request).enqueue { - onResponse = { - preferences.edit().remove(PENDING_PUSH_TOKEN_KEY).apply() - preferences.edit().putString(PUSH_TOKEN_KEY, token).apply() - } - onFailure = { - logger.error("sendPushTokenRequest - failure - ${it.toQonversionError()}") - } - } - } - private fun initRequest( purchases: List? = null, callback: QonversionLaunchCallback? = null diff --git a/sdk/src/main/java/com/qonversion/android/sdk/internal/repository/QRepository.kt b/sdk/src/main/java/com/qonversion/android/sdk/internal/repository/QRepository.kt index 10aa90cc9..642715c41 100644 --- a/sdk/src/main/java/com/qonversion/android/sdk/internal/repository/QRepository.kt +++ b/sdk/src/main/java/com/qonversion/android/sdk/internal/repository/QRepository.kt @@ -95,8 +95,6 @@ internal interface QRepository { onError: (error: QonversionError) -> Unit ) - fun sendPushToken(token: String) - fun screens( screenId: String, onSuccess: (screen: Screen) -> Unit, diff --git a/sdk/src/main/java/com/qonversion/android/sdk/internal/repository/RepositoryWithRateLimits.kt b/sdk/src/main/java/com/qonversion/android/sdk/internal/repository/RepositoryWithRateLimits.kt index f106a7612..70f99e50a 100644 --- a/sdk/src/main/java/com/qonversion/android/sdk/internal/repository/RepositoryWithRateLimits.kt +++ b/sdk/src/main/java/com/qonversion/android/sdk/internal/repository/RepositoryWithRateLimits.kt @@ -214,10 +214,6 @@ internal class RepositoryWithRateLimits( } } - override fun sendPushToken(token: String) { - repository.sendPushToken(token) - } - override fun screens( screenId: String, onSuccess: (screen: Screen) -> Unit, diff --git a/sdk/src/test/java/com/qonversion/android/sdk/automations/internal/QAutomationsManagerTest.kt b/sdk/src/test/java/com/qonversion/android/sdk/automations/internal/QAutomationsManagerTest.kt index 43f40e452..92b831c54 100644 --- a/sdk/src/test/java/com/qonversion/android/sdk/automations/internal/QAutomationsManagerTest.kt +++ b/sdk/src/test/java/com/qonversion/android/sdk/automations/internal/QAutomationsManagerTest.kt @@ -31,19 +31,13 @@ import java.lang.ref.WeakReference internal class QAutomationsManagerTest { private val mockRepository: QRepository = mockk(relaxed = true) private val mockActivity: Activity = mockk(relaxed = true) - private val mockPrefs: SharedPreferences = mockk(relaxed = true) - private val mockEditor: SharedPreferences.Editor = mockk(relaxed = true) private val mockEventMapper: AutomationsEventMapper = mockk(relaxed = true) private val mockApplication: Application = mockk(relaxed = true) private val mockActivityProvider: ActivityProvider = mockk(relaxed = true) - private val mockAppStateProvider: AppStateProvider = mockk(relaxed = true) private lateinit var mockIntent: Intent private lateinit var automationsManager: QAutomationsManager - private val fieldPendingToken = "pendingToken" - private val pushTokenKey = "com.qonversion.keys.push_token_key" - private val pendingPushTokenKey = "com.qonversion.keys.pending_push_token_key" private val screenId = "ZNkQaNy6" private val html = "Screen 2 Content" private val delegate = object : AutomationsDelegate { @@ -64,7 +58,6 @@ internal class QAutomationsManagerTest { mockLogger() mockIntent() - mockSharedPreferences() every { mockActivityProvider.getCurrentActivity() } answers { mockActivity @@ -72,11 +65,9 @@ internal class QAutomationsManagerTest { automationsManager = QAutomationsManager( mockRepository, - mockPrefs, mockEventMapper, mockApplication, mockActivityProvider, - mockAppStateProvider ) } @@ -270,197 +261,6 @@ internal class QAutomationsManagerTest { } - @Nested - inner class SetPushToken { - @Test - fun `should send new token when app is in foreground`() { - // given - val newToken = "newToken" - every { - mockPrefs.getString(pushTokenKey, "") - } returns null - - mockLooper() - every { mockAppStateProvider.appState } returns AppState.Foreground - automationsManager.isLaunchFinished = true - - // when - automationsManager.setPushToken(newToken) - - // then - verifySequence { - mockPrefs.getString(pushTokenKey, "") - mockPrefs.edit() - mockEditor.putString(pendingPushTokenKey, newToken) - mockEditor.apply() - mockRepository.sendPushToken(newToken) - } - } - - @Test - fun `should send new token when launch is processed`() { - // given - val newToken = "newToken" - every { - mockPrefs.getString(pendingPushTokenKey, null) - } returns newToken - - mockLooper() - - // when - automationsManager.onLaunchProcessed() - - // then - verifySequence { - mockPrefs.getString(pendingPushTokenKey, null) - mockRepository.sendPushToken(newToken) - } - } - - @Test - fun `shouldn't send new token when app is in background`() { - // given - val newToken = "newToken" - every { - mockPrefs.getString(pushTokenKey, "") - } returns null - - mockLooper() - every { mockAppStateProvider.appState } returns AppState.Background - automationsManager.isLaunchFinished = true - - // when - automationsManager.setPushToken(newToken) - - // then - val pendingToken = automationsManager.getPrivateField(fieldPendingToken) - assertThat(pendingToken).isEqualTo(newToken) - - verify(exactly = 1) { - mockPrefs.getString(pushTokenKey, "") - mockEditor.putString(pendingPushTokenKey, newToken) - mockEditor.apply() - } - verify(exactly = 0) { - mockRepository.sendPushToken(newToken) - } - } - - @Test - fun `shouldn't send a token when launch is not finished`() { - val token = "someToken" - every { - mockPrefs.getString(pushTokenKey, "") - } returns "another token" - - // when - automationsManager.setPushToken(token) - - // then - val pendingToken = automationsManager.getPrivateField(fieldPendingToken) - assertThat(pendingToken).isEqualTo(token) - verify(exactly = 1) { - mockPrefs.getString(pushTokenKey, "") - mockEditor.putString(pendingPushTokenKey, token) - } - verify { - listOf( - mockRepository - ) wasNot Called - } - } - - @Test - fun `shouldn't send an old token`() { - val oldToken = "oldToken" - every { - mockPrefs.getString(pushTokenKey, "") - } returns oldToken - automationsManager.isLaunchFinished = true - - // when - automationsManager.setPushToken(oldToken) - - // then - verify(exactly = 1) { - mockPrefs.getString(pushTokenKey, "") - } - verify { - listOf( - mockEditor, - mockRepository - ) wasNot Called - } - } - - - @Test - fun `shouldn't send token when it is empty`() { - // given - val newToken = "" - every { - mockPrefs.getString(pushTokenKey, "") - } returns null - - mockLooper() - every { mockAppStateProvider.appState } returns AppState.Foreground - automationsManager.isLaunchFinished = true - - // when - automationsManager.setPushToken(newToken) - - // then - verify(exactly = 1) { - mockPrefs.getString(pushTokenKey, "") - } - verify { - listOf( - mockEditor, - mockRepository - ) wasNot Called - } - } - } - - @Nested - inner class OnAppForeground { - @Test - fun `should send new pending token after app switched to foreground`() { - // given - val newToken = "newToken" - automationsManager.mockPrivateField(fieldPendingToken, newToken) - - // when - automationsManager.onAppForeground() - - // then - val pendingToken = automationsManager.getPrivateField(fieldPendingToken) - assertThat(pendingToken).isNull() - - verifyOrder { - mockRepository.sendPushToken(newToken) - } - } - - @Test - fun `should not send null pending token after app switched to foreground`() { - // given - val nullToken = null - automationsManager.mockPrivateField(fieldPendingToken, nullToken) - - // when - automationsManager.onAppForeground() - - // then - val pendingToken = automationsManager.getPrivateField(fieldPendingToken) - assertThat(pendingToken).isNull() - - verify { - listOf(mockRepository, mockEditor) wasNot called - } - } - } - private fun getQueryParams(): Map { val queryParamTypeKey = "type" val queryParamActiveKey = "active" @@ -477,24 +277,6 @@ internal class QAutomationsManagerTest { } } - private fun mockSharedPreferences() { - every { - mockEditor.putString(pushTokenKey, any()) - } returns mockEditor - - every { - mockEditor.putString(pendingPushTokenKey, any()) - } returns mockEditor - - every { - mockPrefs.edit() - } returns mockEditor - - every { - mockEditor.apply() - } just runs - } - private fun mockIntent() { mockkConstructor(Intent::class) mockIntent = Intent(mockActivity, ScreenActivity::class.java) From efef34e4000dcb3edcf1a7e72036fda7797ff1d7 Mon Sep 17 00:00:00 2001 From: Kamo Spertsyan Date: Fri, 13 Sep 2024 18:11:37 +0300 Subject: [PATCH 2/5] Detekt fixes --- .../main/java/com/qonversion/android/sdk/internal/api/Api.kt | 1 - .../android/sdk/internal/di/module/ManagersModule.kt | 1 - .../android/sdk/internal/di/module/RepositoryModule.kt | 4 ---- .../android/sdk/internal/repository/DefaultRepository.kt | 1 - 4 files changed, 7 deletions(-) diff --git a/sdk/src/main/java/com/qonversion/android/sdk/internal/api/Api.kt b/sdk/src/main/java/com/qonversion/android/sdk/internal/api/Api.kt index 219d4e865..c7d0327a6 100644 --- a/sdk/src/main/java/com/qonversion/android/sdk/internal/api/Api.kt +++ b/sdk/src/main/java/com/qonversion/android/sdk/internal/api/Api.kt @@ -12,7 +12,6 @@ import com.qonversion.android.sdk.internal.dto.Data import com.qonversion.android.sdk.internal.dto.QLaunchResult import com.qonversion.android.sdk.internal.dto.Response import com.qonversion.android.sdk.internal.dto.SendPropertiesResult -import com.qonversion.android.sdk.internal.dto.request.SendPushTokenRequest import com.qonversion.android.sdk.internal.dto.request.AttachUserRequest import com.qonversion.android.sdk.internal.dto.request.AttributionRequest import com.qonversion.android.sdk.internal.dto.request.CrashRequest diff --git a/sdk/src/main/java/com/qonversion/android/sdk/internal/di/module/ManagersModule.kt b/sdk/src/main/java/com/qonversion/android/sdk/internal/di/module/ManagersModule.kt index 16c207e04..5f74aa5e8 100644 --- a/sdk/src/main/java/com/qonversion/android/sdk/internal/di/module/ManagersModule.kt +++ b/sdk/src/main/java/com/qonversion/android/sdk/internal/di/module/ManagersModule.kt @@ -1,7 +1,6 @@ package com.qonversion.android.sdk.internal.di.module import android.app.Application -import android.content.SharedPreferences import com.qonversion.android.sdk.automations.internal.ActivityProvider import com.qonversion.android.sdk.internal.IncrementalDelayCalculator import com.qonversion.android.sdk.internal.QIdentityManager diff --git a/sdk/src/main/java/com/qonversion/android/sdk/internal/di/module/RepositoryModule.kt b/sdk/src/main/java/com/qonversion/android/sdk/internal/di/module/RepositoryModule.kt index 22b78bc17..24965fb5c 100644 --- a/sdk/src/main/java/com/qonversion/android/sdk/internal/di/module/RepositoryModule.kt +++ b/sdk/src/main/java/com/qonversion/android/sdk/internal/di/module/RepositoryModule.kt @@ -34,7 +34,6 @@ internal class RepositoryModule { config: InternalConfig, logger: Logger, apiErrorMapper: ApiErrorMapper, - sharedPreferences: SharedPreferences, delayCalculator: IncrementalDelayCalculator, rateLimiter: RateLimiter ): QRepository { @@ -45,7 +44,6 @@ internal class RepositoryModule { config, logger, apiErrorMapper, - sharedPreferences, delayCalculator ), rateLimiter @@ -60,7 +58,6 @@ internal class RepositoryModule { config: InternalConfig, logger: Logger, apiErrorMapper: ApiErrorMapper, - sharedPreferences: SharedPreferences, delayCalculator: IncrementalDelayCalculator ): DefaultRepository { return DefaultRepository( @@ -69,7 +66,6 @@ internal class RepositoryModule { config, logger, apiErrorMapper, - sharedPreferences, delayCalculator ) } diff --git a/sdk/src/main/java/com/qonversion/android/sdk/internal/repository/DefaultRepository.kt b/sdk/src/main/java/com/qonversion/android/sdk/internal/repository/DefaultRepository.kt index ec2cc1fe9..05a6fb238 100644 --- a/sdk/src/main/java/com/qonversion/android/sdk/internal/repository/DefaultRepository.kt +++ b/sdk/src/main/java/com/qonversion/android/sdk/internal/repository/DefaultRepository.kt @@ -61,7 +61,6 @@ internal class DefaultRepository internal constructor( private val config: InternalConfig, private val logger: Logger, private val errorMapper: ApiErrorMapper, - private val preferences: SharedPreferences, private val delayCalculator: IncrementalDelayCalculator ) : QRepository { private var advertisingId: String? = null From a37fbbeb5973964f73a3a53add3babe20273f238 Mon Sep 17 00:00:00 2001 From: Surik Date: Fri, 13 Sep 2024 21:29:30 +0400 Subject: [PATCH 3/5] Updated comment for purchase options --- .../java/com/qonversion/android/sdk/dto/QPurchaseOptions.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk/src/main/java/com/qonversion/android/sdk/dto/QPurchaseOptions.kt b/sdk/src/main/java/com/qonversion/android/sdk/dto/QPurchaseOptions.kt index efcfed96f..e7e3b927b 100644 --- a/sdk/src/main/java/com/qonversion/android/sdk/dto/QPurchaseOptions.kt +++ b/sdk/src/main/java/com/qonversion/android/sdk/dto/QPurchaseOptions.kt @@ -42,7 +42,8 @@ class QPurchaseOptions internal constructor ( } /** - * Set context keys associated with a purchase. + * Set Qonversion product from which the upgrade/downgrade + * will be initialized. * * @param oldProduct Qonversion product from which the upgrade/downgrade * will be initialized. From 5fd8c9a8b7f79833bf063592b77087c663ac2640 Mon Sep 17 00:00:00 2001 From: Surik Date: Fri, 13 Sep 2024 21:32:42 +0400 Subject: [PATCH 4/5] Fixed warnings --- config/detekt/baseline.xml | 28 +++++++++---------- .../internal/AutomationsInternal.kt | 1 - .../internal/repository/DefaultRepository.kt | 1 - 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/config/detekt/baseline.xml b/config/detekt/baseline.xml index dc412a278..a4a0a4291 100644 --- a/config/detekt/baseline.xml +++ b/config/detekt/baseline.xml @@ -8,6 +8,7 @@ ConstructorParameterNaming:Environment.kt$Environment$@Json(name = "app_version") val app_version: String EmptyCatchBlock:AdvertisingProvider.kt$AdvertisingProvider.AdvertisingConnection${ } EmptyFunctionBlock:AdvertisingProvider.kt$AdvertisingProvider.AdvertisingConnection${} + EmptyFunctionBlock:AutomationsInternal.kt$AutomationsInternal${ } EmptyFunctionBlock:QAutomationsManagerTest.kt$QAutomationsManagerTest.<no name provided>${} EmptyFunctionBlock:QIdentityManagerTest.kt$QIdentityManagerTest.Identify.<no name provided>${} EmptyFunctionBlock:QProductCenterManager.kt$QProductCenterManager.<no name provided>${} @@ -32,11 +33,10 @@ LargeClass:QProductCenterManager.kt$QProductCenterManager : PurchasesListenerUserStateProvider LongParameterList:IBillingClientWrapper.kt$IBillingClientWrapper$( activity: Activity, product: QProduct, offerId: String?, applyOffer: Boolean? = true, updatePurchaseInfo: UpdatePurchaseInfo?, onFailed: (error: BillingError) -> Unit ) LongParameterList:ManagersModule.kt$ManagersModule$( appContext: Application, repository: QRepository, propertiesStorage: UserPropertiesStorage, incrementalDelayCalculator: IncrementalDelayCalculator, appStateProvider: AppStateProvider, logger: Logger ) - LongParameterList:ManagersModule.kt$ManagersModule$( repository: QRepository, preferences: SharedPreferences, eventMapper: AutomationsEventMapper, appContext: Application, activityProvider: ActivityProvider, appStateProvider: AppStateProvider ) LongParameterList:QonversionBillingService.kt$QonversionBillingService$( activity: Activity, product: QProduct, offerId: String?, applyOffer: Boolean?, oldProduct: QProduct, updatePolicy: QPurchaseUpdatePolicy? ) LongParameterList:QonversionBillingService.kt$QonversionBillingService$( private val mainHandler: Handler, private val purchasesListener: PurchasesListener, private val logger: Logger, private val isAnalyticsMode: Boolean, private val billingClientHolder: BillingClientHolder, private val billingClientWrapper: BillingClientWrapper, private val legacyBillingClientWrapper: LegacyBillingClientWrapper ) - LongParameterList:RepositoryModule.kt$RepositoryModule$( retrofit: Retrofit, environmentProvider: EnvironmentProvider, config: InternalConfig, logger: Logger, apiErrorMapper: ApiErrorMapper, sharedPreferences: SharedPreferences, delayCalculator: IncrementalDelayCalculator ) - LongParameterList:RepositoryModule.kt$RepositoryModule$( retrofit: Retrofit, environmentProvider: EnvironmentProvider, config: InternalConfig, logger: Logger, apiErrorMapper: ApiErrorMapper, sharedPreferences: SharedPreferences, delayCalculator: IncrementalDelayCalculator, rateLimiter: RateLimiter ) + LongParameterList:RepositoryModule.kt$RepositoryModule$( retrofit: Retrofit, environmentProvider: EnvironmentProvider, config: InternalConfig, logger: Logger, apiErrorMapper: ApiErrorMapper, delayCalculator: IncrementalDelayCalculator ) + LongParameterList:RepositoryModule.kt$RepositoryModule$( retrofit: Retrofit, environmentProvider: EnvironmentProvider, config: InternalConfig, logger: Logger, apiErrorMapper: ApiErrorMapper, delayCalculator: IncrementalDelayCalculator, rateLimiter: RateLimiter ) MagicNumber:ApiErrorMapper.kt$ApiErrorMapper$10002 MagicNumber:ApiErrorMapper.kt$ApiErrorMapper$10003 MagicNumber:ApiErrorMapper.kt$ApiErrorMapper$10004 @@ -93,7 +93,6 @@ MaxLineLength:LaunchResultCacheWrapperTest.kt$LaunchResultCacheWrapperTest$cacheWrapper = LaunchResultCacheWrapper(mockMoshi, mockPrefsCache, mockCacheConfigProvider, mockQFallbacksService) MaxLineLength:OutagerIntegrationTest.kt$OutagerIntegrationTest$"lgeigljfpmeoddkcebkcepjc.AO-J1Oy305qZj99jXTPEVBN8UZGoYAtjDLj4uTjRQvUFaG0vie-nr6VBlN0qnNDMU8eJR-sI7o3CwQyMOEHKl8eJsoQ86KSFzxKBR07PSpHLI_o7agXhNKY" MaxLineLength:OutagerIntegrationTest.kt$OutagerIntegrationTest$purchaseToken = "lgeigljfpmeoddkcebkcepjc.AO-J1Oy305qZj99jXTPEVBN8UZGoYAtjDLj4uTjRQvUFaG0vie-nr6VBlN0qnNDMU8eJR-sI7o3CwQyMOEHKl8eJsoQ86KSFzxKBR07PSpHLI_o7agXhNKY" - MaxLineLength:OutagerIntegrationTest.kt$OutagerIntegrationTest$val token = "dt70kovLQdKymNnhIY6I94:APA91bGfg6m108VFio2ZdgLR6U0B2PtqAn0hIPVU7M4jKklkMxqDUrjoThpX_K60M7CfH8IVZqtku31ei2hmjdJZDfm-bdAl7uxLDWFU8yVcA6-3wBMn3nsYmUrhYWom-qgGC7yIUYzR" MaxLineLength:OutagerIntegrationTest.kt$OutagerIntegrationTest.<no name provided>$assertEquals(error.additionalMessage, """HTTP status code=503, data={"message":"Service Unavailable","code":0,"status":503}. """) MaxLineLength:PurchasesCacheTest.kt$PurchasesCacheTest$"\"purchaseToken\":\"gfegjilekkmecbonpfjiaakm.AO-J1OxQCaAn0NPlHTh5CoOiXK0p19X7qEymW9SHtssrggp7S9YafjA1oPBPlWO4Ur3W5rtyNJBzIrVoLOb5In0Jxofv4xV_7t1HaUYYd_f8xOBk7nRIY7g\"}" MaxLineLength:PurchasesCacheTest.kt$PurchasesCacheTest$private val fourPurchasesStr = "[${generatePurchaseJson()},${generatePurchaseJson("2")},${generatePurchaseJson("3")},${generatePurchaseJson("4")}]" @@ -123,7 +122,6 @@ MaxLineLength:QonversionRepositoryIntegrationTest.kt$QonversionRepositoryIntegrationTest$"lcbfeigohklhpdgmpildjabg.AO-J1OyV-EE2bKGqDcRCvqjZ2NI1uHDRuvonRn5RorP6LNsyK7yHK8FaFlXp6bjTEX3-4JvZKtbY_bpquKBfux09Mfkx05M9YGZsfsr5BJk74r719m77Oyo" MaxLineLength:QonversionRepositoryIntegrationTest.kt$QonversionRepositoryIntegrationTest$"lgeigljfpmeoddkcebkcepjc.AO-J1Oy305qZj99jXTPEVBN8UZGoYAtjDLj4uTjRQvUFaG0vie-nr6VBlN0qnNDMU8eJR-sI7o3CwQyMOEHKl8eJsoQ86KSFzxKBR07PSpHLI_o7agXhNKY" MaxLineLength:QonversionRepositoryIntegrationTest.kt$QonversionRepositoryIntegrationTest$purchaseToken = "lgeigljfpmeoddkcebkcepjc.AO-J1Oy305qZj99jXTPEVBN8UZGoYAtjDLj4uTjRQvUFaG0vie-nr6VBlN0qnNDMU8eJR-sI7o3CwQyMOEHKl8eJsoQ86KSFzxKBR07PSpHLI_o7agXhNKY" - MaxLineLength:QonversionRepositoryIntegrationTest.kt$QonversionRepositoryIntegrationTest$val token = "dt70kovLQdKymNnhIY6I94:APA91bGfg6m108VFio2ZdgLR6U0B2PtqAn0hIPVU7M4jKklkMxqDUrjoThpX_K60M7CfH8IVZqtku31ei2hmjdJZDfm-bdAl7uxLDWFU8yVcA6-3wBMn3nsYmUrhYWom-qgGC7yIUYzR" MaxLineLength:ScreenPresenterTest.kt$ScreenPresenterTest$fun MaxLineLength:SharedPreferencesCacheTest.kt$SharedPreferencesCacheTest.Object${ Assert.assertEquals("Wrong available offerings size value", 1, realValue?.offerings?.availableOfferings?.size) } MaxLineLength:SharedPreferencesCacheTest.kt$SharedPreferencesCacheTest.Object${ Assert.assertEquals("Wrong offering products value", expectedValue.offerings?.main?.products, realValue?.offerings?.main?.products) } @@ -145,8 +143,8 @@ MaximumLineLength:com.qonversion.android.sdk.automations.internal.AutomationsEventMapperTest.kt:115 MaximumLineLength:com.qonversion.android.sdk.automations.internal.AutomationsEventMapperTest.kt:116 MaximumLineLength:com.qonversion.android.sdk.automations.internal.AutomationsEventMapperTest.kt:117 - MaximumLineLength:com.qonversion.android.sdk.automations.internal.QAutomationsManager.kt:135 - MaximumLineLength:com.qonversion.android.sdk.automations.internal.QAutomationsManager.kt:142 + MaximumLineLength:com.qonversion.android.sdk.automations.internal.QAutomationsManager.kt:102 + MaximumLineLength:com.qonversion.android.sdk.automations.internal.QAutomationsManager.kt:95 MaximumLineLength:com.qonversion.android.sdk.automations.mvp.ScreenPresenterTest.kt:159 MaximumLineLength:com.qonversion.android.sdk.dto.QonversionError.kt:46 MaximumLineLength:com.qonversion.android.sdk.dto.products.QProduct.kt:109 @@ -155,18 +153,16 @@ MaximumLineLength:com.qonversion.android.sdk.dto.products.QProductStoreDetails.kt:130 MaximumLineLength:com.qonversion.android.sdk.internal.OutagerIntegrationTest.kt:214 MaximumLineLength:com.qonversion.android.sdk.internal.OutagerIntegrationTest.kt:371 - MaximumLineLength:com.qonversion.android.sdk.internal.OutagerIntegrationTest.kt:430 MaximumLineLength:com.qonversion.android.sdk.internal.OutagerIntegrationTest.kt:90 MaximumLineLength:com.qonversion.android.sdk.internal.QProductCenterManager.kt:332 MaximumLineLength:com.qonversion.android.sdk.internal.QProductCenterManagerTest.kt:152 MaximumLineLength:com.qonversion.android.sdk.internal.QProductCenterManagerTest.kt:153 MaximumLineLength:com.qonversion.android.sdk.internal.QRemoteConfigManager.kt:225 - MaximumLineLength:com.qonversion.android.sdk.internal.QUserPropertiesManagerTest.kt:175 + MaximumLineLength:com.qonversion.android.sdk.internal.QUserPropertiesManagerTest.kt:178 MaximumLineLength:com.qonversion.android.sdk.internal.QonversionRepositoryIntegrationTest.kt:287 MaximumLineLength:com.qonversion.android.sdk.internal.QonversionRepositoryIntegrationTest.kt:356 - MaximumLineLength:com.qonversion.android.sdk.internal.QonversionRepositoryIntegrationTest.kt:685 + MaximumLineLength:com.qonversion.android.sdk.internal.QonversionRepositoryIntegrationTest.kt:878 MaximumLineLength:com.qonversion.android.sdk.internal.QonversionRepositoryIntegrationTest.kt:89 - MaximumLineLength:com.qonversion.android.sdk.internal.QonversionRepositoryIntegrationTest.kt:906 MaximumLineLength:com.qonversion.android.sdk.internal.api.ApiErrorMapper.kt:118 MaximumLineLength:com.qonversion.android.sdk.internal.api.ApiErrorMapper.kt:119 MaximumLineLength:com.qonversion.android.sdk.internal.billing.QonversionBillingService.kt:253 @@ -202,12 +198,14 @@ NewLineAtEndOfFile:ScreenPresenterTest.kt$com.qonversion.android.sdk.automations.mvp.ScreenPresenterTest.kt NewLineAtEndOfFile:util.kt$com.qonversion.android.sdk.internal.storage.util.kt NewLineAtEndOfFile:utils.kt$com.qonversion.android.sdk.utils.kt - NoBlankLineBeforeRbrace:com.qonversion.android.sdk.automations.internal.QAutomationsManagerTest.kt:270 + NoBlankLineBeforeRbrace:com.qonversion.android.sdk.automations.internal.QAutomationsManagerTest.kt:261 NoBlankLineBeforeRbrace:com.qonversion.android.sdk.internal.validator.TokenValidatorTest.kt:20 NoConsecutiveBlankLines:com.qonversion.android.sdk.QonversionConfigTest.kt:118 - NoConsecutiveBlankLines:com.qonversion.android.sdk.automations.internal.QAutomationsManagerTest.kt:396 NoConsecutiveBlankLines:com.qonversion.android.sdk.internal.QAttributionManagerTest.kt:141 NoConsecutiveBlankLines:com.qonversion.android.sdk.internal.requests.ProviderDataRequestTest.kt:18 + NoUnusedImports:com.qonversion.android.sdk.automations.internal.QAutomationsManagerTest.kt:20 + NoUnusedImports:com.qonversion.android.sdk.automations.internal.QAutomationsManagerTest.kt:22 + NoUnusedImports:com.qonversion.android.sdk.automations.internal.QAutomationsManagerTest.kt:7 NoUnusedImports:com.qonversion.android.sdk.internal.storage.PurchasesCacheTest.kt:4 NoUnusedImports:com.qonversion.android.sdk.internal.storage.PurchasesCacheTest.kt:5 NoWildcardImports:com.qonversion.android.sdk.automations.internal.AutomationsEventMapperTest.kt:12 @@ -248,10 +246,10 @@ ReturnCount:QProductCenterManager.kt$QProductCenterManager$private fun calculatePurchasePermissionsLocally( purchase: Purchase, purchaseCallback: QonversionEntitlementsCallback?, purchaseError: QonversionError ) ReturnCount:ScreenPresenter.kt$ScreenPresenter$override fun shouldOverrideUrlLoading(url: String?): Boolean SpacingAroundColon:com.qonversion.android.sdk.internal.requests.ProviderDataRequestTest.kt:45 - SpacingAroundCurly:com.qonversion.android.sdk.automations.internal.QAutomationsManagerTest.kt:263 + SpacingAroundCurly:com.qonversion.android.sdk.automations.internal.QAutomationsManagerTest.kt:254 SpacingAroundCurly:com.qonversion.android.sdk.internal.QAttributionManagerTest.kt:39 SpacingAroundCurly:com.qonversion.android.sdk.internal.QAttributionManagerTest.kt:54 - SpacingAroundParens:com.qonversion.android.sdk.internal.QUserPropertiesManagerTest.kt:497 + SpacingAroundParens:com.qonversion.android.sdk.internal.QUserPropertiesManagerTest.kt:468 SpacingAroundParens:com.qonversion.android.sdk.internal.storage.SharedPreferencesCacheTest.kt:209 SpacingAroundParens:com.qonversion.android.sdk.internal.storage.SharedPreferencesCacheTest.kt:238 SpacingAroundParens:com.qonversion.android.sdk.internal.storage.SharedPreferencesCacheTest.kt:257 diff --git a/sdk/src/main/java/com/qonversion/android/sdk/automations/internal/AutomationsInternal.kt b/sdk/src/main/java/com/qonversion/android/sdk/automations/internal/AutomationsInternal.kt index f6e6cf5a3..e7c31acda 100644 --- a/sdk/src/main/java/com/qonversion/android/sdk/automations/internal/AutomationsInternal.kt +++ b/sdk/src/main/java/com/qonversion/android/sdk/automations/internal/AutomationsInternal.kt @@ -25,7 +25,6 @@ internal class AutomationsInternal : Automations { @Deprecated("Consider removing this method as it isn't needed anymore") override fun setNotificationsToken(token: String) { - } @Deprecated("Consider removing this method. Qonversion is not working with push notifications anymore") diff --git a/sdk/src/main/java/com/qonversion/android/sdk/internal/repository/DefaultRepository.kt b/sdk/src/main/java/com/qonversion/android/sdk/internal/repository/DefaultRepository.kt index 05a6fb238..9a200f4cc 100644 --- a/sdk/src/main/java/com/qonversion/android/sdk/internal/repository/DefaultRepository.kt +++ b/sdk/src/main/java/com/qonversion/android/sdk/internal/repository/DefaultRepository.kt @@ -1,6 +1,5 @@ package com.qonversion.android.sdk.internal.repository -import android.content.SharedPreferences import androidx.annotation.VisibleForTesting import com.qonversion.android.sdk.dto.QRemoteConfigList import com.qonversion.android.sdk.dto.properties.QUserProperty From 2fdac81dbce5ec43cb802c1f72e7bd81d74d50d9 Mon Sep 17 00:00:00 2001 From: SpertsyanKM Date: Mon, 30 Sep 2024 10:22:57 +0000 Subject: [PATCH 5/5] [create-pull-request] automated change --- build.gradle | 2 +- fastlane/report.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index ebc71c84d..96a11689f 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask buildscript { ext { release = [ - versionName: "8.1.0", + versionName: "8.1.1", versionCode: 1 ] } diff --git a/fastlane/report.xml b/fastlane/report.xml index 1814b4fe0..c0fe19922 100644 --- a/fastlane/report.xml +++ b/fastlane/report.xml @@ -5,7 +5,7 @@ - +