Cleanup plurals format
Change <one> to <1> in string res file Test: Update, existing tests still pass bug: 199230342 Change-Id: Ic3a5259570cb52cd1664638f3b1058c87a631c04
This commit is contained in:
@@ -20,9 +20,16 @@ import static java.lang.annotation.RetentionPolicy.SOURCE;
|
||||
|
||||
import android.annotation.IntDef;
|
||||
import android.annotation.PluralsRes;
|
||||
import android.annotation.StringRes;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.utils.StringUtil;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/** Provides utility methods related auto click. */
|
||||
public final class AutoclickUtils {
|
||||
@@ -58,20 +65,23 @@ public final class AutoclickUtils {
|
||||
/**
|
||||
* Gets string that should be used for provided autoclick delay.
|
||||
*
|
||||
* @param resources Resources from which string should be retrieved.
|
||||
* @param context context from which string should be retrieved.
|
||||
* @param id The desired resource identifier, as generated by the aapt
|
||||
* tool. This integer encodes the package, type, and resource
|
||||
* entry. The value 0 is an invalid identifier.
|
||||
* @param delayMillis Delay for whose value summary should be retrieved.
|
||||
*/
|
||||
public static CharSequence getAutoclickDelaySummary(Resources resources,
|
||||
@PluralsRes int id, int delayMillis) {
|
||||
public static CharSequence getAutoclickDelaySummary(Context context,
|
||||
@StringRes int id, int delayMillis) {
|
||||
final int quantity = (delayMillis == 1000) ? Quantity.ONE : Quantity.FEW;
|
||||
final float delaySecond = (float) delayMillis / 1000;
|
||||
// Only show integer when delay time is 1.
|
||||
final String decimalFormat = (delaySecond == 1) ? "%.0f" : "%.1f";
|
||||
|
||||
return resources.getQuantityString(id, quantity, String.format(decimalFormat, delaySecond));
|
||||
Map<String, Object> arguments = new HashMap<>();
|
||||
arguments.put("count", quantity);
|
||||
arguments.put("time", String.format(decimalFormat, delaySecond));
|
||||
return StringUtil.getIcuPluralsString(context, arguments, id);
|
||||
}
|
||||
|
||||
private AutoclickUtils(){}
|
||||
|
||||
Reference in New Issue
Block a user