+\r
+ /**\r
+ * Called when the 'action' button in an IME is pressed ('enter' in software keyboard).\r
+ * \r
+ * Used to trigger the authorization check when the user presses 'enter' after writing the password.\r
+ */\r
+ @Override\r
+ public boolean onEditorAction(TextView inputField, int actionId, KeyEvent event) {\r
+ if (inputField != null && inputField.equals(mPasswordInput) && \r
+ actionId == EditorInfo.IME_ACTION_DONE) {\r
+ if (mOkButton.isEnabled()) {\r
+ mOkButton.performClick();\r
+ }\r
+ }\r
+ return false; // always return false to grant that the software keyboard is hidden anyway\r
+ }\r
+\r
+\r
+ private abstract static class RightDrawableOnTouchListener implements OnTouchListener {\r
+\r
+ private int fuzz = 75;\r
+ \r
+ /**\r
+ * {@inheritDoc}\r
+ */\r
+ @Override\r
+ public boolean onTouch(View view, MotionEvent event) {\r
+ Drawable rightDrawable = null;\r
+ if (view instanceof TextView) {\r
+ Drawable[] drawables = ((TextView)view).getCompoundDrawables();\r
+ if (drawables.length > 2) {\r
+ rightDrawable = drawables[2];\r
+ }\r
+ }\r
+ if (rightDrawable != null) {\r
+ final int x = (int) event.getX();\r
+ final int y = (int) event.getY();\r
+ final Rect bounds = rightDrawable.getBounds();\r
+ if (x >= (view.getRight() - bounds.width() - fuzz) && x <= (view.getRight() - view.getPaddingRight() + fuzz)\r
+ && y >= (view.getPaddingTop() - fuzz) && y <= (view.getHeight() - view.getPaddingBottom()) + fuzz) {\r
+ \r
+ return onDrawableTouch(event);\r
+ }\r
+ }\r
+ return false;\r
+ }\r
+\r
+ public abstract boolean onDrawableTouch(final MotionEvent event);\r
+ }\r
+\r