Added notification for failures in manual synchronizations; some improvements in...
[pub/Android/ownCloud.git] / src / com / owncloud / android / ui / activity / PreferencesNewSession.java
1 package com.owncloud.android.ui.activity;
2
3 import android.accounts.AccountAuthenticatorActivity;
4 import android.app.Activity;
5 import android.os.Bundle;
6 import android.view.View;
7 import android.view.View.OnClickListener;
8
9 public class PreferencesNewSession extends AccountAuthenticatorActivity
10 implements OnClickListener {
11 @Override
12 public void onCreate(Bundle savedInstanceState) {
13 super.onCreate(savedInstanceState);
14 // setContentView(R.layout.add_new_session);
15 /*
16 * EditText et;// = (EditText)
17 * findViewById(R.id.newSession_sessionName);
18 *
19 * et = (EditText) findViewById(R.id.newSession_URL); if
20 * (getIntent().hasExtra("sessionURL")) { try { URI uri = new
21 * URI(getIntent().getStringExtra("sessionURL")); String url =
22 * uri.getHost(); if (uri.getPort() != -1) { url += ":" +
23 * String.valueOf(uri.getPort()); } if (uri.getPath() != null) { url +=
24 * uri.getPath(); } else { url += "/"; } et.setText(url); et =
25 * (EditText) findViewById(R.id.newSession_username); if
26 * (uri.getAuthority() != null) { if (uri.getUserInfo().indexOf(':') !=
27 * -1) { et.setText(uri.getUserInfo().substring(0,
28 * uri.getUserInfo().indexOf(':'))); et = (EditText)
29 * findViewById(R.id.newSession_password);
30 * et.setText(uri.getUserInfo().substring
31 * (uri.getUserInfo().indexOf(':')+1)); } else {
32 * et.setText(uri.getUserInfo()); } }
33 *
34 * } catch (URISyntaxException e) { Log.e(TAG, "Incorrect URI syntax " +
35 * e.getLocalizedMessage()); } }
36 *
37 * mReturnData = new Intent(); setResult(Activity.RESULT_OK,
38 * mReturnData); ((Button)
39 * findViewById(R.id.button1)).setOnClickListener(this); ((Button)
40 * findViewById(R.id.button2)).setOnClickListener(this);
41 */
42 }
43
44 @Override
45 protected void onResume() {
46 super.onResume();
47 }
48
49 public void onClick(View v) {
50 /*
51 * switch (v.getId()) { case R.id.button1: Intent intent = new Intent();
52 * if (getIntent().hasExtra("sessionId")) { intent.putExtra("sessionId",
53 * getIntent().getIntExtra("sessionId", -1)); } //String sessionName =
54 * ((EditText)
55 * findViewById(R.id.newSession_sessionName)).getText().toString(); //
56 * if (sessionName.trim().equals("") || !isNameValid(sessionName)) { //
57 * Toast.makeText(this, R.string.new_session_session_name_error,
58 * Toast.LENGTH_LONG).show(); // break; // } URI uri = prepareURI(); if
59 * (uri != null) { //intent.putExtra("sessionName", sessionName);
60 * intent.putExtra("sessionURL", uri.toString());
61 * setResult(Activity.RESULT_OK, intent); AccountManager accMgr =
62 * AccountManager.get(this); Account a = new Account("OwnCloud",
63 * AccountAuthenticatorService.ACCOUNT_TYPE);
64 * accMgr.addAccountExplicitly(a, "asd", null); finish(); } break; case
65 * R.id.button2: setResult(Activity.RESULT_CANCELED); finish(); break; }
66 */
67 }
68
69 /*
70 * private URI prepareURI() { URI uri = null; String url = ""; try { String
71 * username = ((EditText)
72 * findViewById(R.id.newSession_username)).getText().toString().trim();
73 * String password = ((EditText)
74 * findViewById(R.id.newSession_password)).getText().toString().trim();
75 * String hostname = ((EditText)
76 * findViewById(R.id.newSession_URL)).getText().toString().trim(); String
77 * scheme; if (hostname.matches("[A-Za-z]://")) { scheme =
78 * hostname.substring(0, hostname.indexOf("://")+3); hostname =
79 * hostname.substring(hostname.indexOf("://")+3); } else { scheme =
80 * "http://"; } if (!username.equals("")) { if (!password.equals("")) {
81 * username += ":" + password + "@"; } else { username += "@"; } } url =
82 * scheme + username + hostname; Log.i(TAG, url); uri = new URI(url); }
83 * catch (URISyntaxException e) { Log.e(TAG, "Incorrect URI syntax " +
84 * e.getLocalizedMessage()); Toast.makeText(this,
85 * R.string.new_session_uri_error, Toast.LENGTH_LONG).show(); } return uri;
86 * }
87 *
88 * private boolean isNameValid(String string) { return
89 * string.matches("[A-Za-z0-9 _-]*"); }
90 */
91
92 @Override
93 public void onBackPressed() {
94 setResult(Activity.RESULT_CANCELED);
95 super.onBackPressed();
96 }
97
98 }