mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-19 13:49:13 +00:00
make side padding work properly in emoji view
This commit is contained in:
parent
15989f24f9
commit
73c21a1d37
2 changed files with 30 additions and 3 deletions
|
@ -49,12 +49,13 @@ public final class EmojiCategoryPageIndicatorView extends View {
|
|||
return;
|
||||
}
|
||||
final float height = getHeight();
|
||||
final float width = getWidth();
|
||||
final float leftPadding = getPaddingLeft();
|
||||
final float width = getWidth() - leftPadding - getPaddingRight();
|
||||
final float unitWidth = width / mCategoryPageSize;
|
||||
final float left = Math.min(unitWidth * mCurrentCategoryPageId + mOffset * unitWidth, width - unitWidth);
|
||||
final float top = 0.0f;
|
||||
final float right = Math.min(left + unitWidth, width);
|
||||
final float bottom = height * BOTTOM_MARGIN_RATIO;
|
||||
canvas.drawRect(left, top, right, bottom, mPaint);
|
||||
canvas.drawRect(left + leftPadding, top, right + leftPadding, bottom, mPaint);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ import helium314.keyboard.latin.RichInputMethodSubtype;
|
|||
import helium314.keyboard.latin.common.ColorType;
|
||||
import helium314.keyboard.latin.common.Colors;
|
||||
import helium314.keyboard.latin.settings.Settings;
|
||||
import helium314.keyboard.latin.utils.DeviceProtectedUtils;
|
||||
import helium314.keyboard.latin.settings.SettingsValues;
|
||||
import helium314.keyboard.latin.utils.ResourceUtils;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -272,6 +272,7 @@ public final class EmojiPalettesView extends LinearLayout
|
|||
mEmojiRecyclerView.setAdapter(mEmojiPalettesAdapter);
|
||||
setCurrentCategoryAndPageId(mEmojiCategory.getCurrentCategoryId(), mEmojiCategory.getCurrentCategoryPageId(), true);
|
||||
}
|
||||
setupSidePadding();
|
||||
}
|
||||
|
||||
private void setupBottomRowKeyboard(final EditorInfo editorInfo, final KeyboardActionListener keyboardActionListener) {
|
||||
|
@ -283,6 +284,31 @@ public final class EmojiPalettesView extends LinearLayout
|
|||
keyboardView.setKeyboard(keyboard);
|
||||
}
|
||||
|
||||
private void setupSidePadding() {
|
||||
final SettingsValues sv = Settings.getInstance().getCurrent();
|
||||
final int keyboardWidth = ResourceUtils.getKeyboardWidth(getContext(), sv);
|
||||
final TypedArray keyboardAttr = getContext().obtainStyledAttributes(
|
||||
null, R.styleable.Keyboard, R.attr.keyboardStyle, R.style.Keyboard);
|
||||
final float leftPadding = keyboardAttr.getFraction(R.styleable.Keyboard_keyboardLeftPadding,
|
||||
keyboardWidth, keyboardWidth, 0f) * sv.mSidePaddingScale;
|
||||
final float rightPadding = keyboardAttr.getFraction(R.styleable.Keyboard_keyboardRightPadding,
|
||||
keyboardWidth, keyboardWidth, 0f) * sv.mSidePaddingScale;
|
||||
keyboardAttr.recycle();
|
||||
mEmojiRecyclerView.setPadding(
|
||||
(int) leftPadding,
|
||||
mEmojiRecyclerView.getPaddingTop(),
|
||||
(int) rightPadding,
|
||||
mEmojiRecyclerView.getPaddingBottom()
|
||||
);
|
||||
mEmojiCategoryPageIndicatorView.setPadding(
|
||||
(int) leftPadding,
|
||||
mEmojiCategoryPageIndicatorView.getPaddingTop(),
|
||||
(int) rightPadding,
|
||||
mEmojiCategoryPageIndicatorView.getPaddingBottom()
|
||||
);
|
||||
// setting width does not do anything, so we have some workaround in EmojiCategoryPageIndicatorView
|
||||
}
|
||||
|
||||
public void stopEmojiPalettes() {
|
||||
if (!initialized) return;
|
||||
mEmojiPalettesAdapter.releaseCurrentKey(true);
|
||||
|
|
Loading…
Add table
Reference in a new issue