From 768accda7502157368376ad8f962067a44b26545 Mon Sep 17 00:00:00 2001 From: Aleksandras Kostarevas Date: Mon, 22 Apr 2024 00:55:09 -0400 Subject: [PATCH] Use theme color for swipe trail --- .../org/futo/inputmethod/keyboard/MainKeyboardView.java | 2 +- .../keyboard/internal/GestureTrailDrawingParams.java | 9 ++++++--- .../keyboard/internal/GestureTrailsDrawingPreview.java | 5 +++-- .../org/futo/inputmethod/latin/uix/BasicThemeProvider.kt | 1 + 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/java/src/org/futo/inputmethod/keyboard/MainKeyboardView.java b/java/src/org/futo/inputmethod/keyboard/MainKeyboardView.java index 16bd76ab2..fb6fef8f9 100644 --- a/java/src/org/futo/inputmethod/keyboard/MainKeyboardView.java +++ b/java/src/org/futo/inputmethod/keyboard/MainKeyboardView.java @@ -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); diff --git a/java/src/org/futo/inputmethod/keyboard/internal/GestureTrailDrawingParams.java b/java/src/org/futo/inputmethod/keyboard/internal/GestureTrailDrawingParams.java index a98219520..70855d717 100644 --- a/java/src/org/futo/inputmethod/keyboard/internal/GestureTrailDrawingParams.java +++ b/java/src/org/futo/inputmethod/keyboard/internal/GestureTrailDrawingParams.java @@ -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( diff --git a/java/src/org/futo/inputmethod/keyboard/internal/GestureTrailsDrawingPreview.java b/java/src/org/futo/inputmethod/keyboard/internal/GestureTrailsDrawingPreview.java index 96add0937..21ccac45a 100644 --- a/java/src/org/futo/inputmethod/keyboard/internal/GestureTrailsDrawingPreview.java +++ b/java/src/org/futo/inputmethod/keyboard/internal/GestureTrailsDrawingPreview.java @@ -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)); diff --git a/java/src/org/futo/inputmethod/latin/uix/BasicThemeProvider.kt b/java/src/org/futo/inputmethod/latin/uix/BasicThemeProvider.kt index c337cd8e8..5a2317d38 100644 --- a/java/src/org/futo/inputmethod/latin/uix/BasicThemeProvider.kt +++ b/java/src/org/futo/inputmethod/latin/uix/BasicThemeProvider.kt @@ -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(