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 4 commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class BarcodeScannerActivity : Activity(), ZXingScannerView.ResultHandler {

companion object {
const val TOGGLE_FLASH = 200
const val CANCEL = 300
const val EXTRA_CONFIG = "config"
const val EXTRA_RESULT = "scan_result"
const val EXTRA_ERROR_CODE = "error_code"
Expand Down Expand Up @@ -78,6 +79,10 @@ class BarcodeScannerActivity : Activity(), ZXingScannerView.ResultHandler {
}
val item = menu.add(0, TOGGLE_FLASH, 0, buttonText)
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS)

val item = menu.add(0, CANCEL, 0, config.stringsMap["cancel"])
iRaySpace marked this conversation as resolved.
Show resolved Hide resolved
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS)

return super.onCreateOptionsMenu(menu)
}

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

Expand Down