forked from extern/Unexpected-Keyboard
Compute the swipe distance from the physical dpi
The previous computation was very different depending on the device's screen and accessibility options. Given that the keyboard is supposed to fill all the space in one dimension, the dpi unit makes little sense. The formula doesn't mean anything in particular, it takes into account both dimensions (x and y) and should be close to the dpi in the diagonals (which is the direction of swipe). This changes the actual value, on a 1920x1080 480dpi screen, the value is increased by 20%.
This commit is contained in:
parent
281f779121
commit
2b6c2b98e0
@ -23,7 +23,6 @@ final class Config
|
|||||||
|
|
||||||
// From preferences
|
// From preferences
|
||||||
public int layout; // Or '-1' for the system defaults
|
public int layout; // Or '-1' for the system defaults
|
||||||
private float swipe_dist_dp;
|
|
||||||
public float swipe_dist_px;
|
public float swipe_dist_px;
|
||||||
public boolean vibrateEnabled;
|
public boolean vibrateEnabled;
|
||||||
public long vibrateDuration;
|
public long vibrateDuration;
|
||||||
@ -103,8 +102,11 @@ final class Config
|
|||||||
keyboardHeightPercent = prefs.getInt("keyboard_height", 35);
|
keyboardHeightPercent = prefs.getInt("keyboard_height", 35);
|
||||||
}
|
}
|
||||||
layout = layoutId_of_string(prefs.getString("layout", "system"));
|
layout = layoutId_of_string(prefs.getString("layout", "system"));
|
||||||
swipe_dist_dp = Float.valueOf(prefs.getString("swipe_dist", "15"));
|
// The swipe distance is defined relatively to the "exact physical pixels
|
||||||
swipe_dist_px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, swipe_dist_dp, dm);
|
// per inch of the screen", which isn't affected by the scaling settings.
|
||||||
|
// Take the mean of both dimensions as an approximation of the diagonal.
|
||||||
|
float physical_scaling = (dm.widthPixels + dm.heightPixels) / (dm.xdpi + dm.ydpi);
|
||||||
|
swipe_dist_px = Float.valueOf(prefs.getString("swipe_dist", "15")) * physical_scaling;;
|
||||||
vibrateEnabled = prefs.getBoolean("vibrate_enabled", vibrateEnabled);
|
vibrateEnabled = prefs.getBoolean("vibrate_enabled", vibrateEnabled);
|
||||||
vibrateDuration = prefs.getInt("vibrate_duration", (int)vibrateDuration);
|
vibrateDuration = prefs.getInt("vibrate_duration", (int)vibrateDuration);
|
||||||
longPressTimeout = prefs.getInt("longpress_timeout", (int)longPressTimeout);
|
longPressTimeout = prefs.getInt("longpress_timeout", (int)longPressTimeout);
|
||||||
|
Loading…
Reference in New Issue
Block a user