X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/dc8c32fb3f7033d6fdfa7e1b64eaa77884da678a..40ee1019bcd6cff06fa408e5a99ad4ad42637aaa:/src/eu/alefzero/owncloud/ui/activity/AuthenticatorActivity.java diff --git a/src/eu/alefzero/owncloud/ui/activity/AuthenticatorActivity.java b/src/eu/alefzero/owncloud/ui/activity/AuthenticatorActivity.java index 79781f3e..9db46e0e 100644 --- a/src/eu/alefzero/owncloud/ui/activity/AuthenticatorActivity.java +++ b/src/eu/alefzero/owncloud/ui/activity/AuthenticatorActivity.java @@ -29,12 +29,16 @@ import android.app.ProgressDialog; import android.content.ContentResolver; import android.content.DialogInterface; import android.content.Intent; +import android.content.SharedPreferences; import android.graphics.Color; import android.os.Bundle; import android.os.Handler; +import android.preference.PreferenceManager; +import android.text.InputType; import android.util.Log; import android.view.View; import android.view.Window; +import android.widget.CheckBox; import android.widget.TextView; import android.widget.Toast; import eu.alefzero.owncloud.R; @@ -96,15 +100,25 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity { try { url = new URL(message); } catch (MalformedURLException e) { - // should never happend + // should never happen Log.e(getClass().getName(), "Malformed URL: " + message); return; } String username = username_text.getText().toString().trim(); - Account account = new Account(username + "@" + url.getHost(), AccountAuthenticator.ACCOUNT_TYPE); + String accountName = username + "@" + url.getHost(); + Account account = new Account(accountName, AccountAuthenticator.ACCOUNT_TYPE); AccountManager accManager = AccountManager.get(this); accManager.addAccountExplicitly(account, password_text.getText().toString(), null); + + // Add this account as default in the preferences, if there is none already + SharedPreferences appPreferences = PreferenceManager.getDefaultSharedPreferences(this); + String defaultAccountName = appPreferences.getString("select_oc_account", null); + if(defaultAccountName == null){ + SharedPreferences.Editor editor = appPreferences.edit(); + editor.putString("select_oc_account", accountName); + editor.commit(); + } final Intent intent = new Intent(); intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, AccountAuthenticator.ACCOUNT_TYPE); @@ -112,7 +126,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity { intent.putExtra(AccountManager.KEY_AUTHTOKEN, AccountAuthenticator.ACCOUNT_TYPE); accManager.setUserData(account, AccountAuthenticator.KEY_OC_URL, url.toString()); - // TODO prepare this URL during a central service + // TODO prepare this URL using a central service intent.putExtra(AccountManager.KEY_USERDATA, username); accManager.setUserData(account, AccountAuthenticator.KEY_CONTACT_URL, url.toString().replace(AuthUtils.WEBDAV_PATH_2_0, AuthUtils.CARDDAV_PATH_2_0) @@ -188,4 +202,21 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity { mHandler, AuthenticatorActivity.this); } + + /** + * Handles the show password checkbox + * @author robstar + * @param view + */ + public void onCheckboxClick(View view) { + CheckBox checkbox = (CheckBox) findViewById(R.id.show_password); + TextView password_text = (TextView) findViewById(R.id.account_password); + + if(checkbox.isChecked()) { + password_text.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); + } else { + password_text.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); + } + + } }