am f3c4cd45: Move dimming keyboard to MainKeyboardView
* commit 'f3c4cd45a5df6f90b922ea44db259e53117bb25a': Move dimming keyboard to MainKeyboardViewmain
commit
654dfd4670
|
@ -58,8 +58,6 @@
|
||||||
|
|
||||||
<!-- Amount to offset the touch Y coordinate by, for bias correction. -->
|
<!-- Amount to offset the touch Y coordinate by, for bias correction. -->
|
||||||
<attr name="verticalCorrection" format="dimension" />
|
<attr name="verticalCorrection" format="dimension" />
|
||||||
|
|
||||||
<attr name="backgroundDimAlpha" format="integer" />
|
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
<declare-styleable name="MainKeyboardView">
|
<declare-styleable name="MainKeyboardView">
|
||||||
|
@ -105,6 +103,7 @@
|
||||||
<attr name="keyPreviewLingerTimeout" format="integer" />
|
<attr name="keyPreviewLingerTimeout" format="integer" />
|
||||||
<!-- Layout resource for more keys keyboard -->
|
<!-- Layout resource for more keys keyboard -->
|
||||||
<attr name="moreKeysKeyboardLayout" format="reference" />
|
<attr name="moreKeysKeyboardLayout" format="reference" />
|
||||||
|
<attr name="backgroundDimAlpha" format="integer" />
|
||||||
<!-- More keys keyboard will shown at touched point. -->
|
<!-- More keys keyboard will shown at touched point. -->
|
||||||
<attr name="showMoreKeysKeyboardAtTouchedPoint" format="boolean" />
|
<attr name="showMoreKeysKeyboardAtTouchedPoint" format="boolean" />
|
||||||
<!-- Delay after gesture trail starts fading out in millisecond. -->
|
<!-- Delay after gesture trail starts fading out in millisecond. -->
|
||||||
|
|
|
@ -52,7 +52,6 @@ import java.util.HashSet;
|
||||||
* @attr ref R.styleable#KeyboardView_keyPopupHintLetterPadding
|
* @attr ref R.styleable#KeyboardView_keyPopupHintLetterPadding
|
||||||
* @attr ref R.styleable#KeyboardView_keyShiftedLetterHintPadding
|
* @attr ref R.styleable#KeyboardView_keyShiftedLetterHintPadding
|
||||||
* @attr ref R.styleable#KeyboardView_keyTextShadowRadius
|
* @attr ref R.styleable#KeyboardView_keyTextShadowRadius
|
||||||
* @attr ref R.styleable#KeyboardView_backgroundDimAlpha
|
|
||||||
* @attr ref R.styleable#KeyboardView_verticalCorrection
|
* @attr ref R.styleable#KeyboardView_verticalCorrection
|
||||||
* @attr ref R.styleable#Keyboard_Key_keyTypeface
|
* @attr ref R.styleable#Keyboard_Key_keyTypeface
|
||||||
* @attr ref R.styleable#Keyboard_Key_keyLetterSize
|
* @attr ref R.styleable#Keyboard_Key_keyLetterSize
|
||||||
|
@ -83,7 +82,6 @@ public class KeyboardView extends View {
|
||||||
protected final float mVerticalCorrection;
|
protected final float mVerticalCorrection;
|
||||||
protected final Drawable mKeyBackground;
|
protected final Drawable mKeyBackground;
|
||||||
protected final Rect mKeyBackgroundPadding = new Rect();
|
protected final Rect mKeyBackgroundPadding = new Rect();
|
||||||
private final int mBackgroundDimAlpha;
|
|
||||||
|
|
||||||
// HORIZONTAL ELLIPSIS "...", character for popup hint.
|
// HORIZONTAL ELLIPSIS "...", character for popup hint.
|
||||||
private static final String POPUP_HINT_CHAR = "\u2026";
|
private static final String POPUP_HINT_CHAR = "\u2026";
|
||||||
|
@ -101,8 +99,6 @@ public class KeyboardView extends View {
|
||||||
protected final KeyDrawParams mKeyDrawParams = new KeyDrawParams();
|
protected final KeyDrawParams mKeyDrawParams = new KeyDrawParams();
|
||||||
|
|
||||||
// Drawing
|
// Drawing
|
||||||
/** True if the entire keyboard needs to be dimmed. */
|
|
||||||
private boolean mNeedsToDimEntireKeyboard;
|
|
||||||
/** True if all keys should be drawn */
|
/** True if all keys should be drawn */
|
||||||
private boolean mInvalidateAllKeys;
|
private boolean mInvalidateAllKeys;
|
||||||
/** The keys that should be drawn */
|
/** The keys that should be drawn */
|
||||||
|
@ -147,8 +143,6 @@ public class KeyboardView extends View {
|
||||||
R.styleable.KeyboardView_keyTextShadowRadius, 0.0f);
|
R.styleable.KeyboardView_keyTextShadowRadius, 0.0f);
|
||||||
mVerticalCorrection = keyboardViewAttr.getDimension(
|
mVerticalCorrection = keyboardViewAttr.getDimension(
|
||||||
R.styleable.KeyboardView_verticalCorrection, 0);
|
R.styleable.KeyboardView_verticalCorrection, 0);
|
||||||
mBackgroundDimAlpha = keyboardViewAttr.getInt(
|
|
||||||
R.styleable.KeyboardView_backgroundDimAlpha, 0);
|
|
||||||
keyboardViewAttr.recycle();
|
keyboardViewAttr.recycle();
|
||||||
|
|
||||||
final TypedArray keyAttr = context.obtainStyledAttributes(attrs,
|
final TypedArray keyAttr = context.obtainStyledAttributes(attrs,
|
||||||
|
@ -203,7 +197,7 @@ public class KeyboardView extends View {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDraw(final Canvas canvas) {
|
protected void onDraw(final Canvas canvas) {
|
||||||
super.onDraw(canvas);
|
super.onDraw(canvas);
|
||||||
if (canvas.isHardwareAccelerated()) {
|
if (canvas.isHardwareAccelerated()) {
|
||||||
onDrawKeyboard(canvas);
|
onDrawKeyboard(canvas);
|
||||||
|
@ -293,15 +287,6 @@ public class KeyboardView extends View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Move this code block to MainKeyboardView.onDraw
|
|
||||||
// Overlay a dark rectangle to dim.
|
|
||||||
if (mNeedsToDimEntireKeyboard) {
|
|
||||||
paint.setColor(Color.BLACK);
|
|
||||||
paint.setAlpha(mBackgroundDimAlpha);
|
|
||||||
// Note: clipRegion() above is in effect if it was called.
|
|
||||||
canvas.drawRect(0, 0, width, height, paint);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ResearchLogging indicator.
|
// ResearchLogging indicator.
|
||||||
// TODO: Reimplement using a keyboard background image specific to the ResearchLogger,
|
// TODO: Reimplement using a keyboard background image specific to the ResearchLogger,
|
||||||
// and remove this call.
|
// and remove this call.
|
||||||
|
@ -313,15 +298,6 @@ public class KeyboardView extends View {
|
||||||
mInvalidateAllKeys = false;
|
mInvalidateAllKeys = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Move this method to MainKeyboardView.
|
|
||||||
public void dimEntireKeyboard(final boolean dimmed) {
|
|
||||||
final boolean needsRedrawing = mNeedsToDimEntireKeyboard != dimmed;
|
|
||||||
mNeedsToDimEntireKeyboard = dimmed;
|
|
||||||
if (needsRedrawing) {
|
|
||||||
invalidateAllKeys();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onDrawKey(final Key key, final Canvas canvas, final Paint paint) {
|
private void onDrawKey(final Key key, final Canvas canvas, final Paint paint) {
|
||||||
final int keyDrawX = key.getDrawX() + getPaddingLeft();
|
final int keyDrawX = key.getDrawX() + getPaddingLeft();
|
||||||
final int keyDrawY = key.mY + getPaddingTop();
|
final int keyDrawY = key.mY + getPaddingTop();
|
||||||
|
|
|
@ -24,6 +24,7 @@ import android.content.pm.PackageManager;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.Paint.Align;
|
import android.graphics.Paint.Align;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
|
@ -98,6 +99,7 @@ import java.util.WeakHashMap;
|
||||||
* @attr ref R.styleable#MainKeyboardView_keyPreviewHeight
|
* @attr ref R.styleable#MainKeyboardView_keyPreviewHeight
|
||||||
* @attr ref R.styleable#MainKeyboardView_keyPreviewLingerTimeout
|
* @attr ref R.styleable#MainKeyboardView_keyPreviewLingerTimeout
|
||||||
* @attr ref R.styleable#MainKeyboardView_moreKeysKeyboardLayout
|
* @attr ref R.styleable#MainKeyboardView_moreKeysKeyboardLayout
|
||||||
|
* @attr ref R.styleable#MainKeyboardView_backgroundDimAlpha
|
||||||
* @attr ref R.styleable#MainKeyboardView_showMoreKeysKeyboardAtTouchPoint
|
* @attr ref R.styleable#MainKeyboardView_showMoreKeysKeyboardAtTouchPoint
|
||||||
* @attr ref R.styleable#MainKeyboardView_gestureFloatingPreviewTextLingerTimeout
|
* @attr ref R.styleable#MainKeyboardView_gestureFloatingPreviewTextLingerTimeout
|
||||||
* @attr ref R.styleable#MainKeyboardView_gestureStaticTimeThresholdAfterFastTyping
|
* @attr ref R.styleable#MainKeyboardView_gestureStaticTimeThresholdAfterFastTyping
|
||||||
|
@ -164,6 +166,8 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
private int mKeyPreviewLingerTimeout;
|
private int mKeyPreviewLingerTimeout;
|
||||||
|
|
||||||
// More keys keyboard
|
// More keys keyboard
|
||||||
|
private final Paint mBackgroundDimAlphaPaint = new Paint();
|
||||||
|
private boolean mNeedsToDimEntireKeyboard;
|
||||||
private final WeakHashMap<Key, MoreKeysPanel> mMoreKeysPanelCache =
|
private final WeakHashMap<Key, MoreKeysPanel> mMoreKeysPanelCache =
|
||||||
new WeakHashMap<Key, MoreKeysPanel>();
|
new WeakHashMap<Key, MoreKeysPanel>();
|
||||||
private final int mMoreKeysLayout;
|
private final int mMoreKeysLayout;
|
||||||
|
@ -492,6 +496,10 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
|
|
||||||
final TypedArray mainKeyboardViewAttr = context.obtainStyledAttributes(
|
final TypedArray mainKeyboardViewAttr = context.obtainStyledAttributes(
|
||||||
attrs, R.styleable.MainKeyboardView, defStyle, R.style.MainKeyboardView);
|
attrs, R.styleable.MainKeyboardView, defStyle, R.style.MainKeyboardView);
|
||||||
|
final int backgroundDimAlpha = mainKeyboardViewAttr.getInt(
|
||||||
|
R.styleable.MainKeyboardView_backgroundDimAlpha, 0);
|
||||||
|
mBackgroundDimAlphaPaint.setColor(Color.BLACK);
|
||||||
|
mBackgroundDimAlphaPaint.setAlpha(backgroundDimAlpha);
|
||||||
mAutoCorrectionSpacebarLedEnabled = mainKeyboardViewAttr.getBoolean(
|
mAutoCorrectionSpacebarLedEnabled = mainKeyboardViewAttr.getBoolean(
|
||||||
R.styleable.MainKeyboardView_autoCorrectionSpacebarLedEnabled, false);
|
R.styleable.MainKeyboardView_autoCorrectionSpacebarLedEnabled, false);
|
||||||
mAutoCorrectionSpacebarLedIcon = mainKeyboardViewAttr.getDrawable(
|
mAutoCorrectionSpacebarLedIcon = mainKeyboardViewAttr.getDrawable(
|
||||||
|
@ -1306,6 +1314,24 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
invalidateKey(mSpaceKey);
|
invalidateKey(mSpaceKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void dimEntireKeyboard(final boolean dimmed) {
|
||||||
|
final boolean needsRedrawing = mNeedsToDimEntireKeyboard != dimmed;
|
||||||
|
mNeedsToDimEntireKeyboard = dimmed;
|
||||||
|
if (needsRedrawing) {
|
||||||
|
invalidateAllKeys();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDraw(final Canvas canvas) {
|
||||||
|
super.onDraw(canvas);
|
||||||
|
|
||||||
|
// Overlay a dark rectangle to dim.
|
||||||
|
if (mNeedsToDimEntireKeyboard) {
|
||||||
|
canvas.drawRect(0, 0, getWidth(), getHeight(), mBackgroundDimAlphaPaint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDrawKeyTopVisuals(final Key key, final Canvas canvas, final Paint paint,
|
protected void onDrawKeyTopVisuals(final Key key, final Canvas canvas, final Paint paint,
|
||||||
final KeyDrawParams params) {
|
final KeyDrawParams params) {
|
||||||
|
|
Loading…
Reference in New Issue