mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-10 00:27:45 +00:00
add font scale setting (separat for emoji view, because here it feels different)
fixes #1149
This commit is contained in:
parent
f45f69f8a2
commit
105a6a7791
8 changed files with 35 additions and 6 deletions
|
@ -65,6 +65,7 @@ public class KeyboardView extends View {
|
||||||
private static final float KET_TEXT_SHADOW_RADIUS_DISABLED = -1.0f;
|
private static final float KET_TEXT_SHADOW_RADIUS_DISABLED = -1.0f;
|
||||||
private final Colors mColors;
|
private final Colors mColors;
|
||||||
private float mKeyScaleForText;
|
private float mKeyScaleForText;
|
||||||
|
protected float mFontSizeMultiplier;
|
||||||
|
|
||||||
// The maximum key label width in the proportion to the key width.
|
// The maximum key label width in the proportion to the key width.
|
||||||
private static final float MAX_LABEL_RATIO = 0.90f;
|
private static final float MAX_LABEL_RATIO = 0.90f;
|
||||||
|
@ -189,6 +190,9 @@ public class KeyboardView extends View {
|
||||||
mKeyDrawParams.updateParams(scaledKeyHeight, keyboard.mKeyVisualAttributes);
|
mKeyDrawParams.updateParams(scaledKeyHeight, keyboard.mKeyVisualAttributes);
|
||||||
invalidateAllKeys();
|
invalidateAllKeys();
|
||||||
requestLayout();
|
requestLayout();
|
||||||
|
mFontSizeMultiplier = mKeyboard.mId.isEmojiKeyboard()
|
||||||
|
? Settings.getInstance().getCurrent().mFontSizeMultiplierEmoji
|
||||||
|
: Settings.getInstance().getCurrent().mFontSizeMultiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -384,7 +388,7 @@ public class KeyboardView extends View {
|
||||||
final String label = key.getLabel();
|
final String label = key.getLabel();
|
||||||
if (label != null) {
|
if (label != null) {
|
||||||
paint.setTypeface(mTypeface == null ? key.selectTypeface(params) : mTypeface);
|
paint.setTypeface(mTypeface == null ? key.selectTypeface(params) : mTypeface);
|
||||||
paint.setTextSize(key.selectTextSize(params));
|
paint.setTextSize(key.selectTextSize(params) * mFontSizeMultiplier);
|
||||||
final float labelCharHeight = TypefaceUtils.getReferenceCharHeight(paint);
|
final float labelCharHeight = TypefaceUtils.getReferenceCharHeight(paint);
|
||||||
final float labelCharWidth = TypefaceUtils.getReferenceCharWidth(paint);
|
final float labelCharWidth = TypefaceUtils.getReferenceCharWidth(paint);
|
||||||
|
|
||||||
|
@ -446,7 +450,7 @@ public class KeyboardView extends View {
|
||||||
// Draw hint label.
|
// Draw hint label.
|
||||||
final String hintLabel = key.getHintLabel();
|
final String hintLabel = key.getHintLabel();
|
||||||
if (hintLabel != null && mShowsHints) {
|
if (hintLabel != null && mShowsHints) {
|
||||||
paint.setTextSize(key.selectHintTextSize(params));
|
paint.setTextSize(key.selectHintTextSize(params) * mFontSizeMultiplier); // maybe take sqrt to not have such extreme changes?
|
||||||
paint.setColor(key.selectHintTextColor(params));
|
paint.setColor(key.selectHintTextColor(params));
|
||||||
// TODO: Should add a way to specify type face for hint letters
|
// TODO: Should add a way to specify type face for hint letters
|
||||||
paint.setTypeface(Typeface.DEFAULT_BOLD);
|
paint.setTypeface(Typeface.DEFAULT_BOLD);
|
||||||
|
@ -561,7 +565,7 @@ public class KeyboardView extends View {
|
||||||
} else {
|
} else {
|
||||||
paint.setColor(key.selectTextColor(mKeyDrawParams));
|
paint.setColor(key.selectTextColor(mKeyDrawParams));
|
||||||
paint.setTypeface(key.selectTypeface(mKeyDrawParams));
|
paint.setTypeface(key.selectTypeface(mKeyDrawParams));
|
||||||
paint.setTextSize(key.selectTextSize(mKeyDrawParams));
|
paint.setTextSize(key.selectTextSize(mKeyDrawParams) * mFontSizeMultiplier);
|
||||||
}
|
}
|
||||||
return paint;
|
return paint;
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,7 +164,8 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
|
||||||
mBackgroundDimAlphaPaint.setColor(Color.BLACK);
|
mBackgroundDimAlphaPaint.setColor(Color.BLACK);
|
||||||
mBackgroundDimAlphaPaint.setAlpha(backgroundDimAlpha);
|
mBackgroundDimAlphaPaint.setAlpha(backgroundDimAlpha);
|
||||||
mLanguageOnSpacebarTextRatio = mainKeyboardViewAttr.getFraction(
|
mLanguageOnSpacebarTextRatio = mainKeyboardViewAttr.getFraction(
|
||||||
R.styleable.MainKeyboardView_languageOnSpacebarTextRatio, 1, 1, 1.0f);
|
R.styleable.MainKeyboardView_languageOnSpacebarTextRatio, 1, 1, 1.0f)
|
||||||
|
* Settings.getInstance().getCurrent().mFontSizeMultiplier;
|
||||||
final Colors colors = Settings.getInstance().getCurrent().mColors;
|
final Colors colors = Settings.getInstance().getCurrent().mColors;
|
||||||
mLanguageOnSpacebarTextColor = colors.get(ColorType.SPACE_BAR_TEXT);
|
mLanguageOnSpacebarTextColor = colors.get(ColorType.SPACE_BAR_TEXT);
|
||||||
mLanguageOnSpacebarTextShadowRadius = mainKeyboardViewAttr.getFloat(
|
mLanguageOnSpacebarTextShadowRadius = mainKeyboardViewAttr.getFloat(
|
||||||
|
|
|
@ -57,8 +57,8 @@ public class KeyPreviewView extends AppCompatTextView {
|
||||||
|
|
||||||
setCompoundDrawables(null, null, null, null);
|
setCompoundDrawables(null, null, null, null);
|
||||||
setTextColor(drawParams.mPreviewTextColor);
|
setTextColor(drawParams.mPreviewTextColor);
|
||||||
setTextSize(TypedValue.COMPLEX_UNIT_PX, key.selectPreviewTextSize(drawParams));
|
setTextSize(TypedValue.COMPLEX_UNIT_PX, key.selectPreviewTextSize(drawParams)
|
||||||
// wie hier machen?
|
* Settings.getInstance().getCurrent().mFontSizeMultiplier);
|
||||||
setTypeface(mTypeface == null ? key.selectPreviewTypeface(drawParams) : mTypeface);
|
setTypeface(mTypeface == null ? key.selectPreviewTypeface(drawParams) : mTypeface);
|
||||||
// TODO Should take care of temporaryShiftLabel here.
|
// TODO Should take care of temporaryShiftLabel here.
|
||||||
setTextAndScaleX(key.getPreviewLabel());
|
setTextAndScaleX(key.getPreviewLabel());
|
||||||
|
|
|
@ -106,6 +106,8 @@ class AppearanceSettingsFragment : SubScreenFragment() {
|
||||||
setupScalePrefs(Settings.PREF_KEYBOARD_HEIGHT_SCALE, SettingsValues.DEFAULT_SIZE_SCALE)
|
setupScalePrefs(Settings.PREF_KEYBOARD_HEIGHT_SCALE, SettingsValues.DEFAULT_SIZE_SCALE)
|
||||||
setupScalePrefs(Settings.PREF_BOTTOM_PADDING_SCALE, SettingsValues.DEFAULT_SIZE_SCALE)
|
setupScalePrefs(Settings.PREF_BOTTOM_PADDING_SCALE, SettingsValues.DEFAULT_SIZE_SCALE)
|
||||||
setupScalePrefs(Settings.PREF_BOTTOM_PADDING_SCALE_LANDSCAPE, 0f)
|
setupScalePrefs(Settings.PREF_BOTTOM_PADDING_SCALE_LANDSCAPE, 0f)
|
||||||
|
setupScalePrefs(Settings.PREF_FONT_SCALE, SettingsValues.DEFAULT_SIZE_SCALE)
|
||||||
|
setupScalePrefs(Settings.PREF_EMOJI_FONT_SCALE, SettingsValues.DEFAULT_SIZE_SCALE)
|
||||||
if (splitScalePref != null) {
|
if (splitScalePref != null) {
|
||||||
setupScalePrefs(Settings.PREF_SPLIT_SPACER_SCALE, SettingsValues.DEFAULT_SIZE_SCALE)
|
setupScalePrefs(Settings.PREF_SPLIT_SPACER_SCALE, SettingsValues.DEFAULT_SIZE_SCALE)
|
||||||
splitScalePref?.isVisible = splitPref?.isChecked == true
|
splitScalePref?.isVisible = splitPref?.isChecked == true
|
||||||
|
|
|
@ -113,6 +113,8 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
||||||
public static final String PREF_KEYBOARD_HEIGHT_SCALE = "keyboard_height_scale";
|
public static final String PREF_KEYBOARD_HEIGHT_SCALE = "keyboard_height_scale";
|
||||||
public static final String PREF_BOTTOM_PADDING_SCALE = "bottom_padding_scale";
|
public static final String PREF_BOTTOM_PADDING_SCALE = "bottom_padding_scale";
|
||||||
public static final String PREF_BOTTOM_PADDING_SCALE_LANDSCAPE = "bottom_padding_scale_landscape";
|
public static final String PREF_BOTTOM_PADDING_SCALE_LANDSCAPE = "bottom_padding_scale_landscape";
|
||||||
|
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_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";
|
||||||
|
|
|
@ -120,6 +120,8 @@ public class SettingsValues {
|
||||||
public final boolean mAlphaAfterSymbolAndSpace;
|
public final boolean mAlphaAfterSymbolAndSpace;
|
||||||
public final boolean mRemoveRedundantPopups;
|
public final boolean mRemoveRedundantPopups;
|
||||||
public final String mSpaceBarText;
|
public final String mSpaceBarText;
|
||||||
|
public final float mFontSizeMultiplier;
|
||||||
|
public final float mFontSizeMultiplierEmoji;
|
||||||
|
|
||||||
// From the input box
|
// From the input box
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -273,6 +275,8 @@ public class SettingsValues {
|
||||||
mRemoveRedundantPopups = prefs.getBoolean(Settings.PREF_REMOVE_REDUNDANT_POPUPS, false);
|
mRemoveRedundantPopups = prefs.getBoolean(Settings.PREF_REMOVE_REDUNDANT_POPUPS, false);
|
||||||
mSpaceBarText = prefs.getString(Settings.PREF_SPACE_BAR_TEXT, "");
|
mSpaceBarText = prefs.getString(Settings.PREF_SPACE_BAR_TEXT, "");
|
||||||
mEmojiMaxSdk = prefs.getInt(Settings.PREF_EMOJI_MAX_SDK, Build.VERSION.SDK_INT);
|
mEmojiMaxSdk = prefs.getInt(Settings.PREF_EMOJI_MAX_SDK, Build.VERSION.SDK_INT);
|
||||||
|
mFontSizeMultiplier = prefs.getFloat(Settings.PREF_FONT_SCALE, DEFAULT_SIZE_SCALE);
|
||||||
|
mFontSizeMultiplierEmoji = prefs.getFloat(Settings.PREF_EMOJI_FONT_SCALE, DEFAULT_SIZE_SCALE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isApplicationSpecifiedCompletionsOn() {
|
public boolean isApplicationSpecifiedCompletionsOn() {
|
||||||
|
|
|
@ -313,6 +313,10 @@
|
||||||
<string name="prefs_bottom_padding_scale">Bottom padding scale</string>
|
<string name="prefs_bottom_padding_scale">Bottom padding scale</string>
|
||||||
<!-- Title of the setting for setting bottom padding height in landscape mode -->
|
<!-- Title of the setting for setting bottom padding height in landscape mode -->
|
||||||
<string name="prefs_bottom_padding_scale_landscape">Bottom padding scale (landscape)</string>
|
<string name="prefs_bottom_padding_scale_landscape">Bottom padding scale (landscape)</string>
|
||||||
|
<!-- Title of the setting for adjusting font size on the keyboard -->
|
||||||
|
<string name="prefs_font_scale">Keyboard font scale</string>
|
||||||
|
<!-- Title of the setting for adjusting font size in emoji view -->
|
||||||
|
<string name="prefs_emoji_font_scale">Emoji view font scale</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 -->
|
||||||
|
|
|
@ -130,6 +130,18 @@
|
||||||
android:defaultValue=""
|
android:defaultValue=""
|
||||||
android:persistent="true" />
|
android:persistent="true" />
|
||||||
|
|
||||||
|
<helium314.keyboard.latin.settings.SeekBarDialogPreference
|
||||||
|
android:key="font_scale"
|
||||||
|
android:title="@string/prefs_font_scale"
|
||||||
|
latin:minValue="50"
|
||||||
|
latin:maxValue="150" /> <!-- percentage -->
|
||||||
|
|
||||||
|
<helium314.keyboard.latin.settings.SeekBarDialogPreference
|
||||||
|
android:key="emoji_font_scale"
|
||||||
|
android:title="@string/prefs_emoji_font_scale"
|
||||||
|
latin:minValue="50"
|
||||||
|
latin:maxValue="150" /> <!-- percentage -->
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue