Merge "Several image attachment fixes" 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/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);
}