compose: focus to/cc/bcc field on label click

This commit is contained in:
Vincent Breitmoser 2016-03-02 18:20:57 +01:00
parent 38b64ea651
commit fb4cee428a
3 changed files with 49 additions and 0 deletions

View file

@ -72,6 +72,13 @@ public class RecipientMvpView implements OnFocusChangeListener, OnClickListener
View recipientExpander = activity.findViewById(R.id.recipient_expander); View recipientExpander = activity.findViewById(R.id.recipient_expander);
recipientExpander.setOnClickListener(this); 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) { public void setPresenter(final RecipientPresenter presenter) {
@ -152,6 +159,14 @@ public class RecipientMvpView implements OnFocusChangeListener, OnClickListener
toView.requestFocus(); toView.requestFocus();
} }
public void requestFocusOnCcField() {
ccView.requestFocus();
}
public void requestFocusOnBccField() {
bccView.requestFocus();
}
public void setFontSizes(FontSizes fontSizes, int fontSize) { public void setFontSizes(FontSizes fontSizes, int fontSize) {
fontSizes.setViewTextSize(toView, fontSize); fontSizes.setViewTextSize(toView, fontSize);
fontSizes.setViewTextSize(ccView, fontSize); fontSizes.setViewTextSize(ccView, fontSize);
@ -346,6 +361,18 @@ public class RecipientMvpView implements OnFocusChangeListener, OnClickListener
@Override @Override
public void onClick(View view) { public void onClick(View view) {
switch (view.getId()) { 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: { case R.id.recipient_expander: {
presenter.onClickRecipientExpander(); presenter.onClickRecipientExpander();
break; break;

View file

@ -282,6 +282,18 @@ public class RecipientPresenter implements PermissionPingCallback {
return result.toArray(new Address[result.size()]); 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() { public void onClickRecipientExpander() {
recipientMvpView.setCcVisibility(true); recipientMvpView.setCcVisibility(true);
recipientMvpView.setBccVisibility(true); recipientMvpView.setBccVisibility(true);

View file

@ -22,6 +22,8 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:id="@+id/from_label" android:id="@+id/from_label"
android:minWidth="50dp" android:minWidth="50dp"
android:text="@string/recipient_from" android:text="@string/recipient_from"
@ -211,6 +213,8 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:id="@+id/to_label" android:id="@+id/to_label"
android:labelFor="@+id/to" android:labelFor="@+id/to"
android:minWidth="50dp" android:minWidth="50dp"
@ -285,7 +289,10 @@
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:minWidth="50dp" android:minWidth="50dp"
android:id="@+id/cc_label"
android:labelFor="@+id/cc" android:labelFor="@+id/cc"
android:text="@string/recipient_cc" android:text="@string/recipient_cc"
style="@style/ComposeTextLabel" /> style="@style/ComposeTextLabel" />
@ -327,7 +334,10 @@
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:minWidth="50dp" android:minWidth="50dp"
android:id="@+id/bcc_label"
android:labelFor="@+id/bcc" android:labelFor="@+id/bcc"
android:text="@string/recipient_bcc" android:text="@string/recipient_bcc"
style="@style/ComposeTextLabel" /> style="@style/ComposeTextLabel" />