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 a media from the Document picker. 48 public static final int REQUEST_PICK_MEDIA_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/video. 170 * 171 * @param fragment the requesting fragment 172 */ launchDocumentImagePicker(final Fragment fragment)173 public abstract void launchDocumentImagePicker(final Fragment fragment); 174 175 /** 176 * Launch an activity to show people & options for a given conversation. 177 */ launchPeopleAndOptionsActivity(final Activity context, final String conversationId)178 public abstract void launchPeopleAndOptionsActivity(final Activity context, 179 final String conversationId); 180 181 /** 182 * Launch an external activity to handle a phone call 183 * @param phoneNumber the phone number to call 184 * @param clickPosition is the location tapped to start this launch for transition use 185 */ launchPhoneCallActivity(final Context context, final String phoneNumber, final Point clickPosition)186 public abstract void launchPhoneCallActivity(final Context context, final String phoneNumber, 187 final Point clickPosition); 188 189 /** 190 * Launch an activity to show archived conversations. 191 */ launchArchivedConversationsActivity(final Context context)192 public abstract void launchArchivedConversationsActivity(final Context context); 193 194 /** 195 * Launch an activity to show blocked participants. 196 */ launchBlockedParticipantsActivity(final Context context)197 public abstract void launchBlockedParticipantsActivity(final Context context); 198 199 /** 200 * Launch an activity to show a class zero message 201 */ launchClassZeroActivity(Context context, ContentValues messageValues)202 public abstract void launchClassZeroActivity(Context context, ContentValues messageValues); 203 204 /** 205 * Launch an activity to let the user forward a message 206 */ launchForwardMessageActivity(Context context, MessageData message)207 public abstract void launchForwardMessageActivity(Context context, MessageData message); 208 209 /** 210 * Launch an activity to show details for a VCard 211 */ launchVCardDetailActivity(Context context, Uri vcardUri)212 public abstract void launchVCardDetailActivity(Context context, Uri vcardUri); 213 214 /** 215 * Launch an external activity that handles the intent to add VCard to contacts 216 */ launchSaveVCardToContactsActivity(Context context, Uri vcardUri)217 public abstract void launchSaveVCardToContactsActivity(Context context, Uri vcardUri); 218 219 /** 220 * Launch an activity to let the user select & unselect the list of attachments to send. 221 */ launchAttachmentChooserActivity(final Activity activity, final String conversationId, final int requestCode)222 public abstract void launchAttachmentChooserActivity(final Activity activity, 223 final String conversationId, final int requestCode); 224 225 /** 226 * Launch full screen video viewer. 227 */ launchFullScreenVideoViewer(Context context, Uri videoUri)228 public abstract void launchFullScreenVideoViewer(Context context, Uri videoUri); 229 230 /** 231 * Launch full screen photo viewer. 232 */ launchFullScreenPhotoViewer(Activity activity, Uri initialPhoto, Rect initialPhotoBounds, Uri photosUri)233 public abstract void launchFullScreenPhotoViewer(Activity activity, Uri initialPhoto, 234 Rect initialPhotoBounds, Uri photosUri); 235 236 /** 237 * Launch an activity to show general app settings 238 * @param topLevel indicates whether the app settings is launched as the top-level settings 239 * activity (instead of SettingsActivity which shows a collapsed view of the app 240 * settings + one settings item per subscription). This is true when there's only one 241 * active SIM in the system so we can show this activity directly. 242 */ launchApplicationSettingsActivity(Context context, boolean topLevel)243 public abstract void launchApplicationSettingsActivity(Context context, boolean topLevel); 244 245 /** 246 * Launch an activity to show per-subscription settings 247 */ launchPerSubscriptionSettingsActivity(Context context, int subId, String settingTitle)248 public abstract void launchPerSubscriptionSettingsActivity(Context context, int subId, 249 String settingTitle); 250 251 /** 252 * Get a ACTION_VIEW intent 253 * @param url display the data in the url to users 254 */ getViewUrlIntent(final String url)255 public abstract Intent getViewUrlIntent(final String url); 256 257 /** 258 * Get an intent to launch the ringtone picker 259 * @param title the title to show in the ringtone picker 260 * @param existingUri the currently set uri 261 * @param defaultUri the default uri if none is currently set 262 * @param toneType type of ringtone to pick, maybe any of RingtoneManager.TYPE_* 263 */ getRingtonePickerIntent(final String title, final Uri existingUri, final Uri defaultUri, final int toneType)264 public abstract Intent getRingtonePickerIntent(final String title, final Uri existingUri, 265 final Uri defaultUri, final int toneType); 266 267 /** 268 * Get an intent to launch the wireless alert viewer. 269 */ getWirelessAlertsIntent()270 public abstract Intent getWirelessAlertsIntent(); 271 272 /** 273 * Get an intent to launch the dialog for changing the default SMS App. 274 */ getChangeDefaultSmsAppIntent(final Activity activity)275 public abstract Intent getChangeDefaultSmsAppIntent(final Activity activity); 276 277 /** 278 * Broadcast conversation self id change so it may be reflected in the message compose UI. 279 */ broadcastConversationSelfIdChange(final Context context, final String conversationId, final String conversationSelfId)280 public abstract void broadcastConversationSelfIdChange(final Context context, 281 final String conversationId, final String conversationSelfId); 282 283 /** 284 * Get a PendingIntent for starting conversation list from notifications. 285 */ getPendingIntentForConversationListActivity( final Context context)286 public abstract PendingIntent getPendingIntentForConversationListActivity( 287 final Context context); 288 289 /** 290 * Get a PendingIntent for starting conversation list from widget. 291 */ getWidgetPendingIntentForConversationListActivity( final Context context)292 public abstract PendingIntent getWidgetPendingIntentForConversationListActivity( 293 final Context context); 294 295 /** 296 * Get a PendingIntent for showing a conversation from notifications. 297 */ getPendingIntentForConversationActivity(final Context context, final String conversationId, final MessageData draft)298 public abstract PendingIntent getPendingIntentForConversationActivity(final Context context, 299 final String conversationId, final MessageData draft); 300 301 /** 302 * Get an Intent for showing a conversation from the widget. 303 */ getIntentForConversationActivity(final Context context, final String conversationId, final MessageData draft)304 public abstract Intent getIntentForConversationActivity(final Context context, 305 final String conversationId, final MessageData draft); 306 307 /** 308 * Get a PendingIntent for sending a message to a conversation, without opening the Bugle UI. 309 * 310 * <p>This is intended to be used by the Android Wear companion app when sending transcribed 311 * voice replies. 312 */ getPendingIntentForSendingMessageToConversation( final Context context, final String conversationId, final String selfId, final boolean requiresMms, final int requestCode)313 public abstract PendingIntent getPendingIntentForSendingMessageToConversation( 314 final Context context, final String conversationId, final String selfId, 315 final boolean requiresMms, final int requestCode); 316 317 /** 318 * Get a PendingIntent for clearing notifications. 319 * 320 * <p>This is intended to be used by notifications. 321 */ getPendingIntentForClearingNotifications(final Context context, final int updateTargets, final ConversationIdSet conversationIdSet, final int requestCode)322 public abstract PendingIntent getPendingIntentForClearingNotifications(final Context context, 323 final int updateTargets, final ConversationIdSet conversationIdSet, 324 final int requestCode); 325 326 /** 327 * Get a PendingIntent for showing low storage notifications. 328 */ getPendingIntentForLowStorageNotifications(final Context context)329 public abstract PendingIntent getPendingIntentForLowStorageNotifications(final Context context); 330 331 /** 332 * Get a PendingIntent for showing a new message to a secondary user. 333 */ getPendingIntentForSecondaryUserNewMessageNotification( final Context context)334 public abstract PendingIntent getPendingIntentForSecondaryUserNewMessageNotification( 335 final Context context); 336 337 /** 338 * Get an intent for showing the APN editor. 339 */ getApnEditorIntent(final Context context, final String rowId, int subId)340 public abstract Intent getApnEditorIntent(final Context context, final String rowId, int subId); 341 342 /** 343 * Get an intent for showing the APN settings. 344 */ getApnSettingsIntent(final Context context, final int subId)345 public abstract Intent getApnSettingsIntent(final Context context, final int subId); 346 347 /** 348 * Get an intent for showing advanced settings. 349 */ getAdvancedSettingsIntent(final Context context)350 public abstract Intent getAdvancedSettingsIntent(final Context context); 351 352 /** 353 * Get an intent for the LaunchConversationActivity. 354 */ getLaunchConversationActivityIntent(final Context context)355 public abstract Intent getLaunchConversationActivityIntent(final Context context); 356 357 /** 358 * Tell MediaScanner to re-scan the specified volume. 359 */ kickMediaScanner(final Context context, final String volume)360 public abstract void kickMediaScanner(final Context context, final String volume); 361 362 /** 363 * Launch to browser for a url. 364 */ launchBrowserForUrl(final Context context, final String url)365 public abstract void launchBrowserForUrl(final Context context, final String url); 366 367 /** 368 * Get a PendingIntent for the widget conversation template. 369 */ getWidgetPendingIntentForConversationActivity( final Context context, final String conversationId, final int requestCode)370 public abstract PendingIntent getWidgetPendingIntentForConversationActivity( 371 final Context context, final String conversationId, final int requestCode); 372 373 /** 374 * Get a PendingIntent for the conversation widget configuration activity template. 375 */ getWidgetPendingIntentForConfigurationActivity( final Context context, final int appWidgetId)376 public abstract PendingIntent getWidgetPendingIntentForConfigurationActivity( 377 final Context context, final int appWidgetId); 378 379 } 380