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 final Colors mColors;
|
||||
private float mKeyScaleForText;
|
||||
protected float mFontSizeMultiplier;
|
||||
|
||||
// The maximum key label width in the proportion to the key width.
|
||||
private static final float MAX_LABEL_RATIO = 0.90f;
|
||||
|
@ -189,6 +190,9 @@ public class KeyboardView extends View {
|
|||
mKeyDrawParams.updateParams(scaledKeyHeight, keyboard.mKeyVisualAttributes);
|
||||
invalidateAllKeys();
|
||||
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();
|
||||
if (label != null) {
|
||||
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 labelCharWidth = TypefaceUtils.getReferenceCharWidth(paint);
|
||||
|
||||
|
@ -446,7 +450,7 @@ public class KeyboardView extends View {
|
|||
// Draw hint label.
|
||||
final String hintLabel = key.getHintLabel();
|
||||
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));
|
||||
// TODO: Should add a way to specify type face for hint letters
|
||||
paint.setTypeface(Typeface.DEFAULT_BOLD);
|
||||
|
@ -561,7 +565,7 @@ public class KeyboardView extends View {
|
|||
} else {
|
||||
paint.setColor(key.selectTextColor(mKeyDrawParams));
|
||||
paint.setTypeface(key.selectTypeface(mKeyDrawParams));
|
||||
paint.setTextSize(key.selectTextSize(mKeyDrawParams));
|
||||
paint.setTextSize(key.selectTextSize(mKeyDrawParams) * mFontSizeMultiplier);
|
||||
}
|
||||
return paint;
|
||||
}
|
||||
|
|
|
@ -164,7 +164,8 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
|
|||
mBackgroundDimAlphaPaint.setColor(Color.BLACK);
|
||||
mBackgroundDimAlphaPaint.setAlpha(backgroundDimAlpha);
|
||||
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;
|
||||
mLanguageOnSpacebarTextColor = colors.get(ColorType.SPACE_BAR_TEXT);
|
||||
mLanguageOnSpacebarTextShadowRadius = mainKeyboardViewAttr.getFloat(
|
||||
|
|
|
@ -57,8 +57,8 @@ public class KeyPreviewView extends AppCompatTextView {
|
|||
|
||||
setCompoundDrawables(null, null, null, null);
|
||||
setTextColor(drawParams.mPreviewTextColor);
|
||||
setTextSize(TypedValue.COMPLEX_UNIT_PX, key.selectPreviewTextSize(drawParams));
|
||||
// wie hier machen?
|
||||
setTextSize(TypedValue.COMPLEX_UNIT_PX, key.selectPreviewTextSize(drawParams)
|
||||
* Settings.getInstance().getCurrent().mFontSizeMultiplier);
|
||||
setTypeface(mTypeface == null ? key.selectPreviewTypeface(drawParams) : mTypeface);
|
||||
// TODO Should take care of temporaryShiftLabel here.
|
||||
setTextAndScaleX(key.getPreviewLabel());
|
||||
|
|
|
@ -106,6 +106,8 @@ class AppearanceSettingsFragment : SubScreenFragment() {
|
|||
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_LANDSCAPE, 0f)
|
||||
setupScalePrefs(Settings.PREF_FONT_SCALE, SettingsValues.DEFAULT_SIZE_SCALE)
|
||||
setupScalePrefs(Settings.PREF_EMOJI_FONT_SCALE, SettingsValues.DEFAULT_SIZE_SCALE)
|
||||
if (splitScalePref != null) {
|
||||
setupScalePrefs(Settings.PREF_SPLIT_SPACER_SCALE, SettingsValues.DEFAULT_SIZE_SCALE)
|
||||
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_BOTTOM_PADDING_SCALE = "bottom_padding_scale";
|
||||
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_VERTICAL_SWIPE = "vertical_space_swipe";
|
||||
public static final String PREF_DELETE_SWIPE = "delete_swipe";
|
||||
|
|
|
@ -120,6 +120,8 @@ public class SettingsValues {
|
|||
public final boolean mAlphaAfterSymbolAndSpace;
|
||||
public final boolean mRemoveRedundantPopups;
|
||||
public final String mSpaceBarText;
|
||||
public final float mFontSizeMultiplier;
|
||||
public final float mFontSizeMultiplierEmoji;
|
||||
|
||||
// From the input box
|
||||
@NonNull
|
||||
|
@ -273,6 +275,8 @@ public class SettingsValues {
|
|||
mRemoveRedundantPopups = prefs.getBoolean(Settings.PREF_REMOVE_REDUNDANT_POPUPS, false);
|
||||
mSpaceBarText = prefs.getString(Settings.PREF_SPACE_BAR_TEXT, "");
|
||||
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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue