Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inflated missing menu #6530

Merged
merged 2 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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