am f9521c6f: Change scope of some methods in KeyboardView

* commit 'f9521c6f378e3f2aa13d9e382ae13708e3ae6317':
  Change scope of some methods in KeyboardView
main
Tadashi G. Takaoka 2012-01-25 02:00:09 -08:00 committed by Android Git Automerger
commit d839c9c2ca
2 changed files with 18 additions and 19 deletions

View File

@ -373,7 +373,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
}
// Read fraction value in TypedArray as float.
private static float getRatio(TypedArray a, int index) {
/* package */ static float getRatio(TypedArray a, int index) {
return a.getFraction(index, 1000, 1000, 1) / 1000.0f;
}
@ -519,7 +519,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
}
// Draw key background.
/* package */ void onDrawKeyBackground(Key key, Canvas canvas, KeyDrawParams params) {
protected void onDrawKeyBackground(Key key, Canvas canvas, KeyDrawParams params) {
final int bgWidth = key.mWidth - key.mVisualInsetsLeft - key.mVisualInsetsRight
+ params.mPadding.left + params.mPadding.right;
final int bgHeight = key.mHeight + params.mPadding.top + params.mPadding.bottom;
@ -541,8 +541,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
}
// Draw key top visuals.
/* package */ void onDrawKeyTopVisuals(Key key, Canvas canvas, Paint paint,
KeyDrawParams params) {
protected void onDrawKeyTopVisuals(Key key, Canvas canvas, Paint paint, KeyDrawParams params) {
final int keyWidth = key.mWidth - key.mVisualInsetsLeft - key.mVisualInsetsRight;
final int keyHeight = key.mHeight;
final float centerX = keyWidth * 0.5f;
@ -718,7 +717,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
}
// Draw popup hint "..." at the bottom right corner of the key.
/* package */ void drawKeyPopupHint(Key key, Canvas canvas, Paint paint, KeyDrawParams params) {
protected void drawKeyPopupHint(Key key, Canvas canvas, Paint paint, KeyDrawParams params) {
final int keyWidth = key.mWidth - key.mVisualInsetsLeft - key.mVisualInsetsRight;
final int keyHeight = key.mHeight;
@ -737,8 +736,6 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
}
}
private static final Rect sTextBounds = new Rect();
private static int getCharGeometryCacheKey(char reference, Paint paint) {
final int labelSize = (int)paint.getTextSize();
final Typeface face = paint.getTypeface();
@ -754,33 +751,36 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
}
}
private static float getCharHeight(char[] character, Paint paint) {
// Working variable for the following methods.
private final Rect mTextBounds = new Rect();
private float getCharHeight(char[] character, Paint paint) {
final Integer key = getCharGeometryCacheKey(character[0], paint);
final Float cachedValue = sTextHeightCache.get(key);
if (cachedValue != null)
return cachedValue;
paint.getTextBounds(character, 0, 1, sTextBounds);
final float height = sTextBounds.height();
paint.getTextBounds(character, 0, 1, mTextBounds);
final float height = mTextBounds.height();
sTextHeightCache.put(key, height);
return height;
}
private static float getCharWidth(char[] character, Paint paint) {
private float getCharWidth(char[] character, Paint paint) {
final Integer key = getCharGeometryCacheKey(character[0], paint);
final Float cachedValue = sTextWidthCache.get(key);
if (cachedValue != null)
return cachedValue;
paint.getTextBounds(character, 0, 1, sTextBounds);
final float width = sTextBounds.width();
paint.getTextBounds(character, 0, 1, mTextBounds);
final float width = mTextBounds.width();
sTextWidthCache.put(key, width);
return width;
}
private static float getLabelWidth(String label, Paint paint) {
paint.getTextBounds(label.toString(), 0, label.length(), sTextBounds);
return sTextBounds.width();
protected float getLabelWidth(CharSequence label, Paint paint) {
paint.getTextBounds(label.toString(), 0, label.length(), mTextBounds);
return mTextBounds.width();
}
public float getDefaultLabelWidth(String label, Paint paint) {
@ -789,7 +789,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
return getLabelWidth(label, paint);
}
private static void drawIcon(Canvas canvas, Drawable icon, int x, int y, int width,
protected static void drawIcon(Canvas canvas, Drawable icon, int x, int y, int width,
int height) {
canvas.translate(x, y);
icon.setBounds(0, 0, width, height);

View File

@ -771,8 +771,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
}
@Override
/* package */ void onDrawKeyTopVisuals(Key key, Canvas canvas, Paint paint,
KeyDrawParams params) {
protected void onDrawKeyTopVisuals(Key key, Canvas canvas, Paint paint, KeyDrawParams params) {
super.onDrawKeyTopVisuals(key, canvas, paint, params);
if (key.mCode == Keyboard.CODE_SPACE) {