From fb4cee428afeac75df5c5b44103c0c43aacd70b8 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Wed, 2 Mar 2016 18:20:57 +0100 Subject: [PATCH] compose: focus to/cc/bcc field on label click --- .../k9/activity/compose/RecipientMvpView.java | 27 +++++++++++++++++++ .../activity/compose/RecipientPresenter.java | 12 +++++++++ .../res/layout/message_compose_recipients.xml | 10 +++++++ 3 files changed, 49 insertions(+) diff --git a/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientMvpView.java b/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientMvpView.java index a609c4ef3..d3cbb5343 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientMvpView.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientMvpView.java @@ -72,6 +72,13 @@ public class RecipientMvpView implements OnFocusChangeListener, OnClickListener View recipientExpander = activity.findViewById(R.id.recipient_expander); recipientExpander.setOnClickListener(this); + + View toLabel = activity.findViewById(R.id.to_label); + View ccLabel = activity.findViewById(R.id.cc_label); + View bccLabel = activity.findViewById(R.id.bcc_label); + toLabel.setOnClickListener(this); + ccLabel.setOnClickListener(this); + bccLabel.setOnClickListener(this); } public void setPresenter(final RecipientPresenter presenter) { @@ -152,6 +159,14 @@ public class RecipientMvpView implements OnFocusChangeListener, OnClickListener toView.requestFocus(); } + public void requestFocusOnCcField() { + ccView.requestFocus(); + } + + public void requestFocusOnBccField() { + bccView.requestFocus(); + } + public void setFontSizes(FontSizes fontSizes, int fontSize) { fontSizes.setViewTextSize(toView, fontSize); fontSizes.setViewTextSize(ccView, fontSize); @@ -346,6 +361,18 @@ public class RecipientMvpView implements OnFocusChangeListener, OnClickListener @Override public void onClick(View view) { switch (view.getId()) { + case R.id.to_label: { + presenter.onClickToLabel(); + break; + } + case R.id.cc_label: { + presenter.onClickCcLabel(); + break; + } + case R.id.bcc_label: { + presenter.onClickBccLabel(); + break; + } case R.id.recipient_expander: { presenter.onClickRecipientExpander(); break; diff --git a/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.java b/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.java index 4e5561117..53ffc6978 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.java @@ -282,6 +282,18 @@ public class RecipientPresenter implements PermissionPingCallback { return result.toArray(new Address[result.size()]); } + public void onClickToLabel() { + recipientMvpView.requestFocusOnToField(); + } + + public void onClickCcLabel() { + recipientMvpView.requestFocusOnCcField(); + } + + public void onClickBccLabel() { + recipientMvpView.requestFocusOnBccField(); + } + public void onClickRecipientExpander() { recipientMvpView.setCcVisibility(true); recipientMvpView.setBccVisibility(true); diff --git a/k9mail/src/main/res/layout/message_compose_recipients.xml b/k9mail/src/main/res/layout/message_compose_recipients.xml index b5bc051ea..fbf691d53 100644 --- a/k9mail/src/main/res/layout/message_compose_recipients.xml +++ b/k9mail/src/main/res/layout/message_compose_recipients.xml @@ -22,6 +22,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" + android:paddingTop="8dp" + android:paddingBottom="8dp" android:id="@+id/from_label" android:minWidth="50dp" android:text="@string/recipient_from" @@ -211,6 +213,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" + android:paddingTop="8dp" + android:paddingBottom="8dp" android:id="@+id/to_label" android:labelFor="@+id/to" android:minWidth="50dp" @@ -285,7 +289,10 @@ @@ -327,7 +334,10 @@