| 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.widget; | 5 package org.chromium.chrome.browser.widget; |
| 6 | 6 |
| 7 import android.animation.AnimatorInflater; | 7 import android.animation.AnimatorInflater; |
| 8 import android.annotation.TargetApi; | 8 import android.annotation.TargetApi; |
| 9 import android.content.Context; | 9 import android.content.Context; |
| 10 import android.content.res.ColorStateList; | 10 import android.content.res.ColorStateList; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 * | 31 * |
| 32 * <org.chromium.chrome.browser.widget.ButtonCompat | 32 * <org.chromium.chrome.browser.widget.ButtonCompat |
| 33 * android:layout_width="wrap_content" | 33 * android:layout_width="wrap_content" |
| 34 * android:layout_height="wrap_content" | 34 * android:layout_height="wrap_content" |
| 35 * android:text="Click me" | 35 * android:text="Click me" |
| 36 * chrome:buttonColor="#f00" /> | 36 * chrome:buttonColor="#f00" /> |
| 37 * | 37 * |
| 38 * Note: To ensure the button's shadow is fully visible, you may need to set | 38 * Note: To ensure the button's shadow is fully visible, you may need to set |
| 39 * android:clipToPadding="false" on the button's parent view. | 39 * android:clipToPadding="false" on the button's parent view. |
| 40 */ | 40 */ |
| 41 @TargetApi(Build.VERSION_CODES.LOLLIPOP) |
| 41 public class ButtonCompat extends Button { | 42 public class ButtonCompat extends Button { |
| 42 | 43 |
| 43 private static final float PRE_L_PRESSED_BRIGHTNESS = 0.85f; | 44 private static final float PRE_L_PRESSED_BRIGHTNESS = 0.85f; |
| 44 private static final int DISABLED_COLOR = 0x1F000000; | 45 private static final int DISABLED_COLOR = 0x1F000000; |
| 45 | 46 |
| 46 private int mColor; | 47 private int mColor; |
| 47 | 48 |
| 48 /** | 49 /** |
| 49 * Returns a new borderless material-style button. | 50 * Returns a new borderless material-style button. |
| 50 */ | 51 */ |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 return DISABLED_COLOR; | 144 return DISABLED_COLOR; |
| 144 } | 145 } |
| 145 | 146 |
| 146 private static int getColorFromAttributeSet(Context context, AttributeSet at
trs) { | 147 private static int getColorFromAttributeSet(Context context, AttributeSet at
trs) { |
| 147 TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ButtonC
ompat, 0, 0); | 148 TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ButtonC
ompat, 0, 0); |
| 148 int color = a.getColor(R.styleable.ButtonCompat_buttonColor, Color.WHITE
); | 149 int color = a.getColor(R.styleable.ButtonCompat_buttonColor, Color.WHITE
); |
| 149 a.recycle(); | 150 a.recycle(); |
| 150 return color; | 151 return color; |
| 151 } | 152 } |
| 152 } | 153 } |
| OLD | NEW |