Standardize usages of "/" separator in SettingsLib
This separator should be translated the same as the
preference_summary_default_combination used in the Settings app. We
reintroduce this string here in order to avoid a dependency from
SettingsLib to Settings app.
Bug: b/62354743
Test: NA - Refactor
Change-Id: I2ce12848b944417b0df5e6f629aabd49712ff634
diff --git a/packages/SettingsLib/res/values/strings.xml b/packages/SettingsLib/res/values/strings.xml
index 064cc84..0b51a8b 100644
--- a/packages/SettingsLib/res/values/strings.xml
+++ b/packages/SettingsLib/res/values/strings.xml
@@ -110,6 +110,9 @@
<!-- Speed label for very fast network speed -->
<string name="speed_label_very_fast">Very Fast</string>
+ <!-- Summary text separator for preferences including a short description (eg. "Fast / Connected"). -->
+ <string name="preference_summary_default_combination"><xliff:g id="state" example="ON">%1$s</xliff:g> / <xliff:g id="description" example="High accuracy mode">%2$s</xliff:g></string>
+
<!-- Bluetooth settings. Message when a device is disconnected -->
<string name="bluetooth_disconnected">Disconnected</string>
<!-- Bluetooth settings. Message when disconnecting from a device -->
diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java
index ec41415..9a3665f 100644
--- a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java
+++ b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java
@@ -677,13 +677,6 @@
// Update to new summary
StringBuilder summary = new StringBuilder();
- // TODO(b/62354743): Standardize and international delimiter usage
- final String concatenator = " / ";
-
- if (mSpeed != Speed.NONE) {
- summary.append(getSpeedLabel() + concatenator);
- }
-
if (isActive() && config != null && config.isPasspoint()) {
// This is the active connection on passpoint
summary.append(getSummary(mContext, getDetailedState(),
@@ -767,14 +760,15 @@
}
}
- // Strip trailing delimiter if applicable
- int concatLength = concatenator.length();
- if (summary.length() >= concatLength && summary.substring(
- summary.length() - concatLength, summary.length()).equals(concatenator)) {
- summary.delete(summary.length() - concatLength, summary.length());
+ // If Speed label is present, use the preference combination to prepend it to the summary.
+ if (mSpeed != Speed.NONE) {
+ return mContext.getResources().getString(
+ R.string.preference_summary_default_combination,
+ getSpeedLabel(),
+ summary.toString());
+ } else {
+ return summary.toString();
}
-
- return summary.toString();
}
/**