Skip to content

Commit

Permalink
CrOS Shelf: Announce user-triggered pin and unpin events
Browse files Browse the repository at this point in the history
Bug: 1012772, 1010697
Change-Id: I80ff57f5278a72244b0e929c0f44de3bd4af62ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1928211
Reviewed-by: Manu Cornet <manucornet@chromium.org>
Reviewed-by: Andrew Xu <andrewxu@chromium.org>
Auto-Submit: Manu Cornet <manucornet@chromium.org>
Commit-Queue: Manu Cornet <manucornet@chromium.org>
Commit-Queue: Andrew Xu <andrewxu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#717749}
  • Loading branch information
Manu Cornet authored and Commit Bot committed Nov 21, 2019
1 parent 5b65a4f commit e793566
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
34 changes: 31 additions & 3 deletions ash/shelf/shelf_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2079,7 +2079,8 @@ void ShelfView::AnnounceShelfAlignment() {
break;
}
announcement_view_->GetViewAccessibility().OverrideName(announcement);
announcement_view_->NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true);
announcement_view_->NotifyAccessibilityEvent(ax::mojom::Event::kAlert,
/*send_native_event=*/true);
}

void ShelfView::AnnounceShelfAutohideBehavior() {
Expand All @@ -2096,7 +2097,21 @@ void ShelfView::AnnounceShelfAutohideBehavior() {
break;
}
announcement_view_->GetViewAccessibility().OverrideName(announcement);
announcement_view_->NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true);
announcement_view_->NotifyAccessibilityEvent(ax::mojom::Event::kAlert,
/*send_native_event=*/true);
}

void ShelfView::AnnouncePinUnpinEvent(const ShelfItem& item, bool pinned) {
base::string16 item_title =
item.title.empty()
? l10n_util::GetStringUTF16(IDS_SHELF_ITEM_GENERIC_NAME)
: item.title;
base::string16 announcement = l10n_util::GetStringFUTF16(
pinned ? IDS_SHELF_ITEM_WAS_PINNED : IDS_SHELF_ITEM_WAS_UNPINNED,
item_title);
announcement_view_->GetViewAccessibility().OverrideName(announcement);
announcement_view_->NotifyAccessibilityEvent(ax::mojom::Event::kAlert,
/*send_native_event=*/true);
}

gfx::Rect ShelfView::GetBoundsForDragInsertInScreen() {
Expand Down Expand Up @@ -2223,6 +2238,11 @@ void ShelfView::ShelfItemAdded(int model_index) {
// Undo the hiding if animation does not run.
view->layer()->SetOpacity(1.0f);
}

if (model_->is_current_mutation_user_triggered() &&
item.type == TYPE_PINNED_APP) {
AnnouncePinUnpinEvent(item, /*pinned=*/true);
}
}

void ShelfView::ShelfItemRemoved(int model_index, const ShelfItem& old_item) {
Expand Down Expand Up @@ -2272,6 +2292,11 @@ void ShelfView::ShelfItemRemoved(int model_index, const ShelfItem& old_item) {

if (view == shelf_->tooltip()->GetCurrentAnchorView())
shelf_->tooltip()->Close();

if (model_->is_current_mutation_user_triggered() &&
old_item.type == TYPE_PINNED_APP) {
AnnouncePinUnpinEvent(old_item, /*pinned=*/false);
}
}

void ShelfView::ShelfItemChanged(int model_index, const ShelfItem& old_item) {
Expand Down Expand Up @@ -2306,8 +2331,11 @@ void ShelfView::ShelfItemChanged(int model_index, const ShelfItem& old_item) {

// If an item is being pinned or unpinned, show the new status of the
// shelf immediately so that the separator gets drawn as needed.
if (old_item.type == TYPE_PINNED_APP || item.type == TYPE_PINNED_APP)
if (old_item.type == TYPE_PINNED_APP || item.type == TYPE_PINNED_APP) {
if (model_->is_current_mutation_user_triggered())
AnnouncePinUnpinEvent(old_item, item.type == TYPE_PINNED_APP);
AnimateToIdealBounds();
}
return;
}

Expand Down
1 change: 1 addition & 0 deletions ash/shelf/shelf_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ class ASH_EXPORT ShelfView : public views::AccessiblePaneView,

void AnnounceShelfAlignment();
void AnnounceShelfAutohideBehavior();
void AnnouncePinUnpinEvent(const ShelfItem& item, bool pinned);

// Overridden from ui::EventHandler:
void OnGestureEvent(ui::GestureEvent* event) override;
Expand Down
13 changes: 11 additions & 2 deletions ui/strings/ui_strings.grd
Original file line number Diff line number Diff line change
Expand Up @@ -865,10 +865,10 @@ need to be translated for each locale.-->
Expand to all apps
</message>
<message name="IDS_APP_LIST_ALL_APPS_ACCESSIBILITY_ANNOUNCEMENT" desc="The accessibility announcement that notifies users that all of their apps are showing, as opposed to showing only suggested apps">
Launcher, all apps
Launcher, all apps
</message>
<message name="IDS_APP_LIST_SUGGESTED_APPS_ACCESSIBILITY_ANNOUNCEMENT" desc="The accessibility announcement that notifies users that the UI is showing a small version of the app list">
Launcher, partial view
Launcher, partial view
</message>
<message name="IDS_APP_LIST_CLEAR_SEARCHBOX" desc="Tooltip for the button that clears all text from the search box in the app list.">
Clear searchbox text
Expand All @@ -891,6 +891,15 @@ need to be translated for each locale.-->
<message name="IDS_SHELF_STATE_AUTO_HIDE" desc="Accessibility announcement notifying users that the shelf will now hide itself automatically">
Shelf auto hidden
</message>
<message name="IDS_SHELF_ITEM_GENERIC_NAME" desc="The generic name of a shelf item, in situations where it does not have an explicit title">
Shelf item
</message>
<message name="IDS_SHELF_ITEM_WAS_PINNED" desc="Accessibility announcement notifying users that an item was pinned to the shelf">
<ph name="ITEM_TITLE">$1<ex>Files</ex></ph> was pinned
</message>
<message name="IDS_SHELF_ITEM_WAS_UNPINNED" desc="Accessibility announcement notifying users that an item was un-pinned from the shelf">
<ph name="ITEM_TITLE">$1<ex>Files</ex></ph> was un-pinned
</message>
<message name="IDS_SHELF_NEXT" desc="Tooltip for the shelf arrow button that scrolls the shelf forward">
Next
</message>
Expand Down

0 comments on commit e793566

Please sign in to comment.