Update string associated with Connected, Always On or Insecure VPNs

Previously these strings were separated with a comma, but the new design
is to separate them with a "/" and to not include always-on information
if the vpn is also insecure.

Comment thread on the strings doc: https://docs.google.com/document/d/1hjaYuGmvNzCKPOrmjixpmLLXBV8cbxgrZ3eN4KvC4E8/edit?resourcekey=0-zo7B2GVc9luQTut0o8THNA&hl=zh-TW&forcehl=1&disco=AAAAIF3eiQY
screenshot: https://screenshot.googleplex.com/BmBroUZtmUPJz9s
Test: atest -c SettingsUnitTests
Bug: 176821216

Change-Id: Ib9c273de61c9722b0beb6fba127e7481e6c64705
This commit is contained in:
Jeremy Goldman
2021-04-07 16:53:02 +08:00
parent 0a03f8e2d2
commit d62b2c23cf
2 changed files with 8 additions and 9 deletions

View File

@@ -7170,9 +7170,9 @@
<!-- Preference summary for app not supporting always-on VPN [CHAR LIMIT=40] --> <!-- Preference summary for app not supporting always-on VPN [CHAR LIMIT=40] -->
<string name="vpn_always_on_summary_not_supported">Not supported by this app</string> <string name="vpn_always_on_summary_not_supported">Not supported by this app</string>
<!-- Preference summary for a VPN app that is set to be always-on. [CHAR LIMIT=40] --> <!-- Preference summary for a VPN app that is set to be always-on. [CHAR LIMIT=40] -->
<string name="vpn_always_on_summary_active">Always-on active</string> <string name="vpn_always_on_summary_active">Always on</string>
<!-- Preference summary for a VPN app that has an insecure type. [CHAR LIMIT=40] --> <!-- Preference summary for a VPN app that has an insecure type. [CHAR LIMIT=40] -->
<string name="vpn_insecure_summary">not secure VPN</string> <string name="vpn_insecure_summary">Not secure</string>
<!-- Preference title for the toggle that controls whether to force all network connections to <!-- Preference title for the toggle that controls whether to force all network connections to
go through VPN. [CHAR LIMIT=40] --> go through VPN. [CHAR LIMIT=40] -->
<string name="vpn_require_connection">Block connections without VPN</string> <string name="vpn_require_connection">Block connections without VPN</string>

View File

@@ -107,21 +107,20 @@ public abstract class ManageablePreference extends GearPreference {
final Resources res = getContext().getResources(); final Resources res = getContext().getResources();
final String[] states = res.getStringArray(R.array.vpn_states); final String[] states = res.getStringArray(R.array.vpn_states);
String summary = (mState == STATE_NONE ? "" : states[mState]); String summary = (mState == STATE_NONE ? "" : states[mState]);
if (mIsAlwaysOn) {
final String alwaysOnString = res.getString(R.string.vpn_always_on_summary_active);
summary = TextUtils.isEmpty(summary) ? alwaysOnString : res.getString(
R.string.join_two_unrelated_items, summary, alwaysOnString);
}
if (mIsInsecureVpn) { if (mIsInsecureVpn) {
final String insecureString = res.getString(R.string.vpn_insecure_summary); final String insecureString = res.getString(R.string.vpn_insecure_summary);
summary = TextUtils.isEmpty(summary) ? insecureString : res.getString( summary = TextUtils.isEmpty(summary) ? insecureString : summary + " / "
R.string.join_two_unrelated_items, summary, insecureString); + insecureString;
SpannableString summarySpan = new SpannableString(summary); SpannableString summarySpan = new SpannableString(summary);
final int colorError = Utils.getColorErrorDefaultColor(getContext()); final int colorError = Utils.getColorErrorDefaultColor(getContext());
summarySpan.setSpan(new ForegroundColorSpan(colorError), 0, summary.length(), summarySpan.setSpan(new ForegroundColorSpan(colorError), 0, summary.length(),
SPAN_EXCLUSIVE_INCLUSIVE); SPAN_EXCLUSIVE_INCLUSIVE);
setSummary(summarySpan); setSummary(summarySpan);
} else if (mIsAlwaysOn) {
final String alwaysOnString = res.getString(R.string.vpn_always_on_summary_active);
summary = TextUtils.isEmpty(summary) ? alwaysOnString : summary + " / "
+ alwaysOnString;
} else { } else {
setSummary(summary); setSummary(summary);
} }