Skip to content

Commit

Permalink
Merge pull request #6530 from grzesiek2010/COLLECT-6529
Browse files Browse the repository at this point in the history
Inflated missing menu
  • Loading branch information
lognaturel authored Nov 22, 2024
2 parents 26f6a5b + 2afc88b commit f0ce2a6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<MaterialToolbar>(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)
Expand Down

0 comments on commit f0ce2a6

Please sign in to comment.