From 37601393cbe97211b94088b29a80aea78be100c0 Mon Sep 17 00:00:00 2001 From: str4d Date: Thu, 1 Jan 2015 11:48:45 +0000 Subject: [PATCH] Stubbed out attachment saving --- .../i2p/bote/android/NewEmailFragment.java | 2 +- .../i2p/bote/android/ViewEmailFragment.java | 39 +++++++++++++++++- .../ic_more_vert_grey600_24dp.png | Bin 0 -> 221 bytes .../ic_more_vert_grey600_24dp.png | Bin 0 -> 202 bytes .../ic_more_vert_grey600_24dp.png | Bin 0 -> 252 bytes .../ic_more_vert_grey600_24dp.png | Bin 0 -> 316 bytes .../main/res/layout/listitem_attachment.xml | 2 +- app/src/main/res/values/strings.xml | 1 + 8 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 app/src/main/res/drawable-hdpi/ic_more_vert_grey600_24dp.png create mode 100644 app/src/main/res/drawable-mdpi/ic_more_vert_grey600_24dp.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_more_vert_grey600_24dp.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_more_vert_grey600_24dp.png 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 0000000000000000000000000000000000000000..e141502a69bd1442b49b6a5cc1b35fe71be48ebe GIT binary patch literal 221 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k0wldT1B8K;Lb6AYF9SoB8UsT^3j@P1pisjL z28L1t28LG&3=CE?7#PG0=Ijcz0ZK3>dAqwX{BQ3+vmeOgEbxddW?B?0_fWX?B;$bJn%o3gg`e4<#CsF(r!<{wG@5&M z(Zr;H=XI+MGptRLFBD}QS@0~N)3NhZO27`2C2dzGNCi1(o%rv-|4@I)+XZO=~G=WkM1 zFVdQ&MBb@0ROQx761SM literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..7bc63a511de28fa7260348468d9523e8a42413fe GIT binary patch literal 252 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA0wn)(8}a}tg=CK)Uj~LMH3o);76yi2K%s^g z3=E|}g|8AA7_4S6Fo+k-*%fF5lweBoc6VX;-`;;_Kaj^+;1OBOz`!jG!i)^F=12eq zOFUg1Ln02py<*69KtaGI&|mn-@4v;KM~YdSqh_l~ywTahdHCDsSx=?U+%slk`NLh{ zqSe}Pm(e2cR(0mQ8SF{(^G(iub&ze?Bd4*u(SV`OHo>#@-=iBJmra}ObL{+iZPBcW rQA@;Dx-wl++UlVjq{YJV;~itF^yUaYL$~)p`x!i4{an^LB{Ts5+|g0{ literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..44012b87dd8e742f69e3a872cc85e62c292f704a GIT binary patch literal 316 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY0wn)GsXhaw6p}rHd>I(3)EF2VS{N990fib~ zFff!FFfhDIU|_JC!N4G1FlSew4N!t9$=lt9;eUJonf*W>XMsm#F#`j)FbFd;%$g$s z6x`zJ;uw-~@9i~ju4V@j){FC8zYClca@`pAGF@TP(hg%|j+OQ!h-x}FDo@OGq Reply Reply all Forward + Save Compose Subject Compose email