Update settings per latest UX spec.

Fixes b/8773002. Turns Remove Action into Archive & delete
actions with three options. Setting that option changes
the title of the text in the swipe to setting below it.

This CL adds strings, changes around the preferences to support
the new tri-state setting, and updates the action bar based on
the setting (to show archive, delete, or archive & delete and
push move to into the overflow). An accompanying CL does the
rest of the work.

Change-Id: I17d8ada9bc9f16b5e7b5a8abd8c55e8708773991
diff --git a/res/menu/conversation_list_selection_actions_menu.xml b/res/menu/conversation_list_selection_actions_menu.xml
index c8823ae..d97d6ab 100644
--- a/res/menu/conversation_list_selection_actions_menu.xml
+++ b/res/menu/conversation_list_selection_actions_menu.xml
@@ -53,17 +53,17 @@
         android:icon="@drawable/trash"
         android:visible="false" />
 
-    <!-- Only one of mark read or mark unread is shown. Both of these are set as always. -->
+    <!-- Only one of mark read or mark unread is shown. -->
     <item
         android:id="@+id/read"
         android:title="@string/mark_read"
-        android:showAsAction="always"
+        android:showAsAction="ifRoom"
         android:icon="@drawable/ic_menu_mark_read_holo_light" />
 
     <item
         android:id="@+id/unread"
         android:title="@string/mark_unread"
-        android:showAsAction="always"
+        android:showAsAction="ifRoom"
         android:icon="@drawable/ic_menu_mark_unread_holo_light" />
 
     <item
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 82b46df..f8d7cc1 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -838,33 +838,38 @@
     <string name="silent_ringtone">Silent</string>
 
     <!-- Settings screen, preference name for archive vs. delete [CHAR LIMIT=50] -->
-    <string name="preference_archive_vs_delete_title">Remove action</string>
+    <string name="preference_removal_action_title">Archive &amp; delete actions</string>
     <!-- Options to select from for whether to have archive or delete as the remove action [CHAR LIMIT=50] -->
-    <string-array name="prefEntries_archive_vs_delete">
-        <item>Archive conversations</item>
-        <item>Delete conversations</item>
+    <string-array name="prefEntries_removal_action">
+        <item>Show archive only</item>
+        <item>Show delete only</item>
+        <item>Show archive &amp; delete</item>
     </string-array>
     <!-- Description of currently selected option of whether to use archive or delete as remove action [CHAR LIMIT=200] -->
-    <string-array name="prefSummaries_archive_vs_delete_summary">
-        <item>Archive rather than delete conversations</item>
-        <item>Delete rather than archive conversations</item>
+    <string-array name="prefSummaries_removal_action_summary">
+        <item>Show archive only</item>
+        <item>Show delete only</item>
+        <item>Show archive &amp; delete</item>
     </string-array>
-    <string-array translatable="false" name="prefValues_archive_vs_delete">
+    <string-array translatable="false" name="prefValues_removal_action">
         <item>archive</item>
         <item>delete</item>
+        <item>archive-and-delete</item>
     </string-array>
     <!-- Dialog title for the choosing whether to use archive or delete as remove action [CHAR LIMIT=150] -->
-    <string name="prefDialogTitle_archive_vs_delete">Remove action</string>
+    <string name="prefDialogTitle_removal_action">Archive &amp; delete actions</string>
     <!-- The default value -->
-    <string translatable="false" name="prefDefault_archive_vs_delete">archive</string>
+    <string translatable="false" name="prefDefault_removal_action">archive</string>
 
     <!--  Settings screen, Reply to all default setting title  [CHAR LIMIT=30] -->
     <string name="preferences_default_reply_all_title">Reply all</string>
     <!--  Settings screen, Reply to all default setting summary [CHAR LIMIT=70] -->
     <string name="preferences_default_reply_all_summary">Use as default for message replies</string>
 
-    <!-- Preference name for swipe action [CHAR LIMIT=100]-->
-    <string name="preference_swipe_title">Swipe to remove</string>
+    <!-- Preference name for swipe action when action is archive [CHAR LIMIT=100]-->
+    <string name="preference_swipe_title_archive">Swipe to archive</string>
+    <!-- Preference name for swipe action when action is delete [CHAR LIMIT=100]-->
+    <string name="preference_swipe_title_delete">Swipe to delete</string>
     <!-- Preference description swiping in conversation list option [CHAR LIMIT=100] -->
     <string name="preference_swipe_description">In conversation list</string>
 
diff --git a/src/com/android/mail/preferences/FolderPreferences.java b/src/com/android/mail/preferences/FolderPreferences.java
index 4da2089..00d7048 100644
--- a/src/com/android/mail/preferences/FolderPreferences.java
+++ b/src/com/android/mail/preferences/FolderPreferences.java
@@ -252,7 +252,8 @@
                 account.supportsCapability(AccountCapabilities.ARCHIVE)
                 && (mFolder.supportsCapability(FolderCapabilities.ARCHIVE)
                 || mFolder.supportsCapability(FolderCapabilities.ALLOWS_REMOVE_CONVERSATION));
-        final boolean preferDelete = MailPrefs.get(getContext()).getPreferDelete();
+        final boolean preferDelete = MailPrefs.RemovalActions.DELETE.equals(
+                MailPrefs.get(getContext()).getRemovalAction());
         final NotificationActionType destructiveActionType =
                 supportsArchiveRemoveLabel && !preferDelete ?
                         NotificationActionType.ARCHIVE_REMOVE_LABEL : NotificationActionType.DELETE;
