Merge "Refine the plural strings design in SettingsLib"
This commit is contained in:
committed by
Android (Google) Code Review
commit
bcf56a541a
@@ -1271,10 +1271,13 @@
|
||||
<string name="wifi_status_mac_randomized">MAC is randomized</string>
|
||||
|
||||
<!-- Summary to show how many devices are connected in wifi hotspot [CHAR LIMIT=NONE] -->
|
||||
<plurals name="wifi_tether_connected_summary">
|
||||
<item quantity="one">%1$d device connected</item>
|
||||
<item quantity="other">%1$d devices connected</item>
|
||||
</plurals>
|
||||
<string name="wifi_tether_connected_summary">
|
||||
{count, plural,
|
||||
=0 {0 device connected}
|
||||
=1 {1 device connected}
|
||||
other {# devices connected}
|
||||
}
|
||||
</string>
|
||||
|
||||
<!-- Content description of zen mode time condition plus button (not shown on the screen). [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_manual_zen_more_time">More time.</string>
|
||||
|
||||
@@ -22,6 +22,7 @@ import static android.net.wifi.WifiConfiguration.NetworkSelectionStatus.getMaxNe
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.icu.text.MessageFormat;
|
||||
import android.net.wifi.ScanResult;
|
||||
import android.net.wifi.WifiConfiguration;
|
||||
import android.net.wifi.WifiConfiguration.NetworkSelectionStatus;
|
||||
@@ -33,6 +34,8 @@ import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.settingslib.R;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
public class WifiUtils {
|
||||
@@ -333,4 +336,20 @@ public class WifiUtils {
|
||||
intent.putExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS, bundle);
|
||||
return intent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string of Wi-Fi tethering summary for connected devices.
|
||||
*
|
||||
* @param context The application context
|
||||
* @param connectedDevices The count of connected devices
|
||||
*/
|
||||
public static String getWifiTetherSummaryForConnectedDevices(Context context,
|
||||
int connectedDevices) {
|
||||
MessageFormat msgFormat = new MessageFormat(
|
||||
context.getResources().getString(R.string.wifi_tether_connected_summary),
|
||||
Locale.getDefault());
|
||||
Map<String, Object> arguments = new HashMap<>();
|
||||
arguments.put("count", connectedDevices);
|
||||
return msgFormat.format(arguments);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user