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.content.res.TypedArray; 23import android.util.AttributeSet; 24import android.view.View; 25 26import androidx.annotation.NonNull; 27import androidx.annotation.RestrictTo; 28import androidx.emoji.R; 29 30/** 31 * Helper class to parse EmojiCompat EditText attributes. 32 * 33 * @hide 34 */ 35@RestrictTo(LIBRARY_GROUP) 36public class EditTextAttributeHelper { 37 static final int MAX_EMOJI_COUNT = Integer.MAX_VALUE; 38 private int mMaxEmojiCount; 39 40 public EditTextAttributeHelper(@NonNull View view, AttributeSet attrs, int defStyleAttr, 41 int defStyleRes) { 42 if (attrs != null) { 43 final Context context = view.getContext(); 44 TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.EmojiEditText, 45 defStyleAttr, defStyleRes); 46 mMaxEmojiCount = a.getInteger(R.styleable.EmojiEditText_maxEmojiCount, MAX_EMOJI_COUNT); 47 a.recycle(); 48 } 49 } 50 51 public int getMaxEmojiCount() { 52 return mMaxEmojiCount; 53 } 54} 55