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
This commit is contained in:
Sundeep Ghuman
2017-07-12 23:02:24 -07:00
parent 1c005d1e80
commit d3171ca2a1
2 changed files with 11 additions and 14 deletions

View File

@@ -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 -->

View File

@@ -677,13 +677,6 @@ public class AccessPoint implements Comparable<AccessPoint> {
// 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 @@ public class AccessPoint implements Comparable<AccessPoint> {
}
}
// 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();
}
/**