-/* ownCloud Android client application\r
- * Copyright (C) 2012 Bartek Przybylski\r
- * Copyright (C) 2012-2013 ownCloud Inc.\r
- *\r
- * This program is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License version 2,\r
- * as published by the Free Software Foundation.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
- *\r
- */\r
-\r
-package com.owncloud.android.ui.activity;\r
-\r
-import android.accounts.AccountAuthenticatorActivity;\r
-import android.app.Activity;\r
-import android.os.Bundle;\r
-import android.view.View;\r
-import android.view.View.OnClickListener;\r
-\r
-public class PreferencesNewSession extends AccountAuthenticatorActivity\r
- implements OnClickListener {\r
- @Override\r
- public void onCreate(Bundle savedInstanceState) {\r
- super.onCreate(savedInstanceState);\r
- // setContentView(R.layout.add_new_session);\r
- /*\r
- * EditText et;// = (EditText)\r
- * findViewById(R.id.newSession_sessionName);\r
- * \r
- * et = (EditText) findViewById(R.id.newSession_URL); if\r
- * (getIntent().hasExtra("sessionURL")) { try { URI uri = new\r
- * URI(getIntent().getStringExtra("sessionURL")); String url =\r
- * uri.getHost(); if (uri.getPort() != -1) { url += ":" +\r
- * String.valueOf(uri.getPort()); } if (uri.getPath() != null) { url +=\r
- * uri.getPath(); } else { url += "/"; } et.setText(url); et =\r
- * (EditText) findViewById(R.id.newSession_username); if\r
- * (uri.getAuthority() != null) { if (uri.getUserInfo().indexOf(':') !=\r
- * -1) { et.setText(uri.getUserInfo().substring(0,\r
- * uri.getUserInfo().indexOf(':'))); et = (EditText)\r
- * findViewById(R.id.newSession_password);\r
- * et.setText(uri.getUserInfo().substring\r
- * (uri.getUserInfo().indexOf(':')+1)); } else {\r
- * et.setText(uri.getUserInfo()); } }\r
- * \r
- * } catch (URISyntaxException e) { Log.e(TAG, "Incorrect URI syntax " +\r
- * e.getLocalizedMessage()); } }\r
- * \r
- * mReturnData = new Intent(); setResult(Activity.RESULT_OK,\r
- * mReturnData); ((Button)\r
- * findViewById(R.id.button1)).setOnClickListener(this); ((Button)\r
- * findViewById(R.id.button2)).setOnClickListener(this);\r
- */\r
- }\r
-\r
- @Override\r
- protected void onResume() {\r
- super.onResume();\r
- }\r
-\r
- public void onClick(View v) {\r
- /*\r
- * switch (v.getId()) { case R.id.button1: Intent intent = new Intent();\r
- * if (getIntent().hasExtra("sessionId")) { intent.putExtra("sessionId",\r
- * getIntent().getIntExtra("sessionId", -1)); } //String sessionName =\r
- * ((EditText)\r
- * findViewById(R.id.newSession_sessionName)).getText().toString(); //\r
- * if (sessionName.trim().equals("") || !isNameValid(sessionName)) { //\r
- * Toast.makeText(this, R.string.new_session_session_name_error,\r
- * Toast.LENGTH_LONG).show(); // break; // } URI uri = prepareURI(); if\r
- * (uri != null) { //intent.putExtra("sessionName", sessionName);\r
- * intent.putExtra("sessionURL", uri.toString());\r
- * setResult(Activity.RESULT_OK, intent); AccountManager accMgr =\r
- * AccountManager.get(this); Account a = new Account("OwnCloud",\r
- * AccountAuthenticatorService.ACCOUNT_TYPE);\r
- * accMgr.addAccountExplicitly(a, "asd", null); finish(); } break; case\r
- * R.id.button2: setResult(Activity.RESULT_CANCELED); finish(); break; }\r
- */\r
- }\r
-\r
- /*\r
- * private URI prepareURI() { URI uri = null; String url = ""; try { String\r
- * username = ((EditText)\r
- * findViewById(R.id.newSession_username)).getText().toString().trim();\r
- * String password = ((EditText)\r
- * findViewById(R.id.newSession_password)).getText().toString().trim();\r
- * String hostname = ((EditText)\r
- * findViewById(R.id.newSession_URL)).getText().toString().trim(); String\r
- * scheme; if (hostname.matches("[A-Za-z]://")) { scheme =\r
- * hostname.substring(0, hostname.indexOf("://")+3); hostname =\r
- * hostname.substring(hostname.indexOf("://")+3); } else { scheme =\r
- * "http://"; } if (!username.equals("")) { if (!password.equals("")) {\r
- * username += ":" + password + "@"; } else { username += "@"; } } url =\r
- * scheme + username + hostname; Log.i(TAG, url); uri = new URI(url); }\r
- * catch (URISyntaxException e) { Log.e(TAG, "Incorrect URI syntax " +\r
- * e.getLocalizedMessage()); Toast.makeText(this,\r
- * R.string.new_session_uri_error, Toast.LENGTH_LONG).show(); } return uri;\r
- * }\r
- * \r
- * private boolean isNameValid(String string) { return\r
- * string.matches("[A-Za-z0-9 _-]*"); }\r
- */\r
-\r
- @Override\r
- public void onBackPressed() {\r
- setResult(Activity.RESULT_CANCELED);\r
- super.onBackPressed();\r
- }\r
-\r
-}\r