VPN settings: gray out always-on checkbox dynamically

In the ConfigDialog for legacy VPNs, many configurations do not support
Always-on VPN. Previously, when a user entered an unsupported set of
settings, the Always-on VPN checkbox could still be ticked, and the
Save or Connect action buttons would be disabled. This was not intuitive
as the user could not easily figure out which part of the settings was
incompatible that grayed out the action buttons.

With this change, we disable the Always-on VPN checkbox immediately as
the user enters any incompatible setting. We also display the reason why
Always-on VPN is disabled. This will make it more straightforward for
the users to understand which setting is conflicting with the Always-on
feature.

This change is also the first step towards refactoring the ConfigDialog
for legacy VPNs with PreferenceFragment.

Test: manual
Bug: 29208008
Bug: 28072644
Change-Id: I1e6d32a1069ca0b936513f4985ffb9a9412b249c
This commit is contained in:
Charles He
2017-03-20 14:00:06 +00:00
parent e11cb90ed2
commit ad828f1551
4 changed files with 68 additions and 14 deletions

View File

@@ -5375,6 +5375,16 @@
<string name="vpn_no_ca_cert">(don\u2019t verify server)</string>
<!-- Option to use the server certificate received from the VPN server. [CHAR LIMIT=40] -->
<string name="vpn_no_server_cert">(received from server)</string>
<!-- Reason for Always-on VPN checkbox being disabled: the selected VPN type doesn't support always-on. [CHAR LIMIT=120] -->
<string name="vpn_always_on_invalid_reason_type">The selected VPN type can\u2019t be always on</string>
<!-- Reason for Always-on VPN checkbox being disabled: the server address is invalid. [CHAR LIMIT=120] -->
<string name="vpn_always_on_invalid_reason_server">Always-on VPN only supports numeric server addresses</string>
<!-- Reason for Always-on VPN checkbox being disabled: no DNS is found. [CHAR LIMIT=120] -->
<string name="vpn_always_on_invalid_reason_no_dns">A DNS server must be specified for always-on VPN</string>
<!-- Reason for Always-on VPN checkbox being disabled: DNS server addresses are invalid. [CHAR LIMIT=120] -->
<string name="vpn_always_on_invalid_reason_dns">DNS server addresses must be numeric for always-on VPN</string>
<!-- Reason for Always-on VPN checkbox being disabled: generic reason. [CHAR LIMIT=120] -->
<string name="vpn_always_on_invalid_reason_other">The information entered doesn\u2019t support always-on VPN</string>
<!-- Button label to cancel changing a VPN profile. [CHAR LIMIT=40] -->
<string name="vpn_cancel">Cancel</string>

View File

@@ -284,6 +284,13 @@
<item name="android:singleLine">true</item>
</style>
<style name="vpn_warning">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:paddingStart">8dip</item>
<item name="android:textAppearance">?android:attr/textAppearanceSmall</item>
</style>
<style name="TextAppearance.PagerTabs" parent="@android:style/TextAppearance.Material.Widget.TabWidget" />
<style name="KeyguardAppWidgetItem">