Skip to content

Commit

Permalink
Merge pull request #1457 from minvws/bugfix/exploratory-4.9-part-2
Browse files Browse the repository at this point in the history
Bugfix/exploratory 4.9 part 2
  • Loading branch information
ktiniatros authored Dec 8, 2022
2 parents 1e85937 + a86415e commit bc3cb68
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ package nl.rijksoverheid.ctr.holder.choose_proof_type
import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import nl.rijksoverheid.ctr.holder.R
import nl.rijksoverheid.ctr.holder.databinding.FragmentChooseProofTypeBinding
import nl.rijksoverheid.ctr.holder.get_events.models.RemoteOriginType
import nl.rijksoverheid.ctr.holder.ui.create_qr.bind
import nl.rijksoverheid.ctr.holder.usecases.HolderFeatureFlagUseCase
import nl.rijksoverheid.ctr.shared.ext.navigateSafety
import org.koin.android.ext.android.inject

/*
Expand All @@ -39,17 +39,17 @@ class ChooseProofTypeFragment : Fragment(R.layout.fragment_choose_proof_type) {
getString(R.string.qr_code_type_negative_test_description)
) {
if (featureFlagUseCase.getGgdEnabled()) {
findNavController().navigate(ChooseProofTypeFragmentDirections.actionChooseProvider())
navigateSafety(ChooseProofTypeFragmentDirections.actionChooseProvider())
} else {
findNavController().navigate(ChooseProofTypeFragmentDirections.actionInputToken())
navigateSafety(ChooseProofTypeFragmentDirections.actionInputToken())
}
}

binding.recoveryButton.bind(
R.string.qr_code_type_recovery_title,
getString(R.string.qr_code_type_recovery_description)
) {
findNavController().navigate(
navigateSafety(
ChooseProofTypeFragmentDirections.actionGetEvents(
originType = RemoteOriginType.Recovery,
toolbarTitle = resources.getString(R.string.choose_provider_toolbar)
Expand All @@ -61,7 +61,7 @@ class ChooseProofTypeFragment : Fragment(R.layout.fragment_choose_proof_type) {
R.string.qr_code_type_vaccination_title,
getString(R.string.qr_code_type_vaccination_description)
) {
findNavController().navigate(
navigateSafety(
ChooseProofTypeFragmentDirections.actionGetEvents(
originType = RemoteOriginType.Vaccination,
toolbarTitle = resources.getString(R.string.choose_provider_toolbar)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import nl.rijksoverheid.ctr.holder.R
import nl.rijksoverheid.ctr.holder.dashboard.DashboardFragment
import nl.rijksoverheid.ctr.holder.dashboard.DashboardFragmentDirections
import nl.rijksoverheid.ctr.holder.usecases.HolderFeatureFlagUseCase
import nl.rijksoverheid.ctr.shared.ext.findNavControllerSafety
import nl.rijksoverheid.ctr.shared.ext.navigateSafety

interface MenuUtil {
fun showMenu(dashboardFragment: DashboardFragment)
Expand All @@ -32,7 +32,7 @@ class MenuUtilImpl(
) : MenuUtil {

override fun showMenu(dashboardFragment: DashboardFragment) {
dashboardFragment.findNavControllerSafety()?.navigate(
dashboardFragment.navigateSafety(
DashboardFragmentDirections.actionMenu(
menuSections = getMenuSections(dashboardFragment.requireContext())
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.navArgs
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.SimpleItemAnimator
import com.google.android.material.divider.MaterialDividerItemDecoration
import com.xwray.groupie.GroupAdapter
import com.xwray.groupie.GroupieViewHolder
Expand Down Expand Up @@ -136,6 +137,8 @@ class HolderNameSelectionFragment : Fragment(R.layout.fragment_holder_name_selec
isLastItemDecorated = false
}
)
// prevent item decorator flickering when updating recyclerview to its error state
(binding.recyclerView.itemAnimator as? SimpleItemAnimator)?.supportsChangeAnimations = false
}

private fun setItems(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
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<Context>()
.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)
}
}
}
}
}
}
1 change: 1 addition & 0 deletions qrscanner/src/main/res/layout/fragment_scanner.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
app:navigationContentDescription="@string/back"
app:navigationIcon="@drawable/ic_back"
android:fitsSystemWindows="true"
app:titleTextColor="@color/white"
tools:title="QR-Code scannen" />

<androidx.camera.view.PreviewView
Expand Down

0 comments on commit bc3cb68

Please sign in to comment.