Stubbed out attachment saving

This commit is contained in:
str4d
2015-01-01 11:48:45 +00:00
parent 9626e5e384
commit 37601393cb
8 changed files with 40 additions and 4 deletions

View File

@@ -449,7 +449,7 @@ public class NewEmailFragment extends Fragment {
v.setTag(attachment);
((TextView) v.findViewById(R.id.filename)).setText(attachment.getFileName());
((TextView) v.findViewById(R.id.size)).setText(attachment.getHumanReadableSize());
v.findViewById(R.id.remove_attachment).setOnClickListener(new View.OnClickListener() {
v.findViewById(R.id.attachment_action).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
attachment.clean();

View File

@@ -6,6 +6,7 @@ import android.graphics.Typeface;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.PopupMenu;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@@ -79,7 +80,7 @@ public class ViewEmailFragment extends Fragment {
return v;
}
private void displayEmail(Email email, View v) {
private void displayEmail(final Email email, View v) {
View sigInvalid = v.findViewById(R.id.signature_invalid);
TextView subject = (TextView) v.findViewById(R.id.email_subject);
ImageView picture = (ImageView) v.findViewById(R.id.picture);
@@ -174,7 +175,30 @@ public class ViewEmailFragment extends Fragment {
View a = getActivity().getLayoutInflater().inflate(R.layout.listitem_attachment, attachments, false);
((TextView)a.findViewById(R.id.filename)).setText(attachment.getFileName());
((TextView)a.findViewById(R.id.size)).setText(attachment.getHumanReadableSize());
a.findViewById(R.id.remove_attachment).setVisibility(View.GONE);
final ImageView action = (ImageView) a.findViewById(R.id.attachment_action);
action.setImageDrawable(getActivity().getResources().getDrawable(R.drawable.ic_more_vert_grey600_24dp));
final int finalPartIndex = partIndex;
action.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
PopupMenu popup = new PopupMenu(getActivity(), action);
popup.inflate(R.menu.attachment);
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
switch (menuItem.getItemId()) {
case R.id.save_attachment:
saveAttachment(email, finalPartIndex);
return true;
default:
return false;
}
}
});
popup.show();
}
});
final Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(AttachmentProvider.getUriForAttachment(mFolderName, mMessageId, partIndex));
@@ -214,6 +238,17 @@ public class ViewEmailFragment extends Fragment {
}
}
private void saveAttachment(Email email, int partNum) {
try {
Part attachment = email.getParts().get(partNum);
Toast.makeText(getActivity(), "Saving attachment " + attachment.getFileName(), Toast.LENGTH_SHORT).show();
} catch (MessagingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.view_email, menu);

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 316 B

View File

@@ -37,7 +37,7 @@
</LinearLayout>
<ImageView
android:id="@+id/remove_attachment"
android:id="@+id/attachment_action"
android:layout_width="@dimen/listitem_picture_size"
android:layout_height="@dimen/listitem_picture_size"
android:scaleType="center"

View File

@@ -120,6 +120,7 @@
<string name="reply">Reply</string>
<string name="reply_all">Reply all</string>
<string name="forward">Forward</string>
<string name="save">Save</string>
<string name="compose">Compose</string>
<string name="subject">Subject</string>
<string name="compose_email">Compose email</string>