PageRenderTime 49ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 1ms

/src/com/laomo/zxing/decode/Intents.java

https://bitbucket.org/laomo/zxing-for-android-portrait
Java | 254 lines | 62 code | 41 blank | 151 comment | 0 complexity | 08439734fd54982c511f36e21012641b MD5 | raw file
  1. /*
  2. * Copyright (C) 2008 ZXing authors
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.laomo.zxing.decode;
  17. /**
  18. * This class provides the constants to use when sending an Intent to Barcode Scanner.
  19. * These strings are effectively API and cannot be changed.
  20. *
  21. * @author dswitkin@google.com (Daniel Switkin)
  22. */
  23. public final class Intents {
  24. private Intents() {
  25. }
  26. public static final class Scan {
  27. /**
  28. * Send this intent to open the Barcodes app in scanning mode, find a barcode, and return
  29. * the results.
  30. */
  31. public static final String ACTION = "com.google.zxing.client.android.SCAN";
  32. /**
  33. * By default, sending this will decode all barcodes that we understand. However it
  34. * may be useful to limit scanning to certain formats. Use
  35. * {@link android.content.Intent#putExtra(String, String)} with one of the values below.
  36. *
  37. * Setting this is effectively shorthand for setting explicit formats with {@link #FORMATS}.
  38. * It is overridden by that setting.
  39. */
  40. public static final String MODE = "SCAN_MODE";
  41. /**
  42. * Decode only UPC and EAN barcodes. This is the right choice for shopping apps which get
  43. * prices, reviews, etc. for products.
  44. */
  45. public static final String PRODUCT_MODE = "PRODUCT_MODE";
  46. /**
  47. * Decode only 1D barcodes.
  48. */
  49. public static final String ONE_D_MODE = "ONE_D_MODE";
  50. /**
  51. * Decode only QR codes.
  52. */
  53. public static final String QR_CODE_MODE = "QR_CODE_MODE";
  54. /**
  55. * Decode only Data Matrix codes.
  56. */
  57. public static final String DATA_MATRIX_MODE = "DATA_MATRIX_MODE";
  58. /**
  59. * Comma-separated list of formats to scan for. The values must match the names of
  60. * {@link com.google.zxing.BarcodeFormat}s, e.g. {@link com.google.zxing.BarcodeFormat#EAN_13}.
  61. * Example: "EAN_13,EAN_8,QR_CODE"
  62. *
  63. * This overrides {@link #MODE}.
  64. */
  65. public static final String FORMATS = "SCAN_FORMATS";
  66. /**
  67. * @see com.google.zxing.DecodeHintType#CHARACTER_SET
  68. */
  69. public static final String CHARACTER_SET = "CHARACTER_SET";
  70. /**
  71. * Optional parameters to specify the width and height of the scanning rectangle in pixels.
  72. * The app will try to honor these, but will clamp them to the size of the preview frame.
  73. * You should specify both or neither, and pass the size as an int.
  74. */
  75. public static final String WIDTH = "SCAN_WIDTH";
  76. public static final String HEIGHT = "SCAN_HEIGHT";
  77. /**
  78. * Desired duration in milliseconds for which to pause after a successful scan before
  79. * returning to the calling intent. Specified as a long, not an integer!
  80. * For example: 1000L, not 1000.
  81. */
  82. public static final String RESULT_DISPLAY_DURATION_MS = "RESULT_DISPLAY_DURATION_MS";
  83. /**
  84. * Prompt to show on-screen when scanning by intent. Specified as a {@link String}.
  85. */
  86. public static final String PROMPT_MESSAGE = "PROMPT_MESSAGE";
  87. /**
  88. * If a barcode is found, Barcodes returns RESULT_OK to
  89. * {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)}
  90. * of the app which requested the scan via
  91. * {@link android.app.Activity#startActivityForResult(android.content.Intent, int)}
  92. * The barcodes contents can be retrieved with
  93. * {@link android.content.Intent#getStringExtra(String)}.
  94. * If the user presses Back, the result code will be
  95. * RESULT_CANCELED.
  96. */
  97. public static final String RESULT = "SCAN_RESULT";
  98. /**
  99. * Call intent.getStringExtra(RESULT_FORMAT) to determine which barcode format was found.
  100. * See Contents.Format for possible values.
  101. */
  102. public static final String RESULT_FORMAT = "SCAN_RESULT_FORMAT";
  103. /**
  104. * Call intent.getByteArrayExtra(RESULT_BYTES) to get a {@code byte[]} of raw bytes in the
  105. * barcode, if available.
  106. */
  107. public static final String RESULT_BYTES = "SCAN_RESULT_BYTES";
  108. /**
  109. * Key for the value of {@link com.google.zxing.ResultMetadataType#ORIENTATION}, if available.
  110. * Call intent.getIntExtra(RESULT_ORIENTATION).
  111. */
  112. public static final String RESULT_ORIENTATION = "SCAN_RESULT_ORIENTATION";
  113. /**
  114. * Key for the value of {@link com.google.zxing.ResultMetadataType#ERROR_CORRECTION_LEVEL}, if available.
  115. * Call intent.getStringExtra(RESULT_ERROR_CORRECTION_LEVEL).
  116. */
  117. public static final String RESULT_ERROR_CORRECTION_LEVEL = "SCAN_RESULT_ERROR_CORRECTION_LEVEL";
  118. /**
  119. * Prefix for keys that map to the values of {@link com.google.zxing.ResultMetadataType#BYTE_SEGMENTS},
  120. * if available. The actual values will be set under a series of keys formed by adding 0, 1, 2, ...
  121. * to this prefix. So the first byte segment is under key "SCAN_RESULT_BYTE_SEGMENTS_0" for example.
  122. */
  123. public static final String RESULT_BYTE_SEGMENTS_PREFIX = "SCAN_RESULT_BYTE_SEGMENTS_";
  124. /**
  125. * Setting this to false will not save scanned codes in the history.
  126. */
  127. public static final String SAVE_HISTORY = "SAVE_HISTORY";
  128. private Scan() {
  129. }
  130. }
  131. public static final class History {
  132. public static final String ITEM_NUMBER = "ITEM_NUMBER";
  133. private History() {
  134. }
  135. }
  136. public static final class Encode {
  137. /**
  138. * Send this intent to encode a piece of data as a QR code and display it full screen, so
  139. * that another person can scan the barcode from your screen.
  140. */
  141. public static final String ACTION = "com.google.zxing.client.android.ENCODE";
  142. /**
  143. * The data to encode. Use {@link android.content.Intent#putExtra(String, String)} or
  144. * {@link android.content.Intent#putExtra(String, android.os.Bundle)},
  145. * depending on the type and format specified. Non-QR Code formats should
  146. * just use a String here. For QR Code, see Contents for details.
  147. */
  148. public static final String DATA = "ENCODE_DATA";
  149. /**
  150. * The type of data being supplied if the format is QR Code. Use
  151. * {@link android.content.Intent#putExtra(String, String)} with one of {@link Contents.Type}.
  152. */
  153. public static final String TYPE = "ENCODE_TYPE";
  154. /**
  155. * The barcode format to be displayed. If this isn't specified or is blank,
  156. * it defaults to QR Code. Use {@link android.content.Intent#putExtra(String, String)}, where
  157. * format is one of {@link com.google.zxing.BarcodeFormat}.
  158. */
  159. public static final String FORMAT = "ENCODE_FORMAT";
  160. /**
  161. * Normally the contents of the barcode are displayed to the user in a TextView. Setting this
  162. * boolean to false will hide that TextView, showing only the encode barcode.
  163. */
  164. public static final String SHOW_CONTENTS = "ENCODE_SHOW_CONTENTS";
  165. private Encode() {
  166. }
  167. }
  168. public static final class SearchBookContents {
  169. /**
  170. * Use Google Book Search to search the contents of the book provided.
  171. */
  172. public static final String ACTION = "com.google.zxing.client.android.SEARCH_BOOK_CONTENTS";
  173. /**
  174. * The book to search, identified by ISBN number.
  175. */
  176. public static final String ISBN = "ISBN";
  177. /**
  178. * An optional field which is the text to search for.
  179. */
  180. public static final String QUERY = "QUERY";
  181. private SearchBookContents() {
  182. }
  183. }
  184. public static final class WifiConnect {
  185. /**
  186. * Internal intent used to trigger connection to a wi-fi network.
  187. */
  188. public static final String ACTION = "com.google.zxing.client.android.WIFI_CONNECT";
  189. /**
  190. * The network to connect to, all the configuration provided here.
  191. */
  192. public static final String SSID = "SSID";
  193. /**
  194. * The network to connect to, all the configuration provided here.
  195. */
  196. public static final String TYPE = "TYPE";
  197. /**
  198. * The network to connect to, all the configuration provided here.
  199. */
  200. public static final String PASSWORD = "PASSWORD";
  201. private WifiConnect() {
  202. }
  203. }
  204. public static final class Share {
  205. /**
  206. * Give the user a choice of items to encode as a barcode, then render it as a QR Code and
  207. * display onscreen for a friend to scan with their phone.
  208. */
  209. public static final String ACTION = "com.google.zxing.client.android.SHARE";
  210. private Share() {
  211. }
  212. }
  213. }