Merge "Hide Save to drive in EML view. b/14277510." into ub-gmail-ur12-dev
diff --git a/src/com/android/mail/browse/InlineAttachmentViewIntentBuilder.java b/src/com/android/mail/browse/InlineAttachmentViewIntentBuilder.java
index ac169b9..1722239 100644
--- a/src/com/android/mail/browse/InlineAttachmentViewIntentBuilder.java
+++ b/src/com/android/mail/browse/InlineAttachmentViewIntentBuilder.java
@@ -20,8 +20,6 @@
import android.content.Context;
import android.content.Intent;
-import com.android.mail.providers.Message;
-
/**
* Builds an intent to be used when the user long presses an
* inline image and selects "View image".
@@ -39,5 +37,6 @@
* inline image and selects "View Image" or {@code null} if there should not
* be a "View image" option for this url.
*/
- Intent createInlineAttachmentViewIntent(Context context, String url, Message message);
+ Intent createInlineAttachmentViewIntent(
+ Context context, String url, ConversationMessage message);
}
diff --git a/src/com/android/mail/browse/MessageAttachmentBar.java b/src/com/android/mail/browse/MessageAttachmentBar.java
index 230e634..2c6cbbe 100644
--- a/src/com/android/mail/browse/MessageAttachmentBar.java
+++ b/src/com/android/mail/browse/MessageAttachmentBar.java
@@ -83,6 +83,13 @@
private static final String LOG_TAG = LogTag.getLogTag();
+ /**
+ * Boolean used to tell whether extra option 1 should always be hidden.
+ * Currently makes sure that there is no conversation because that state
+ * means that we're in the EML viewer.
+ */
+ private boolean mHideExtraOptionOne;
+
public MessageAttachmentBar(Context context) {
this(context, null);
@@ -119,6 +126,7 @@
mActionHandler.setAccount(mAccount.getEmailAddress());
mActionHandler.setMessage(message);
mActionHandler.setAttachment(mAttachment);
+ mHideExtraOptionOne = message.getConversation() == null;
// reset mSaveClicked if we are not currently downloading
// So if the download fails or the download completes, we stop
@@ -304,7 +312,7 @@
}
private boolean shouldShowExtraOption1() {
- return mActionHandler.shouldShowExtraOption1();
+ return !mHideExtraOptionOne && mActionHandler.shouldShowExtraOption1();
}
private boolean shouldShowOverflow() {
diff --git a/src/com/android/mail/browse/WebViewContextMenu.java b/src/com/android/mail/browse/WebViewContextMenu.java
index fc6ac63..a71cff2 100644
--- a/src/com/android/mail/browse/WebViewContextMenu.java
+++ b/src/com/android/mail/browse/WebViewContextMenu.java
@@ -90,7 +90,7 @@
* @param url URL of a selected link
* @return Message containing that URL
*/
- Message getMessageForClickedUrl(String url);
+ ConversationMessage getMessageForClickedUrl(String url);
}
public WebViewContextMenu(Activity host, InlineAttachmentViewIntentBuilder builder) {
@@ -385,7 +385,8 @@
* @param menu The {@link android.view.ContextMenu} that is about to be shown.
*/
private void setupImageMenu(String url, ContextMenu menu) {
- final Message msg = (mCallbacks != null) ? mCallbacks.getMessageForClickedUrl(url) : null;
+ final ConversationMessage msg =
+ (mCallbacks != null) ? mCallbacks.getMessageForClickedUrl(url) : null;
if (msg == null) {
menu.setGroupVisible(R.id.IMAGE_MENU, false);
return;
diff --git a/src/com/android/mail/photo/MailPhotoViewActivity.java b/src/com/android/mail/photo/MailPhotoViewActivity.java
index 3113bdf..5d24394 100644
--- a/src/com/android/mail/photo/MailPhotoViewActivity.java
+++ b/src/com/android/mail/photo/MailPhotoViewActivity.java
@@ -39,6 +39,7 @@
import com.android.mail.R;
import com.android.mail.analytics.Analytics;
import com.android.mail.browse.AttachmentActionHandler;
+import com.android.mail.browse.ConversationMessage;
import com.android.mail.print.PrintUtils;
import com.android.mail.providers.Attachment;
import com.android.mail.providers.Message;
@@ -79,6 +80,10 @@
private static final String EXTRA_ACCOUNT = MailPhotoViewActivity.class.getName() + "-acct";
private static final String EXTRA_MESSAGE = MailPhotoViewActivity.class.getName() + "-msg";
+ private static final String EXTRA_HIDE_EXTRA_OPTION_ONE =
+ MailPhotoViewActivity.class.getName() + "-hide-extra-option-one";
+
+ private boolean mHideExtraOptionOne;
/**
* Start a new MailPhotoViewActivity to view the given images.
@@ -86,7 +91,7 @@
* @param photoIndex The index of the photo to show first.
*/
public static void startMailPhotoViewActivity(final Context context, final String account,
- final Message msg, final int photoIndex) {
+ final ConversationMessage msg, final int photoIndex) {
final Intents.PhotoViewIntentBuilder builder =
Intents.newPhotoViewIntentBuilder(context,
"com.android.mail.photo.MailPhotoViewActivity");
@@ -104,13 +109,13 @@
* @param initialPhotoUri The uri of the photo to show first.
*/
public static void startMailPhotoViewActivity(final Context context, final String account,
- final Message msg, final String initialPhotoUri) {
+ final ConversationMessage msg, final String initialPhotoUri) {
context.startActivity(
buildMailPhotoViewActivityIntent(context, account, msg, initialPhotoUri));
}
public static Intent buildMailPhotoViewActivityIntent(
- final Context context, final String account, final Message msg,
+ final Context context, final String account, final ConversationMessage msg,
final String initialPhotoUri) {
final Intents.PhotoViewIntentBuilder builder = Intents.newPhotoViewIntentBuilder(
context, "com.android.mail.photo.MailPhotoViewActivity");
@@ -122,9 +127,11 @@
return wrapIntent(builder.build(), account, msg);
}
- private static Intent wrapIntent(final Intent intent, final String account, final Message msg) {
+ private static Intent wrapIntent(
+ final Intent intent, final String account, final ConversationMessage msg) {
intent.putExtra(EXTRA_MESSAGE, msg);
intent.putExtra(EXTRA_ACCOUNT, account);
+ intent.putExtra(EXTRA_HIDE_EXTRA_OPTION_ONE, msg.getConversation() == null);
return intent;
}
@@ -139,6 +146,7 @@
final Intent intent = getIntent();
final String account = intent.getStringExtra(EXTRA_ACCOUNT);
final Message msg = intent.getParcelableExtra(EXTRA_MESSAGE);
+ mHideExtraOptionOne = intent.getBooleanExtra(EXTRA_HIDE_EXTRA_OPTION_ONE, false);
mActionHandler.setAccount(account);
mActionHandler.setMessage(msg);
}
@@ -183,7 +191,11 @@
mShareItem.setEnabled(canShare);
mPrintItem.setEnabled(canShare);
mDownloadAgainItem.setEnabled(attachment.canSave() && attachment.isDownloading());
- mExtraOption1Item.setEnabled(mActionHandler.shouldShowExtraOption1());
+ if (mHideExtraOptionOne) {
+ mExtraOption1Item.setVisible(false);
+ } else {
+ mExtraOption1Item.setEnabled(mActionHandler.shouldShowExtraOption1());
+ }
} else {
if (mMenu != null) {
mMenu.setGroupEnabled(R.id.photo_view_menu_group, false);
diff --git a/src/com/android/mail/ui/AttachmentTileGrid.java b/src/com/android/mail/ui/AttachmentTileGrid.java
index 59ff704..b5fefcc 100644
--- a/src/com/android/mail/ui/AttachmentTileGrid.java
+++ b/src/com/android/mail/ui/AttachmentTileGrid.java
@@ -31,7 +31,6 @@
import com.android.mail.photo.MailPhotoViewActivity;
import com.android.mail.providers.Account;
import com.android.mail.providers.Attachment;
-import com.android.mail.providers.Message;
import com.android.mail.ui.AttachmentTile.AttachmentPreview;
import com.android.mail.ui.AttachmentTile.AttachmentPreviewCache;
import com.android.mail.utils.ViewUtils;
@@ -54,7 +53,7 @@
private final HashMap<String, AttachmentPreview> mAttachmentPreviews;
private FragmentManager mFragmentManager;
private Account mAccount;
- private Message mMessage;
+ private ConversationMessage mMessage;
public AttachmentTileGrid(Context context, AttributeSet attrs) {
super(context, attrs);
diff --git a/src/com/android/mail/ui/ConversationViewFragment.java b/src/com/android/mail/ui/ConversationViewFragment.java
index 15a8739..0972dd1 100644
--- a/src/com/android/mail/ui/ConversationViewFragment.java
+++ b/src/com/android/mail/ui/ConversationViewFragment.java
@@ -1128,7 +1128,7 @@
}
@Override
- public Message getMessageForClickedUrl(String url) {
+ public ConversationMessage getMessageForClickedUrl(String url) {
final String domMessageId = mUrlToMessageIdMap.get(url);
if (domMessageId == null) {
return null;