]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
android: Add label to read-only profiles in list
authorMarkus Pfeiffer <markus.pfeiffer@relution.io>
Tue, 21 Nov 2023 14:37:22 +0000 (15:37 +0100)
committerTobias Brunner <tobias@strongswan.org>
Wed, 21 Feb 2024 11:24:53 +0000 (12:24 +0100)
Show "Managed profile" in the list of VPN profiles, to make it
immediately obvious that a profile is managed/read-only.

src/frontends/android/app/src/main/java/org/strongswan/android/ui/adapter/VpnProfileAdapter.java
src/frontends/android/app/src/main/res/layout/profile_list_item.xml
src/frontends/android/app/src/main/res/values-de/strings.xml
src/frontends/android/app/src/main/res/values-pl/strings.xml
src/frontends/android/app/src/main/res/values-ru/strings.xml
src/frontends/android/app/src/main/res/values-uk/strings.xml
src/frontends/android/app/src/main/res/values-zh-rCN/strings.xml
src/frontends/android/app/src/main/res/values-zh-rTW/strings.xml
src/frontends/android/app/src/main/res/values/strings.xml

index 05a15464d90c89d6644f25351db3b18423bbeed2..c2942b8a1858ce6dc423e8e8f0b6896e2cb6e2f9 100644 (file)
@@ -61,11 +61,13 @@ public class VpnProfileAdapter extends ArrayAdapter<VpnProfile>
                        vpnProfileView = inflater.inflate(resource, null);
                }
                VpnProfile profile = getItem(position);
-               TextView tv = (TextView)vpnProfileView.findViewById(R.id.profile_item_name);
+               TextView tv = vpnProfileView.findViewById(R.id.profile_item_name);
                tv.setText(profile.getName());
-               tv = (TextView)vpnProfileView.findViewById(R.id.profile_item_gateway);
+               tv = vpnProfileView.findViewById(R.id.profile_item_managed);
+               tv.setVisibility(profile.isReadOnly() ? View.VISIBLE : View.GONE);
+               tv = vpnProfileView.findViewById(R.id.profile_item_gateway);
                tv.setText(getContext().getString(R.string.profile_gateway_label) + ": " + profile.getGateway());
