Merge "Add shortcuts count as a subtitle in the full widgets sheet" into sc-dev

This commit is contained in:
Steven Ng authored and Android (Google) Code Review committed 2021-03-05 17:56:11 +00:00
commit 1f4a3414f1
3 files changed
+37 -11

No files matched your search

+1 -1
View File
@@ -52,7 +52,7 @@
android:id="@+id/app_subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="n widgets" />
tools:text="m widgets, n shortcuts" />
</LinearLayout>
+15 -4
View File
@@ -52,11 +52,22 @@
<string name="add_item_request_drag_hint">Touch &amp; hold to place manually</string>
<!-- Button label to automatically add icon on home screen [CHAR_LIMIT=50] -->
<string name="place_automatically">Add automatically</string>
<!-- Label for showing the number of widgets an app has in the full widgets picker. [CHAR_LIMIT=25] -->
<plurals name="widgets_tray_subtitle">
<item quantity="one"><xliff:g id="widget_count" example="1">%1$d</xliff:g> widget</item>
<item quantity="other"><xliff:g id="widget_count" example="2">%1$d</xliff:g> widgets</item>
<!-- Label for showing the number of widgets an app has in the full widgets picker.
[CHAR_LIMIT=25] -->
<plurals name="widgets_count">
<item quantity="one"><xliff:g id="widgets_count" example="1">%1$d</xliff:g> widget</item>
<item quantity="other"><xliff:g id="widgets_count" example="2">%1$d</xliff:g> widgets</item>
</plurals>
<!-- Label for showing the number of shortcut an app has in the full widgets picker.
[CHAR_LIMIT=25] -->
<plurals name="shortcuts_count">
<item quantity="one"><xliff:g id="shortcuts_count" example="1">%1$d</xliff:g> shortcut</item>
<item quantity="other"><xliff:g id="shortcuts_count" example="2">%1$d</xliff:g> shortcuts</item>
</plurals>
<!-- Label for showing both the number of widgets and shortcuts an app has in the full widgets
picker. [CHAR_LIMIT=50] -->
<string name="widgets_and_shortcuts_count"><xliff:g id="widgets_count" example="5 widgets">%1$s</xliff:g>, <xliff:g id="shortcuts_count" example="1 shortcut">%2$s</xliff:g></string>
<!-- Text for both the tile of a popup view, which shows all available widgets installed on
the device, and the text of a button, which opens this popup view. [CHAR LIMIT=30]-->
<string name="widget_button_text">Widgets</string>
@@ -157,14 +157,29 @@ public final class WidgetsListHeader extends LinearLayout implements ItemInfoUpd
private void setTitles(WidgetsListHeaderEntry entry) {
mTitle.setText(entry.mPkgItem.title);
if (entry.widgetsCount > 0) {
Resources resources = getContext().getResources();
mSubtitle.setText(resources.getQuantityString(R.plurals.widgets_tray_subtitle,
entry.widgetsCount, entry.widgetsCount));
mSubtitle.setVisibility(VISIBLE);
} else {
Resources resources = getContext().getResources();
if (entry.widgetsCount == 0 && entry.shortcutsCount == 0) {
mSubtitle.setVisibility(GONE);
return;
}
String subtitle;
if (entry.widgetsCount > 0 && entry.shortcutsCount > 0) {
String widgetsCount = resources.getQuantityString(R.plurals.widgets_count,
entry.widgetsCount, entry.widgetsCount);
String shortcutsCount = resources.getQuantityString(R.plurals.shortcuts_count,
entry.shortcutsCount, entry.shortcutsCount);
subtitle = resources.getString(R.string.widgets_and_shortcuts_count, widgetsCount,
shortcutsCount);
} else if (entry.widgetsCount > 0) {
subtitle = resources.getQuantityString(R.plurals.widgets_count,
entry.widgetsCount, entry.widgetsCount);
} else {
subtitle = resources.getQuantityString(R.plurals.shortcuts_count,
entry.shortcutsCount, entry.shortcutsCount);
}
mSubtitle.setText(subtitle);
mSubtitle.setVisibility(VISIBLE);
}
@Override