зеркало из https://github.com/nextcloud/android.git
Merge branch 'fragments-ui' of ssh://git@gitorious.org/owncloud/android.git into fragments-ui
This commit is contained in:
Коммит
a7a68eba53
|
@ -276,9 +276,9 @@ public class Uploader extends ListActivity implements OnItemClickListener, andro
|
|||
null,
|
||||
null);
|
||||
mCursor.moveToFirst();
|
||||
pathToUpload = mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta.FILE_PATH)) +
|
||||
mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta.FILE_NAME)).replace(" ", "%20");
|
||||
pathToUpload = mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta.FILE_PATH)).replace(" ", "%20");
|
||||
}
|
||||
Log.d(TAG, "Uploading file to dir " + pathToUpload);
|
||||
|
||||
showDialog(DIALOG_WAITING);
|
||||
mUploadThread = new Thread(new BackgroundUploader(pathToUpload, mStreamsToUpload, mHandler));
|
||||
|
@ -329,29 +329,38 @@ public class Uploader extends ListActivity implements OnItemClickListener, andro
|
|||
mUsername = mAccount.name.substring(0, mAccount.name.indexOf('@'));
|
||||
mPassword = mAccountManager.getPassword(mAccount);
|
||||
setContentView(R.layout.uploader_layout);
|
||||
|
||||
mCursor = managedQuery(ProviderMeta.ProviderTableMeta.CONTENT_URI,
|
||||
null,
|
||||
ProviderTableMeta.FILE_CONTENT_TYPE+"=? AND " + ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?",
|
||||
new String[]{"DIR", mAccount.name},
|
||||
ProviderTableMeta.FILE_NAME+"=? AND " +ProviderTableMeta.FILE_ACCOUNT_OWNER+"=?",
|
||||
new String[]{"/", mAccount.name},
|
||||
null);
|
||||
|
||||
ListView lv = getListView();
|
||||
lv.setOnItemClickListener(this);
|
||||
SimpleCursorAdapter sca = new SimpleCursorAdapter(this,
|
||||
R.layout.uploader_list_item_layout,
|
||||
mCursor,
|
||||
new String[]{ProviderTableMeta.FILE_NAME},
|
||||
new int[]{R.id.textView1});
|
||||
setListAdapter(sca);
|
||||
Button btn = (Button) findViewById(R.id.uploader_choose_folder);
|
||||
btn.setOnClickListener(this);
|
||||
// insert create new directory for multiple items uploading
|
||||
if (getIntent().getAction().equals(Intent.ACTION_SEND_MULTIPLE)) {
|
||||
Button createDirBtn = new Button(this);
|
||||
createDirBtn.setId(android.R.id.button1);
|
||||
createDirBtn.setText(R.string.uploader_btn_create_dir_text);
|
||||
createDirBtn.setOnClickListener(this);
|
||||
((LinearLayout)findViewById(R.id.linearLayout1)).addView(createDirBtn, LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
|
||||
|
||||
if (mCursor.moveToFirst()) {
|
||||
mCursor = managedQuery(ProviderMeta.ProviderTableMeta.CONTENT_URI,
|
||||
null,
|
||||
ProviderTableMeta.FILE_CONTENT_TYPE+"=? AND " + ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND " +ProviderTableMeta.FILE_PARENT+"=?",
|
||||
new String[]{"DIR", mAccount.name, mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta._ID))},
|
||||
null);
|
||||
|
||||
ListView lv = getListView();
|
||||
lv.setOnItemClickListener(this);
|
||||
SimpleCursorAdapter sca = new SimpleCursorAdapter(this,
|
||||
R.layout.uploader_list_item_layout,
|
||||
mCursor,
|
||||
new String[]{ProviderTableMeta.FILE_NAME},
|
||||
new int[]{R.id.textView1});
|
||||
setListAdapter(sca);
|
||||
Button btn = (Button) findViewById(R.id.uploader_choose_folder);
|
||||
btn.setOnClickListener(this);
|
||||
// insert create new directory for multiple items uploading
|
||||
if (getIntent().getAction().equals(Intent.ACTION_SEND_MULTIPLE)) {
|
||||
Button createDirBtn = new Button(this);
|
||||
createDirBtn.setId(android.R.id.button1);
|
||||
createDirBtn.setText(R.string.uploader_btn_create_dir_text);
|
||||
createDirBtn.setOnClickListener(this);
|
||||
((LinearLayout)findViewById(R.id.linearLayout1)).addView(createDirBtn, LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.Vector;
|
|||
|
||||
import eu.alefzero.owncloud.db.ProviderMeta.ProviderTableMeta;
|
||||
import android.accounts.Account;
|
||||
import android.content.ContentProvider;
|
||||
import android.content.ContentProviderClient;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentValues;
|
||||
|
@ -122,6 +123,25 @@ public class OCFile {
|
|||
}
|
||||
}
|
||||
|
||||
public OCFile(ContentProviderClient cp, Account account, String path) {
|
||||
cp_ = cp;
|
||||
account_ = account;
|
||||
|
||||
try {
|
||||
Cursor c = cp_.query(ProviderTableMeta.CONTENT_URI_FILE, null,
|
||||
ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND "
|
||||
+ ProviderTableMeta.FILE_PATH + "=?", new String[]{account_.name,
|
||||
path}, null);
|
||||
if (c.moveToFirst()) {
|
||||
setFileData(c);
|
||||
if (path_ != null)
|
||||
path_ = path;
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.d(TAG , e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public long getFileId() {
|
||||
return id_;
|
||||
}
|
||||
|
|
|
@ -145,7 +145,6 @@ public class FileContentProvider extends ContentProvider {
|
|||
|
||||
switch (mUriMatcher.match(uri)) {
|
||||
case ROOT_DIRECTORY:
|
||||
sqlQuery.appendWhere(ProviderTableMeta.FILE_PARENT + " is null");
|
||||
break;
|
||||
case DIRECTORY:
|
||||
sqlQuery.appendWhere(ProviderTableMeta.FILE_PARENT + "="+uri.getPathSegments().get(1));
|
||||
|
|
|
@ -42,6 +42,7 @@ import android.content.ContentProviderClient;
|
|||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import eu.alefzero.owncloud.authenticator.AccountAuthenticator;
|
||||
import eu.alefzero.owncloud.datamodel.OCFile;
|
||||
import eu.alefzero.webdav.HttpPropFind;
|
||||
|
@ -66,7 +67,8 @@ public abstract class AbstractOwnCloudSyncAdapter extends AbstractThreadedSyncAd
|
|||
|
||||
private HttpHost mHost;
|
||||
private WebdavClient mClient = null;
|
||||
|
||||
private static String TAG = "AbstractOwnCloudSyncAdapter";
|
||||
|
||||
public AbstractOwnCloudSyncAdapter(Context context, boolean autoInitialize) {
|
||||
super(context, autoInitialize);
|
||||
this.setAccountManager(AccountManager.get(context));
|
||||
|
@ -180,26 +182,42 @@ public abstract class AbstractOwnCloudSyncAdapter extends AbstractThreadedSyncAd
|
|||
continue;
|
||||
}
|
||||
String path = n.stripPathFromFilename(uri.getPath());
|
||||
OCFile new_file = OCFile.createNewFile(getContentProvider(),
|
||||
getAccount(),
|
||||
n.getProperty(NodeProperty.PATH),
|
||||
0,//Long.parseLong(n.getProperty(NodeProperty.CONTENT_LENGTH)),
|
||||
0,//Long.parseLong(n.getProperty(NodeProperty.CREATE_DATE)),
|
||||
0,//Long.parseLong(n.getProperty(NodeProperty.LAST_MODIFIED_DATE)),
|
||||
n.getProperty(NodeProperty.RESOURCE_TYPE),
|
||||
parent_id);
|
||||
new_file.save();
|
||||
if (override_parent) {
|
||||
parent_id = new_file.getFileId();
|
||||
override_parent = false;
|
||||
}
|
||||
|
||||
long mod = n.getProperty(NodeProperty.LAST_MODIFIED_DATE) == null ?
|
||||
0 :
|
||||
Long.parseLong(n.getProperty(NodeProperty.LAST_MODIFIED_DATE));
|
||||
OCFile file = new OCFile(getContentProvider(), getAccount(), n.getProperty(NodeProperty.PATH));
|
||||
if (file.fileExtist() && file.getModificationTimestamp() >= mod) {
|
||||
Log.d(TAG, "No update for file/dir " + file.getFileName() + " is needed");
|
||||
} else {
|
||||
Log.d(TAG, "File " + n.getProperty(NodeProperty.PATH) + " will be " + (file.fileExtist() ? "updated" : "created"));
|
||||
long len = n.getProperty(NodeProperty.CONTENT_LENGTH) == null ?
|
||||
0 :
|
||||
Long.parseLong(n.getProperty(NodeProperty.CONTENT_LENGTH));
|
||||
long create = n.getProperty(NodeProperty.CREATE_DATE) == null ?
|
||||
0 :
|
||||
Long.parseLong(n.getProperty(NodeProperty.CREATE_DATE));
|
||||
file = OCFile.createNewFile(getContentProvider(),
|
||||
getAccount(),
|
||||
n.getProperty(NodeProperty.PATH),
|
||||
len,
|
||||
create,
|
||||
mod,
|
||||
n.getProperty(NodeProperty.RESOURCE_TYPE),
|
||||
parent_id);
|
||||
file.save();
|
||||
if (override_parent) {
|
||||
parent_id = file.getFileId();
|
||||
override_parent = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(n.getProperty(NodeProperty.NAME)) &&
|
||||
n.getProperty(NodeProperty.RESOURCE_TYPE).equals("DIR")) {
|
||||
|
||||
HttpPropFind method = new HttpPropFind(uri.getPath() + path + n.getProperty(NodeProperty.NAME).replace(" ", "%20") + "/");
|
||||
HttpResponse response = fireRawRequest(method);
|
||||
parseResponse(response, uri, client, targetHost, n.getChildList(), true, new_file.getFileId());
|
||||
parseResponse(response, uri, client, targetHost, n.getChildList(), true, file.getFileId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,7 +86,6 @@ public class TreeNode {
|
|||
propertyMap_.put(NodeProperty.NAME, name);
|
||||
propertyMap_.remove(NodeProperty.PATH);
|
||||
propertyMap_.put(NodeProperty.PATH, name2);
|
||||
Log.i("TreeNode", toString());
|
||||
return path;
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -119,8 +119,6 @@ public class WebdavUtils {
|
|||
parseDisplayName(currentNode, resultNode, davPrefix);
|
||||
rList.add(resultNode);
|
||||
}
|
||||
|
||||
|
||||
} catch (ParserConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
} catch (SAXException e) {
|
||||
|
@ -150,7 +148,7 @@ public class WebdavUtils {
|
|||
if (currentElement.getElementsByTagName(davPrefix + CREATE_DATE).getLength() != 0) {
|
||||
Date date = parseResponseDate(
|
||||
currentElement.getElementsByTagName(davPrefix + CREATE_DATE).item(0).getFirstChild().getNodeValue());
|
||||
resultNode.setProperty(NodeProperty.CREATE_DATE, String.valueOf(date));
|
||||
resultNode.setProperty(NodeProperty.CREATE_DATE, String.valueOf(date.getTime()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче