2010-07-30 00:06:00 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2010 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package com.android.email.activity;
|
|
|
|
|
|
|
|
import com.android.email.Email;
|
|
|
|
import com.android.email.R;
|
|
|
|
import com.android.email.Utility;
|
|
|
|
import com.android.email.mail.MeetingInfo;
|
|
|
|
import com.android.email.mail.PackedString;
|
Let MessageViewFragment own bottom buttons.
Create a custom view containing the bottons below MVF
(delete, move, reply, etc) and let MVF own this.
These buttons used to be owned by the XL activity itself, because
the UI for these commands will most likely be totally different
from the tablet UI, so the fragment having them looked wrong.
However, this made it harder to make changes suggested by the latest
mock, such as "put reply/forward in the message header".
I think the buttons are semantically part of the message view anyway,
so the fragment owning UI for these commands is probably the way to go.
(And let's worry about the phone UI later.)
Reason for the use of a custom view is that it will make it easier
to make non-trivial UI changes, e.g. "combine reply, reply-all and
forward and make it dropdown."
Also removed obsolete TODOs from MessageListXL.
Change-Id: Ibf93f4c70fe07bdbbe33d2adb6bbd2b96812830d
2010-09-16 18:16:46 +00:00
|
|
|
import com.android.email.provider.EmailContent.Mailbox;
|
2010-07-30 00:06:00 +00:00
|
|
|
import com.android.email.provider.EmailContent.Message;
|
|
|
|
import com.android.email.service.EmailServiceConstants;
|
|
|
|
|
|
|
|
import android.content.res.Resources;
|
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.view.LayoutInflater;
|
2010-11-08 23:04:10 +00:00
|
|
|
import android.view.Menu;
|
|
|
|
import android.view.MenuInflater;
|
|
|
|
import android.view.MenuItem;
|
2010-07-30 00:06:00 +00:00
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
import android.widget.ImageView;
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
import java.security.InvalidParameterException;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A {@link MessageViewFragmentBase} subclass for regular email messages. (regular as in "not eml
|
|
|
|
* files").
|
|
|
|
*
|
|
|
|
* See {@link MessageViewBase} for the class relation diagram.
|
|
|
|
*/
|
2010-07-30 22:41:40 +00:00
|
|
|
public class MessageViewFragment extends MessageViewFragmentBase {
|
2010-07-30 00:06:00 +00:00
|
|
|
private ImageView mFavoriteIcon;
|
|
|
|
private View mInviteSection;
|
|
|
|
|
2010-09-30 21:25:57 +00:00
|
|
|
private View mReplyButton;
|
|
|
|
private View mReplyAllButton;
|
|
|
|
private View mForwardButton;
|
|
|
|
|
2010-07-30 00:06:00 +00:00
|
|
|
// calendar meeting invite answers
|
|
|
|
private TextView mMeetingYes;
|
|
|
|
private TextView mMeetingMaybe;
|
|
|
|
private TextView mMeetingNo;
|
Let MessageViewFragment own bottom buttons.
Create a custom view containing the bottons below MVF
(delete, move, reply, etc) and let MVF own this.
These buttons used to be owned by the XL activity itself, because
the UI for these commands will most likely be totally different
from the tablet UI, so the fragment having them looked wrong.
However, this made it harder to make changes suggested by the latest
mock, such as "put reply/forward in the message header".
I think the buttons are semantically part of the message view anyway,
so the fragment owning UI for these commands is probably the way to go.
(And let's worry about the phone UI later.)
Reason for the use of a custom view is that it will make it easier
to make non-trivial UI changes, e.g. "combine reply, reply-all and
forward and make it dropdown."
Also removed obsolete TODOs from MessageListXL.
Change-Id: Ibf93f4c70fe07bdbbe33d2adb6bbd2b96812830d
2010-09-16 18:16:46 +00:00
|
|
|
private MessageCommandButtonView mCommandButtons;
|
2010-07-30 00:06:00 +00:00
|
|
|
private int mPreviousMeetingResponse = -1;
|
|
|
|
|
|
|
|
private Drawable mFavoriteIconOn;
|
|
|
|
private Drawable mFavoriteIconOff;
|
|
|
|
|
2010-10-12 21:47:29 +00:00
|
|
|
/**
|
|
|
|
* ID of the message that will be loaded. Protect with {@link #mLock}.
|
|
|
|
*/
|
2010-07-30 00:06:00 +00:00
|
|
|
private long mMessageIdToOpen = -1;
|
|
|
|
|
2010-10-12 21:47:29 +00:00
|
|
|
/** Lock object to protect {@link #mMessageIdToOpen} */
|
|
|
|
private final Object mLock = new Object();
|
|
|
|
|
Let MessageViewFragment own bottom buttons.
Create a custom view containing the bottons below MVF
(delete, move, reply, etc) and let MVF own this.
These buttons used to be owned by the XL activity itself, because
the UI for these commands will most likely be totally different
from the tablet UI, so the fragment having them looked wrong.
However, this made it harder to make changes suggested by the latest
mock, such as "put reply/forward in the message header".
I think the buttons are semantically part of the message view anyway,
so the fragment owning UI for these commands is probably the way to go.
(And let's worry about the phone UI later.)
Reason for the use of a custom view is that it will make it easier
to make non-trivial UI changes, e.g. "combine reply, reply-all and
forward and make it dropdown."
Also removed obsolete TODOs from MessageListXL.
Change-Id: Ibf93f4c70fe07bdbbe33d2adb6bbd2b96812830d
2010-09-16 18:16:46 +00:00
|
|
|
/** ID of the currently shown message */
|
|
|
|
private long mCurrentMessageId = -1;
|
|
|
|
|
|
|
|
private final CommandButtonCallback mCommandButtonCallback = new CommandButtonCallback();
|
|
|
|
|
2010-07-30 00:06:00 +00:00
|
|
|
/**
|
|
|
|
* This class has more call backs than {@link MessageViewFragmentBase}.
|
|
|
|
*
|
|
|
|
* - EML files can't be "mark unread".
|
|
|
|
* - EML files can't have the invite buttons or the view in calender link.
|
|
|
|
* Note EML files can have ICS (calendar invitation) files, but we don't treat them as
|
|
|
|
* invites. (Only exchange provider sets the FLAG_INCOMING_MEETING_INVITE
|
|
|
|
* flag.)
|
|
|
|
* It'd be weird to respond to an invitation in an EML that might not be addressed to you...
|
|
|
|
*/
|
|
|
|
public interface Callback extends MessageViewFragmentBase.Callback {
|
|
|
|
/** Called when the "view in calendar" link is clicked. */
|
|
|
|
public void onCalendarLinkClicked(long epochEventStartTime);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when a calender response button is clicked.
|
|
|
|
*
|
|
|
|
* @param response one of {@link EmailServiceConstants#MEETING_REQUEST_ACCEPTED},
|
|
|
|
* {@link EmailServiceConstants#MEETING_REQUEST_DECLINED}, or
|
|
|
|
* {@link EmailServiceConstants#MEETING_REQUEST_TENTATIVE}.
|
|
|
|
*/
|
|
|
|
public void onRespondedToInvite(int response);
|
|
|
|
|
|
|
|
/** Called when the current message is set unread. */
|
|
|
|
public void onMessageSetUnread();
|
Let MessageViewFragment own bottom buttons.
Create a custom view containing the bottons below MVF
(delete, move, reply, etc) and let MVF own this.
These buttons used to be owned by the XL activity itself, because
the UI for these commands will most likely be totally different
from the tablet UI, so the fragment having them looked wrong.
However, this made it harder to make changes suggested by the latest
mock, such as "put reply/forward in the message header".
I think the buttons are semantically part of the message view anyway,
so the fragment owning UI for these commands is probably the way to go.
(And let's worry about the phone UI later.)
Reason for the use of a custom view is that it will make it easier
to make non-trivial UI changes, e.g. "combine reply, reply-all and
forward and make it dropdown."
Also removed obsolete TODOs from MessageListXL.
Change-Id: Ibf93f4c70fe07bdbbe33d2adb6bbd2b96812830d
2010-09-16 18:16:46 +00:00
|
|
|
|
|
|
|
/** Called when "move to newer" button is pressed. */
|
|
|
|
public void onMoveToNewer();
|
|
|
|
|
|
|
|
/** Called when "move to older" button is pressed. */
|
|
|
|
public void onMoveToOlder();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called right before the current message will be deleted.
|
|
|
|
* Callees don't have to delete messages. The fragment does.
|
|
|
|
*/
|
|
|
|
public void onBeforeMessageDelete();
|
|
|
|
|
|
|
|
/** Called when the move button is pressed. */
|
|
|
|
public void onMoveMessage();
|
|
|
|
/** Called when the forward button is pressed. */
|
|
|
|
public void onForward();
|
|
|
|
/** Called when the reply button is pressed. */
|
|
|
|
public void onReply();
|
|
|
|
/** Called when the reply-all button is pressed. */
|
|
|
|
public void onReplyAll();
|
2010-07-30 00:06:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static final class EmptyCallback extends MessageViewFragmentBase.EmptyCallback
|
|
|
|
implements Callback {
|
|
|
|
public static final Callback INSTANCE = new EmptyCallback();
|
|
|
|
|
Let MessageViewFragment own bottom buttons.
Create a custom view containing the bottons below MVF
(delete, move, reply, etc) and let MVF own this.
These buttons used to be owned by the XL activity itself, because
the UI for these commands will most likely be totally different
from the tablet UI, so the fragment having them looked wrong.
However, this made it harder to make changes suggested by the latest
mock, such as "put reply/forward in the message header".
I think the buttons are semantically part of the message view anyway,
so the fragment owning UI for these commands is probably the way to go.
(And let's worry about the phone UI later.)
Reason for the use of a custom view is that it will make it easier
to make non-trivial UI changes, e.g. "combine reply, reply-all and
forward and make it dropdown."
Also removed obsolete TODOs from MessageListXL.
Change-Id: Ibf93f4c70fe07bdbbe33d2adb6bbd2b96812830d
2010-09-16 18:16:46 +00:00
|
|
|
@Override public void onCalendarLinkClicked(long epochEventStartTime) { }
|
|
|
|
@Override public void onMessageSetUnread() { }
|
|
|
|
@Override public void onRespondedToInvite(int response) { }
|
|
|
|
@Override public void onMoveToNewer() { }
|
|
|
|
@Override public void onMoveToOlder() { }
|
|
|
|
@Override public void onBeforeMessageDelete() { }
|
|
|
|
@Override public void onMoveMessage() { }
|
|
|
|
@Override public void onForward() { }
|
|
|
|
@Override public void onReply() { }
|
|
|
|
@Override public void onReplyAll() { }
|
2010-07-30 00:06:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private Callback mCallback = EmptyCallback.INSTANCE;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
|
|
final Resources res = getActivity().getResources();
|
|
|
|
mFavoriteIconOn = res.getDrawable(R.drawable.btn_star_big_buttonless_on);
|
|
|
|
mFavoriteIconOff = res.getDrawable(R.drawable.btn_star_big_buttonless_off);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public View onCreateView(
|
|
|
|
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
|
|
final View view = super.onCreateView(inflater, container, savedInstanceState);
|
|
|
|
|
|
|
|
mFavoriteIcon = (ImageView) view.findViewById(R.id.favorite);
|
|
|
|
mInviteSection = view.findViewById(R.id.invite_section);
|
2010-09-30 21:25:57 +00:00
|
|
|
mReplyButton = view.findViewById(R.id.reply);
|
|
|
|
mReplyAllButton = view.findViewById(R.id.reply_all);
|
|
|
|
mForwardButton = view.findViewById(R.id.forward);
|
2010-07-30 00:06:00 +00:00
|
|
|
mMeetingYes = (TextView) view.findViewById(R.id.accept);
|
|
|
|
mMeetingMaybe = (TextView) view.findViewById(R.id.maybe);
|
|
|
|
mMeetingNo = (TextView) view.findViewById(R.id.decline);
|
|
|
|
|
2010-09-30 21:25:57 +00:00
|
|
|
mFavoriteIcon.setOnClickListener(this);
|
|
|
|
mReplyButton.setOnClickListener(this);
|
|
|
|
mReplyAllButton.setOnClickListener(this);
|
|
|
|
mForwardButton.setOnClickListener(this);
|
2010-07-30 00:06:00 +00:00
|
|
|
mMeetingYes.setOnClickListener(this);
|
|
|
|
mMeetingMaybe.setOnClickListener(this);
|
|
|
|
mMeetingNo.setOnClickListener(this);
|
|
|
|
view.findViewById(R.id.invite_link).setOnClickListener(this);
|
|
|
|
|
Let MessageViewFragment own bottom buttons.
Create a custom view containing the bottons below MVF
(delete, move, reply, etc) and let MVF own this.
These buttons used to be owned by the XL activity itself, because
the UI for these commands will most likely be totally different
from the tablet UI, so the fragment having them looked wrong.
However, this made it harder to make changes suggested by the latest
mock, such as "put reply/forward in the message header".
I think the buttons are semantically part of the message view anyway,
so the fragment owning UI for these commands is probably the way to go.
(And let's worry about the phone UI later.)
Reason for the use of a custom view is that it will make it easier
to make non-trivial UI changes, e.g. "combine reply, reply-all and
forward and make it dropdown."
Also removed obsolete TODOs from MessageListXL.
Change-Id: Ibf93f4c70fe07bdbbe33d2adb6bbd2b96812830d
2010-09-16 18:16:46 +00:00
|
|
|
// Show the command buttons at the bottom.
|
|
|
|
mCommandButtons =
|
|
|
|
(MessageCommandButtonView) view.findViewById(R.id.message_command_buttons);
|
|
|
|
mCommandButtons.setVisibility(View.VISIBLE);
|
|
|
|
mCommandButtons.setCallback(mCommandButtonCallback);
|
|
|
|
|
2010-09-30 21:25:57 +00:00
|
|
|
enableReplyForwardButtons(false);
|
|
|
|
|
2010-07-30 00:06:00 +00:00
|
|
|
return view;
|
|
|
|
}
|
|
|
|
|
2010-09-22 23:17:53 +00:00
|
|
|
@Override
|
|
|
|
public void onResume() {
|
|
|
|
super.onResume();
|
2010-07-30 00:06:00 +00:00
|
|
|
}
|
|
|
|
|
2010-11-08 23:04:10 +00:00
|
|
|
@Override
|
|
|
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
|
|
inflater.inflate(R.menu.message_view_fragment_option, menu);
|
|
|
|
}
|
|
|
|
|
2010-09-30 21:25:57 +00:00
|
|
|
private void enableReplyForwardButtons(boolean enabled) {
|
|
|
|
// We don't have disabled button assets, so let's hide them for now
|
|
|
|
final int visibility = enabled ? View.VISIBLE : View.GONE;
|
|
|
|
mReplyButton.setVisibility(visibility);
|
|
|
|
mReplyAllButton.setVisibility(visibility);
|
|
|
|
mForwardButton.setVisibility(visibility);
|
2010-09-22 23:17:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setCallback(Callback callback) {
|
|
|
|
mCallback = (callback == null) ? EmptyCallback.INSTANCE : callback;
|
|
|
|
super.setCallback(mCallback);
|
Let MessageViewFragment own bottom buttons.
Create a custom view containing the bottons below MVF
(delete, move, reply, etc) and let MVF own this.
These buttons used to be owned by the XL activity itself, because
the UI for these commands will most likely be totally different
from the tablet UI, so the fragment having them looked wrong.
However, this made it harder to make changes suggested by the latest
mock, such as "put reply/forward in the message header".
I think the buttons are semantically part of the message view anyway,
so the fragment owning UI for these commands is probably the way to go.
(And let's worry about the phone UI later.)
Reason for the use of a custom view is that it will make it easier
to make non-trivial UI changes, e.g. "combine reply, reply-all and
forward and make it dropdown."
Also removed obsolete TODOs from MessageListXL.
Change-Id: Ibf93f4c70fe07bdbbe33d2adb6bbd2b96812830d
2010-09-16 18:16:46 +00:00
|
|
|
}
|
|
|
|
|
2010-07-30 00:06:00 +00:00
|
|
|
/** Called by activities to set an id of a message to open. */
|
|
|
|
public void openMessage(long messageId) {
|
|
|
|
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
|
|
|
|
Log.d(Email.LOG_TAG, "MessageViewFragment openMessage");
|
|
|
|
}
|
|
|
|
if (messageId == -1) {
|
|
|
|
throw new InvalidParameterException();
|
|
|
|
}
|
2010-10-12 21:47:29 +00:00
|
|
|
synchronized (mLock) {
|
|
|
|
mMessageIdToOpen = messageId;
|
|
|
|
}
|
2010-11-19 23:03:37 +00:00
|
|
|
loadMessageIfResumed();
|
2010-07-30 00:06:00 +00:00
|
|
|
}
|
|
|
|
|
2010-09-30 01:44:05 +00:00
|
|
|
@Override
|
|
|
|
public void clearContent() {
|
2010-10-12 21:47:29 +00:00
|
|
|
synchronized (mLock) {
|
|
|
|
super.clearContent();
|
|
|
|
mMessageIdToOpen = -1;
|
2010-11-08 23:04:10 +00:00
|
|
|
|
|
|
|
// Hide the menu.
|
|
|
|
// This isn't really necessary if we're really hiding the fragment. However,
|
|
|
|
// for now, we're actually *not* hiding the fragment (just hiding the root view of it),
|
|
|
|
// so need to remove menus manually.
|
|
|
|
setHasOptionsMenu(false);
|
2010-10-12 21:47:29 +00:00
|
|
|
}
|
2010-09-30 01:44:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void resetView() {
|
|
|
|
super.resetView();
|
|
|
|
// TODO Hide command buttons. (Careful when to re-show it)
|
|
|
|
}
|
|
|
|
|
2010-07-30 00:06:00 +00:00
|
|
|
@Override
|
|
|
|
protected boolean isMessageSpecified() {
|
2010-10-12 21:47:29 +00:00
|
|
|
synchronized (mLock) {
|
|
|
|
return mMessageIdToOpen != -1;
|
|
|
|
}
|
2010-07-30 00:06:00 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 21:47:29 +00:00
|
|
|
/**
|
|
|
|
* NOTE See the comment on the super method. It's called on a worker thread.
|
|
|
|
*/
|
2010-07-30 00:06:00 +00:00
|
|
|
@Override
|
|
|
|
protected Message openMessageSync() {
|
2010-10-12 21:47:29 +00:00
|
|
|
synchronized (mLock) {
|
|
|
|
long messageId = mMessageIdToOpen;
|
|
|
|
if (messageId < 0) {
|
|
|
|
return null; // Called after clearContent().
|
|
|
|
}
|
|
|
|
return Message.restoreMessageWithId(getActivity(), messageId);
|
|
|
|
}
|
2010-07-30 00:06:00 +00:00
|
|
|
}
|
|
|
|
|
Let MessageViewFragment own bottom buttons.
Create a custom view containing the bottons below MVF
(delete, move, reply, etc) and let MVF own this.
These buttons used to be owned by the XL activity itself, because
the UI for these commands will most likely be totally different
from the tablet UI, so the fragment having them looked wrong.
However, this made it harder to make changes suggested by the latest
mock, such as "put reply/forward in the message header".
I think the buttons are semantically part of the message view anyway,
so the fragment owning UI for these commands is probably the way to go.
(And let's worry about the phone UI later.)
Reason for the use of a custom view is that it will make it easier
to make non-trivial UI changes, e.g. "combine reply, reply-all and
forward and make it dropdown."
Also removed obsolete TODOs from MessageListXL.
Change-Id: Ibf93f4c70fe07bdbbe33d2adb6bbd2b96812830d
2010-09-16 18:16:46 +00:00
|
|
|
@Override
|
|
|
|
protected void onMessageShown(long messageId, int mailboxType) {
|
|
|
|
super.onMessageShown(messageId, mailboxType);
|
|
|
|
|
|
|
|
// Remember the currently shown message ID.
|
|
|
|
mCurrentMessageId = messageId;
|
|
|
|
|
|
|
|
// Disable forward/reply buttons as necessary.
|
2010-09-30 21:25:57 +00:00
|
|
|
enableReplyForwardButtons(Mailbox.isMailboxTypeReplyAndForwardable(mailboxType));
|
2010-11-08 23:04:10 +00:00
|
|
|
|
|
|
|
// Show the menu when it's showing a message.
|
|
|
|
setHasOptionsMenu(true);
|
2010-09-22 23:17:53 +00:00
|
|
|
}
|
|
|
|
|
2010-11-08 23:04:10 +00:00
|
|
|
public void enableNavigationButons(boolean enableMoveToNewer, boolean enableMoveToOlder,
|
|
|
|
int currentPosition, int countMessages) {
|
|
|
|
mCommandButtons.enableNavigationButtons(enableMoveToNewer, enableMoveToOlder,
|
|
|
|
currentPosition, countMessages);
|
Let MessageViewFragment own bottom buttons.
Create a custom view containing the bottons below MVF
(delete, move, reply, etc) and let MVF own this.
These buttons used to be owned by the XL activity itself, because
the UI for these commands will most likely be totally different
from the tablet UI, so the fragment having them looked wrong.
However, this made it harder to make changes suggested by the latest
mock, such as "put reply/forward in the message header".
I think the buttons are semantically part of the message view anyway,
so the fragment owning UI for these commands is probably the way to go.
(And let's worry about the phone UI later.)
Reason for the use of a custom view is that it will make it easier
to make non-trivial UI changes, e.g. "combine reply, reply-all and
forward and make it dropdown."
Also removed obsolete TODOs from MessageListXL.
Change-Id: Ibf93f4c70fe07bdbbe33d2adb6bbd2b96812830d
2010-09-16 18:16:46 +00:00
|
|
|
}
|
|
|
|
|
2010-07-30 00:06:00 +00:00
|
|
|
/**
|
|
|
|
* Toggle favorite status and write back to provider
|
|
|
|
*/
|
|
|
|
private void onClickFavorite() {
|
|
|
|
Message message = getMessage();
|
|
|
|
|
|
|
|
// Update UI
|
|
|
|
boolean newFavorite = ! message.mFlagFavorite;
|
|
|
|
mFavoriteIcon.setImageDrawable(newFavorite ? mFavoriteIconOn : mFavoriteIconOff);
|
|
|
|
|
|
|
|
// Update provider
|
|
|
|
message.mFlagFavorite = newFavorite;
|
|
|
|
getController().setMessageFavorite(message.mId, newFavorite);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set message read/unread.
|
|
|
|
*/
|
|
|
|
public void onMarkMessageAsRead(boolean isRead) {
|
|
|
|
Message message = getMessage();
|
|
|
|
if (message.mFlagRead != isRead) {
|
|
|
|
message.mFlagRead = isRead;
|
|
|
|
getController().setMessageRead(message.mId, isRead);
|
|
|
|
if (!isRead) { // Became unread. We need to close the message.
|
|
|
|
mCallback.onMessageSetUnread();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send a service message indicating that a meeting invite button has been clicked.
|
|
|
|
*/
|
|
|
|
private void onRespondToInvite(int response, int toastResId) {
|
|
|
|
Message message = getMessage();
|
|
|
|
// do not send twice in a row the same response
|
|
|
|
if (mPreviousMeetingResponse != response) {
|
|
|
|
getController().sendMeetingResponse(message.mId, response);
|
|
|
|
mPreviousMeetingResponse = response;
|
|
|
|
}
|
|
|
|
Utility.showToast(getActivity(), toastResId);
|
|
|
|
mCallback.onRespondedToInvite(response);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void onInviteLinkClicked() {
|
|
|
|
Message message = getMessage();
|
|
|
|
String startTime = new PackedString(message.mMeetingInfo).get(MeetingInfo.MEETING_DTSTART);
|
|
|
|
if (startTime != null) {
|
|
|
|
long epochTimeMillis = Utility.parseEmailDateTimeToMillis(startTime);
|
|
|
|
mCallback.onCalendarLinkClicked(epochTimeMillis);
|
|
|
|
} else {
|
|
|
|
Email.log("meetingInfo without DTSTART " + message.mMeetingInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onClick(View view) {
|
|
|
|
if (!isMessageOpen()) {
|
|
|
|
return; // Ignore.
|
|
|
|
}
|
|
|
|
switch (view.getId()) {
|
2010-09-30 21:25:57 +00:00
|
|
|
case R.id.reply:
|
|
|
|
mCallback.onReply();
|
|
|
|
return;
|
|
|
|
case R.id.reply_all:
|
|
|
|
mCallback.onReplyAll();
|
|
|
|
return;
|
|
|
|
case R.id.forward:
|
|
|
|
mCallback.onForward();
|
|
|
|
return;
|
|
|
|
|
2010-07-30 00:06:00 +00:00
|
|
|
case R.id.favorite:
|
|
|
|
onClickFavorite();
|
|
|
|
return;
|
2010-09-30 21:25:57 +00:00
|
|
|
|
2010-07-30 00:06:00 +00:00
|
|
|
case R.id.accept:
|
|
|
|
onRespondToInvite(EmailServiceConstants.MEETING_REQUEST_ACCEPTED,
|
|
|
|
R.string.message_view_invite_toast_yes);
|
|
|
|
return;
|
|
|
|
case R.id.maybe:
|
|
|
|
onRespondToInvite(EmailServiceConstants.MEETING_REQUEST_TENTATIVE,
|
|
|
|
R.string.message_view_invite_toast_maybe);
|
|
|
|
return;
|
|
|
|
case R.id.decline:
|
|
|
|
onRespondToInvite(EmailServiceConstants.MEETING_REQUEST_DECLINED,
|
|
|
|
R.string.message_view_invite_toast_no);
|
|
|
|
return;
|
|
|
|
case R.id.invite_link:
|
|
|
|
onInviteLinkClicked();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
super.onClick(view);
|
|
|
|
}
|
|
|
|
|
2010-11-08 23:04:10 +00:00
|
|
|
@Override
|
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
|
switch (item.getItemId()) {
|
|
|
|
case R.id.move:
|
|
|
|
onMove();
|
|
|
|
return true;
|
|
|
|
case R.id.delete:
|
|
|
|
onDelete();
|
|
|
|
return true;
|
|
|
|
case R.id.mark_as_unread:
|
|
|
|
onMarkAsUnread();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return super.onOptionsItemSelected(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void onMove() {
|
|
|
|
mCallback.onMoveMessage();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void onDelete() {
|
|
|
|
mCallback.onBeforeMessageDelete();
|
|
|
|
ActivityHelper.deleteMessage(getActivity(), mCurrentMessageId);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void onMarkAsUnread() {
|
|
|
|
onMarkMessageAsRead(false);
|
|
|
|
mCallback.onMessageSetUnread();
|
|
|
|
}
|
|
|
|
|
2010-07-30 00:06:00 +00:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*
|
|
|
|
* Mark the current as unread.
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
protected void onPostLoadBody() {
|
|
|
|
onMarkMessageAsRead(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2010-10-02 01:04:12 +00:00
|
|
|
protected void updateHeaderView(Message message) {
|
|
|
|
super.updateHeaderView(message);
|
2010-07-30 00:06:00 +00:00
|
|
|
|
|
|
|
mFavoriteIcon.setImageDrawable(message.mFlagFavorite ? mFavoriteIconOn : mFavoriteIconOff);
|
2010-10-02 01:04:12 +00:00
|
|
|
|
2010-10-04 23:00:02 +00:00
|
|
|
// Enable the invite tab if necessary
|
|
|
|
if ((message.mFlags & Message.FLAG_INCOMING_MEETING_INVITE) != 0) {
|
|
|
|
addTabFlags(TAB_FLAGS_HAS_INVITE);
|
|
|
|
}
|
2010-07-30 00:06:00 +00:00
|
|
|
}
|
Let MessageViewFragment own bottom buttons.
Create a custom view containing the bottons below MVF
(delete, move, reply, etc) and let MVF own this.
These buttons used to be owned by the XL activity itself, because
the UI for these commands will most likely be totally different
from the tablet UI, so the fragment having them looked wrong.
However, this made it harder to make changes suggested by the latest
mock, such as "put reply/forward in the message header".
I think the buttons are semantically part of the message view anyway,
so the fragment owning UI for these commands is probably the way to go.
(And let's worry about the phone UI later.)
Reason for the use of a custom view is that it will make it easier
to make non-trivial UI changes, e.g. "combine reply, reply-all and
forward and make it dropdown."
Also removed obsolete TODOs from MessageListXL.
Change-Id: Ibf93f4c70fe07bdbbe33d2adb6bbd2b96812830d
2010-09-16 18:16:46 +00:00
|
|
|
|
|
|
|
private class CommandButtonCallback implements MessageCommandButtonView.Callback {
|
|
|
|
@Override
|
|
|
|
public void onMoveToNewer() {
|
|
|
|
mCallback.onMoveToNewer();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onMoveToOlder() {
|
|
|
|
mCallback.onMoveToOlder();
|
|
|
|
}
|
|
|
|
}
|
2010-07-30 00:06:00 +00:00
|
|
|
}
|