mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-10 00:27:45 +00:00
Adjust emoji key size according to emoji font size (#1543)
This commit is contained in:
parent
3c36033acb
commit
1f8a94f219
7 changed files with 21 additions and 4 deletions
|
@ -193,7 +193,8 @@ public class KeyboardView extends View {
|
||||||
invalidateAllKeys();
|
invalidateAllKeys();
|
||||||
requestLayout();
|
requestLayout();
|
||||||
mFontSizeMultiplier = mKeyboard.mId.isEmojiKeyboard()
|
mFontSizeMultiplier = mKeyboard.mId.isEmojiKeyboard()
|
||||||
? Settings.getValues().mFontSizeMultiplierEmoji
|
// In the case of EmojiKeyFit, the size of emojis is taken care of by the size of the keys
|
||||||
|
? (Settings.getValues().mEmojiKeyFit? 1 : Settings.getValues().mFontSizeMultiplierEmoji)
|
||||||
: Settings.getValues().mFontSizeMultiplier;
|
: Settings.getValues().mFontSizeMultiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,11 +44,17 @@ class EmojiParser(private val params: KeyboardParams, private val context: Conte
|
||||||
// this is a bit long, but ensures that emoji size stays the same, independent of these settings
|
// this is a bit long, but ensures that emoji size stays the same, independent of these settings
|
||||||
// we also ignore side padding for key width, and prefer fewer keys per row over narrower keys
|
// we also ignore side padding for key width, and prefer fewer keys per row over narrower keys
|
||||||
val defaultKeyWidth = ResourceUtils.getDefaultKeyboardWidth(context) * params.mDefaultKeyWidth
|
val defaultKeyWidth = ResourceUtils.getDefaultKeyboardWidth(context) * params.mDefaultKeyWidth
|
||||||
val keyWidth = defaultKeyWidth * sqrt(Settings.getValues().mKeyboardHeightScale)
|
var keyWidth = defaultKeyWidth * sqrt(Settings.getValues().mKeyboardHeightScale)
|
||||||
val defaultKeyboardHeight = ResourceUtils.getDefaultKeyboardHeight(context.resources, false)
|
val defaultKeyboardHeight = ResourceUtils.getDefaultKeyboardHeight(context.resources, false)
|
||||||
val defaultBottomPadding = context.resources.getFraction(R.fraction.config_keyboard_bottom_padding_holo, defaultKeyboardHeight, defaultKeyboardHeight)
|
val defaultBottomPadding = context.resources.getFraction(R.fraction.config_keyboard_bottom_padding_holo, defaultKeyboardHeight, defaultKeyboardHeight)
|
||||||
val emojiKeyboardHeight = ResourceUtils.getDefaultKeyboardHeight(context.resources, false) * 0.75f + params.mVerticalGap - defaultBottomPadding - context.resources.getDimensionPixelSize(R.dimen.config_emoji_category_page_id_height)
|
val emojiKeyboardHeight = ResourceUtils.getDefaultKeyboardHeight(context.resources, false) * 0.75f + params.mVerticalGap - defaultBottomPadding - context.resources.getDimensionPixelSize(R.dimen.config_emoji_category_page_id_height)
|
||||||
val keyHeight = emojiKeyboardHeight * params.mDefaultRowHeight * Settings.getValues().mKeyboardHeightScale // still apply height scale to key
|
var keyHeight = emojiKeyboardHeight * params.mDefaultRowHeight * Settings.getValues().mKeyboardHeightScale // still apply height scale to key
|
||||||
|
|
||||||
|
if (Settings.getValues().mEmojiKeyFit) {
|
||||||
|
keyWidth *= Settings.getValues().mFontSizeMultiplierEmoji
|
||||||
|
keyHeight *= Settings.getValues().mFontSizeMultiplierEmoji
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
emojiArray.forEachIndexed { i, codeArraySpec ->
|
emojiArray.forEachIndexed { i, codeArraySpec ->
|
||||||
val keyParams = parseEmojiKey(codeArraySpec, popupEmojisArray?.get(i)?.takeIf { it.isNotEmpty() }) ?: return@forEachIndexed
|
val keyParams = parseEmojiKey(codeArraySpec, popupEmojisArray?.get(i)?.takeIf { it.isNotEmpty() }) ?: return@forEachIndexed
|
||||||
|
|
|
@ -89,6 +89,7 @@ object Defaults {
|
||||||
const val PREF_SIDE_PADDING_SCALE_LANDSCAPE = 0f
|
const val PREF_SIDE_PADDING_SCALE_LANDSCAPE = 0f
|
||||||
const val PREF_FONT_SCALE = SettingsValues.DEFAULT_SIZE_SCALE
|
const val PREF_FONT_SCALE = SettingsValues.DEFAULT_SIZE_SCALE
|
||||||
const val PREF_EMOJI_FONT_SCALE = SettingsValues.DEFAULT_SIZE_SCALE
|
const val PREF_EMOJI_FONT_SCALE = SettingsValues.DEFAULT_SIZE_SCALE
|
||||||
|
const val PREF_EMOJI_KEY_FIT = true
|
||||||
const val PREF_SPACE_HORIZONTAL_SWIPE = "move_cursor"
|
const val PREF_SPACE_HORIZONTAL_SWIPE = "move_cursor"
|
||||||
const val PREF_SPACE_VERTICAL_SWIPE = "none"
|
const val PREF_SPACE_VERTICAL_SWIPE = "none"
|
||||||
const val PREF_DELETE_SWIPE = true
|
const val PREF_DELETE_SWIPE = true
|
||||||
|
|
|
@ -95,6 +95,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
||||||
public static final String PREF_SIDE_PADDING_SCALE_LANDSCAPE = "side_padding_scale_landscape";
|
public static final String PREF_SIDE_PADDING_SCALE_LANDSCAPE = "side_padding_scale_landscape";
|
||||||
public static final String PREF_FONT_SCALE = "font_scale";
|
public static final String PREF_FONT_SCALE = "font_scale";
|
||||||
public static final String PREF_EMOJI_FONT_SCALE = "emoji_font_scale";
|
public static final String PREF_EMOJI_FONT_SCALE = "emoji_font_scale";
|
||||||
|
public static final String PREF_EMOJI_KEY_FIT = "emoji_key_fit";
|
||||||
public static final String PREF_SPACE_HORIZONTAL_SWIPE = "horizontal_space_swipe";
|
public static final String PREF_SPACE_HORIZONTAL_SWIPE = "horizontal_space_swipe";
|
||||||
public static final String PREF_SPACE_VERTICAL_SWIPE = "vertical_space_swipe";
|
public static final String PREF_SPACE_VERTICAL_SWIPE = "vertical_space_swipe";
|
||||||
public static final String PREF_DELETE_SWIPE = "delete_swipe";
|
public static final String PREF_DELETE_SWIPE = "delete_swipe";
|
||||||
|
|
|
@ -124,6 +124,7 @@ public class SettingsValues {
|
||||||
public final String mSpaceBarText;
|
public final String mSpaceBarText;
|
||||||
public final float mFontSizeMultiplier;
|
public final float mFontSizeMultiplier;
|
||||||
public final float mFontSizeMultiplierEmoji;
|
public final float mFontSizeMultiplierEmoji;
|
||||||
|
public final boolean mEmojiKeyFit;
|
||||||
|
|
||||||
// From the input box
|
// From the input box
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -289,6 +290,7 @@ public class SettingsValues {
|
||||||
mEmojiMaxSdk = prefs.getInt(Settings.PREF_EMOJI_MAX_SDK, Defaults.PREF_EMOJI_MAX_SDK);
|
mEmojiMaxSdk = prefs.getInt(Settings.PREF_EMOJI_MAX_SDK, Defaults.PREF_EMOJI_MAX_SDK);
|
||||||
mFontSizeMultiplier = prefs.getFloat(Settings.PREF_FONT_SCALE, Defaults.PREF_FONT_SCALE);
|
mFontSizeMultiplier = prefs.getFloat(Settings.PREF_FONT_SCALE, Defaults.PREF_FONT_SCALE);
|
||||||
mFontSizeMultiplierEmoji = prefs.getFloat(Settings.PREF_EMOJI_FONT_SCALE, Defaults.PREF_EMOJI_FONT_SCALE);
|
mFontSizeMultiplierEmoji = prefs.getFloat(Settings.PREF_EMOJI_FONT_SCALE, Defaults.PREF_EMOJI_FONT_SCALE);
|
||||||
|
mEmojiKeyFit = prefs.getBoolean(Settings.PREF_EMOJI_KEY_FIT, Defaults.PREF_EMOJI_KEY_FIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isApplicationSpecifiedCompletionsOn() {
|
public boolean isApplicationSpecifiedCompletionsOn() {
|
||||||
|
|
|
@ -84,6 +84,7 @@ fun AppearanceScreen(
|
||||||
SettingsWithoutKey.CUSTOM_FONT,
|
SettingsWithoutKey.CUSTOM_FONT,
|
||||||
Settings.PREF_FONT_SCALE,
|
Settings.PREF_FONT_SCALE,
|
||||||
Settings.PREF_EMOJI_FONT_SCALE,
|
Settings.PREF_EMOJI_FONT_SCALE,
|
||||||
|
Settings.PREF_EMOJI_KEY_FIT,
|
||||||
)
|
)
|
||||||
SearchSettingsScreen(
|
SearchSettingsScreen(
|
||||||
onClickBack = onClickBack,
|
onClickBack = onClickBack,
|
||||||
|
@ -289,6 +290,9 @@ fun createAppearanceSettings(context: Context) = listOf(
|
||||||
description = { "${(100 * it).toInt()}%" }
|
description = { "${(100 * it).toInt()}%" }
|
||||||
) { KeyboardSwitcher.getInstance().setThemeNeedsReload() }
|
) { KeyboardSwitcher.getInstance().setThemeNeedsReload() }
|
||||||
},
|
},
|
||||||
|
Setting(context, Settings.PREF_EMOJI_KEY_FIT, R.string.prefs_emoji_key_fit) {
|
||||||
|
SwitchPreference(it, Defaults.PREF_EMOJI_KEY_FIT) { KeyboardSwitcher.getInstance().setThemeNeedsReload() }
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
@Preview
|
@Preview
|
||||||
|
|
|
@ -348,6 +348,8 @@
|
||||||
<string name="prefs_font_scale">Keyboard font scale</string>
|
<string name="prefs_font_scale">Keyboard font scale</string>
|
||||||
<!-- Title of the setting for adjusting font size in emoji view -->
|
<!-- Title of the setting for adjusting font size in emoji view -->
|
||||||
<string name="prefs_emoji_font_scale">Emoji view font scale</string>
|
<string name="prefs_emoji_font_scale">Emoji view font scale</string>
|
||||||
|
<!-- Title of the setting for adjusting emoji key size to fit emoji size in emoji view -->
|
||||||
|
<string name="prefs_emoji_key_fit">Scale emoji key size with font size</string>
|
||||||
<!-- Title of the setting for customizing space bar text -->
|
<!-- Title of the setting for customizing space bar text -->
|
||||||
<string name="prefs_space_bar_text">Custom text on space bar</string>
|
<string name="prefs_space_bar_text">Custom text on space bar</string>
|
||||||
<!-- Title of the setting for adding / removing custom font file -->
|
<!-- Title of the setting for adding / removing custom font file -->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue