Merge "Import translations. DO NOT MERGE" into jb-ub-mail
diff --git a/res/drawable-hdpi/default_image.png b/res/drawable-hdpi/default_image.png
new file mode 100644
index 0000000..43e8744
--- /dev/null
+++ b/res/drawable-hdpi/default_image.png
Binary files differ
diff --git a/res/drawable-mdpi/default_image.png b/res/drawable-mdpi/default_image.png
new file mode 100644
index 0000000..e66e04a
--- /dev/null
+++ b/res/drawable-mdpi/default_image.png
Binary files differ
diff --git a/res/drawable-xhdpi/default_image.png b/res/drawable-xhdpi/default_image.png
new file mode 100644
index 0000000..88118a8
--- /dev/null
+++ b/res/drawable-xhdpi/default_image.png
Binary files differ
diff --git a/res/layout-sw600dp/wait_for_manual_sync.xml b/res/layout-sw600dp/wait_for_manual_sync.xml
index 237cd50..37b5554 100644
--- a/res/layout-sw600dp/wait_for_manual_sync.xml
+++ b/res/layout-sw600dp/wait_for_manual_sync.xml
@@ -20,42 +20,38 @@
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical"
-    android:background="@android:color/white">
+    android:background="@android:color/white"
+    android:padding="@dimen/wait_padding">
 
     <TextView
         style="@style/WaitFragmentTitle"
         android:text="@string/not_synced_title"
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:paddingTop="32dip"
-        android:gravity="center"/>
+        android:layout_height="wrap_content"/>
 
     <TextView
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
+        android:layout_height="0dip"
+        android:layout_weight="1.0"
         android:text="@string/wait_for_manual_sync_body"
-        android:textAppearance="?android:attr/textAppearanceMedium"
-        android:paddingTop="32dip"
-        android:lineSpacingExtra="16dip"
-        android:gravity="center" />
+        android:textAppearance="?android:attr/textAppearanceMedium" />
 
     <LinearLayout
-        android:layout_width="match_parent"
+        android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:orientation="horizontal"
-        android:paddingTop="48dip"
-        android:gravity="center">
+        android:orientation="vertical"
+        android:layout_gravity="right">
 
         <Button android:id="@+id/manual_sync"
-            android:layout_width="wrap_content"
+            android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:text="@string/manual_sync" />
+            android:text="@string/manual_sync"
+            android:layout_marginBottom="16dip" />
 
         <Button android:id="@+id/change_sync_settings"
-            android:layout_width="wrap_content"
+            android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:text="@string/change_sync_settings"
-            android:layout_marginLeft="46dip" />
+            android:text="@string/change_sync_settings"/>
 
     </LinearLayout>
 
diff --git a/res/layout-sw600dp/wait_for_sync.xml b/res/layout-sw600dp/wait_for_sync.xml
deleted file mode 100644
index d519902..0000000
--- a/res/layout-sw600dp/wait_for_sync.xml
+++ /dev/null
@@ -1,63 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-     Copyright (C) 2012 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.
--->
-
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:orientation="vertical"
-    android:background="@android:color/white"
-    android:layout_gravity="center" >
-
-    <RelativeLayout android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:gravity="center"
-        android:id="@+id/wait_for_sync_wrapper"
-        android:visibility="visible" >
-
-        <ProgressBar
-            android:indeterminate="true"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:paddingLeft="32dip"
-            android:id="@+id/progress_spinner"
-            android:layout_gravity="center"
-            android:gravity="center"
-            android:paddingTop="32dip" />
-
-        <TextView
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:text="@string/wait_for_sync_title"
-            style="@style/WaitFragmentTitle"
-            android:paddingLeft="48dip"
-            android:paddingTop="32dip"
-            android:id="@+id/wait_for_sync_title"
-            android:layout_toRightOf="@id/progress_spinner" />
-
-        <TextView
-            android:paddingLeft="128dip"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:text="@string/wait_for_sync_body"
-            android:textAppearance="?android:attr/textAppearanceMedium"
-            android:paddingTop="32dip"
-            android:lineSpacingExtra="16dip"
-            android:layout_below="@id/wait_for_sync_title" />
-    </RelativeLayout>
-
-</RelativeLayout>
\ No newline at end of file
diff --git a/res/layout/wait_for_compose.xml b/res/layout/wait_for_compose.xml
index 95e06c5..2f56956 100644
--- a/res/layout/wait_for_compose.xml
+++ b/res/layout/wait_for_compose.xml
@@ -16,13 +16,11 @@
      limitations under the License.
 -->
 
- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:background="@android:color/white"
-    android:gravity="center"
-    android:layout_gravity="center"
-    android:id="@+id/wait_for_sync_wrapper">
+    android:padding="@dimen/wait_padding">
 
     <ProgressBar
         android:indeterminate="true"
@@ -40,4 +38,4 @@
         android:layout_marginTop="8dip"
         android:textAppearance="?android:attr/textAppearanceLarge" />
 
- </RelativeLayout>
+</RelativeLayout>
diff --git a/res/layout/wait_for_manual_sync.xml b/res/layout/wait_for_manual_sync.xml
index 96fbc2a..0748a44 100644
--- a/res/layout/wait_for_manual_sync.xml
+++ b/res/layout/wait_for_manual_sync.xml
@@ -17,38 +17,34 @@
 -->
 
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:orientation="vertical"
-    android:background="@android:color/white">
+   android:layout_width="match_parent"
+   android:layout_height="match_parent"
+   android:orientation="vertical"
+   android:background="@android:color/white"
+   android:padding="@dimen/wait_padding">
 
    <TextView
        style="@style/WaitFragmentTitle"
        android:text="@string/not_synced_title"
-       android:gravity="center"
        android:layout_width="match_parent"
-       android:layout_height="wrap_content"
-       android:paddingTop="16dip"/>
+       android:layout_height="wrap_content"/>
 
    <TextView
        android:layout_width="match_parent"
-       android:layout_height="wrap_content"
+       android:layout_height="0dip"
+       android:layout_weight="1.0"
        android:text="@string/wait_for_manual_sync_body"
-       android:textAppearance="?android:attr/textAppearanceMedium"
-       android:layout_marginTop="32dip"
-       android:layout_marginBottom="16dip"
-       android:gravity="center"
-       android:layout_marginLeft="4dip"
-       android:layout_marginRight="4dip"/>
+       android:textAppearance="?android:attr/textAppearanceMedium"/>
 
    <Button android:id="@+id/manual_sync"
-       android:layout_width="wrap_content"
+       android:layout_width="match_parent"
        android:layout_height="wrap_content"
-       android:text="@string/manual_sync"/>
+       android:text="@string/manual_sync"
+       android:layout_marginBottom="16dip"/>
 
-    <Button android:id="@+id/change_sync_settings"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:text="@string/change_sync_settings" />
+   <Button android:id="@+id/change_sync_settings"
+       android:layout_width="match_parent"
+       android:layout_height="wrap_content"
+       android:text="@string/change_sync_settings" />
 
 </LinearLayout>
diff --git a/res/layout/wait_for_sync.xml b/res/layout/wait_for_sync.xml
index 56e6ae6..ffe9c79 100644
--- a/res/layout/wait_for_sync.xml
+++ b/res/layout/wait_for_sync.xml
@@ -16,43 +16,35 @@
      limitations under the License.
 -->
 
- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-     android:layout_width="match_parent"
-     android:layout_height="match_parent"
-     android:background="@android:color/white">
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@android:color/white"
+    android:padding="@dimen/wait_padding">
 
-     <RelativeLayout android:layout_width="match_parent"
-         android:layout_height="wrap_content"
-         android:gravity="center"
-         android:id="@+id/wait_for_sync_wrapper"
-         android:layout_marginTop="16dip"
-         android:layout_marginLeft="16dip"
-         android:visibility="visible" >
+    <ProgressBar
+        android:indeterminate="true"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:id="@+id/progress_spinner"/>
 
-         <ProgressBar
-             android:indeterminate="true"
-             android:layout_width="wrap_content"
-             android:layout_height="wrap_content"
-             android:id="@+id/progress_spinner"/>
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/wait_for_sync_title"
+        style="@style/WaitFragmentTitle"
+        android:id="@+id/wait_for_sync_title"
+        android:layout_toRightOf="@id/progress_spinner"
+        android:layout_marginLeft="4dip"
+        android:layout_marginBottom="4dip"/>
 
