android:orientation="vertical" \r
>\r
\r
- <FrameLayout\r
+ <EditText\r
+ android:id="@+id/hostUrlInput"\r
android:layout_width="match_parent"\r
android:layout_height="wrap_content"\r
- >\r
- \r
- <EditText\r
- android:id="@+id/hostUrlInput"\r
- android:layout_width="match_parent"\r
- android:layout_height="wrap_content"\r
- android:ems="10"\r
- android:hint="@string/auth_host_url"\r
- android:inputType="textUri"\r
- >\r
- <requestFocus />\r
- </EditText>\r
- \r
- <ImageView\r
- android:id="@+id/refreshButton"\r
- android:layout_width="wrap_content"\r
- android:layout_height="wrap_content"\r
- android:layout_gravity="right|center_vertical"\r
- android:src="@drawable/ic_action_refresh_black"\r
- android:onClick="onRefreshClick"\r
- android:visibility="invisible" />\r
- \r
- </FrameLayout>\r
+ android:ems="10"\r
+ android:hint="@string/auth_host_url"\r
+ android:inputType="textUri"\r
+ android:drawablePadding="5dp"\r
+ >\r
+ <requestFocus />\r
+ </EditText>\r
\r
<TextView\r
android:id="@+id/server_status_text"\r
android:layout_marginTop="10dp"\r
android:src="@drawable/logo" />\r
\r
- <FrameLayout\r
- android:layout_width="match_parent"\r
- android:layout_height="wrap_content" >\r
-\r
- <EditText\r
- android:id="@+id/hostUrlInput"\r
- android:layout_width="match_parent"\r
- android:layout_height="wrap_content"\r
- android:ems="10"\r
- android:hint="@string/auth_host_url"\r
- android:inputType="textUri" >\r
-\r
- <requestFocus />\r
- </EditText>\r
-\r
- <ImageView\r
- android:id="@+id/refreshButton"\r
- android:layout_width="wrap_content"\r
- android:layout_height="wrap_content"\r
- android:layout_gravity="right|center_vertical"\r
- android:src="@drawable/ic_action_refresh_black"\r
- android:onClick="onRefreshClick"\r
- android:visibility="invisible" />\r
- </FrameLayout>\r
+ <EditText\r
+ android:id="@+id/hostUrlInput"\r
+ android:layout_width="match_parent"\r
+ android:layout_height="wrap_content"\r
+ android:ems="10"\r
+ android:hint="@string/auth_host_url"\r
+ android:inputType="textUri"\r
+ android:drawablePadding="5dp"\r
+ >\r
+ <requestFocus />\r
+ </EditText>\r
\r
<TextView\r
android:id="@+id/server_status_text"\r
import android.content.DialogInterface;\r
import android.content.Intent;\r
import android.content.SharedPreferences;\r
+import android.graphics.Rect;\r
+import android.graphics.drawable.Drawable;\r
import android.net.Uri;\r
import android.os.Bundle;\r
import android.os.Handler;\r
import android.preference.PreferenceManager;\r
import android.text.InputType;\r
import android.view.KeyEvent;\r
+import android.view.MotionEvent;\r
import android.view.View;\r
import android.view.View.OnFocusChangeListener;\r
+import android.view.View.OnTouchListener;\r
import android.view.Window;\r
import android.view.inputmethod.EditorInfo;\r
import android.widget.CheckBox;\r
private byte mAction;\r
private Account mAccount;\r
\r
- private ImageView mRefreshButton;\r
private ImageView mViewPasswordButton;\r
private EditText mHostUrlInput;\r
private EditText mUsernameInput;\r
\r
/// set view and get references to view elements\r
setContentView(R.layout.account_setup);\r
- mRefreshButton = (ImageView) findViewById(R.id.refreshButton);\r
mViewPasswordButton = (ImageView) findViewById(R.id.viewPasswordButton);\r
mHostUrlInput = (EditText) findViewById(R.id.hostUrlInput);\r
mUsernameInput = (EditText) findViewById(R.id.account_username);\r
\r
/// bind view elements to listeners\r
mHostUrlInput.setOnFocusChangeListener(this);\r
+ mHostUrlInput.setOnTouchListener(new RightDrawableOnTouchListener() {\r
+ @Override\r
+ public boolean onDrawableTouch(final MotionEvent event) {\r
+ AuthenticatorActivity.this.onRefreshClick(mHostUrlInput);\r
+ return true;\r
+ }\r
+ });\r
mPasswordInput.setOnFocusChangeListener(this);\r
mPasswordInput.setImeOptions(EditorInfo.IME_ACTION_DONE);\r
mPasswordInput.setOnEditorActionListener(this);\r
\r
/// UI settings depending upon connection\r
mOkButton.setEnabled(mStatusCorrect); \r
- if (!mStatusCorrect)\r
- mRefreshButton.setVisibility(View.VISIBLE); // seems that setting visibility is necessary\r
- else\r
- mRefreshButton.setVisibility(View.INVISIBLE);\r
+ if (!mStatusCorrect) {\r
+ mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_action_refresh_black, 0);\r
+ } else {\r
+ mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);\r
+ }\r
\r
/// server data\r
String ocVersion = savedInstanceState.getString(KEY_OC_VERSION);\r
mDiscoveredVersion = null;\r
mOperationThread = mOcServerChkOperation.execute(client, this, mHandler);\r
} else {\r
- mRefreshButton.setVisibility(View.INVISIBLE);\r
+ mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);\r
mStatusText = 0;\r
mStatusIcon = 0;\r
updateConnStatus();\r
}\r
\r
/// update the visibility of the 'retry connection' button\r
- if (!mStatusCorrect)\r
- mRefreshButton.setVisibility(View.VISIBLE);\r
- else\r
- mRefreshButton.setVisibility(View.INVISIBLE);\r
+ if (!mStatusCorrect) {\r
+ mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_action_refresh_black, 0);\r
+ } else {\r
+ mHostUrlInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);\r
+ }\r
\r
/// retrieve discovered version and normalize server URL\r
mDiscoveredVersion = operation.getDiscoveredVersion();\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 = 10;\r
+ \r
+ /**\r
+ * {@inheritDoc}\r
+ */\r
+ @Override\r
+ public boolean onTouch(View view, MotionEvent event) {\r
+ if (event.getAction() == MotionEvent.ACTION_DOWN) {\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
+ }\r
+ return false;\r
+ }\r
+ \r
+ public abstract boolean onDrawableTouch(final MotionEvent event);\r
+ }\r
+ \r
}\r