From 162f17a7a01b9518c2a36940ce68620c59f20d5e Mon Sep 17 00:00:00 2001 From: jaguillo Date: Thu, 29 Oct 2015 12:49:40 +0100 Subject: Move configs to Config object --- srcs/juloo.keyboard2/KeyPreviewPopup.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'srcs/juloo.keyboard2/KeyPreviewPopup.java') diff --git a/srcs/juloo.keyboard2/KeyPreviewPopup.java b/srcs/juloo.keyboard2/KeyPreviewPopup.java index 0aa5e03..cd96f50 100644 --- a/srcs/juloo.keyboard2/KeyPreviewPopup.java +++ b/srcs/juloo.keyboard2/KeyPreviewPopup.java @@ -15,17 +15,20 @@ class KeyPreviewPopup extends PopupWindow private final TextView _content; private final View _anchor; - private final int _bottomMargin; - private final long _dismissTimeout; + private Config _config; private final Handler _handler; private int _minWidth; - public KeyPreviewPopup(View anchor, long dismissTimeout) + public KeyPreviewPopup(View anchor, Config config) { super(anchor.getContext()); + _config = config; _content = new TextView(anchor.getContext()); + /* + ** TODO: move all resources get to Config object + */ _content.setTextColor(anchor.getResources().getColor(R.color.preview_text)); _content.setTextSize(anchor.getResources().getDimension(R.dimen.preview_text)); int padding = (int)anchor.getResources().getDimension(R.dimen.preview_padding); @@ -33,8 +36,6 @@ class KeyPreviewPopup extends PopupWindow _content.setTextAlignment(View.TEXT_ALIGNMENT_GRAVITY); _content.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL); _anchor = anchor; - _bottomMargin = (int)anchor.getResources().getDimension(R.dimen.preview_margin); - _dismissTimeout = dismissTimeout; _handler = new Handler(this); setMinWidth(0); setWidth(WindowManager.LayoutParams.WRAP_CONTENT); @@ -64,7 +65,7 @@ class KeyPreviewPopup extends PopupWindow if (key == null) { - _handler.sendEmptyMessageDelayed(0, _dismissTimeout); + _handler.sendEmptyMessageDelayed(0, _config.previewDismissTimeout); return ; } _handler.removeMessages(0); @@ -99,7 +100,7 @@ class KeyPreviewPopup extends PopupWindow if (width > _minWidth) setMinWidth(width); x = (_anchor.getMeasuredWidth() - width) / 2; - y = -(height + _bottomMargin); + y = -(height + _config.previewBottomMargin); if (!isShowing()) showAtLocation(_anchor, Gravity.NO_GRAVITY, x, y); update(x, y, width, height); -- cgit v1.2.3