android: Display the selected certificate alias in the profile list
authorTobias Brunner <tobias@strongswan.org>
Tue, 28 Aug 2012 12:47:00 +0000 (14:47 +0200)
committerTobias Brunner <tobias@strongswan.org>
Fri, 31 Aug 2012 16:24:45 +0000 (18:24 +0200)
src/frontends/android/res/layout/profile_list_item.xml
src/frontends/android/src/org/strongswan/android/ui/adapter/VpnProfileAdapter.java

index f55c835..93df7b6 100644 (file)
         android:textAppearance="?android:attr/textAppearanceSmall"
         android:layout_marginLeft="15dp" />
 
+    <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:ellipsize="end"
+        android:layout_marginLeft="15dp" />
+
 </LinearLayout>
index 39e3e58..85dc837 100644 (file)
@@ -64,7 +64,25 @@ public class VpnProfileAdapter extends ArrayAdapter<VpnProfile>
                tv = (TextView)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.setText(getContext().getString(R.string.profile_username_label) + " " + profile.getUsername());
+               if (profile.getVpnType().getRequiresUsernamePassword())
+               {       /* if the view is reused we make sure it is visible */
+                       tv.setVisibility(View.VISIBLE);
+                       tv.setText(getContext().getString(R.string.profile_username_label) + " " + profile.getUsername());
+               }
+               else
+               {
+                       tv.setVisibility(View.GONE);
+               }
+               tv = (TextView)vpnProfileView.findViewById(R.id.profile_item_certificate);
+               if (profile.getVpnType().getRequiresCertificate())
+               {
+                       tv.setText(getContext().getString(R.string.profile_user_certificate_label) + " " + profile.getUserCertificateAlias());
+                       tv.setVisibility(View.VISIBLE);
+               }
+               else
+               {
+                       tv.setVisibility(View.GONE);
+               }
                return vpnProfileView;
        }