Show newer/older in landscape as well, below message list

Now the button area is owned by the 3-pane layout, rather than the message view
fragment.

Bug 3327153

Change-Id: I9c262086c5a001cfe6e81b788c27d05d490c9830
This commit is contained in:
Makoto Onuki 2011-01-11 14:36:00 -08:00
parent 071274f078
commit f7b8bc1ed7
11 changed files with 155 additions and 154 deletions

View File

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->
<!--
Landscape, where we show no buttons.
-->
<!-- extends LinearLayout -->
<com.android.email.activity.MessageCommandButtonView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="0dip"
android:orientation="horizontal"
>
</com.android.email.activity.MessageCommandButtonView>

View File

@ -29,12 +29,23 @@
android:layout_width="0dip"
android:layout_height="match_parent"
/>
<fragment
android:name="com.android.email.activity.MessageListFragment"
android:id="@+id/middle_pane"
android:layout_width="0dip"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
/>
android:orientation="vertical"
>
<fragment
android:name="com.android.email.activity.MessageListFragment"
android:id="@+id/middle_pane"
android:layout_width="0dip"
android:layout_height="0dip"
android:layout_weight="1"
/>
<include
layout="@layout/message_command_button_view"
android:id="@+id/message_command_buttons"
/>
</LinearLayout>
<fragment
android:name="com.android.email.activity.MessageViewFragment"
android:id="@+id/right_pane"

View File

@ -41,12 +41,23 @@
android:layout_width="0dip"
android:layout_height="match_parent"
>
<fragment
android:name="com.android.email.activity.MessageViewFragment"
android:id="@+id/right_pane"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
android:orientation="vertical"
>
<fragment
android:name="com.android.email.activity.MessageViewFragment"
android:id="@+id/right_pane"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
/>
<include
layout="@layout/message_command_button_view"
android:id="@+id/message_command_buttons"
/>
</LinearLayout>
<View
android:id="@+id/fogged_glass"
android:layout_width="match_parent"

View File

@ -399,12 +399,4 @@
</LinearLayout>
</RelativeLayout>
</FrameLayout>
<!-- Buttons at the bottom.
Only MessageViewFragment uses these. MessageFileViewFragment doesn't. -->
<include
layout="@layout/message_command_button_view"
android:id="@+id/message_command_buttons"
android:visibility="gone"
/>
</LinearLayout>

View File

@ -14,8 +14,6 @@
limitations under the License.
-->
<!-- Portrait -->
<!-- extends LinearLayout -->
<com.android.email.activity.MessageCommandButtonView
xmlns:android="http://schemas.android.com/apk/res/android"
@ -25,6 +23,7 @@
android:gravity="center_vertical"
android:paddingLeft="16dip"
android:paddingRight="16dip"
android:background="#fff"
>
<Button
android:id="@+id/move_to_newer_button"

View File

@ -244,13 +244,4 @@
/>
</ScrollView>
<!-- end of content area -->
<!--
Buttons such as delete, mark unread. Only MessageViewFragment uses these.
MessageFileViewFragment doesn't.
-->
<include
layout="@layout/message_command_button_view"
android:id="@+id/message_command_buttons"
android:visibility="gone"
/>
</LinearLayout>

View File

@ -383,14 +383,12 @@ public class MessageListXL extends Activity implements
* Disable/enable the move-to-newer/older buttons.
*/
private void updateNavigationArrows() {
MessageViewFragment f = mFragmentManager.getMessageViewFragment();
if (f == null) {
return;
}
if (mOrderManager == null) {
f.enableNavigationButons(false, false, 0, 0); // shouldn't happen, but just in case
// shouldn't happen, but just in case
mFragmentManager.updateMessageCommandButtons(false, false, 0, 0);
} else {
f.enableNavigationButons(mOrderManager.canMoveToNewer(), mOrderManager.canMoveToOlder(),
mFragmentManager.updateMessageCommandButtons(
mOrderManager.canMoveToNewer(), mOrderManager.canMoveToOlder(),
mOrderManager.getCurrentPosition(), mOrderManager.getTotalMessageCount());
}
}
@ -504,16 +502,6 @@ public class MessageListXL extends Activity implements
ActivityHelper.openCalendar(MessageListXL.this, epochEventStartTime);
}
@Override
public void onMoveToNewer() {
moveToNewer();
}
@Override
public void onMoveToOlder() {
moveToOlder();
}
@Override
public void onBeforeMessageDelete() {
onCurrentMessageGone();
@ -555,6 +543,16 @@ public class MessageListXL extends Activity implements
updateProgressIcon();
}
@Override
public void onMoveToNewer() {
moveToNewer();
}
@Override
public void onMoveToOlder() {
moveToOlder();
}
/**
* Call this when getting a connection error.
*/

View File

