From 804e9a7adcc58d81327873ba787c2230eeee350b Mon Sep 17 00:00:00 2001 From: jaguillo Date: Wed, 28 Oct 2015 00:39:20 +0100 Subject: Fix some bugs + Try to show a preview popup --- srcs/juloo.keyboard2/KeyPreviewPopup.java | 38 +++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 srcs/juloo.keyboard2/KeyPreviewPopup.java (limited to 'srcs/juloo.keyboard2/KeyPreviewPopup.java') diff --git a/srcs/juloo.keyboard2/KeyPreviewPopup.java b/srcs/juloo.keyboard2/KeyPreviewPopup.java new file mode 100644 index 0000000..3eb1505 --- /dev/null +++ b/srcs/juloo.keyboard2/KeyPreviewPopup.java @@ -0,0 +1,38 @@ +package juloo.keyboard2; + +import android.view.Gravity; +import android.view.View; +import android.view.WindowManager; +import android.widget.PopupWindow; +import android.widget.TextView; + +class KeyPreviewPopup extends PopupWindow +{ + private TextView _content; + private View _anchor; + + public KeyPreviewPopup(View anchor) + { + super(anchor.getContext()); + _content = new TextView(anchor.getContext()); + _content.setTextColor(0xFFFFFFFF); + _anchor = anchor; + setWidth(WindowManager.LayoutParams.WRAP_CONTENT); + setHeight(WindowManager.LayoutParams.WRAP_CONTENT); + setContentView(_content); + setTouchable(false); + } + + public void setPreview(String preview) + { + System.out.println("popup preview: " + preview); + if (preview == null) + dismiss(); + else + { + _content.setText(preview); + if (!isShowing()) + showAtLocation(_anchor, Gravity.CENTER_HORIZONTAL | Gravity.TOP, 0, -400); + } + } +} -- cgit v1.2.3