135ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka/*
235ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka * Copyright (C) 2012 The Android Open Source Project
335ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka *
48aa9963a895f9dd5bb1bc92ab2e4f461e058f87aTadashi G. Takaoka * Licensed under the Apache License, Version 2.0 (the "License");
58aa9963a895f9dd5bb1bc92ab2e4f461e058f87aTadashi G. Takaoka * you may not use this file except in compliance with the License.
68aa9963a895f9dd5bb1bc92ab2e4f461e058f87aTadashi G. Takaoka * You may obtain a copy of the License at
735ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka *
88aa9963a895f9dd5bb1bc92ab2e4f461e058f87aTadashi 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
118aa9963a895f9dd5bb1bc92ab2e4f461e058f87aTadashi G. Takaoka * distributed under the License is distributed on an "AS IS" BASIS,
128aa9963a895f9dd5bb1bc92ab2e4f461e058f87aTadashi G. Takaoka * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
138aa9963a895f9dd5bb1bc92ab2e4f461e058f87aTadashi G. Takaoka * See the License for the specific language governing permissions and
148aa9963a895f9dd5bb1bc92ab2e4f461e058f87aTadashi G. Takaoka * limitations under 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
21b3fd70118119e736209173d34053974e61f936d8Tadashi G. Takaokaimport com.android.inputmethod.latin.StringUtils;
22b3fd70118119e736209173d34053974e61f936d8Tadashi G. Takaoka
2335ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaokapublic abstract class KeyStyle {
2435ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka    private final KeyboardTextsSet mTextsSet;
2535ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka
2635ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka    public abstract String[] getStringArray(TypedArray a, int index);
2735ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka    public abstract String getString(TypedArray a, int index);
2835ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka    public abstract int getInt(TypedArray a, int index, int defaultValue);
2935ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka    public abstract int getFlag(TypedArray a, int index);
3035ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka
3135ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka    protected KeyStyle(final KeyboardTextsSet textsSet) {
3235ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka        mTextsSet = textsSet;
3335ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka    }
3435ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka
3535ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka    protected String parseString(final TypedArray a, final int index) {
3635ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka        if (a.hasValue(index)) {
3735ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka            return KeySpecParser.resolveTextReference(a.getString(index), mTextsSet);
3835ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka        }
3935ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka        return null;
4035ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka    }
4135ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka
4235ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka    protected String[] parseStringArray(final TypedArray a, final int index) {
4335ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka        if (a.hasValue(index)) {
44b3fd70118119e736209173d34053974e61f936d8Tadashi G. Takaoka            final String text = KeySpecParser.resolveTextReference(a.getString(index), mTextsSet);
45b3fd70118119e736209173d34053974e61f936d8Tadashi G. Takaoka            return StringUtils.parseCsvString(text);
4635ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka        }
4735ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka        return null;
4835ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka    }
4935ff94547c16c84c5b6fafdae0b4a683be782b97Tadashi G. Takaoka}
50