* \r
*/\r
public class AuthenticatorActivity extends AccountAuthenticatorActivity\r
- implements OnAuthenticationResultListener,\r
- OnConnectCheckListener,\r
- OnFocusChangeListener,\r
- OnClickListener {\r
- private static final int DIALOG_LOGIN_PROGRESS = 0;\r
- \r
- private static final String TAG = "AuthActivity";\r
-\r
- private Thread mAuthThread;\r
- private AuthenticationRunnable mAuthRunnable;\r
- private ConnectionCheckerRunnable mConnChkRunnable;\r
- private final Handler mHandler = new Handler();\r
- private String mBaseUrl;\r
- \r
- private static final String STATUS_TEXT = "STATUS_TEXT"; \r
- private static final String STATUS_ICON = "STATUS_ICON";\r
- private static final String STATUS_CORRECT = "STATUS_CORRECT";\r
- private static final String IS_SSL_CONN = "IS_SSL_CONN";\r
- private int mStatusText, mStatusIcon;\r
- private boolean mStatusCorrect, mIsSslConn;\r
-\r
- public static final String PARAM_USERNAME = "param_Username";\r
- public static final String PARAM_HOSTNAME = "param_Hostname";\r
-\r
- @Override\r
- protected void onCreate(Bundle savedInstanceState) {\r
- super.onCreate(savedInstanceState);\r
- getWindow().requestFeature(Window.FEATURE_NO_TITLE);\r
- setContentView(R.layout.account_setup);\r
- ImageView iv = (ImageView) findViewById(R.id.refreshButton);\r
- ImageView iv2 = (ImageView) findViewById(R.id.viewPassword);\r
- TextView tv = (TextView) findViewById(R.id.host_URL);\r
- TextView tv2 = (TextView) findViewById(R.id.account_password);\r
- \r
- if (savedInstanceState != null) {\r
- mStatusIcon = savedInstanceState.getInt(STATUS_ICON);\r
- mStatusText = savedInstanceState.getInt(STATUS_TEXT);\r
- mStatusCorrect = savedInstanceState.getBoolean(STATUS_CORRECT);\r
- mIsSslConn = savedInstanceState.getBoolean(IS_SSL_CONN);\r
- setResultIconAndText(mStatusIcon, mStatusText);\r
- findViewById(R.id.buttonOK).setEnabled(mStatusCorrect);\r
- if (!mStatusCorrect)\r
- iv.setVisibility(View.VISIBLE);\r
- else\r
- iv.setVisibility(View.INVISIBLE);\r
- \r
- } else {\r
- mStatusText = mStatusIcon = 0;\r
- mStatusCorrect = false;\r
- mIsSslConn = false;\r
+ implements OnAuthenticationResultListener, OnConnectCheckListener,\r
+ OnFocusChangeListener, OnClickListener {\r
+ private static final int DIALOG_LOGIN_PROGRESS = 0;\r
+\r
+ private static final String TAG = "AuthActivity";\r
+\r
+ private Thread mAuthThread;\r
+ private AuthenticationRunnable mAuthRunnable;\r
+ private ConnectionCheckerRunnable mConnChkRunnable;\r
+ private final Handler mHandler = new Handler();\r
+ private String mBaseUrl;\r
+\r
+ private static final String STATUS_TEXT = "STATUS_TEXT";\r
+ private static final String STATUS_ICON = "STATUS_ICON";\r
+ private static final String STATUS_CORRECT = "STATUS_CORRECT";\r
+ private static final String IS_SSL_CONN = "IS_SSL_CONN";\r
+ private int mStatusText, mStatusIcon;\r
+ private boolean mStatusCorrect, mIsSslConn;\r
+\r
+ public static final String PARAM_USERNAME = "param_Username";\r
+ public static final String PARAM_HOSTNAME = "param_Hostname";\r
+\r
+ @Override\r
+ protected void onCreate(Bundle savedInstanceState) {\r
+ super.onCreate(savedInstanceState);\r
+ getWindow().requestFeature(Window.FEATURE_NO_TITLE);\r
+ setContentView(R.layout.account_setup);\r
+ ImageView iv = (ImageView) findViewById(R.id.refreshButton);\r
+ ImageView iv2 = (ImageView) findViewById(R.id.viewPassword);\r
+ TextView tv = (TextView) findViewById(R.id.host_URL);\r
+ TextView tv2 = (TextView) findViewById(R.id.account_password);\r
+\r
+ if (savedInstanceState != null) {\r
+ mStatusIcon = savedInstanceState.getInt(STATUS_ICON);\r
+ mStatusText = savedInstanceState.getInt(STATUS_TEXT);\r
+ mStatusCorrect = savedInstanceState.getBoolean(STATUS_CORRECT);\r
+ mIsSslConn = savedInstanceState.getBoolean(IS_SSL_CONN);\r
+ setResultIconAndText(mStatusIcon, mStatusText);\r
+ findViewById(R.id.buttonOK).setEnabled(mStatusCorrect);\r
+ if (!mStatusCorrect)\r
+ iv.setVisibility(View.VISIBLE);\r
+ else\r
+ iv.setVisibility(View.INVISIBLE);\r
+\r
+ } else {\r
+ mStatusText = mStatusIcon = 0;\r
+ mStatusCorrect = false;\r
+ mIsSslConn = false;\r
+ }\r
+ iv.setOnClickListener(this);\r
+ iv2.setOnClickListener(this);\r
+ tv.setOnFocusChangeListener(this);\r
+ tv2.setOnFocusChangeListener(this);\r
}\r
- iv.setOnClickListener(this);\r
- iv2.setOnClickListener(this);\r
- tv.setOnFocusChangeListener(this);\r
- tv2.setOnFocusChangeListener(this);\r
- }\r
-\r
- @Override\r
- protected void onSaveInstanceState(Bundle outState) {\r
- outState.putInt(STATUS_ICON, mStatusIcon);\r
- outState.putInt(STATUS_TEXT, mStatusText);\r
- outState.putBoolean(STATUS_CORRECT, mStatusCorrect);\r
- super.onSaveInstanceState(outState);\r
- }\r
-\r
- @Override\r
- protected Dialog onCreateDialog(int id) {\r
- Dialog dialog = null;\r
- switch (id) {\r
- case DIALOG_LOGIN_PROGRESS : {\r
- ProgressDialog working_dialog = new ProgressDialog(this);\r
- working_dialog.setMessage(getResources().getString(R.string.auth_trying_to_login));\r
- working_dialog.setIndeterminate(true);\r
- working_dialog.setCancelable(true);\r
- working_dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {\r
- @Override\r
- public void onCancel(DialogInterface dialog) {\r
- Log.i(TAG, "Login canceled");\r
- if (mAuthThread != null) {\r
- mAuthThread.interrupt();\r
- finish();\r
+\r
+ @Override\r
+ protected void onSaveInstanceState(Bundle outState) {\r
+ outState.putInt(STATUS_ICON, mStatusIcon);\r
+ outState.putInt(STATUS_TEXT, mStatusText);\r
+ outState.putBoolean(STATUS_CORRECT, mStatusCorrect);\r
+ super.onSaveInstanceState(outState);\r
+ }\r
+\r
+ @Override\r
+ protected Dialog onCreateDialog(int id) {\r
+ Dialog dialog = null;\r
+ switch (id) {\r
+ case DIALOG_LOGIN_PROGRESS: {\r
+ ProgressDialog working_dialog = new ProgressDialog(this);\r
+ working_dialog.setMessage(getResources().getString(\r
+ R.string.auth_trying_to_login));\r
+ working_dialog.setIndeterminate(true);\r
+ working_dialog.setCancelable(true);\r
+ working_dialog\r
+ .setOnCancelListener(new DialogInterface.OnCancelListener() {\r
+ @Override\r
+ public void onCancel(DialogInterface dialog) {\r
+ Log.i(TAG, "Login canceled");\r
+ if (mAuthThread != null) {\r
+ mAuthThread.interrupt();\r
+ finish();\r
+ }\r
+ }\r
+ });\r
+ dialog = working_dialog;\r
+ break;\r
+ }\r
+ default:\r
+ Log.e(TAG, "Incorrect dialog called with id = " + id);\r
+ }\r
+ return dialog;\r
+ }\r
+\r
+ public void onAuthenticationResult(boolean success, String message) {\r
+ if (success) {\r
+ TextView username_text = (TextView) findViewById(R.id.account_username), password_text = (TextView) findViewById(R.id.account_password);\r
+\r
+ URL url;\r
+ try {\r
+ url = new URL(message);\r
+ } catch (MalformedURLException e) {\r
+ // should never happen\r
+ Log.e(getClass().getName(), "Malformed URL: " + message);\r
+ return;\r
+ }\r
+\r
+ String username = username_text.getText().toString().trim();\r
+ String accountName = username + "@" + url.getHost();\r
+ Account account = new Account(accountName,\r
+ AccountAuthenticator.ACCOUNT_TYPE);\r
+ AccountManager accManager = AccountManager.get(this);\r
+ accManager.addAccountExplicitly(account, password_text.getText()\r
+ .toString(), null);\r
+\r
+ // Add this account as default in the preferences, if there is none\r
+ // already\r
+ Account defaultAccount = AccountUtils\r
+ .getCurrentOwnCloudAccount(this);\r
+ if (defaultAccount == null) {\r
+ SharedPreferences.Editor editor = PreferenceManager\r
+ .getDefaultSharedPreferences(this).edit();\r
+ editor.putString("select_oc_account", accountName);\r
+ editor.commit();\r
}\r
- }\r
- });\r
- dialog = working_dialog;\r
- break;\r
- }\r
- default :\r
- Log.e(TAG, "Incorrect dialog called with id = " + id);\r
+\r
+ final Intent intent = new Intent();\r
+ intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE,\r
+ AccountAuthenticator.ACCOUNT_TYPE);\r
+ intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, account.name);\r
+ intent.putExtra(AccountManager.KEY_AUTHTOKEN,\r
+ AccountAuthenticator.ACCOUNT_TYPE);\r
+ intent.putExtra(AccountManager.KEY_USERDATA, username);\r
+\r
+ accManager.setUserData(account, AccountAuthenticator.KEY_OC_URL,\r
+ url.toString());\r
+ accManager.setUserData(account,\r
+ AccountAuthenticator.KEY_OC_VERSION, mConnChkRunnable\r
+ .getDiscoveredVersion().toString());\r
+ accManager.setUserData(account,\r
+ AccountAuthenticator.KEY_OC_BASE_URL, mBaseUrl);\r
+\r
+ setAccountAuthenticatorResult(intent.getExtras());\r
+ setResult(RESULT_OK, intent);\r
+ Bundle bundle = new Bundle();\r
+ bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);\r
+ //getContentResolver().startSync(ProviderTableMeta.CONTENT_URI,\r
+ // bundle);\r
+ ContentResolver.requestSync(account, "org.owncloud", bundle);\r
+\r
+ /*\r
+ * if\r
+ * (mConnChkRunnable.getDiscoveredVersion().compareTo(OwnCloudVersion\r
+ * .owncloud_v2) >= 0) { Intent i = new Intent(this,\r
+ * ExtensionsAvailableActivity.class); startActivity(i); }\r
+ */\r
+\r
+ finish();\r
+ } else {\r
+ dismissDialog(DIALOG_LOGIN_PROGRESS);\r
+ TextView tv = (TextView) findViewById(R.id.account_username);\r
+ tv.setError(message);\r
+ }\r
}\r
- return dialog;\r
- }\r
-\r
- public void onAuthenticationResult(boolean success, String message) {\r
- if (success) {\r
- TextView username_text = (TextView) findViewById(R.id.account_username), password_text = (TextView) findViewById(R.id.account_password);\r
-\r
- URL url;\r
- try {\r
- url = new URL(message);\r
- } catch (MalformedURLException e) {\r
- // should never happen\r
- Log.e(getClass().getName(), "Malformed URL: " + message);\r
- return;\r
- }\r
-\r
- String username = username_text.getText().toString().trim();\r
- String accountName = username + "@" + url.getHost();\r
- Account account = new Account(accountName,\r
- AccountAuthenticator.ACCOUNT_TYPE);\r
- AccountManager accManager = AccountManager.get(this);\r
- accManager.addAccountExplicitly(account, password_text.getText()\r
- .toString(), null);\r
-\r
- // Add this account as default in the preferences, if there is none\r
- // already\r
- Account defaultAccount = AccountUtils.getCurrentOwnCloudAccount(this);\r
- if (defaultAccount == null) {\r
- SharedPreferences.Editor editor = PreferenceManager\r
- .getDefaultSharedPreferences(this).edit();\r
- editor.putString("select_oc_account", accountName);\r
- editor.commit();\r
- }\r
-\r
- final Intent intent = new Intent();\r
- intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, AccountAuthenticator.ACCOUNT_TYPE);\r
- intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, account.name);\r
- intent.putExtra(AccountManager.KEY_AUTHTOKEN, AccountAuthenticator.ACCOUNT_TYPE);\r
- intent.putExtra(AccountManager.KEY_USERDATA, username);\r
-\r
- accManager.setUserData(account,\r
- AccountAuthenticator.KEY_OC_URL,\r
- url.toString());\r
- accManager.setUserData(account,\r
- AccountAuthenticator.KEY_OC_VERSION,\r
- mConnChkRunnable.getDiscoveredVersion().toString());\r
- accManager.setUserData(account,\r
- AccountAuthenticator.KEY_OC_BASE_URL,\r
- mBaseUrl);\r
-\r
- setAccountAuthenticatorResult(intent.getExtras());\r
- setResult(RESULT_OK, intent);\r
- Bundle bundle = new Bundle();\r
- bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);\r
- getContentResolver().startSync(ProviderTableMeta.CONTENT_URI, bundle);\r
-\r
- /*if (mConnChkRunnable.getDiscoveredVersion().compareTo(OwnCloudVersion.owncloud_v2) >= 0) {\r
- Intent i = new Intent(this, ExtensionsAvailableActivity.class);\r
- startActivity(i);\r
- }*/\r
-\r
- finish();\r
- } else {\r
- dismissDialog(DIALOG_LOGIN_PROGRESS);\r
- TextView tv = (TextView) findViewById(R.id.account_username);\r
- tv.setError(message);\r
+ public void onCancelClick(View view) {\r
+ finish();\r
}\r
- }\r
-\r
- public void onOkClick(View view) {\r
- String prefix = "";\r
- String url = ((TextView) findViewById(R.id.host_URL)).getText().toString();\r
- if (mIsSslConn) {\r
- prefix = "https://";\r
- } else {\r
- prefix = "http://";\r
+ \r
+ public void onOkClick(View view) {\r
+ String prefix = "";\r
+ String url = ((TextView) findViewById(R.id.host_URL)).getText()\r
+ .toString();\r
+ if (mIsSslConn) {\r
+ prefix = "https://";\r
+ } else {\r
+ prefix = "http://";\r
+ }\r
+ if (url.toLowerCase().startsWith("http://")\r
+ || url.toLowerCase().startsWith("https://")) {\r
+ prefix = "";\r
+ }\r
+ continueConnection(prefix);\r
}\r
- if (url.toLowerCase().startsWith("http://") || url.toLowerCase().startsWith("https://")) {\r
- prefix = "";\r
+\r
+ private void continueConnection(String prefix) {\r
+ String url = ((TextView) findViewById(R.id.host_URL)).getText()\r
+ .toString();\r
+ String username = ((TextView) findViewById(R.id.account_username))\r
+ .getText().toString();\r
+ String password = ((TextView) findViewById(R.id.account_password))\r
+ .getText().toString();\r
+ if (url.endsWith("/"))\r
+ url = url.substring(0, url.length() - 1);\r
+\r
+ URL uri = null;\r
+ String webdav_path = AccountUtils.getWebdavPath(mConnChkRunnable\r
+ .getDiscoveredVersion());\r
+\r
+ try {\r
+ mBaseUrl = prefix + url;\r
+ String url_str = prefix + url + webdav_path;\r
+ uri = new URL(url_str);\r
+ } catch (MalformedURLException e) {\r
+ // should not happend\r
+ e.printStackTrace();\r
+ }\r
+\r
+ showDialog(DIALOG_LOGIN_PROGRESS);\r
+ mAuthRunnable = new AuthenticationRunnable(uri, username, password);\r
+ mAuthRunnable.setOnAuthenticationResultListener(this, mHandler);\r
+ mAuthThread = new Thread(mAuthRunnable);\r
+ mAuthThread.start();\r
}\r
- continueConnection(prefix);\r
- }\r
- \r
- private void continueConnection(String prefix) {\r
- String url = ((TextView) findViewById(R.id.host_URL)).getText().toString();\r
- String username = ((TextView) findViewById(R.id.account_username)).getText().toString();\r
- String password = ((TextView) findViewById(R.id.account_password)).getText().toString();\r
- if (url.endsWith("/"))\r
- url = url.substring(0, url.length()-1);\r
-\r
- URL uri = null;\r
- String webdav_path = AccountUtils.getWebdavPath(mConnChkRunnable.getDiscoveredVersion());\r
-\r
- try {\r
- mBaseUrl = prefix + url;\r
- String url_str = prefix + url + webdav_path;\r
- uri = new URL(url_str);\r
- } catch (MalformedURLException e) {\r
- // should not happend\r
- e.printStackTrace();\r
+\r
+ @Override\r
+ public void onConnectionCheckResult(ResultType type) {\r
+ mStatusText = mStatusIcon = 0;\r
+ mStatusCorrect = false;\r
+ String t_url = ((TextView) findViewById(R.id.host_URL)).getText()\r
+ .toString().toLowerCase();\r
+\r
+ switch (type) {\r
+ case OK:\r
+ // ugly as hell\r
+ if (t_url.startsWith("http://") || t_url.startsWith("https://")) {\r
+ mIsSslConn = t_url.startsWith("http://") ? false : true;\r
+ mStatusIcon = R.drawable.ic_ok;\r
+ mStatusText = R.string.auth_connection_established;\r
+ mStatusCorrect = true;\r
+ } else {\r
+ mIsSslConn = true;\r
+ mStatusIcon = android.R.drawable.ic_secure;\r
+ mStatusText = R.string.auth_secure_connection;\r
+ mStatusCorrect = true;\r
+ }\r
+ break;\r
+ case OK_NO_SSL:\r
+ mStatusIcon = android.R.drawable.ic_secure;\r
+ mStatusText = R.string.auth_nossl_plain_ok_title;\r
+ mStatusCorrect = true;\r
+ mIsSslConn = false;\r
+ break;\r
+ case TIMEOUT:\r
+ case INORRECT_ADDRESS:\r
+ case SSL_INIT_ERROR:\r
+ case HOST_NOT_AVAILABLE:\r
+ mStatusIcon = R.drawable.common_error;\r
+ mStatusText = R.string.auth_unknow_host_title;\r
+ break;\r
+ case NO_NETWORK_CONNECTION:\r
+ mStatusIcon = R.drawable.no_network;\r
+ mStatusText = R.string.auth_no_net_conn_title;\r
+ break;\r
+ case INSTANCE_NOT_CONFIGURED:\r
+ mStatusIcon = R.drawable.common_error;\r
+ mStatusText = R.string.auth_not_configured_title;\r
+ break;\r
+ case UNKNOWN_ERROR:\r
+ mStatusIcon = R.drawable.common_error;\r
+ mStatusText = R.string.auth_unknow_error;\r
+ break;\r
+ case FILE_NOT_FOUND:\r
+ mStatusIcon = R.drawable.common_error;\r
+ mStatusText = R.string.auth_incorrect_path_title;\r
+ break;\r
+ default:\r
+ Log.e(TAG, "Incorrect connection checker result type: " + type);\r
+ }\r
+ setResultIconAndText(mStatusIcon, mStatusText);\r
+ if (!mStatusCorrect)\r
+ findViewById(R.id.refreshButton).setVisibility(View.VISIBLE);\r
+ else\r
+ findViewById(R.id.refreshButton).setVisibility(View.INVISIBLE);\r
+ findViewById(R.id.buttonOK).setEnabled(mStatusCorrect);\r
}\r
\r
- showDialog(DIALOG_LOGIN_PROGRESS);\r
- mAuthRunnable = new AuthenticationRunnable(uri, username, password);\r
- mAuthRunnable.setOnAuthenticationResultListener(this, mHandler);\r
- mAuthThread = new Thread(mAuthRunnable);\r
- mAuthThread.start();\r
- }\r
- \r
- @Override\r
- public void onConnectionCheckResult(ResultType type) {\r
- mStatusText = mStatusIcon = 0;\r
- mStatusCorrect = false;\r
- String t_url = ((TextView) findViewById(R.id.host_URL)).getText().toString().toLowerCase();\r
-\r
- switch (type) {\r
- case OK:\r
- // ugly as hell\r
- if (t_url.startsWith("http://") || t_url.startsWith("https://")) {\r
- mIsSslConn = t_url.startsWith("http://") ? false : true;\r
- mStatusIcon = R.drawable.ic_ok;\r
- mStatusText = R.string.auth_connection_established;\r
- mStatusCorrect = true;\r
- } else {\r
- mIsSslConn = true;\r
- mStatusIcon = android.R.drawable.ic_secure;\r
- mStatusText = R.string.auth_secure_connection;\r
- mStatusCorrect = true; \r
+ @Override\r
+ public void onFocusChange(View view, boolean hasFocus) {\r
+ if (view.getId() == R.id.host_URL) {\r
+ if (!hasFocus) {\r
+ TextView tv = ((TextView) findViewById(R.id.host_URL));\r
+ String uri = tv.getText().toString();\r
+ if (uri.length() != 0) {\r
+ setResultIconAndText(R.drawable.progress_small,\r
+ R.string.auth_testing_connection);\r
+ findViewById(R.id.buttonOK).setEnabled(false); // avoid connect can be clicked if the test was previously passed\r
+ mConnChkRunnable = new ConnectionCheckerRunnable(uri, this);\r
+ mConnChkRunnable.setListener(this, mHandler);\r
+ mAuthThread = new Thread(mConnChkRunnable);\r
+ mAuthThread.start();\r
+ } else {\r
+ findViewById(R.id.refreshButton).setVisibility(\r
+ View.INVISIBLE);\r
+ setResultIconAndText(0, 0);\r
+ }\r
+ }\r
+ } else if (view.getId() == R.id.account_password) {\r
+ ImageView iv = (ImageView) findViewById(R.id.viewPassword);\r
+ if (hasFocus) {\r
+ iv.setVisibility(View.VISIBLE);\r
+ } else {\r
+ TextView v = (TextView) findViewById(R.id.account_password);\r
+ int input_type = InputType.TYPE_CLASS_TEXT\r
+ | InputType.TYPE_TEXT_VARIATION_PASSWORD;\r
+ v.setInputType(input_type);\r
+ iv.setVisibility(View.INVISIBLE);\r
+ }\r
}\r
- break;\r
- case OK_NO_SSL:\r
- mStatusIcon = android.R.drawable.ic_secure;\r
- mStatusText = R.string.auth_nossl_plain_ok_title;\r
- mStatusCorrect = true;\r
- mIsSslConn = false;\r
- break;\r
- case TIMEOUT:\r
- case INORRECT_ADDRESS:\r
- case SSL_INIT_ERROR:\r
- case HOST_NOT_AVAILABLE:\r
- mStatusIcon = R.drawable.common_error;\r
- mStatusText = R.string.auth_unknow_host_title;\r
- break;\r
- case NO_NETWORK_CONNECTION:\r
- mStatusIcon = R.drawable.no_network;\r
- mStatusText = R.string.auth_no_net_conn_title;\r
- break;\r
- case INSTANCE_NOT_CONFIGURED:\r
- mStatusIcon = R.drawable.common_error;\r
- mStatusText = R.string.auth_not_configured_title;\r
- break;\r
- case UNKNOWN_ERROR:\r
- mStatusIcon = R.drawable.common_error;\r
- mStatusText = R.string.auth_unknow_error;\r
- break;\r
- case FILE_NOT_FOUND:\r
- mStatusIcon = R.drawable.common_error;\r
- mStatusText = R.string.auth_incorrect_path_title;\r
- break;\r
- default:\r
- Log.e(TAG, "Incorrect connection checker result type: " + type);\r
}\r
- setResultIconAndText(mStatusIcon, mStatusText);\r
- if (!mStatusCorrect)\r
- findViewById(R.id.refreshButton).setVisibility(View.VISIBLE);\r
- else\r
- findViewById(R.id.refreshButton).setVisibility(View.INVISIBLE);\r
- findViewById(R.id.buttonOK).setEnabled(mStatusCorrect);\r
- }\r
-\r
- @Override\r
- public void onFocusChange(View view, boolean hasFocus) {\r
- if (view.getId() == R.id.host_URL) {\r
- if (!hasFocus) {\r
- TextView tv = ((TextView)findViewById(R.id.host_URL));\r
- String uri = tv.getText().toString();\r
- if (uri.length() != 0) {\r
- setResultIconAndText(R.drawable.progress_small, R.string.auth_testing_connection);\r
- mConnChkRunnable = new ConnectionCheckerRunnable(uri, this);\r
- mConnChkRunnable.setListener(this, mHandler);\r
- mAuthThread = new Thread(mConnChkRunnable);\r
- mAuthThread.start();\r
+\r
+ private void setResultIconAndText(int drawable_id, int text_id) {\r
+ ImageView iv = (ImageView) findViewById(R.id.action_indicator);\r
+ TextView tv = (TextView) findViewById(R.id.status_text);\r
+\r
+ if (drawable_id == 0 && text_id == 0) {\r
+ iv.setVisibility(View.INVISIBLE);\r
+ tv.setVisibility(View.INVISIBLE);\r
} else {\r
- findViewById(R.id.refreshButton).setVisibility(View.INVISIBLE);\r
- setResultIconAndText(0, 0);\r
+ iv.setImageResource(drawable_id);\r
+ tv.setText(text_id);\r
+ iv.setVisibility(View.VISIBLE);\r
+ tv.setVisibility(View.VISIBLE);\r
}\r
- }\r
- } else if (view.getId() == R.id.account_password) {\r
- ImageView iv = (ImageView) findViewById(R.id.viewPassword);\r
- if (hasFocus) {\r
- iv.setVisibility(View.VISIBLE);\r
- } else {\r
- TextView v = (TextView) findViewById(R.id.account_password);\r
- int input_type = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD; \r
- v.setInputType(input_type);\r
- iv.setVisibility(View.INVISIBLE);\r
- }\r
- }\r
- }\r
- \r
- private void setResultIconAndText(int drawable_id, int text_id) {\r
- ImageView iv = (ImageView) findViewById(R.id.action_indicator);\r
- TextView tv = (TextView) findViewById(R.id.status_text);\r
- \r
- if (drawable_id == 0 && text_id == 0) {\r
- iv.setVisibility(View.INVISIBLE);\r
- tv.setVisibility(View.INVISIBLE);\r
- } else {\r
- iv.setImageResource(drawable_id);\r
- tv.setText(text_id);\r
- iv.setVisibility(View.VISIBLE);\r
- tv.setVisibility(View.VISIBLE);\r
}\r
- }\r
-\r
- @Override\r
- public void onClick(View v) {\r
- if (v.getId() == R.id.refreshButton) {\r
- onFocusChange(findViewById(R.id.host_URL), false);\r
- } else if (v.getId() == R.id.viewPassword) {\r
- TextView view = (TextView) findViewById(R.id.account_password);\r
- int input_type = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;\r
- view.setInputType(input_type);\r
+\r
+ @Override\r
+ public void onClick(View v) {\r
+ if (v.getId() == R.id.refreshButton) {\r
+ onFocusChange(findViewById(R.id.host_URL), false);\r
+ } else if (v.getId() == R.id.viewPassword) {\r
+ TextView view = (TextView) findViewById(R.id.account_password);\r
+ int input_type = InputType.TYPE_CLASS_TEXT\r
+ | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;\r
+ view.setInputType(input_type);\r
+ }\r
}\r
- }\r
}\r