Printing: support tablet message header overflow.

b/10712542
Adds new behavior for v19 devices, both phone and tablet.
On phone, new printing option in MessageHeaderView overflow menu.
On tablet, new printing option in same place but since we now
have an overflow, we use the reply/reply all setting to show
only one of reply/reply all on tablet as well.

As a result, we also changed the string for that setting for
v19 tablets.

Change-Id: I71db88ce4a50479b03775b9d50d65e3626231589
diff --git a/res/layout-sw600dp/conversation_message_upper_header_actions.xml b/res/layout-v19/conversation_message_upper_header_actions_land_or_tablet.xml
similarity index 87%
rename from res/layout-sw600dp/conversation_message_upper_header_actions.xml
rename to res/layout-v19/conversation_message_upper_header_actions_land_or_tablet.xml
index 2e3c5f9..e21ccd0 100644
--- a/res/layout-sw600dp/conversation_message_upper_header_actions.xml
+++ b/res/layout-v19/conversation_message_upper_header_actions_land_or_tablet.xml
@@ -42,4 +42,9 @@
         style="@style/MessageHeaderActionButtonStyle"
         android:src="@drawable/ic_forward_holo_light"
         android:contentDescription="@string/forward" />
+    <ImageView
+        android:id="@+id/overflow"
+        android:layout_height="@dimen/message_header_action_button_height"
+        android:layout_width="@dimen/message_header_action_button_width"
+        style="@style/OverflowButtonStyle" />
 </merge>
diff --git a/res/layout-land/conversation_message_upper_header_actions.xml b/res/layout/conversation_message_upper_header_actions_land_or_tablet.xml
similarity index 100%
rename from res/layout-land/conversation_message_upper_header_actions.xml
rename to res/layout/conversation_message_upper_header_actions_land_or_tablet.xml
diff --git a/res/menu-sw600dp-land/conversation_actions.xml b/res/menu-sw600dp-land/conversation_actions.xml
index a9ff1ef..f61d58b 100644
--- a/res/menu-sw600dp-land/conversation_actions.xml
+++ b/res/menu-sw600dp-land/conversation_actions.xml
@@ -102,6 +102,11 @@
         android:id="@+id/mute"
         android:title="@string/mute"
         android:showAsAction="never" />
+
+    <item android:id="@+id/print_all"
+          android:title="@string/print_all"
+          android:visible="false" />
+
     <item
         android:id="@+id/show_original"
         android:title="@string/menu_show_original"
diff --git a/res/menu/conversation_actions.xml b/res/menu/conversation_actions.xml
index 9c722d8..bb3976f 100644
--- a/res/menu/conversation_actions.xml
+++ b/res/menu/conversation_actions.xml
@@ -92,6 +92,11 @@
     <item
         android:id="@+id/mute"
         android:title="@string/mute" />
+
+    <item android:id="@+id/print_all"
+          android:title="@string/print_all"
+          android:visible="false" />
+
     <item
         android:id="@+id/show_original"
         android:title="@string/menu_show_original"/>
@@ -111,10 +116,6 @@
         android:title="@string/report_phishing"
         android:visible="false" />
 
-    <item android:id="@+id/print"
-          android:title="@string/print"
-          android:visible="false" />
-
     <!-- Always available -->
     <item android:id="@+id/settings"
         android:title="@string/menu_settings" />
diff --git a/res/menu/message_header_overflow_menu.xml b/res/menu/message_header_overflow_menu.xml
index 46f5e97..5c5f233 100644
--- a/res/menu/message_header_overflow_menu.xml
+++ b/res/menu/message_header_overflow_menu.xml
@@ -23,6 +23,8 @@
           android:title="@string/reply_all" />
     <item android:id="@+id/forward"
           android:title="@string/forward" />
+    <item android:id="@+id/print_message"
+          android:title="@string/print" />
     <item android:id="@+id/report_rendering_problem"
           android:title="@string/report_rendering_problem" />
     <item android:id="@+id/report_rendering_improvement"
