add modifier keys in terminal app

Except ctrl key, it just generates a matched keycode to the view
ctrl key, it enables javascript variable `ctrl`, and handler inside
xtermjs reads ctrl variable and the keycode, and if it is convertible
to ctrl keycode, it does.

Test: test added keys
Bug: 376813452
Change-Id: I22e5f80ca75ffe6426b7374855cdd015ad08f324
diff --git a/android/TerminalApp/res/layout/activity_headless.xml b/android/TerminalApp/res/layout/activity_headless.xml
index 3b01179..0bcfbea 100644
--- a/android/TerminalApp/res/layout/activity_headless.xml
+++ b/android/TerminalApp/res/layout/activity_headless.xml
@@ -47,13 +47,20 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"/>
         </LinearLayout>
-        <com.android.virtualization.terminal.TerminalView
-            android:id="@+id/webview"
-            android:layout_marginBottom="5dp"
-            android:layout_gravity="fill"
+        <LinearLayout
+            android:id="@+id/webview_container"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
-            android:visibility="invisible"/>
+            android:layout_marginBottom="5dp"
+            android:orientation="vertical"
+            android:visibility="gone" >
+            <com.android.virtualization.terminal.TerminalView
+                android:id="@+id/webview"
+                android:layout_width="match_parent"
+                android:layout_height="0dp"
+                android:layout_weight="1" />
+            <include layout="@layout/layout_keyboard" />
+        </LinearLayout>
     </FrameLayout>
 
 </LinearLayout>
diff --git a/android/TerminalApp/res/layout/layout_keyboard.xml b/android/TerminalApp/res/layout/layout_keyboard.xml
new file mode 100644
index 0000000..d8b7e11
--- /dev/null
+++ b/android/TerminalApp/res/layout/layout_keyboard.xml
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ -->
+<!--TODO(b/376813452): we might want tablet UI for that-->
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/keyboard_container"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="vertical" >
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:orientation="horizontal">
+        <Button
+            style="@style/ModifierKeyStyle"
+            android:id="@+id/btn_esc"
+            android:text="@string/btn_esc_text" />
+        <Button
+            style="@style/ModifierKeyStyle"
+            android:id="@+id/btn_tab"
+            android:text="@string/btn_tab_text" />
+        <Button
+            style="@style/ModifierKeyStyle"
+            android:id="@+id/btn_home"
+            android:text="@string/btn_home_text" />
+        <Button
+            style="@style/ModifierKeyStyle"
+            android:id="@+id/btn_up"
+            android:text="@string/btn_up_text" />
+        <Button
+            style="@style/ModifierKeyStyle"
+            android:id="@+id/btn_end"
+            android:text="@string/btn_end_text" />
+        <Button
+            style="@style/ModifierKeyStyle"
+            android:id="@+id/btn_pgup"
+            android:text="@string/btn_pgup_text" />
+    </LinearLayout>
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:orientation="horizontal">
+        <Button
+            style="@style/ModifierKeyStyle"
+            android:id="@+id/btn_ctrl"
+            android:text="@string/btn_ctrl_text" />
+        <Button
+            style="@style/ModifierKeyStyle"
+            android:id="@+id/btn_alt"
+            android:text="@string/btn_alt_text" />
+        <Button
+            style="@style/ModifierKeyStyle"
+            android:id="@+id/btn_left"
+            android:text="@string/btn_left_text" />
+        <Button
+            style="@style/ModifierKeyStyle"
+            android:id="@+id/btn_down"
+            android:text="@string/btn_down_text" />
+        <Button
+            style="@style/ModifierKeyStyle"
+            android:id="@+id/btn_right"
+            android:text="@string/btn_right_text" />
+        <Button
+            style="@style/ModifierKeyStyle"
+            android:id="@+id/btn_pgdn"
+            android:text="@string/btn_pgdn_text" />
+    </LinearLayout>
+</LinearLayout>
\ No newline at end of file
diff --git a/android/TerminalApp/res/values/keyboard_btn_strings.xml b/android/TerminalApp/res/values/keyboard_btn_strings.xml
new file mode 100644
index 0000000..384c583
--- /dev/null
+++ b/android/TerminalApp/res/values/keyboard_btn_strings.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--  Copyright (C) 2024 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <string name="btn_esc_text" translatable="false">Esc</string>
+    <string name="btn_tab_text" translatable="false">Tab</string>
+    <string name="btn_home_text" translatable="false">Home</string>
+    <string name="btn_up_text" translatable="false">↑</string>
+    <string name="btn_end_text" translatable="false">End</string>
+    <string name="btn_pgup_text" translatable="false">PgUp</string>
+    <string name="btn_ctrl_text" translatable="false">Ctrl</string>
+    <string name="btn_alt_text" translatable="false">Alt</string>
+    <string name="btn_left_text" translatable="false">←</string>
+    <string name="btn_down_text" translatable="false">↓</string>
+    <string name="btn_right_text" translatable="false">→</string>
+    <string name="btn_pgdn_text" translatable="false">PgDn</string>
+</resources>
diff --git a/android/TerminalApp/res/values/styles.xml b/android/TerminalApp/res/values/styles.xml
new file mode 100644
index 0000000..ee80862
--- /dev/null
+++ b/android/TerminalApp/res/values/styles.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+     Copyright (C) 2024 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<resources>
+    <style name="ModifierKeyStyle" parent="@style/Widget.Material3.Button.TextButton">
+        <item name="android:textAppearance">?android:attr/textAppearanceSmall</item>
+        <item name="android:textColor">?android:attr/textColorPrimary</item>
+        <item name="android:layout_weight">1</item>
+        <item name="android:layout_width">0dp</item>
+        <item name="android:layout_height">wrap_content</item>
+        <item name="android:paddingHorizontal">0dp</item>
+        <item name="android:hapticFeedbackEnabled">true</item>
+    </style>
+</resources>
\ No newline at end of file