Home | History | Annotate | Download | only in overview
      1 /*
      2  * Copyright (c) 2016, 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 com.android.car.overview;
     18 
     19 import android.content.Context;
     20 import android.support.annotation.ColorInt;
     21 import android.util.AttributeSet;
     22 import android.widget.ImageView;
     23 import com.android.car.apps.common.FabDrawable;
     24 
     25 /**
     26  * A FAB button with an affordance for setting the accent color.
     27  */
     28 public class OverviewFabButton extends ImageView {
     29     private final FabDrawable mFabDrawable;
     30 
     31     public OverviewFabButton(Context context) {
     32         super(context);
     33     }
     34 
     35     public OverviewFabButton(Context context, AttributeSet attrs) {
     36         super(context, attrs);
     37     }
     38 
     39     public OverviewFabButton(Context context, AttributeSet attrs, int defStyleAttrs) {
     40         super(context, attrs, defStyleAttrs);
     41     }
     42 
     43     public OverviewFabButton(Context context, AttributeSet attrs, int defStyleAttrs,
     44             int defStyleRes) {
     45         super(context, attrs, defStyleAttrs, defStyleRes);
     46     }
     47 
     48     {
     49         Context context = getContext();
     50 
     51         mFabDrawable = new FabDrawable(context);
     52         setBackground(mFabDrawable);
     53     }
     54 
     55     /**
     56      * Sets the color that the FAB button will be.
     57      */
     58     public void setAccentColor(@ColorInt int color) {
     59         mFabDrawable.setFabAndStrokeColor(color);
     60     }
     61 }
     62