diff --git a/collect_app/src/main/java/org/odk/collect/android/projects/QrCodeProjectCreatorDialog.kt b/collect_app/src/main/java/org/odk/collect/android/projects/QrCodeProjectCreatorDialog.kt index 06c9ea943e6..51fd7ba724a 100644 --- a/collect_app/src/main/java/org/odk/collect/android/projects/QrCodeProjectCreatorDialog.kt +++ b/collect_app/src/main/java/org/odk/collect/android/projects/QrCodeProjectCreatorDialog.kt @@ -170,12 +170,15 @@ class QrCodeProjectCreatorDialog : } private fun configureMenu() { - val menu = binding.toolbarLayout.toolbar.menu + val toolbar = binding.toolbarLayout.toolbar + toolbar.inflateMenu(R.menu.qr_code_scan_menu) + + val menu = toolbar.menu menu.enableIconsVisibility() menu.removeItem(R.id.menu_item_share) - binding.toolbarLayout.toolbar.setOnMenuItemClickListener { + toolbar.setOnMenuItemClickListener { when (it.itemId) { R.id.menu_item_scan_sd_card -> { val photoPickerIntent = Intent(Intent.ACTION_GET_CONTENT) diff --git a/collect_app/src/test/java/org/odk/collect/android/projects/QrCodeProjectCreatorDialogTest.kt b/collect_app/src/test/java/org/odk/collect/android/projects/QrCodeProjectCreatorDialogTest.kt index 94cf39d585b..946d557e346 100644 --- a/collect_app/src/test/java/org/odk/collect/android/projects/QrCodeProjectCreatorDialogTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/projects/QrCodeProjectCreatorDialogTest.kt @@ -15,6 +15,7 @@ import androidx.test.espresso.matcher.RootMatchers.isDialog import androidx.test.espresso.matcher.ViewMatchers.isRoot import androidx.test.espresso.matcher.ViewMatchers.withText import androidx.test.ext.junit.runners.AndroidJUnit4 +import com.google.android.material.appbar.MaterialToolbar import com.journeyapps.barcodescanner.BarcodeResult import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.equalTo @@ -109,6 +110,17 @@ class QrCodeProjectCreatorDialogTest { } } + @Test + fun `The dialog should have the option to import settings from file`() { + val scenario = launcherRule.launch(QrCodeProjectCreatorDialog::class.java) + scenario.onFragment { fragment -> + val toolbar = fragment.requireView().findViewById(org.odk.collect.androidshared.R.id.toolbar) + val importMenuItem = toolbar.menu.findItem(R.id.menu_item_scan_sd_card) + + assertThat(importMenuItem, `is`(notNullValue())) + } + } + @Test fun `The ManualProjectCreatorDialog should be displayed after switching to the manual mode`() { val scenario = launcherRule.launch(QrCodeProjectCreatorDialog::class.java)