diff --git a/res/menu/message_header_overflow_menu_land_or_tablet_v19.xml b/res/menu/message_header_overflow_menu_land_or_tablet_v19.xml
new file mode 100644
index 0000000..d48dbb5
--- /dev/null
+++ b/res/menu/message_header_overflow_menu_land_or_tablet_v19.xml
@@ -0,0 +1,30 @@
+<?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.
+-->
+
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:id="@+id/reply"
+          android:title="@string/reply" />
+    <item android:id="@+id/reply_all"
+          android:title="@string/reply_all" />
+    <item android:id="@+id/print_message"
+          android:title="@string/print" />
+    <item android:id="@+id/report_rendering_problem"
+          android:title="@string/report_rendering_problem" />
+    <item android:id="@+id/report_rendering_improvement"
+          android:title="@string/report_rendering_improvement" />
+</menu>
diff --git a/res/values-land/layouts.xml b/res/values-land/layouts.xml
new file mode 100755
index 0000000..2a9894a
--- /dev/null
+++ b/res/values-land/layouts.xml
@@ -0,0 +1,22 @@
+<?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>
+    <item name="conversation_message_upper_header_actions" type="layout">
+        @layout/conversation_message_upper_header_actions_land_or_tablet</item>
+</resources>
diff --git a/res/values-land/menus.xml b/res/values-land/menus.xml
new file mode 100644
index 0000000..694e663
--- /dev/null
+++ b/res/values-land/menus.xml
@@ -0,0 +1,22 @@
+<?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>
+    <item name="message_header_overflow_menu" type="menu">
+        @menu/message_header_overflow_menu_land_or_tablet_v19</item>
+</resources>
\ No newline at end of file
diff --git a/res/values-sw600dp-v19/strings.xml b/res/values-sw600dp-v19/strings.xml
new file mode 100644
index 0000000..b0d646a
--- /dev/null
+++ b/res/values-sw600dp-v19/strings.xml
@@ -0,0 +1,20 @@
+<?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>
+    <string name="preferences_default_reply_all_summary" translatable="false">@string/preferences_default_reply_all_summary_impl</string>
+</resources>
\ No newline at end of file
diff --git a/res/values-sw600dp/layouts.xml b/res/values-sw600dp/layouts.xml
new file mode 100755
index 0000000..2a9894a
--- /dev/null
+++ b/res/values-sw600dp/layouts.xml
@@ -0,0 +1,22 @@
+<?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>
+    <item name="conversation_message_upper_header_actions" type="layout">
+        @layout/conversation_message_upper_header_actions_land_or_tablet</item>
+</resources>
diff --git a/res/values-sw600dp/menus.xml b/res/values-sw600dp/menus.xml
new file mode 100644
index 0000000..694e663
--- /dev/null
+++ b/res/values-sw600dp/menus.xml
@@ -0,0 +1,22 @@
+<?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>
+    <item name="message_header_overflow_menu" type="menu">
+        @menu/message_header_overflow_menu_land_or_tablet_v19</item>
+</resources>
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 55195fe..97035e0 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -808,7 +808,9 @@
     <!--  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>
+    <string name="preferences_default_reply_all_summary_impl">Use as default for message replies</string>
+    <!--  DO NOT TRANSLATE THE BELOW STRING - In order to allow overriding of this for K tablets (but not pre-K tablets), we use an indirection with the actual string defined above. -->
+    <string name="preferences_default_reply_all_summary" translatable="false">@string/preferences_default_reply_all_summary_impl</string>
 
     <!-- Preference name for swipe action when action is archive [CHAR LIMIT=100]-->
     <string name="preference_swipe_title_archive">Swipe to archive</string>
@@ -934,8 +936,10 @@
     <!-- Button in conversation list to hide folders [CHAR LIMIT=50] -->
     <string name="hide_folders">Hide folders</string>
 
-    <!-- Menu item text to that when clicked will allow a user to print an email conversation. [CHAR LIMIT=25] -->
+    <!-- Menu item text to that when clicked will allow a user to print an email message. [CHAR LIMIT=25] -->
     <string name="print">Print</string>
+    <!-- Menu item text to that when clicked will allow a user to print an email conversation. [CHAR LIMIT=25] -->
+    <string name="print_all">Print all</string>
     <!-- Number of messages in a conversation [CHAR LIMIT=30]-->
     <plurals name="num_messages">
         <item quantity="one"><xliff:g id="count">%1$d</xliff:g> message</item>
diff --git a/src/com/android/mail/browse/MessageHeaderView.java b/src/com/android/mail/browse/MessageHeaderView.java
index 205fa8c..677be9d 100644
--- a/src/com/android/mail/browse/MessageHeaderView.java
+++ b/src/com/android/mail/browse/MessageHeaderView.java
@@ -895,6 +895,7 @@
             final Menu m = mPopup.getMenu();
             m.findItem(R.id.reply).setVisible(defaultReplyAll);
             m.findItem(R.id.reply_all).setVisible(!defaultReplyAll);
+            m.findItem(R.id.print_message).setVisible(Utils.isRunningKitkatOrLater());
 
             final boolean reportRendering = ENABLE_REPORT_RENDERING_PROBLEM
                 && mCallbacks.supportsMessageTransforms();
diff --git a/src/com/android/mail/ui/AbstractConversationViewFragment.java b/src/com/android/mail/ui/AbstractConversationViewFragment.java
index 5b64ce8..b27bd04 100644
--- a/src/com/android/mail/ui/AbstractConversationViewFragment.java
+++ b/src/com/android/mail/ui/AbstractConversationViewFragment.java
@@ -24,7 +24,6 @@
 import android.content.Loader;
 import android.database.Cursor;
 import android.net.Uri;
-import android.os.Build;
 import android.os.Bundle;
 import android.os.Handler;
 import android.view.Menu;
@@ -333,7 +332,7 @@
         } else if (itemId == R.id.show_original) {
             showUntransformedConversation();
             handled = true;
-        } else if (itemId == R.id.print) {
+        } else if (itemId == R.id.print_all) {
             printConversation();
             handled = true;
         }
@@ -345,7 +344,7 @@
         // Only show option if we support message transforms and message has been transformed.
         Utils.setMenuItemVisibility(menu, R.id.show_original, supportsMessageTransforms() &&
                 mHasConversationBeenTransformed && !mHasConversationTransformBeenReverted);
-        Utils.setMenuItemVisibility(menu, R.id.print, Utils.isRunningKitkatOrLater());
+        Utils.setMenuItemVisibility(menu, R.id.print_all, Utils.isRunningKitkatOrLater());
     }
 
     abstract boolean supportsMessageTransforms();