Lots of updates:
[zxing.git] / android / src / com / google / zxing / client / android / Contents.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 import android.provider.Contacts;
20
21 /**
22  * The set of constants to use when sending Barcode Scanner an Intent which requests a barcode
23  * to be encoded.
24  *
25  * @author dswitkin@google.com (Daniel Switkin)
26  */
27 public final class Contents {
28   private Contents() {
29   }
30
31   /**
32    * All the formats we know about.
33    */
34   public static final class Format {
35     public static final String UPC_A = "UPC_A";
36     public static final String UPC_E = "UPC_E";
37     public static final String EAN_8 = "EAN_8";
38     public static final String EAN_13 = "EAN_13";
39     public static final String CODE_39 = "CODE_39";
40     public static final String CODE_128 = "CODE_128";
41     public static final String QR_CODE = "QR_CODE";
42     private Format() {
43     }
44   }
45
46   public static final class Type {
47     /**
48      * Plain text. Use Intent.putExtra(DATA, string). This can be used for URLs too, but string
49      * must include "http://" or "https://".
50      */
51     public static final String TEXT = "TEXT_TYPE";
52
53     /**
54      * An email type. Use Intent.putExtra(DATA, string) where string is the email address.
55      */
56     public static final String EMAIL = "EMAIL_TYPE";
57
58     /**
59      * Use Intent.putExtra(DATA, string) where string is the phone number to call.
60      */
61     public static final String PHONE = "PHONE_TYPE";
62
63     /**
64      * An SMS type. Use Intent.putExtra(DATA, string) where string is the number to SMS.
65      */
66     public static final String SMS = "SMS_TYPE";
67
68     /**
69      * A contact. Send a request to encode it as follows:
70      * <p/>
71      * import android.provider.Contacts;
72      * <p/>
73      * Intent intent = new Intent(Intents.Encode.ACTION);
74      * intent.putExtra(Intents.Encode.TYPE, CONTACT);
75      * Bundle bundle = new Bundle();
76      * bundle.putString(Contacts.Intents.Insert.NAME, "Jenny");
77      * bundle.putString(Contacts.Intents.Insert.PHONE, "8675309");
78      * bundle.putString(Contacts.Intents.Insert.EMAIL, "jenny@the80s.com");
79      * bundle.putString(Contacts.Intents.Insert.POSTAL, "123 Fake St. San Francisco, CA 94102");
80      * intent.putExtra(Intents.Encode.DATA, bundle);
81      */
82     public static final String CONTACT = "CONTACT_TYPE";
83
84     /**
85      * A geographic location. Use as follows:
86      * Bundle bundle = new Bundle();
87      * bundle.putFloat("LAT", latitude);
88      * bundle.putFloat("LONG", longitude);
89      * intent.putExtra(Intents.Encode.DATA, bundle);
90      */
91     public static final String LOCATION = "LOCATION_TYPE";
92
93     private Type() {
94     }
95   }
96
97   /**
98    * When using Type.CONTACT, these arrays provide the keys for adding or retrieving multiple
99    * phone numbers and addresses.
100    */
101   public static final String[] PHONE_KEYS = {
102       Contacts.Intents.Insert.PHONE,
103       Contacts.Intents.Insert.SECONDARY_PHONE,
104       Contacts.Intents.Insert.TERTIARY_PHONE
105   };
106
107   public static final String[] EMAIL_KEYS = {
108       Contacts.Intents.Insert.EMAIL,
109       Contacts.Intents.Insert.SECONDARY_EMAIL,
110       Contacts.Intents.Insert.TERTIARY_EMAIL
111   };
112 }