Home | History | Annotate | Download | only in view
      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 androidx.annotation.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 public interface TintableBackgroundView {
     29 
     30     /**
     31      * Applies a tint to the background drawable. Does not modify the current tint
     32      * mode, which is {@link PorterDuff.Mode#SRC_IN} by default.
     33      * <p>
     34      * Subsequent calls to {@code View.setBackground(Drawable)} will automatically
     35      * mutate the drawable and apply the specified tint and tint mode.
     36      *
     37      * @param tint the tint to apply, may be {@code null} to clear tint
     38      *
     39      * @see #getSupportBackgroundTintList()
     40      */
     41     void setSupportBackgroundTintList(@Nullable ColorStateList tint);
     42 
     43     /**
     44      * Return the tint applied to the background drawable, if specified.
     45      *
     46      * @return the tint applied to the background drawable
     47      */
     48     @Nullable
     49     ColorStateList getSupportBackgroundTintList();
     50 
     51     /**
     52      * Specifies the blending mode used to apply the tint specified by
     53      * {@link #setSupportBackgroundTintList(ColorStateList)}} to the background
     54      * drawable. The 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      * @see #getSupportBackgroundTintMode()
     59      */
     60     void setSupportBackgroundTintMode(@Nullable PorterDuff.Mode tintMode);
     61 
     62     /**
     63      * Return the blending mode used to apply the tint to the background
     64      * drawable, if specified.
     65      *
     66      * @return the blending mode used to apply the tint to the background
     67      *         drawable
     68      */
     69     @Nullable
     70     PorterDuff.Mode getSupportBackgroundTintMode();
     71 }
     72