From: Bartek Przybylski Date: Sun, 15 Apr 2012 07:54:21 +0000 (+0200) Subject: adding use ssl mode X-Git-Tag: oc-android-1.4.3~443^2 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/ff36d908024994abe425351ba4f01b9cf805d1e3?ds=inline;hp=--cc adding use ssl mode --- ff36d908024994abe425351ba4f01b9cf805d1e3 diff --git a/res/layout/account_setup.xml b/res/layout/account_setup.xml index 277ef368..9868b27c 100644 --- a/res/layout/account_setup.xml +++ b/res/layout/account_setup.xml @@ -134,7 +134,21 @@ android:hint="@string/setup_hint_show_password" android:textColor="@android:color/black" android:onClick="onCheckboxClick"/> + + + diff --git a/res/values/strings.xml b/res/values/strings.xml index fc3fb856..7a2768f9 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -51,4 +51,5 @@ Upload failed: Choose account Contacts + Use Secure Connection diff --git a/src/eu/alefzero/owncloud/ui/activity/AuthenticatorActivity.java b/src/eu/alefzero/owncloud/ui/activity/AuthenticatorActivity.java index f134630d..b6c9ddab 100644 --- a/src/eu/alefzero/owncloud/ui/activity/AuthenticatorActivity.java +++ b/src/eu/alefzero/owncloud/ui/activity/AuthenticatorActivity.java @@ -54,10 +54,15 @@ import eu.alefzero.owncloud.db.ProviderMeta.ProviderTableMeta; public class AuthenticatorActivity extends AccountAuthenticatorActivity { private Thread mAuthThread; private final Handler mHandler = new Handler(); + private boolean mUseSSLConnection; public static final String PARAM_USERNAME = "param_Username"; public static final String PARAM_HOSTNAME = "param_Hostname"; + public AuthenticatorActivity() { + mUseSSLConnection = false; + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -162,12 +167,15 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity { url_text.setTextColor(Color.RED); hasErrors = true; } else { - url_text.setTextColor(Color.BLACK); + url_text.setTextColor(android.R.color.primary_text_light); } try { String url_str = url_text.getText().toString(); if (!url_str.startsWith("http://") && !url_str.startsWith("https://")) { + if (mUseSSLConnection) + url_str = "https://" + url_str; + else url_str = "http://" + url_str; } uri = new URL(url_str); @@ -182,18 +190,33 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity { username_text.setTextColor(Color.RED); hasErrors = true; } else { - username_text.setTextColor(Color.BLACK); + username_text.setTextColor(android.R.color.primary_text_light); } if (password_text.getText().toString().trim().length() == 0) { password_text.setTextColor(Color.RED); hasErrors = true; } else { - password_text.setTextColor(Color.BLACK); + password_text.setTextColor(android.R.color.primary_text_light); } if (hasErrors) { return; } + + int new_port = uri.getPort(); + if (new_port == -1) { + if (mUseSSLConnection) + new_port = 443; + else + new_port = 80; + } + + try { + uri = new URL(uri.getProtocol(), uri.getHost(), new_port, uri.getPath()); + } catch (MalformedURLException e) { + e.printStackTrace(); // should not happend + } + showDialog(0); mAuthThread = AuthUtils.attemptAuth(uri, username_text.getText().toString(), @@ -205,17 +228,26 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity { /** * Handles the show password checkbox * @author robstar + * @author aqu * @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); - } + switch (view.getId()) { + case R.id.show_password: + TextView password_text = (TextView) findViewById(R.id.account_password); + + if(((CheckBox)view).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); + } + break; + case R.id.use_ssl: + mUseSSLConnection = ((CheckBox)view).isChecked(); + break; + default: + Log.d("AuthActivity", "Clicked invalid view with id: " + view.getId()); + } } }