|
7 | 7 | import android.support.design.widget.Snackbar; |
8 | 8 | import android.support.v4.app.DialogFragment; |
9 | 9 | import android.util.Log; |
| 10 | +import android.view.KeyEvent; |
10 | 11 | import android.view.LayoutInflater; |
11 | 12 | import android.view.View; |
12 | 13 | import android.view.ViewGroup; |
| 14 | +import android.view.inputmethod.EditorInfo; |
13 | 15 | import android.widget.Button; |
14 | 16 | import android.widget.EditText; |
15 | 17 | import android.widget.ProgressBar; |
| 18 | +import android.widget.TextView; |
16 | 19 |
|
17 | 20 | import java.io.IOException; |
18 | 21 |
|
@@ -46,15 +49,26 @@ public void onClick(View v) { |
46 | 49 | espIPAddress = espIPEditText.getText().toString(); |
47 | 50 | if (espIPAddress.length() == 0) { |
48 | 51 | CustomSnackBar.showSnackBar(getActivity().findViewById(android.R.id.content), |
49 | | - getString(R.string.incorrect_IP_address_message),null,null, Snackbar.LENGTH_SHORT); |
| 52 | + getString(R.string.incorrect_IP_address_message),null,null, null, Snackbar.LENGTH_SHORT); |
| 53 | + |
50 | 54 | } else { |
51 | 55 | new ESPTask().execute(); |
52 | 56 | } |
53 | 57 | } |
| 58 | + |
| 59 | + }); |
| 60 | + espIPEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { |
| 61 | + @Override |
| 62 | + public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { |
| 63 | + if (actionId == EditorInfo.IME_ACTION_DONE) { |
| 64 | + espConnectBtn.performClick(); |
| 65 | + return true; |
| 66 | + } |
| 67 | + return false; |
| 68 | + } |
54 | 69 | }); |
55 | 70 | return rootView; |
56 | 71 | } |
57 | | - |
58 | 72 | @Override |
59 | 73 | public void onResume() { |
60 | 74 | super.onResume(); |
@@ -98,7 +112,7 @@ protected void onPostExecute(String result) { |
98 | 112 | espConnectBtn.setVisibility(View.VISIBLE); |
99 | 113 | if (result.length() == 0) { |
100 | 114 | CustomSnackBar.showSnackBar(getActivity().findViewById(android.R.id.content), |
101 | | - getString(R.string.incorrect_IP_address_message),null,null,Snackbar.LENGTH_SHORT); |
| 115 | + getString(R.string.incorrect_IP_address_message),null,null, null, Snackbar.LENGTH_SHORT); |
102 | 116 | } else { |
103 | 117 | Log.v("Response", result); |
104 | 118 | } |
|
0 commit comments