@ -70,6 +70,7 @@ class MessageListXLFragmentManager {
private MailboxListFragment mMailboxListFragment;
private MessageListFragment mMessageListFragment;
private MessageViewFragment mMessageViewFragment;
private MessageCommandButtonView mMessageCommandButtons;
private MailboxFinder mMailboxFinder;
private final MailboxFinderCallback mMailboxFinderCallback = new MailboxFinderCallback();
@ -104,6 +105,12 @@ class MessageListXLFragmentManager {
*/
public void onMailboxChanged(long accountId, long newMailboxId);
/** Called when "move to newer" button is pressed. */
public void onMoveToNewer();
/** Called when "move to older" button is pressed. */
public void onMoveToOlder();
public View findViewById(int id);
}
@ -134,6 +141,8 @@ class MessageListXLFragmentManager {
mThreePane.getMiddlePaneId());
mMessageViewFragment = (MessageViewFragment) fm.findFragmentById(
mThreePane.getRightPaneId());
mMessageCommandButtons = mThreePane.getMessageCommandButtons();
mMessageCommandButtons.setCallback(new CommandButtonCallback());
mActionBar = mTargetActivity.getActionBar();
@ -520,6 +529,24 @@ class MessageListXLFragmentManager {
}
}
public void updateMessageCommandButtons(boolean enableMoveToNewer, boolean enableMoveToOlder,
int currentPosition, int countMessages) {
mMessageCommandButtons.enableNavigationButtons(enableMoveToNewer, enableMoveToOlder,
currentPosition, countMessages);
}
private class CommandButtonCallback implements MessageCommandButtonView.Callback {
@Override
public void onMoveToNewer() {
mTargetActivity.onMoveToNewer();
}
@Override
public void onMoveToOlder() {
mTargetActivity.onMoveToOlder();
}
}
private class ThreePaneLayoutCallback implements ThreePaneLayout.Callback {
@Override
public void onVisiblePanesChanged(int previousVisiblePanes) {

View File

@ -349,16 +349,6 @@ public class MessageView extends MessageViewBase implements View.OnClickListener
finish();
}
@Override
public void onMoveToNewer() {
// TODO Implement this
}
@Override
public void onMoveToOlder() {
// TODO Implement this
}
@Override
public void onBeforeMessageDelete() {
// TODO Implement this

View File

@ -61,7 +61,6 @@ public class MessageViewFragment extends MessageViewFragmentBase
private CheckBox mMeetingYes;
private CheckBox mMeetingMaybe;
private CheckBox mMeetingNo;
private MessageCommandButtonView mCommandButtons;
private int mPreviousMeetingResponse = -1;
private Drawable mFavoriteIconOn;
@ -78,8 +77,6 @@ public class MessageViewFragment extends MessageViewFragmentBase
/** ID of the currently shown message */
private long mCurrentMessageId = -1;
private final CommandButtonCallback mCommandButtonCallback = new CommandButtonCallback();
/**
* This class has more call backs than {@link MessageViewFragmentBase}.
*
@ -106,12 +103,6 @@ public class MessageViewFragment extends MessageViewFragmentBase
/** Called when the current message is set unread. */
public void onMessageSetUnread();
/** 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.
@ -135,8 +126,6 @@ public class MessageViewFragment extends MessageViewFragmentBase
@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() { }
@ -181,12 +170,6 @@ public class MessageViewFragment extends MessageViewFragmentBase
mMeetingNo.setOnCheckedChangeListener(this);
view.findViewById(R.id.invite_link).setOnClickListener(this);
// Show the command buttons at the bottom.
mCommandButtons =
(MessageCommandButtonView) view.findViewById(R.id.message_command_buttons);
mCommandButtons.setVisibility(View.VISIBLE);
mCommandButtons.setCallback(mCommandButtonCallback);
enableReplyForwardButtons(false);
return view;
@ -286,12 +269,6 @@ public class MessageViewFragment extends MessageViewFragmentBase
setHasOptionsMenu(true);
}
public void enableNavigationButons(boolean enableMoveToNewer, boolean enableMoveToOlder,
int currentPosition, int countMessages) {
mCommandButtons.enableNavigationButtons(enableMoveToNewer, enableMoveToOlder,
currentPosition, countMessages);
}
/**
* Toggle favorite status and write back to provider
*/
@ -442,16 +419,4 @@ public class MessageViewFragment extends MessageViewFragmentBase
addTabFlags(TAB_FLAGS_HAS_INVITE);
}
}
private class CommandButtonCallback implements MessageCommandButtonView.Callback {
@Override
public void onMoveToNewer() {
mCallback.onMoveToNewer();
}
@Override
public void onMoveToOlder() {
mCallback.onMoveToOlder();
}
}
}

View File