-               tv = (TextView)vpnProfileView.findViewById(R.id.profile_item_username);
+               tv = vpnProfileView.findViewById(R.id.profile_item_username);
                if (profile.getVpnType().has(VpnTypeFeature.USER_PASS))
                {       /* if the view is reused we make sure it is visible */
                        tv.setVisibility(View.VISIBLE);
@@ -81,7 +83,7 @@ public class VpnProfileAdapter extends ArrayAdapter<VpnProfile>
                {
                        tv.setVisibility(View.GONE);
                }
-               tv = (TextView)vpnProfileView.findViewById(R.id.profile_item_certificate);
+               tv = vpnProfileView.findViewById(R.id.profile_item_certificate);
                if (profile.getVpnType().has(VpnTypeFeature.CERTIFICATE))
                {
                        tv.setText(getContext().getString(R.string.profile_user_certificate_label) + ": " + profile.getUserCertificateAlias());
@@ -103,7 +105,8 @@ public class VpnProfileAdapter extends ArrayAdapter<VpnProfile>
 
        private void sortItems()
        {
-               Collections.sort(this.items, new Comparator<VpnProfile>() {
+               Collections.sort(this.items, new Comparator<VpnProfile>()
+               {
                        @Override
                        public int compare(VpnProfile lhs, VpnProfile rhs)
                        {
index caf5488584cab79955349a6850e83e78e19019fb..d4d9b651e31439a5c09d6222462b175eb63e7c43 100644 (file)
     for more details.
 -->
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
+    android:background="?android:attr/activatedBackgroundIndicator"
     android:orientation="vertical"
     android:paddingBottom="6dip"
-    android:paddingTop="4dip"
-    android:background="?android:attr/activatedBackgroundIndicator" >
+    android:paddingTop="4dip">
 
     <TextView
         android:id="@+id/profile_item_name"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:layout_marginLeft="15dp"
-        android:textAppearance="?android:attr/textAppearanceMedium" />
+        android:layout_marginStart="15dp"
+        android:textAppearance="?android:attr/textAppearanceMedium"
+        tools:text="Profile name" />
+
+    <TextView
+        android:id="@+id/profile_item_managed"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="15dp"
+        android:text="@string/profile_managed"
+        android:textAppearance="?android:attr/textAppearanceSmall"
+        android:textColor="@color/success_text"
+        android:visibility="gone"
+        tools:visibility="visible" />
 
     <TextView
         android:id="@+id/profile_item_gateway"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:textColor="?android:textColorSecondary"
+        android:layout_marginStart="15dp"
         android:textAppearance="?android:attr/textAppearanceSmall"
-        android:layout_marginLeft="15dp" />
+        android:textColor="?android:textColorSecondary"
+        tools:text="Server: vpn.example.com" />
 
     <TextView
         android:id="@+id/profile_item_username"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:textColor="?android:textColorSecondary"
+        android:layout_marginStart="15dp"
         android:textAppearance="?android:attr/textAppearanceSmall"
-        android:layout_marginLeft="15dp" />
+        android:textColor="?android:textColorSecondary"
+        tools:text="Username" />
 
     <TextView
         android:id="@+id/profile_item_certificate"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:textColor="?android:textColorSecondary"
-        android:textAppearance="?android:attr/textAppearanceSmall"
-        android:singleLine="true"
+        android:layout_marginStart="15dp"
         android:ellipsize="end"
-        android:layout_marginLeft="15dp" />
+        android:singleLine="true"
+        android:textAppearance="?android:attr/textAppearanceSmall"
+        android:textColor="?android:textColorSecondary"
+        tools:text="Certificate" />
 
 </LinearLayout>
index 0b21fc747f937dc2c601c1a5324a5a5f20a2bfe2..19d5a1a5419e0aa9f38b1b54dfd3abedb7b0001a 100644 (file)
     <string name="profile_cert_import">Zertifikat aus VPN Profil importieren</string>
     <string name="profile_cert_alias">Zertifikat für \"%1$s\"</string>
     <string name="profile_profile_id">Profil-ID</string>
+    <string name="profile_managed">Verwaltetes Profil</string>
     <!-- Warnings/Notifications in the details view -->
     <string name="alert_text_no_input_gateway">Ein Wert wird benötigt, um die Verbindung aufbauen zu können</string>
     <string name="alert_text_no_input_username">Bitte geben Sie Ihren Benutzernamen ein</string>
index ec6ba216b893b130f397d7923434a6aca6573c01..737eddf868aebe555bbbccdd2b4f088fffc39a4d 100644 (file)
     <string name="profile_cert_import">Import certificate from VPN profile</string>
     <string name="profile_cert_alias">Certificate for \"%1$s\"</string>
     <string name="profile_profile_id">Profile ID</string>
+    <string name="profile_managed">Managed profile</string>
     <!-- Warnings/Notifications in the details view -->
     <string name="alert_text_no_input_gateway">A value is required to initiate the connection</string>
     <string name="alert_text_no_input_username">Wprowadź swoją nazwę użytkownika</string>
index 0150016b73bf0dc21a54810b17044dfdb21dc908..2bbe2b4dc15a2249a75b907fb55fda94cc9cbae3 100644 (file)
     <string name="profile_cert_import">Import certificate from VPN profile</string>
     <string name="profile_cert_alias">Certificate for \"%1$s\"</string>
     <string name="profile_profile_id">Profile ID</string>
+    <string name="profile_managed">Managed profile</string>
     <!-- Warnings/Notifications in the details view -->
     <string name="alert_text_no_input_gateway">A value is required to initiate the connection</string>
     <string name="alert_text_no_input_username">Пожалуйста введите имя пользователя</string>
index e02a640a3ff550a0ad1644877daa8d7ebf429e03..3868fc47564e9d7b0f377addd63c0445d01be19d 100644 (file)
     <string name="profile_cert_import">Import certificate from VPN profile</string>
     <string name="profile_cert_alias">Certificate for \"%1$s\"</string>
     <string name="profile_profile_id">Profile ID</string>
+    <string name="profile_managed">Managed profile</string>
     <!-- Warnings/Notifications in the details view -->
     <string name="alert_text_no_input_gateway">A value is required to initiate the connection</string>
     <string name="alert_text_no_input_username">Введіть ім\'я користувача </string>
index 99693c50920e6e6dfb8535634ba7f23d82e44191..69b9f4d2682929b518462e3bf7cda68709bb4fb7 100644 (file)
     <string name="profile_cert_import">从VPN配置导入证书</string>
     <string name="profile_cert_alias">\"%1$s\" 所对应的证书</string>
     <string name="profile_profile_id">配置文件ID</string>
+    <string name="profile_managed">Managed profile</string>
     <!-- Warnings/Notifications in the details view -->
     <string name="alert_text_no_input_gateway">必填信息以初始化连接</string>
     <string name="alert_text_no_input_username">请输入您的用户名</string>
index 79d3e41ba34e5469efcd63749a4b369d949bdb18..33473b63e6ddce4f136d86b560e619f864df2e6f 100644 (file)
     <string name="profile_cert_import">從VPN設定檔匯入憑證</string>
     <string name="profile_cert_alias">\"%1$s\" 對應的憑證</string>
     <string name="profile_profile_id">Profile ID</string>
+    <string name="profile_managed">Managed profile</string>
     <!-- Warnings/Notifications in the details view -->
     <string name="alert_text_no_input_gateway">請填寫必要訊息才能初始化連線</string>
     <string name="alert_text_no_input_username">請輸入您的用戶名稱</string>
index 59f24e7e25e80932e2b38be78a35b59c499befbb..d6d2ce8546e6fac0027921cfe127d9c7a4ebd9c1 100644 (file)
     <string name="profile_cert_import">Import certificate from VPN profile</string>
     <string name="profile_cert_alias">Certificate for \"%1$s\"</string>
     <string name="profile_profile_id">Profile ID</string>
+    <string name="profile_managed">Managed profile</string>
     <!-- Warnings/Notifications in the details view -->
     <string name="alert_text_no_input_gateway">A value is required to initiate the connection</string>
     <string name="alert_text_no_input_username">Please enter your username </string>