diff --git a/src/com/android/mail/preferences/MailPrefs.java b/src/com/android/mail/preferences/MailPrefs.java
index ff4e0f8..10da3fd 100644
--- a/src/com/android/mail/preferences/MailPrefs.java
+++ b/src/com/android/mail/preferences/MailPrefs.java
@@ -59,9 +59,9 @@
         public static final String CONVERSATION_LIST_SWIPE = "conversation-list-swipe";
 
         /**
-         * A boolean indicating whether the user prefers delete or archive.
+         * A string indicating the user's removal action preference.
          */
-        public static final String PREFER_DELETE = "prefer-delete";
+        public static final String REMOVAL_ACTION = "removal-action";
 
         /** Hidden preference used to cache the active notification set */
         private static final String CACHED_ACTIVE_NOTIFICATION_SET =
@@ -71,7 +71,7 @@
                 new ImmutableSet.Builder<String>()
                 .add(DEFAULT_REPLY_ALL)
                 .add(CONVERSATION_LIST_SWIPE)
-                .add(PREFER_DELETE)
+                .add(REMOVAL_ACTION)
                 .build();
 
     }
@@ -82,6 +82,12 @@
         public static final String DISABLED = "disabled";
     }
 
+    public static final class RemovalActions {
+        public static final String ARCHIVE = "archive";
+        public static final String DELETE = "delete";
+        public static final String ARCHIVE_AND_DELETE = "archive-and-delete";
+    }
+
     public static MailPrefs get(Context c) {
         if (sInstance == null) {
             sInstance = new MailPrefs(c);
@@ -157,15 +163,20 @@
     }
 
     /**
-     * Gets a boolean indicating whether delete is preferred over archive.
+     * Returns a string indicating the preferred removal action.
+     * Should be one of the {@link RemovalActions}.
      */
-    public boolean getPreferDelete() {
+    public String getRemovalAction() {
         final SharedPreferences sharedPreferences = getSharedPreferences();
-        return sharedPreferences.getBoolean(PreferenceKeys.PREFER_DELETE, false);
+        return sharedPreferences.getString(PreferenceKeys.REMOVAL_ACTION, RemovalActions.ARCHIVE);
     }
 
-    public void setPreferDelete(final boolean preferDelete) {
-        getEditor().putBoolean(PreferenceKeys.PREFER_DELETE, preferDelete).apply();
+    /**
+     * Sets the removal action preference.
+     * @param removalAction The preferred {@link RemovalActions}.
+     */
+    public void setRemovalAction(final String removalAction) {
+        getEditor().putString(PreferenceKeys.REMOVAL_ACTION, removalAction).apply();
         MailIntentService.broadcastBackupDataChanged(getContext());
     }
 
@@ -191,7 +202,7 @@
      */
     public int getConversationListSwipeActionInteger(final boolean allowArchive) {
         final boolean swipeEnabled = getIsConversationListSwipeEnabled();
-        final boolean archive = !getPreferDelete() && allowArchive;
+        final boolean archive = !RemovalActions.DELETE.equals(getRemovalAction()) && allowArchive;
 
         if (swipeEnabled) {
             return archive ? UIProvider.Swipe.ARCHIVE : UIProvider.Swipe.DELETE;
diff --git a/src/com/android/mail/ui/MailActionBarView.java b/src/com/android/mail/ui/MailActionBarView.java
index a88a634..5b410b1 100644
--- a/src/com/android/mail/ui/MailActionBarView.java
+++ b/src/com/android/mail/ui/MailActionBarView.java
@@ -452,7 +452,11 @@
      * preference.
      */
     public static void reorderMenu(final Context context, final Menu menu) {
-        final boolean preferDelete = MailPrefs.get(context).getPreferDelete();
+        final String removalAction = MailPrefs.get(context).getRemovalAction();
+        final boolean showArchive = MailPrefs.RemovalActions.ARCHIVE.equals(removalAction) ||
+                MailPrefs.RemovalActions.ARCHIVE_AND_DELETE.equals(removalAction);
+        final boolean showDelete = MailPrefs.RemovalActions.DELETE.equals(removalAction) ||
+                MailPrefs.RemovalActions.ARCHIVE_AND_DELETE.equals(removalAction);
 
         // Do a first pass to extract necessary information on what is safe to move to the overflow
         boolean archiveVisibleEnabled = false;
@@ -474,15 +478,23 @@
             final MenuItem menuItem = menu.getItem(i);
             final int itemId = menuItem.getItemId();
 
-            if (preferDelete && deleteVisibleEnabled) {
+            if (!showArchive && deleteVisibleEnabled) {
                 if (itemId == R.id.archive || itemId == R.id.remove_folder) {
                     menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
                 }
-            } else if (!preferDelete && archiveVisibleEnabled) {
+            }
+
+            if (!showDelete && archiveVisibleEnabled) {
                 if (itemId == R.id.delete || itemId == R.id.discard_drafts) {
                     menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
                 }
             }
+
+            if (showArchive && archiveVisibleEnabled && showDelete && deleteVisibleEnabled) {
+                if (itemId == R.id.move_to) {
+                    menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
+                }
+            }
         }
     }