diff --git a/app/src/main/java/org/pocketworkstation/pckeyboard/LatinKeyboardBaseView.java b/app/src/main/java/org/pocketworkstation/pckeyboard/LatinKeyboardBaseView.java index 0ef7bae32..7e520ef4d 100644 --- a/app/src/main/java/org/pocketworkstation/pckeyboard/LatinKeyboardBaseView.java +++ b/app/src/main/java/org/pocketworkstation/pckeyboard/LatinKeyboardBaseView.java @@ -25,6 +25,7 @@ import android.graphics.Canvas; import android.graphics.Color; import android.graphics.ColorFilter; +import android.graphics.ColorMatrixColorFilter; import android.graphics.Paint; import android.graphics.PorterDuffColorFilter; import android.graphics.Paint.Align; @@ -277,6 +278,14 @@ public interface OnKeyboardActionListener { /* package */ static Method sSetRenderMode; private static int sPrevRenderMode = -1; + private static final float[] INVERTING_MATRIX = { + -1.f, 0, 0, 0, 255, // Red + 0, -1.f, 0, 0, 255, // Green + 0, 0, -1.f, 0, 255, // Blue + 0, 0, 0, 1.f, 0, // Alpha + }; + private final ColorMatrixColorFilter mInvertingColorFilter = new ColorMatrixColorFilter(INVERTING_MATRIX); + private final UIHandler mHandler = new UIHandler(); class UIHandler extends Handler { @@ -915,15 +924,7 @@ private void onBufferDraw(Canvas canvas) { final Key[] keys = mKeys; final Key invalidKey = mInvalidatedKey; - ColorFilter iconColorFilter = null; - ColorFilter shadowColorFilter = null; - if (mRecolorSymbols) { - // TODO: cache these? - iconColorFilter = new PorterDuffColorFilter( - mKeyTextColor, PorterDuff.Mode.SRC_ATOP); - shadowColorFilter = new PorterDuffColorFilter( - mShadowColor, PorterDuff.Mode.SRC_ATOP); - } + ColorFilter iconColorFilter = mRecolorSymbols ? mInvertingColorFilter : null; boolean drawSingleKey = false; if (invalidKey != null && canvas.getClipBounds(clipRegion)) { @@ -1100,25 +1101,9 @@ private void onBufferDraw(Canvas canvas) { canvas.translate(drawableX, drawableY); icon.setBounds(0, 0, drawableWidth, drawableHeight); - if (shadowColorFilter != null && iconColorFilter != null) { - // Re-color the icon to match the theme, and draw a shadow for it manually. - // - // This doesn't seem to look quite right, possibly a problem with using - // premultiplied icon images? - - // Try EmbossMaskFilter, and/or offset? Configurable? - BlurMaskFilter shadowBlur = new BlurMaskFilter(mShadowRadius, BlurMaskFilter.Blur.OUTER); - Paint blurPaint = new Paint(); - blurPaint.setMaskFilter(shadowBlur); - Bitmap tmpIcon = Bitmap.createBitmap(key.width, key.height, Bitmap.Config.ARGB_8888); - Canvas tmpCanvas = new Canvas(tmpIcon); - icon.draw(tmpCanvas); - int[] offsets = new int[2]; - Bitmap shadowBitmap = tmpIcon.extractAlpha(blurPaint, offsets); - Paint shadowPaint = new Paint(); - shadowPaint.setColorFilter(shadowColorFilter); - canvas.drawBitmap(shadowBitmap, offsets[0], offsets[1], shadowPaint); - + if (iconColorFilter != null) { + // Re-color the icon to match the theme. Skip the shadow since it tends to not + // look right. icon.setColorFilter(iconColorFilter); icon.draw(canvas); icon.setColorFilter(null); diff --git a/app/src/main/res/layout/input_material_light.xml b/app/src/main/res/layout/input_material_light.xml index ec05e45a2..3893cac70 100644 --- a/app/src/main/res/layout/input_material_light.xml +++ b/app/src/main/res/layout/input_material_light.xml @@ -29,6 +29,8 @@ android:background="@drawable/keyboard_background_lxx_light" latin:symbolColorScheme="@color/key_text_color_lxx_light" latin:recolorSymbols="true" + latin:shadowRadius="0" + latin:shadowColor="#ff777777" latin:keyTextColor="@color/key_text_color_lxx_light" latin:keyHintColor="@color/key_hint_letter_color_lxx_light" diff --git a/app/src/main/res/layout/input_stone_bold.xml b/app/src/main/res/layout/input_stone_bold.xml index 3a9de5198..4178367d3 100644 --- a/app/src/main/res/layout/input_stone_bold.xml +++ b/app/src/main/res/layout/input_stone_bold.xml @@ -33,6 +33,7 @@ latin:keyHintColor="#FF777777" latin:keyCursorColor="@color/latinkeyboard_dim_color_black" latin:shadowColor="@color/latinkeyboard_key_color_white" + latin:shadowRadius="0" latin:keyTextStyle="bold" latin:symbolColorScheme="black" latin:recolorSymbols="true"