1 /*
2  * Copyright (C) 2017 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 static androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP;
20 
21 import android.content.res.ColorStateList;
22 import android.graphics.PorterDuff;
23 
24 import androidx.annotation.Nullable;
25 import androidx.annotation.RestrictTo;
26 
27 /**
28  * Interface which allows an {@link android.widget.ImageView} to receive image tinting calls
29  * from {@link ImageViewCompat} when running on API v20 devices or lower.
30  *
31  * @hide Internal use only
32  */
33 @RestrictTo(LIBRARY_GROUP)
34 public interface TintableImageSourceView {
35 
36     /**
37      * Applies a tint to the image drawable. Does not modify the current tint
38      * mode, which is {@link PorterDuff.Mode#SRC_IN} by default.
39      * <p>
40      * Subsequent calls to the source's image will automatically
41      * mutate the drawable and apply the specified tint and tint mode.
42      *
43      * @param tint the tint to apply, may be {@code null} to clear tint
44      *
45      * @see #getSupportImageTintList()
46      */
setSupportImageTintList(@ullable ColorStateList tint)47     void setSupportImageTintList(@Nullable ColorStateList tint);
48 
49     /**
50      * Return the tint applied to the image drawable, if specified.
51      *
52      * @return the tint applied to the image drawable
53      */
54     @Nullable
getSupportImageTintList()55     ColorStateList getSupportImageTintList();
56 
57     /**
58      * Specifies the blending mode used to apply the tint specified by
59      * {@link #setSupportImageTintList(ColorStateList)}} to the image
60      * drawable. The default mode is {@link PorterDuff.Mode#SRC_IN}.
61      *
62      * @param tintMode the blending mode used to apply the tint, may be
63      *                 {@code null} to clear tint
64      * @see #getSupportImageTintMode()
65      */
setSupportImageTintMode(@ullable PorterDuff.Mode tintMode)66     void setSupportImageTintMode(@Nullable PorterDuff.Mode tintMode);
67 
68     /**
69      * Return the blending mode used to apply the tint to the image
70      * drawable, if specified.
71      *
72      * @return the blending mode used to apply the tint to the image drawable
73      */
74     @Nullable
getSupportImageTintMode()75     PorterDuff.Mode getSupportImageTintMode();
76 }
77