1 /* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.support.v4.widget; 18 19 import android.content.res.ColorStateList; 20 import android.graphics.PorterDuff; 21 import android.graphics.drawable.Drawable; 22 import android.support.annotation.Nullable; 23 24 /** 25 * Interface which allows a {@link android.widget.CompoundButton} to receive tinting 26 * calls from {@code CompoundButtonCompat} when running on API v20 devices or lower. 27 */ 28 public interface TintableCompoundButton { 29 30 /** 31 * Applies a tint to the button drawable. Does not modify the current tint 32 * mode, which is {@link PorterDuff.Mode#SRC_IN} by default. 33 * <p> 34 * Subsequent calls to 35 * {@link android.widget.CompoundButton#setButtonDrawable(Drawable) setButtonDrawable(Drawable)} 36 * should automatically mutate the drawable and apply the specified tint and tint mode. 37 * 38 * @param tint the tint to apply, may be {@code null} to clear tint 39 */ setSupportButtonTintList(@ullable ColorStateList tint)40 void setSupportButtonTintList(@Nullable ColorStateList tint); 41 42 /** 43 * Returns the tint applied to the button drawable 44 * 45 * @see #setSupportButtonTintList(ColorStateList) 46 */ 47 @Nullable getSupportButtonTintList()48 ColorStateList getSupportButtonTintList(); 49 50 /** 51 * Specifies the blending mode which should be used to apply the tint specified by 52 * {@link #setSupportButtonTintList(ColorStateList)} to the button drawable. The 53 * default mode is {@link PorterDuff.Mode#SRC_IN}. 54 * 55 * @param tintMode the blending mode used to apply the tint, may be 56 * {@code null} to clear tint 57 * 58 * @see #getSupportButtonTintMode() 59 * @see android.support.v4.graphics.drawable.DrawableCompat#setTintMode(Drawable, 60 * PorterDuff.Mode) 61 */ setSupportButtonTintMode(@ullable PorterDuff.Mode tintMode)62 void setSupportButtonTintMode(@Nullable PorterDuff.Mode tintMode); 63 64 /** 65 * Returns the blending mode used to apply the tint to the button drawable 66 * 67 * @see #setSupportButtonTintMode(PorterDuff.Mode) 68 */ 69 @Nullable getSupportButtonTintMode()70 PorterDuff.Mode getSupportButtonTintMode(); 71 } 72