diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2017-08-31 16:17:04 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-08-31 16:17:04 +0000 |
commit | c39ea3c55fac807c0b98aabdf56c70dc8a49036c (patch) | |
tree | e282668a9587cf6c1ec7b604dea860400c75c6c7 /java/com/android/dialer/widget/MessageFragment.java | |
parent | 68038172793ee0e2ab3e2e56ddfbeb82879d1f58 (diff) | |
parent | 2ca4318cc1ee57dda907ba2069bd61d162b1baef (diff) |
Merge "Update Dialer source to latest internal Google revision."
Diffstat (limited to 'java/com/android/dialer/widget/MessageFragment.java')
-rw-r--r-- | java/com/android/dialer/widget/MessageFragment.java | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/java/com/android/dialer/widget/MessageFragment.java b/java/com/android/dialer/widget/MessageFragment.java index b136f47eb..7a0fcfd0f 100644 --- a/java/com/android/dialer/widget/MessageFragment.java +++ b/java/com/android/dialer/widget/MessageFragment.java @@ -23,6 +23,7 @@ import android.text.Editable; import android.text.InputFilter; import android.text.TextUtils; import android.text.TextWatcher; +import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; @@ -31,11 +32,13 @@ import android.widget.EditText; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; +import android.widget.TextView.OnEditorActionListener; import com.android.dialer.common.Assert; import com.android.dialer.common.FragmentUtils; /** Fragment used to compose call with message fragment. */ -public class MessageFragment extends Fragment implements OnClickListener, TextWatcher { +public class MessageFragment extends Fragment + implements OnClickListener, TextWatcher, OnEditorActionListener { private static final String CHAR_LIMIT_KEY = "char_limit"; private static final String SHOW_SEND_ICON_KEY = "show_send_icon"; private static final String MESSAGE_LIST_KEY = "message_list"; @@ -69,7 +72,7 @@ public class MessageFragment extends Fragment implements OnClickListener, TextWa LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_message, container, false); - sendMessage = (ImageView) view.findViewById(R.id.send_message); + sendMessage = view.findViewById(R.id.send_message); sendMessageContainer = view.findViewById(R.id.count_and_send_container); if (getArguments().getBoolean(SHOW_SEND_ICON_KEY, false)) { sendMessage.setVisibility(View.VISIBLE); @@ -77,18 +80,19 @@ public class MessageFragment extends Fragment implements OnClickListener, TextWa sendMessageContainer.setOnClickListener(this); } - customMessage = (EditText) view.findViewById(R.id.custom_message); + customMessage = view.findViewById(R.id.custom_message); customMessage.addTextChangedListener(this); + customMessage.setOnEditorActionListener(this); charLimit = getArguments().getInt(CHAR_LIMIT_KEY, NO_CHAR_LIMIT); if (charLimit != NO_CHAR_LIMIT) { - remainingChar = (TextView) view.findViewById(R.id.remaining_characters); + remainingChar = view.findViewById(R.id.remaining_characters); remainingChar.setVisibility(View.VISIBLE); - remainingChar = (TextView) view.findViewById(R.id.remaining_characters); - remainingChar.setText("" + charLimit); + remainingChar = view.findViewById(R.id.remaining_characters); + remainingChar.setText(Integer.toString(charLimit)); customMessage.setFilters(new InputFilter[] {new InputFilter.LengthFilter(charLimit)}); } - LinearLayout messageContainer = (LinearLayout) view.findViewById(R.id.message_container); + LinearLayout messageContainer = view.findViewById(R.id.message_container); for (String message : getArguments().getStringArray(MESSAGE_LIST_KEY)) { TextView textView = (TextView) inflater.inflate(R.layout.selectable_text_view, null); textView.setOnClickListener(this); @@ -123,11 +127,19 @@ public class MessageFragment extends Fragment implements OnClickListener, TextWa @Override public void afterTextChanged(Editable s) { if (charLimit != NO_CHAR_LIMIT) { - remainingChar.setText("" + (charLimit - s.length())); + remainingChar.setText(Integer.toString(charLimit - s.length())); } getListener().onMessageFragmentAfterTextChange(s.toString()); } + @Override + public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { + if (!TextUtils.isEmpty(getMessage())) { + getListener().onMessageFragmentSendMessage(getMessage()); + } + return true; + } + private Listener getListener() { return FragmentUtils.getParentUnsafe(this, Listener.class); } |