Commit 598e056c authored by Theresa's avatar Theresa Committed by Commit Bot

[Android] Announce when history items have been deleted

BUG=524215

Change-Id: If163f88332e28bf769c4f4c80e6a2a00efc16f39
Reviewed-on: https://chromium-review.googlesource.com/c/1392249Reviewed-by: default avatarBecky Zhou <huayinz@chromium.org>
Commit-Queue: Theresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#619446}
parent ae3d6169
......@@ -82,10 +82,11 @@ public class BookmarkUndoController extends BookmarkModelObserver implements
if (!isUndoable) return;
if (titles.length == 1) {
mSnackbarManager.showSnackbar(Snackbar
.make(titles[0], this, Snackbar.TYPE_ACTION, Snackbar.UMA_BOOKMARK_DELETE_UNDO)
.setTemplateText(mContext.getString(R.string.undo_bar_delete_message))
.setAction(mContext.getString(R.string.undo), null));
mSnackbarManager.showSnackbar(
Snackbar.make(titles[0], this, Snackbar.TYPE_ACTION,
Snackbar.UMA_BOOKMARK_DELETE_UNDO)
.setTemplateText(mContext.getString(R.string.delete_message))
.setAction(mContext.getString(R.string.undo), null));
} else {
mSnackbarManager.showSnackbar(
Snackbar.make(String.format(Locale.getDefault(), "%d", titles.length), this,
......
......@@ -27,7 +27,7 @@ final class UndoUiUtils {
public static String getTemplateTextFor(Collection<OfflineItem> items) {
Context context = ContextUtils.getApplicationContext();
return items.size() == 1
? context.getString(R.string.undo_bar_delete_message)
? context.getString(R.string.delete_message)
: context.getString(R.string.undo_bar_multiple_downloads_delete_message);
}
}
\ No newline at end of file
......@@ -471,7 +471,8 @@ public class DownloadManagerUi implements OnMenuItemClickListener, SearchDelegat
String snackbarText = singleItemDeleted
? items.get(0).getDisplayFileName()
: String.format(Locale.getDefault(), "%d", items.size());
int snackbarTemplateId = singleItemDeleted ? R.string.undo_bar_delete_message
int snackbarTemplateId = singleItemDeleted
? R.string.delete_message
: R.string.undo_bar_multiple_downloads_delete_message;
Snackbar snackbar = Snackbar.make(snackbarText, mUndoDeletionSnackbarController,
......
......@@ -222,11 +222,25 @@ public class HistoryManager implements OnMenuItemClickListener, SignInStateObser
recordSelectionCountHistorgram("Remove");
recordUserActionWithOptionalSearch("RemoveSelected");
int numItemsRemoved = 0;
HistoryItem lastItemRemoved = null;
for (HistoryItem historyItem : mSelectionDelegate.getSelectedItems()) {
mHistoryAdapter.markItemForRemoval(historyItem);
numItemsRemoved++;
lastItemRemoved = historyItem;
}
mHistoryAdapter.removeItems();
mSelectionDelegate.clearSelection();
if (numItemsRemoved == 1) {
assert lastItemRemoved != null;
announceItemRemoved(lastItemRemoved);
} else if (numItemsRemoved > 1) {
mRecyclerView.announceForAccessibility(mRecyclerView.getContext().getString(
R.string.multiple_history_items_deleted, numItemsRemoved));
}
return true;
} else if (item.getItemId() == R.id.search_menu_id) {
mHistoryAdapter.removeHeader();
......@@ -285,6 +299,12 @@ public class HistoryManager implements OnMenuItemClickListener, SignInStateObser
}
mHistoryAdapter.markItemForRemoval(item);
mHistoryAdapter.removeItems();
announceItemRemoved(item);
}
private void announceItemRemoved(HistoryItem item) {
mRecyclerView.announceForAccessibility(
mRecyclerView.getContext().getString(R.string.delete_message, item.getTitle()));
}
/**
......
......@@ -814,6 +814,9 @@ Your Google account may have other forms of browsing history like searches and a
<message name="IDS_ANDROID_HISTORY_BLOCKED_SITE" desc="The text displayed in the history page indicating that a visit to a web site was blocked due to an administrator policy.">
Blocked site
</message>
<message name="IDS_MULTIPLE_HISTORY_ITEMS_DELETED" desc="Accessibility announcement when multiple browsing history items have been deleted.">
<ph name="NUMBER_OF_ITEMS">%1$s<ex>3</ex></ph> items deleted
</message>
<message name="IDS_USAGE_AND_CRASH_REPORTS_TITLE_LEGACY" desc="Title for 'Usage and crash reports' preference">
Usage and crash reports
......@@ -3408,8 +3411,8 @@ However, you aren’t invisible. Going private doesn’t hide your browsing from
<message name="IDS_UNDO_BAR_CLOSE_ALL_MESSAGE" desc="Message shown when you can undo a close all tabs action.">
<ph name="TAB_COUNT">%1$s<ex>3</ex></ph> tabs closed
</message>
<message name="IDS_UNDO_BAR_DELETE_MESSAGE" desc="Message shown when you can undo a delete action.">
Deleted <ph name="BOOKMARK_TITLE">%1$s<ex>YouTube</ex></ph>
<message name="IDS_DELETE_MESSAGE" desc="Message shown or announced when an item has been deleted.">
Deleted <ph name="ITEM_TITLE">%1$s<ex>YouTube</ex></ph>
</message>
<message name="IDS_UNDO_BAR_MULTIPLE_DELETE_MESSAGE" desc="Message shown when you can undo several bookmark delete actions.">
<ph name="NUMBER_OF_BOOKMARKS">%1$s<ex>3</ex></ph> bookmarks deleted
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment