Skip to content
This repository has been archived by the owner on Oct 10, 2020. It is now read-only.

feat: added cancel for ux #198

Merged
merged 6 commits into from
Apr 20, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -20,7 +20,7 @@ class BarcodeScannerActivity : Activity(), ZXingScannerView.ResultHandler {
companion object {
val REQUEST_TAKE_PHOTO_CAMERA_PERMISSION = 100
val TOGGLE_FLASH = 200

val CANCEL = 300
}

override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -43,6 +43,10 @@ class BarcodeScannerActivity : Activity(), ZXingScannerView.ResultHandler {
TOGGLE_FLASH, 0, "Flash On")
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS)
}

val item = menu.add(0, CANCEL, 0, "Cancel")
iRaySpace marked this conversation as resolved.
Show resolved Hide resolved
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS)

return super.onCreateOptionsMenu(menu)
}

Expand All @@ -52,6 +56,10 @@ class BarcodeScannerActivity : Activity(), ZXingScannerView.ResultHandler {
this.invalidateOptionsMenu()
return true
}
if (item.itemId == CANCEL) {
finish()
iRaySpace marked this conversation as resolved.
Show resolved Hide resolved
return true
}
return super.onOptionsItemSelected(item)
}

Expand Down