Clean <plurals> in BugreportProgressService

Bug: 199230228
Test: make
Change-Id: I888c65c8819eb5443178ddfc2097d3519b89cefb
This commit is contained in:
Calvin Pan
2022-01-17 12:03:28 +08:00
parent bf4e15d017
commit 4ffb7e8884
3 changed files with 15 additions and 8 deletions

View File

@@ -689,10 +689,11 @@
your device is unresponsive or too slow, or when you need all report sections.
Does not allow you to enter more details or take additional screenshots.</string>
<!-- Toast message informing user in how many seconds a bugreport screenshot will be taken -->
<plurals name="bugreport_countdown">
<item quantity="one">Taking screenshot for bug report in <xliff:g id="number">%d</xliff:g> second.</item>
<item quantity="other">Taking screenshot for bug report in <xliff:g id="number">%d</xliff:g> seconds.</item>
</plurals>
<string name="bugreport_countdown">{count, plural,
=1 {Taking screenshot for bug report in # second.}
other {Taking screenshot for bug report in # seconds.}
}
</string>
<!-- Format for build summary info [CHAR LIMIT=NONE] -->
<string name="bugreport_status" translatable="false">%s (%s)</string>

View File

@@ -1260,9 +1260,9 @@
<java-symbol type="string" name="conference_call" />
<java-symbol type="string" name="tooltip_popup_title" />
<java-symbol type="plurals" name="bugreport_countdown" />
<java-symbol type="plurals" name="last_num_days" />
<java-symbol type="plurals" name="restr_pin_countdown" />
<java-symbol type="string" name="bugreport_countdown" />
<java-symbol type="string" name="file_count" />
<java-symbol type="string" name="matches_found" />
<java-symbol type="plurals" name="pinpuk_attempts" />

View File

@@ -72,6 +72,7 @@ import android.text.format.DateUtils;
import android.util.Log;
import android.util.Pair;
import android.util.Patterns;
import android.util.PluralsMessageFormatter;
import android.util.SparseArray;
import android.view.ContextThemeWrapper;
import android.view.IWindowManager;
@@ -111,7 +112,9 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
@@ -943,9 +946,12 @@ public class BugreportProgressService extends Service {
}
setTakingScreenshot(true);
collapseNotificationBar();
final String msg = mContext.getResources()
.getQuantityString(com.android.internal.R.plurals.bugreport_countdown,
mScreenshotDelaySec, mScreenshotDelaySec);
Map<String, Object> arguments = new HashMap<>();
arguments.put("count", mScreenshotDelaySec);
final String msg = PluralsMessageFormatter.format(
mContext.getResources(),
arguments,
com.android.internal.R.string.bugreport_countdown);
Log.i(TAG, msg);
// Show a toast just once, otherwise it might be captured in the screenshot.
Toast.makeText(mContext, msg, Toast.LENGTH_SHORT).show();