Improve the UI layout of the input screen

TextInputLayout should be introduced to have a modern user interface
design. The helper text and the maximum length of the response are moved
under the edit box.

Bug: 128890104
Test: Confirmed the expected behavior in manual test cases.

Change-Id: If281bd7c914469270b60d8b49d43cf46b2d77742
diff --git a/src/com/android/stk/StkInputActivity.java b/src/com/android/stk/StkInputActivity.java
index 356bcfc..da80f9a 100644
--- a/src/com/android/stk/StkInputActivity.java
+++ b/src/com/android/stk/StkInputActivity.java
@@ -42,13 +42,18 @@
 import android.widget.TextView;
 import android.widget.TextView.BufferType;
 
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.widget.Toolbar;
+
 import com.android.internal.telephony.cat.CatLog;
 import com.android.internal.telephony.cat.Input;
 
+import com.google.android.material.textfield.TextInputLayout;
+
 /**
  * Display a request for a text input a long with a text edit form.
  */
-public class StkInputActivity extends Activity implements View.OnClickListener,
+public class StkInputActivity extends AppCompatActivity implements View.OnClickListener,
         TextWatcher {
 
     // Members
@@ -158,18 +163,13 @@
             return;
         }
 
-        ActionBar actionBar = null;
-        if (getResources().getBoolean(R.bool.show_menu_title_only_on_menu)) {
-            actionBar = getActionBar();
-            if (actionBar != null) {
-                actionBar.hide();
-            }
-        }
-
         // Set the layout for this activity.
         setContentView(R.layout.stk_input);
+        setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
 
-        if (actionBar != null) {
+        if (getResources().getBoolean(R.bool.show_menu_title_only_on_menu)) {
+            getSupportActionBar().hide();
+
             mMoreOptions = findViewById(R.id.more);
             mMoreOptions.setVisibility(View.VISIBLE);
             mMoreOptions.setOnClickListener(this);
@@ -476,8 +476,7 @@
     }
 
     private void configInputDisplay() {
-        TextView numOfCharsView = (TextView) findViewById(R.id.num_of_chars);
-        TextView inTypeView = (TextView) findViewById(R.id.input_type);
+        TextInputLayout textInput = (TextInputLayout) findViewById(R.id.text_input_layout);
 
         int inTypeId = R.string.alphabet;
 
@@ -493,7 +492,8 @@
             mTextIn.setKeyListener(StkDigitsKeyListener.getInstance());
             inTypeId = R.string.digits;
         }
-        inTypeView.setText(inTypeId);
+        textInput.setHelperText(getResources().getString(inTypeId));
+        textInput.setHelperTextEnabled(true);
 
         setTitle(R.string.app_name);
 
@@ -506,17 +506,10 @@
         // Handle specific global and text attributes.
         switch (mState) {
         case STATE_TEXT:
-            int maxLen = mStkInput.maxLen;
-            int minLen = mStkInput.minLen;
-            mTextIn.setFilters(new InputFilter[] {new InputFilter.LengthFilter(
-                    maxLen)});
+            mTextIn.setFilters(new InputFilter[] {new InputFilter.LengthFilter(mStkInput.maxLen)});
 
-            // Set number of chars info.
-            String lengthLimit = String.valueOf(minLen);
-            if (maxLen != minLen) {
-                lengthLimit = minLen + " - " + maxLen;
-            }
-            numOfCharsView.setText(lengthLimit);
+            textInput.setCounterMaxLength(mStkInput.maxLen);
+            textInput.setCounterEnabled(true);
 
             if (!mStkInput.echo) {
                 mTextIn.setTransformationMethod(PasswordTransformationMethod