diff options
Diffstat (limited to 'srcs/juloo.keyboard2')
| -rw-r--r-- | srcs/juloo.keyboard2/Config.java | 7 | ||||
| -rw-r--r-- | srcs/juloo.keyboard2/KeyPreviewPopup.java | 108 | ||||
| -rw-r--r-- | srcs/juloo.keyboard2/Keyboard2View.java | 21 |
3 files changed, 0 insertions, 136 deletions
diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java index 80f6004..baecc1b 100644 --- a/srcs/juloo.keyboard2/Config.java +++ b/srcs/juloo.keyboard2/Config.java @@ -10,14 +10,11 @@ class Config private Keyboard2 _context; - public final long previewDismissTimeout; - public final int previewBottomMargin; public final float marginTop; public final float keyPadding; public final float keyBgPadding; public final float keyRound; - public boolean previewEnabled; public float subValueDist; public boolean vibrateEnabled; public long vibrateDuration; @@ -33,14 +30,11 @@ class Config _context = context; // static values - previewDismissTimeout = 150; - previewBottomMargin = (int)res.getDimension(R.dimen.preview_margin); marginTop = res.getDimension(R.dimen.margin_top); keyPadding = res.getDimension(R.dimen.key_padding); keyBgPadding = res.getDimension(R.dimen.key_bg_padding); keyRound = res.getDimension(R.dimen.key_round); // default values - previewEnabled = false; subValueDist = 10f; vibrateEnabled = true; vibrateDuration = 20; @@ -60,7 +54,6 @@ class Config { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(_context); - previewEnabled = prefs.getBoolean("preview_enabled", previewEnabled); subValueDist = prefs.getFloat("sub_value_dist", subValueDist); vibrateEnabled = prefs.getBoolean("vibrate_enabled", vibrateEnabled); vibrateDuration = prefs.getInt("vibrate_duration", (int)vibrateDuration); diff --git a/srcs/juloo.keyboard2/KeyPreviewPopup.java b/srcs/juloo.keyboard2/KeyPreviewPopup.java deleted file mode 100644 index cd96f50..0000000 --- a/srcs/juloo.keyboard2/KeyPreviewPopup.java +++ /dev/null @@ -1,108 +0,0 @@ -package juloo.keyboard2; - -import android.os.Handler; -import android.os.Message; -import android.view.Gravity; -import android.view.View; -import android.view.View.MeasureSpec; -import android.view.WindowManager; -import android.widget.PopupWindow; -import android.widget.TextView; - -class KeyPreviewPopup extends PopupWindow - implements Handler.Callback -{ - private final TextView _content; - private final View _anchor; - - private Config _config; - - private final Handler _handler; - - private int _minWidth; - - 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); - _content.setPaddingRelative(padding, padding, padding, padding); - _content.setTextAlignment(View.TEXT_ALIGNMENT_GRAVITY); - _content.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL); - _anchor = anchor; - _handler = new Handler(this); - setMinWidth(0); - setWidth(WindowManager.LayoutParams.WRAP_CONTENT); - setHeight(WindowManager.LayoutParams.WRAP_CONTENT); - setBackgroundDrawable(anchor.getResources().getDrawable(R.drawable.preview_popup)); - setContentView(_content); - setClippingEnabled(false); - setTouchable(false); - } - - @Override - public boolean handleMessage(Message msg) - { - forceDismiss(); - return (true); - } - - public void forceDismiss() - { - setMinWidth(0); - dismiss(); - } - - public void setPreview(KeyValue key, int flags) - { - StringBuilder preview; - - if (key == null) - { - _handler.sendEmptyMessageDelayed(0, _config.previewDismissTimeout); - return ; - } - _handler.removeMessages(0); - preview = new StringBuilder(); - if ((flags & KeyValue.FLAG_CTRL) != 0) - preview.append("Ctrl-"); - if ((flags & KeyValue.FLAG_ALT) != 0) - preview.append("Alt-"); - if ((flags & KeyValue.FLAG_SHIFT) != 0 && !Character.isLetter(key.getChar(0))) - preview.append("Shift-"); - preview.append(key.getSymbol(flags)); - _content.setText(preview.toString()); - show(); - } - - private void setMinWidth(int minWidth) - { - _minWidth = minWidth; - _content.setMinWidth(minWidth); - } - - private void show() - { - int x; - int y; - int width; - int height; - - _content.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED); - width = _content.getMeasuredWidth(); - height = _content.getMeasuredHeight(); - if (width > _minWidth) - setMinWidth(width); - x = (_anchor.getMeasuredWidth() - width) / 2; - y = -(height + _config.previewBottomMargin); - if (!isShowing()) - showAtLocation(_anchor, Gravity.NO_GRAVITY, x, y); - update(x, y, width, height); - } -} diff --git a/srcs/juloo.keyboard2/Keyboard2View.java b/srcs/juloo.keyboard2/Keyboard2View.java index 86c78ab..041b881 100644 --- a/srcs/juloo.keyboard2/Keyboard2View.java +++ b/srcs/juloo.keyboard2/Keyboard2View.java @@ -34,13 +34,6 @@ public class Keyboard2View extends View private Handler _handler; private static int _currentWhat = 0; - private KeyPreviewPopup _previewPopup; - - /* - ** TODO: settings: preview_text_size - ** TODO: settings: preview_timeout - ** TODO: disable preview in password fields - */ private Config _config; private float _keyWidth; @@ -64,7 +57,6 @@ public class Keyboard2View extends View _vibratorService = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE); _handler = new Handler(this); _config = ((Keyboard2)context).getConfig(); - _previewPopup = new KeyPreviewPopup(this, _config); _keyBgPaint.setColor(getResources().getColor(R.color.key_bg)); _keyDownBgPaint.setColor(getResources().getColor(R.color.key_down_bg)); _keyLabelPaint = initLabelPaint(_keyLabelPaint, Paint.Align.CENTER, R.color.key_label, R.dimen.label_text_size, null); @@ -273,24 +265,12 @@ public class Keyboard2View extends View { if (key.value != null && (key.flags & (KeyValue.FLAG_LOCKED | KeyValue.FLAG_NOCHAR)) == 0) ((Keyboard2)getContext()).handleKeyUp(key.value, _flags); - // previewNextKeyDown - if (!_config.previewEnabled) - return ; - for (KeyDown k : _downKeys) - if ((k.value.getFlags() & (KeyValue.FLAG_KEY_FONT | KeyValue.FLAG_NOREPEAT | KeyValue.FLAG_NOCHAR)) == 0) - { - _previewPopup.setPreview(k.value, _flags); - return ; - } - _previewPopup.setPreview(null, 0); } private void handleKeyDown(KeyValue key) { if (key == null) return ; - if (_config.previewEnabled && (key.getFlags() & (KeyValue.FLAG_KEY_FONT | KeyValue.FLAG_NOREPEAT | KeyValue.FLAG_NOCHAR)) == 0) - _previewPopup.setPreview(key, _flags); vibrate(); } @@ -395,7 +375,6 @@ public class Keyboard2View extends View public void onDetachedFromWindow() { super.onDetachedFromWindow(); - _previewPopup.forceDismiss(); } private void drawLabel(Canvas canvas, KeyValue k, float x, float y, boolean locked) |
