diff options
| author | Tadashi G. Takaoka <takaoka@google.com> | 2011-12-14 18:11:27 +0900 |
|---|---|---|
| committer | Tadashi G. Takaoka <takaoka@google.com> | 2011-12-14 19:46:03 +0900 |
| commit | 4665463ccd4880c2392d26baa784c5d28de986cc (patch) | |
| tree | 0679fdeafd6f3485ec2e22b37f763a214954d5f5 /java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java | |
| parent | e35e13fc7dc046be7f605cbfc706678f57e40491 (diff) | |
Add XmlParseUtils class
Change-Id: Ie288272bc75832db7d743262c4c4fbe73b6dca04
Diffstat (limited to 'java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java')
| -rw-r--r-- | java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java b/java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java index 218793500..3324fa6af 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java @@ -19,10 +19,10 @@ package com.android.inputmethod.keyboard.internal; import android.content.res.TypedArray; import android.util.Log; -import com.android.inputmethod.keyboard.internal.KeyboardBuilder.ParseException; import com.android.inputmethod.latin.R; import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; import java.util.ArrayList; import java.util.HashMap; @@ -43,7 +43,7 @@ public class KeyStyles { } /* package */ static class EmptyKeyStyle implements KeyStyle { - private EmptyKeyStyle() { + EmptyKeyStyle() { // Nothing to do. } @@ -118,7 +118,7 @@ public class KeyStyles { } } - private static class DeclaredKeyStyle extends EmptyKeyStyle { + /* package */ static class DeclaredKeyStyle extends EmptyKeyStyle { private final HashMap<Integer, Object> mAttributes = new HashMap<Integer, Object>(); @Override @@ -145,11 +145,11 @@ public class KeyStyles { return super.getFlag(a, index, defaultValue) | (value != null ? value : 0); } - private DeclaredKeyStyle() { + DeclaredKeyStyle() { super(); } - private void parseKeyStyleAttributes(TypedArray keyAttr) { + void parseKeyStyleAttributes(TypedArray keyAttr) { // TODO: Currently not all Key attributes can be declared as style. readInt(keyAttr, R.styleable.Keyboard_Key_code); readInt(keyAttr, R.styleable.Keyboard_Key_altCode); @@ -188,18 +188,19 @@ public class KeyStyles { mAttributes.put(index, value); } - private void addParent(DeclaredKeyStyle parentStyle) { + void addParent(DeclaredKeyStyle parentStyle) { mAttributes.putAll(parentStyle.mAttributes); } } public void parseKeyStyleAttributes(TypedArray keyStyleAttr, TypedArray keyAttrs, - XmlPullParser parser) { + XmlPullParser parser) throws XmlPullParserException { final String styleName = keyStyleAttr.getString(R.styleable.Keyboard_KeyStyle_styleName); if (DEBUG) Log.d(TAG, String.format("<%s styleName=%s />", KeyboardBuilder.TAG_KEY_STYLE, styleName)); if (mStyles.containsKey(styleName)) - throw new ParseException("duplicate key style declared: " + styleName, parser); + throw new XmlParseUtils.ParseException( + "duplicate key style declared: " + styleName, parser); final DeclaredKeyStyle style = new DeclaredKeyStyle(); if (keyStyleAttr.hasValue(R.styleable.Keyboard_KeyStyle_parentStyle)) { @@ -207,7 +208,8 @@ public class KeyStyles { R.styleable.Keyboard_KeyStyle_parentStyle); final DeclaredKeyStyle parent = mStyles.get(parentStyle); if (parent == null) - throw new ParseException("Unknown parentStyle " + parentStyle, parser); + throw new XmlParseUtils.ParseException( + "Unknown parentStyle " + parentStyle, parser); style.addParent(parent); } style.parseKeyStyleAttributes(keyAttrs); |
