1 /*
2  * Copyright (C) 2010 The Android Open Source Project
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.android.contacts.list;
18 
19 import android.content.Intent;
20 import android.net.Uri;
21 import android.os.Parcel;
22 import android.os.Parcelable;
23 
24 /**
25  * Parsed form of the intent sent to the Contacts application.
26  */
27 public class ContactsRequest {
28 
29     /** Default mode: browse contacts */
30     public static final int ACTION_DEFAULT = 10;
31 
32     /** Show all contacts */
33     public static final int ACTION_ALL_CONTACTS = 15;
34 
35     /** Show all contacts with phone numbers */
36     public static final int ACTION_CONTACTS_WITH_PHONES = 17;
37 
38     /** Show contents of a specific group */
39     public static final int ACTION_GROUP = 20;
40 
41     /** Show all starred contacts */
42     public static final int ACTION_STARRED = 30;
43 
44     /** Show frequently contacted contacts */
45     public static final int ACTION_FREQUENT = 40;
46 
47     /** Show starred and the frequent */
48     public static final int ACTION_STREQUENT = 50;
49 
50     /** Show all contacts and pick them when clicking */
51     public static final int ACTION_PICK_CONTACT = 60;
52 
53     /** Show all contacts as well as the option to create a new one */
54     public static final int ACTION_PICK_OR_CREATE_CONTACT = 70;
55 
56     /** Show all contacts and pick them for edit when clicking, and allow creating a new contact */
57     public static final int ACTION_INSERT_OR_EDIT_CONTACT = 80;
58 
59     /** Show all phone numbers and pick them when clicking */
60     public static final int ACTION_PICK_PHONE = 90;
61 
62     /** Show all postal addresses and pick them when clicking */
63     public static final int ACTION_PICK_POSTAL = 100;
64 
65     /** Show all postal addresses and pick them when clicking */
66     public static final int ACTION_PICK_EMAIL = 105;
67 
68     /** Show all contacts and create a shortcut for the picked contact */
69     public static final int ACTION_CREATE_SHORTCUT_CONTACT = 110;
70 
71     /** Show all phone numbers and create a call shortcut for the picked number */
72     public static final int ACTION_CREATE_SHORTCUT_CALL = 120;
73 
74     /** Show all phone numbers and create an SMS shortcut for the picked number */
75     public static final int ACTION_CREATE_SHORTCUT_SMS = 130;
76 
77     /** Show all contacts and activate the specified one */
78     public static final int ACTION_VIEW_CONTACT = 140;
79 
80     /** Show contacts recommended for joining with a specified target contact */
81     public static final int ACTION_PICK_JOIN = 150;
82 
83     private boolean mValid = true;
84     private int mActionCode = ACTION_DEFAULT;
85     private CharSequence mTitle;
86     private boolean mSearchMode;
87     private String mQueryString;
88     private boolean mIncludeProfile;
89     private boolean mLegacyCompatibilityMode;
90     private boolean mDirectorySearchEnabled = true;
91     private Uri mContactUri;
92 
93     @Override
toString()94     public String toString() {
95         return "{ContactsRequest:mValid=" + mValid
96                 + " mActionCode=" + mActionCode
97                 + " mTitle=" + mTitle
98                 + " mSearchMode=" + mSearchMode
99                 + " mQueryString=" + mQueryString
100                 + " mIncludeProfile=" + mIncludeProfile
101                 + " mLegacyCompatibilityMode=" + mLegacyCompatibilityMode
102                 + " mDirectorySearchEnabled=" + mDirectorySearchEnabled
103                 + " mContactUri=" + mContactUri
104                 + "}";
105     }
106 
isValid()107     public boolean isValid() {
108         return mValid;
109     }
110 
setValid(boolean flag)111     public void setValid(boolean flag) {
112         mValid = flag;
113     }
114 
setActivityTitle(CharSequence title)115     public void setActivityTitle(CharSequence title) {
116         mTitle = title;
117     }
118 
getActivityTitle()119     public CharSequence getActivityTitle() {
120         return mTitle;
121     }
122 
getActionCode()123     public int getActionCode() {
124         return mActionCode;
125     }
126 
setActionCode(int actionCode)127     public void setActionCode(int actionCode) {
128         mActionCode = actionCode;
129     }
130 
isSearchMode()131     public boolean isSearchMode() {
132         return mSearchMode;
133     }
134 
setSearchMode(boolean flag)135     public void setSearchMode(boolean flag) {
136         mSearchMode = flag;
137     }
138 
getQueryString()139     public String getQueryString() {
140         return mQueryString;
141     }
142 
setQueryString(String string)143     public void setQueryString(String string) {
144         mQueryString = string;
145     }
146 
shouldIncludeProfile()147     public boolean shouldIncludeProfile() {
148         return mIncludeProfile;
149     }
150 
setIncludeProfile(boolean includeProfile)151     public void setIncludeProfile(boolean includeProfile) {
152         mIncludeProfile = includeProfile;
153     }
154 
isLegacyCompatibilityMode()155     public boolean isLegacyCompatibilityMode() {
156         return mLegacyCompatibilityMode;
157     }
158 
setLegacyCompatibilityMode(boolean flag)159     public void setLegacyCompatibilityMode(boolean flag) {
160         mLegacyCompatibilityMode = flag;
161     }
162 
163     /**
164      * Determines whether this search request should include directories or
165      * is limited to local contacts only.
166      */
isDirectorySearchEnabled()167     public boolean isDirectorySearchEnabled() {
168         return mDirectorySearchEnabled;
169     }
170 
setDirectorySearchEnabled(boolean flag)171     public void setDirectorySearchEnabled(boolean flag) {
172         mDirectorySearchEnabled = flag;
173     }
174 
getContactUri()175     public Uri getContactUri() {
176         return mContactUri;
177     }
178 
setContactUri(Uri contactUri)179     public void setContactUri(Uri contactUri) {
180         this.mContactUri = contactUri;
181     }
182 }
183