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; | 5 package org.chromium.chrome.browser; |
6 | 6 |
7 import android.app.Activity; | 7 import android.app.Activity; |
8 import android.app.Dialog; | 8 import android.app.Dialog; |
9 import android.content.Context; | 9 import android.content.Context; |
10 import android.content.DialogInterface; | 10 import android.content.DialogInterface; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 } | 63 } |
64 | 64 |
65 /** | 65 /** |
66 * A class representing one data row in the picker. | 66 * A class representing one data row in the picker. |
67 */ | 67 */ |
68 public static class ItemChooserRow { | 68 public static class ItemChooserRow { |
69 private final String mKey; | 69 private final String mKey; |
70 private String mDescription; | 70 private String mDescription; |
71 private Drawable mIcon; | 71 private Drawable mIcon; |
72 private String mIconDescription; | 72 private String mIconDescription; |
| 73 private int mIconLevel; |
73 | 74 |
74 public ItemChooserRow(String key, String description, @Nullable Drawable
icon, | 75 public ItemChooserRow(String key, String description, @Nullable Drawable
icon, |
75 @Nullable String iconDescription) { | 76 @Nullable String iconDescription) { |
76 mKey = key; | 77 mKey = key; |
77 mDescription = description; | 78 mDescription = description; |
78 mIcon = icon; | 79 mIcon = icon; |
79 mIconDescription = iconDescription; | 80 mIconDescription = iconDescription; |
| 81 mIconLevel = icon.getLevel(); |
80 } | 82 } |
81 | 83 |
82 /** | 84 /** |
83 * Returns true if all parameters match the corresponding member. | 85 * Returns true if all parameters match the corresponding member. |
84 * | 86 * |
85 * @param key Expected item unique identifier. | 87 * @param key Expected item unique identifier. |
86 * @param description Expected item description. | 88 * @param description Expected item description. |
87 * @param icon Expected item icon. | 89 * @param icon Expected item icon. |
88 */ | 90 */ |
89 public boolean hasSameContents(String key, String description, @Nullable
Drawable icon, | 91 public boolean hasSameContents(String key, String description, @Nullable
Drawable icon, |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 // If there is at least one item with an icon then we set mImageView
's | 350 // If there is at least one item with an icon then we set mImageView
's |
349 // visibility to INVISIBLE for all items with no icons. We do this | 351 // visibility to INVISIBLE for all items with no icons. We do this |
350 // so that all items' desriptions are aligned. | 352 // so that all items' desriptions are aligned. |
351 if (!mHasIcon) { | 353 if (!mHasIcon) { |
352 row.mImageView.setVisibility(View.GONE); | 354 row.mImageView.setVisibility(View.GONE); |
353 } else { | 355 } else { |
354 ItemChooserRow item = getItem(position); | 356 ItemChooserRow item = getItem(position); |
355 if (item.mIcon != null) { | 357 if (item.mIcon != null) { |
356 row.mImageView.setContentDescription(item.mIconDescription); | 358 row.mImageView.setContentDescription(item.mIconDescription); |
357 row.mImageView.setImageDrawable(item.mIcon); | 359 row.mImageView.setImageDrawable(item.mIcon); |
| 360 row.mImageView.setImageLevel(item.mIconLevel); |
358 row.mImageView.setVisibility(View.VISIBLE); | 361 row.mImageView.setVisibility(View.VISIBLE); |
359 } else { | 362 } else { |
360 row.mImageView.setVisibility(View.INVISIBLE); | 363 row.mImageView.setVisibility(View.INVISIBLE); |
361 row.mImageView.setImageDrawable(null); | 364 row.mImageView.setImageDrawable(null); |
362 row.mImageView.setContentDescription(null); | 365 row.mImageView.setContentDescription(null); |
363 } | 366 } |
364 row.mImageView.setSelected(position == mSelectedItem); | 367 row.mImageView.setSelected(position == mSelectedItem); |
365 } | 368 } |
366 return convertView; | 369 return convertView; |
367 } | 370 } |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 } | 684 } |
682 | 685 |
683 /** | 686 /** |
684 * Returns the ItemAdapter associated with this class. For use with tests on
ly. | 687 * Returns the ItemAdapter associated with this class. For use with tests on
ly. |
685 */ | 688 */ |
686 @VisibleForTesting | 689 @VisibleForTesting |
687 public ItemAdapter getItemAdapterForTesting() { | 690 public ItemAdapter getItemAdapterForTesting() { |
688 return mItemAdapter; | 691 return mItemAdapter; |
689 } | 692 } |
690 } | 693 } |
OLD | NEW |