messageview: display unsigned attachments in LockedAttachmentView
This commit is contained in:
parent
d98f579b34
commit
61232cb631
7 changed files with 213 additions and 18 deletions
|
@ -53,7 +53,7 @@ public class AttachmentView extends FrameLayout implements OnClickListener, OnLo
|
|||
downloadButton.setEnabled(false);
|
||||
}
|
||||
|
||||
public void setAttachment(AttachmentViewInfo attachment) throws MessagingException {
|
||||
public void setAttachment(AttachmentViewInfo attachment) {
|
||||
this.attachment = attachment;
|
||||
|
||||
displayAttachmentInformation();
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
package com.fsck.k9.ui.messageview;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewStub;
|
||||
|
||||
import com.fsck.k9.R;
|
||||
import com.fsck.k9.mailstore.AttachmentViewInfo;
|
||||
import com.fsck.k9.view.ToolableViewAnimator;
|
||||
|
||||
|
||||
public class LockedAttachmentView extends ToolableViewAnimator implements OnClickListener {
|
||||
private ViewStub attachmentViewStub;
|
||||
private AttachmentViewInfo attachment;
|
||||
private AttachmentViewCallback attachmentCallback;
|
||||
|
||||
|
||||
public LockedAttachmentView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
public LockedAttachmentView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public LockedAttachmentView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
if (isInEditMode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
View unlockButton = findViewById(R.id.locked_button);
|
||||
unlockButton.setOnClickListener(this);
|
||||
|
||||
attachmentViewStub = (ViewStub) findViewById(R.id.attachment_stub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.locked_button: {
|
||||
showUnlockedView();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void showUnlockedView() {
|
||||
if (attachmentViewStub == null) {
|
||||
throw new IllegalStateException("Cannot display unlocked attachment!");
|
||||
}
|
||||
|
||||
AttachmentView attachmentView = (AttachmentView) attachmentViewStub.inflate();
|
||||
attachmentView.setAttachment(attachment);
|
||||
attachmentView.setCallback(attachmentCallback);
|
||||
attachmentViewStub = null;
|
||||
|
||||
setDisplayedChild(1);
|
||||
}
|
||||
|
||||
public void setAttachment(AttachmentViewInfo attachment) {
|
||||
this.attachment = attachment;
|
||||
}
|
||||
|
||||
public void setCallback(AttachmentViewCallback attachmentCallback) {
|
||||
this.attachmentCallback = attachmentCallback;
|
||||
}
|
||||
}
|
|
@ -69,7 +69,7 @@ public class MessageContainerView extends LinearLayout implements OnClickListene
|
|||
private View mAttachmentsContainer;
|
||||
private SavedState mSavedState;
|
||||
private ClipboardManager mClipboardManager;
|
||||
private Map<AttachmentViewInfo, AttachmentView> attachments = new HashMap<AttachmentViewInfo, AttachmentView>();
|
||||
private Map<AttachmentViewInfo, AttachmentView> attachments = new HashMap<>();
|
||||
|
||||
private String currentHtmlText;
|
||||
private AttachmentResolver currentAttachmentResolver;
|
||||
|
@ -80,7 +80,9 @@ public class MessageContainerView extends LinearLayout implements OnClickListene
|
|||
super.onFinishInflate();
|
||||
|
||||
mMessageContentView = (MessageWebView) findViewById(R.id.message_content);
|
||||
mMessageContentView.configure();
|
||||
if (!isInEditMode()) {
|
||||
mMessageContentView.configure();
|
||||
}
|
||||
mMessageContentView.setOnCreateContextMenuListener(this);
|
||||
mMessageContentView.setVisibility(View.VISIBLE);
|
||||
|
||||
|
@ -398,10 +400,7 @@ public class MessageContainerView extends LinearLayout implements OnClickListene
|
|||
|
||||
resetView();
|
||||
|
||||
boolean hasAttachments = !messageViewInfo.attachments.isEmpty();
|
||||
if (hasAttachments) {
|
||||
renderAttachments(messageViewInfo);
|
||||
}
|
||||
renderAttachments(messageViewInfo);
|
||||
|
||||
mHiddenAttachments.setVisibility(View.GONE);
|
||||
|
||||
|
@ -456,14 +455,30 @@ public class MessageContainerView extends LinearLayout implements OnClickListene
|
|||
}
|
||||
|
||||
public void renderAttachments(MessageViewInfo messageViewInfo) throws MessagingException {
|
||||
for (AttachmentViewInfo attachment : messageViewInfo.attachments) {
|
||||
ViewGroup parent = attachment.firstClassAttachment ? mAttachments : mHiddenAttachments;
|
||||
AttachmentView view = (AttachmentView) mInflater.inflate(R.layout.message_view_attachment, parent, false);
|
||||
view.setCallback(attachmentCallback);
|
||||
view.setAttachment(attachment);
|
||||
if (messageViewInfo.attachments != null) {
|
||||
for (AttachmentViewInfo attachment : messageViewInfo.attachments) {
|
||||
ViewGroup parent = attachment.firstClassAttachment ? mAttachments : mHiddenAttachments;
|
||||
AttachmentView view =
|
||||
(AttachmentView) mInflater.inflate(R.layout.message_view_attachment, parent, false);
|
||||
view.setCallback(attachmentCallback);
|
||||
view.setAttachment(attachment);
|
||||
|
||||
attachments.put(attachment, view);
|
||||
parent.addView(view);
|
||||
attachments.put(attachment, view);
|
||||
parent.addView(view);
|
||||
}
|
||||
}
|
||||
|
||||
if (messageViewInfo.extraAttachments != null) {
|
||||
for (AttachmentViewInfo attachment : messageViewInfo.extraAttachments) {
|
||||
ViewGroup parent = attachment.firstClassAttachment ? mAttachments : mHiddenAttachments;
|
||||
LockedAttachmentView view = (LockedAttachmentView) mInflater
|
||||
.inflate(R.layout.message_view_attachment_locked, parent, false);
|
||||
view.setCallback(attachmentCallback);
|
||||
view.setAttachment(attachment);
|
||||
|
||||
// attachments.put(attachment, view);
|
||||
parent.addView(view);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,19 +14,19 @@
|
|||
<LinearLayout
|
||||
android:id="@+id/attachments_container"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/attachments"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="4dip" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/show_hidden_attachments"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/message_view_show_more_attachments_action" />
|
||||
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="4dip">
|
||||
android:paddingBottom="4dip"
|
||||
android:id="@+id/attachment">
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.fsck.k9.ui.messageview.LockedAttachmentView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:custom="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="4dip"
|
||||
android:inAnimation="@anim/fade_in"
|
||||
android:outAnimation="@anim/fade_out"
|
||||
custom:previewInitialChild="0"
|
||||
tools:layout_height="80dp"
|
||||
>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:background="?attr/messageViewAttachmentBackground"
|
||||
>
|
||||
</FrameLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/lock_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:src="@drawable/status_signature_unverified_cutout"
|
||||
android:tint="@color/openpgp_red"
|
||||
android:layout_marginTop="8dip"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:padding="14dp"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/locked_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_toRightOf="@id/lock_icon"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignWithParentIfMissing="true"
|
||||
android:layout_marginTop="8dp"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="middle"
|
||||
android:text="@string/locked_attach_title"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/locked_button"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:layout_marginRight="4dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:paddingLeft="20dip"
|
||||
android:paddingRight="20dip"
|
||||
android:singleLine="true"
|
||||
android:text="@string/locked_attach_unlock"
|
||||
style="?android:attr/buttonStyleSmall"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/locked_info"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="?android:attr/textColorTertiary"
|
||||
android:layout_alignLeft="@id/locked_name"
|
||||
android:layout_toLeftOf="@id/locked_button"
|
||||
android:layout_below="@id/locked_name"
|
||||
android:layout_alignWithParentIfMissing="true"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:text="@string/locked_attach_unencrypted" />
|
||||
|
||||
<ImageView
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:src="@drawable/ic_email_attachment" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<ViewStub
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/attachment_stub"
|
||||
android:layout="@layout/message_view_attachment"
|
||||
android:inflatedId="@+id/attachment"
|
||||
/>
|
||||
|
||||
</com.fsck.k9.ui.messageview.LockedAttachmentView>
|
|
@ -1184,5 +1184,9 @@ Please submit bug reports, contribute new features and ask questions at
|
|||
<string name="crypto_msg_signed_encrypted">Message is signed and encrypted.</string>
|
||||
<string name="crypto_msg_unsigned_encrypted">There is no signature, this message may have been intercepted.</string>
|
||||
<string name="crypto_info_ok">OK</string>
|
||||
<string name="locked_attach_unlock">Unlock</string>
|
||||
<string name="locked_attach_unsigned">This part was not encrypted, and may be insecure.</string>
|
||||
<string name="locked_attach_unencrypted">This part was not encrypted, and may be insecure.</string>
|
||||
<string name="locked_attach_title">Unprotected Attachment</string>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue