Make enabled but inactive ports visible in port forwarding setting
Bug: 382998391
Test: Run VmTerminalApp
Change-Id: Iab4e0753487c6d15833e0eb186ee00adbc4be3d9
diff --git a/android/TerminalApp/res/drawable/ic_close.xml b/android/TerminalApp/res/drawable/ic_close.xml
new file mode 100644
index 0000000..e21c19c
--- /dev/null
+++ b/android/TerminalApp/res/drawable/ic_close.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright 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.
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="960"
+ android:viewportHeight="960"
+ android:tint="?attr/colorControlNormal">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M256,760L200,704L424,480L200,256L256,200L480,424L704,200L760,256L536,480L760,704L704,760L480,536L256,760Z"/>
+</vector>
diff --git a/android/TerminalApp/res/layout/settings_port_forwarding.xml b/android/TerminalApp/res/layout/settings_port_forwarding.xml
index 2d21962..77b9bf7 100644
--- a/android/TerminalApp/res/layout/settings_port_forwarding.xml
+++ b/android/TerminalApp/res/layout/settings_port_forwarding.xml
@@ -31,9 +31,33 @@
android:hyphenationFrequency="full"
android:layout_marginBottom="24dp"/>
+ <TextView
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:text="@string/settings_port_forwarding_active_ports_title"
+ android:textSize="24sp"
+ android:hyphenationFrequency="full"
+ android:layout_marginBottom="24dp"/>
+
<androidx.recyclerview.widget.RecyclerView
- android:id="@+id/settings_port_forwarding_recycler_view"
+ android:id="@+id/settings_port_forwarding_active_recycler_view"
android:layout_marginHorizontal="16dp"
+ android:layout_marginBottom="24dp"
android:layout_width="match_parent"
- android:layout_height="match_parent" />
+ android:layout_height="wrap_content" />
+
+ <TextView
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:text="@string/settings_port_forwarding_other_enabled_ports_title"
+ android:textSize="24sp"
+ android:hyphenationFrequency="full"
+ android:layout_marginBottom="24dp"/>
+
+ <androidx.recyclerview.widget.RecyclerView
+ android:id="@+id/settings_port_forwarding_inactive_recycler_view"
+ android:layout_marginHorizontal="16dp"
+ android:layout_marginBottom="24dp"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
</LinearLayout>
diff --git a/android/TerminalApp/res/layout/settings_port_forwarding_item.xml b/android/TerminalApp/res/layout/settings_port_forwarding_active_item.xml
similarity index 81%
rename from android/TerminalApp/res/layout/settings_port_forwarding_item.xml
rename to android/TerminalApp/res/layout/settings_port_forwarding_active_item.xml
index 8a57b41..2a74146 100644
--- a/android/TerminalApp/res/layout/settings_port_forwarding_item.xml
+++ b/android/TerminalApp/res/layout/settings_port_forwarding_active_item.xml
@@ -19,21 +19,26 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:minHeight="48dp"
app:layout_constraintCircleRadius="@dimen/material_emphasis_medium">
<TextView
- android:id="@+id/settings_port_forwarding_item_port"
+ android:id="@+id/settings_port_forwarding_active_item_port"
android:layout_height="wrap_content"
android:layout_width="match_parent"
+ android:textSize="16sp"
+ android:layout_marginTop="8dp"
+ android:layout_marginBottom="8dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"/>
<com.google.android.material.materialswitch.MaterialSwitch
- android:id="@+id/settings_port_forwarding_item_enabled_switch"
+ android:id="@+id/settings_port_forwarding_active_item_enabled_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
-</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
+</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/android/TerminalApp/res/layout/settings_port_forwarding_item.xml b/android/TerminalApp/res/layout/settings_port_forwarding_inactive_item.xml
similarity index 74%
copy from android/TerminalApp/res/layout/settings_port_forwarding_item.xml
copy to android/TerminalApp/res/layout/settings_port_forwarding_inactive_item.xml
index 8a57b41..127b152 100644
--- a/android/TerminalApp/res/layout/settings_port_forwarding_item.xml
+++ b/android/TerminalApp/res/layout/settings_port_forwarding_inactive_item.xml
@@ -19,21 +19,28 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:minHeight="48dp"
app:layout_constraintCircleRadius="@dimen/material_emphasis_medium">
<TextView
- android:id="@+id/settings_port_forwarding_item_port"
+ android:id="@+id/settings_port_forwarding_inactive_item_port"
android:layout_height="wrap_content"
android:layout_width="match_parent"
+ android:textSize="16sp"
+ android:layout_marginTop="8dp"
+ android:layout_marginBottom="8dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"/>
- <com.google.android.material.materialswitch.MaterialSwitch
- android:id="@+id/settings_port_forwarding_item_enabled_switch"
+ <ImageButton
+ android:id="@+id/settings_port_forwarding_active_item_close_button"
+ android:src="@drawable/ic_close"
+ android:background="@android:color/transparent"
+ android:contentDescription="@null"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
-
-</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
+</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/android/TerminalApp/res/values/strings.xml b/android/TerminalApp/res/values/strings.xml
index 20fd95d..493496c 100644
--- a/android/TerminalApp/res/values/strings.xml
+++ b/android/TerminalApp/res/values/strings.xml
@@ -89,6 +89,8 @@
<string name="settings_port_forwarding_active_ports_title">Listening ports</string>
<!-- Title for other enabled ports setting in port forwarding [CHAR LIMIT=none] -->
<string name="settings_port_forwarding_other_enabled_ports_title">Saved allowed ports</string>
+ <!-- Description of close button for other enabled ports. Used for talkback. [CHAR LIMIT=none] -->
+ <string name="settings_port_forwarding_other_enabled_port_close_button">Delete <xliff:g id="port_number" example="8000">%d</xliff:g></string>
<!-- Dialog title for enabling a new port [CHAR LIMIT=none] -->
<string name="settings_port_forwarding_dialog_title">Allow a new port</string>