Merge "Announce folder content size with folder title" into ub-launcher3-rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
161ed5ad9b
@@ -172,8 +172,10 @@
|
||||
<string name="folder_closed">Folder closed</string>
|
||||
<!-- Folder renamed format -->
|
||||
<string name="folder_renamed">Folder renamed to <xliff:g id="name" example="Games">%1$s</xliff:g></string>
|
||||
<!-- Folder name format -->
|
||||
<string name="folder_name_format">Folder: <xliff:g id="name" example="Games">%1$s</xliff:g></string>
|
||||
<!-- Folder name format when folder has less than 4 items -->
|
||||
<string name="folder_name_format_exact">Folder: <xliff:g id="name" example="Games">%1$s</xliff:g>, <xliff:g id="size" example="2">%2$d</xliff:g> items</string>
|
||||
<!-- Folder name format when folder has 4 or more items shown in preview-->
|
||||
<string name="folder_name_format_overflow">Folder: <xliff:g id="name" example="Games">%1$s</xliff:g>, <xliff:g id="size" example="2">%2$d</xliff:g> or more items</string>
|
||||
|
||||
<!-- Strings for the customization mode -->
|
||||
<!-- Text for widget add button -->
|
||||
|
||||
@@ -201,8 +201,7 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel
|
||||
icon.mActivity = activity;
|
||||
icon.mDotRenderer = grid.mDotRendererWorkSpace;
|
||||
|
||||
icon.setContentDescription(
|
||||
group.getContext().getString(R.string.folder_name_format, folderInfo.title));
|
||||
icon.setContentDescription(icon.getAccessiblityTitle(folderInfo.title));
|
||||
|
||||
// Keep the notification dot up to date with the sum of all the content's dots.
|
||||
FolderDotInfo folderDotInfo = new FolderDotInfo();
|
||||
@@ -665,6 +664,7 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel
|
||||
mDotInfo.addDotInfo(mActivity.getDotInfoForItem(item));
|
||||
boolean isDotted = mDotInfo.hasDot();
|
||||
updateDotScale(wasDotted, isDotted);
|
||||
setContentDescription(getAccessiblityTitle(mInfo.title));
|
||||
invalidate();
|
||||
requestLayout();
|
||||
}
|
||||
@@ -675,13 +675,14 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel
|
||||
mDotInfo.subtractDotInfo(mActivity.getDotInfoForItem(item));
|
||||
boolean isDotted = mDotInfo.hasDot();
|
||||
updateDotScale(wasDotted, isDotted);
|
||||
setContentDescription(getAccessiblityTitle(mInfo.title));
|
||||
invalidate();
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
public void onTitleChanged(CharSequence title) {
|
||||
mFolderName.setText(title);
|
||||
setContentDescription(getContext().getString(R.string.folder_name_format, title));
|
||||
setContentDescription(getAccessiblityTitle(title));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -775,4 +776,17 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel
|
||||
public void getWorkspaceVisualDragBounds(Rect bounds) {
|
||||
getPreviewBounds(bounds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a formatted accessibility title for folder
|
||||
*/
|
||||
public String getAccessiblityTitle(CharSequence title) {
|
||||
int size = mInfo.contents.size();
|
||||
if (size < MAX_NUM_ITEMS_IN_PREVIEW) {
|
||||
return getContext().getString(R.string.folder_name_format_exact, title, size);
|
||||
} else {
|
||||
return getContext().getString(R.string.folder_name_format_overflow, title,
|
||||
MAX_NUM_ITEMS_IN_PREVIEW);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user