Show attachments and delivery status in email list
This commit is contained in:
@@ -56,4 +56,35 @@
|
||||
android:text="##:## XX"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/email_attachment"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@+id/email_from"
|
||||
android:layout_alignBottom="@+id/email_from"
|
||||
android:layout_alignParentRight="true"
|
||||
android:scaleType="fitEnd"
|
||||
android:visibility="gone"
|
||||
android:src="@drawable/ic_content_attachment" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/email_status"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@+id/email_content"
|
||||
android:layout_alignBottom="@+id/email_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:scaleType="fitEnd"
|
||||
android:visibility="gone"
|
||||
android:src="@drawable/ic_navigation_accept" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/email_status_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@+id/email_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:visibility="gone"
|
||||
android:text="0%" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
@@ -6,9 +6,11 @@ import java.text.DateFormat;
|
||||
import java.util.List;
|
||||
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.Part;
|
||||
|
||||
import i2p.bote.android.util.BoteHelper;
|
||||
import i2p.bote.email.Email;
|
||||
import i2p.bote.email.EmailDestination;
|
||||
import i2p.bote.fileencryption.PasswordException;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
@@ -80,10 +82,32 @@ public class EmailListAdapter extends ArrayAdapter<Email> {
|
||||
sent.setText(DateFormat.getInstance().format(
|
||||
email.getSentDate()));
|
||||
|
||||
List<Part> parts = email.getParts();
|
||||
for (Part part : parts) {
|
||||
if (Part.ATTACHMENT.equalsIgnoreCase(part.getDisposition())) {
|
||||
((ImageView) v.findViewById(
|
||||
R.id.email_attachment)).setVisibility(View.VISIBLE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (email.isNew()) {
|
||||
subject.setTypeface(Typeface.DEFAULT_BOLD);
|
||||
from.setTypeface(Typeface.DEFAULT_BOLD);
|
||||
}
|
||||
|
||||
// Set email status if we sent it
|
||||
String fromDest = EmailDestination.extractBase64Dest(fromAddress);
|
||||
if (fromDest != null && BoteHelper.getIdentity(fromDest) != null) {
|
||||
TextView emailStatus = (TextView) v.findViewById(R.id.email_status_text);
|
||||
if (email.isDelivered())
|
||||
((ImageView) v.findViewById(
|
||||
R.id.email_status)).setVisibility(View.VISIBLE);
|
||||
else if (email.getDeliveryPercentage() > 0)
|
||||
emailStatus.setText(email.getDeliveryPercentage() + "%");
|
||||
else
|
||||
emailStatus.setText(BoteHelper.getEmailStatus(email));
|
||||
}
|
||||
} catch (MessagingException e) {
|
||||
subject.setText("ERROR: " + e.getMessage());
|
||||
} catch (PasswordException e) {
|
||||
|
||||
Reference in New Issue
Block a user