Skip to content

Commit

Permalink
Formatted code
Browse files Browse the repository at this point in the history
  • Loading branch information
grzesiek2010 committed Jul 6, 2023
1 parent 4e33cea commit 261c65c
Show file tree
Hide file tree
Showing 8 changed files with 421 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,39 +21,86 @@ internal class ProjectSettingsDialogPage : Page<ProjectSettingsDialogPage>() {
}

fun clickSettings(): ProjectSettingsPage {
return clickOnButtonInDialog(org.odk.collect.strings.R.string.settings, ProjectSettingsPage())
return clickOnButtonInDialog(
org.odk.collect.strings.R.string.settings,
ProjectSettingsPage()
)
}

fun clickAbout(): AboutPage {
return clickOnButtonInDialog(org.odk.collect.strings.R.string.about_preferences, AboutPage())
return clickOnButtonInDialog(
org.odk.collect.strings.R.string.about_preferences,
AboutPage()
)
}

fun clickAddProject(): QrCodeProjectCreatorDialogPage {
return clickOnButtonInDialog(org.odk.collect.strings.R.string.add_project, QrCodeProjectCreatorDialogPage())
return clickOnButtonInDialog(
org.odk.collect.strings.R.string.add_project,
QrCodeProjectCreatorDialogPage()
)
}

fun assertCurrentProject(projectName: String, subtext: String): ProjectSettingsDialogPage {
onView(allOf(hasDescendant(withText(projectName)), hasDescendant(withText(subtext)), withContentDescription(getTranslatedString(
org.odk.collect.strings.R.string.using_project, projectName)))).check(matches(isDisplayed()))
onView(
allOf(
hasDescendant(withText(projectName)),
hasDescendant(withText(subtext)),
withContentDescription(
getTranslatedString(
org.odk.collect.strings.R.string.using_project,
projectName
)
)
)
).check(matches(isDisplayed()))
return this
}

fun assertInactiveProject(projectName: String, subtext: String): ProjectSettingsDialogPage {
onView(allOf(hasDescendant(withText(projectName)), hasDescendant(withText(subtext)), withContentDescription(getTranslatedString(
org.odk.collect.strings.R.string.switch_to_project, projectName)))).check(matches(isDisplayed()))
onView(
allOf(
hasDescendant(withText(projectName)),
hasDescendant(withText(subtext)),
withContentDescription(
getTranslatedString(
org.odk.collect.strings.R.string.switch_to_project,
projectName
)
)
)
).check(matches(isDisplayed()))
return this
}

fun assertNotInactiveProject(projectName: String): ProjectSettingsDialogPage {
onView(allOf(hasDescendant(withText(projectName)), withContentDescription(getTranslatedString(
org.odk.collect.strings.R.string.switch_to_project, projectName)))).check(doesNotExist())
onView(
allOf(
hasDescendant(withText(projectName)),
withContentDescription(
getTranslatedString(
org.odk.collect.strings.R.string.switch_to_project,
projectName
)
)
)
).check(doesNotExist())
return this
}

fun selectProject(projectName: String): MainMenuPage {
WaitFor.wait250ms() // https://github.com/android/android-test/issues/444
onView(allOf(hasDescendant(withText(projectName)), withContentDescription(getTranslatedString(
org.odk.collect.strings.R.string.switch_to_project, projectName))))
onView(
allOf(
hasDescendant(withText(projectName)),
withContentDescription(
getTranslatedString(
org.odk.collect.strings.R.string.switch_to_project,
projectName
)
)
)
)
.inRoot(RootMatchers.isDialog())
.perform(click())
return MainMenuPage().assertOnPage()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,11 @@ class DeleteSavedFormActivity : LocalizedActivity() {
}

TabLayoutMediator(binding.tabLayout, viewPager) { tab: TabLayout.Tab, position: Int ->
tab.text = if (position == 0) getString(org.odk.collect.strings.R.string.data) else getString(
org.odk.collect.strings.R.string.forms)
tab.text = if (position == 0) {
getString(org.odk.collect.strings.R.string.data)
} else {
getString(org.odk.collect.strings.R.string.forms)
}
}.attach()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,27 @@ class QRCodeScannerFragment : BarCodeScannerFragment() {
File(storagePathProvider.getProjectRootDirPath() + File.separator + newProjectName).createNewFile()
}

showLongToast(requireContext(), getString(org.odk.collect.strings.R.string.successfully_imported_settings))
showLongToast(
requireContext(),
getString(org.odk.collect.strings.R.string.successfully_imported_settings)
)
ActivityUtils.startActivityAndCloseAllOthers(
requireActivity(),
MainMenuActivity::class.java
)
}
SettingsImportingResult.INVALID_SETTINGS -> showLongToast(requireContext(), getString(
org.odk.collect.strings.R.string.invalid_qrcode))
SettingsImportingResult.GD_PROJECT -> showLongToast(requireContext(), getString(org.odk.collect.strings.R.string.settings_with_gd_protocol))

SettingsImportingResult.INVALID_SETTINGS -> showLongToast(
requireContext(),
getString(
org.odk.collect.strings.R.string.invalid_qrcode
)
)

SettingsImportingResult.GD_PROJECT -> showLongToast(
requireContext(),
getString(org.odk.collect.strings.R.string.settings_with_gd_protocol)
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,10 @@ class QrCodeProjectCreatorDialog :
R.id.menu_item_scan_sd_card -> {
val photoPickerIntent = Intent(Intent.ACTION_GET_CONTENT)
photoPickerIntent.type = "image/*"
intentLauncher.launchForResult(imageQrCodeImportResultLauncher, photoPickerIntent) {
intentLauncher.launchForResult(
imageQrCodeImportResultLauncher,
photoPickerIntent
) {
showShortToast(
requireContext(),
getString(
Expand Down Expand Up @@ -249,7 +252,10 @@ class QrCodeProjectCreatorDialog :
val settingsJson = try {
CompressionUtils.decompress(barcodeResult.text)
} catch (e: Exception) {
showShortToast(requireContext(), getString(org.odk.collect.strings.R.string.invalid_qrcode))
showShortToast(
requireContext(),
getString(org.odk.collect.strings.R.string.invalid_qrcode)
)
""
}
createProjectOrError(settingsJson)
Expand Down Expand Up @@ -288,10 +294,20 @@ class QrCodeProjectCreatorDialog :
)
)
}
SettingsImportingResult.INVALID_SETTINGS -> ToastUtils.showLongToast(requireContext(), getString(
org.odk.collect.strings.R.string.invalid_qrcode))
SettingsImportingResult.GD_PROJECT -> ToastUtils.showLongToast(requireContext(), getString(
org.odk.collect.strings.R.string.settings_with_gd_protocol))

SettingsImportingResult.INVALID_SETTINGS -> ToastUtils.showLongToast(
requireContext(),
getString(
org.odk.collect.strings.R.string.invalid_qrcode
)
)

SettingsImportingResult.GD_PROJECT -> ToastUtils.showLongToast(
requireContext(),
getString(
org.odk.collect.strings.R.string.settings_with_gd_protocol
)
)
}
}

Expand Down
Loading

0 comments on commit 261c65c

Please sign in to comment.