Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/app_list/views/search_result_tile_item_list_view.h" | 5 #include "ui/app_list/views/search_result_tile_item_list_view.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "ui/app_list/app_list_constants.h" | 10 #include "ui/app_list/app_list_constants.h" |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 constexpr SkColor kSeparatorColor = SkColorSetARGBMacro(0x1F, 0x00, 0x00, 0x00); | 38 constexpr SkColor kSeparatorColor = SkColorSetARGBMacro(0x1F, 0x00, 0x00, 0x00); |
| 39 | 39 |
| 40 } // namespace | 40 } // namespace |
| 41 | 41 |
| 42 namespace app_list { | 42 namespace app_list { |
| 43 | 43 |
| 44 SearchResultTileItemListView::SearchResultTileItemListView( | 44 SearchResultTileItemListView::SearchResultTileItemListView( |
| 45 views::Textfield* search_box, | 45 views::Textfield* search_box, |
| 46 AppListViewDelegate* view_delegate) | 46 AppListViewDelegate* view_delegate) |
| 47 : search_box_(search_box), | 47 : search_box_(search_box), |
| 48 is_play_store_app_search_enabled_( | 48 is_play_store_app_search_enabled_( |
|
khmel
2017/07/17 17:16:12
Q: I think this is not enough to check.
This featu
Jiaquan He
2017/07/18 03:32:45
Yes. We only enable this feature in the new launch
| |
| 49 features::IsPlayStoreAppSearchEnabled()) { | 49 features::IsPlayStoreAppSearchEnabled()) { |
| 50 if (is_play_store_app_search_enabled_) { | 50 if (is_play_store_app_search_enabled_) { |
| 51 SetLayoutManager(new views::BoxLayout( | 51 SetLayoutManager(new views::BoxLayout( |
| 52 views::BoxLayout::kHorizontal, | 52 views::BoxLayout::kHorizontal, |
| 53 gfx::Insets(kItemListVerticalSpacing, kItemListHorizontalSpacing), | 53 gfx::Insets(kItemListVerticalSpacing, kItemListHorizontalSpacing), |
| 54 kBetweenItemSpacing)); | 54 kBetweenItemSpacing)); |
| 55 for (size_t i = 0; i < kMaxNumSearchResultTiles; ++i) { | 55 for (size_t i = 0; i < kMaxNumSearchResultTiles; ++i) { |
| 56 views::Separator* separator = new views::Separator; | 56 views::Separator* separator = new views::Separator; |
| 57 separator->SetVisible(false); | 57 separator->SetVisible(false); |
| 58 separator->SetBorder(views::CreateEmptyBorder( | 58 separator->SetBorder(views::CreateEmptyBorder( |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 if (old_selected >= 0) | 162 if (old_selected >= 0) |
| 163 tile_views_[old_selected]->SetSelected(false); | 163 tile_views_[old_selected]->SetSelected(false); |
| 164 | 164 |
| 165 if (new_selected >= 0) { | 165 if (new_selected >= 0) { |
| 166 tile_views_[new_selected]->SetSelected(true); | 166 tile_views_[new_selected]->SetSelected(true); |
| 167 ScrollRectToVisible(GetLocalBounds()); | 167 ScrollRectToVisible(GetLocalBounds()); |
| 168 } | 168 } |
| 169 } | 169 } |
| 170 | 170 |
| 171 bool SearchResultTileItemListView::OnKeyPressed(const ui::KeyEvent& event) { | 171 bool SearchResultTileItemListView::OnKeyPressed(const ui::KeyEvent& event) { |
| 172 if (selected_index() >= 0 && child_at(selected_index())->OnKeyPressed(event)) | 172 int selection_index = selected_index(); |
| 173 // Also count the separator when Play Store app search feature is enabled. | |
| 174 int child_index = is_play_store_app_search_enabled_ ? selection_index * 2 + 1 | |
| 175 : selection_index; | |
| 176 if (selection_index >= 0 && child_at(child_index)->OnKeyPressed(event)) | |
| 173 return true; | 177 return true; |
| 174 | 178 |
| 175 int dir = 0; | 179 int dir = 0; |
| 176 bool cursor_at_end_of_searchbox = | 180 bool cursor_at_end_of_searchbox = |
| 177 search_box_->GetCursorPosition() == search_box_->text().length(); | 181 search_box_->GetCursorPosition() == search_box_->text().length(); |
| 178 const int forward_dir = base::i18n::IsRTL() ? -1 : 1; | 182 const int forward_dir = base::i18n::IsRTL() ? -1 : 1; |
| 179 switch (event.key_code()) { | 183 switch (event.key_code()) { |
| 180 case ui::VKEY_TAB: | 184 case ui::VKEY_TAB: |
| 181 if (event.IsShiftDown()) | 185 if (event.IsShiftDown()) |
| 182 dir = -1; | 186 dir = -1; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 197 // text. | 201 // text. |
| 198 if (cursor_at_end_of_searchbox) | 202 if (cursor_at_end_of_searchbox) |
| 199 dir = forward_dir; | 203 dir = forward_dir; |
| 200 break; | 204 break; |
| 201 default: | 205 default: |
| 202 break; | 206 break; |
| 203 } | 207 } |
| 204 if (dir == 0) | 208 if (dir == 0) |
| 205 return false; | 209 return false; |
| 206 | 210 |
| 207 int selection_index = selected_index() + dir; | 211 selection_index = selection_index + dir; |
| 208 if (IsValidSelectionIndex(selection_index)) { | 212 if (IsValidSelectionIndex(selection_index)) { |
| 209 SetSelectedIndex(selection_index); | 213 SetSelectedIndex(selection_index); |
| 210 return true; | 214 return true; |
| 211 } | 215 } |
| 212 | 216 |
| 213 return false; | 217 return false; |
| 214 } | 218 } |
| 215 | 219 |
| 216 } // namespace app_list | 220 } // namespace app_list |
| OLD | NEW |