1/* 2 * Copyright (C) 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 17package com.android.dialer.widget; 18 19import android.content.Context; 20import android.support.annotation.Nullable; 21import android.support.design.widget.FloatingActionButton; 22import android.util.AttributeSet; 23import com.android.dialer.common.Assert; 24 25/** 26 * Since {@link FloatingActionButton} is possibly the worst widget supported by the framework, we 27 * need this class to work around several of it's bugs. 28 * 29 * <p>Current fixes: 30 * 31 * <ul> 32 * <li>Being able to trigger click events twice. 33 * <li>Banning setVisibility since 9 times out of 10, it just causes bad state. 34 * </ul> 35 * 36 * Planned fixes: 37 * 38 * <ul> 39 * <li>Animating on first show/hide 40 * <li>Being able to call show/hide rapidly and being in the proper state 41 * <li>Having a proper 48x48 touch target in mini mode 42 * </ul> 43 */ 44public class DialerFloatingActionButton extends FloatingActionButton { 45 46 public DialerFloatingActionButton(Context context, AttributeSet attributeSet) { 47 super(context, attributeSet); 48 } 49 50 @Override 51 public void show() { 52 super.show(); 53 setClickable(true); 54 } 55 56 @Override 57 public void show(@Nullable OnVisibilityChangedListener onVisibilityChangedListener) { 58 super.show(onVisibilityChangedListener); 59 setClickable(true); 60 } 61 62 @Override 63 public void hide() { 64 super.hide(); 65 setClickable(false); 66 } 67 68 @Override 69 public void hide(@Nullable OnVisibilityChangedListener onVisibilityChangedListener) { 70 super.hide(onVisibilityChangedListener); 71 setClickable(false); 72 } 73 74 @Override 75 public void setVisibility(int i) { 76 throw Assert.createUnsupportedOperationFailException( 77 "Do not call setVisibility, call show/hide instead"); 78 } 79} 80