fix bad spacebar height in some modes

This commit is contained in:
Helium314 2023-07-31 10:56:19 +02:00
parent 093280b513
commit 20a1c95d8d
4 changed files with 38 additions and 6 deletions

View file

@ -382,9 +382,22 @@ public class KeyboardView extends View {
} else {
final Rect padding = mKeyBackgroundPadding;
bgWidth = keyWidth + padding.left + padding.right;
bgHeight = keyHeight + padding.top + padding.bottom;
// absurdly horrible workaround, because it's not possible to set padding as percentage of height in btn_keyboard_spacebar_lxx_base
if (mColors.isCustom && key.getBackgroundType() == Key.BACKGROUND_TYPE_SPACEBAR) {
Rect p = new Rect();
background.getPadding(p);
if (p.top != 0) {
bgHeight = (keyHeight + padding.top + padding.bottom) / 2;
bgY = -padding.top + bgHeight / 2;
} else {
bgHeight = keyHeight + padding.top + padding.bottom;
bgY = -padding.top;
}
} else {
bgHeight = keyHeight + padding.top + padding.bottom;
bgY = -padding.top;
}
bgX = -padding.left;
bgY = -padding.top;
}
if (mColors.isCustom)
setCustomKeyBackgroundColor(key, getKeyboard(), background);

View file

@ -21,11 +21,14 @@ import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
@ -271,6 +274,10 @@ public final class EmojiPalettesView extends LinearLayout
mSpacebar.setTag(Constants.CODE_SPACE);
mSpacebar.setOnTouchListener(this);
mSpacebar.setOnClickListener(this);
mEmojiLayoutParams.setKeyProperties(mSpacebar);
mSpacebarIcon = findViewById(R.id.emoji_keyboard_space_icon);
final Colors colors = Settings.getInstance().getCurrent().mColors;
if (colors.isCustom) {
DrawableCompat.setTintList(mAlphabetKeyLeft.getBackground(), colors.functionalKeyStateList);
@ -281,9 +288,18 @@ public final class EmojiPalettesView extends LinearLayout
DrawableCompat.setTintMode(mDeleteKey.getBackground(), PorterDuff.Mode.MULTIPLY);
getBackground().setColorFilter(colors.backgroundFilter);
mEmojiCategoryPageIndicatorView.setColors(colors.accent, colors.adjustedBackground);
// another weird workaround because it's not possible to set padding as percentage of height in btn_keyboard_spacebar_lxx_base
// of course different than in KeyboardView...
Rect p = new Rect();
mSpacebar.getBackground().getPadding(p);
if (p.top != 0) {
final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mSpacebar.getLayoutParams();
lp.topMargin = p.top;
lp.bottomMargin = p.top;
mSpacebar.setLayoutParams(lp);
}
}
mEmojiLayoutParams.setKeyProperties(mSpacebar);
mSpacebarIcon = findViewById(R.id.emoji_keyboard_space_icon);
}
@Override

View file

@ -190,6 +190,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
// set to keyboard_background_lxx_base (just white drawable), but NOT when set to
// btn_suggestion_lxx_base (state drawable with selector) or keyboard_suggest_strip_lxx_base_border (layer-list)
// why is this? then it's necessary to set tint list for voice/clipboard/other keys and all word views separately
// it seems to work in other places, e.g. for btn_keyboard_spacebar_lxx_base... though maybe that's the weirdly nested layer list?
// todo (later): when fixing this, revert changes in themes-lxx-base[-border] (in todo)
// this would allow having a different background shape in pressed state
DrawableCompat.setTintList(getBackground(), colors.backgroundStateList);

View file

@ -3,20 +3,22 @@
<!-- without this weirdly nested layer list the bottom/top things are ignored -->
<item android:state_pressed="true">
<layer-list>
<item android:bottom="12dp" android:top="12dp">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/key_background_pressed_lxx_base" />
<corners android:radius="5dp" />
<padding android:bottom="12dp" android:top="12dp"/>
</shape>
</item>
</layer-list>
</item>
<item>
<layer-list>
<item android:bottom="12dp" android:top="12dp">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/key_background_lxx_base" />
<corners android:radius="5dp" />
<padding android:bottom="12dp" android:top="12dp"/>
</shape>
</item>
</layer-list>