-         <TextView
-             android:layout_width="wrap_content"
-             android:layout_height="wrap_content"
-             android:text="@string/wait_for_sync_title"
-             style="@style/WaitFragmentTitle"
-             android:id="@+id/wait_for_sync_title"
-             android:layout_toRightOf="@id/progress_spinner"
-             android:layout_marginLeft="4dip" />
-
-         <TextView
-             android:layout_width="match_parent"
-             android:layout_height="wrap_content"
-             android:text="@string/wait_for_sync_body"
-             android:textAppearance="?android:attr/textAppearanceSmall"
-             android:layout_below="@id/wait_for_sync_title"
-             android:layout_toRightOf="@id/progress_spinner"
-             android:layout_marginLeft="4dip" />
-     </RelativeLayout>
-
+    <TextView
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:text="@string/wait_for_sync_body"
+        android:textAppearance="?android:attr/textAppearanceSmall"
+        android:layout_below="@id/wait_for_sync_title"
+        android:layout_toRightOf="@id/progress_spinner"
+        android:layout_marginLeft="4dip" />
 
  </RelativeLayout>
diff --git a/res/values-sw600dp/dimen.xml b/res/values-sw600dp/dimen.xml
index 725798e..d980bd3 100644
--- a/res/values-sw600dp/dimen.xml
+++ b/res/values-sw600dp/dimen.xml
@@ -47,4 +47,5 @@
     <dimen name="compose_area_right_padding">100dip</dimen>
     <dimen name="search_view_width">500dip</dimen>
     <dimen name="attachment_tile_min_size">180dp</dimen>
+    <dimen name="wait_padding">32dp</dimen>
 </resources>
diff --git a/res/values-sw600dp/styles.xml b/res/values-sw600dp/styles.xml
index 096fcb1..0f7fce3 100644
--- a/res/values-sw600dp/styles.xml
+++ b/res/values-sw600dp/styles.xml
@@ -54,10 +54,6 @@
         <item name="android:textColor">@color/conv_header_text_light</item>
     </style>
 
-    <style name="WaitFragmentTitle" parent="@android:style/Widget.Holo.TextView">
-        <item name="android:textSize">30sp</item>
-    </style>
-
     <style name="AccountSpinnerAnchorTextPrimary" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
     </style>
 
diff --git a/res/values/dimen.xml b/res/values/dimen.xml
index 9ba1f46..3cf50a9 100644
--- a/res/values/dimen.xml
+++ b/res/values/dimen.xml
@@ -98,4 +98,5 @@
     <dimen name="attachment_tile_min_size">120dp</dimen>
     <dimen name="toast_bar_bottom_margin_in_conversation">24dip</dimen>
     <dimen name="undo_animation_offset">600dp</dimen>
+    <dimen name="wait_padding">16dp</dimen>
 </resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index dc96b79..5e04654 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -561,7 +561,7 @@
     <!-- Displayed for one second after user saves message as draft [CHAR LIMIT=50]-->
     <string name="message_saved">Message saved as draft.</string>
     <!-- Displayed for one second while message is being sent [CHAR LIMIT=50]-->
-    <string name="sending_message">Sending message\u2026</string>
+    <string name="sending_message">Sending message to outbox\u2026</string>
     <!-- Displayed for one second after trying to send with invalid recipients [CHAR LIMIT=50]-->
     <string name="invalid_recipient">The address <xliff:g id="wrongemail" example="foo@@gmail..com">%s</xliff:g> is invalid.</string>
     <!-- Shown in HTML to allow the user to see quoted text; should match Gmail web UI. 25B6 is Unicode for a right-pointing triangle. [CHAR LIMIT=50] -->
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 6cbe36e..46a5f72 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -401,7 +401,9 @@
     </style>
 
     <style name="WaitFragmentTitle" parent="@android:style/Widget.Holo.TextView">
-        <item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
+        <item name="android:textAppearance">?android:attr/textAppearanceLarge</item>
+        <item name="android:textColor">@android:color/black</item>
+        <item name="android:layout_marginBottom">8dip</item>
     </style>
 
     <style name="NotificationPrimaryText">
diff --git a/src/com/android/mail/photo/MailPhotoViewActivity.java b/src/com/android/mail/photo/MailPhotoViewActivity.java
index 0991513..e25289d 100644
--- a/src/com/android/mail/photo/MailPhotoViewActivity.java
+++ b/src/com/android/mail/photo/MailPhotoViewActivity.java
@@ -184,9 +184,17 @@
         }
 
         updateActionItems();
+    }
+
+    @Override
+    public void onFragmentVisible(PhotoViewFragment fragment) {
+        super.onFragmentVisible(fragment);
+
+        final Attachment attachment = getCurrentAttachment();
         updateProgressAndEmptyViews(fragment, attachment);
     }
 
