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.toolbar; | 5 package org.chromium.chrome.browser.toolbar; |
6 | 6 |
7 import android.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
8 import android.content.Context; | 8 import android.content.Context; |
9 import android.graphics.Canvas; | 9 import android.graphics.Canvas; |
10 import android.graphics.Rect; | 10 import android.graphics.Rect; |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 (ViewGroup) getRootView().findViewById(R.id.control_containe
r); | 219 (ViewGroup) getRootView().findViewById(R.id.control_containe
r); |
220 int progressBarPosition = UiUtils.insertAfter( | 220 int progressBarPosition = UiUtils.insertAfter( |
221 controlContainer, mProgressBar, (View) getParent()); | 221 controlContainer, mProgressBar, (View) getParent()); |
222 assert progressBarPosition >= 0; | 222 assert progressBarPosition >= 0; |
223 } | 223 } |
224 } | 224 } |
225 | 225 |
226 /** | 226 /** |
227 * Shows the content description toast for items on the toolbar. | 227 * Shows the content description toast for items on the toolbar. |
228 * @param view The view to anchor the toast. | 228 * @param view The view to anchor the toast. |
229 * @param stringResId The resource id for the string in the toast. | 229 * @param description The string shown in the toast. |
230 * @return Whether a toast has been shown successfully. | 230 * @return Whether a toast has been shown successfully. |
231 */ | 231 */ |
232 protected boolean showAccessibilityToast(View view, int stringResId) { | 232 protected boolean showAccessibilityToast(View view, CharSequence description
) { |
233 if (stringResId == 0) return false; | 233 if (description == null) return false; |
234 | 234 |
235 final int screenWidth = getResources().getDisplayMetrics().widthPixels; | 235 final int screenWidth = getResources().getDisplayMetrics().widthPixels; |
236 final int[] screenPos = new int[2]; | 236 final int[] screenPos = new int[2]; |
237 view.getLocationOnScreen(screenPos); | 237 view.getLocationOnScreen(screenPos); |
238 final int width = view.getWidth(); | 238 final int width = view.getWidth(); |
239 | 239 |
240 Toast toast = Toast.makeText( | 240 Toast toast = Toast.makeText(getContext(), description, Toast.LENGTH_SHO
RT); |
241 getContext(), getResources().getString(stringResId), Toast.LENGT
H_SHORT); | |
242 toast.setGravity( | 241 toast.setGravity( |
243 Gravity.TOP | Gravity.END, | 242 Gravity.TOP | Gravity.END, |
244 screenWidth - screenPos[0] - width / 2, | 243 screenWidth - screenPos[0] - width / 2, |
245 getHeight()); | 244 getHeight()); |
246 toast.show(); | 245 toast.show(); |
247 return true; | 246 return true; |
248 } | 247 } |
249 | 248 |
250 /** | 249 /** |
251 * @return The provider for toolbar related data. | 250 * @return The provider for toolbar related data. |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 */ | 377 */ |
379 protected void onPrimaryColorChanged() { } | 378 protected void onPrimaryColorChanged() { } |
380 | 379 |
381 /** | 380 /** |
382 * Sets the icon drawable that the close button in the toolbar (if any) shou
ld show. | 381 * Sets the icon drawable that the close button in the toolbar (if any) shou
ld show. |
383 */ | 382 */ |
384 public void setCloseButtonImageResource(Drawable drawable) { } | 383 public void setCloseButtonImageResource(Drawable drawable) { } |
385 | 384 |
386 /** | 385 /** |
387 * Adds a custom action button to the {@link ToolbarLayout} if it is support
ed. | 386 * Adds a custom action button to the {@link ToolbarLayout} if it is support
ed. |
| 387 * @param description The content description for the button. |
| 388 * @param listener The {@link OnClickListener} to use for clicks to the
button. |
388 * @param buttonSource The {@link Bitmap} resource to use as the source for
the button. | 389 * @param buttonSource The {@link Bitmap} resource to use as the source for
the button. |
389 * @param listener The {@link OnClickListener} to use for clicks to the butt
on. | |
390 */ | 390 */ |
391 public void addCustomActionButton(Drawable drawable, OnClickListener listene
r) { } | 391 public void addCustomActionButton(Drawable drawable, String description, |
| 392 OnClickListener listener) { } |
392 | 393 |
393 /** | 394 /** |
394 * Triggered when the content view for the specified tab has changed. | 395 * Triggered when the content view for the specified tab has changed. |
395 */ | 396 */ |
396 protected void onTabContentViewChanged() { | 397 protected void onTabContentViewChanged() { |
397 NewTabPage ntp = getToolbarDataProvider().getNewTabPageForCurrentTab(); | 398 NewTabPage ntp = getToolbarDataProvider().getNewTabPageForCurrentTab(); |
398 if (ntp != null) getLocationBar().onTabLoadingNTP(ntp); | 399 if (ntp != null) getLocationBar().onTabLoadingNTP(ntp); |
399 } | 400 } |
400 | 401 |
401 @Override | 402 @Override |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 } | 587 } |
587 | 588 |
588 /** | 589 /** |
589 * Opens hompage in the current tab. | 590 * Opens hompage in the current tab. |
590 */ | 591 */ |
591 protected void openHomepage() { | 592 protected void openHomepage() { |
592 getLocationBar().hideSuggestions(); | 593 getLocationBar().hideSuggestions(); |
593 if (mToolbarTabController != null) mToolbarTabController.openHomepage(); | 594 if (mToolbarTabController != null) mToolbarTabController.openHomepage(); |
594 } | 595 } |
595 } | 596 } |
OLD | NEW |