2011-01-19 11:59:57 +00:00
|
|
|
/*
|
2011-05-20 03:09:57 +00:00
|
|
|
* Copyright (C) 2011 The Android Open Source Project
|
2011-01-19 11:59:57 +00:00
|
|
|
*
|
|
|
|
* 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;
|
|
|
|
|
2011-08-23 03:08:36 +00:00
|
|
|
import android.graphics.Paint;
|
2012-02-29 13:21:57 +00:00
|
|
|
import android.graphics.drawable.Drawable;
|
2012-04-27 14:44:28 +00:00
|
|
|
import android.view.View;
|
2011-08-23 03:08:36 +00:00
|
|
|
|
2012-10-03 08:36:45 +00:00
|
|
|
import com.android.inputmethod.annotations.UsedForTesting;
|
2013-01-21 06:23:32 +00:00
|
|
|
import com.android.inputmethod.keyboard.internal.KeyPreviewDrawParams;
|
2012-08-30 05:22:40 +00:00
|
|
|
import com.android.inputmethod.keyboard.internal.KeyboardBuilder;
|
2012-02-29 13:21:57 +00:00
|
|
|
import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
|
2012-08-30 05:22:40 +00:00
|
|
|
import com.android.inputmethod.keyboard.internal.KeyboardParams;
|
|
|
|
import com.android.inputmethod.keyboard.internal.MoreKeySpec;
|
2011-08-23 03:08:36 +00:00
|
|
|
import com.android.inputmethod.latin.R;
|
2012-03-08 08:07:02 +00:00
|
|
|
import com.android.inputmethod.latin.StringUtils;
|
2011-01-19 11:59:57 +00:00
|
|
|
|
2012-09-27 09:16:16 +00:00
|
|
|
public final class MoreKeysKeyboard extends Keyboard {
|
2011-07-29 00:05:40 +00:00
|
|
|
private final int mDefaultKeyCoordX;
|
2011-01-19 11:59:57 +00:00
|
|
|
|
2012-08-30 05:22:40 +00:00
|
|
|
MoreKeysKeyboard(final MoreKeysKeyboardParams params) {
|
2011-07-29 00:05:40 +00:00
|
|
|
super(params);
|
|
|
|
mDefaultKeyCoordX = params.getDefaultKeyCoordX() + params.mDefaultKeyWidth / 2;
|
2011-01-19 11:59:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getDefaultCoordX() {
|
|
|
|
return mDefaultKeyCoordX;
|
|
|
|
}
|
2011-08-23 03:08:36 +00:00
|
|
|
|
2012-10-03 08:36:45 +00:00
|
|
|
@UsedForTesting
|
2012-08-30 05:22:40 +00:00
|
|
|
static class MoreKeysKeyboardParams extends KeyboardParams {
|
|
|
|
public boolean mIsFixedOrder;
|
|
|
|
/* package */int mTopRowAdjustment;
|
|
|
|
public int mNumRows;
|
|
|
|
public int mNumColumns;
|
|
|
|
public int mTopKeys;
|
|
|
|
public int mLeftKeys;
|
|
|
|
public int mRightKeys; // includes default key.
|
|
|
|
public int mDividerWidth;
|
|
|
|
public int mColumnWidth;
|
|
|
|
|
|
|
|
public MoreKeysKeyboardParams() {
|
|
|
|
super();
|
|
|
|
}
|
2012-02-29 09:45:13 +00:00
|
|
|
|
2012-08-30 05:22:40 +00:00
|
|
|
/**
|
|
|
|
* Set keyboard parameters of more keys keyboard.
|
|
|
|
*
|
|
|
|
* @param numKeys number of keys in this more keys keyboard.
|
|
|
|
* @param maxColumns number of maximum columns of this more keys keyboard.
|
|
|
|
* @param keyWidth more keys keyboard key width in pixel, including horizontal gap.
|
|
|
|
* @param rowHeight more keys keyboard row height in pixel, including vertical gap.
|
|
|
|
* @param coordXInParent coordinate x of the key preview in parent keyboard.
|
|
|
|
* @param parentKeyboardWidth parent keyboard width in pixel.
|
|
|
|
* @param isFixedColumnOrder if true, more keys should be laid out in fixed order.
|
|
|
|
* @param dividerWidth width of divider, zero for no dividers.
|
|
|
|
*/
|
|
|
|
public void setParameters(final int numKeys, final int maxColumns, final int keyWidth,
|
|
|
|
final int rowHeight, final int coordXInParent, final int parentKeyboardWidth,
|
|
|
|
final boolean isFixedColumnOrder, final int dividerWidth) {
|
|
|
|
mIsFixedOrder = isFixedColumnOrder;
|
|
|
|
if (parentKeyboardWidth / keyWidth < maxColumns) {
|
|
|
|
throw new IllegalArgumentException(
|
|
|
|
"Keyboard is too small to hold more keys keyboard: "
|
|
|
|
+ parentKeyboardWidth + " " + keyWidth + " " + maxColumns);
|
2011-08-23 03:08:36 +00:00
|
|
|
}
|
2012-08-30 05:22:40 +00:00
|
|
|
mDefaultKeyWidth = keyWidth;
|
|
|
|
mDefaultRowHeight = rowHeight;
|
|
|
|
|
|
|
|
final int numRows = (numKeys + maxColumns - 1) / maxColumns;
|
|
|
|
mNumRows = numRows;
|
|
|
|
final int numColumns = mIsFixedOrder ? Math.min(numKeys, maxColumns)
|
|
|
|
: getOptimizedColumns(numKeys, maxColumns);
|
|
|
|
mNumColumns = numColumns;
|
|
|
|
final int topKeys = numKeys % numColumns;
|
|
|
|
mTopKeys = topKeys == 0 ? numColumns : topKeys;
|
|
|
|
|
|
|
|
final int numLeftKeys = (numColumns - 1) / 2;
|
|
|
|
final int numRightKeys = numColumns - numLeftKeys; // including default key.
|
|
|
|
// Maximum number of keys we can layout both side of the parent key
|
|
|
|
final int maxLeftKeys = coordXInParent / keyWidth;
|
|
|
|
final int maxRightKeys = (parentKeyboardWidth - coordXInParent) / keyWidth;
|
|
|
|
int leftKeys, rightKeys;
|
|
|
|
if (numLeftKeys > maxLeftKeys) {
|
|
|
|
leftKeys = maxLeftKeys;
|
|
|
|
rightKeys = numColumns - leftKeys;
|
|
|
|
} else if (numRightKeys > maxRightKeys + 1) {
|
|
|
|
rightKeys = maxRightKeys + 1; // include default key
|
|
|
|
leftKeys = numColumns - rightKeys;
|
|
|
|
} else {
|
|
|
|
leftKeys = numLeftKeys;
|
|
|
|
rightKeys = numRightKeys;
|
2011-08-23 03:08:36 +00:00
|
|
|
}
|
2012-08-30 05:22:40 +00:00
|
|
|
// If the left keys fill the left side of the parent key, entire more keys keyboard
|
|
|
|
// should be shifted to the right unless the parent key is on the left edge.
|
|
|
|
if (maxLeftKeys == leftKeys && leftKeys > 0) {
|
|
|
|
leftKeys--;
|
|
|
|
rightKeys++;
|
2012-02-13 22:34:09 +00:00
|
|
|
}
|
2012-08-30 05:22:40 +00:00
|
|
|
// If the right keys fill the right side of the parent key, entire more keys
|
|
|
|
// should be shifted to the left unless the parent key is on the right edge.
|
|
|
|
if (maxRightKeys == rightKeys - 1 && rightKeys > 1) {
|
|
|
|
leftKeys++;
|
|
|
|
rightKeys--;
|
2012-02-13 22:34:09 +00:00
|
|
|
}
|
2012-08-30 05:22:40 +00:00
|
|
|
mLeftKeys = leftKeys;
|
|
|
|
mRightKeys = rightKeys;
|
|
|
|
|
|
|
|
// Adjustment of the top row.
|
|
|
|
mTopRowAdjustment = mIsFixedOrder ? getFixedOrderTopRowAdjustment()
|
|
|
|
: getAutoOrderTopRowAdjustment();
|
|
|
|
mDividerWidth = dividerWidth;
|
|
|
|
mColumnWidth = mDefaultKeyWidth + mDividerWidth;
|
|
|
|
mBaseWidth = mOccupiedWidth = mNumColumns * mColumnWidth - mDividerWidth;
|
|
|
|
// Need to subtract the bottom row's gutter only.
|
|
|
|
mBaseHeight = mOccupiedHeight = mNumRows * mDefaultRowHeight - mVerticalGap
|
|
|
|
+ mTopPadding + mBottomPadding;
|
|
|
|
}
|
2012-02-13 22:34:09 +00:00
|
|
|
|
2012-08-30 05:22:40 +00:00
|
|
|
private int getFixedOrderTopRowAdjustment() {
|
|
|
|
if (mNumRows == 1 || mTopKeys % 2 == 1 || mTopKeys == mNumColumns
|
|
|
|
|| mLeftKeys == 0 || mRightKeys == 1) {
|
|
|
|
return 0;
|
2012-02-13 22:34:09 +00:00
|
|
|
}
|
2012-08-30 05:22:40 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2012-02-13 22:34:09 +00:00
|
|
|
|
2012-08-30 05:22:40 +00:00
|
|
|
private int getAutoOrderTopRowAdjustment() {
|
|
|
|
if (mNumRows == 1 || mTopKeys == 1 || mNumColumns % 2 == mTopKeys % 2
|
|
|
|
|| mLeftKeys == 0 || mRightKeys == 1) {
|
|
|
|
return 0;
|
2012-02-13 22:34:09 +00:00
|
|
|
}
|
2012-08-30 05:22:40 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2012-02-13 22:34:09 +00:00
|
|
|
|
2012-08-30 05:22:40 +00:00
|
|
|
// Return key position according to column count (0 is default).
|
|
|
|
/* package */int getColumnPos(final int n) {
|
|
|
|
return mIsFixedOrder ? getFixedOrderColumnPos(n) : getAutomaticColumnPos(n);
|
|
|
|
}
|
2012-02-13 22:34:09 +00:00
|
|
|
|
2012-08-30 05:22:40 +00:00
|
|
|
private int getFixedOrderColumnPos(final int n) {
|
|
|
|
final int col = n % mNumColumns;
|
|
|
|
final int row = n / mNumColumns;
|
|
|
|
if (!isTopRow(row)) {
|
|
|
|
return col - mLeftKeys;
|
|
|
|
}
|
|
|
|
final int rightSideKeys = mTopKeys / 2;
|
|
|
|
final int leftSideKeys = mTopKeys - (rightSideKeys + 1);
|
|
|
|
final int pos = col - leftSideKeys;
|
|
|
|
final int numLeftKeys = mLeftKeys + mTopRowAdjustment;
|
|
|
|
final int numRightKeys = mRightKeys - 1;
|
|
|
|
if (numRightKeys >= rightSideKeys && numLeftKeys >= leftSideKeys) {
|
2011-08-23 03:08:36 +00:00
|
|
|
return pos;
|
2012-08-30 05:22:40 +00:00
|
|
|
} else if (numRightKeys < rightSideKeys) {
|
|
|
|
return pos - (rightSideKeys - numRightKeys);
|
|
|
|
} else { // numLeftKeys < leftSideKeys
|
|
|
|
return pos + (leftSideKeys - numLeftKeys);
|
2011-08-23 03:08:36 +00:00
|
|
|
}
|
2012-08-30 05:22:40 +00:00
|
|
|
}
|
2011-08-23 03:08:36 +00:00
|
|
|
|
2012-08-30 05:22:40 +00:00
|
|
|
private int getAutomaticColumnPos(final int n) {
|
|
|
|
final int col = n % mNumColumns;
|
|
|
|
final int row = n / mNumColumns;
|
|
|
|
int leftKeys = mLeftKeys;
|
|
|
|
if (isTopRow(row)) {
|
|
|
|
leftKeys += mTopRowAdjustment;
|
|
|
|
}
|
|
|
|
if (col == 0) {
|
|
|
|
// default position.
|
|
|
|
return 0;
|
2011-08-23 03:08:36 +00:00
|
|
|
}
|
|
|
|
|
2012-08-30 05:22:40 +00:00
|
|
|
int pos = 0;
|
|
|
|
int right = 1; // include default position key.
|
|
|
|
int left = 0;
|
|
|
|
int i = 0;
|
|
|
|
while (true) {
|
|
|
|
// Assign right key if available.
|
|
|
|
if (right < mRightKeys) {
|
|
|
|
pos = right;
|
|
|
|
right++;
|
|
|
|
i++;
|
2011-08-23 03:08:36 +00:00
|
|
|
}
|
2012-08-30 05:22:40 +00:00
|
|
|
if (i >= col)
|
|
|
|
break;
|
|
|
|
// Assign left key if available.
|
|
|
|
if (left < leftKeys) {
|
|
|
|
left++;
|
|
|
|
pos = -left;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
if (i >= col)
|
|
|
|
break;
|
2011-08-23 03:08:36 +00:00
|
|
|
}
|
2012-08-30 05:22:40 +00:00
|
|
|
return pos;
|
|
|
|
}
|
2011-08-23 03:08:36 +00:00
|
|
|
|
2012-08-30 05:22:40 +00:00
|
|
|
private static int getTopRowEmptySlots(final int numKeys, final int numColumns) {
|
|
|
|
final int remainings = numKeys % numColumns;
|
|
|
|
return remainings == 0 ? 0 : numColumns - remainings;
|
|
|
|
}
|
2011-08-23 03:08:36 +00:00
|
|
|
|
2012-08-30 05:22:40 +00:00
|
|
|
private int getOptimizedColumns(final int numKeys, final int maxColumns) {
|
|
|
|
int numColumns = Math.min(numKeys, maxColumns);
|
|
|
|
while (getTopRowEmptySlots(numKeys, numColumns) >= mNumRows) {
|
|
|
|
numColumns--;
|
2011-08-23 03:08:36 +00:00
|
|
|
}
|
2012-08-30 05:22:40 +00:00
|
|
|
return numColumns;
|
|
|
|
}
|
2011-08-23 03:08:36 +00:00
|
|
|
|
2012-08-30 05:22:40 +00:00
|
|
|
public int getDefaultKeyCoordX() {
|
|
|
|
return mLeftKeys * mColumnWidth;
|
|
|
|
}
|
2011-08-23 03:08:36 +00:00
|
|
|
|
2012-08-30 05:22:40 +00:00
|
|
|
public int getX(final int n, final int row) {
|
|
|
|
final int x = getColumnPos(n) * mColumnWidth + getDefaultKeyCoordX();
|
|
|
|
if (isTopRow(row)) {
|
|
|
|
return x + mTopRowAdjustment * (mColumnWidth / 2);
|
2011-08-23 03:08:36 +00:00
|
|
|
}
|
2012-08-30 05:22:40 +00:00
|
|
|
return x;
|
|
|
|
}
|
2011-08-23 03:08:36 +00:00
|
|
|
|
2012-08-30 05:22:40 +00:00
|
|
|
public int getY(final int row) {
|
|
|
|
return (mNumRows - 1 - row) * mDefaultRowHeight + mTopPadding;
|
2011-08-23 03:08:36 +00:00
|
|
|
}
|
|
|
|
|
2012-08-30 05:22:40 +00:00
|
|
|
public void markAsEdgeKey(final Key key, final int row) {
|
|
|
|
if (row == 0)
|
|
|
|
key.markAsTopEdge(this);
|
|
|
|
if (isTopRow(row))
|
|
|
|
key.markAsBottomEdge(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean isTopRow(final int rowCount) {
|
|
|
|
return mNumRows > 1 && rowCount == mNumRows - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class Builder extends KeyboardBuilder<MoreKeysKeyboardParams> {
|
|
|
|
private final Key mParentKey;
|
|
|
|
private final Drawable mDivider;
|
|
|
|
|
|
|
|
private static final float LABEL_PADDING_RATIO = 0.2f;
|
|
|
|
private static final float DIVIDER_RATIO = 0.2f;
|
|
|
|
|
|
|
|
|
2012-04-27 14:44:28 +00:00
|
|
|
/**
|
|
|
|
* The builder of MoreKeysKeyboard.
|
|
|
|
* @param containerView the container of {@link MoreKeysKeyboardView}.
|
|
|
|
* @param parentKey the {@link Key} that invokes more keys keyboard.
|
|
|
|
* @param parentKeyboardView the {@link KeyboardView} that contains the parentKey.
|
2013-01-21 06:23:32 +00:00
|
|
|
* @param keyPreviewDrawParams the parameter to place key preview.
|
2012-04-27 14:44:28 +00:00
|
|
|
*/
|
2012-08-30 05:22:40 +00:00
|
|
|
public Builder(final View containerView, final Key parentKey,
|
2013-01-21 06:23:32 +00:00
|
|
|
final MainKeyboardView parentKeyboardView,
|
|
|
|
final KeyPreviewDrawParams keyPreviewDrawParams) {
|
2012-04-27 14:44:28 +00:00
|
|
|
super(containerView.getContext(), new MoreKeysKeyboardParams());
|
|
|
|
final Keyboard parentKeyboard = parentKeyboardView.getKeyboard();
|
|
|
|
load(parentKeyboard.mMoreKeysTemplate, parentKeyboard.mId);
|
2011-08-23 03:08:36 +00:00
|
|
|
|
2012-02-08 07:12:11 +00:00
|
|
|
// TODO: More keys keyboard's vertical gap is currently calculated heuristically.
|
2011-09-05 09:58:30 +00:00
|
|
|
// Should revise the algorithm.
|
|
|
|
mParams.mVerticalGap = parentKeyboard.mVerticalGap / 2;
|
2012-03-01 04:09:39 +00:00
|
|
|
mParentKey = parentKey;
|
2011-08-23 03:08:36 +00:00
|
|
|
|
2011-10-12 09:50:04 +00:00
|
|
|
final int width, height;
|
2012-04-27 14:44:28 +00:00
|
|
|
final boolean singleMoreKeyWithPreview = parentKeyboardView.isKeyPreviewPopupEnabled()
|
|
|
|
&& !parentKey.noKeyPreview() && parentKey.mMoreKeys.length == 1;
|
2012-03-01 04:09:39 +00:00
|
|
|
if (singleMoreKeyWithPreview) {
|
2012-04-27 14:44:28 +00:00
|
|
|
// Use pre-computed width and height if this more keys keyboard has only one key to
|
|
|
|
// mitigate visual flicker between key preview and more keys keyboard.
|
|
|
|
// Caveats for the visual assets: To achieve this effect, both the key preview
|
|
|
|
// backgrounds and the more keys keyboard panel background have the exact same
|
|
|
|
// left/right/top paddings. The bottom paddings of both backgrounds don't need to
|
|
|
|
// be considered because the vertical positions of both backgrounds were already
|
|
|
|
// adjusted with their bottom paddings deducted.
|
2013-01-21 06:23:32 +00:00
|
|
|
width = keyPreviewDrawParams.mPreviewVisibleWidth;
|
|
|
|
height = keyPreviewDrawParams.mPreviewVisibleHeight
|
2012-04-27 14:44:28 +00:00
|
|
|
+ mParams.mVerticalGap;
|
2011-10-12 09:50:04 +00:00
|
|
|
} else {
|
2012-04-27 14:44:28 +00:00
|
|
|
width = getMaxKeyWidth(parentKeyboardView, parentKey, mParams.mDefaultKeyWidth);
|
2011-10-12 09:50:04 +00:00
|
|
|
height = parentKeyboard.mMostCommonKeyHeight;
|
|
|
|
}
|
2012-02-29 13:21:57 +00:00
|
|
|
final int dividerWidth;
|
|
|
|
if (parentKey.needsDividersInMoreKeys()) {
|
|
|
|
mDivider = mResources.getDrawable(R.drawable.more_keys_divider);
|
|
|
|
dividerWidth = (int)(width * DIVIDER_RATIO);
|
|
|
|
} else {
|
|
|
|
mDivider = null;
|
|
|
|
dividerWidth = 0;
|
|
|
|
}
|
2012-03-01 04:09:39 +00:00
|
|
|
mParams.setParameters(parentKey.mMoreKeys.length, parentKey.getMoreKeysColumn(),
|
2012-04-27 14:44:28 +00:00
|
|
|
width, height, parentKey.mX + parentKey.mWidth / 2,
|
|
|
|
parentKeyboardView.getMeasuredWidth(), parentKey.isFixedColumnOrderMoreKeys(),
|
|
|
|
dividerWidth);
|
2011-08-23 03:08:36 +00:00
|
|
|
}
|
|
|
|
|
2012-08-30 05:22:40 +00:00
|
|
|
private static int getMaxKeyWidth(final KeyboardView view, final Key parentKey,
|
|
|
|
final int minKeyWidth) {
|
2012-02-29 09:45:13 +00:00
|
|
|
final int padding = (int)(view.getResources()
|
|
|
|
.getDimension(R.dimen.more_keys_keyboard_key_horizontal_padding)
|
|
|
|
+ (parentKey.hasLabelsInMoreKeys() ? minKeyWidth * LABEL_PADDING_RATIO : 0));
|
2012-03-16 07:41:18 +00:00
|
|
|
final Paint paint = view.newDefaultLabelPaint();
|
2012-08-30 08:42:49 +00:00
|
|
|
paint.setTypeface(parentKey.selectTypeface(view.mKeyDrawParams));
|
|
|
|
paint.setTextSize(parentKey.selectMoreKeyTextSize(view.mKeyDrawParams));
|
2011-08-29 12:12:36 +00:00
|
|
|
int maxWidth = minKeyWidth;
|
2012-04-09 08:48:32 +00:00
|
|
|
for (final MoreKeySpec spec : parentKey.mMoreKeys) {
|
|
|
|
final String label = spec.mLabel;
|
2012-01-20 04:18:06 +00:00
|
|
|
// If the label is single letter, minKeyWidth is enough to hold the label.
|
2012-03-08 08:07:02 +00:00
|
|
|
if (label != null && StringUtils.codePointCount(label) > 1) {
|
2012-03-16 07:41:18 +00:00
|
|
|
final int width = (int)view.getLabelWidth(label, paint) + padding;
|
2011-08-29 12:12:36 +00:00
|
|
|
if (maxWidth < width) {
|
|
|
|
maxWidth = width;
|
|
|
|
}
|
2011-08-23 03:08:36 +00:00
|
|
|
}
|
|
|
|
}
|
2011-08-30 07:48:38 +00:00
|
|
|
return maxWidth;
|
2011-08-23 03:08:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-02-08 07:12:11 +00:00
|
|
|
public MoreKeysKeyboard build() {
|
|
|
|
final MoreKeysKeyboardParams params = mParams;
|
2012-04-11 03:34:30 +00:00
|
|
|
final int moreKeyFlags = mParentKey.getMoreKeyLabelFlags();
|
2012-04-09 08:48:32 +00:00
|
|
|
final MoreKeySpec[] moreKeys = mParentKey.mMoreKeys;
|
2012-03-01 04:09:39 +00:00
|
|
|
for (int n = 0; n < moreKeys.length; n++) {
|
2012-04-09 08:48:32 +00:00
|
|
|
final MoreKeySpec moreKeySpec = moreKeys[n];
|
2011-08-23 03:08:36 +00:00
|
|
|
final int row = n / params.mNumColumns;
|
2012-02-29 13:21:57 +00:00
|
|
|
final int x = params.getX(n, row);
|
|
|
|
final int y = params.getY(row);
|
2012-04-09 08:48:32 +00:00
|
|
|
final Key key = new Key(params, moreKeySpec, x, y,
|
2012-02-29 13:21:57 +00:00
|
|
|
params.mDefaultKeyWidth, params.mDefaultRowHeight, moreKeyFlags);
|
2011-09-28 09:51:57 +00:00
|
|
|
params.markAsEdgeKey(key, row);
|
2011-08-23 03:08:36 +00:00
|
|
|
params.onAddKey(key);
|
2012-02-29 13:21:57 +00:00
|
|
|
|
|
|
|
final int pos = params.getColumnPos(n);
|
|
|
|
// The "pos" value represents the offset from the default position. Negative means
|
|
|
|
// left of the default position.
|
|
|
|
if (params.mDividerWidth > 0 && pos != 0) {
|
|
|
|
final int dividerX = (pos > 0) ? x - params.mDividerWidth
|
|
|
|
: x + params.mDefaultKeyWidth;
|
|
|
|
final Key divider = new MoreKeyDivider(params, mDivider, dividerX, y);
|
|
|
|
params.onAddKey(divider);
|
|
|
|
}
|
2011-08-23 03:08:36 +00:00
|
|
|
}
|
2012-02-08 07:12:11 +00:00
|
|
|
return new MoreKeysKeyboard(params);
|
2011-08-23 03:08:36 +00:00
|
|
|
}
|
|
|
|
}
|
2012-08-30 05:22:40 +00:00
|
|
|
|
|
|
|
private static class MoreKeyDivider extends Key.Spacer {
|
|
|
|
private final Drawable mIcon;
|
|
|
|
|
|
|
|
public MoreKeyDivider(final MoreKeysKeyboardParams params, final Drawable icon,
|
|
|
|
final int x, final int y) {
|
|
|
|
super(params, x, y, params.mDividerWidth, params.mDefaultRowHeight);
|
|
|
|
mIcon = icon;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Drawable getIcon(final KeyboardIconsSet iconSet, final int alpha) {
|
|
|
|
// KeyboardIconsSet and alpha are unused. Use the icon that has been passed to the
|
|
|
|
// constructor.
|
|
|
|
// TODO: Drawable itself should have an alpha value.
|
|
|
|
mIcon.setAlpha(128);
|
|
|
|
return mIcon;
|
|
|
|
}
|
|
|
|
}
|
2011-01-19 11:59:57 +00:00
|
|
|
}
|