OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.chromoting; |
| 6 |
| 7 import android.content.Context; |
| 8 import android.graphics.PorterDuff; |
| 9 import android.graphics.drawable.Drawable; |
| 10 import android.util.TypedValue; |
| 11 import android.view.Menu; |
| 12 |
| 13 /** Utility methods for chromoting code. */ |
| 14 public abstract class ChromotingUtil { |
| 15 /** |
| 16 * Tints all icons of a toolbar menu so they have the same color as the 'bac
k' navigation icon |
| 17 * and the three-dots overflow icon. |
| 18 * @param context Context for getting theme and resource information. |
| 19 * @param menu Menu with icons to be tinted. |
| 20 */ |
| 21 public static void tintMenuIcons(Context context, Menu menu) { |
| 22 TypedValue typedValue = new TypedValue(); |
| 23 context.getTheme().resolveAttribute(R.attr.colorControlNormal, typedValu
e, true); |
| 24 int color = context.getResources().getColor(typedValue.resourceId); |
| 25 int items = menu.size(); |
| 26 for (int i = 0; i < items; i++) { |
| 27 Drawable icon = menu.getItem(i).getIcon(); |
| 28 if (icon != null) { |
| 29 icon.mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN); |
| 30 } |
| 31 } |
| 32 } |
| 33 } |
OLD | NEW |