1 /*
2  * Copyright (C) 2015 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 package com.android.messaging.ui;
17 
18 import android.app.Activity;
19 import android.app.Fragment;
20 import android.app.PendingIntent;
21 import android.content.ContentValues;
22 import android.content.Context;
23 import android.content.Intent;
24 import android.graphics.Point;
25 import android.graphics.Rect;
26 import android.net.Uri;
27 import android.os.Bundle;
28 
29 import com.android.messaging.Factory;
30 import com.android.messaging.datamodel.data.MessageData;
31 import com.android.messaging.util.ConversationIdSet;
32 
33 /**
34  * A central repository of Intents used to start activities.
35  */
36 public abstract class UIIntents {
get()37     public static UIIntents get() {
38         return Factory.get().getUIIntents();
39     }
40 
41     // Intent extras
42     public static final String UI_INTENT_EXTRA_CONVERSATION_ID = "conversation_id";
43 
44     // Sending draft data (from share intent / message forwarding) to the ConversationActivity.
45     public static final String UI_INTENT_EXTRA_DRAFT_DATA = "draft_data";
46 
47     // The request code for picking image from the Document picker.
48     public static final int REQUEST_PICK_IMAGE_FROM_DOCUMENT_PICKER = 1400;
49 
50     // Indicates what type of notification this applies to (See BugleNotifications:
51     // UPDATE_NONE, UPDATE_MESSAGES, UPDATE_ERRORS, UPDATE_ALL)
52     public static final String UI_INTENT_EXTRA_NOTIFICATIONS_UPDATE = "notifications_update";
53 
54     // Pass a set of conversation id's.
55     public static final String UI_INTENT_EXTRA_CONVERSATION_ID_SET = "conversation_id_set";
56 
57     // Sending class zero message to its activity
58     public static final String UI_INTENT_EXTRA_MESSAGE_VALUES = "message_values";
59 
60     // For the widget to go to the ConversationList from the Conversation.
61     public static final String UI_INTENT_EXTRA_GOTO_CONVERSATION_LIST = "goto_conv_list";
62 
63     // Indicates whether a conversation is launched with custom transition.
64     public static final String UI_INTENT_EXTRA_WITH_CUSTOM_TRANSITION = "with_custom_transition";
65 
66     public static final String ACTION_RESET_NOTIFICATIONS =
67             "com.android.messaging.reset_notifications";
68 
69     // Sending VCard uri to VCard detail activity
70     public static final String UI_INTENT_EXTRA_VCARD_URI = "vcard_uri";
71 
72     public static final String CMAS_COMPONENT = "com.android.cellbroadcastreceiver";
73 
74     // Intent action for local broadcast receiver for conversation self id change.
75     public static final String CONVERSATION_SELF_ID_CHANGE_BROADCAST_ACTION =
76             "conversation_self_id_change";
77 
78     // Conversation self id
79     public static final String UI_INTENT_EXTRA_CONVERSATION_SELF_ID = "conversation_self_id";
80 
81     // For opening an APN editor on a particular row in the apn database.
82     public static final String UI_INTENT_EXTRA_APN_ROW_ID = "apn_row_id";
83 
84     // Subscription id
85     public static final String UI_INTENT_EXTRA_SUB_ID = "sub_id";
86 
87     // Per-Subscription setting activity title
88     public static final String UI_INTENT_EXTRA_PER_SUBSCRIPTION_SETTING_TITLE =
89             "per_sub_setting_title";
90 
91     // Is application settings launched as the top level settings activity?
92     public static final String UI_INTENT_EXTRA_TOP_LEVEL_SETTINGS = "top_level_settings";
93 
94     // Sending attachment uri from widget
95     public static final String UI_INTENT_EXTRA_ATTACHMENT_URI = "attachment_uri";
96 
97     // Sending attachment content type from widget
98     public static final String UI_INTENT_EXTRA_ATTACHMENT_TYPE = "attachment_type";
99 
100     public static final String ACTION_WIDGET_CONVERSATION =
101             "com.android.messaging.widget_conversation:";
102 
103     public static final String UI_INTENT_EXTRA_REQUIRES_MMS = "requires_mms";
104 
105     public static final String UI_INTENT_EXTRA_SELF_ID = "self_id";
106 
107     // Message position to scroll to.
108     public static final String UI_INTENT_EXTRA_MESSAGE_POSITION = "message_position";
109 
110     /**
111      * Launch the permission check activity
112      */
launchPermissionCheckActivity(final Context context)113     public abstract void launchPermissionCheckActivity(final Context context);
114 
launchConversationListActivity(final Context context)115     public abstract void launchConversationListActivity(final Context context);
116 
117     /**
118      * Launch an activity to show a conversation. This method by default provides no additional
119      * activity options.
120      */
launchConversationActivity(final Context context, final String conversationId, final MessageData draft)121     public void launchConversationActivity(final Context context,
122             final String conversationId, final MessageData draft) {
123         launchConversationActivity(context, conversationId, draft, null,
124                 false /* withCustomTransition */);
125     }
126 
127     /**
128      * Launch an activity to show a conversation.
129      */
launchConversationActivity(final Context context, final String conversationId, final MessageData draft, final Bundle activityOptions, final boolean withCustomTransition)130     public abstract void launchConversationActivity(final Context context,
131             final String conversationId, final MessageData draft, final Bundle activityOptions,
132             final boolean withCustomTransition);
133 
134 
135     /**
136      * Launch an activity to show conversation with conversation list in back stack.
137      */
launchConversationActivityWithParentStack(Context context, String conversationId, String smsBody)138     public abstract void launchConversationActivityWithParentStack(Context context,
139             String conversationId, String smsBody);
140 
141     /**
142      * Launch an activity to show a conversation as a new task.
143      */
launchConversationActivityNewTask(final Context context, final String conversationId)144     public abstract void launchConversationActivityNewTask(final Context context,
145             final String conversationId);
146 
147     /**
148      * Launch an activity to start a new conversation
149      */
launchCreateNewConversationActivity(final Context context, final MessageData draft)150     public abstract void launchCreateNewConversationActivity(final Context context,
151             final MessageData draft);
152 
153     /**
154      * Launch debug activity to set MMS config options.
155      */
launchDebugMmsConfigActivity(final Context context)156     public abstract void launchDebugMmsConfigActivity(final Context context);
157 
158     /**
159      * Launch an activity to change settings.
160      */
launchSettingsActivity(final Context context)161     public abstract void launchSettingsActivity(final Context context);
162 
163     /**
164      * Launch an activity to add a contact with a given destination.
165      */
launchAddContactActivity(final Context context, final String destination)166     public abstract void launchAddContactActivity(final Context context, final String destination);
167 
168     /**
169      * Launch an activity to show the document picker to pick an image.
170      * @param fragment the requesting fragment
171      */
launchDocumentImagePicker(final Fragment fragment)172     public abstract void launchDocumentImagePicker(final Fragment fragment);
173 
174     /**
175      * Launch an activity to show people & options for a given conversation.
176      */
launchPeopleAndOptionsActivity(final Activity context, final String conversationId)177     public abstract void launchPeopleAndOptionsActivity(final Activity context,
178             final String conversationId);
179 
180     /**
181      * Launch an external activity to handle a phone call
182      * @param phoneNumber the phone number to call
183      * @param clickPosition is the location tapped to start this launch for transition use
184      */
launchPhoneCallActivity(final Context context, final String phoneNumber, final Point clickPosition)185     public abstract void launchPhoneCallActivity(final Context context, final String phoneNumber,
186                                                  final Point clickPosition);
187 
188     /**
189      * Launch an activity to show archived conversations.
190      */
launchArchivedConversationsActivity(final Context context)191     public abstract void launchArchivedConversationsActivity(final Context context);
192 
193     /**
194      * Launch an activity to show blocked participants.
195      */
launchBlockedParticipantsActivity(final Context context)196     public abstract void launchBlockedParticipantsActivity(final Context context);
197 
198     /**
199      * Launch an activity to show a class zero message
200      */
launchClassZeroActivity(Context context, ContentValues messageValues)201     public abstract void launchClassZeroActivity(Context context, ContentValues messageValues);
202 
203     /**
204      * Launch an activity to let the user forward a message
205      */
launchForwardMessageActivity(Context context, MessageData message)206     public abstract void launchForwardMessageActivity(Context context, MessageData message);
207 
208     /**
209      * Launch an activity to show details for a VCard
210      */
launchVCardDetailActivity(Context context, Uri vcardUri)211     public abstract void launchVCardDetailActivity(Context context, Uri vcardUri);
212 
213     /**
214      * Launch an external activity that handles the intent to add VCard to contacts
215      */
launchSaveVCardToContactsActivity(Context context, Uri vcardUri)216     public abstract void launchSaveVCardToContactsActivity(Context context, Uri vcardUri);
217 
218     /**
219      * Launch an activity to let the user select & unselect the list of attachments to send.
220      */
launchAttachmentChooserActivity(final Activity activity, final String conversationId, final int requestCode)221     public abstract void launchAttachmentChooserActivity(final Activity activity,
222             final String conversationId, final int requestCode);
223 
224     /**
225      * Launch full screen video viewer.
226      */
launchFullScreenVideoViewer(Context context, Uri videoUri)227     public abstract void launchFullScreenVideoViewer(Context context, Uri videoUri);
228 
229     /**
230      * Launch full screen photo viewer.
231      */
launchFullScreenPhotoViewer(Activity activity, Uri initialPhoto, Rect initialPhotoBounds, Uri photosUri)232     public abstract void launchFullScreenPhotoViewer(Activity activity, Uri initialPhoto,
233             Rect initialPhotoBounds, Uri photosUri);
234 
235     /**
236      * Launch an activity to show general app settings
237      * @param topLevel indicates whether the app settings is launched as the top-level settings
238      *        activity (instead of SettingsActivity which shows a collapsed view of the app
239      *        settings + one settings item per subscription). This is true when there's only one
240      *        active SIM in the system so we can show this activity directly.
241      */
launchApplicationSettingsActivity(Context context, boolean topLevel)242     public abstract void launchApplicationSettingsActivity(Context context, boolean topLevel);
243 
244     /**
245      * Launch an activity to show per-subscription settings
246      */
launchPerSubscriptionSettingsActivity(Context context, int subId, String settingTitle)247     public abstract void launchPerSubscriptionSettingsActivity(Context context, int subId,
248             String settingTitle);
249 
250     /**
251      * Get a ACTION_VIEW intent
252      * @param url display the data in the url to users
253      */
getViewUrlIntent(final String url)254     public abstract Intent getViewUrlIntent(final String url);
255 
256     /**
257      * Get an intent to launch the ringtone picker
258      * @param title the title to show in the ringtone picker
259      * @param existingUri the currently set uri
260      * @param defaultUri the default uri if none is currently set
261      * @param toneType type of ringtone to pick, maybe any of RingtoneManager.TYPE_*
262      */
getRingtonePickerIntent(final String title, final Uri existingUri, final Uri defaultUri, final int toneType)263     public abstract Intent getRingtonePickerIntent(final String title, final Uri existingUri,
264             final Uri defaultUri, final int toneType);
265 
266     /**
267      * Get an intent to launch the wireless alert viewer.
268      */
getWirelessAlertsIntent()269     public abstract Intent getWirelessAlertsIntent();
270 
271     /**
272      * Get an intent to launch the dialog for changing the default SMS App.
273      */
getChangeDefaultSmsAppIntent(final Activity activity)274     public abstract Intent getChangeDefaultSmsAppIntent(final Activity activity);
275 
276     /**
277      * Broadcast conversation self id change so it may be reflected in the message compose UI.
278      */
broadcastConversationSelfIdChange(final Context context, final String conversationId, final String conversationSelfId)279     public abstract void broadcastConversationSelfIdChange(final Context context,
280             final String conversationId, final String conversationSelfId);
281 
282     /**
283      * Get a PendingIntent for starting conversation list from notifications.
284      */
getPendingIntentForConversationListActivity( final Context context)285     public abstract PendingIntent getPendingIntentForConversationListActivity(
286             final Context context);
287 
288     /**
289      * Get a PendingIntent for starting conversation list from widget.
290      */
getWidgetPendingIntentForConversationListActivity( final Context context)291     public abstract PendingIntent getWidgetPendingIntentForConversationListActivity(
292             final Context context);
293 
294     /**
295      * Get a PendingIntent for showing a conversation from notifications.
296      */
getPendingIntentForConversationActivity(final Context context, final String conversationId, final MessageData draft)297     public abstract PendingIntent getPendingIntentForConversationActivity(final Context context,
298             final String conversationId, final MessageData draft);
299 
300     /**
301      * Get an Intent for showing a conversation from the widget.
302      */
getIntentForConversationActivity(final Context context, final String conversationId, final MessageData draft)303     public abstract Intent getIntentForConversationActivity(final Context context,
304             final String conversationId, final MessageData draft);
305 
306     /**
307      * Get a PendingIntent for sending a message to a conversation, without opening the Bugle UI.
308      *
309      * <p>This is intended to be used by the Android Wear companion app when sending transcribed
310      * voice replies.
311      */
getPendingIntentForSendingMessageToConversation( final Context context, final String conversationId, final String selfId, final boolean requiresMms, final int requestCode)312     public abstract PendingIntent getPendingIntentForSendingMessageToConversation(
313             final Context context, final String conversationId, final String selfId,
314             final boolean requiresMms, final int requestCode);
315 
316     /**
317      * Get a PendingIntent for clearing notifications.
318      *
319      * <p>This is intended to be used by notifications.
320      */
getPendingIntentForClearingNotifications(final Context context, final int updateTargets, final ConversationIdSet conversationIdSet, final int requestCode)321     public abstract PendingIntent getPendingIntentForClearingNotifications(final Context context,
322             final int updateTargets, final ConversationIdSet conversationIdSet,
323             final int requestCode);
324 
325     /**
326      * Get a PendingIntent for showing low storage notifications.
327      */
getPendingIntentForLowStorageNotifications(final Context context)328     public abstract PendingIntent getPendingIntentForLowStorageNotifications(final Context context);
329 
330     /**
331      * Get a PendingIntent for showing a new message to a secondary user.
332      */
getPendingIntentForSecondaryUserNewMessageNotification( final Context context)333     public abstract PendingIntent getPendingIntentForSecondaryUserNewMessageNotification(
334             final Context context);
335 
336     /**
337      * Get an intent for showing the APN editor.
338      */
getApnEditorIntent(final Context context, final String rowId, int subId)339     public abstract Intent getApnEditorIntent(final Context context, final String rowId, int subId);
340 
341     /**
342      * Get an intent for showing the APN settings.
343      */
getApnSettingsIntent(final Context context, final int subId)344     public abstract Intent getApnSettingsIntent(final Context context, final int subId);
345 
346     /**
347      * Get an intent for showing advanced settings.
348      */
getAdvancedSettingsIntent(final Context context)349     public abstract Intent getAdvancedSettingsIntent(final Context context);
350 
351     /**
352      * Get an intent for the LaunchConversationActivity.
353      */
getLaunchConversationActivityIntent(final Context context)354     public abstract Intent getLaunchConversationActivityIntent(final Context context);
355 
356     /**
357      *  Tell MediaScanner to re-scan the specified volume.
358      */
kickMediaScanner(final Context context, final String volume)359     public abstract void kickMediaScanner(final Context context, final String volume);
360 
361     /**
362      * Launch to browser for a url.
363      */
launchBrowserForUrl(final Context context, final String url)364     public abstract void launchBrowserForUrl(final Context context, final String url);
365 
366     /**
367      * Get a PendingIntent for the widget conversation template.
368      */
getWidgetPendingIntentForConversationActivity( final Context context, final String conversationId, final int requestCode)369     public abstract PendingIntent getWidgetPendingIntentForConversationActivity(
370             final Context context, final String conversationId, final int requestCode);
371 
372     /**
373      * Get a PendingIntent for the conversation widget configuration activity template.
374      */
getWidgetPendingIntentForConfigurationActivity( final Context context, final int appWidgetId)375     public abstract PendingIntent getWidgetPendingIntentForConfigurationActivity(
376             final Context context, final int appWidgetId);
377 
378 }
379