Issue 549, Make slightly more consistent by changing value of as-yet-unused key ENCOD...
[zxing.git] / android / src / com / google / zxing / client / android / Intents.java
index 0d13542..6605baf 100755 (executable)
 
 package com.google.zxing.client.android;
 
+/**
+ * This class provides the constants to use when sending an Intent to Barcode Scanner.
+ * These strings are effectively API and cannot be changed.
+ *
+ * @author dswitkin@google.com (Daniel Switkin)
+ */
 public final class Intents {
+  private Intents() {
+  }
 
   public static final class Scan {
     /**
@@ -25,16 +33,31 @@ public final class Intents {
      */
     public static final String ACTION = "com.google.zxing.client.android.SCAN";
 
-    // For compatibility only - do not use in new code, this will go away!
-    public static final String DEPRECATED_ACTION = "com.android.barcodes.SCAN";
-
     /**
      * By default, sending Scan.ACTION will decode all barcodes that we understand. However it
      * may be useful to limit scanning to certain formats. Use Intent.putExtra(MODE, value) with
-     * one of the values below (optional).
+     * one of the values below ({@link #PRODUCT_MODE}, {@link #ONE_D_MODE}, {@link #QR_CODE_MODE}).
+     * Optional.
+     *
+     * Setting this is effectively shorthnad for setting explicit formats with {@link #SCAN_FORMATS}.
+     * It is overridden by that setting.
      */
     public static final String MODE = "SCAN_MODE";
 
+    /**
+     * Comma-separated list of formats to scan for. The values must match the names of
+     * {@link com.google.zxing.BarcodeFormat}s, such as {@link com.google.zxing.BarcodeFormat#EAN_13}.
+     * Example: "EAN_13,EAN_8,QR_CODE"
+     *
+     * This overrides {@link #MODE}.
+     */
+    public static final String SCAN_FORMATS = "SCAN_FORMATS";
+
+    /**
+     * @see com.google.zxing.DecodeHintType#CHARACTER_SET
+     */
+    public static final String CHARACTER_SET = "CHARACTER_SET";
+
     /**
      * Decode only UPC and EAN barcodes. This is the right choice for shopping apps which get
      * prices, reviews, etc. for products.
@@ -51,6 +74,11 @@ public final class Intents {
      */
     public static final String QR_CODE_MODE = "QR_CODE_MODE";
 
+    /**
+     * Decode only Data Matrix codes.
+     */
+    public static final String DATA_MATRIX_MODE = "DATA_MATRIX_MODE";
+
     /**
      * If a barcode is found, Barcodes returns RESULT_OK to onActivityResult() of the app which
      * requested the scan via startSubActivity(). The barcodes contents can be retrieved with
@@ -64,6 +92,14 @@ public final class Intents {
      * See Contents.Format for possible values.
      */
     public static final String RESULT_FORMAT = "SCAN_RESULT_FORMAT";
+
+    /**
+     * Setting this to false will not save scanned codes in the history.
+     */
+    public static final String SAVE_HISTORY = "SAVE_HISTORY";
+
+    private Scan() {
+    }
   }
 
   public static final class Encode {
@@ -73,20 +109,28 @@ public final class Intents {
      */
     public static final String ACTION = "com.google.zxing.client.android.ENCODE";
 
-    // For compatibility only - do not use in new code, this will go away!
-    public static final String DEPRECATED_ACTION = "com.android.barcodes.ENCODE";
-
     /**
      * The data to encode. Use Intent.putExtra(DATA, data) where data is either a String or a
-     * Bundle, depending on the type specified. See Contents for details.
+     * Bundle, depending on the type and format specified. Non-QR Code formats should
+     * just use a String here. For QR Code, see Contents for details.
      */
     public static final String DATA = "ENCODE_DATA";
 
     /**
-     * The type of data being supplied. Use Intent.putExtra(TYPE, type) with one of
-     * Contents.Type.
+     * The type of data being supplied if the format is QR Code. Use
+     * Intent.putExtra(TYPE, type) with one of Contents.Type.
      */
     public static final String TYPE = "ENCODE_TYPE";
+    
+    /**
+     * The barcode format to be displayed. If this isn't specified or is blank, 
+     * it defaults to QR Code. Use Intent.putExtra(FORMAT, format), where
+     * format is one of Contents.Format. 
+     */
+    public static final String FORMAT = "ENCODE_FORMAT";
+
+    private Encode() {
+    }
   }
 
   public static final class SearchBookContents {
@@ -95,9 +139,6 @@ public final class Intents {
      */
     public static final String ACTION = "com.google.zxing.client.android.SEARCH_BOOK_CONTENTS";
 
-    // For compatibility only - do not use in new code, this will go away!
-    public static final String DEPRECATED_ACTION = "com.android.barcodes.SEARCH_BOOK_CONTENTS";
-
     /**
      * The book to search, identified by ISBN number.
      */
@@ -107,14 +148,45 @@ public final class Intents {
      * An optional field which is the text to search for.
      */
     public static final String QUERY = "QUERY";
+
+    private SearchBookContents() {
+    }
   }
 
+  public static final class WifiConnect {
+           /**
+            * Internal intent used to trigger connection to a wi-fi network.
+            */
+           public static final String ACTION = "com.google.zxing.client.android.WIFI_CONNECT";
+
+           /**
+            * The network to connect to, all the configuration provided here.
+            */
+           public static final String SSID = "SSID";
+
+           /**
+            * The network to connect to, all the configuration provided here.
+            */
+           public static final String TYPE = "TYPE";
+
+           /**
+            * The network to connect to, all the configuration provided here.
+            */
+           public static final String PASSWORD = "PASSWORD";
+
+           private WifiConnect() {
+           }
+         }
+
+
   public static final class Share {
     /**
      * Give the user a choice of items to encode as a barcode, then render it as a QR Code and
      * display onscreen for a friend to scan with their phone.
      */
     public static final String ACTION = "com.google.zxing.client.android.SHARE";
-  }
 
+    private Share() {
+    }
+  }
 }