1/* 2 * Copyright (C) 2017 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 androidx.emoji.widget; 18 19import static androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP; 20 21import android.content.Context; 22import android.os.Build; 23import android.util.AttributeSet; 24import android.widget.Button; 25 26import androidx.annotation.RequiresApi; 27import androidx.annotation.RestrictTo; 28 29/** 30 * Support library implementation for ExtractButton. Used by {@link EmojiExtractViewHelper} while 31 * inflating {@link EmojiExtractEditText} for keyboard use. 32 * @hide 33 */ 34@RestrictTo(LIBRARY_GROUP) 35public class ExtractButtonCompat extends Button { 36 public ExtractButtonCompat(Context context) { 37 super(context, null); 38 } 39 40 public ExtractButtonCompat(Context context, AttributeSet attrs) { 41 super(context, attrs); 42 } 43 44 public ExtractButtonCompat(Context context, AttributeSet attrs, int defStyleAttr) { 45 super(context, attrs, defStyleAttr); 46 } 47 48 @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) 49 public ExtractButtonCompat(Context context, AttributeSet attrs, int defStyleAttr, 50 int defStyleRes) { 51 super(context, attrs, defStyleAttr, defStyleRes); 52 } 53 54 /** 55 * Pretend like the window this view is in always has focus, so it will 56 * highlight when selected. 57 */ 58 @Override 59 public boolean hasWindowFocus() { 60 return isEnabled() && getVisibility() == VISIBLE ? true : false; 61 } 62} 63