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 androidx.core.widget;
18 
19 import android.content.res.ColorStateList;
20 import android.graphics.PorterDuff;
21 import android.graphics.drawable.Drawable;
22 
23 import androidx.annotation.Nullable;
24 
25 /**
26  * Interface which allows a {@link android.widget.CompoundButton} to receive tinting
27  * calls from {@code CompoundButtonCompat} when running on API v20 devices or lower.
28  */
29 public interface TintableCompoundButton {
30 
31     /**
32      * Applies a tint to the button drawable. Does not modify the current tint
33      * mode, which is {@link PorterDuff.Mode#SRC_IN} by default.
34      * <p>
35      * Subsequent calls to
36      * {@link android.widget.CompoundButton#setButtonDrawable(Drawable) setButtonDrawable(Drawable)}
37      * should automatically mutate the drawable and apply the specified tint and tint mode.
38      *
39      * @param tint the tint to apply, may be {@code null} to clear tint
40      */
setSupportButtonTintList(@ullable ColorStateList tint)41     void setSupportButtonTintList(@Nullable ColorStateList tint);
42 
43     /**
44      * Returns the tint applied to the button drawable
45      *
46      * @see #setSupportButtonTintList(ColorStateList)
47      */
48     @Nullable
getSupportButtonTintList()49     ColorStateList getSupportButtonTintList();
50 
51     /**
52      * Specifies the blending mode which should be used to apply the tint specified by
53      * {@link #setSupportButtonTintList(ColorStateList)} to the button drawable. The
54      * default mode is {@link PorterDuff.Mode#SRC_IN}.
55      *
56      * @param tintMode the blending mode used to apply the tint, may be
57      *                 {@code null} to clear tint
58      *
59      * @see #getSupportButtonTintMode()
60      * @see androidx.core.graphics.drawable.DrawableCompat#setTintMode(Drawable,
61      * PorterDuff.Mode)
62      */
setSupportButtonTintMode(@ullable PorterDuff.Mode tintMode)63     void setSupportButtonTintMode(@Nullable PorterDuff.Mode tintMode);
64 
65     /**
66      * Returns the blending mode used to apply the tint to the button drawable
67      *
68      * @see #setSupportButtonTintMode(PorterDuff.Mode)
69      */
70     @Nullable
getSupportButtonTintMode()71     PorterDuff.Mode getSupportButtonTintMode();
72 }
73