dark theme caps lock fix

This commit is contained in:
Yuriy Liskov
2020-05-24 14:54:59 +03:00
parent b08484ed84
commit 08bcb92c8e
4 changed files with 30 additions and 2 deletions

View File

@@ -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);
}
}
}

View File

@@ -816,7 +816,7 @@ public class LeanbackKeyboardContainer {
}
public boolean isCapsLockOn() {
return mMainKeyboardView.getShiftState() == 2;
return mMainKeyboardView.getShiftState() == LeanbackKeyboardView.SHIFT_LOCKED;
}
public boolean isCurrKeyShifted() {

View File

@@ -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;
}
}

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 716 B