android: Add label to read-only profiles in list

Show "Managed profile" in the list of VPN profiles, to make it
immediately obvious that a profile is managed/read-only.
This commit is contained in:
Markus Pfeiffer
2024-02-21 12:24:53 +01:00
committed by Tobias Brunner
parent d3f5c3a760
commit c9c65a94c9
9 changed files with 43 additions and 17 deletions
@@ -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)
{
@@ -17,44 +17,60 @@
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>
@@ -139,6 +139,7 @@
<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>
@@ -141,6 +141,7 @@
<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>
@@ -135,6 +135,7 @@
<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>
@@ -136,6 +136,7 @@
<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>
@@ -135,6 +135,7 @@
<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>
@@ -135,6 +135,7 @@
<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>
@@ -139,6 +139,7 @@
<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>