1 /* 2 * Copyright 2018 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.view; 18 19 import android.content.res.ColorStateList; 20 import android.graphics.PorterDuff; 21 22 import org.jspecify.annotations.Nullable; 23 24 /** 25 * Interface which allows a {@link android.view.View} to receive background tinting calls from 26 * {@link ViewCompat} when running on API v20 devices or lower. 27 */ 28 /* 29 * When used with androidx.resourceinspection.annotation.AppCompatShadowedAttributes, this 30 * interface implies that AppCompat shadows the platform's background tint attributes. 31 * See androidx.resourceinspection.processor for more details and a full mapping of attributes. 32 */ 33 public interface TintableBackgroundView { 34 35 /** 36 * Applies a tint to the background drawable. Does not modify the current tint 37 * mode, which is {@link PorterDuff.Mode#SRC_IN} by default. 38 * <p> 39 * Subsequent calls to {@code View.setBackground(Drawable)} will automatically 40 * mutate the drawable and apply the specified tint and tint mode. 41 * 42 * @param tint the tint to apply, may be {@code null} to clear tint 43 * 44 * @see #getSupportBackgroundTintList() 45 */ setSupportBackgroundTintList(@ullable ColorStateList tint)46 void setSupportBackgroundTintList(@Nullable ColorStateList tint); 47 48 /** 49 * Return the tint applied to the background drawable, if specified. 50 * 51 * @return the tint applied to the background drawable 52 */ getSupportBackgroundTintList()53 @Nullable ColorStateList getSupportBackgroundTintList(); 54 55 /** 56 * Specifies the blending mode used to apply the tint specified by 57 * {@link #setSupportBackgroundTintList(ColorStateList)}} to the background 58 * drawable. The default mode is {@link PorterDuff.Mode#SRC_IN}. 59 * 60 * @param tintMode the blending mode used to apply the tint, may be 61 * {@code null} to clear tint 62 * @see #getSupportBackgroundTintMode() 63 */ setSupportBackgroundTintMode(PorterDuff.@ullable Mode tintMode)64 void setSupportBackgroundTintMode(PorterDuff.@Nullable Mode tintMode); 65 66 /** 67 * Return the blending mode used to apply the tint to the background 68 * drawable, if specified. 69 * 70 * @return the blending mode used to apply the tint to the background 71 * drawable 72 */ getSupportBackgroundTintMode()73 PorterDuff.@Nullable Mode getSupportBackgroundTintMode(); 74 } 75