/* 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 as published by\r
- * the Free Software Foundation, either version 3 of the License, or\r
+ * the Free Software Foundation, either version 2 of the License, or\r
* (at your option) any later version.\r
*\r
* This program is distributed in the hope that it will be useful,\r
getWindow().requestFeature(Window.FEATURE_NO_TITLE);\r
mParents = new Stack<String>();\r
mParents.add("");\r
- if (getIntent().hasExtra(Intent.EXTRA_STREAM)) {\r
- prepareStreamsToUpload();\r
+ /*if (getIntent().hasExtra(Intent.EXTRA_STREAM)) {\r
+ prepareStreamsToUpload();*/\r
+ if (prepareStreamsToUpload()) {\r
mAccountManager = (AccountManager) getSystemService(Context.ACCOUNT_SERVICE);\r
Account[] accounts = mAccountManager.getAccountsByType(AccountAuthenticator.ACCOUNT_TYPE);\r
if (accounts.length == 0) {\r
case DIALOG_NO_ACCOUNT:\r
builder.setIcon(android.R.drawable.ic_dialog_alert);\r
builder.setTitle(R.string.uploader_wrn_no_account_title);\r
- builder.setMessage(R.string.uploader_wrn_no_account_text);\r
+ builder.setMessage(String.format(getString(R.string.uploader_wrn_no_account_text), getString(R.string.app_name)));\r
builder.setCancelable(false);\r
builder.setPositiveButton(R.string.uploader_wrn_no_account_setup_btn_text, new OnClickListener() {\r
+ @Override\r
public void onClick(DialogInterface dialog, int which) {\r
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.ECLAIR_MR1) {\r
// using string value since in API7 this\r
}\r
});\r
builder.setNegativeButton(R.string.uploader_wrn_no_account_quit_btn_text, new OnClickListener() {\r
+ @Override\r
public void onClick(DialogInterface dialog, int which) {\r
finish();\r
}\r
}\r
builder.setTitle(R.string.common_choose_account);\r
builder.setItems(ac, new OnClickListener() {\r
+ @Override\r
public void onClick(DialogInterface dialog, int which) {\r
mAccount = mAccountManager.getAccountsByType(AccountAuthenticator.ACCOUNT_TYPE)[which];\r
mStorageManager = new FileDataStorageManager(mAccount, getContentResolver());\r
});\r
builder.setCancelable(true);\r
builder.setOnCancelListener(new OnCancelListener() {\r
+ @Override\r
public void onCancel(DialogInterface dialog) {\r
dialog.cancel();\r
finish();\r
builder.setMessage(R.string.uploader_wrn_no_content_text);\r
builder.setCancelable(false);\r
builder.setNegativeButton(R.string.common_cancel, new OnClickListener() {\r
+ @Override\r
public void onClick(DialogInterface dialog, int which) {\r
finish();\r
}\r
mDirname = dirname;\r
}\r
\r
+ @Override\r
public void onClick(DialogInterface dialog, int which) {\r
Uploader.this.mUploadPath = mPath + mDirname.getText().toString();\r
Uploader.this.mCreateDir = true;\r
}\r
}\r
\r
+ @Override\r
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {\r
// click on folder in the list\r
Log.d(TAG, "on item click");\r
Vector<OCFile> tmpfiles = mStorageManager.getDirectoryContent(mFile);\r
- if (tmpfiles == null) return;\r
+ if (tmpfiles.size() <= 0) return;\r
// filter on dirtype\r
Vector<OCFile> files = new Vector<OCFile>();\r
for (OCFile f : tmpfiles)\r
populateDirectoryList();\r
}\r
\r
+ @Override\r
public void onClick(View v) {\r
// click on button\r
switch (v.getId()) {\r
mFile = mStorageManager.getFileByPath(full_path);\r
if (mFile != null) {\r
Vector<OCFile> files = mStorageManager.getDirectoryContent(mFile);\r
- if (files != null) {\r
- List<HashMap<String, Object>> data = new LinkedList<HashMap<String,Object>>();\r
- for (OCFile f : files) {\r
- HashMap<String, Object> h = new HashMap<String, Object>();\r
- if (f.isDirectory()) {\r
- h.put("dirname", f.getFileName());\r
- data.add(h);\r
- }\r
+ List<HashMap<String, Object>> data = new LinkedList<HashMap<String,Object>>();\r
+ for (OCFile f : files) {\r
+ HashMap<String, Object> h = new HashMap<String, Object>();\r
+ if (f.isDirectory()) {\r
+ h.put("dirname", f.getFileName());\r
+ data.add(h);\r
}\r
- SimpleAdapter sa = new SimpleAdapter(this,\r
- data,\r
- R.layout.uploader_list_item_layout,\r
- new String[] {"dirname"},\r
- new int[] {R.id.textView1});\r
- setListAdapter(sa);\r
- Button btn = (Button) findViewById(R.id.uploader_choose_folder);\r
- btn.setOnClickListener(this);\r
- getListView().setOnItemClickListener(this);\r
}\r
- }\r
- /*\r
- mCursor = managedQuery(ProviderMeta.ProviderTableMeta.CONTENT_URI, null, ProviderTableMeta.FILE_NAME\r
- + "=? AND " + ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?", new String[] { "/", mAccount.name }, null);\r
-\r
- if (mCursor.moveToFirst()) {\r
- mCursor = managedQuery(\r
- ProviderMeta.ProviderTableMeta.CONTENT_URI,\r
- null,\r
- ProviderTableMeta.FILE_CONTENT_TYPE + "=? AND " + ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND "\r
- + ProviderTableMeta.FILE_PARENT + "=?",\r
- new String[] { "DIR", mAccount.name,\r
- mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta._ID)) }, null);\r
-\r
- ListView lv = getListView();\r
- lv.setOnItemClickListener(this);\r
- SimpleCursorAdapter sca = new SimpleCursorAdapter(this, R.layout.uploader_list_item_layout, mCursor,\r
- new String[] { ProviderTableMeta.FILE_NAME }, new int[] { R.id.textView1 });\r
- setListAdapter(sca);\r
+ SimpleAdapter sa = new SimpleAdapter(this,\r
+ data,\r
+ R.layout.uploader_list_item_layout,\r
+ new String[] {"dirname"},\r
+ new int[] {R.id.textView1});\r
+ setListAdapter(sa);\r
Button btn = (Button) findViewById(R.id.uploader_choose_folder);\r
btn.setOnClickListener(this);\r
- /*\r
- * disable this until new server interaction service wont be created\r
- * // insert create new directory for multiple items uploading if\r
- * (getIntent().getAction().equals(Intent.ACTION_SEND_MULTIPLE)) {\r
- * Button createDirBtn = new Button(this);\r
- * createDirBtn.setId(android.R.id.button1);\r
- * createDirBtn.setText(R.string.uploader_btn_create_dir_text);\r
- * createDirBtn.setOnClickListener(this); ((LinearLayout)\r
- * findViewById(R.id.linearLayout1)).addView( createDirBtn,\r
- * LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); }\r
- *\r
- }*/\r
+ getListView().setOnItemClickListener(this);\r
+ }\r
}\r
\r
- private void prepareStreamsToUpload() {\r
+ private boolean prepareStreamsToUpload() {\r
if (getIntent().getAction().equals(Intent.ACTION_SEND)) {\r
mStreamsToUpload = new ArrayList<Parcelable>();\r
mStreamsToUpload.add(getIntent().getParcelableExtra(Intent.EXTRA_STREAM));\r
} else if (getIntent().getAction().equals(Intent.ACTION_SEND_MULTIPLE)) {\r
mStreamsToUpload = getIntent().getParcelableArrayListExtra(Intent.EXTRA_STREAM);\r
- } else {\r
- // unknow action inserted\r
- throw new IllegalArgumentException("Unknown action given: " + getIntent().getAction());\r
}\r
+ return (mStreamsToUpload != null && mStreamsToUpload.get(0) != null);\r
}\r
\r
public void uploadFiles() {\r
finish();\r
\r
} catch (SecurityException e) {\r
- Toast.makeText(this, getString(R.string.uploader_error_forbidden_content), Toast.LENGTH_LONG).show();\r
+ String message = String.format(getString(R.string.uploader_error_forbidden_content), getString(R.string.app_name));\r
+ Toast.makeText(this, message, Toast.LENGTH_LONG).show(); \r
}\r
}\r
\r