+
     /**
      * Updates the empty views of the fragment based upon the current
      * state of the attachment.
@@ -195,6 +203,7 @@
      */
     private void updateProgressAndEmptyViews(
             PhotoViewFragment fragment, final Attachment attachment) {
+
         final ProgressBarWrapper progressBar = fragment.getPhotoProgressBar();
         final TextView emptyText = fragment.getEmptyText();
         final ImageView retryButton = fragment.getRetryButton();
@@ -204,7 +213,7 @@
             progressBar.setMax(attachment.size);
             progressBar.setProgress(attachment.downloadedSize);
             progressBar.setIndeterminate(false);
-        } else {
+        } else if (fragment.isProgressBarNeeded()) {
             progressBar.setIndeterminate(true);
         }
 
diff --git a/src/com/android/mail/providers/Attachment.java b/src/com/android/mail/providers/Attachment.java
index fee998d..4488fab 100644
--- a/src/com/android/mail/providers/Attachment.java
+++ b/src/com/android/mail/providers/Attachment.java
@@ -25,6 +25,7 @@
 import com.android.mail.providers.UIProvider.AttachmentDestination;
 import com.android.mail.providers.UIProvider.AttachmentState;
 import com.android.mail.utils.LogTag;
+import com.android.mail.utils.LogUtils;
 import com.google.common.collect.Lists;
 
 import org.json.JSONArray;
@@ -189,6 +190,16 @@
                 originExtras == null ? "" : originExtras, ""));
     }
 
+    @Override
+    public String toString() {
+        try {
+            return toJSON().toString();
+        } catch (JSONException e) {
+            LogUtils.e(LOG_TAG, e, "JSONException in toString");
+            return super.toString();
+        }
+    }
+
     private static Uri parseOptionalUri(String uriString) {
         return uriString == null ? null : Uri.parse(uriString);
     }
diff --git a/src/com/android/mail/providers/MailAppProvider.java b/src/com/android/mail/providers/MailAppProvider.java
index 479cea0..f187ba1 100644
--- a/src/com/android/mail/providers/MailAppProvider.java
+++ b/src/com/android/mail/providers/MailAppProvider.java
@@ -42,13 +42,11 @@
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 
-import java.util.Collections;
 import java.util.Map;
 import java.util.Set;
 import java.util.regex.Pattern;
 
 
-
 /**
  * The Mail App provider allows email providers to register "accounts" and the UI has a single
  * place to query for the list of accounts.
@@ -381,21 +379,13 @@
         cacheAccountList();
     }
 
-    public static void removeAccount(Uri accountUri) {
-        final MailAppProvider provider = getInstance();
-        if (provider == null) {
-            throw new IllegalStateException("MailAppProvider not intialized");
-        }
-        provider.removeAccounts(Collections.singleton(accountUri), true /* notify */);
-    }
-
     private void removeAccounts(Set<Uri> uris, boolean notify) {
         synchronized (mAccountCache) {
             for (Uri accountUri : uris) {
+                LogUtils.d(LOG_TAG, "Removing account %s", accountUri);
                 mAccountCache.remove(accountUri);
             }
         }
-
         // Explicitly calling this out of the synchronized block in case any of the observers get
         // called synchronously.
         if (notify) {
@@ -549,16 +539,13 @@
             newQueryUriMap.add(accountUri);
             addAccountImpl(account, accountsQueryUri, false /* don't notify */);
         }
+        // Remove all of the accounts that are in the new result set
+        previousQueryUriMap.removeAll(newQueryUriMap);
 
-        if (previousQueryUriMap != null) {
-            // Remove all of the accounts that are in the new result set
-            previousQueryUriMap.removeAll(newQueryUriMap);
-
-            // For all of the entries that had been in the previous result set, and are not
-            // in the new result set, remove them from the cache
-            if (previousQueryUriMap.size() > 0 && mAccountsFullyLoaded) {
-              removeAccounts(previousQueryUriMap, false /* don't notify */);
-            }
+        // For all of the entries that had been in the previous result set, and are not
+        // in the new result set, remove them from the cache
+        if (previousQueryUriMap.size() > 0 && mAccountsFullyLoaded) {
+            removeAccounts(previousQueryUriMap, false /* don't notify */);
         }
         broadcastAccountChange();
     }