From b8b0f412d3011fc5e8cb571d65a0fd7a6e09a0f8 Mon Sep 17 00:00:00 2001 From: jaguillo Date: Wed, 30 Sep 2015 22:47:18 +0200 Subject: [PATCH] Add margin_bottom, key_height and horizontal_margin configs --- project.properties | 2 +- res/values/strings.xml | 8 ++++++++ res/xml/settings.xml | 26 +++++++++++++++++++++++++ srcs/juloo.keyboard2/Keyboard2View.java | 17 +++++++++------- 4 files changed, 45 insertions(+), 8 deletions(-) diff --git a/project.properties b/project.properties index 00cf62b..916037e 100644 --- a/project.properties +++ b/project.properties @@ -11,4 +11,4 @@ #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt # Project target. -target=android-22 +target=android-23 diff --git a/res/values/strings.xml b/res/values/strings.xml index 103d0d9..0928cce 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -27,4 +27,12 @@ Duration %sms + Style + Margin bottom + %sdp + Key height + %sdp + Horizontal margin + %sdp + diff --git a/res/xml/settings.xml b/res/xml/settings.xml index fe6dbef..2bc4299 100644 --- a/res/xml/settings.xml +++ b/res/xml/settings.xml @@ -50,4 +50,30 @@ max="50" /> + + + + + diff --git a/srcs/juloo.keyboard2/Keyboard2View.java b/srcs/juloo.keyboard2/Keyboard2View.java index 0e70282..b5148f7 100644 --- a/srcs/juloo.keyboard2/Keyboard2View.java +++ b/srcs/juloo.keyboard2/Keyboard2View.java @@ -3,14 +3,15 @@ package juloo.keyboard2; import android.content.Context; import android.content.SharedPreferences; import android.graphics.Canvas; -import android.graphics.RectF; import android.graphics.Paint; -import android.preference.PreferenceManager; -import android.util.AttributeSet; -import android.util.DisplayMetrics; +import android.graphics.RectF; import android.os.Handler; import android.os.Message; import android.os.Vibrator; +import android.preference.PreferenceManager; +import android.util.AttributeSet; +import android.util.DisplayMetrics; +import android.util.TypedValue; import android.view.MotionEvent; import android.view.View; import java.util.LinkedList; @@ -35,10 +36,8 @@ public class Keyboard2View extends View private Handler _handler; private static int _currentWhat = 0; - private float _horizontalMargin; private float _marginTop; private float _keyWidth; - private float _keyHeight; private float _keyPadding; private float _keyBgPadding; private float _keyRound; @@ -49,6 +48,8 @@ public class Keyboard2View extends View private long _longPressTimeout = 600; private long _longPressInterval = 65; private float _marginBottom; + private float _keyHeight; + private float _horizontalMargin; private Paint _keyBgPaint = new Paint(); private Paint _keyDownBgPaint = new Paint(); @@ -91,7 +92,9 @@ public class Keyboard2View extends View _vibrateDuration = prefs.getInt("vibrate_duration", (int)_vibrateDuration); _longPressTimeout = prefs.getInt("longpress_timeout", (int)_longPressTimeout); _longPressInterval = prefs.getInt("longpress_interval", (int)_longPressInterval); - _marginBottom = prefs.getFloat("margin_bottom", _marginBottom); + _marginBottom = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, prefs.getInt("margin_bottom", (int)_marginBottom), getResources().getDisplayMetrics()); + _keyHeight = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, prefs.getInt("key_height", (int)_keyHeight), getResources().getDisplayMetrics()); + _horizontalMargin = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, prefs.getInt("horizontal_margin", (int)_horizontalMargin), getResources().getDisplayMetrics()); String keyboardLayout = prefs.getString("keyboard_layout", null); int xmlRes = 0;