diff --git a/app/src/main/java/i2p/bote/android/NewEmailFragment.java b/app/src/main/java/i2p/bote/android/NewEmailFragment.java index 52246e2..95e4bd9 100644 --- a/app/src/main/java/i2p/bote/android/NewEmailFragment.java +++ b/app/src/main/java/i2p/bote/android/NewEmailFragment.java @@ -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(); diff --git a/app/src/main/java/i2p/bote/android/ViewEmailFragment.java b/app/src/main/java/i2p/bote/android/ViewEmailFragment.java index 96773a8..552dfca 100644 --- a/app/src/main/java/i2p/bote/android/ViewEmailFragment.java +++ b/app/src/main/java/i2p/bote/android/ViewEmailFragment.java @@ -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); diff --git a/app/src/main/res/drawable-hdpi/ic_more_vert_grey600_24dp.png b/app/src/main/res/drawable-hdpi/ic_more_vert_grey600_24dp.png new file mode 100644 index 0000000..e141502 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_more_vert_grey600_24dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_more_vert_grey600_24dp.png b/app/src/main/res/drawable-mdpi/ic_more_vert_grey600_24dp.png new file mode 100644 index 0000000..4ed3435 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_more_vert_grey600_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_more_vert_grey600_24dp.png b/app/src/main/res/drawable-xhdpi/ic_more_vert_grey600_24dp.png new file mode 100644 index 0000000..7bc63a5 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_more_vert_grey600_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_more_vert_grey600_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_more_vert_grey600_24dp.png new file mode 100644 index 0000000..44012b8 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_more_vert_grey600_24dp.png differ diff --git a/app/src/main/res/layout/listitem_attachment.xml b/app/src/main/res/layout/listitem_attachment.xml index 202be61..334f1d0 100644 --- a/app/src/main/res/layout/listitem_attachment.xml +++ b/app/src/main/res/layout/listitem_attachment.xml @@ -37,7 +37,7 @@ Reply Reply all Forward + Save Compose Subject Compose email