Commit cab7951a authored by Tatsuhisa Yamaguchi's avatar Tatsuhisa Yamaguchi Committed by Commit Bot

Fix notification swipe control button position with RTL UI languages.

Bug: 840497
Test: manually verified
Change-Id: Id853396b9ab2b1ca88df81fa028e0783a8377fe0
Reviewed-on: https://chromium-review.googlesource.com/1201633
Commit-Queue: Tatsuhisa Yamaguchi <yamaguchi@chromium.org>
Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#588345}
parent 4d01f290
...@@ -37,12 +37,11 @@ NotificationSwipeControlView::NotificationSwipeControlView() { ...@@ -37,12 +37,11 @@ NotificationSwipeControlView::NotificationSwipeControlView() {
NotificationSwipeControlView::~NotificationSwipeControlView() = default; NotificationSwipeControlView::~NotificationSwipeControlView() = default;
void NotificationSwipeControlView::ShowButtons(bool is_right, void NotificationSwipeControlView::ShowButtons(ButtonPosition button_position,
bool show_settings, bool show_settings,
bool show_snooze) { bool show_snooze) {
views::BoxLayout* layout = static_cast<views::BoxLayout*>(GetLayoutManager()); views::BoxLayout* layout = static_cast<views::BoxLayout*>(GetLayoutManager());
if (is_right) { if ((button_position == ButtonPosition::RIGHT) != base::i18n::IsRTL()) {
// TODO: Flip the arrangement if current UI language is RTL.
layout->set_main_axis_alignment(views::BoxLayout::MAIN_AXIS_ALIGNMENT_END); layout->set_main_axis_alignment(views::BoxLayout::MAIN_AXIS_ALIGNMENT_END);
} else { } else {
layout->set_main_axis_alignment( layout->set_main_axis_alignment(
......
...@@ -28,6 +28,11 @@ class MESSAGE_CENTER_EXPORT NotificationSwipeControlView ...@@ -28,6 +28,11 @@ class MESSAGE_CENTER_EXPORT NotificationSwipeControlView
virtual void OnSnoozeButtonPressed(const ui::Event& event) = 0; virtual void OnSnoozeButtonPressed(const ui::Event& event) = 0;
}; };
// Physical positions to show buttons in the swipe control. This is invariant
// across RTL/LTR languages because buttons should be shown on one side which
// is made uncovered by the overlapping view after user's swipe action.
enum class ButtonPosition { RIGHT, LEFT };
// String to be returned by GetClassName() method. // String to be returned by GetClassName() method.
static const char kViewClassName[]; static const char kViewClassName[];
...@@ -41,7 +46,9 @@ class MESSAGE_CENTER_EXPORT NotificationSwipeControlView ...@@ -41,7 +46,9 @@ class MESSAGE_CENTER_EXPORT NotificationSwipeControlView
void ButtonPressed(views::Button* sender, const ui::Event& event) override; void ButtonPressed(views::Button* sender, const ui::Event& event) override;
// Change the visibility of the settings button. // Change the visibility of the settings button.
void ShowButtons(bool is_right, bool has_settings, bool has_snooze); void ShowButtons(ButtonPosition button_position,
bool has_settings,
bool has_snooze);
void HideButtons(); void HideButtons();
void AddObserver(Observer* observer); void AddObserver(Observer* observer);
......
...@@ -47,12 +47,14 @@ void SlidableMessageView::OnSlideChanged(const std::string& notification_id) { ...@@ -47,12 +47,14 @@ void SlidableMessageView::OnSlideChanged(const std::string& notification_id) {
if (gesture_amount == 0) { if (gesture_amount == 0) {
control_view_->HideButtons(); control_view_->HideButtons();
} else { } else {
bool on_right = gesture_amount < 0; NotificationSwipeControlView::ButtonPosition button_position =
gesture_amount < 0 ? NotificationSwipeControlView::ButtonPosition::RIGHT
: NotificationSwipeControlView::ButtonPosition::LEFT;
NotificationControlButtonsView* buttons = NotificationControlButtonsView* buttons =
message_view_->GetControlButtonsView(); message_view_->GetControlButtonsView();
bool has_settings_button = buttons->settings_button(); bool has_settings_button = buttons->settings_button();
bool has_snooze_button = buttons->snooze_button(); bool has_snooze_button = buttons->snooze_button();
control_view_->ShowButtons(on_right, has_settings_button, control_view_->ShowButtons(button_position, has_settings_button,
has_snooze_button); has_snooze_button);
} }
} }
......
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