Move Row class into KeyboardBuilder

This is a followup of I5929e656.

Bug: 5245837
Change-Id: I06bc2774f77a2c5ddf0b6fe1b3ee70e9b3a7dd23
main
Tadashi G. Takaoka 2011-09-02 17:38:59 +09:00
parent 08e64e1874
commit d4d9b33c39
3 changed files with 33 additions and 59 deletions

View File

@ -31,7 +31,6 @@ import com.android.inputmethod.keyboard.internal.KeyboardBuilder.ParseException;
import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
import com.android.inputmethod.keyboard.internal.KeyboardParams;
import com.android.inputmethod.keyboard.internal.MoreKeySpecParser;
import com.android.inputmethod.keyboard.internal.Row;
import com.android.inputmethod.latin.R;
import java.util.HashMap;
@ -248,8 +247,8 @@ public class Key {
* @param parser the XML parser containing the attributes for this key
* @param keyStyles active key styles set
*/
public Key(Resources res, KeyboardParams params, Row row, XmlResourceParser parser,
KeyStyles keyStyles) {
public Key(Resources res, KeyboardParams params, KeyboardBuilder.Row row,
XmlResourceParser parser, KeyStyles keyStyles) {
final TypedArray keyboardAttr = res.obtainAttributes(Xml.asAttributeSet(parser),
R.styleable.Keyboard);

View File

@ -135,6 +135,37 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
private Key mRightEdgeKey = null;
private final KeyStyles mKeyStyles = new KeyStyles();
/**
* Container for keys in the keyboard. All keys in a row are at the same Y-coordinate.
* Some of the key size defaults can be overridden per row from what the {@link Keyboard}
* defines.
*/
public static class Row {
/** Default width of a key in this row. */
public final float mDefaultKeyWidth;
/** Default height of a key in this row. */
public final int mRowHeight;
public final int mCurrentY;
// Will be updated by {@link Key}'s constructor.
public float mCurrentX;
public Row(Resources res, KeyboardParams params, XmlResourceParser parser, int y) {
final int keyboardWidth = params.mWidth;
final int keyboardHeight = params.mHeight;
TypedArray a = res.obtainAttributes(Xml.asAttributeSet(parser),
R.styleable.Keyboard);
mDefaultKeyWidth = KeyboardBuilder.getDimensionOrFraction(a,
R.styleable.Keyboard_keyWidth, keyboardWidth, params.mDefaultKeyWidth);
mRowHeight = (int)KeyboardBuilder.getDimensionOrFraction(a,
R.styleable.Keyboard_rowHeight, keyboardHeight, params.mDefaultRowHeight);
a.recycle();
mCurrentY = y;
mCurrentX = 0.0f;
}
}
public KeyboardBuilder(Context context, KP params) {
mContext = context;
final Resources res = context.getResources();

View File

@ -1,56 +0,0 @@
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.android.inputmethod.keyboard.internal;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.util.Xml;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.latin.R;
/**
* Container for keys in the keyboard. All keys in a row are at the same Y-coordinate.
* Some of the key size defaults can be overridden per row from what the {@link Keyboard}
* defines.
*/
public class Row {
/** Default width of a key in this row. */
public final float mDefaultKeyWidth;
/** Default height of a key in this row. */
public final int mRowHeight;
public final int mCurrentY;
// Will be updated by {@link Key}'s constructor.
public float mCurrentX;
public Row(Resources res, KeyboardParams params, XmlResourceParser parser, int y) {
final int keyboardWidth = params.mWidth;
final int keyboardHeight = params.mHeight;
TypedArray a = res.obtainAttributes(Xml.asAttributeSet(parser),
R.styleable.Keyboard);
mDefaultKeyWidth = KeyboardBuilder.getDimensionOrFraction(a,
R.styleable.Keyboard_keyWidth, keyboardWidth, params.mDefaultKeyWidth);
mRowHeight = (int)KeyboardBuilder.getDimensionOrFraction(a,
R.styleable.Keyboard_rowHeight, keyboardHeight, params.mDefaultRowHeight);
a.recycle();
mCurrentY = y;
mCurrentX = 0.0f;
}
}