Automated import from //branches/master/...@142747,142747
This commit is contained in:
parent
123ef48a0d
commit
d211e5c51c
@ -190,6 +190,10 @@
|
||||
the email address, e.g. "Add xyz@foo.com to contacts" -->
|
||||
<string name="add_contact_dlg_message_fmt">Add \"<xliff:g id="email">%s</xliff:g>\" to contacts
|
||||
</string>
|
||||
<!-- String that is displayed when the attachment could not be displayed. TODO: Make local
|
||||
version and remove use of "borrowed" string. -->
|
||||
<string name="message_view_display_attachment_toast"
|
||||
msgid="6849630429576038532">This attachment cannot be displayed.</string>
|
||||
|
||||
<!-- Title of screen when setting up new email account -->
|
||||
<string name="account_setup_basics_title">Set up email</string>
|
||||
|
@ -36,6 +36,7 @@ import com.android.email.provider.AttachmentProvider;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
@ -134,6 +135,7 @@ public class MessageView extends Activity
|
||||
private static final int MSG_SHOW_SHOW_PICTURES = 9;
|
||||
private static final int MSG_FETCHING_ATTACHMENT = 10;
|
||||
private static final int MSG_SET_SENDER_PRESENCE = 11;
|
||||
private static final int MSG_VIEW_ATTACHMENT_ERROR = 12;
|
||||
|
||||
@Override
|
||||
public void handleMessage(android.os.Message msg) {
|
||||
@ -188,6 +190,11 @@ public class MessageView extends Activity
|
||||
case MSG_SET_SENDER_PRESENCE:
|
||||
updateSenderPresence(msg.arg1);
|
||||
break;
|
||||
case MSG_VIEW_ATTACHMENT_ERROR:
|
||||
Toast.makeText(MessageView.this,
|
||||
getString(R.string.message_view_display_attachment_toast),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
default:
|
||||
super.handleMessage(msg);
|
||||
}
|
||||
@ -260,6 +267,10 @@ public class MessageView extends Activity
|
||||
.obtain(this, MSG_SET_SENDER_PRESENCE, presenceIconId, 0)
|
||||
.sendToTarget();
|
||||
}
|
||||
|
||||
public void attachmentViewError() {
|
||||
sendEmptyMessage(MSG_VIEW_ATTACHMENT_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1037,13 +1048,14 @@ public class MessageView extends Activity
|
||||
out.close();
|
||||
in.close();
|
||||
mHandler.attachmentSaved(file.getName());
|
||||
new MediaScannerNotifier(MessageView.this, file);
|
||||
new MediaScannerNotifier(MessageView.this, file, mHandler);
|
||||
}
|
||||
catch (IOException ioe) {
|
||||
mHandler.attachmentNotSaved();
|
||||
}
|
||||
}
|
||||
else {
|
||||
try {
|
||||
Uri uri = AttachmentProvider.getAttachmentUri(
|
||||
mAccount,
|
||||
attachment.part.getAttachmentId());
|
||||
@ -1051,6 +1063,11 @@ public class MessageView extends Activity
|
||||
intent.setData(uri);
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
startActivity(intent);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
mHandler.attachmentViewError();
|
||||
// TODO: Add a proper warning message (and lots of upstream cleanup to prevent
|
||||
// it from happening) in the next release.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1072,10 +1089,12 @@ public class MessageView extends Activity
|
||||
private Context mContext;
|
||||
private MediaScannerConnection mConnection;
|
||||
private File mFile;
|
||||
MessageViewHandler mHandler;
|
||||
|
||||
public MediaScannerNotifier(Context context, File file) {
|
||||
public MediaScannerNotifier(Context context, File file, MessageViewHandler handler) {
|
||||
mContext = context;
|
||||
mFile = file;
|
||||
mHandler = handler;
|
||||
mConnection = new MediaScannerConnection(context, this);
|
||||
mConnection.connect();
|
||||
}
|
||||
@ -1091,9 +1110,14 @@ public class MessageView extends Activity
|
||||
intent.setData(uri);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
} catch (ActivityNotFoundException e) {
|
||||
mHandler.attachmentViewError();
|
||||
// TODO: Add a proper warning message (and lots of upstream cleanup to prevent
|
||||
// it from happening) in the next release.
|
||||
} finally {
|
||||
mConnection.disconnect();
|
||||
mContext = null;
|
||||
mHandler = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user