From 78f02fa8780844e4284b5a4441c98770f359d999 Mon Sep 17 00:00:00 2001 From: Giorgos Papadopoulos Date: Fri, 28 Jul 2023 13:03:10 +0200 Subject: [PATCH 1/2] remove camera support --- holder/build.gradle | 1 - holder/src/main/AndroidManifest.xml | 5 - .../ctr/holder/HolderApplication.kt | 2 - .../ctr/holder/HolderMainFragment.kt | 5 - .../data_migration/DataExportUseCase.kt | 60 ----- .../DataMigrationImportUseCase.kt | 51 ---- .../DataMigrationInstructionsFragment.kt | 234 ------------------ .../DataMigrationOnboardingItem.kt | 39 --- .../DataMigrationPayloadUseCase.kt | 40 --- .../DataMigrationScanQrFragment.kt | 117 --------- .../DataMigrationScanQrViewModel.kt | 168 ------------- .../DataMigrationShowQrCodeFragment.kt | 71 ------ .../DataMigrationShowQrCodeViewModel.kt | 69 ------ .../DataMigrationShowQrViewState.kt | 16 -- .../DataMigrationStartFragment.kt | 45 ---- .../DataMigrationStartViewModel.kt | 24 -- .../DataMigrationTransferOptionsFragment.kt | 84 ------- .../data_migration/DataMigrationUseCase.kt | 23 -- .../holder/data_migration/EventGroupParcel.kt | 16 -- .../holder/data_migration/MigrationParcel.kt | 19 -- .../holder/data_migration/StringDataZipper.kt | 29 --- .../ctr/holder/menu/MenuViewModel.kt | 31 --- .../holder/modules/EventsUseCasesModule.kt | 12 - .../ctr/holder/modules/UtilsModule.kt | 3 - .../ctr/holder/modules/ViewModels.kt | 15 -- .../PaperProofDomesticInputCodeFragment.kt | 162 ------------ .../PaperProofDomesticInputCodeViewModel.kt | 52 ---- .../PaperProofQrScannerFragment.kt | 112 --------- .../PaperProofQrScannerViewModel.kt | 33 --- .../PaperProofStartScanningFragment.kt | 88 ------- .../res/navigation/holder_nav_graph_main.xml | 168 ------------- .../res/navigation/holder_nav_graph_root.xml | 34 --- 32 files changed, 1828 deletions(-) delete mode 100644 holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataExportUseCase.kt delete mode 100644 holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationImportUseCase.kt delete mode 100644 holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationInstructionsFragment.kt delete mode 100644 holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationOnboardingItem.kt delete mode 100644 holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationPayloadUseCase.kt delete mode 100644 holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationScanQrFragment.kt delete mode 100644 holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationScanQrViewModel.kt delete mode 100644 holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationShowQrCodeFragment.kt delete mode 100644 holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationShowQrCodeViewModel.kt delete mode 100644 holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationShowQrViewState.kt delete mode 100644 holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationStartFragment.kt delete mode 100644 holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationStartViewModel.kt delete mode 100644 holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationTransferOptionsFragment.kt delete mode 100644 holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationUseCase.kt delete mode 100644 holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/EventGroupParcel.kt delete mode 100644 holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/MigrationParcel.kt delete mode 100644 holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/StringDataZipper.kt delete mode 100644 holder/src/main/java/nl/rijksoverheid/ctr/holder/paper_proof/PaperProofDomesticInputCodeFragment.kt delete mode 100644 holder/src/main/java/nl/rijksoverheid/ctr/holder/paper_proof/PaperProofDomesticInputCodeViewModel.kt delete mode 100644 holder/src/main/java/nl/rijksoverheid/ctr/holder/paper_proof/PaperProofQrScannerFragment.kt delete mode 100644 holder/src/main/java/nl/rijksoverheid/ctr/holder/paper_proof/PaperProofQrScannerViewModel.kt delete mode 100644 holder/src/main/java/nl/rijksoverheid/ctr/holder/paper_proof/PaperProofStartScanningFragment.kt diff --git a/holder/build.gradle b/holder/build.gradle index e3ca5fd23..6a6c08827 100644 --- a/holder/build.gradle +++ b/holder/build.gradle @@ -180,7 +180,6 @@ dependencies { implementation project(":introduction") implementation project(":api") implementation project(':mobilecore') - implementation project(":qrscanner") implementation project(":modules:luhncheck") implementation project(":modules:qrgenerator") implementation project(":modules:openidconnect") diff --git a/holder/src/main/AndroidManifest.xml b/holder/src/main/AndroidManifest.xml index da889f0e9..4ed7144b5 100644 --- a/holder/src/main/AndroidManifest.xml +++ b/holder/src/main/AndroidManifest.xml @@ -3,11 +3,6 @@ xmlns:tools="http://schemas.android.com/tools"> - - - { - // Trigger custom dispatcher in destination - requireActivity().onBackPressedDispatcher.onBackPressed() - return@setNavigationOnClickListener - } } NavigationUI.navigateUp(navController, null) diff --git a/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataExportUseCase.kt b/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataExportUseCase.kt deleted file mode 100644 index 0a11fbe33..000000000 --- a/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataExportUseCase.kt +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2023 De Staat der Nederlanden, Ministerie van Volksgezondheid, Welzijn en Sport. - * Licensed under the EUROPEAN UNION PUBLIC LICENCE v. 1.2 - * - * SPDX-License-Identifier: EUPL-1.2 - * - */ -package nl.rijksoverheid.ctr.holder.data_migration - -import com.squareup.moshi.JsonAdapter -import com.squareup.moshi.Moshi -import com.squareup.moshi.Types -import nl.rijksoverheid.ctr.api.json.Base64JsonAdapter -import nl.rijksoverheid.ctr.persistence.database.HolderDatabase - -interface DataExportUseCase { - suspend fun export(): List -} - -class DataExportUseCaseImpl( - private val holderDatabase: HolderDatabase, - private val moshi: Moshi, - private val stringDataZipper: StringDataZipper -) : DataExportUseCase { - override suspend fun export(): List { - val eventsGroups = holderDatabase.eventGroupDao().getAll().filter { !it.draft } - val eventGroupParcels = eventsGroups.map { - EventGroupParcel( - jsonData = it.jsonData - ) - } - val parameterizedType = - Types.newParameterizedType(List::class.java, EventGroupParcel::class.java) - val adapter: JsonAdapter> = moshi.adapter(parameterizedType) - val json = adapter.toJson(eventGroupParcels) - - val compressed = stringDataZipper.zip(json) - - val base64JsonAdapter = Base64JsonAdapter() - val base64 = base64JsonAdapter.toBase64(compressed) - - val compChunks = base64.chunked(maxPackageSize) - - val migrationParcelAdapter = moshi.adapter(MigrationParcel::class.java) - return compChunks.map { - val parcel = MigrationParcel( - index = compChunks.indexOf(it), - numberOfPackages = compChunks.size, - payload = it, - version = version - ) - base64JsonAdapter.toBase64(migrationParcelAdapter.toJson(parcel).toByteArray()) - } - } - - companion object { - const val version = "CC1" - const val maxPackageSize = 800 - } -} diff --git a/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationImportUseCase.kt b/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationImportUseCase.kt deleted file mode 100644 index def49d31d..000000000 --- a/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationImportUseCase.kt +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2023 De Staat der Nederlanden, Ministerie van Volksgezondheid, Welzijn en Sport. - * Licensed under the EUROPEAN UNION PUBLIC LICENCE v. 1.2 - * - * SPDX-License-Identifier: EUPL-1.2 - * - */ - -package nl.rijksoverheid.ctr.holder.data_migration - -import com.squareup.moshi.JsonAdapter -import com.squareup.moshi.Moshi -import com.squareup.moshi.Types -import nl.rijksoverheid.ctr.api.json.Base64JsonAdapter - -interface DataMigrationImportUseCase { - suspend fun import(content: String): MigrationParcel? - suspend fun merge(migrationParcels: List): List -} - -class DataMigrationImportUseCaseImpl( - private val moshi: Moshi, - private val stringDataZipper: StringDataZipper -) : DataMigrationImportUseCase { - - private val base64JsonAdapter = Base64JsonAdapter() - - override suspend fun import(content: String): MigrationParcel? { - val decodedContent = base64JsonAdapter.fromBase64(content) - - val migrationParcelAdapter = moshi.adapter(MigrationParcel::class.java) - - return migrationParcelAdapter.fromJson(String(decodedContent)) - } - - override suspend fun merge(migrationParcels: List): List { - val mergedMigrationParcel = - migrationParcels.sortedBy { it.index }.map { base64JsonAdapter.fromBase64(it.payload) } - .reduce { acc, bytes -> acc + bytes } - - val uncompressed = stringDataZipper.unzip(mergedMigrationParcel) - - val parameterizedType = - Types.newParameterizedType(List::class.java, EventGroupParcel::class.java) - val adapter: JsonAdapter> = moshi.adapter(parameterizedType) - - val eventGroupParcels = adapter.fromJson(uncompressed) - - return eventGroupParcels ?: emptyList() - } -} diff --git a/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationInstructionsFragment.kt b/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationInstructionsFragment.kt deleted file mode 100644 index 6daab3efd..000000000 --- a/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationInstructionsFragment.kt +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Copyright (c) 2023 De Staat der Nederlanden, Ministerie van Volksgezondheid, Welzijn en Sport. - * Licensed under the EUROPEAN UNION PUBLIC LICENCE v. 1.2 - * - * SPDX-License-Identifier: EUPL-1.2 - * - */ - -package nl.rijksoverheid.ctr.holder.data_migration - -import android.annotation.SuppressLint -import android.content.Context -import android.content.pm.ActivityInfo -import android.hardware.camera2.CameraAccessException -import android.hardware.camera2.CameraManager -import android.os.Bundle -import android.view.View -import android.view.WindowManager -import android.widget.ScrollView -import androidx.activity.OnBackPressedCallback -import androidx.fragment.app.Fragment -import androidx.navigation.Navigation -import androidx.navigation.fragment.navArgs -import androidx.viewpager2.widget.ViewPager2 -import nl.rijksoverheid.ctr.design.fragments.ErrorResultFragment -import nl.rijksoverheid.ctr.holder.BuildConfig -import nl.rijksoverheid.ctr.holder.HolderMainActivityViewModel -import nl.rijksoverheid.ctr.holder.R -import nl.rijksoverheid.ctr.introduction.databinding.FragmentOnboardingBinding -import nl.rijksoverheid.ctr.introduction.onboarding.OnboardingPagerAdapter -import nl.rijksoverheid.ctr.persistence.PersistenceManager -import nl.rijksoverheid.ctr.shared.ext.findNavControllerSafety -import nl.rijksoverheid.ctr.shared.ext.navigateSafety -import nl.rijksoverheid.ctr.shared.livedata.EventObserver -import nl.rijksoverheid.ctr.shared.models.ErrorResultFragmentData -import org.koin.android.ext.android.inject -import org.koin.androidx.viewmodel.ext.android.sharedViewModel - -class DataMigrationInstructionsFragment : Fragment(R.layout.fragment_onboarding) { - - private var _binding: FragmentOnboardingBinding? = null - private val binding get() = _binding!! - - private val args: DataMigrationInstructionsFragmentArgs by navArgs() - private val persistenceManager: PersistenceManager by inject() - - private val holderMainActivityViewModel: HolderMainActivityViewModel by sharedViewModel() - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - - if (BuildConfig.FLAVOR.lowercase().contains("prod")) { - requireActivity().window.setFlags( - WindowManager.LayoutParams.FLAG_SECURE, - WindowManager.LayoutParams.FLAG_SECURE - ) - } - - increaseBrightness() - } - - @SuppressLint("SourceLockedOrientationActivity") - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - - requireActivity().requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT - - _binding = FragmentOnboardingBinding.bind(view) - - val adapter = - OnboardingPagerAdapter( - childFragmentManager, - lifecycle, - args.instructionItems.toList() - ) - - binding.indicators.initIndicator(3) - initViewPager(adapter, savedInstanceState?.getInt(indicatorPositionKey)) - - setBackPressListener() - setBindings(adapter) - - holderMainActivityViewModel.navigateLiveData.observe(viewLifecycleOwner, EventObserver { - findNavControllerSafety()?.navigate(it) - }) - - holderMainActivityViewModel.navigateWithBundleLiveData.observe( - viewLifecycleOwner, - EventObserver { - navigateSafety(it.first, it.second) - }) - } - - private fun setBindings( - adapter: OnboardingPagerAdapter - ) { - binding.button.setOnClickListener { - val currentItem = binding.viewPager.currentItem - if (currentItem == adapter.itemCount - 1) { - if (args.destination is DataMigrationOnboardingItem.ScanQrCode) { - openScanner() - } else { - persistenceManager.setShowMigrationDialog(true) - navigateSafety(args.destination.navigationActionId) - } - } else { - binding.viewPager.currentItem = currentItem + 1 - } - } - } - - private fun openScanner() { - try { - val cameraManager = - requireActivity().getSystemService(Context.CAMERA_SERVICE) as CameraManager - if (cameraManager.cameraIdList.isNotEmpty()) { - Navigation.findNavController(requireActivity(), R.id.main_nav_host_fragment) - .navigate(R.id.action_data_migration_scan_qr) - } else { - showNoCameraError() - } - } catch (exception: CameraAccessException) { - showNoCameraError() - } - } - - private fun showNoCameraError() { - navigateSafety( - R.id.action_error_result, - ErrorResultFragment.getBundle( - ErrorResultFragmentData( - title = getString(R.string.add_paper_proof_no_camera_error_header), - description = getString(R.string.add_paper_proof_no_camera_error_description), - buttonTitle = getString(R.string.back_to_overview), - buttonAction = ErrorResultFragmentData.ButtonAction.Destination(R.id.action_my_overview) - ) - ) - ) - } - - private fun setBackPressListener() { - requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, object : - OnBackPressedCallback(true) { - override fun handleOnBackPressed() { - val currentItem = binding.viewPager.currentItem - if (currentItem == 0) { - findNavControllerSafety()?.popBackStack() - } else { - binding.viewPager.currentItem = binding.viewPager.currentItem - 1 - } - } - }) - } - - override fun onSaveInstanceState(outState: Bundle) { - super.onSaveInstanceState(outState) - _binding?.let { - outState.putInt(indicatorPositionKey, it.viewPager.currentItem) - } - } - - private fun initViewPager( - adapter: OnboardingPagerAdapter, - startingItem: Int? = null - ) { - binding.viewPager.offscreenPageLimit = 2 - binding.viewPager.adapter = adapter - binding.viewPager.registerOnPageChangeCallback(object : - ViewPager2.OnPageChangeCallback() { - @SuppressLint("StringFormatInvalid") - override fun onPageSelected(position: Int) { - super.onPageSelected(position) - - binding.button.text = if (position == 2) { - getString(R.string.holder_startMigration_onboarding_doneButton) - } else { - getString(R.string.holder_startMigration_onboarding_nextButton) - } - - binding.indicators.updateSelected(position) - - binding.indicators.contentDescription = getString( - nl.rijksoverheid.ctr.introduction.R.string.onboarding_page_indicator_label, - (position + 1).toString(), - adapter.itemCount.toString() - ) - - // Apply bottom elevation if the view inside the viewpager is scrollable - val scrollView = - childFragmentManager.fragments[position]?.view?.findViewById(nl.rijksoverheid.ctr.introduction.R.id.scroll) - if (scrollView?.canScrollVertically(1) == true) { - binding.bottom.cardElevation = - resources.getDimensionPixelSize(nl.rijksoverheid.ctr.introduction.R.dimen.scroll_view_button_elevation) - .toFloat() - } else { - binding.bottom.cardElevation = 0f - } - - if (args.instructionItems[position].clazz == DataMigrationShowQrCodeFragment::class.java) { - increaseBrightness() - } else { - resetBrightness() - } - } - }) - startingItem?.let { binding.viewPager.currentItem = it } - } - - fun increaseBrightness() { - val params = requireActivity().window.attributes - params?.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_FULL - requireActivity().window.attributes = params - } - - private fun resetBrightness() { - val params = requireActivity().window.attributes - params?.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE - requireActivity().window.attributes = params - } - - override fun onDestroyView() { - super.onDestroyView() - _binding = null - - resetBrightness() - - requireActivity().requestedOrientation = - ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED - } - - companion object { - private const val indicatorPositionKey = "indicator_position_key" - } -} diff --git a/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationOnboardingItem.kt b/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationOnboardingItem.kt deleted file mode 100644 index e8d194b21..000000000 --- a/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationOnboardingItem.kt +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023 De Staat der Nederlanden, Ministerie van Volksgezondheid, Welzijn en Sport. - * Licensed under the EUROPEAN UNION PUBLIC LICENCE v. 1.2 - * - * SPDX-License-Identifier: EUPL-1.2 - * - */ - -package nl.rijksoverheid.ctr.holder.data_migration - -import android.os.Parcelable -import androidx.annotation.IdRes -import androidx.annotation.StringRes -import kotlinx.parcelize.Parcelize -import nl.rijksoverheid.ctr.holder.R -import nl.rijksoverheid.ctr.introduction.onboarding.models.OnboardingItem - -sealed class DataMigrationOnboardingItem( - @StringRes val title: Int, - @StringRes val descriptionResource: Int, - @IdRes val navigationActionId: Int -) : OnboardingItem( - titleResource = title, - description = descriptionResource -) { - @Parcelize - object ShowQrCode : DataMigrationOnboardingItem( - title = R.string.holder_startMigration_toOtherDevice_onboarding_step3_title, - descriptionResource = R.string.holder_startMigration_toOtherDevice_onboarding_step3_title, - navigationActionId = R.id.action_my_overview - ), Parcelable - - @Parcelize - object ScanQrCode : DataMigrationOnboardingItem( - title = R.string.holder_startMigration_toThisDevice_onboarding_step3_title, - descriptionResource = R.string.holder_startMigration_toThisDevice_onboarding_step3_title, - navigationActionId = R.id.action_data_migration_scan_qr - ), Parcelable -} diff --git a/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationPayloadUseCase.kt b/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationPayloadUseCase.kt deleted file mode 100644 index aa372670b..000000000 --- a/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationPayloadUseCase.kt +++ /dev/null @@ -1,40 +0,0 @@ -package nl.rijksoverheid.ctr.holder.data_migration - -import android.util.Base64 -import com.squareup.moshi.Moshi -import nl.rijksoverheid.ctr.holder.get_events.models.RemoteProtocol -import nl.rijksoverheid.ctr.holder.paper_proof.usecases.GetEventsFromPaperProofQrUseCase -import nl.rijksoverheid.ctr.holder.your_events.utils.SignedResponse -import org.json.JSONObject - -/* - * Copyright (c) 2023 De Staat der Nederlanden, Ministerie van Volksgezondheid, Welzijn en Sport. - * Licensed under the EUROPEAN UNION PUBLIC LICENCE v. 1.2 - * - * SPDX-License-Identifier: EUPL-1.2 - * - */ - -interface DataMigrationPayloadUseCase { - fun parsePayload(jsonData: ByteArray): RemoteProtocol? -} - -class DataMigrationPayloadUseCaseImpl( - private val moshi: Moshi, - private val getEventsFromPaperProofQrUseCase: GetEventsFromPaperProofQrUseCase -) : DataMigrationPayloadUseCase { - override fun parsePayload(jsonData: ByteArray): RemoteProtocol? { - val json = JSONObject(jsonData.decodeToString()) - - return if (json.has("credential")) { - // dcc - getEventsFromPaperProofQrUseCase.get(json.getString("credential")) - } else { - // non dcc - val payload = moshi.adapter(SignedResponse::class.java) - .fromJson(String(jsonData))?.payload - val decodedPayload = String(Base64.decode(payload, Base64.DEFAULT)) - return moshi.adapter(RemoteProtocol::class.java).fromJson(decodedPayload) - } - } -} diff --git a/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationScanQrFragment.kt b/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationScanQrFragment.kt deleted file mode 100644 index 020b7c95a..000000000 --- a/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationScanQrFragment.kt +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2023 De Staat der Nederlanden, Ministerie van Volksgezondheid, Welzijn en Sport. - * Licensed under the EUROPEAN UNION PUBLIC LICENCE v. 1.2 - * - * SPDX-License-Identifier: EUPL-1.2 - * - */ - -package nl.rijksoverheid.ctr.holder.data_migration - -import android.os.Bundle -import android.view.View -import androidx.core.view.isVisible -import nl.rijksoverheid.ctr.design.fragments.ErrorResultFragment -import nl.rijksoverheid.ctr.holder.HolderMainActivityViewModel -import nl.rijksoverheid.ctr.holder.HolderMainFragment -import nl.rijksoverheid.ctr.holder.R -import nl.rijksoverheid.ctr.holder.models.HolderFlow -import nl.rijksoverheid.ctr.qrscanner.QrCodeScannerFragment -import nl.rijksoverheid.ctr.shared.ext.findNavControllerSafety -import nl.rijksoverheid.ctr.shared.factories.ErrorCodeStringFactory -import nl.rijksoverheid.ctr.shared.livedata.EventObserver -import nl.rijksoverheid.ctr.shared.models.ErrorResultFragmentData -import org.koin.android.ext.android.inject -import org.koin.androidx.viewmodel.ext.android.sharedViewModel -import org.koin.androidx.viewmodel.ext.android.viewModel - -class DataMigrationScanQrFragment : QrCodeScannerFragment() { - - private val holderMainActivityViewModel: HolderMainActivityViewModel by sharedViewModel() - - private val viewModel: DataMigrationScanQrViewModel by viewModel() - - private val errorCodeStringFactory: ErrorCodeStringFactory by inject() - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - - viewModel.scanFinishedLiveData.observe(viewLifecycleOwner, EventObserver { - findNavControllerSafety()?.popBackStack() - - when (it) { - is DataMigrationScanQrState.Error -> holderMainActivityViewModel.navigateWithBundle( - DataMigrationInstructionsFragmentDirections.actionErrorResult().actionId, - ErrorResultFragment.getBundle( - ErrorResultFragmentData( - title = getString(R.string.error_something_went_wrong_title), - description = getString( - R.string.holder_migration_errorcode_message, - errorCodeStringFactory.get( - HolderFlow.Migration, - listOf(it.errorResult) - ) - ), - buttonTitle = getString(R.string.general_toMyOverview), - buttonAction = ErrorResultFragmentData.ButtonAction.Destination( - R.id.action_my_overview - ) - ) - ) - ) - is DataMigrationScanQrState.Success -> holderMainActivityViewModel.navigate( - navDirections = DataMigrationInstructionsFragmentDirections.actionYourEvents( - type = it.type, - toolbarTitle = "", - flow = HolderFlow.Migration - ) - ) - } - }) - - viewModel.progressBarLiveData.observe(viewLifecycleOwner) { - binding.progressBar.isVisible = true - binding.progressBar.progress = it.calculateProgressPercentage() - } - - (parentFragment?.parentFragment as? HolderMainFragment)?.getToolbar()?.isVisible = false - - binding.extraContentMessage.postDelayed({ - if (isAdded) { - val defaultMessage = getString(R.string.holder_startMigration_toThisDevice_onboarding_step3_messageKeepPointing) - val extraMessage = getString(R.string.holder_startMigration_toThisDevice_onboarding_step3_messageKeepPointing_longer) - val message = "$defaultMessage $extraMessage" - binding.extraContentMessage.animate().setDuration(150).alpha(0f).withEndAction { - binding.extraContentMessage.text = message - binding.extraContentMessage.animate().setDuration(150).alpha(1f) - } - } - }, 10000) - } - - override fun onDestroyView() { - super.onDestroyView() - - (parentFragment?.parentFragment as? HolderMainFragment)?.getToolbar()?.isVisible = true - } - - override fun onQrScanned(content: String) { - binding.extraContentTitle.text = - getString(R.string.holder_startMigration_toThisDevice_onboarding_step3_titleScanning) - binding.extraContentMessage.text = - getString(R.string.holder_startMigration_toThisDevice_onboarding_step3_messageKeepPointing) - viewModel.onQrScanned(content) - } - - override fun getCopy(): Copy { - return Copy( - title = getString(R.string.add_paper_proof_qr_scanner_title), - message = "", - extraContent = Copy.ExtraContent( - header = getString(R.string.holder_startMigration_onboarding_step, "3"), - title = getString(R.string.holder_startMigration_toThisDevice_onboarding_step3_title), - message = getString(R.string.holder_startMigration_toThisDevice_onboarding_step3_message) - ) - ) - } -} diff --git a/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationScanQrViewModel.kt b/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationScanQrViewModel.kt deleted file mode 100644 index c441d8b30..000000000 --- a/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationScanQrViewModel.kt +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (c) 2023 De Staat der Nederlanden, Ministerie van Volksgezondheid, Welzijn en Sport. - * Licensed under the EUROPEAN UNION PUBLIC LICENCE v. 1.2 - * - * SPDX-License-Identifier: EUPL-1.2 - * - */ -package nl.rijksoverheid.ctr.holder.data_migration - -import androidx.lifecycle.LiveData -import androidx.lifecycle.MutableLiveData -import androidx.lifecycle.ViewModel -import androidx.lifecycle.viewModelScope -import kotlinx.coroutines.launch -import nl.rijksoverheid.ctr.holder.get_events.models.EventProvider -import nl.rijksoverheid.ctr.holder.get_events.models.RemoteProtocol -import nl.rijksoverheid.ctr.holder.get_events.usecases.ConfigProvidersUseCase -import nl.rijksoverheid.ctr.holder.get_events.usecases.EventProvidersResult -import nl.rijksoverheid.ctr.holder.models.HolderStep -import nl.rijksoverheid.ctr.holder.your_events.YourEventsFragmentType -import nl.rijksoverheid.ctr.shared.exceptions.DataMigrationDecodingErrorException -import nl.rijksoverheid.ctr.shared.exceptions.DataMigrationInvalidNumberOfPackagesException -import nl.rijksoverheid.ctr.shared.exceptions.DataMigrationInvalidVersionException -import nl.rijksoverheid.ctr.shared.exceptions.DataMigrationOtherException -import nl.rijksoverheid.ctr.shared.exceptions.NoProvidersException -import nl.rijksoverheid.ctr.shared.livedata.Event -import nl.rijksoverheid.ctr.shared.models.AppErrorResult - -data class ProgressBarState(val progress: Int, val max: Int) { - fun calculateProgressPercentage(): Int { - return ((progress.toFloat() / max.toFloat()) * 100).toInt() - } -} - -sealed class DataMigrationScanQrState { - data class Success(val type: YourEventsFragmentType.RemoteProtocol3Type) : - DataMigrationScanQrState() - - data class Error(val errorResult: AppErrorResult) : DataMigrationScanQrState() -} - -abstract class DataMigrationScanQrViewModel : ViewModel() { - val progressBarLiveData: LiveData = MutableLiveData() - val scanFinishedLiveData: LiveData> = - MutableLiveData() - - abstract fun onQrScanned(content: String) -} - -class DataMigrationScanQrViewModelImpl( - private val dataMigrationImportUseCase: DataMigrationImportUseCase, - private val dataMigrationPayloadUseCase: DataMigrationPayloadUseCase, - private val configProvidersUseCase: ConfigProvidersUseCase -) : DataMigrationScanQrViewModel() { - - private val scannedChunks = mutableListOf() - private val scannedQRs = mutableListOf() - - private fun scanFinished(state: DataMigrationScanQrState) { - (scanFinishedLiveData as MutableLiveData).postValue(Event(state)) - } - - private fun scanFinishedWithError(exception: Exception) { - scanFinished( - DataMigrationScanQrState.Error( - AppErrorResult( - HolderStep.DataMigrationImport, - exception - ) - ) - ) - } - - override fun onQrScanned(content: String) { - if (scannedQRs.contains(content)) { - return - } - scannedQRs.add(content) - viewModelScope.launch { - val migrationParcel = try { - dataMigrationImportUseCase.import(content) - } catch (exception: Exception) { - scanFinishedWithError(DataMigrationDecodingErrorException()) - return@launch - } - - when { - migrationParcel == null -> { - scanFinishedWithError(DataMigrationOtherException()) - } - migrationParcel.version != DataExportUseCaseImpl.version -> { - scanFinishedWithError(DataMigrationInvalidVersionException()) - } - else -> { - next(migrationParcel) - } - } - } - } - - private suspend fun next(migrationParcel: MigrationParcel) { - when { - scannedChunks.size >= migrationParcel.numberOfPackages -> { - scanFinishedWithError(DataMigrationInvalidNumberOfPackagesException()) - } - else -> { - updateProgress(migrationParcel) - } - } - } - - private suspend fun updateProgress(migrationParcel: MigrationParcel) { - val currentState = progressBarLiveData.value - val currentProgress = currentState?.progress ?: 0 - if (!scannedChunks.map { it.payload }.contains(migrationParcel.payload)) { - scannedChunks.add(migrationParcel) - (progressBarLiveData as MutableLiveData).postValue( - ProgressBarState( - progress = currentProgress + 1, - max = migrationParcel.numberOfPackages - ) - ) - if (scannedChunks.size == migrationParcel.numberOfPackages) { - scanFinished() - } - } - } - - private suspend fun scanFinished() { - val eventGroupParcels = try { - dataMigrationImportUseCase.merge(scannedChunks) - } catch (exception: Exception) { - scanFinishedWithError(DataMigrationDecodingErrorException()) - return - } - val remoteEventsMap = eventGroupParcels.mapNotNull { - val remoteProtocol = - dataMigrationPayloadUseCase.parsePayload(it.jsonData) - - if (remoteProtocol != null) { - mapOf(remoteProtocol to it.jsonData) - } else { - null - } - } - .fold(mapOf()) { protocol, byteArray -> protocol + byteArray } - - val eventProvidersResult = configProvidersUseCase.eventProviders() - - if (eventProvidersResult is EventProvidersResult.Success) { - scanFinished( - state = DataMigrationScanQrState.Success( - type = YourEventsFragmentType.RemoteProtocol3Type( - remoteEvents = remoteEventsMap, - eventProviders = eventProvidersResult.eventProviders.map { - EventProvider( - it.providerIdentifier, - it.name - ) - } - ) - ) - ) - } else { - scanFinishedWithError(NoProvidersException.Migration) - } - } -} diff --git a/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationShowQrCodeFragment.kt b/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationShowQrCodeFragment.kt deleted file mode 100644 index ca75fe2d8..000000000 --- a/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationShowQrCodeFragment.kt +++ /dev/null @@ -1,71 +0,0 @@ -package nl.rijksoverheid.ctr.holder.data_migration - -import android.os.Bundle -import android.view.View -import nl.rijksoverheid.ctr.holder.BaseFragment -import nl.rijksoverheid.ctr.holder.R -import nl.rijksoverheid.ctr.holder.databinding.FragmentDataMigrationShowQrBinding -import nl.rijksoverheid.ctr.holder.models.HolderFlow -import nl.rijksoverheid.ctr.shared.models.ErrorResultFragmentData -import nl.rijksoverheid.ctr.shared.models.Flow -import org.koin.androidx.viewmodel.ext.android.viewModel - -class DataMigrationShowQrCodeFragment : BaseFragment(R.layout.fragment_data_migration_show_qr) { - - private val viewModel: DataMigrationShowQrCodeViewModel by viewModel() - - override fun onButtonClickWithRetryAction() { - // no-op - } - - override fun getFlow(): Flow { - return HolderFlow.Migration - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - - val binding = FragmentDataMigrationShowQrBinding.bind(view) - binding.step.text = getString(R.string.holder_startMigration_onboarding_step, "3") - - viewModel.qrCodesLiveData.observe(viewLifecycleOwner) { - when (it) { - is DataMigrationShowQrViewState.ShowError -> { - presentError( - data = ErrorResultFragmentData( - title = getString(R.string.error_something_went_wrong_title), - description = getString( - R.string.holder_migration_errorcode_message, - errorCodeStringFactory.get(getFlow(), it.errorResults) - ), - buttonTitle = getString(R.string.general_toMyOverview), - buttonAction = ErrorResultFragmentData.ButtonAction.Destination(R.id.action_my_overview) - ) - ) - } - is DataMigrationShowQrViewState.ShowQrs -> { - val bitmaps = it.bitmaps - val firstBitmap = bitmaps.firstOrNull() ?: return@observe - binding.dataMigrationQrCodes.setImageBitmap(firstBitmap) - if (bitmaps.size > 1) { - var nextIndex = 1 - val runnable = object : Runnable { - override fun run() { - if (!isAdded) return - binding.dataMigrationQrCodes.setImageBitmap(bitmaps[nextIndex]) - nextIndex++ - if (nextIndex == bitmaps.size) { - nextIndex = 0 - } - binding.dataMigrationQrCodes.postDelayed(this, 200) - } - } - binding.dataMigrationQrCodes.postDelayed(runnable, 200) - } - } - } - } - - viewModel.generateQrCodes(resources.displayMetrics.widthPixels) - } -} diff --git a/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationShowQrCodeViewModel.kt b/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationShowQrCodeViewModel.kt deleted file mode 100644 index 471881d2d..000000000 --- a/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationShowQrCodeViewModel.kt +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2023 De Staat der Nederlanden, Ministerie van Volksgezondheid, Welzijn en Sport. - * Licensed under the EUROPEAN UNION PUBLIC LICENCE v. 1.2 - * - * SPDX-License-Identifier: EUPL-1.2 - */ - -package nl.rijksoverheid.ctr.holder.data_migration - -import androidx.lifecycle.LiveData -import androidx.lifecycle.MutableLiveData -import androidx.lifecycle.ViewModel -import androidx.lifecycle.viewModelScope -import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel -import java.io.IOException -import kotlinx.coroutines.launch -import nl.rijksoverheid.ctr.holder.models.HolderStep -import nl.rijksoverheid.ctr.holder.qrcodes.models.QrCodeFragmentData -import nl.rijksoverheid.ctr.holder.qrcodes.usecases.QrCodeUseCase -import nl.rijksoverheid.ctr.shared.exceptions.DataMigrationCompressionException -import nl.rijksoverheid.ctr.shared.exceptions.DataMigrationOtherException -import nl.rijksoverheid.ctr.shared.models.AppErrorResult - -abstract class DataMigrationShowQrCodeViewModel : ViewModel() { - val qrCodesLiveData: LiveData = MutableLiveData() - - abstract fun generateQrCodes(size: Int) -} - -class DataMigrationShowQrCodeViewModelImpl( - private val dataExportUseCase: DataExportUseCase, - private val qrCodeUseCase: QrCodeUseCase -) : DataMigrationShowQrCodeViewModel() { - override fun generateQrCodes(size: Int) { - viewModelScope.launch { - try { - val qrCodes = dataExportUseCase.export() - val bitmaps = qrCodes.map { - qrCodeUseCase.qrCode( - it.toByteArray(), - QrCodeFragmentData.ShouldDisclose.DoNotDisclose, - size, - size, - ErrorCorrectionLevel.M - ) - } - (qrCodesLiveData as MutableLiveData).postValue( - DataMigrationShowQrViewState.ShowQrs( - bitmaps - ) - ) - } catch (exception: Exception) { - val errorResult = AppErrorResult( - e = if (exception is IOException) { - DataMigrationCompressionException() - } else { - DataMigrationOtherException() - }, - step = HolderStep.DataMigrationExport - ) - (qrCodesLiveData as MutableLiveData).postValue( - DataMigrationShowQrViewState.ShowError( - errorResults = listOf(errorResult) - ) - ) - } - } - } -} diff --git a/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationShowQrViewState.kt b/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationShowQrViewState.kt deleted file mode 100644 index c64807598..000000000 --- a/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationShowQrViewState.kt +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2023 De Staat der Nederlanden, Ministerie van Volksgezondheid, Welzijn en Sport. - * Licensed under the EUROPEAN UNION PUBLIC LICENCE v. 1.2 - * - * SPDX-License-Identifier: EUPL-1.2 - */ - -package nl.rijksoverheid.ctr.holder.data_migration - -import android.graphics.Bitmap -import nl.rijksoverheid.ctr.shared.models.ErrorResult - -sealed class DataMigrationShowQrViewState { - data class ShowQrs(val bitmaps: List) : DataMigrationShowQrViewState() - data class ShowError(val errorResults: List) : DataMigrationShowQrViewState() -} diff --git a/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationStartFragment.kt b/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationStartFragment.kt deleted file mode 100644 index e60d096aa..000000000 --- a/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationStartFragment.kt +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2023 De Staat der Nederlanden, Ministerie van Volksgezondheid, Welzijn en Sport. - * Licensed under the EUROPEAN UNION PUBLIC LICENCE v. 1.2 - * - * SPDX-License-Identifier: EUPL-1.2 - */ - -package nl.rijksoverheid.ctr.holder.data_migration - -import android.os.Bundle -import android.view.View -import androidx.fragment.app.Fragment -import nl.rijksoverheid.ctr.holder.R -import nl.rijksoverheid.ctr.holder.databinding.FragmentDataMigrationStartTransferringBinding -import nl.rijksoverheid.ctr.shared.ext.navigateSafety -import nl.rijksoverheid.ctr.shared.livedata.EventObserver -import org.koin.androidx.viewmodel.ext.android.viewModel - -class DataMigrationStartFragment : Fragment(R.layout.fragment_data_migration_start_transferring) { - - private val viewModel: DataMigrationStartViewModel by viewModel() - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - - val binding = FragmentDataMigrationStartTransferringBinding.bind(view) - - viewModel.canTransferData.observe(viewLifecycleOwner, EventObserver { - binding.bottom.setButtonClick { - if (it) { - navigateSafety(DataMigrationStartFragmentDirections.actionDataTransferOptions()) - } else { - navigateSafety( - DataMigrationTransferOptionsFragmentDirections.actionDataMigrationInstructions( - instructionItems = transferInOnboardingItems, - destination = DataMigrationOnboardingItem.ScanQrCode - ) - ) - } - } - }) - - viewModel.canTransfer() - } -} diff --git a/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationStartViewModel.kt b/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationStartViewModel.kt deleted file mode 100644 index 4579d365c..000000000 --- a/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationStartViewModel.kt +++ /dev/null @@ -1,24 +0,0 @@ -package nl.rijksoverheid.ctr.holder.data_migration - -import androidx.lifecycle.LiveData -import androidx.lifecycle.MutableLiveData -import androidx.lifecycle.ViewModel -import androidx.lifecycle.viewModelScope -import kotlinx.coroutines.launch -import nl.rijksoverheid.ctr.shared.livedata.Event - -abstract class DataMigrationStartViewModel : ViewModel() { - val canTransferData: LiveData> = MutableLiveData() - - abstract fun canTransfer() -} - -class DataMigrationStartViewModelImpl( - private val dataMigrationUseCase: DataMigrationUseCase -) : DataMigrationStartViewModel() { - override fun canTransfer() { - viewModelScope.launch { - (canTransferData as MutableLiveData).postValue(Event(dataMigrationUseCase.canTransferData())) - } - } -} diff --git a/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationTransferOptionsFragment.kt b/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationTransferOptionsFragment.kt deleted file mode 100644 index 9c84f06ac..000000000 --- a/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationTransferOptionsFragment.kt +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2023 De Staat der Nederlanden, Ministerie van Volksgezondheid, Welzijn en Sport. - * Licensed under the EUROPEAN UNION PUBLIC LICENCE v. 1.2 - * - * SPDX-License-Identifier: EUPL-1.2 - */ - -package nl.rijksoverheid.ctr.holder.data_migration - -import android.os.Bundle -import android.view.View -import androidx.fragment.app.Fragment -import nl.rijksoverheid.ctr.holder.R -import nl.rijksoverheid.ctr.holder.databinding.FragmentDataMigrationTransferOptionsBinding -import nl.rijksoverheid.ctr.introduction.onboarding.models.OnboardingItem -import nl.rijksoverheid.ctr.shared.ext.navigateSafety - -val transferOutOnboardingItems = arrayOf( - OnboardingItem( - imageResource = R.drawable.illustration_data_migration_instructions_step_1, - titleResource = R.string.holder_startMigration_toOtherDevice_onboarding_step1_title, - description = R.string.holder_startMigration_toOtherDevice_onboarding_step1_message, - position = 1 - ), - OnboardingItem( - imageResource = R.drawable.illustration_data_migration_instructions_step_2, - titleResource = R.string.holder_startMigration_toOtherDevice_onboarding_step2_title, - description = R.string.holder_startMigration_toOtherDevice_onboarding_step2_message, - position = 2 - ), - OnboardingItem( - clazz = DataMigrationShowQrCodeFragment::class.java, - titleResource = R.string.holder_startMigration_toOtherDevice_onboarding_step3_title, - description = R.string.holder_startMigration_toOtherDevice_onboarding_step3_title, - position = 3 - ) -) - -val transferInOnboardingItems = arrayOf( - OnboardingItem( - imageResource = R.drawable.illustration_data_migration_instructions_step_1, - titleResource = R.string.holder_startMigration_toThisDevice_onboarding_step1_title, - description = R.string.holder_startMigration_toThisDevice_onboarding_step1_message, - position = 1 - ), - OnboardingItem( - imageResource = R.drawable.illustration_data_migration_instructions_step_2, - titleResource = R.string.holder_startMigration_toThisDevice_onboarding_step2_title, - description = R.string.holder_startMigration_toThisDevice_onboarding_step2_message, - position = 2 - ) -) - -class DataMigrationTransferOptionsFragment : Fragment(R.layout.fragment_data_migration_transfer_options) { - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - - val binding = FragmentDataMigrationTransferOptionsBinding.bind(view) - - binding.transferOutButton.transferOptionsButtonTitle.text = getString(R.string.holder_startMigration_option_toOtherDevice_title) - binding.transferOutButton.transferOptionsButtonIcon.setImageResource(R.drawable.illustration_data_migration_transfer_out) - binding.transferInButton.transferOptionsButtonTitle.text = getString(R.string.holder_startMigration_option_toThisDevice_title) - binding.transferInButton.transferOptionsButtonIcon.setImageResource(R.drawable.illustration_data_migration_transfer_in) - - binding.transferOutButton.root.setOnClickListener { - navigateSafety( - DataMigrationTransferOptionsFragmentDirections.actionDataMigrationInstructions( - instructionItems = transferOutOnboardingItems, - destination = DataMigrationOnboardingItem.ShowQrCode - ) - ) - } - - binding.transferInButton.root.setOnClickListener { - navigateSafety( - DataMigrationTransferOptionsFragmentDirections.actionDataMigrationInstructions( - instructionItems = transferInOnboardingItems, - destination = DataMigrationOnboardingItem.ScanQrCode - ) - ) - } - } -} diff --git a/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationUseCase.kt b/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationUseCase.kt deleted file mode 100644 index 010ea70e1..000000000 --- a/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationUseCase.kt +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2023 De Staat der Nederlanden, Ministerie van Volksgezondheid, Welzijn en Sport. - * Licensed under the EUROPEAN UNION PUBLIC LICENCE v. 1.2 - * - * SPDX-License-Identifier: EUPL-1.2 - */ -package nl.rijksoverheid.ctr.holder.data_migration - -import nl.rijksoverheid.ctr.persistence.database.HolderDatabase - -interface DataMigrationUseCase { - suspend fun canTransferData(): Boolean -} - -class DataMigrationUseCaseImpl( - private val holderDatabase: HolderDatabase -) : DataMigrationUseCase { - - override suspend fun canTransferData(): Boolean { - val events = holderDatabase.eventGroupDao().getAll().filter { !it.draft } - return events.isNotEmpty() - } -} diff --git a/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/EventGroupParcel.kt b/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/EventGroupParcel.kt deleted file mode 100644 index 628dfcdb4..000000000 --- a/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/EventGroupParcel.kt +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2023 De Staat der Nederlanden, Ministerie van Volksgezondheid, Welzijn en Sport. - * Licensed under the EUROPEAN UNION PUBLIC LICENCE v. 1.2 - * - * SPDX-License-Identifier: EUPL-1.2 - * - */ -package nl.rijksoverheid.ctr.holder.data_migration - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -data class EventGroupParcel( - @Json(name = "d") val jsonData: ByteArray -) diff --git a/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/MigrationParcel.kt b/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/MigrationParcel.kt deleted file mode 100644 index 915ac8680..000000000 --- a/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/MigrationParcel.kt +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2023 De Staat der Nederlanden, Ministerie van Volksgezondheid, Welzijn en Sport. - * Licensed under the EUROPEAN UNION PUBLIC LICENCE v. 1.2 - * - * SPDX-License-Identifier: EUPL-1.2 - * - */ -package nl.rijksoverheid.ctr.holder.data_migration - -import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -data class MigrationParcel( - @Json(name = "i") val index: Int, - @Json(name = "n") val numberOfPackages: Int, - @Json(name = "p") val payload: String, - @Json(name = "v") val version: String -) diff --git a/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/StringDataZipper.kt b/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/StringDataZipper.kt deleted file mode 100644 index 287b555c6..000000000 --- a/holder/src/main/java/nl/rijksoverheid/ctr/holder/data_migration/StringDataZipper.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2023 De Staat der Nederlanden, Ministerie van Volksgezondheid, Welzijn en Sport. - * Licensed under the EUROPEAN UNION PUBLIC LICENCE v. 1.2 - * - * SPDX-License-Identifier: EUPL-1.2 - * - */ -package nl.rijksoverheid.ctr.holder.data_migration - -import java.io.ByteArrayOutputStream -import java.nio.charset.StandardCharsets.UTF_8 -import java.util.zip.GZIPInputStream -import java.util.zip.GZIPOutputStream - -interface StringDataZipper { - fun zip(data: String): ByteArray - fun unzip(data: ByteArray): String -} - -class StringDataZipperImpl : StringDataZipper { - override fun zip(data: String): ByteArray { - val bos = ByteArrayOutputStream() - GZIPOutputStream(bos).bufferedWriter(UTF_8).use { it.write(data) } - return bos.toByteArray() - } - - override fun unzip(data: ByteArray): String = - GZIPInputStream(data.inputStream()).bufferedReader(UTF_8).use { it.readText() } -} diff --git a/holder/src/main/java/nl/rijksoverheid/ctr/holder/menu/MenuViewModel.kt b/holder/src/main/java/nl/rijksoverheid/ctr/holder/menu/MenuViewModel.kt index c560d374e..46fc04f52 100644 --- a/holder/src/main/java/nl/rijksoverheid/ctr/holder/menu/MenuViewModel.kt +++ b/holder/src/main/java/nl/rijksoverheid/ctr/holder/menu/MenuViewModel.kt @@ -31,9 +31,7 @@ class MenuViewModelImpl( private fun menuSections(context: Context): Array { val actionExportIntroduction = MenuFragmentDirections.actionExportIntroduction() val actionChooseProofType = MenuFragmentDirections.actionChooseProofType() - val actionPaperProof = MenuFragmentDirections.actionPaperProof() val actionSavedEvents = MenuFragmentDirections.actionSavedEvents() - val actionDataMigration = MenuFragmentDirections.actionDataMigration() val actionHelpInfo = MenuFragmentDirections.actionMenu( toolbarTitle = context.getString(R.string.holder_helpInfo_title), menuSections = helpMenuDataModel.get(context) @@ -56,16 +54,6 @@ class MenuViewModelImpl( ) ) - val addPaperProofMenuItem = MenuSection.MenuItem( - icon = R.drawable.ic_menu_paper, - title = R.string.holder_menu_paperproof_title, - subtitle = R.string.holder_menu_paperproof_subTitle, - onClick = MenuSection.MenuItem.OnClick.Navigate( - navigationActionId = actionPaperProof.actionId, - navigationArguments = actionPaperProof.arguments - ) - ) - val savedEventsMenuItem = MenuSection.MenuItem( icon = R.drawable.ic_menu_saved_events, title = R.string.holder_menu_storedEvents, @@ -74,15 +62,6 @@ class MenuViewModelImpl( ) ) - val dataMigrationMenuItem = MenuSection.MenuItem( - icon = R.drawable.ic_menu_data_migration, - iconColor = -1, - title = R.string.holder_menu_migration, - onClick = MenuSection.MenuItem.OnClick.Navigate( - navigationActionId = actionDataMigration.actionId - ) - ) - val helpInfoMenuItem = MenuSection.MenuItem( icon = R.drawable.ic_menu_info, title = R.string.holder_menu_helpInfo, @@ -102,11 +81,6 @@ class MenuViewModelImpl( addVaccinationOrTestMenuItem } else { null - }, - if (featureFlagUseCase.getScanCertificateButtonEnabled()) { - addPaperProofMenuItem - } else { - null } ) @@ -120,11 +94,6 @@ class MenuViewModelImpl( null } else { savedEventsMenuItem - }, - if (featureFlagUseCase.getMigrateButtonEnabled()) { - dataMigrationMenuItem - } else { - null } ) ), diff --git a/holder/src/main/java/nl/rijksoverheid/ctr/holder/modules/EventsUseCasesModule.kt b/holder/src/main/java/nl/rijksoverheid/ctr/holder/modules/EventsUseCasesModule.kt index c0ed88b24..bf1f1376f 100644 --- a/holder/src/main/java/nl/rijksoverheid/ctr/holder/modules/EventsUseCasesModule.kt +++ b/holder/src/main/java/nl/rijksoverheid/ctr/holder/modules/EventsUseCasesModule.kt @@ -3,14 +3,6 @@ package nl.rijksoverheid.ctr.holder.modules import java.time.Clock import nl.rijksoverheid.ctr.holder.dashboard.usecases.ShowBlockedEventsDialogUseCase import nl.rijksoverheid.ctr.holder.dashboard.usecases.ShowBlockedEventsDialogUseCaseImpl -import nl.rijksoverheid.ctr.holder.data_migration.DataExportUseCase -import nl.rijksoverheid.ctr.holder.data_migration.DataExportUseCaseImpl -import nl.rijksoverheid.ctr.holder.data_migration.DataMigrationImportUseCase -import nl.rijksoverheid.ctr.holder.data_migration.DataMigrationImportUseCaseImpl -import nl.rijksoverheid.ctr.holder.data_migration.DataMigrationPayloadUseCase -import nl.rijksoverheid.ctr.holder.data_migration.DataMigrationPayloadUseCaseImpl -import nl.rijksoverheid.ctr.holder.data_migration.DataMigrationUseCase -import nl.rijksoverheid.ctr.holder.data_migration.DataMigrationUseCaseImpl import nl.rijksoverheid.ctr.holder.get_events.usecases.GetEventProvidersWithTokensUseCase import nl.rijksoverheid.ctr.holder.get_events.usecases.GetEventProvidersWithTokensUseCaseImpl import nl.rijksoverheid.ctr.holder.get_events.usecases.GetEventsUseCase @@ -95,10 +87,6 @@ val eventsUseCasesModule = module { factory { PersistBlockedEventsUseCaseImpl(get()) } factory { ShowBlockedEventsDialogUseCaseImpl(get()) } factory { DraftEventUseCaseImpl(get()) } - factory { DataMigrationUseCaseImpl(get()) } - factory { DataExportUseCaseImpl(get(), get(), get()) } - factory { DataMigrationImportUseCaseImpl(get(), get()) } - factory { DataMigrationPayloadUseCaseImpl(get(), get()) } factory { PrintExportDccUseCaseImpl(get(), get(), get()) } factory { PreviewPdfUseCaseImpl() } } diff --git a/holder/src/main/java/nl/rijksoverheid/ctr/holder/modules/UtilsModule.kt b/holder/src/main/java/nl/rijksoverheid/ctr/holder/modules/UtilsModule.kt index 32aa8aacc..5849f3547 100644 --- a/holder/src/main/java/nl/rijksoverheid/ctr/holder/modules/UtilsModule.kt +++ b/holder/src/main/java/nl/rijksoverheid/ctr/holder/modules/UtilsModule.kt @@ -21,8 +21,6 @@ import nl.rijksoverheid.ctr.holder.dashboard.util.OriginUtil import nl.rijksoverheid.ctr.holder.dashboard.util.OriginUtilImpl import nl.rijksoverheid.ctr.holder.dashboard.util.RemovedEventsBottomSheetUtil import nl.rijksoverheid.ctr.holder.dashboard.util.RemovedEventsBottomSheetUtilImpl -import nl.rijksoverheid.ctr.holder.data_migration.StringDataZipper -import nl.rijksoverheid.ctr.holder.data_migration.StringDataZipperImpl import nl.rijksoverheid.ctr.holder.get_events.utils.LoginTypeUtil import nl.rijksoverheid.ctr.holder.get_events.utils.LoginTypeUtilImpl import nl.rijksoverheid.ctr.holder.get_events.utils.ScopeUtil @@ -129,5 +127,4 @@ val utilsModule = module { factory { StringUtilImpl(get()) } factory { YourEventsEndStateUtilImpl(get()) } factory { RemovedEventsBottomSheetUtilImpl(get(), get(), get(), get(), get(), get()) } - factory { StringDataZipperImpl() } } diff --git a/holder/src/main/java/nl/rijksoverheid/ctr/holder/modules/ViewModels.kt b/holder/src/main/java/nl/rijksoverheid/ctr/holder/modules/ViewModels.kt index e5f71ca1c..6f205ae61 100644 --- a/holder/src/main/java/nl/rijksoverheid/ctr/holder/modules/ViewModels.kt +++ b/holder/src/main/java/nl/rijksoverheid/ctr/holder/modules/ViewModels.kt @@ -5,12 +5,6 @@ import nl.rijksoverheid.ctr.holder.HolderMainActivityViewModel import nl.rijksoverheid.ctr.holder.HolderMainActivityViewModelImpl import nl.rijksoverheid.ctr.holder.dashboard.DashboardViewModel import nl.rijksoverheid.ctr.holder.dashboard.DashboardViewModelImpl -import nl.rijksoverheid.ctr.holder.data_migration.DataMigrationScanQrViewModel -import nl.rijksoverheid.ctr.holder.data_migration.DataMigrationScanQrViewModelImpl -import nl.rijksoverheid.ctr.holder.data_migration.DataMigrationShowQrCodeViewModel -import nl.rijksoverheid.ctr.holder.data_migration.DataMigrationShowQrCodeViewModelImpl -import nl.rijksoverheid.ctr.holder.data_migration.DataMigrationStartViewModel -import nl.rijksoverheid.ctr.holder.data_migration.DataMigrationStartViewModelImpl import nl.rijksoverheid.ctr.holder.get_events.GetEventsViewModel import nl.rijksoverheid.ctr.holder.get_events.GetEventsViewModelImpl import nl.rijksoverheid.ctr.holder.get_events.LoginViewModel @@ -18,10 +12,6 @@ import nl.rijksoverheid.ctr.holder.input_token.InputTokenViewModel import nl.rijksoverheid.ctr.holder.input_token.InputTokenViewModelImpl import nl.rijksoverheid.ctr.holder.menu.MenuViewModelImpl import nl.rijksoverheid.ctr.holder.modules.qualifier.LoginQualifier -import nl.rijksoverheid.ctr.holder.paper_proof.PaperProofDomesticInputCodeViewModel -import nl.rijksoverheid.ctr.holder.paper_proof.PaperProofDomesticInputCodeViewModelImpl -import nl.rijksoverheid.ctr.holder.paper_proof.PaperProofQrScannerViewModel -import nl.rijksoverheid.ctr.holder.paper_proof.PaperProofQrScannerViewModelImpl import nl.rijksoverheid.ctr.holder.pdf.PdfPreviewViewModel import nl.rijksoverheid.ctr.holder.pdf.PdfPreviewViewModelImpl import nl.rijksoverheid.ctr.holder.pdf.PdfWebViewModel @@ -65,16 +55,11 @@ val viewModels = module { viewModel { DeviceSecureViewModelImpl(get(), get()) } viewModel { YourEventsViewModelImpl(get(), get(), get()) } viewModel { GetEventsViewModelImpl(get(), get(), get()) } - viewModel { PaperProofDomesticInputCodeViewModelImpl(get(), get()) } - viewModel { PaperProofQrScannerViewModelImpl(get()) } viewModel { DashboardViewModelImpl(get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get()) } viewModel { SyncGreenCardsViewModelImpl(get(), get()) } viewModel { SavedEventsViewModel(get(), get()) } viewModel { MenuViewModelImpl(get(), get()) } viewModel { PriorityNotificationViewModelImpl(get()) } - viewModel { DataMigrationStartViewModelImpl(get()) } - viewModel { DataMigrationShowQrCodeViewModelImpl(get(), get()) } - viewModel { DataMigrationScanQrViewModelImpl(get(), get(), get()) } viewModel { PdfWebViewModelImpl(androidContext().filesDir.path, get(), get()) } viewModel { PdfPreviewViewModelImpl(get()) } } diff --git a/holder/src/main/java/nl/rijksoverheid/ctr/holder/paper_proof/PaperProofDomesticInputCodeFragment.kt b/holder/src/main/java/nl/rijksoverheid/ctr/holder/paper_proof/PaperProofDomesticInputCodeFragment.kt deleted file mode 100644 index b3a7a1a9f..000000000 --- a/holder/src/main/java/nl/rijksoverheid/ctr/holder/paper_proof/PaperProofDomesticInputCodeFragment.kt +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (c) 2021 De Staat der Nederlanden, Ministerie van Volksgezondheid, Welzijn en Sport. - * Licensed under the EUROPEAN UNION PUBLIC LICENCE v. 1.2 - * - * SPDX-License-Identifier: EUPL-1.2 - * - */ - -package nl.rijksoverheid.ctr.holder.paper_proof - -import android.os.Bundle -import android.view.View -import androidx.navigation.fragment.navArgs -import nl.rijksoverheid.ctr.design.fragments.info.ButtonData -import nl.rijksoverheid.ctr.design.fragments.info.DescriptionData -import nl.rijksoverheid.ctr.design.fragments.info.InfoFragmentData -import nl.rijksoverheid.ctr.design.utils.InfoFragmentUtil -import nl.rijksoverheid.ctr.holder.BaseFragment -import nl.rijksoverheid.ctr.holder.HolderMainFragment -import nl.rijksoverheid.ctr.holder.R -import nl.rijksoverheid.ctr.holder.databinding.FragmentPaperProofDomesticInputCodeBinding -import nl.rijksoverheid.ctr.holder.models.HolderFlow -import nl.rijksoverheid.ctr.holder.paper_proof.models.PaperProofDomesticCodeResult -import nl.rijksoverheid.ctr.holder.paper_proof.models.PaperProofDomesticResult -import nl.rijksoverheid.ctr.holder.your_events.YourEventsFragmentType -import nl.rijksoverheid.ctr.persistence.database.entities.OriginType -import nl.rijksoverheid.ctr.shared.ext.findNavControllerSafety -import nl.rijksoverheid.ctr.shared.ext.hideKeyboard -import nl.rijksoverheid.ctr.shared.ext.showKeyboard -import nl.rijksoverheid.ctr.shared.livedata.EventObserver -import nl.rijksoverheid.ctr.shared.models.ErrorResultFragmentData -import nl.rijksoverheid.ctr.shared.models.Flow -import org.koin.android.ext.android.inject -import org.koin.androidx.viewmodel.ext.android.stateViewModel -import org.koin.androidx.viewmodel.scope.emptyState - -class PaperProofDomesticInputCodeFragment : BaseFragment(R.layout.fragment_paper_proof_domestic_input_code) { - - private var _binding: FragmentPaperProofDomesticInputCodeBinding? = null - private val binding get() = _binding!! - private val args: PaperProofDomesticInputCodeFragmentArgs by navArgs() - private val infoFragmentUtil: InfoFragmentUtil by inject() - - private val viewModel: PaperProofDomesticInputCodeViewModel by stateViewModel( - state = emptyState() - ) - - override fun onButtonClickWithRetryAction() { - viewModel.validateProof( - qrContent = args.qrContent, - couplingCode = binding.codeInputText.text.toString() - ) - } - - override fun getFlow(): Flow { - return HolderFlow.HkviScan - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - - _binding = FragmentPaperProofDomesticInputCodeBinding.bind(view) - showKeyboard(binding.codeInputText) - - viewModel.loading.observe(viewLifecycleOwner) { - (parentFragment?.parentFragment as HolderMainFragment).presentLoading(it) - binding.bottom.setButtonEnabled(!it) - } - - viewModel.validateCodeLiveData.observe(viewLifecycleOwner, EventObserver { - when (it) { - is PaperProofDomesticCodeResult.Valid -> { - onButtonClickWithRetryAction() - } - is PaperProofDomesticCodeResult.Empty -> { - binding.codeInput.error = - getString(R.string.add_paper_proof_input_empty) - binding.codeInput.isErrorEnabled = true - binding.codeInput.setErrorIconDrawable(R.drawable.ic_error) - } - is PaperProofDomesticCodeResult.Invalid -> { - binding.codeInput.error = - getString(R.string.add_paper_proof_input_invalid) - binding.codeInput.isErrorEnabled = true - binding.codeInput.setErrorIconDrawable(R.drawable.ic_error) - } - } - }) - - viewModel.validateProofLiveData.observe(viewLifecycleOwner, EventObserver { - when (it) { - is PaperProofDomesticResult.Valid -> { - findNavControllerSafety()?.navigate(PaperProofDomesticInputCodeFragmentDirections.actionYourEvents( - toolbarTitle = getString(R.string.your_dcc_event_toolbar_title), - type = YourEventsFragmentType.DCC( - remoteEvent = it.remoteEvent, - eventGroupJsonData = it.eventGroupJsonData, - originType = OriginType.fromTypeString(it.remoteEvent.events!!.first().type!!) - ), - flow = HolderFlow.HkviScanned(it.remoteEvent) - )) - } - is PaperProofDomesticResult.Invalid.BlockedQr -> { - presentError( - data = ErrorResultFragmentData( - title = getString(R.string.add_paper_proof_limit_reached_paper_proof_title), - description = getString(R.string.add_paper_proof_limit_reached_paper_proof_description), - buttonTitle = getString(R.string.back_to_overview), - ErrorResultFragmentData.ButtonAction.Destination(R.id.action_my_overview) - ) - ) - } - is PaperProofDomesticResult.Invalid.RejectedQr -> { - presentError( - data = ErrorResultFragmentData( - title = getString(R.string.add_paper_proof_invalid_combination_title), - description = getString(R.string.add_paper_proof_invalid_combination_), - buttonTitle = getString(R.string.back_to_overview), - ErrorResultFragmentData.ButtonAction.Destination(R.id.action_my_overview) - ) - ) - } - is PaperProofDomesticResult.Invalid.Error -> { - presentError( - errorResult = it.errorResult - ) - } - } - }) - - binding.noLetterCombinationBtn.setOnClickListener { - infoFragmentUtil.presentFullScreen( - currentFragment = this, - toolbarTitle = getString(R.string.add_paper_proof_title), - data = InfoFragmentData.TitleDescriptionWithButton( - title = getString(R.string.no_letter_combination_dialog_title), - descriptionData = DescriptionData(R.string.no_letter_combination_dialog_description), - secondaryButtonData = ButtonData.NavigationButton( - text = getString(R.string.add_paper_proof_self_printed_goto_add_proof_button), - navigationActionId = R.id.action_choose_proof_type - ) - ) - ) - } - - binding.bottom.setButtonClick { - binding.codeInput.error = null - viewModel.validateCode(binding.codeInputText.text.toString()) - } - } - - override fun onDestroyView() { - super.onDestroyView() - (parentFragment?.parentFragment as? HolderMainFragment)?.presentLoading(false) - _binding = null - } - - override fun onPause() { - super.onPause() - hideKeyboard() - } -} diff --git a/holder/src/main/java/nl/rijksoverheid/ctr/holder/paper_proof/PaperProofDomesticInputCodeViewModel.kt b/holder/src/main/java/nl/rijksoverheid/ctr/holder/paper_proof/PaperProofDomesticInputCodeViewModel.kt deleted file mode 100644 index e7d1a6067..000000000 --- a/holder/src/main/java/nl/rijksoverheid/ctr/holder/paper_proof/PaperProofDomesticInputCodeViewModel.kt +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2021 De Staat der Nederlanden, Ministerie van Volksgezondheid, Welzijn en Sport. - * Licensed under the EUROPEAN UNION PUBLIC LICENCE v. 1.2 - * - * SPDX-License-Identifier: EUPL-1.2 - * - */ - -package nl.rijksoverheid.ctr.holder.paper_proof - -import androidx.lifecycle.LiveData -import androidx.lifecycle.MutableLiveData -import androidx.lifecycle.ViewModel -import androidx.lifecycle.viewModelScope -import kotlinx.coroutines.launch -import nl.rijksoverheid.ctr.holder.paper_proof.models.PaperProofDomesticCodeResult -import nl.rijksoverheid.ctr.holder.paper_proof.models.PaperProofDomesticResult -import nl.rijksoverheid.ctr.holder.paper_proof.usecases.ValidatePaperProofDomesticInputCodeUseCase -import nl.rijksoverheid.ctr.holder.paper_proof.usecases.ValidatePaperProofDomesticUseCase -import nl.rijksoverheid.ctr.shared.livedata.Event - -abstract class PaperProofDomesticInputCodeViewModel : ViewModel() { - val loading: LiveData = MutableLiveData() - val validateCodeLiveData: LiveData> = MutableLiveData() - val validateProofLiveData: LiveData> = MutableLiveData() - - abstract fun validateCode(code: String) - abstract fun validateProof(qrContent: String, couplingCode: String) -} - -class PaperProofDomesticInputCodeViewModelImpl( - private val validatePaperProofDomesticInputCodeUseCase: ValidatePaperProofDomesticInputCodeUseCase, - private val validatePaperProofDomesticUseCase: ValidatePaperProofDomesticUseCase -) : PaperProofDomesticInputCodeViewModel() { - - override fun validateCode(code: String) { - val result = validatePaperProofDomesticInputCodeUseCase.validate(code) - (validateCodeLiveData as MutableLiveData).postValue(Event(result)) - } - - override fun validateProof(qrContent: String, couplingCode: String) { - viewModelScope.launch { - (loading as MutableLiveData).postValue(true) - val result = validatePaperProofDomesticUseCase.validate( - qrContent = qrContent, - couplingCode = couplingCode - ) - (validateProofLiveData as MutableLiveData).postValue(Event(result)) - loading.postValue(false) - } - } -} diff --git a/holder/src/main/java/nl/rijksoverheid/ctr/holder/paper_proof/PaperProofQrScannerFragment.kt b/holder/src/main/java/nl/rijksoverheid/ctr/holder/paper_proof/PaperProofQrScannerFragment.kt deleted file mode 100644 index 2d1ad9937..000000000 --- a/holder/src/main/java/nl/rijksoverheid/ctr/holder/paper_proof/PaperProofQrScannerFragment.kt +++ /dev/null @@ -1,112 +0,0 @@ -package nl.rijksoverheid.ctr.holder.paper_proof - -import android.os.Bundle -import android.view.View -import nl.rijksoverheid.ctr.design.fragments.info.ButtonData -import nl.rijksoverheid.ctr.design.fragments.info.DescriptionData -import nl.rijksoverheid.ctr.design.fragments.info.InfoFragmentData -import nl.rijksoverheid.ctr.holder.HolderMainActivityViewModel -import nl.rijksoverheid.ctr.holder.R -import nl.rijksoverheid.ctr.holder.models.HolderFlow -import nl.rijksoverheid.ctr.holder.paper_proof.models.PaperProofType -import nl.rijksoverheid.ctr.holder.your_events.YourEventsFragmentType -import nl.rijksoverheid.ctr.persistence.database.entities.OriginType -import nl.rijksoverheid.ctr.qrscanner.QrCodeScannerFragment -import nl.rijksoverheid.ctr.shared.ext.findNavControllerSafety -import nl.rijksoverheid.ctr.shared.livedata.EventObserver -import org.koin.androidx.viewmodel.ext.android.sharedViewModel -import org.koin.androidx.viewmodel.ext.android.viewModel - -class PaperProofQrScannerFragment : QrCodeScannerFragment() { - - private val holderMainActivityViewModel: HolderMainActivityViewModel by sharedViewModel() - private val paperProofScannerViewModel: PaperProofQrScannerViewModel by viewModel() - - override fun onQrScanned(content: String) { - paperProofScannerViewModel.getType( - qrContent = content - ) - } - - override fun getCopy(): Copy { - return Copy( - title = getString(R.string.add_paper_proof_qr_scanner_title), - message = getString(R.string.add_paper_proof_qr_scanner_text), - rationaleDialog = Copy.RationaleDialog( - title = R.string.camera_rationale_dialog_title, - description = getString(R.string.camera_rationale_dialog_description), - okayButtonText = R.string.ok - ) - ) - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - - paperProofScannerViewModel.loadingLiveData.observe(viewLifecycleOwner, EventObserver { - binding.progress.visibility = if (it) View.VISIBLE else View.GONE - }) - - paperProofScannerViewModel.paperProofTypeLiveData.observe( - viewLifecycleOwner, - EventObserver { paperProofType -> - findNavControllerSafety()?.popBackStack() - when (paperProofType) { - is PaperProofType.DCC.Dutch -> { - holderMainActivityViewModel.navigate( - navDirections = PaperProofStartScanningFragmentDirections.actionPaperProofCode( - paperProofType.qrContent - ), - delayMillis = resources.getInteger(android.R.integer.config_mediumAnimTime) - .toLong() - ) - } - is PaperProofType.DCC.Foreign -> { - holderMainActivityViewModel.navigate( - navDirections = PaperProofStartScanningFragmentDirections.actionYourEvents( - toolbarTitle = getString(R.string.your_dcc_event_toolbar_title), - type = YourEventsFragmentType.DCC( - remoteEvent = paperProofType.remoteProtocol, - eventGroupJsonData = paperProofType.eventGroupJsonData, - originType = OriginType.fromTypeString(paperProofType.remoteProtocol.events!!.first().type!!) - ), - flow = HolderFlow.HkviScanned(paperProofType.remoteProtocol) - ) - ) - } - is PaperProofType.CTB -> { - scanAgain( - title = getString(R.string.holder_scanner_error_title_ctb), - description = getString(R.string.holder_scanner_error_message_ctb), - buttonText = getString(R.string.holder_scanner_error_action) - ) - } - is PaperProofType.Unknown -> { - scanAgain( - title = getString(R.string.holder_scanner_error_title_unknown), - description = getString(R.string.holder_scanner_error_message_unknown), - buttonText = getString(R.string.holder_scanner_error_action) - ) - } - } - }) - } - - private fun scanAgain(title: String, description: String, buttonText: String) { - holderMainActivityViewModel.navigate( - PaperProofStartScanningFragmentDirections.actionInfoFragment( - toolbarTitle = "", - data = InfoFragmentData.TitleDescriptionWithButton( - title = title, - descriptionData = DescriptionData( - htmlTextString = description - ), - primaryButtonData = ButtonData.NavigationButton( - text = buttonText, - navigationActionId = R.id.action_paper_proof_start_scanning - ) - ) - ) - ) - } -} diff --git a/holder/src/main/java/nl/rijksoverheid/ctr/holder/paper_proof/PaperProofQrScannerViewModel.kt b/holder/src/main/java/nl/rijksoverheid/ctr/holder/paper_proof/PaperProofQrScannerViewModel.kt deleted file mode 100644 index c2f710d22..000000000 --- a/holder/src/main/java/nl/rijksoverheid/ctr/holder/paper_proof/PaperProofQrScannerViewModel.kt +++ /dev/null @@ -1,33 +0,0 @@ -package nl.rijksoverheid.ctr.holder.paper_proof - -import androidx.lifecycle.MutableLiveData -import androidx.lifecycle.ViewModel -import androidx.lifecycle.viewModelScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch -import nl.rijksoverheid.ctr.holder.paper_proof.models.PaperProofType -import nl.rijksoverheid.ctr.holder.paper_proof.usecases.GetPaperProofTypeUseCase -import nl.rijksoverheid.ctr.shared.livedata.Event - -abstract class PaperProofQrScannerViewModel : ViewModel() { - val loadingLiveData = MutableLiveData>() - val paperProofTypeLiveData = MutableLiveData>() - - abstract fun getType(qrContent: String) -} - -class PaperProofQrScannerViewModelImpl( - private val getPaperProofTypeUseCase: GetPaperProofTypeUseCase -) : PaperProofQrScannerViewModel() { - - override fun getType(qrContent: String) { - viewModelScope.launch(Dispatchers.IO) { - loadingLiveData.postValue(Event(true)) - val result = getPaperProofTypeUseCase.get( - qrContent = qrContent - ) - paperProofTypeLiveData.postValue(Event(result)) - loadingLiveData.postValue(Event(false)) - } - } -} diff --git a/holder/src/main/java/nl/rijksoverheid/ctr/holder/paper_proof/PaperProofStartScanningFragment.kt b/holder/src/main/java/nl/rijksoverheid/ctr/holder/paper_proof/PaperProofStartScanningFragment.kt deleted file mode 100644 index 86b9af7c4..000000000 --- a/holder/src/main/java/nl/rijksoverheid/ctr/holder/paper_proof/PaperProofStartScanningFragment.kt +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2021 De Staat der Nederlanden, Ministerie van Volksgezondheid, Welzijn en Sport. - * Licensed under the EUROPEAN UNION PUBLIC LICENCE v. 1.2 - * - * SPDX-License-Identifier: EUPL-1.2 - */ - -package nl.rijksoverheid.ctr.holder.paper_proof - -import android.content.Context -import android.hardware.camera2.CameraAccessException -import android.hardware.camera2.CameraManager -import android.os.Bundle -import android.view.View -import androidx.fragment.app.Fragment -import androidx.navigation.Navigation -import nl.rijksoverheid.ctr.design.fragments.ErrorResultFragment -import nl.rijksoverheid.ctr.design.fragments.info.DescriptionData -import nl.rijksoverheid.ctr.design.fragments.info.InfoFragmentData -import nl.rijksoverheid.ctr.design.utils.InfoFragmentUtil -import nl.rijksoverheid.ctr.holder.HolderMainActivityViewModel -import nl.rijksoverheid.ctr.holder.R -import nl.rijksoverheid.ctr.holder.databinding.FragmentPaperProofStartScanningBinding -import nl.rijksoverheid.ctr.shared.ext.findNavControllerSafety -import nl.rijksoverheid.ctr.shared.livedata.EventObserver -import nl.rijksoverheid.ctr.shared.models.ErrorResultFragmentData -import org.koin.android.ext.android.inject -import org.koin.androidx.viewmodel.ext.android.sharedViewModel - -class PaperProofStartScanningFragment : Fragment(R.layout.fragment_paper_proof_start_scanning) { - - private val holderMainActivityViewModel: HolderMainActivityViewModel by sharedViewModel() - private val infoFragmentUtil: InfoFragmentUtil by inject() - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - val binding = FragmentPaperProofStartScanningBinding.bind(view) - - holderMainActivityViewModel.navigateLiveData.observe(viewLifecycleOwner, EventObserver { - findNavControllerSafety()?.navigate(it) - }) - - binding.button.setOnClickListener { - infoFragmentUtil.presentAsBottomSheet( - fragmentManager = childFragmentManager, - data = InfoFragmentData.TitleDescription( - title = getString(R.string.holder_paperproof_whichProofsCanBeUsed_title), - descriptionData = DescriptionData( - htmlText = R.string.holder_paperproof_whichProofsCanBeUsed_body - ) - ) - ) - } - - binding.bottom.setButtonClick { - openScanner() - } - } - - private fun openScanner() { - try { - val cameraManager = - requireActivity().getSystemService(Context.CAMERA_SERVICE) as CameraManager - if (cameraManager.cameraIdList.isNotEmpty()) { - Navigation.findNavController(requireActivity(), R.id.main_nav_host_fragment) - .navigate(R.id.action_paper_proof_qr_scanner) - } else { - showNoCameraError() - } - } catch (exception: CameraAccessException) { - showNoCameraError() - } - } - - private fun showNoCameraError() { - findNavControllerSafety()?.navigate( - R.id.action_error_result, - ErrorResultFragment.getBundle( - ErrorResultFragmentData( - title = getString(R.string.add_paper_proof_no_camera_error_header), - description = getString(R.string.add_paper_proof_no_camera_error_description), - buttonTitle = getString(R.string.back_to_overview), - buttonAction = ErrorResultFragmentData.ButtonAction.Destination(R.id.action_my_overview) - ) - ) - ) - } -} diff --git a/holder/src/main/res/navigation/holder_nav_graph_main.xml b/holder/src/main/res/navigation/holder_nav_graph_main.xml index d71bb0b0b..e70cbcb8f 100644 --- a/holder/src/main/res/navigation/holder_nav_graph_main.xml +++ b/holder/src/main/res/navigation/holder_nav_graph_main.xml @@ -249,64 +249,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 8108816c3945c9a1f48e04559821717a2d9bc613 Mon Sep 17 00:00:00 2001 From: Giorgos Papadopoulos Date: Mon, 31 Jul 2023 09:59:37 +0200 Subject: [PATCH 2/2] update tests from removing camera related features --- .../DataExportUseCaseImplTest.kt | 46 ----- .../DataMigrationImportUseCaseImplTest.kt | 43 ---- .../DataMigrationPayloadUseCaseImplTest.kt | 68 ------- .../DataMigrationScanQrViewModelImplTest.kt | 192 ------------------ ...ataMigrationShowQrCodeViewModelImplTest.kt | 71 ------- .../DataMigrationUseCaseImplTest.kt | 43 ---- .../data_migration/ProgressBarStateTests.kt | 16 -- .../ctr/holder/menu/MenuViewModelImplTest.kt | 34 +--- .../PaperProofQrScannerFragmentTest.kt | 49 ----- 9 files changed, 10 insertions(+), 552 deletions(-) delete mode 100644 holder/src/test/java/nl/rijksoverheid/ctr/holder/data_migration/DataExportUseCaseImplTest.kt delete mode 100644 holder/src/test/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationImportUseCaseImplTest.kt delete mode 100644 holder/src/test/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationPayloadUseCaseImplTest.kt delete mode 100644 holder/src/test/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationScanQrViewModelImplTest.kt delete mode 100644 holder/src/test/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationShowQrCodeViewModelImplTest.kt delete mode 100644 holder/src/test/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationUseCaseImplTest.kt delete mode 100644 holder/src/test/java/nl/rijksoverheid/ctr/holder/data_migration/ProgressBarStateTests.kt delete mode 100644 holder/src/test/java/nl/rijksoverheid/ctr/holder/paper_proof/PaperProofQrScannerFragmentTest.kt diff --git a/holder/src/test/java/nl/rijksoverheid/ctr/holder/data_migration/DataExportUseCaseImplTest.kt b/holder/src/test/java/nl/rijksoverheid/ctr/holder/data_migration/DataExportUseCaseImplTest.kt deleted file mode 100644 index 1ec499f8e..000000000 --- a/holder/src/test/java/nl/rijksoverheid/ctr/holder/data_migration/DataExportUseCaseImplTest.kt +++ /dev/null @@ -1,46 +0,0 @@ -package nl.rijksoverheid.ctr.holder.data_migration - -import com.squareup.moshi.Moshi -import io.mockk.coEvery -import io.mockk.mockk -import kotlinx.coroutines.test.runTest -import nl.rijksoverheid.ctr.persistence.database.HolderDatabase -import nl.rijksoverheid.ctr.persistence.database.entities.EventGroupEntity -import nl.rijksoverheid.ctr.persistence.database.entities.OriginType -import org.junit.Assert.assertEquals -import org.junit.Test -import org.junit.runner.RunWith -import org.koin.test.AutoCloseKoinTest -import org.robolectric.RobolectricTestRunner - -@RunWith(RobolectricTestRunner::class) -class DataExportUseCaseImplTest : AutoCloseKoinTest() { - - private val holderDatabase: HolderDatabase = mockk() - private val stringDataZipper: StringDataZipper = mockk() - private val moshi = Moshi.Builder().build() - - @Test - fun `event group entity exports to migration parcels`() = runTest { - coEvery { holderDatabase.eventGroupDao().getAll() } returns listOf( - EventGroupEntity( - id = 1, - walletId = 1, - providerIdentifier = "ZZZ", - type = OriginType.Vaccination, - scope = "", - draft = false, - expiryDate = null, - jsonData = "".toByteArray() - ) - ) - - coEvery { stringDataZipper.zip(any()) } returns "Xi8RQlrQWV4nfZbaox3KL3vjVU6x8Dh5qr20Unao3LN74ckv6mHXDNglCH/UXeefnNQxg52y6/bl0rPuEiUdR+P5hCgu2uTBFhvArKjCfXOqYeRVSDzpyY9zyJAUTcQdzA0OmHFlUEf1R7nQXOaj4lgvZdQEHMucSrOvsPzgTuEekYy0Nzb1wG6in0jVfT4rXLjatVR3fl4vUpSRP8olKVWuGUP0cXLlSe4maxy/U1jvM0UFh3E4C3PiEc1Sd2a60wcjpKijeUdxfadcvpRC3szAFmMTdkQs5XudkM42OvLxJUYw/wkqFhum1pJCPfws17t6jzdnMU8nhONqIXcaz68s0vdLPEuZYyeLEMwx1JCa9GnBwQkZl0u6g/GTZ0wPpOvuJtdP7szlCTXKXKeIKKmJs72XsW21aqjMb8ulnyyRB7dAErHW3Gmb5EeEc3Pdzlm2fSltI6o26FIkHybePkVOn3IxmkSYicWeMqcBfZimWo0PMrCCx/6GiuZ4QrpUcWNJf9icntsjDYMwg75wh9pssDZDyWsh5ZmKbVQivCvtzTVS9kriU61m0IkaFWKztiEyLiYmGl/OYfB6kUynQxDpIVhMK7M6m07EaT4Zpu7JwXM6/HimVu9O7kyhjrjqHkgsMsu6+sPYIL2IRiic3BkKntSdPe1gW6PGrzHVxkmGCiUqlTWsSbS/2OZdRbMSXaOy7HOu+u1r6iZWicIz2TYw++BOUdBqORbpMN5ZxBBD45N0FNZv52oxnmk+5kZss0tvY6jNE1mCEx1Mdt4bLRULin4qtGPu".toByteArray() - - val dataExportUseCase = DataExportUseCaseImpl(holderDatabase, moshi, stringDataZipper) - - val migrationParcels = dataExportUseCase.export() - - assertEquals(2, migrationParcels.size) - } -} diff --git a/holder/src/test/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationImportUseCaseImplTest.kt b/holder/src/test/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationImportUseCaseImplTest.kt deleted file mode 100644 index 9ba19afb2..000000000 --- a/holder/src/test/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationImportUseCaseImplTest.kt +++ /dev/null @@ -1,43 +0,0 @@ -package nl.rijksoverheid.ctr.holder.data_migration - -import com.squareup.moshi.Moshi -import io.mockk.mockk -import kotlin.test.assertEquals -import kotlin.test.assertNotNull -import kotlinx.coroutines.test.runTest -import nl.rijksoverheid.ctr.api.json.Base64JsonAdapter -import nl.rijksoverheid.ctr.api.json.JsonObjectJsonAdapter -import nl.rijksoverheid.ctr.api.json.LocalDateJsonAdapter -import nl.rijksoverheid.ctr.api.json.OffsetDateTimeJsonAdapter -import org.junit.Test -import org.junit.runner.RunWith -import org.koin.test.AutoCloseKoinTest -import org.robolectric.RobolectricTestRunner - -@RunWith(RobolectricTestRunner::class) -class DataMigrationImportUseCaseImplTest : AutoCloseKoinTest() { - - private val moshi = Moshi.Builder() - .add(Base64JsonAdapter()) - .add(JsonObjectJsonAdapter()) - .add(OffsetDateTimeJsonAdapter()) - .add(LocalDateJsonAdapter()) - .build() - - private val stringDataZipper = mockk() - - private val dataMigrationUseCase = DataMigrationImportUseCaseImpl(moshi, stringDataZipper) - - @Test - fun `convert migration qr string to migration parcel`() = runTest { - val content = - "eyJpIjo4LCJuIjoxNywicCI6InpGSVUzams4K0xXeWNkYVBJK1NwanpMMkpjdnhJMnRUQlB5V1ZLaiswTzdZUU8wSkhrTnlGS3d2Qm55QWRyckVlWGpyQ1lIcXRrSFJUVEZrMXcySDRXSk9oQ0FMdnZEWVFJaURWUU0xSmdhTitHNDZYRUtjS0lVYWdvSkVpay9JTExUVExxVGRrQzFuSlZEbE5TNGZ3UDlDTzZxWWJFQXpWaDRQMHY0M3FOZWt1WFFVZU5LMHdGSEFrL1lFV1FxWURNc3NXczliWkhicGtwZ0xTVUdmd3hyMEhYZzRoajRIcWR1ODYzamJBZXQ3aFRmZVRmZDQvdFFQREcwMVRoMGZGclYrVnMxbklRMHpDdGFQcHpPMldFY0swT09ZVGFDM3BleDgwRnUvaEl6OEJGNWM5d3VjYjcyUjYyZlFHMkNVVmU4ZzV3OUNHbWdiY1lpUXZoNXdiQ0RCbE5KOEZhTHpURDlpcGFKN0dVSWN0U3dRdis4bmQralhmaktOVWdIdEYyLzM3L01pZ1hibjMvTklia0JvMGE0UU9HYWhkaUdqZjJUeGRyeEVpYjNnWklGNVRvc2Vuem1pRDRMcG5Zdmk4WDMrcFlBN1paSnpvWmx4R0lER3BETUpIQ3B0VjNmcmVhVGRzUWhUME9NSGFBQjRUWElqQTRYMm1JRjFLSUo2RFN0Qk1STjRuOFhyZnZrNkZ4WVlrd1dRd1FmdEpldStiYnpxTlBCdHBxQjJvUDRlYTM2aDNleWZnYWVCcS8rZDhUWWd6NnMvSHFBV0U2eHlrN0VvQ1N2SVRCb0ZkOFdiWC9kalArZHZzTUR6MGl0NDhnbDVaSUx4YjZCT0htcmxmNVdFa0YydnBNVi93L3QvczkvVG9lODhVeXcwWThEYnhtT3dmaVJTbkI1cjRIZjZhN3paSHNiL3V2WEU5N2tBckxmK0g1LzNBZlArT3UrRDM1ZVJjM1RuR1hJVmtXanN1SXRURTBtWS8rQVZXUFJGdThrTGVOUk5Qbis3S3pFK1pJKy93RWRUNExscnhadVVEL1VIV1hSd1Z2T1F0czB0IiwidiI6IkNDMSJ9" - - val migrationParcel = dataMigrationUseCase.import(content) - - assertNotNull(migrationParcel) - assertEquals("CC1", migrationParcel.version) - assertEquals(8, migrationParcel.index) - assertEquals(17, migrationParcel.numberOfPackages) - } -} diff --git a/holder/src/test/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationPayloadUseCaseImplTest.kt b/holder/src/test/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationPayloadUseCaseImplTest.kt deleted file mode 100644 index 9a81266b9..000000000 --- a/holder/src/test/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationPayloadUseCaseImplTest.kt +++ /dev/null @@ -1,68 +0,0 @@ -package nl.rijksoverheid.ctr.holder.data_migration - -import com.squareup.moshi.Moshi -import com.squareup.moshi.adapters.PolymorphicJsonAdapterFactory -import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory -import io.mockk.every -import io.mockk.mockk -import kotlin.test.assertNotNull -import nl.rijksoverheid.ctr.api.json.Base64JsonAdapter -import nl.rijksoverheid.ctr.api.json.JsonObjectJsonAdapter -import nl.rijksoverheid.ctr.api.json.LocalDateJsonAdapter -import nl.rijksoverheid.ctr.api.json.OffsetDateTimeJsonAdapter -import nl.rijksoverheid.ctr.holder.api.OriginTypeJsonAdapter -import nl.rijksoverheid.ctr.holder.api.RemoteCouplingStatusJsonAdapter -import nl.rijksoverheid.ctr.holder.api.RemoteTestStatusJsonAdapter -import nl.rijksoverheid.ctr.holder.get_events.models.RemoteEvent -import nl.rijksoverheid.ctr.holder.paper_proof.usecases.GetEventsFromPaperProofQrUseCase -import org.junit.Test -import org.junit.runner.RunWith -import org.koin.test.AutoCloseKoinTest -import org.robolectric.RobolectricTestRunner - -@RunWith(RobolectricTestRunner::class) -class DataMigrationPayloadUseCaseImplTest : AutoCloseKoinTest() { - private val moshi = Moshi.Builder() - .add(Base64JsonAdapter()) - .add(JsonObjectJsonAdapter()) - .add(OffsetDateTimeJsonAdapter()) - .add(LocalDateJsonAdapter()) - .add(RemoteTestStatusJsonAdapter()) - .add(OriginTypeJsonAdapter()) - .add(RemoteCouplingStatusJsonAdapter()) - .add( - PolymorphicJsonAdapterFactory.of( - RemoteEvent::class.java, "type" - ) - .withSubtype(RemoteEvent.getRemoteEventClassFromType(RemoteEvent.TYPE_POSITIVE_TEST), RemoteEvent.TYPE_POSITIVE_TEST) - .withSubtype(RemoteEvent.getRemoteEventClassFromType(RemoteEvent.TYPE_RECOVERY), RemoteEvent.TYPE_RECOVERY) - .withSubtype(RemoteEvent.getRemoteEventClassFromType(RemoteEvent.TYPE_NEGATIVE_TEST), RemoteEvent.TYPE_NEGATIVE_TEST) - .withSubtype(RemoteEvent.getRemoteEventClassFromType(RemoteEvent.TYPE_VACCINATION), RemoteEvent.TYPE_VACCINATION) - ) - .add(KotlinJsonAdapterFactory()) - .build() - - private val getEventsFromPaperProofQrUseCase = mockk() - private val dataMigrationPayloadUseCase = DataMigrationPayloadUseCaseImpl(moshi, getEventsFromPaperProofQrUseCase) - - @Test - fun `get remoteprotocol from non dcc payload`() { - val jsonData = - "{\"payload\":\"eyJwcm90b2NvbFZlcnNpb24iOiIzLjAiLCJwcm92aWRlcklkZW50aWZpZXIiOiJaWloiLCJzdGF0dXMiOiJjb21wbGV0ZSIsImhvbGRlciI6eyJmaXJzdE5hbWUiOiJDb3JyaWUiLCJpbmZpeCI6InZhbiIsImxhc3ROYW1lIjoiR2VlciIsImJpcnRoRGF0ZSI6IjE5NjAtMDEtMDEifSwiZXZlbnRzIjpbeyJ0eXBlIjoicG9zaXRpdmV0ZXN0IiwidW5pcXVlIjoiZGRmNDMyYTMtNTQ2OC00ODBiLThlYWYtNzg3NDFiMWE4OTYyIiwiaXNTcGVjaW1lbiI6dHJ1ZSwicG9zaXRpdmV0ZXN0Ijp7InNhbXBsZURhdGUiOiIyMDIzLTAzLTI1VDEwOjAxWiIsInBvc2l0aXZlUmVzdWx0Ijp0cnVlLCJmYWNpbGl0eSI6IkdHRCBYTCBBbXN0ZXJkYW0iLCJ0eXBlIjoiTFA2NDY0LTQiLCJuYW1lIjoiUENSIE5hbWUiLCJtYW51ZmFjdHVyZXIiOiJQQ1IgTWFudWZhY3R1cmVyIiwiY291bnRyeSI6Ik5MIn19XX0=\",\"signature\":\"MIIeGwYJKoZIhvcNAQcCoIIeDDCCHggCAQExDTALBglghkgBZQMEAgEwCwYJKoZIhvcNAQcBoIIaZjCCBYQwggNsoAMCAQICBACYpiEwDQYJKoZIhvcNA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+6DbYNrXzsvcD9LAnSAiCmNVyQ3r6dE+KbdmcpxOBxA4x1vqtgoujCwfhsatF/fxB+9GQfwDU8AFUZ9t3A5SUMP0INdwe4N3A/6umRXx7bMx6x2aS45yY49xK+VWCic0XDcXe5bwuytz7jElQ/5jrLmCkJosOsahA7UAOds3hm8Vvwqo1HLY0in4aTQin+aksIYeEOS4GeROk0a06LE1DCBIEKsBP+S6uyziaQ7c4rEKMkw++wP1zTBEaPTbLDduiwgARExMVnRTBSTO3QEBh5FYOnXTy9J+eoRQJKZFLT5knA7Zy4fh2wkawMwMjhbVZ2xf0IhCGTxOmTw6s1OgH82tUEU6aD935OYeF4Bu/++/nZzS/LWbvF7gR3YG7Duz+eFn4VJ1BUnuSoGAEHOaj7zIlB/luNrbF+AqET7ODW5PmsV3TAe6agW7Kcjl6zesFGU3KXNdgsoLuSlROEyHT9tfbgV4A==\"}" - - val remoteProtocol = dataMigrationPayloadUseCase.parsePayload(jsonData.toByteArray()) - - assertNotNull(remoteProtocol) - } - - @Test - fun `get remoteprotocol from dcc payload`() { - val jsonData = - "{\"couplingCode\":\"ZKGBKH\",\"credential\":\"HC1:NCFC20490T9WTWGVLKS79 1VYLTXZM8AVX*4FBBU42*70J+9DN03E54F3/Y1LOCY50.FK8ZKO/EZKEZ967L6C56GVC*JC1A6C%63W5Y96746TPCBEC7ZKW.CC9DCECS34\$ CXKEW.CAWEV+A3+9K09GY8 JC2/DSN83LEQEDMPCG/DY-CB1A5IAVY87:EDOL9WEQDD+Q6TW6FA7C466KCN9E%961A6DL6FA7D46.JCP9EJY8L/5M/5546.96VF6.JCBECB1A-:8\$966469L6OF6VX6FVCPD0KQEPD0LVC6JD846Y96*963W5.A6UPCBJCOT9+EDL8FHZ95/D QEALEN44:+C%69AECAWE:34: CJ.CZKE9440/D+34S9E5LEWJC0FD3%4AIA%G7ZM81G72A6J+9SG77N91R6E+9LCBMIBQCAYM8UIB51A9Y9AF6WA6I4817S6ZKH/C3*F*\$GR4N2+5F8FM B\$W6KU91A9WTO8S1QK87DBBMHDKFT*UMNCI3V\$LS.QFWMF18W6TH5\$9W+4QZLU71.5DB73000FGWU/0CRF\"}" - every { getEventsFromPaperProofQrUseCase.get(any()) } returns mockk() - - val remoteProtocol = dataMigrationPayloadUseCase.parsePayload(jsonData.toByteArray()) - - assertNotNull(remoteProtocol) - } -} diff --git a/holder/src/test/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationScanQrViewModelImplTest.kt b/holder/src/test/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationScanQrViewModelImplTest.kt deleted file mode 100644 index 4b49155a9..000000000 --- a/holder/src/test/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationScanQrViewModelImplTest.kt +++ /dev/null @@ -1,192 +0,0 @@ -package nl.rijksoverheid.ctr.holder.data_migration - -import androidx.arch.core.executor.testing.InstantTaskExecutorRule -import io.mockk.coEvery -import io.mockk.mockk -import kotlin.test.assertTrue -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.test.UnconfinedTestDispatcher -import kotlinx.coroutines.test.setMain -import nl.rijksoverheid.ctr.getOrAwaitValue -import nl.rijksoverheid.ctr.holder.get_events.usecases.ConfigProvidersUseCase -import nl.rijksoverheid.ctr.holder.get_events.usecases.EventProvidersResult -import nl.rijksoverheid.ctr.shared.exceptions.DataMigrationDecodingErrorException -import nl.rijksoverheid.ctr.shared.exceptions.DataMigrationInvalidNumberOfPackagesException -import nl.rijksoverheid.ctr.shared.exceptions.DataMigrationInvalidVersionException -import nl.rijksoverheid.ctr.shared.exceptions.DataMigrationOtherException -import nl.rijksoverheid.ctr.shared.exceptions.NoProvidersException -import org.junit.Assert.assertEquals -import org.junit.Before -import org.junit.Rule -import org.junit.Test - -class DataMigrationScanQrViewModelImplTest { - - @get:Rule - val instantExecutorRule = InstantTaskExecutorRule() - - private val dataMigrationImportUseCase: DataMigrationImportUseCase = mockk() - private val dataMigrationPayloadUseCase: DataMigrationPayloadUseCase = mockk() - private val configProvidersUseCase: ConfigProvidersUseCase = mockk() - - private val viewModel = DataMigrationScanQrViewModelImpl( - dataMigrationImportUseCase, - dataMigrationPayloadUseCase, - configProvidersUseCase - ) - - @Before - fun setup() { - Dispatchers.setMain(UnconfinedTestDispatcher()) - } - - @Test - fun `given a qr that throws exception when importing it, then app state is DataMigrationImport error`() { - coEvery { dataMigrationImportUseCase.import(any()) } throws Exception("Import failed") - - viewModel.onQrScanned("qrcodecontent") - - val dataMigrationScanQrState = - viewModel.scanFinishedLiveData.getOrAwaitValue().peekContent() - - assertTrue(dataMigrationScanQrState is DataMigrationScanQrState.Error) - assertTrue(dataMigrationScanQrState.errorResult.e is DataMigrationDecodingErrorException) - } - - @Test - fun `given a qr that generates no migration parcel, then app state is DataMigrationImport error`() { - coEvery { dataMigrationImportUseCase.import(any()) } returns null - - viewModel.onQrScanned("qrcodecontent") - - val dataMigrationScanQrState = - viewModel.scanFinishedLiveData.getOrAwaitValue().peekContent() - - assertTrue(dataMigrationScanQrState is DataMigrationScanQrState.Error) - assertTrue(dataMigrationScanQrState.errorResult.e is DataMigrationOtherException) - } - - @Test - fun `given a qr that generates a migration parcel with different version, then app state is DataMigrationImport error`() { - coEvery { dataMigrationImportUseCase.import(any()) } returns mockk().apply { - coEvery { version } returns "CC2" - } - - viewModel.onQrScanned("qrcodecontent") - - val dataMigrationScanQrState = - viewModel.scanFinishedLiveData.getOrAwaitValue().peekContent() - - assertTrue(dataMigrationScanQrState is DataMigrationScanQrState.Error) - assertTrue(dataMigrationScanQrState.errorResult.e is DataMigrationInvalidVersionException) - } - - @Test - fun `given a qr that generates a valid migration parcel, then app state updates progress`() { - coEvery { dataMigrationImportUseCase.import(any()) } returns MigrationParcel( - index = 1, - numberOfPackages = 10, - payload = "", - version = "CC1" - ) - - viewModel.onQrScanned("qrcodecontent") - - val progressBarLiveData = viewModel.progressBarLiveData.getOrAwaitValue() - - assertEquals(10, progressBarLiveData.calculateProgressPercentage()) - } - - @Test - fun `given a qr that generates a migration parcel with bigger number of packages, then app state is DataMigrationImport error`() { - coEvery { dataMigrationImportUseCase.import(any()) } returnsMany listOf( - MigrationParcel( - index = 1, - numberOfPackages = 10, - payload = "", - version = "CC1" - ), - MigrationParcel( - index = 1, - numberOfPackages = 1, - payload = "", - version = "CC1" - ) - ) - - viewModel.onQrScanned("qrcodecontent1") - viewModel.onQrScanned("qrcodecontent2") - - val dataMigrationScanQrState = - viewModel.scanFinishedLiveData.getOrAwaitValue().peekContent() - - assertTrue(dataMigrationScanQrState is DataMigrationScanQrState.Error) - assertTrue(dataMigrationScanQrState.errorResult.e is DataMigrationInvalidNumberOfPackagesException) - } - - @Test - fun `given a qr that generates a migration parcel that fails to merge to an event parcel, then app state is DataMigrationImport error`() { - coEvery { dataMigrationImportUseCase.import(any()) } returns MigrationParcel( - index = 1, - numberOfPackages = 1, - payload = "", - version = "CC1" - ) - coEvery { dataMigrationImportUseCase.merge(any()) } throws Exception("exception") - - viewModel.onQrScanned("qrcodecontent1") - - val dataMigrationScanQrState = - viewModel.scanFinishedLiveData.getOrAwaitValue().peekContent() - - assertTrue(dataMigrationScanQrState is DataMigrationScanQrState.Error) - assertTrue(dataMigrationScanQrState.errorResult.e is DataMigrationDecodingErrorException) - } - - @Test - fun `given a qr that generates a migration parcel but we have no event providers, then app state is DataMigrationImport error`() { - coEvery { dataMigrationImportUseCase.import(any()) } returns MigrationParcel( - index = 1, - numberOfPackages = 1, - payload = "", - version = "CC1" - ) - coEvery { dataMigrationImportUseCase.merge(any()) } returns listOf(mockk().apply { - coEvery { jsonData } returns "".toByteArray() - }) - coEvery { dataMigrationPayloadUseCase.parsePayload(any()) } returns mockk() - coEvery { configProvidersUseCase.eventProviders() } returns EventProvidersResult.Error(mockk()) - - viewModel.onQrScanned("qrcodecontent1") - - val dataMigrationScanQrState = - viewModel.scanFinishedLiveData.getOrAwaitValue().peekContent() - - assertTrue(dataMigrationScanQrState is DataMigrationScanQrState.Error) - assertTrue(dataMigrationScanQrState.errorResult.e is NoProvidersException.Migration) - } - - @Test - fun `given a qr that generated all migrations parcels, then app state is Success`() { - coEvery { dataMigrationImportUseCase.import(any()) } returns MigrationParcel( - index = 1, - numberOfPackages = 1, - payload = "", - version = "CC1" - ) - coEvery { dataMigrationImportUseCase.merge(any()) } returns listOf(mockk().apply { - coEvery { jsonData } returns "".toByteArray() - }) - coEvery { dataMigrationPayloadUseCase.parsePayload(any()) } returns mockk() - coEvery { configProvidersUseCase.eventProviders() } returns EventProvidersResult.Success( - listOf() - ) - - viewModel.onQrScanned("qrcodecontent1") - - val dataMigrationScanQrState = - viewModel.scanFinishedLiveData.getOrAwaitValue().peekContent() - - assertTrue(dataMigrationScanQrState is DataMigrationScanQrState.Success) - } -} diff --git a/holder/src/test/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationShowQrCodeViewModelImplTest.kt b/holder/src/test/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationShowQrCodeViewModelImplTest.kt deleted file mode 100644 index b3f7f9942..000000000 --- a/holder/src/test/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationShowQrCodeViewModelImplTest.kt +++ /dev/null @@ -1,71 +0,0 @@ -package nl.rijksoverheid.ctr.holder.data_migration - -import androidx.arch.core.executor.testing.InstantTaskExecutorRule -import io.mockk.coEvery -import io.mockk.mockk -import java.io.IOException -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.test.UnconfinedTestDispatcher -import kotlinx.coroutines.test.setMain -import nl.rijksoverheid.ctr.getOrAwaitValue -import nl.rijksoverheid.ctr.holder.qrcodes.usecases.QrCodeUseCase -import nl.rijksoverheid.ctr.shared.exceptions.DataMigrationCompressionException -import nl.rijksoverheid.ctr.shared.exceptions.DataMigrationOtherException -import org.junit.Assert.assertTrue -import org.junit.Before -import org.junit.Rule -import org.junit.Test - -class DataMigrationShowQrCodeViewModelImplTest { - - @get:Rule - val instantExecutorRule = InstantTaskExecutorRule() - - private val dataExportUseCase: DataExportUseCase = mockk() - private val qrCodeUseCase: QrCodeUseCase = mockk() - - private val viewModel = DataMigrationShowQrCodeViewModelImpl(dataExportUseCase, qrCodeUseCase) - - @Before - fun setup() { - Dispatchers.setMain(UnconfinedTestDispatcher()) - } - - @Test - fun `generateQrCodes with no errors generates qr codes`() { - coEvery { dataExportUseCase.export() } returns listOf("") - coEvery { qrCodeUseCase.qrCode(any(), any(), any(), any(), any()) } returns mockk() - - viewModel.generateQrCodes(800) - - assertTrue(viewModel.qrCodesLiveData.getOrAwaitValue() is DataMigrationShowQrViewState.ShowQrs) - } - - @Test - fun `generateQrCodes with export error shows error`() { - coEvery { dataExportUseCase.export() } throws IOException("") - - viewModel.generateQrCodes(800) - - val state = viewModel.qrCodesLiveData.getOrAwaitValue() - - assertTrue( - (state as DataMigrationShowQrViewState.ShowError).errorResults.first() - .getException() is DataMigrationCompressionException - ) - } - - @Test - fun `generateQrCodes with other error shows error`() { - coEvery { dataExportUseCase.export() } throws Exception("") - - viewModel.generateQrCodes(800) - - val state = viewModel.qrCodesLiveData.getOrAwaitValue() - - assertTrue( - (state as DataMigrationShowQrViewState.ShowError).errorResults.first() - .getException() is DataMigrationOtherException - ) - } -} diff --git a/holder/src/test/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationUseCaseImplTest.kt b/holder/src/test/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationUseCaseImplTest.kt deleted file mode 100644 index a9d6c509b..000000000 --- a/holder/src/test/java/nl/rijksoverheid/ctr/holder/data_migration/DataMigrationUseCaseImplTest.kt +++ /dev/null @@ -1,43 +0,0 @@ -package nl.rijksoverheid.ctr.holder.data_migration - -import io.mockk.coEvery -import io.mockk.mockk -import kotlinx.coroutines.test.runTest -import nl.rijksoverheid.ctr.persistence.database.HolderDatabase -import nl.rijksoverheid.ctr.persistence.database.entities.EventGroupEntity -import org.junit.Assert.assertFalse -import org.junit.Assert.assertTrue -import org.junit.Test - -class DataMigrationUseCaseImplTest { - - private val holderDatabase = mockk() - private val dataMigrationUseCase = DataMigrationUseCaseImpl(holderDatabase) - - @Test - fun `canTransferData returns false for draft only events`() = runTest { - val events = listOf( - mockk().apply { - coEvery { draft } returns true - } - ) - coEvery { holderDatabase.eventGroupDao().getAll() } returns events - - assertFalse(dataMigrationUseCase.canTransferData()) - } - - @Test - fun `canTransferData returns true if non draft events exist`() = runTest { - val events = listOf( - mockk().apply { - coEvery { draft } returns true - }, - mockk().apply { - coEvery { draft } returns false - } - ) - coEvery { holderDatabase.eventGroupDao().getAll() } returns events - - assertTrue(dataMigrationUseCase.canTransferData()) - } -} diff --git a/holder/src/test/java/nl/rijksoverheid/ctr/holder/data_migration/ProgressBarStateTests.kt b/holder/src/test/java/nl/rijksoverheid/ctr/holder/data_migration/ProgressBarStateTests.kt deleted file mode 100644 index 51d9ecb39..000000000 --- a/holder/src/test/java/nl/rijksoverheid/ctr/holder/data_migration/ProgressBarStateTests.kt +++ /dev/null @@ -1,16 +0,0 @@ -package nl.rijksoverheid.ctr.holder.data_migration - -import kotlin.test.assertEquals -import org.junit.Test - -class ProgressBarStateTests { - @Test - fun calculateProgressPercentage() { - val progressBarState = ProgressBarState( - max = 17, - progress = 15 - ) - - assertEquals(88, progressBarState.calculateProgressPercentage()) - } -} diff --git a/holder/src/test/java/nl/rijksoverheid/ctr/holder/menu/MenuViewModelImplTest.kt b/holder/src/test/java/nl/rijksoverheid/ctr/holder/menu/MenuViewModelImplTest.kt index 9e37e05ec..b927cf606 100644 --- a/holder/src/test/java/nl/rijksoverheid/ctr/holder/menu/MenuViewModelImplTest.kt +++ b/holder/src/test/java/nl/rijksoverheid/ctr/holder/menu/MenuViewModelImplTest.kt @@ -5,13 +5,11 @@ import androidx.arch.core.executor.testing.InstantTaskExecutorRule import androidx.test.core.app.ApplicationProvider import io.mockk.every import io.mockk.mockk -import nl.rijksoverheid.ctr.design.fragments.menu.MenuFragmentDirections import nl.rijksoverheid.ctr.design.fragments.menu.MenuSection import nl.rijksoverheid.ctr.holder.R import nl.rijksoverheid.ctr.holder.usecases.HolderFeatureFlagUseCase import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue -import org.junit.Ignore import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith @@ -29,13 +27,10 @@ class MenuViewModelImplTest : AutoCloseKoinTest() { } private val featureFlagUseCase = mockk().apply { every { getAddEventsButtonEnabled() } returns true - every { getScanCertificateButtonEnabled() } returns true - every { getMigrateButtonEnabled() } returns true - every { isInArchiveMode() } returns false + every { isInArchiveMode() } returns true } @Test - @Ignore fun `on menu click get correct menu items`() { val menuViewModel = MenuViewModelImpl(helpMenuDataModel, featureFlagUseCase) @@ -43,29 +38,20 @@ class MenuViewModelImplTest : AutoCloseKoinTest() { val menuSections = menuViewModel.menuSectionLiveData.value!!.peekContent() assertEquals(2, menuSections[0].menuItems.size) - assertEquals(R.drawable.ic_menu_add, menuSections[0].menuItems[0].icon) + assertEquals(R.drawable.ic_menu_export_pdf, menuSections[0].menuItems[0].icon) assertEquals( - R.string.holder_menu_listItem_addVaccinationOrTest_title, + R.string.holder_menu_exportPDF, menuSections[0].menuItems[0].title ) assertTrue(menuSections[0].menuItems[0].onClick is MenuSection.MenuItem.OnClick.Navigate) - assertEquals(R.drawable.ic_menu_paper, menuSections[0].menuItems[1].icon) - assertEquals(R.string.holder_menu_paperproof_title, menuSections[0].menuItems[1].title) + assertEquals(R.drawable.ic_menu_add, menuSections[0].menuItems[1].icon) + assertEquals(R.string.holder_menu_listItem_addVaccinationOrTest_title, menuSections[0].menuItems[1].title) assertTrue(menuSections[0].menuItems[1].onClick is MenuSection.MenuItem.OnClick.Navigate) - assertEquals(2, menuSections[1].menuItems.size) - - assertEquals(R.drawable.ic_menu_saved_events, menuSections[1].menuItems[0].icon) - assertEquals(R.string.holder_menu_storedEvents, menuSections[1].menuItems[0].title) - assertTrue(menuSections[1].menuItems[0].onClick is MenuSection.MenuItem.OnClick.Navigate) - assertEquals(R.drawable.ic_menu_data_migration, menuSections[1].menuItems[1].icon) - assertEquals(R.string.holder_menu_migration, menuSections[1].menuItems[1].title) - assertEquals( - MenuFragmentDirections.actionDataMigration().actionId, - (menuSections[1].menuItems[1].onClick as MenuSection.MenuItem.OnClick.Navigate).navigationActionId - ) - - assertEquals(R.drawable.ic_menu_info, menuSections[2].menuItems[0].icon) - assertEquals(R.string.holder_menu_helpInfo, menuSections[2].menuItems[0].title) + assertEquals(R.drawable.ic_menu_saved_events, menuSections[2].menuItems[0].icon) + assertEquals(R.string.holder_menu_storedEvents, menuSections[2].menuItems[0].title) assertTrue(menuSections[2].menuItems[0].onClick is MenuSection.MenuItem.OnClick.Navigate) + assertEquals(R.drawable.ic_menu_info, menuSections[2].menuItems[1].icon) + assertEquals(R.string.holder_menu_helpInfo, menuSections[2].menuItems[1].title) + assertTrue(menuSections[2].menuItems[1].onClick is MenuSection.MenuItem.OnClick.Navigate) } } diff --git a/holder/src/test/java/nl/rijksoverheid/ctr/holder/paper_proof/PaperProofQrScannerFragmentTest.kt b/holder/src/test/java/nl/rijksoverheid/ctr/holder/paper_proof/PaperProofQrScannerFragmentTest.kt deleted file mode 100644 index aebd95f63..000000000 --- a/holder/src/test/java/nl/rijksoverheid/ctr/holder/paper_proof/PaperProofQrScannerFragmentTest.kt +++ /dev/null @@ -1,49 +0,0 @@ -package nl.rijksoverheid.ctr.holder.paper_proof - -import android.content.Context -import androidx.fragment.app.testing.launchFragmentInContainer -import androidx.lifecycle.ViewModelStore -import androidx.navigation.Navigation -import androidx.navigation.testing.TestNavHostController -import androidx.test.core.app.ApplicationProvider -import com.adevinta.android.barista.internal.assertAny -import com.adevinta.android.barista.internal.matcher.TextColorMatcher -import com.adevinta.android.barista.internal.matcher.withCompatText -import nl.rijksoverheid.ctr.holder.R -import org.junit.Test -import org.junit.runner.RunWith -import org.koin.test.AutoCloseKoinTest -import org.robolectric.RobolectricTestRunner - -@RunWith(RobolectricTestRunner::class) -class PaperProofQrScannerFragmentTest : AutoCloseKoinTest() { - - private val navController = TestNavHostController( - ApplicationProvider.getApplicationContext() - ).also { - it.setViewModelStore(ViewModelStore()) - it.setGraph(R.navigation.holder_nav_graph_root) - it.setCurrentDestination(R.id.nav_paper_proof_qr_scanner) - } - - @Test - fun `scanner toolbar title color is white`() { - launchFragment() - - val toolbarTitle = ApplicationProvider.getApplicationContext() - .getString(R.string.add_paper_proof_qr_scanner_title) - withCompatText(toolbarTitle).assertAny(TextColorMatcher(R.color.white)) - } - - private fun launchFragment() { - launchFragmentInContainer(themeResId = R.style.AppTheme) { - PaperProofQrScannerFragment().also { - it.viewLifecycleOwnerLiveData.observeForever { viewLifecycleOwner -> - if (viewLifecycleOwner != null) { - Navigation.setViewNavController(it.requireView(), navController) - } - } - } - } - } -}