1 /* 2 * Copyright (C) 2015 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.systemui.statusbar; 18 19 import android.content.Context; 20 import android.util.AttributeSet; 21 import android.widget.Button; 22 23 import com.android.systemui.animation.LaunchableView; 24 import com.android.systemui.animation.LaunchableViewDelegate; 25 26 import kotlin.Unit; 27 28 /** 29 * A Button which doesn't have overlapping drawing commands 30 */ 31 public class AlphaOptimizedButton extends Button implements LaunchableView { 32 private LaunchableViewDelegate mDelegate = new LaunchableViewDelegate(this, 33 (visibility) -> { 34 super.setVisibility(visibility); 35 return Unit.INSTANCE; 36 }); 37 AlphaOptimizedButton(Context context)38 public AlphaOptimizedButton(Context context) { 39 super(context); 40 } 41 AlphaOptimizedButton(Context context, AttributeSet attrs)42 public AlphaOptimizedButton(Context context, AttributeSet attrs) { 43 super(context, attrs); 44 } 45 AlphaOptimizedButton(Context context, AttributeSet attrs, int defStyleAttr)46 public AlphaOptimizedButton(Context context, AttributeSet attrs, int defStyleAttr) { 47 super(context, attrs, defStyleAttr); 48 } 49 AlphaOptimizedButton(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)50 public AlphaOptimizedButton(Context context, AttributeSet attrs, int defStyleAttr, 51 int defStyleRes) { 52 super(context, attrs, defStyleAttr, defStyleRes); 53 } 54 55 @Override hasOverlappingRendering()56 public boolean hasOverlappingRendering() { 57 return false; 58 } 59 60 @Override setShouldBlockVisibilityChanges(boolean block)61 public void setShouldBlockVisibilityChanges(boolean block) { 62 mDelegate.setShouldBlockVisibilityChanges(block); 63 } 64 65 @Override setVisibility(int visibility)66 public void setVisibility(int visibility) { 67 mDelegate.setVisibility(visibility); 68 } 69 } 70