import com.owncloud.android.datamodel.FileDataStorageManager;\r
import com.owncloud.android.datamodel.OCFile;\r
import com.owncloud.android.files.services.FileUploader;\r
-import com.owncloud.android.network.OwnCloudClientUtils;\r
\r
import android.accounts.Account;\r
import android.accounts.AccountManager;\r
import android.widget.Toast;\r
\r
import com.owncloud.android.R;\r
-import eu.alefzero.webdav.WebdavClient;\r
\r
/**\r
* This can be used to upload things to an ownCloud instance.\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
// in API7 < this constatant is defined in\r
// Settings.ADD_ACCOUNT_SETTINGS\r
// and Settings.EXTRA_AUTHORITIES\r
- Intent intent = new Intent("android.settings.ADD_ACCOUNT_SETTINGS");\r
- intent.putExtra("authorities", new String[] { AccountAuthenticator.AUTH_TOKEN_TYPE });\r
+ Intent intent = new Intent(android.provider.Settings.ACTION_ADD_ACCOUNT);\r
+ intent.putExtra("authorities", new String[] { AccountAuthenticator.AUTHORITY });\r
startActivityForResult(intent, REQUEST_CODE_SETUP_ACCOUNT);\r
} else {\r
// since in API7 there is no direct call for\r
mFile = mStorageManager.getFileByPath(full_path);\r
if (mFile != null) {\r
Vector<OCFile> files = mStorageManager.getDirectoryContent(mFile);\r
- if (files.size() > 0) {\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 boolean prepareStreamsToUpload() {\r
\r
public void uploadFiles() {\r
try {\r
+ /* TODO - mCreateDir can never be true at this moment; we will replace wdc.createDirectory by CreateFolderOperation when that is fixed \r
WebdavClient wdc = OwnCloudClientUtils.createOwnCloudClient(mAccount, getApplicationContext());\r
-\r
// create last directory in path if necessary\r
if (mCreateDir) {\r
wdc.createDirectory(mUploadPath);\r
}\r
+ */\r
\r
String[] local = new String[mStreamsToUpload.size()], remote = new String[mStreamsToUpload.size()];\r
\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