Use theme color for swipe trail

This commit is contained in:
Aleksandras Kostarevas 2024-04-22 00:55:09 -04:00
parent 43984a6a76
commit 768accda75
4 changed files with 11 additions and 6 deletions

View File

@ -250,7 +250,7 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
mainKeyboardViewAttr);
mGestureFloatingTextDrawingPreview.setDrawingView(drawingPreviewPlacerView);
mGestureTrailsDrawingPreview = new GestureTrailsDrawingPreview(mainKeyboardViewAttr);
mGestureTrailsDrawingPreview = new GestureTrailsDrawingPreview(mainKeyboardViewAttr, mDrawableProvider);
mGestureTrailsDrawingPreview.setDrawingView(drawingPreviewPlacerView);
mSlidingKeyInputDrawingPreview = new SlidingKeyInputDrawingPreview(mainKeyboardViewAttr);

View File

@ -19,6 +19,7 @@ package org.futo.inputmethod.keyboard.internal;
import android.content.res.TypedArray;
import org.futo.inputmethod.latin.R;
import org.futo.inputmethod.latin.uix.DynamicThemeProvider;
/**
* This class holds parameters to control how a gesture trail is drawn and animated on the screen.
@ -49,9 +50,11 @@ final class GestureTrailDrawingParams {
public final int mTrailLingerDuration;
public GestureTrailDrawingParams(final TypedArray mainKeyboardViewAttr) {
mTrailColor = mainKeyboardViewAttr.getColor(
R.styleable.MainKeyboardView_gestureTrailColor, 0);
public GestureTrailDrawingParams(final TypedArray mainKeyboardViewAttr, DynamicThemeProvider provider) {
mTrailColor = DynamicThemeProvider.Companion.getColorOrDefault(
R.styleable.MainKeyboardView_gestureTrailColor, 0,
mainKeyboardViewAttr, provider
);
mTrailStartWidth = mainKeyboardViewAttr.getDimension(
R.styleable.MainKeyboardView_gestureTrailStartWidth, 0.0f);
mTrailEndWidth = mainKeyboardViewAttr.getDimension(

View File

@ -28,6 +28,7 @@ import android.os.Handler;
import android.util.SparseArray;
import org.futo.inputmethod.keyboard.PointerTracker;
import org.futo.inputmethod.latin.uix.DynamicThemeProvider;
/**
* Draw preview graphics of multiple gesture trails during gesture input.
@ -47,8 +48,8 @@ public final class GestureTrailsDrawingPreview extends AbstractDrawingPreview im
private final Handler mDrawingHandler = new Handler();
public GestureTrailsDrawingPreview(final TypedArray mainKeyboardViewAttr) {
mDrawingParams = new GestureTrailDrawingParams(mainKeyboardViewAttr);
public GestureTrailsDrawingPreview(final TypedArray mainKeyboardViewAttr, DynamicThemeProvider provider) {
mDrawingParams = new GestureTrailDrawingParams(mainKeyboardViewAttr, provider);
final Paint gesturePaint = new Paint();
gesturePaint.setAntiAlias(true);
gesturePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));

View File

@ -193,6 +193,7 @@ class BasicThemeProvider(val context: Context, val overrideColorScheme: ColorSch
colors[R.styleable.Keyboard_Key_keyShiftedLetterHintActivatedColor] = onBackgroundHalf
colors[R.styleable.Keyboard_Key_keyPreviewTextColor] = onSecondary
colors[R.styleable.MainKeyboardView_languageOnSpacebarTextColor] = onBackgroundHalf
colors[R.styleable.MainKeyboardView_gestureTrailColor] = primary
val overrideDrawable: (Int, Int, Int) -> Unit = { a, b, color ->
drawables[a] = AppCompatResources.getDrawable(