Merge "Two options on narrow; Three on wide" into jb-ub-mail-ur9
diff --git a/res/values-sw340dp/constants.xml b/res/values-sw340dp/constants.xml
new file mode 100644
index 0000000..e181003
--- /dev/null
+++ b/res/values-sw340dp/constants.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Copyright (C) 2013 Google Inc.
+ Licensed to 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.
+-->
+<resources>
+ <!-- Is the screen narrow? Used to determine how many items to show in CAB mode. -->
+ <bool name="is_narrow">false</bool>
+</resources>
diff --git a/res/values/constants.xml b/res/values/constants.xml
index 3eca8f0..234d73b 100644
--- a/res/values/constants.xml
+++ b/res/values/constants.xml
@@ -112,4 +112,6 @@
<bool name="inline_personal_level">true</bool>
<integer name="swipe_senders_length">25</integer>
+ <!-- Is the screen narrow? Used to determine how many items to show in CAB mode. -->
+ <bool name="is_narrow">true</bool>
</resources>
diff --git a/src/com/android/mail/browse/SelectedConversationsActionMenu.java b/src/com/android/mail/browse/SelectedConversationsActionMenu.java
index 9f6a03e..5fd902b 100644
--- a/src/com/android/mail/browse/SelectedConversationsActionMenu.java
+++ b/src/com/android/mail/browse/SelectedConversationsActionMenu.java
@@ -18,6 +18,7 @@
package com.android.mail.browse;
import android.content.Context;
+import android.content.res.Resources;
import android.net.Uri;
import android.view.ActionMode;
import android.view.Menu;
@@ -89,6 +90,8 @@
private final Folder mFolder;
private AccountObserver mAccountObserver;
+ /** True if this device is narrow. */
+ private final boolean mMoveToInOverflow;
public SelectedConversationsActionMenu(
ControllableActivity activity, ConversationSelectionSet selectionSet, Folder folder) {
@@ -103,6 +106,9 @@
};
mAccount = mAccountObserver.initialize(activity.getAccountController());
mFolder = folder;
+ final Resources r = activity.getActivityContext().getResources();
+ // If the device is narrow, "move to" should be in the overflow menu.
+ mMoveToInOverflow = r.getBoolean(R.bool.is_narrow);
mContext = mActivity.getActivityContext();
mUpdater = activity.getConversationUpdater();
FolderSelectionDialog.setDialogDismissed();
@@ -386,6 +392,12 @@
&& mFolder.supportsCapability(FolderCapabilities.ALLOWS_REMOVE_CONVERSATION);
removeFolder.setVisible(showRemoveFolder);
moveTo.setVisible(showMoveTo);
+ if (showMoveTo) {
+ // Hide the "move to" on narrow devices so that the selected count can be shown.
+ final int showWhen = mMoveToInOverflow ? MenuItem.SHOW_AS_ACTION_IF_ROOM
+ : MenuItem.SHOW_AS_ACTION_ALWAYS;
+ moveTo.setShowAsAction(showWhen);
+ }
if (mFolder != null && showRemoveFolder) {
removeFolder.setTitle(mActivity.getActivityContext().getString(R.string.remove_folder,
mFolder.name));