5e268ee464e86fa84caa9aceb829fec335945ae6
[zxing.git] / android / src / com / google / zxing / client / android / Intents.java
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
17 package com.google.zxing.client.android;
18
19 /**
20  * This class provides the constants to use when sending an Intent to Barcode Scanner.
21  * These strings are effectively API and cannot be changed.
22  *
23  * @author dswitkin@google.com (Daniel Switkin)
24  */
25 public final class Intents {
26   private Intents() {
27   }
28
29   public static final class Scan {
30     /**
31      * Send this intent to open the Barcodes app in scanning mode, find a barcode, and return
32      * the results.
33      */
34     public static final String ACTION = "com.google.zxing.client.android.SCAN";
35
36     /**
37      * By default, sending Scan.ACTION will decode all barcodes that we understand. However it
38      * may be useful to limit scanning to certain formats. Use Intent.putExtra(MODE, value) with
39      * one of the values below ({@link #PRODUCT_MODE}, {@link #ONE_D_MODE}, {@link #QR_CODE_MODE}).
40      * Optional.
41      *
42      * Setting this is effectively shorthnad for setting explicit formats with {@link #SCAN_FORMATS}.
43      * It is overridden by that setting.
44      */
45     public static final String MODE = "SCAN_MODE";
46
47     /**
48      * Comma-separated list of formats to scan for. The values must match the names of
49      * {@link com.google.zxing.BarcodeFormat}s, such as {@link com.google.zxing.BarcodeFormat#EAN_13}.
50      * Example: "EAN_13,EAN_8,QR_CODE"
51      *
52      * This overrides {@link #MODE}.
53      */
54     public static final String SCAN_FORMATS = "SCAN_FORMATS";
55
56     /**
57      * @see com.google.zxing.DecodeHintType#CHARACTER_SET
58      */
59     public static final String CHARACTER_SET = "CHARACTER_SET";
60
61     /**
62      * Decode only UPC and EAN barcodes. This is the right choice for shopping apps which get
63      * prices, reviews, etc. for products.
64      */
65     public static final String PRODUCT_MODE = "PRODUCT_MODE";
66
67     /**
68      * Decode only 1D barcodes (currently UPC, EAN, Code 39, and Code 128).
69      */
70     public static final String ONE_D_MODE = "ONE_D_MODE";
71
72     /**
73      * Decode only QR codes.
74      */
75     public static final String QR_CODE_MODE = "QR_CODE_MODE";
76
77     /**
78      * If a barcode is found, Barcodes returns RESULT_OK to onActivityResult() of the app which
79      * requested the scan via startSubActivity(). The barcodes contents can be retrieved with
80      * intent.getStringExtra(RESULT). If the user presses Back, the result code will be
81      * RESULT_CANCELED.
82      */
83     public static final String RESULT = "SCAN_RESULT";
84
85     /**
86      * Call intent.getStringExtra(RESULT_FORMAT) to determine which barcode format was found.
87      * See Contents.Format for possible values.
88      */
89     public static final String RESULT_FORMAT = "SCAN_RESULT_FORMAT";
90
91     /**
92      * Setting this to false will not save scanned codes in the history.
93      */
94     public static final String SAVE_HISTORY = "SAVE_HISTORY";
95
96     private Scan() {
97     }
98   }
99
100   public static final class Encode {
101     /**
102      * Send this intent to encode a piece of data as a QR code and display it full screen, so
103      * that another person can scan the barcode from your screen.
104      */
105     public static final String ACTION = "com.google.zxing.client.android.ENCODE";
106
107     /**
108      * The data to encode. Use Intent.putExtra(DATA, data) where data is either a String or a
109      * Bundle, depending on the type and format specified. Non-QR Code formats should
110      * just use a String here. For QR Code, see Contents for details.
111      */
112     public static final String DATA = "ENCODE_DATA";
113
114     /**
115      * The type of data being supplied if the format is QR Code. Use
116      * Intent.putExtra(TYPE, type) with one of Contents.Type.
117      */
118     public static final String TYPE = "ENCODE_TYPE";
119     
120     /**
121      * The barcode format to be displayed. If this isn't specified or is blank, 
122      * it defaults to QR Code. Use Intent.putExtra(FORMAT, format), where
123      * format is one of Contents.Format. 
124      */
125     public static final String FORMAT = "com.google.zxing.client.android.ENCODE_FORMAT";
126
127     private Encode() {
128     }
129   }
130
131   public static final class SearchBookContents {
132     /**
133      * Use Google Book Search to search the contents of the book provided.
134      */
135     public static final String ACTION = "com.google.zxing.client.android.SEARCH_BOOK_CONTENTS";
136
137     /**
138      * The book to search, identified by ISBN number.
139      */
140     public static final String ISBN = "ISBN";
141
142     /**
143      * An optional field which is the text to search for.
144      */
145     public static final String QUERY = "QUERY";
146
147     private SearchBookContents() {
148     }
149   }
150
151   public static final class WifiConnect {
152             /**
153              * Internal intent used to trigger connection to a wi-fi network.
154              */
155             public static final String ACTION = "com.google.zxing.client.android.WIFI_CONNECT";
156
157             /**
158              * The network to connect to, all the configuration provided here.
159              */
160             public static final String SSID = "SSID";
161
162             /**
163              * The network to connect to, all the configuration provided here.
164              */
165             public static final String TYPE = "TYPE";
166
167             /**
168              * The network to connect to, all the configuration provided here.
169              */
170             public static final String PASSWORD = "PASSWORD";
171
172             private WifiConnect() {
173             }
174           }
175
176
177   public static final class Share {
178     /**
179      * Give the user a choice of items to encode as a barcode, then render it as a QR Code and
180      * display onscreen for a friend to scan with their phone.
181      */
182     public static final String ACTION = "com.google.zxing.client.android.SHARE";
183
184     private Share() {
185     }
186   }
187 }