diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 33a79d211..6de8f5ad8 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -20,7 +20,7 @@ kotlin { } // soralution 138 3.8.5.0 2024.09.06 -// sora dae 116 3.8.5.1 2024.10.23 +// sora dae 118 3.8.5.3 2024.10.23 android { namespace = "jp.co.soramitsu.sora" @@ -30,8 +30,8 @@ android { applicationId = "jp.co.soramitsu.sora" minSdk = 26 targetSdk = 34 - versionCode = System.getenv("CI_BUILD_ID")?.toInt() ?: 116 - versionName = "3.8.5.1" + versionCode = System.getenv("CI_BUILD_ID")?.toInt() ?: 118 + versionName = "3.8.5.3" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" multiDexEnabled = true // resConfigs "en", "ru", "es", "fr", "de", "nb", "in", "tr", "ar" @@ -172,7 +172,7 @@ play { serviceAccountCredentials = file(System.getenv("CI_PLAY_KEY") ?: "../key/fake.json") track = "internal" releaseStatus = ReleaseStatus.DRAFT - releaseName = "3.8.5.1 - Bug fixes and minor improvements" + releaseName = "3.8.5.3 - Bug fixes and minor improvements" defaultToAppBundles = true } diff --git a/feature_wallet_impl/src/main/AndroidManifest.xml b/feature_wallet_impl/src/main/AndroidManifest.xml index 5d8c02a5e..18811f720 100644 --- a/feature_wallet_impl/src/main/AndroidManifest.xml +++ b/feature_wallet_impl/src/main/AndroidManifest.xml @@ -1,13 +1,4 @@ - - - - - - diff --git a/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/claim/ClaimFragment.kt b/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/claim/ClaimFragment.kt index c65d90fa9..426110084 100644 --- a/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/claim/ClaimFragment.kt +++ b/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/claim/ClaimFragment.kt @@ -32,8 +32,6 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package jp.co.soramitsu.feature_wallet_impl.presentation.claim -import android.Manifest -import android.os.Build import android.os.Bundle import android.view.View import androidx.compose.foundation.Image @@ -50,7 +48,6 @@ import androidx.fragment.app.viewModels import androidx.navigation.NavGraphBuilder import androidx.navigation.NavHostController import androidx.navigation.compose.composable -import com.permissionx.guolindev.PermissionX import dagger.hilt.android.AndroidEntryPoint import jp.co.soramitsu.androidfoundation.intent.ShareUtil import jp.co.soramitsu.common.R @@ -84,20 +81,8 @@ class ClaimFragment : SoraBaseFragment() { viewModel.claimScreenState.observeAsState().value?.let { ClaimScreen( claimState = it, - onSubmitClicked = { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - PermissionX.init(this@ClaimFragment) - .permissions(Manifest.permission.POST_NOTIFICATIONS) - .request { allGranted, _, _ -> - if (allGranted) { - viewModel.nextButtonClicked(this@ClaimFragment) - } - } - } else { - viewModel.nextButtonClicked(this@ClaimFragment) - } - }, - onContactUsClicked = viewModel::contactsUsClicked + onSubmitClicked = viewModel::nextButtonClicked, + onContactUsClicked = viewModel::contactsUsClicked, ) } } diff --git a/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/claim/ClaimViewModel.kt b/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/claim/ClaimViewModel.kt index 9bd9f1505..d545056d9 100644 --- a/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/claim/ClaimViewModel.kt +++ b/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/claim/ClaimViewModel.kt @@ -32,25 +32,28 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package jp.co.soramitsu.feature_wallet_impl.presentation.claim -import androidx.fragment.app.Fragment import androidx.lifecycle.LiveData import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel import javax.inject.Inject +import jp.co.soramitsu.androidfoundation.coroutine.CoroutineManager import jp.co.soramitsu.androidfoundation.fragment.SingleLiveEvent import jp.co.soramitsu.common.R import jp.co.soramitsu.common.domain.OptionsProvider +import jp.co.soramitsu.common.logger.FirebaseWrapper import jp.co.soramitsu.common.presentation.viewmodel.BaseViewModel import jp.co.soramitsu.feature_wallet_api.domain.interfaces.WalletInteractor import jp.co.soramitsu.feature_wallet_api.domain.model.MigrationStatus import jp.co.soramitsu.feature_wallet_api.launcher.WalletRouter import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext @HiltViewModel class ClaimViewModel @Inject constructor( private val router: WalletRouter, private val walletInteractor: WalletInteractor, + private val coroutineManager: CoroutineManager, ) : BaseViewModel() { private val _openSendEmailEvent = SingleLiveEvent() @@ -85,10 +88,21 @@ class ClaimViewModel @Inject constructor( _openSendEmailEvent.postValue(OptionsProvider.email) } - fun nextButtonClicked(fragment: Fragment) { - _claimScreenState.value?.let { - _claimScreenState.value = it.copy(loading = true) + fun nextButtonClicked() { + viewModelScope.launch { + _claimScreenState.value?.let { + _claimScreenState.value = it.copy(loading = true) + } + withContext(coroutineManager.io) { + val result = runCatching { walletInteractor.migrate() }.getOrElse { + FirebaseWrapper.recordException(it) + false + } + FirebaseWrapper.log("SORA migration done $result") + walletInteractor.saveMigrationStatus( + if (result) MigrationStatus.SUCCESS else MigrationStatus.FAILED + ) + } } - ClaimWorker.start(fragment.requireContext()) } } diff --git a/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/claim/ClaimWorker.kt b/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/claim/ClaimWorker.kt deleted file mode 100644 index c356d660e..000000000 --- a/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/claim/ClaimWorker.kt +++ /dev/null @@ -1,104 +0,0 @@ -/* -This file is part of the SORA network and Polkaswap app. - -Copyright (c) 2020, 2021, Polka Biome Ltd. All rights reserved. -SPDX-License-Identifier: BSD-4-Clause - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list -of conditions and the following disclaimer. -Redistributions in binary form must reproduce the above copyright notice, this -list of conditions and the following disclaimer in the documentation and/or other -materials provided with the distribution. - -All advertising materials mentioning features or use of this software must display -the following acknowledgement: This product includes software developed by Polka Biome -Ltd., SORA, and Polkaswap. - -Neither the name of the Polka Biome Ltd. nor the names of its contributors may be used -to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY Polka Biome Ltd. AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Polka Biome Ltd. BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -package jp.co.soramitsu.feature_wallet_impl.presentation.claim - -import android.content.Context -import android.content.pm.ServiceInfo -import android.os.Build -import androidx.core.app.NotificationManagerCompat -import androidx.hilt.work.HiltWorker -import androidx.work.CoroutineWorker -import androidx.work.ExistingWorkPolicy -import androidx.work.ForegroundInfo -import androidx.work.OneTimeWorkRequestBuilder -import androidx.work.WorkManager -import androidx.work.WorkerParameters -import dagger.assisted.Assisted -import dagger.assisted.AssistedInject -import javax.inject.Inject -import jp.co.soramitsu.common.R -import jp.co.soramitsu.common.logger.FirebaseWrapper -import jp.co.soramitsu.common.util.BuildUtils -import jp.co.soramitsu.common.util.Notification -import jp.co.soramitsu.feature_wallet_api.domain.interfaces.WalletInteractor -import jp.co.soramitsu.feature_wallet_api.domain.model.MigrationStatus - -@HiltWorker -class ClaimWorker @AssistedInject constructor( - @Assisted val appContext: Context, - @Assisted workerParams: WorkerParameters -) : - CoroutineWorker(appContext, workerParams) { - - companion object { - private const val TAG = "ClaimWorker" - const val NOTIFICATION_ID = 42 - - fun start(context: Context) { - val ethereumWorkRequest = OneTimeWorkRequestBuilder() - .addTag(TAG) - .build() - - WorkManager.getInstance(context) - .enqueueUniqueWork(TAG, ExistingWorkPolicy.REPLACE, ethereumWorkRequest) - } - } - - @Inject - lateinit var walletInteractor: WalletInteractor - - private val notificationManager = NotificationManagerCompat.from(appContext) - - override suspend fun doWork(): Result { - Notification.checkNotificationChannel(notificationManager) - val notification = Notification.getBuilder(appContext) - .setContentTitle(appContext.getString(R.string.claim_notification_text)) - .build() - - val foregroundInfo = if (BuildUtils.sdkAtLeast(Build.VERSION_CODES.Q)) { - ForegroundInfo(NOTIFICATION_ID, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC) - } else { - ForegroundInfo(NOTIFICATION_ID, notification) - } - setForeground(foregroundInfo) - - val result = runCatching { walletInteractor.migrate() }.getOrElse { - FirebaseWrapper.recordException(it) - false - } - FirebaseWrapper.log("SORA migration done $result") - walletInteractor.saveMigrationStatus(if (result) MigrationStatus.SUCCESS else MigrationStatus.FAILED) - - return Result.success() - } -} diff --git a/feature_wallet_impl/src/test/java/jp/co/soramitsu/feature_wallet_impl/presentation/claim/ClaimViewModelTest.kt b/feature_wallet_impl/src/test/java/jp/co/soramitsu/feature_wallet_impl/presentation/claim/ClaimViewModelTest.kt index 9dc50fd23..64801f4ed 100644 --- a/feature_wallet_impl/src/test/java/jp/co/soramitsu/feature_wallet_impl/presentation/claim/ClaimViewModelTest.kt +++ b/feature_wallet_impl/src/test/java/jp/co/soramitsu/feature_wallet_impl/presentation/claim/ClaimViewModelTest.kt @@ -32,9 +32,8 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package jp.co.soramitsu.feature_wallet_impl.presentation.claim -import android.content.Context import androidx.arch.core.executor.testing.InstantTaskExecutorRule -import jp.co.soramitsu.androidfoundation.resource.ResourceManager +import jp.co.soramitsu.androidfoundation.coroutine.CoroutineManager import jp.co.soramitsu.androidfoundation.testing.MainCoroutineRule import jp.co.soramitsu.feature_wallet_api.domain.interfaces.WalletInteractor import jp.co.soramitsu.feature_wallet_api.domain.model.MigrationStatus @@ -66,9 +65,6 @@ class ClaimViewModelTest { @get:Rule var mainCoroutineRule = MainCoroutineRule() - @Mock - private lateinit var context: Context - @Mock private lateinit var walletInteractor: WalletInteractor @@ -76,14 +72,18 @@ class ClaimViewModelTest { private lateinit var router: WalletRouter @Mock - private lateinit var resourceManager: ResourceManager + private lateinit var cm: CoroutineManager private lateinit var viewModel: ClaimViewModel @Before fun setUp() { given(walletInteractor.observeMigrationStatus()).willReturn(flow { emit(MigrationStatus.SUCCESS) }) - viewModel = ClaimViewModel(router, walletInteractor) + viewModel = ClaimViewModel( + router, + walletInteractor, + cm, + ) } @Test