@ -48,16 +48,16 @@ public class ThreePaneLayout extends LinearLayout implements View.OnClickListene
private static final TimeInterpolator INTERPOLATOR = new DecelerateInterpolator(1.5f);
/** Uninitialized state -- {@link #changePaneState} hasn't been called yet. */
private static final int STATE_UNINITIALIZED = 0;
private static final int STATE_UNINITIALIZED = -1;
/** Mailbox list + message list */
private static final int STATE_LEFT_VISIBLE = 1;
private static final int STATE_LEFT_VISIBLE = 0;
/** Message view on portrait, + message list on landscape. */
private static final int STATE_RIGHT_VISIBLE = 2;
private static final int STATE_RIGHT_VISIBLE = 1;
/** Portrait mode only: message view + expanded message list */
private static final int STATE_PORTRAIT_MIDDLE_EXPANDED = 3;
private static final int STATE_PORTRAIT_MIDDLE_EXPANDED = 2;
// Flags for getVisiblePanes()
public static final int PANE_LEFT = 1 << 2;
@ -73,6 +73,7 @@ public class ThreePaneLayout extends LinearLayout implements View.OnClickListene
private View mLeftPane;
private View mMiddlePane;
private View mRightPane;
private MessageCommandButtonView mMessageCommandButtons;
// Views used only on portrait
private View mFoggedGlass;
@ -98,12 +99,15 @@ public class ThreePaneLayout extends LinearLayout implements View.OnClickListene
*/
private AnimatorListener mLastAnimatorListener;
// 2nd index for {@link #changePaneState}
private final int INDEX_VISIBLE = 0;
private final int INDEX_INVISIBLE = 1;
private final int INDEX_GONE = 2;
// Arrays used in {@link #changePaneState}
private View[] mViewsLeft;
private View[] mViewsRight;
private View[] mViewsLeftMiddle;
private View[] mViewsMiddleRightFogged;
private View[] mViewsLeftMiddleFogged;
// First index: STATE_*
// Second index: INDEX_*
private View[][][] mShowHideViews;
private Callback mCallback = EmptyCallback.INSTANCE;
@ -144,6 +148,8 @@ public class ThreePaneLayout extends LinearLayout implements View.OnClickListene
mLeftPane = findViewById(R.id.left_pane);
mMiddlePane = findViewById(R.id.middle_pane);
mMessageCommandButtons =
(MessageCommandButtonView) findViewById(R.id.message_command_buttons);
mFoggedGlass = findViewById(R.id.fogged_glass);
if (mFoggedGlass != null) { // If it's around, it's portrait.
@ -152,11 +158,50 @@ public class ThreePaneLayout extends LinearLayout implements View.OnClickListene
} else { // landscape
mRightPane = findViewById(R.id.right_pane);
}
mViewsLeft = new View[] {mLeftPane};
mViewsRight = new View[] {mRightPane};
mViewsLeftMiddle = new View[] {mLeftPane, mMiddlePane};
mViewsMiddleRightFogged = new View[] {mMiddlePane, mRightPane, mFoggedGlass};
mViewsLeftMiddleFogged = new View[] {mLeftPane, mMiddlePane, mFoggedGlass};
if (isLandscape()) {
mShowHideViews = new View[][][] {
// STATE_LEFT_VISIBLE
{
{mLeftPane, mMiddlePane}, // Visible
{mRightPane}, // Invisible
{mMessageCommandButtons}, // Gone
},
// STATE_RIGHT_VISIBLE
{
{mMiddlePane, mMessageCommandButtons, mRightPane}, // Visible
{mLeftPane}, // Invisible
{}, // Gone
},
// STATE_PORTRAIT_MIDDLE_EXPANDED -- not used in landscape
{
{}, // Visible
{}, // Invisible
{}, // Gone
},
};
} else {
mShowHideViews = new View[][][] {
// STATE_LEFT_VISIBLE
{
{mLeftPane, mMiddlePane}, // Visible
{mRightPane, mFoggedGlass}, // Invisible
{mMessageCommandButtons}, // Gone
},
// STATE_RIGHT_VISIBLE
{
{mRightPane, mMessageCommandButtons}, // Visible
{mLeftPane, mMiddlePane, mFoggedGlass}, // Invisible
{}, // Gone
},
// STATE_PORTRAIT_MIDDLE_EXPANDED
{
{mMiddlePane, mRightPane, mMessageCommandButtons, mFoggedGlass}, // Visible
{mLeftPane}, // Invisible
{}, // Gone
},
};
}
mInitialPaneState = STATE_LEFT_VISIBLE;
@ -175,6 +220,10 @@ public class ThreePaneLayout extends LinearLayout implements View.OnClickListene
return mFoggedGlass == null;
}
public MessageCommandButtonView getMessageCommandButtons() {
return mMessageCommandButtons;
}
@Override
protected Parcelable onSaveInstanceState() {
SavedState ss = new SavedState(super.onSaveInstanceState());
@ -300,9 +349,6 @@ public class ThreePaneLayout extends LinearLayout implements View.OnClickListene
final String animatorLabel; // for debug purpose
final View[] viewsToShow;
final View[] viewsToHide;
if (isLandscape()) { // Landscape
setViewWidth(mLeftPane, mMailboxListWidth);
setViewWidth(mRightPane, totalWidth - mMessageListWidth);
@ -313,16 +359,12 @@ public class ThreePaneLayout extends LinearLayout implements View.OnClickListene
animatorLabel = "moving to [mailbox list + message list]";
expectedMailboxLeft = 0;
expectedMessageListWidth = totalWidth - mMailboxListWidth;
viewsToShow = mViewsLeft;
viewsToHide = mViewsRight;
break;
case STATE_RIGHT_VISIBLE:
// message list + message view
animatorLabel = "moving to [message list + message view]";
expectedMailboxLeft = -mMailboxListWidth;
expectedMessageListWidth = mMessageListWidth;
viewsToShow = mViewsRight;
viewsToHide = mViewsLeft;
break;
default:
throw new IllegalStateException();
@ -338,32 +380,30 @@ public class ThreePaneLayout extends LinearLayout implements View.OnClickListene
animatorLabel = "moving to [mailbox list + message list]";
expectedMailboxLeft = 0;
expectedMessageListWidth = totalWidth - mMailboxListWidth;
viewsToShow = mViewsLeftMiddle;
viewsToHide = mViewsRight;
break;
case STATE_PORTRAIT_MIDDLE_EXPANDED:
// mailbox + message list -> message list + message view
animatorLabel = "moving to [message list + message view]";
expectedMailboxLeft = -mMailboxListWidth;
expectedMessageListWidth = mMessageListWidth;
viewsToShow = mViewsMiddleRightFogged;
viewsToHide = mViewsLeft;
break;
case STATE_RIGHT_VISIBLE:
// message view only
animatorLabel = "moving to [message view]";
expectedMailboxLeft = -(mMailboxListWidth + mMessageListWidth);
expectedMessageListWidth = mMessageListWidth;
viewsToShow = mViewsRight;
viewsToHide = mViewsLeftMiddleFogged;
break;
default:
throw new IllegalStateException();
}
}
final AnimatorListener listener = new AnimatorListener(animatorLabel, viewsToShow,
viewsToHide, previousVisiblePanes) ;
final View[][] showHideViews = mShowHideViews[mPaneState];
final AnimatorListener listener = new AnimatorListener(animatorLabel,
showHideViews[INDEX_VISIBLE],
showHideViews[INDEX_INVISIBLE],
showHideViews[INDEX_GONE],
previousVisiblePanes);
// Animation properties -- mailbox list left and message list width, at the same time.
startLayoutAnimation(animate ? ANIMATION_DURATION : 0, listener,
@ -470,17 +510,19 @@ public class ThreePaneLayout extends LinearLayout implements View.OnClickListene
*/
private class AnimatorListener implements Animator.AnimatorListener {
private final String mLogLabel;
private final View[] mViewsToShow;
private final View[] mViewsToHide;
private final View[] mViewsVisible;
private final View[] mViewsInvisible;
private final View[] mViewsGone;
private final int mPreviousVisiblePanes;
private boolean mCancelled;
public AnimatorListener(String logLabel, View[] viewsToShow, View[] viewsToHide,
int previousVisiblePanes) {
public AnimatorListener(String logLabel, View[] viewsVisible, View[] viewsInvisible,
View[] viewsGone, int previousVisiblePanes) {
mLogLabel = logLabel;
mViewsToShow = viewsToShow;
mViewsToHide = viewsToHide;
mViewsVisible = viewsVisible;
mViewsInvisible = viewsInvisible;
mViewsGone = viewsGone;
mPreviousVisiblePanes = previousVisiblePanes;
}
@ -501,7 +543,7 @@ public class ThreePaneLayout extends LinearLayout implements View.OnClickListene
@Override
public void onAnimationStart(Animator animation) {
log("start");
for (View v : mViewsToShow) {
for (View v : mViewsVisible) {
v.setVisibility(View.VISIBLE);
}
mCallback.onVisiblePanesChanged(mPreviousVisiblePanes);
@ -524,9 +566,12 @@ public class ThreePaneLayout extends LinearLayout implements View.OnClickListene
return; // But they shouldn't be hidden when cancelled.
}
log("end");
for (View v : mViewsToHide) {
for (View v : mViewsInvisible) {
v.setVisibility(View.INVISIBLE);
}
for (View v : mViewsGone) {
v.setVisibility(View.GONE);
}
mCallback.onVisiblePanesChanged(mPreviousVisiblePanes);
}
}