add reply button to message header

This commit is contained in:
Vincent Breitmoser 2018-11-23 17:08:27 +01:00 committed by cketti
parent ecd3238dd1
commit a592b0dfba
6 changed files with 80 additions and 2 deletions

View file

@ -9,6 +9,7 @@ import android.graphics.drawable.Drawable;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import android.support.v7.widget.PopupMenu.OnMenuItemClickListener;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
@ -219,6 +220,10 @@ public class MessageTopView extends LinearLayout {
mHeaderContainer.setOnFlagListener(listener);
}
public void setOnMenuItemClickListener(OnMenuItemClickListener listener) {
mHeaderContainer.setOnMenuItemClickListener(listener);
}
public void showAllHeaders() {
mHeaderContainer.onShowAdditionalHeaders();
}

View file

@ -18,10 +18,12 @@ import android.os.SystemClock;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v7.widget.PopupMenu.OnMenuItemClickListener;
import android.text.TextUtils;
import android.view.ContextThemeWrapper;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
@ -179,6 +181,30 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
}
});
mMessageView.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
int id = item.getItemId();
if (id == R.id.reply) {
onReply();
return true;
} else if (id == R.id.reply_all) {
onReplyAll();
return true;
} else if (id == R.id.forward) {
onForward();
return true;
} else if (id == R.id.forward_as_attachment) {
onForwardAsAttachment();
return true;
} else if (id == R.id.share) {
onSendAlternate();
return true;
}
return false;
}
});
mMessageView.setOnDownloadButtonClickListener(new OnClickListener() {
@Override
public void onClick(View v) {

View file

@ -12,6 +12,8 @@ import android.graphics.Typeface;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import android.support.v7.widget.PopupMenu;
import android.support.v7.widget.PopupMenu.OnMenuItemClickListener;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
@ -19,6 +21,7 @@ import android.text.format.DateUtils;
import android.text.style.StyleSpan;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
@ -32,7 +35,6 @@ import com.fsck.k9.FontSizes;
import com.fsck.k9.K9;
import com.fsck.k9.activity.misc.ContactPicture;
import com.fsck.k9.contacts.ContactPictureLoader;
import com.fsck.k9.ui.R;
import com.fsck.k9.helper.ClipboardManager;
import com.fsck.k9.helper.Contacts;
import com.fsck.k9.helper.MessageHelper;
@ -41,6 +43,7 @@ import com.fsck.k9.mail.Flag;
import com.fsck.k9.mail.Message;
import com.fsck.k9.mail.internet.MimeUtility;
import com.fsck.k9.ui.ContactBadge;
import com.fsck.k9.ui.R;
import com.fsck.k9.ui.messageview.OnCryptoClickListener;
import timber.log.Timber;
@ -63,6 +66,7 @@ public class MessageHeader extends LinearLayout implements OnClickListener, OnLo
private CheckBox mFlagged;
private int defaultSubjectColor;
private TextView mAdditionalHeadersView;
private View singleMessageOptionIcon;
private View mAnsweredIcon;
private View mForwardedIcon;
private Message mMessage;
@ -77,6 +81,7 @@ public class MessageHeader extends LinearLayout implements OnClickListener, OnLo
private OnLayoutChangedListener mOnLayoutChangedListener;
private OnCryptoClickListener onCryptoClickListener;
private OnMenuItemClickListener onMenuItemClickListener;
/**
* Pair class is only available since API Level 5, so we need
@ -115,6 +120,8 @@ public class MessageHeader extends LinearLayout implements OnClickListener, OnLo
mContactBadge = findViewById(R.id.contact_badge);
singleMessageOptionIcon = findViewById(R.id.icon_single_message_options);
mSubjectView = findViewById(R.id.subject);
mAdditionalHeadersView = findViewById(R.id.additional_headers_view);
mChip = findViewById(R.id.chip);
@ -134,6 +141,8 @@ public class MessageHeader extends LinearLayout implements OnClickListener, OnLo
mFontSizes.setViewTextSize(mBccView, mFontSizes.getMessageViewBCC());
mFontSizes.setViewTextSize(mBccLabel, mFontSizes.getMessageViewBCC());
singleMessageOptionIcon.setOnClickListener(this);
mFromView.setOnClickListener(this);
mToView.setOnClickListener(this);
mCcView.setOnClickListener(this);
@ -162,6 +171,11 @@ public class MessageHeader extends LinearLayout implements OnClickListener, OnLo
layoutChanged();
} else if (id == R.id.crypto_status_icon) {
onCryptoClickListener.onCryptoClick();
} else if (id == R.id.icon_single_message_options) {
PopupMenu popupMenu = new PopupMenu(getContext(), view);
popupMenu.setOnMenuItemClickListener(onMenuItemClickListener);
popupMenu.inflate(R.menu.single_message_options);
popupMenu.show();
}
}
@ -534,4 +548,8 @@ public class MessageHeader extends LinearLayout implements OnClickListener, OnLo
public void setOnCryptoClickListener(OnCryptoClickListener onCryptoClickListener) {
this.onCryptoClickListener = onCryptoClickListener;
}
public void setOnMenuItemClickListener(OnMenuItemClickListener onMenuItemClickListener) {
this.onMenuItemClickListener = onMenuItemClickListener;
}
}

View file

@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/crypto_status_icon"
android:layout_width="36dp"
android:layout_height="32dp"
android:layout_height="36dp"
android:visibility="gone"
custom:previewInitialChild="0"
android:background="?selectableItemBackground"

View file

@ -230,6 +230,7 @@
android:id="@+id/status_icon_strip"
>
<!--
<CheckBox
android:id="@+id/flagged"
android:layout_width="wrap_content"
@ -237,6 +238,16 @@
android:focusable="false"
style="?android:attr/starStyle"
android:checked="false" />
-->
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/icon_single_message_options"
android:src="?iconActionSingleMessageOptions"
android:padding="8dp"
android:background="?selectableItemBackground"
/>
<include layout="@layout/message_crypto_status_view" />

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/reply"
android:title="@string/reply_action"/>
<item
android:id="@+id/reply_all"
android:title="@string/reply_all_action"/>
<item
android:id="@+id/forward"
android:title="@string/forward_action"/>
<item
android:id="@+id/forward_as_attachment"
android:title="@string/forward_as_attachment_action"/>
<item
android:id="@+id/share"
android:title="@string/send_alternate_action"/>
</menu>