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 package org.chromium.chrome.browser.appmenu; | 5 package org.chromium.chrome.browser.appmenu; |
6 | 6 |
7 import android.animation.Animator; | 7 import android.animation.Animator; |
8 import android.animation.AnimatorListenerAdapter; | 8 import android.animation.AnimatorListenerAdapter; |
9 import android.animation.AnimatorSet; | 9 import android.animation.AnimatorSet; |
10 import android.animation.ObjectAnimator; | 10 import android.animation.ObjectAnimator; |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 @Override | 161 @Override |
162 public void onClick(View v) { | 162 public void onClick(View v) { |
163 mAppMenu.onItemClick(item); | 163 mAppMenu.onItemClick(item); |
164 } | 164 } |
165 }); | 165 }); |
166 // Set up the icon. | 166 // Set up the icon. |
167 Drawable icon = item.getIcon(); | 167 Drawable icon = item.getIcon(); |
168 holder.image.setImageDrawable(icon); | 168 holder.image.setImageDrawable(icon); |
169 holder.image.setVisibility(icon == null ? View.GONE : View.VISIB
LE); | 169 holder.image.setVisibility(icon == null ? View.GONE : View.VISIB
LE); |
170 holder.image.setChecked(item.isChecked()); | 170 holder.image.setChecked(item.isChecked()); |
| 171 holder.text.setText(item.getTitle()); |
| 172 holder.text.setContentDescription(item.getTitleCondensed()); |
171 | 173 |
172 holder.text.setText(item.getTitle()); | |
173 boolean isEnabled = item.isEnabled(); | 174 boolean isEnabled = item.isEnabled(); |
174 // Set the text color (using a color state list). | 175 // Set the text color (using a color state list). |
175 holder.text.setEnabled(isEnabled); | 176 holder.text.setEnabled(isEnabled); |
176 // This will ensure that the item is not highlighted when select
ed. | 177 // This will ensure that the item is not highlighted when select
ed. |
177 convertView.setEnabled(isEnabled); | 178 convertView.setEnabled(isEnabled); |
178 break; | 179 break; |
179 } | 180 } |
180 case TWO_BUTTON_MENU_ITEM: { | 181 case TWO_BUTTON_MENU_ITEM: { |
181 TwoButtonMenuItemViewHolder holder = null; | 182 TwoButtonMenuItemViewHolder holder = null; |
182 if (convertView == null) { | 183 if (convertView == null) { |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 } | 302 } |
302 return convertView; | 303 return convertView; |
303 } | 304 } |
304 | 305 |
305 private void setupImageButton(ImageButton button, final MenuItem item) { | 306 private void setupImageButton(ImageButton button, final MenuItem item) { |
306 // Store and recover the level of image as button.setimageDrawable | 307 // Store and recover the level of image as button.setimageDrawable |
307 // resets drawable to default level. | 308 // resets drawable to default level. |
308 int currentLevel = item.getIcon().getLevel(); | 309 int currentLevel = item.getIcon().getLevel(); |
309 button.setImageDrawable(item.getIcon()); | 310 button.setImageDrawable(item.getIcon()); |
310 item.getIcon().setLevel(currentLevel); | 311 item.getIcon().setLevel(currentLevel); |
311 button.setContentDescription(item.getTitle()); | |
312 button.setEnabled(item.isEnabled()); | 312 button.setEnabled(item.isEnabled()); |
313 button.setFocusable(item.isEnabled()); | 313 button.setFocusable(item.isEnabled()); |
| 314 button.setContentDescription(item.getTitleCondensed()); |
| 315 |
314 button.setOnClickListener(new OnClickListener() { | 316 button.setOnClickListener(new OnClickListener() { |
315 @Override | 317 @Override |
316 public void onClick(View v) { | 318 public void onClick(View v) { |
317 mAppMenu.onItemClick(item); | 319 mAppMenu.onItemClick(item); |
318 } | 320 } |
319 }); | 321 }); |
320 } | 322 } |
321 | 323 |
322 private void setupMenuButton(ImageButton button) { | 324 private void setupMenuButton(ImageButton button) { |
323 button.setImageResource(R.drawable.btn_menu_pressed); | 325 button.setImageResource(R.drawable.btn_menu_pressed); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 | 431 |
430 static class FourButtonMenuItemViewHolder { | 432 static class FourButtonMenuItemViewHolder { |
431 public ImageButton[] buttons = new ImageButton[4]; | 433 public ImageButton[] buttons = new ImageButton[4]; |
432 } | 434 } |
433 | 435 |
434 static class TitleButtonMenuItemViewHolder { | 436 static class TitleButtonMenuItemViewHolder { |
435 public TextView title; | 437 public TextView title; |
436 public ImageButton button; | 438 public ImageButton button; |
437 } | 439 } |
438 } | 440 } |
OLD | NEW |