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