diff --git a/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/addons/theme/ThemeManager.java b/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/addons/theme/ThemeManager.java index 4ddd3fd..b49390b 100644 --- a/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/addons/theme/ThemeManager.java +++ b/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/addons/theme/ThemeManager.java @@ -1,12 +1,14 @@ package com.liskovsoft.leankeyboard.addons.theme; import android.content.Context; +import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.LinearLayout; import android.widget.RelativeLayout; import androidx.core.content.ContextCompat; +import com.liskovsoft.leankeyboard.ime.LeanbackKeyboardView; import com.liskovsoft.leankeyboard.utils.LeanKeySettings; import com.liskovsoft.leankeykeyboard.R; @@ -31,12 +33,14 @@ public class ThemeManager { R.color.candidate_background, R.color.enter_key_font_color ); + applyShiftDrawable(-1); } else if (LeanKeySettings.DARK_THEME_ID.equals(currentTheme)) { applyKeyboardColors( R.color.keyboard_background_dark, R.color.candidate_background_dark, R.color.enter_key_font_color_dark ); + applyShiftDrawable(R.drawable.ic_ime_shift_lock_on_dark); } } @@ -96,4 +100,18 @@ public class ThemeManager { } } } + + private void applyShiftDrawable(int resId) { + LeanbackKeyboardView keyboardView = mRootView.findViewById(R.id.main_keyboard); + + if (keyboardView != null) { + Drawable drawable = null; + + if (resId != -1) { + drawable = ContextCompat.getDrawable(mContext, resId); + } + + keyboardView.setCustomCapsLockDrawable(drawable); + } + } } diff --git a/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/ime/LeanbackKeyboardContainer.java b/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/ime/LeanbackKeyboardContainer.java index 1c820f9..6204760 100644 --- a/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/ime/LeanbackKeyboardContainer.java +++ b/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/ime/LeanbackKeyboardContainer.java @@ -816,7 +816,7 @@ public class LeanbackKeyboardContainer { } public boolean isCapsLockOn() { - return mMainKeyboardView.getShiftState() == 2; + return mMainKeyboardView.getShiftState() == LeanbackKeyboardView.SHIFT_LOCKED; } public boolean isCurrKeyShifted() { diff --git a/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/ime/LeanbackKeyboardView.java b/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/ime/LeanbackKeyboardView.java index d495451..aed253c 100644 --- a/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/ime/LeanbackKeyboardView.java +++ b/leankeykeyboard/src/main/java/com/liskovsoft/leankeyboard/ime/LeanbackKeyboardView.java @@ -11,6 +11,7 @@ import android.graphics.Paint; import android.graphics.Paint.Align; import android.graphics.Rect; import android.graphics.Typeface; +import android.graphics.drawable.Drawable; import android.inputmethodservice.Keyboard; import android.inputmethodservice.Keyboard.Key; import android.util.AttributeSet; @@ -74,6 +75,7 @@ public class LeanbackKeyboardView extends FrameLayout { protected Paint mPaint; protected int mKeyTextSize; protected int mModeChangeTextSize; + private Drawable mCustomCapsLockDrawable; private static class KeyConverter { private static final int LOWER_CASE = 0; @@ -198,7 +200,11 @@ public class LeanbackKeyboardView extends FrameLayout { key.icon = ContextCompat.getDrawable(getContext(), R.drawable.ic_ime_shift_on); break; case SHIFT_LOCKED: - key.icon = ContextCompat.getDrawable(getContext(), R.drawable.ic_ime_shift_lock_on); + if (mCustomCapsLockDrawable != null) { + key.icon = mCustomCapsLockDrawable; + } else { + key.icon = ContextCompat.getDrawable(getContext(), R.drawable.ic_ime_shift_lock_on); + } } } @@ -622,4 +628,8 @@ public class LeanbackKeyboardView extends FrameLayout { this.key = key; } } + + public void setCustomCapsLockDrawable(Drawable drawable) { + mCustomCapsLockDrawable = drawable; + } } diff --git a/leankeykeyboard/src/main/res/drawable-nodpi-v4/ic_ime_shift_lock_on_dark.png b/leankeykeyboard/src/main/res/drawable-nodpi-v4/ic_ime_shift_lock_on_dark.png new file mode 100644 index 0000000..68ff338 Binary files /dev/null and b/leankeykeyboard/src/main/res/drawable-nodpi-v4/ic_ime_shift_lock_on_dark.png differ