135ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka/* 235ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka * Copyright (C) 2012 The Android Open Source Project 335ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka * 435ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka * Licensed under the Apache License, Version 2.0 (the "License"); you may not 535ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka * use this file except in compliance with the License. You may obtain a copy of 635ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka * the License at 735ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka * 835ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka * http://www.apache.org/licenses/LICENSE-2.0 935ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka * 1035ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka * Unless required by applicable law or agreed to in writing, software 1135ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 1235ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 1335ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka * License for the specific language governing permissions and limitations under 1435ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka * the License. 1535ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka */ 1635ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka 1735ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaokapackage com.android.inputmethod.keyboard.internal; 1835ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka 1935ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaokaimport android.content.res.TypedArray; 2035ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka 2135ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaokapublic abstract class KeyStyle { 2235ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka private final KeyboardTextsSet mTextsSet; 2335ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka 2435ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka public abstract String[] getStringArray(TypedArray a, int index); 2535ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka public abstract String getString(TypedArray a, int index); 2635ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka public abstract int getInt(TypedArray a, int index, int defaultValue); 2735ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka public abstract int getFlag(TypedArray a, int index); 2835ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka 2935ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka protected KeyStyle(final KeyboardTextsSet textsSet) { 3035ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka mTextsSet = textsSet; 3135ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka } 3235ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka 3335ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka protected String parseString(final TypedArray a, final int index) { 3435ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka if (a.hasValue(index)) { 3535ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka return KeySpecParser.resolveTextReference(a.getString(index), mTextsSet); 3635ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka } 3735ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka return null; 3835ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka } 3935ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka 4035ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka protected String[] parseStringArray(final TypedArray a, final int index) { 4135ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka if (a.hasValue(index)) { 4235ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka return KeySpecParser.parseCsvString(a.getString(index), mTextsSet); 4335ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka } 4435ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka return null; 4535ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka } 4635ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka} 47