OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 package org.chromium.chrome.browser.bookmarks; | 5 package org.chromium.chrome.browser.bookmarks; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.preference.PreferenceManager; | 8 import android.preference.PreferenceManager; |
9 import android.support.v7.widget.Toolbar; | 9 import android.support.v7.widget.Toolbar; |
10 import android.text.Editable; | 10 import android.text.Editable; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 super(context, attrs); | 59 super(context, attrs); |
60 } | 60 } |
61 | 61 |
62 @Override | 62 @Override |
63 protected void onFinishInflate() { | 63 protected void onFinishInflate() { |
64 super.onFinishInflate(); | 64 super.onFinishInflate(); |
65 mResultEmptySwitcher = (ViewSwitcher) findViewById(R.id.result_empty
_switcher); | 65 mResultEmptySwitcher = (ViewSwitcher) findViewById(R.id.result_empty
_switcher); |
66 } | 66 } |
67 | 67 |
68 void showHistory() { | 68 void showHistory() { |
69 if (getCurrentView().getId() == R.id.eb_history_list) return; | 69 if (getCurrentView().getId() == R.id.bookmark_history_list) return; |
70 showNext(); | 70 showNext(); |
71 } | 71 } |
72 | 72 |
73 void showResult() { | 73 void showResult() { |
74 if (getCurrentView().getId() == R.id.eb_history_list) showNext(); | 74 if (getCurrentView().getId() == R.id.bookmark_history_list) showNext
(); |
75 if (mResultEmptySwitcher.getCurrentView().getId() == R.id.eb_search_
empty_view) { | 75 if (mResultEmptySwitcher.getCurrentView().getId() == R.id.bookmark_s
earch_empty_view) { |
76 mResultEmptySwitcher.showNext(); | 76 mResultEmptySwitcher.showNext(); |
77 } | 77 } |
78 } | 78 } |
79 | 79 |
80 void showEmpty() { | 80 void showEmpty() { |
81 if (getCurrentView().getId() == R.id.eb_history_list) showNext(); | 81 if (getCurrentView().getId() == R.id.bookmark_history_list) showNext
(); |
82 if (mResultEmptySwitcher.getCurrentView().getId() == R.id.eb_result_
list) { | 82 if (mResultEmptySwitcher.getCurrentView().getId() == R.id.bookmark_r
esult_list) { |
83 mResultEmptySwitcher.showNext(); | 83 mResultEmptySwitcher.showNext(); |
84 } | 84 } |
85 } | 85 } |
86 } | 86 } |
87 | 87 |
88 private static enum UIState {HISTORY, RESULT, EMPTY} | 88 private static enum UIState {HISTORY, RESULT, EMPTY} |
89 | 89 |
90 private static final String PREF_SEARCH_HISTORY = "bookmark_search_history"; | 90 private static final String PREF_SEARCH_HISTORY = "bookmark_search_history"; |
91 private static final int SEARCH_HISTORY_MAX_ENTRIES = 10; | 91 private static final int SEARCH_HISTORY_MAX_ENTRIES = 10; |
92 private static final int HISTORY_ITEM_PADDING_START_DP = 72; | 92 private static final int HISTORY_ITEM_PADDING_START_DP = 72; |
(...skipping 28 matching lines...) Expand all Loading... |
121 /** | 121 /** |
122 * Constructor for inflating from XML. | 122 * Constructor for inflating from XML. |
123 */ | 123 */ |
124 public BookmarkSearchView(Context context, AttributeSet attrs) { | 124 public BookmarkSearchView(Context context, AttributeSet attrs) { |
125 super(context, attrs); | 125 super(context, attrs); |
126 } | 126 } |
127 | 127 |
128 @Override | 128 @Override |
129 protected void onFinishInflate() { | 129 protected void onFinishInflate() { |
130 super.onFinishInflate(); | 130 super.onFinishInflate(); |
131 mSearchText = (EditText) findViewById(R.id.eb_search_text); | 131 mSearchText = (EditText) findViewById(R.id.bookmark_search_text); |
132 mResultList = (ListView) findViewById(R.id.eb_result_list); | 132 mResultList = (ListView) findViewById(R.id.bookmark_result_list); |
133 mHistoryList = (ListView) findViewById(R.id.eb_history_list); | 133 mHistoryList = (ListView) findViewById(R.id.bookmark_history_list); |
134 mHistoryResultSwitcher = (HistoryResultSwitcher) findViewById(R.id.histo
ry_result_switcher); | 134 mHistoryResultSwitcher = (HistoryResultSwitcher) findViewById(R.id.histo
ry_result_switcher); |
135 | 135 |
136 Toolbar searchBar = (Toolbar) findViewById(R.id.search_bar); | 136 Toolbar searchBar = (Toolbar) findViewById(R.id.search_bar); |
137 searchBar.setNavigationIcon(R.drawable.eb_back_normal); | 137 searchBar.setNavigationIcon(R.drawable.bookmark_back_normal); |
138 searchBar.setNavigationContentDescription(R.string.accessibility_toolbar
_btn_back); | 138 searchBar.setNavigationContentDescription(R.string.accessibility_toolbar
_btn_back); |
139 searchBar.setNavigationOnClickListener(new OnClickListener() { | 139 searchBar.setNavigationOnClickListener(new OnClickListener() { |
140 @Override | 140 @Override |
141 public void onClick(View v) { | 141 public void onClick(View v) { |
142 onBackPressed(); | 142 onBackPressed(); |
143 } | 143 } |
144 }); | 144 }); |
145 | 145 |
146 mHistoryList.setOnItemClickListener(this); | 146 mHistoryList.setOnItemClickListener(this); |
147 mSearchText.setOnEditorActionListener(this); | 147 mSearchText.setOnEditorActionListener(this); |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 @Override | 388 @Override |
389 public long getItemId(int position) { | 389 public long getItemId(int position) { |
390 return position; | 390 return position; |
391 } | 391 } |
392 | 392 |
393 @Override | 393 @Override |
394 public View getView(int position, View convertView, ViewGroup parent) { | 394 public View getView(int position, View convertView, ViewGroup parent) { |
395 final BookmarkMatch bookmarkMatch = getItem(position); | 395 final BookmarkMatch bookmarkMatch = getItem(position); |
396 if (convertView == null) { | 396 if (convertView == null) { |
397 convertView = LayoutInflater.from(parent.getContext()).inflate( | 397 convertView = LayoutInflater.from(parent.getContext()).inflate( |
398 R.layout.eb_search_row, parent, false); | 398 R.layout.bookmark_search_row, parent, false); |
399 } | 399 } |
400 final BookmarkSearchRow row = (BookmarkSearchRow) convertView; | 400 final BookmarkSearchRow row = (BookmarkSearchRow) convertView; |
401 row.onBookmarkDelegateInitialized(mDelegate); | 401 row.onBookmarkDelegateInitialized(mDelegate); |
402 row.setBookmarkId(bookmarkMatch.getBookmarkId()); | 402 row.setBookmarkId(bookmarkMatch.getBookmarkId()); |
403 row.setSearchHistoryDelegate(BookmarkSearchView.this); | 403 row.setSearchHistoryDelegate(BookmarkSearchView.this); |
404 return convertView; | 404 return convertView; |
405 } | 405 } |
406 } | 406 } |
407 } | 407 } |
OLD | NEW |