Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1cc5e51e authored by Chandru's avatar Chandru
Browse files

Change usages of getQuantityString to icu MessageFormatter.

This cleans up all usages under frameworks/base/packages/SystemUI
Bug: 199230205
Fixes: 199230205
Test: atest passes for all the affected packages

Change-Id: I0c8dfbbd53901c3b34669a02447d2461869a90ea
parent 0c8bb60c
Loading
Loading
Loading
Loading
+21 −25
Original line number Diff line number Diff line
@@ -164,21 +164,21 @@
         Displayed in a dialog box.  -->
    <string name="kg_password_wrong_pin_code_pukked">Incorrect SIM PIN code you must now contact your carrier to unlock your device.</string>
    <!-- Instructions telling the user that they entered the wrong SIM PIN while trying
         to unlock the keyguard.  Displayed in a dialog box.  -->
    <plurals name="kg_password_wrong_pin_code">
        <item quantity="one">Incorrect SIM PIN code, you have <xliff:g id="number">%d</xliff:g> remaining attempt before you must contact your carrier to unlock your device.</item>
        <item quantity="other">Incorrect SIM PIN code, you have <xliff:g id="number">%d</xliff:g> remaining attempts.</item>
    </plurals>
         to unlock the keyguard.  Displayed in a dialog box.  [CHAR LIMIT=NONE] -->
    <string name="kg_password_wrong_pin_code"> {count, plural,
        =1 {Incorrect SIM PIN code, you have # remaining attempt before you must contact your carrier to unlock your device.}
        other {Incorrect SIM PIN code, you have # remaining attempts. }
    }</string>

    <!-- Instructions telling the user that they have exhausted SIM PUK retries and the SIM is now unusable.
         Displayed in a dialog box.  -->
    <string name="kg_password_wrong_puk_code_dead">SIM is unusable. Contact your carrier.</string>
    <!-- Instructions telling the user that they entered the wrong puk while trying
         to unlock the keyguard.  Displayed in a dialog box.  -->
    <plurals name="kg_password_wrong_puk_code">
        <item quantity="one">Incorrect SIM PUK code, you have <xliff:g id="number">%d</xliff:g> remaining attempt before SIM becomes permanently unusable.</item>
        <item quantity="other">Incorrect SIM PUK code, you have <xliff:g id="number">%d</xliff:g> remaining attempts before SIM becomes permanently unusable.</item>
    </plurals>
         to unlock the keyguard.  Displayed in a dialog box.  [CHAR LIMIT=NONE] -->
    <string name="kg_password_wrong_puk_code">{count, plural,
        =1 {Incorrect SIM PUK code, you have # remaining attempt before SIM becomes permanently unusable.}
        other {Incorrect SIM PUK code, you have # remaining attempts before SIM becomes permanently unusable.}
    }</string>
    <!-- Instructions telling the user that the operation to unlock the keyguard
         with SIM PIN failed. Displayed in one line in a large font.  -->
    <string name="kg_password_pin_failed">SIM PIN operation failed!</string>
@@ -223,21 +223,17 @@
     <!-- Error message indicating that the camera privacy sensor has been turned on [CHAR LIMIT=NONE] -->
    <string name="kg_face_sensor_privacy_enabled">To use Face Unlock, turn on <b>Camera access</b> in Settings > Privacy</string>

    <!-- Instructions telling the user remaining times when enter SIM PIN view.  -->
    <plurals name="kg_password_default_pin_message">
        <item quantity="one">Enter SIM PIN. You have <xliff:g id="number">%d</xliff:g> remaining
attempt before you must contact your carrier to unlock your device.</item>
        <item quantity="other">Enter SIM PIN. You have <xliff:g id="number">%d</xliff:g> remaining
attempts.</item>
    </plurals>

    <!-- Instructions telling the user remaining times when enter SIM PUK view.  -->
    <plurals name="kg_password_default_puk_message">
        <item quantity="one">SIM is now disabled. Enter PUK code to continue. You have <xliff:g id="
number">%d</xliff:g> remaining attempt before SIM becomes permanently unusable. Contact carrier for details.</item>
        <item quantity="other">SIM is now disabled. Enter PUK code to continue. You have <xliff:g id="
number">%d</xliff:g> remaining attempts before SIM becomes permanently unusable. Contact carrier for details.</item>
    </plurals>
    <!-- Instructions telling the user remaining times when enter SIM PIN view.  [CHAR LIMIT=NONE] -->
    <string name="kg_password_default_pin_message">{count, plural,
        =1 {Enter SIM PIN. You have # remaining attempt before you must contact your carrier to unlock your device.}
        other {Enter SIM PIN. You have # remaining attempts.}
    }</string>

    <!-- Instructions telling the user remaining times when enter SIM PUK view. [CHAR LIMIT=NONE] -->
    <string name="kg_password_default_puk_message">{count, plural,
        =1 {SIM is now disabled. Enter PUK code to continue. You have # remaining attempt before SIM becomes permanently unusable. Contact carrier for details.}
        other {SIM is now disabled. Enter PUK code to continue. You have # remaining attempts before SIM becomes permanently unusable. Contact carrier for details.}
    }</string>

    <!-- Name of the "Default" clock face, which is the clock face that will be shown by default. [CHAR LIMIT=15]-->
    <string name="clock_title_default">Default</string>
+34 −34
Original line number Diff line number Diff line
@@ -505,10 +505,10 @@
    <string name="notification_group_overflow_indicator">+ <xliff:g id="number" example="3">%s</xliff:g></string>

    <!-- Content description describing how many more notifications are in a group [CHAR LIMIT=NONE] -->
    <plurals name="notification_group_overflow_description">
        <item quantity="one"><xliff:g id="number" example="1">%s</xliff:g> more notification inside.</item>
        <item quantity="other"><xliff:g id="number" example="3">%s</xliff:g> more notifications inside.</item>
    </plurals>
    <string name="notification_group_overflow_description">{count, plural,
        =1 {# more notification inside.}
        other {# more notifications inside.}
    }</string>

    <!-- Format to use to summarize a message from a contact in a single line of text. For example: "Julia: How's it going?". [CHAR LIMIT=NONE] -->

@@ -654,10 +654,10 @@
         the user why they can't toggle the hotspot tile. [CHAR LIMIT=20] -->
    <string name="quick_settings_hotspot_secondary_label_data_saver_enabled">Data Saver is on</string>
    <!-- QuickSettings: Hotspot: Secondary label for how many devices are connected to the hotspot [CHAR LIMIT=NONE] -->
    <plurals name="quick_settings_hotspot_secondary_label_num_devices">
        <item quantity="one">%d device</item>
        <item quantity="other">%d devices</item>
    </plurals>
    <string name="quick_settings_hotspot_secondary_label_num_devices">{count, plural,
        =1 {# device}
        other {# devices}
    }</string>
    <!-- QuickSettings: Notifications [CHAR LIMIT=NONE] -->
    <!-- QuickSettings: Flashlight [CHAR LIMIT=NONE] -->
    <string name="quick_settings_flashlight_label">Flashlight</string>
@@ -928,10 +928,10 @@
    <string name="user_limit_reached_title">User limit reached</string>

    <!-- Message that tells people what's the maximum number of uses allowed on the device. [CHAR_LIMIT=NONE]-->
    <plurals name="user_limit_reached_message">
        <item quantity="one">Only one user can be created.</item>
        <item quantity="other">You can add up to <xliff:g id="count" example="3">%d</xliff:g> users.</item>
    </plurals>
    <string name="user_limit_reached_message">{count, plural,
        =1 {Only one user can be created.}
        other {You can add up to # users.}
    }</string>

    <!-- Title of the confirmation dialog for deleting a user [CHAR LIMIT=NONE] -->
    <string name="user_remove_user_title">Remove user?</string>
@@ -1486,20 +1486,20 @@
    <!-- Notification: Snooze panel: message indicating how long the notification was snoozed for. [CHAR LIMIT=100]-->
    <string name="snoozed_for_time">Snoozed for <xliff:g id="time_amount" example="15 minutes">%1$s</xliff:g></string>

    <!-- Notification:Snooze panel: Snooze options for hours -->
    <plurals name="snoozeHourOptions">
        <item quantity="one">%d hour</item>
        <item quantity="two">%d hours</item>
        <item quantity="few">%d hours</item>
        <item quantity="other">%d hours</item>
    </plurals>

   <!--  Notification: Snooze panel: Snooze options for minutes -->
   <plurals name="snoozeMinuteOptions">
        <item quantity="one">%d minute</item>
        <item quantity="few">%d minutes</item>
        <item quantity="other">%d minutes</item>
    </plurals>
    <!-- Notification:Snooze panel: Snooze options for hours [CHAR LIMIT=NONE]-->
    <string name="snoozeHourOptions">{count, plural,
        =1 {# hour}
        =2 {# hours}
        few {# hours}
        other {# hours}
    }</string>

   <!--  Notification: Snooze panel: Snooze options for minutes [CHAR LIMIT=NONE]-->
   <string name="snoozeMinuteOptions">{count, plural,
        =1 {# minute}
        few {# minutes}
        other {# minutes}
    }</string>

    <!-- Summary of battery saver not available [CHAR LIMIT=NONE] -->

@@ -2136,10 +2136,10 @@
    <!-- Controls management providers screen title [CHAR LIMIT=60]-->
    <string name="controls_providers_title">Choose app to add controls</string>
    <!-- Number of favorites for controls management screen [CHAR LIMIT=NONE]-->
    <plurals name="controls_number_of_favorites">
        <item quantity="one"><xliff:g id="number" example="1">%s</xliff:g> control added.</item>
        <item quantity="other"><xliff:g id="number" example="3">%s</xliff:g> controls added.</item>
    </plurals>
    <string name="controls_number_of_favorites">{count, plural,
        =1 {# control added.}
        other {# controls added.}
    }</string>

    <!-- Removed control in management screen [CHAR LIMIT=20] -->
    <string name="controls_removed">Removed</string>
@@ -2495,10 +2495,10 @@
    <string name="qs_user_switch_dialog_title">Select user</string>

    <!-- Label for the entry point to open the dialog which shows currently running applications [CHAR LIMIT=NONE]-->
    <plurals name="fgs_manager_footer_label">
        <item quantity="one"><xliff:g id="count" example="1">%s</xliff:g> app is active</item>
        <item quantity="other"><xliff:g id="count" example="2">%s</xliff:g> apps are active</item>
    </plurals>
    <string name="fgs_manager_footer_label">{count, plural,
        =1 {# app is active}
        other {# apps are active}
    }</string>
    <!-- Content description for a dot indicator in the running application indicating that there
    is new information [CHAR LIMIT=NONE] -->
    <string name="fgs_dot_content_description">New information</string>
+5 −4
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.keyguard;

import static com.android.systemui.util.PluralMessageFormaterKt.icuMessageFormat;

import android.annotation.NonNull;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
@@ -241,10 +243,9 @@ public class KeyguardSimPinViewController
            displayMessage = mView.getResources().getString(
                    R.string.kg_password_wrong_pin_code_pukked);
        } else if (attemptsRemaining > 0) {
            msgId = isDefault ? R.plurals.kg_password_default_pin_message :
                    R.plurals.kg_password_wrong_pin_code;
            displayMessage = mView.getResources()
                    .getQuantityString(msgId, attemptsRemaining, attemptsRemaining);
            msgId = isDefault ? R.string.kg_password_default_pin_message :
                    R.string.kg_password_wrong_pin_code;
            displayMessage = icuMessageFormat(mView.getResources(), msgId, attemptsRemaining);
        } else {
            msgId = isDefault ? R.string.kg_sim_pin_instructions : R.string.kg_password_pin_failed;
            displayMessage = mView.getResources().getString(msgId);
+5 −4
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.keyguard;

import static com.android.systemui.util.PluralMessageFormaterKt.icuMessageFormat;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
@@ -57,10 +59,9 @@ public class KeyguardSimPukView extends KeyguardPinBasedInputView {
        if (attemptsRemaining == 0) {
            displayMessage = getContext().getString(R.string.kg_password_wrong_puk_code_dead);
        } else if (attemptsRemaining > 0) {
            int msgId = isDefault ? R.plurals.kg_password_default_puk_message :
                    R.plurals.kg_password_wrong_puk_code;
            displayMessage = getContext().getResources()
                    .getQuantityString(msgId, attemptsRemaining, attemptsRemaining);
            int msgId = isDefault ? R.string.kg_password_default_puk_message :
                    R.string.kg_password_wrong_puk_code;
            displayMessage = icuMessageFormat(getResources(), msgId, attemptsRemaining);
        } else {
            int msgId = isDefault ? R.string.kg_puk_enter_puk_hint :
                    R.string.kg_password_puk_failed;
+8 −5
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import androidx.lifecycle.LifecycleOwner
import androidx.recyclerview.widget.RecyclerView
import com.android.systemui.R
import com.android.systemui.controls.ControlsServiceInfo
import com.android.systemui.util.icuMessageFormat
import java.text.Collator
import java.util.concurrent.Executor

@@ -74,8 +75,10 @@ class AppAdapter(
    }

    override fun onCreateViewHolder(parent: ViewGroup, i: Int): Holder {
        return Holder(layoutInflater.inflate(R.layout.controls_app_item, parent, false),
                favoritesRenderer)
        return Holder(
            layoutInflater.inflate(R.layout.controls_app_item, parent, false),
            favoritesRenderer
        )
    }

    override fun getItemCount() = listOfServices.size
@@ -116,10 +119,10 @@ class FavoritesRenderer(

    fun renderFavoritesForComponent(component: ComponentName): String? {
        val qty = favoriteFunction(component)
        if (qty != 0) {
            return resources.getQuantityString(R.plurals.controls_number_of_favorites, qty, qty)
        return if (qty != 0) {
            icuMessageFormat(resources, R.string.controls_number_of_favorites, qty)
        } else {
            return null
            null
        }
    }
}
Loading