1 /** 2 * Copyright (C) 2018 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.email.activity; 18 19 import android.content.Intent; 20 import android.os.Bundle; 21 import com.android.mail.compose.ComposeActivity; 22 23 /** 24 * A subclass of {@link ComposeActivityEmail} which is exported for other Android packages to open. 25 */ 26 public class ComposeActivityEmailExternal extends ComposeActivityEmail { 27 28 @Override onCreate(Bundle savedInstanceState)29 protected void onCreate(Bundle savedInstanceState) { 30 sanitizeIntent(); 31 super.onCreate(savedInstanceState); 32 } 33 34 /** 35 * Only relevant when WebView Compose is enabled. Change this when WebView 36 * Compose is enabled for Email. 37 */ 38 @Override isExternal()39 public boolean isExternal() { 40 return false; 41 } 42 43 /** 44 * Overrides the value of {@code #getIntent()} so any future callers will get a sanitized version 45 * of the intent. 46 */ 47 // See b/114493057 for context. sanitizeIntent()48 private void sanitizeIntent() { 49 Intent sanitizedIntent = getIntent(); 50 if (sanitizedIntent != null) { 51 sanitizedIntent.removeExtra(ComposeActivity.EXTRA_IN_REFERENCE_TO_MESSAGE_URI); 52 setIntent(sanitizedIntent); 53 } 54 } 55 } 56