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