mirror of
https://github.com/Julow/Unexpected-Keyboard.git
synced 2024-11-28 18:23:16 +01:00
Redefined the key margin options in percent
Define the key margin options relative to the baseline dimensions of keys. This removes the doubling of the horizontal margin in landscape mode.
This commit is contained in:
parent
c5f2c0b727
commit
bbc6226839
@ -44,7 +44,7 @@
|
|||||||
<juloo.keyboard2.prefs.IntSlideBarPreference android:key="horizontal_margin_landscape" android:title="@string/pref_landscape" android:summary="%sdp" android:defaultValue="28" min="0" max="200"/>
|
<juloo.keyboard2.prefs.IntSlideBarPreference android:key="horizontal_margin_landscape" android:title="@string/pref_landscape" android:summary="%sdp" android:defaultValue="28" min="0" max="200"/>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
<juloo.keyboard2.prefs.SlideBarPreference android:key="character_size" android:title="@string/pref_character_size_title" android:summary="@string/pref_character_size_summary" android:defaultValue="1.0" min="0.75" max="1.5"/>
|
<juloo.keyboard2.prefs.SlideBarPreference android:key="character_size" android:title="@string/pref_character_size_title" android:summary="@string/pref_character_size_summary" android:defaultValue="1.0" min="0.75" max="1.5"/>
|
||||||
<juloo.keyboard2.prefs.IntSlideBarPreference android:key="key_vertical_space" android:title="@string/pref_key_vertical_space" android:summary="%sdp" android:defaultValue="2" min="0" max="8"/>
|
<juloo.keyboard2.prefs.SlideBarPreference android:key="key_vertical_margin" android:title="@string/pref_key_vertical_space" android:summary="%s%%" android:defaultValue="1.5" min="0" max="5"/>
|
||||||
<juloo.keyboard2.prefs.IntSlideBarPreference android:key="key_horizontal_space" android:title="@string/pref_key_horizontal_space" android:summary="%sdp" android:defaultValue="2" min="0" max="8"/>
|
<juloo.keyboard2.prefs.SlideBarPreference android:key="key_horizontal_margin" android:title="@string/pref_key_horizontal_space" android:summary="%s%%" android:defaultValue="2" min="0" max="5"/>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@ -47,8 +47,8 @@ public final class Config
|
|||||||
public float margin_bottom;
|
public float margin_bottom;
|
||||||
public float keyHeight;
|
public float keyHeight;
|
||||||
public float horizontal_margin;
|
public float horizontal_margin;
|
||||||
public float keyVerticalInterval;
|
public float key_vertical_margin;
|
||||||
public float keyHorizontalInterval;
|
public float key_horizontal_margin;
|
||||||
public int labelBrightness; // 0 - 255
|
public int labelBrightness; // 0 - 255
|
||||||
public int keyboardOpacity; // 0 - 255
|
public int keyboardOpacity; // 0 - 255
|
||||||
public int keyOpacity; // 0 - 255
|
public int keyOpacity; // 0 - 255
|
||||||
@ -105,8 +105,6 @@ public final class Config
|
|||||||
// The height of the keyboard is relative to the height of the screen.
|
// The height of the keyboard is relative to the height of the screen.
|
||||||
// This is the height of the keyboard if it have 4 rows.
|
// This is the height of the keyboard if it have 4 rows.
|
||||||
int keyboardHeightPercent;
|
int keyboardHeightPercent;
|
||||||
// Scale some dimensions depending on orientation
|
|
||||||
float horizontalIntervalScale = 1.f;
|
|
||||||
float characterSizeScale = 1.f;
|
float characterSizeScale = 1.f;
|
||||||
String show_numpad_s = _prefs.getString("show_numpad", "never");
|
String show_numpad_s = _prefs.getString("show_numpad", "never");
|
||||||
show_numpad = "always".equals(show_numpad_s);
|
show_numpad = "always".equals(show_numpad_s);
|
||||||
@ -115,7 +113,6 @@ public final class Config
|
|||||||
if ("landscape".equals(show_numpad_s))
|
if ("landscape".equals(show_numpad_s))
|
||||||
show_numpad = true;
|
show_numpad = true;
|
||||||
keyboardHeightPercent = _prefs.getInt("keyboard_height_landscape", 50);
|
keyboardHeightPercent = _prefs.getInt("keyboard_height_landscape", 50);
|
||||||
horizontalIntervalScale = 2.f;
|
|
||||||
characterSizeScale = 1.25f;
|
characterSizeScale = 1.25f;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -139,16 +136,16 @@ public final class Config
|
|||||||
longPressTimeout = _prefs.getInt("longpress_timeout", 600);
|
longPressTimeout = _prefs.getInt("longpress_timeout", 600);
|
||||||
longPressInterval = _prefs.getInt("longpress_interval", 65);
|
longPressInterval = _prefs.getInt("longpress_interval", 65);
|
||||||
margin_bottom = get_dip_pref_oriented(dm, "margin_bottom", 7, 3);
|
margin_bottom = get_dip_pref_oriented(dm, "margin_bottom", 7, 3);
|
||||||
keyVerticalInterval = get_dip_pref(dm, "key_vertical_space", 2);
|
key_vertical_margin = get_dip_pref(dm, "key_vertical_margin", 1.5f) / 100;
|
||||||
keyHorizontalInterval = get_dip_pref(dm, "key_horizontal_space", 2) * horizontalIntervalScale;
|
key_horizontal_margin = get_dip_pref(dm, "key_horizontal_margin", 2) / 100;
|
||||||
// Label brightness is used as the alpha channel
|
// Label brightness is used as the alpha channel
|
||||||
labelBrightness = _prefs.getInt("label_brightness", 100) * 255 / 100;
|
labelBrightness = _prefs.getInt("label_brightness", 100) * 255 / 100;
|
||||||
// Keyboard opacity
|
// Keyboard opacity
|
||||||
keyboardOpacity = _prefs.getInt("keyboard_opacity", 100) * 255 / 100;
|
keyboardOpacity = _prefs.getInt("keyboard_opacity", 100) * 255 / 100;
|
||||||
keyOpacity = _prefs.getInt("key_opacity", 100) * 255 / 100;
|
keyOpacity = _prefs.getInt("key_opacity", 100) * 255 / 100;
|
||||||
keyActivatedOpacity = _prefs.getInt("key_activated_opacity", 100) * 255 / 100;
|
keyActivatedOpacity = _prefs.getInt("key_activated_opacity", 100) * 255 / 100;
|
||||||
// Do not substract keyVerticalInterval from keyHeight because this is done
|
// Do not substract key_vertical_margin from keyHeight because this is done
|
||||||
// during rendered.
|
// during rendering.
|
||||||
keyHeight = dm.heightPixels * keyboardHeightPercent / 100 / 4;
|
keyHeight = dm.heightPixels * keyboardHeightPercent / 100 / 4;
|
||||||
horizontal_margin =
|
horizontal_margin =
|
||||||
get_dip_pref_oriented(dm, "horizontal_margin", 3, 28);
|
get_dip_pref_oriented(dm, "horizontal_margin", 3, 28);
|
||||||
|
@ -299,16 +299,20 @@ public class Keyboard2View extends View
|
|||||||
_theme.keyBgPaint.setAlpha(_config.keyOpacity);
|
_theme.keyBgPaint.setAlpha(_config.keyOpacity);
|
||||||
_theme.keyDownBgPaint.setAlpha(_config.keyActivatedOpacity);
|
_theme.keyDownBgPaint.setAlpha(_config.keyActivatedOpacity);
|
||||||
_theme.keyBorderPaint.setAlpha(_config.keyOpacity);
|
_theme.keyBorderPaint.setAlpha(_config.keyOpacity);
|
||||||
float y = _config.marginTop + _config.keyVerticalInterval / 2;
|
float key_vertical_margin = _config.key_vertical_margin * _config.keyHeight;
|
||||||
|
float key_horizontal_margin = _config.key_horizontal_margin * _keyWidth;
|
||||||
|
// Add half of the key margin on the left and on the top as it's then added
|
||||||
|
// on the right and on the bottom of every keys.
|
||||||
|
float y = _config.marginTop + key_vertical_margin / 2;
|
||||||
for (KeyboardData.Row row : _keyboard.rows)
|
for (KeyboardData.Row row : _keyboard.rows)
|
||||||
{
|
{
|
||||||
y += row.shift * _config.keyHeight;
|
y += row.shift * _config.keyHeight;
|
||||||
float x = _config.horizontal_margin + _config.keyHorizontalInterval / 2;
|
float x = _config.horizontal_margin + key_horizontal_margin / 2;
|
||||||
float keyH = row.height * _config.keyHeight - _config.keyVerticalInterval;
|
float keyH = row.height * _config.keyHeight - key_vertical_margin;
|
||||||
for (KeyboardData.Key k : row.keys)
|
for (KeyboardData.Key k : row.keys)
|
||||||
{
|
{
|
||||||
x += k.shift * _keyWidth;
|
x += k.shift * _keyWidth;
|
||||||
float keyW = _keyWidth * k.width - _config.keyHorizontalInterval;
|
float keyW = _keyWidth * k.width - key_horizontal_margin;
|
||||||
boolean isKeyDown = _pointers.isKeyDown(k);
|
boolean isKeyDown = _pointers.isKeyDown(k);
|
||||||
drawKeyFrame(canvas, x, y, keyW, keyH, isKeyDown);
|
drawKeyFrame(canvas, x, y, keyW, keyH, isKeyDown);
|
||||||
if (k.keys[0] != null)
|
if (k.keys[0] != null)
|
||||||
|
Loading…
Reference in New Issue
Block a user