keep file in sync and initial commit for file sharing

This commit is contained in:
Bartek Przybylski 2012-07-08 16:57:48 +02:00
parent 3e9d818a08
commit 3113c45909
14 changed files with 326 additions and 44 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -155,25 +155,55 @@
android:id="@+id/fdPreviewAndDL"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/fdDetailsContainer" >
android:layout_below="@+id/fdDetailsContainer"
android:gravity="center_horizontal" >
<CheckBox
android:id="@+id/fdKeepInSync"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="@string/fd_keep_in_sync" />
<ImageView
android:id="@+id/fdPreview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/fdKeepInSync"
android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"
android:src="@drawable/owncloud_logo" />
<Button
android:id="@+id/fdDownloadBtn"
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="@+id/fdPreview"
android:layout_marginTop="12dp"
android:text="@string/filedetails_download" />
android:layout_below="@id/fdPreview"
android:gravity="center_horizontal" >
<Button
android:id="@+id/fdDownloadBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/filedetails_download" />
<Button
android:id="@+id/fdRemoveBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="Remove" />
<!--
<Button
android:id="@+id/fdShareBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/common_share" />
-->
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
</ScrollView>

View file

@ -43,6 +43,15 @@
android:layout_margin="4dp"
android:src="@drawable/ic_menu_archive" />
<ImageView
android:id="@+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight=".1"
android:maxHeight="15dip"
android:src="@drawable/ic_favorite" />
</FrameLayout>
<LinearLayout

View file

@ -112,4 +112,6 @@
<string name="extensions_avail_title">Extensions available!</string>
<string name="extensions_avail_message">Looks like your ownCloud instance is supporting advanced extensions. Would you like to see extensions available for android ?</string>
<string name="fd_keep_in_sync">Keep file up to date</string>
<string name="common_share">Share</string>
</resources>

View file

@ -43,7 +43,7 @@ import eu.alefzero.webdav.FileRequestEntity;
public class CrashlogSendActivity extends SherlockActivity implements OnClickListener, OnCancelListener {
private static final String TAG = "CrashlogSendActivity";
private static final String CRASHLOG_SUBMIT_URL = "";
private static final String CRASHLOG_SUBMIT_URL = "http://alefzero.eu/a/crashlog/";
private static final int DIALOG_SUBMIT = 5;
private String mLogFilename;

View file

@ -101,6 +101,7 @@ public class FileDataStorageManager implements DataStorageManager {
cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath());
cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, mAccount.name);
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, file.getLastSyncDate());
cv.put(ProviderTableMeta.FILE_KEEP_IN_SYNC, file.keepInSync() ? 1 : 0);
if (fileExists(file.getRemotePath())) {
OCFile tmpfile = getFileByPath(file.getRemotePath());
@ -303,6 +304,8 @@ public class FileDataStorageManager implements DataStorageManager {
.getColumnIndex(ProviderTableMeta.FILE_MODIFIED)));
file.setLastSyncDate(c.getLong(c
.getColumnIndex(ProviderTableMeta.FILE_LAST_SYNC_DATE)));
file.setKeepInSync(c.getInt(
c.getColumnIndex(ProviderTableMeta.FILE_KEEP_IN_SYNC)) == 1 ? true : false);
}
return file;
}

View file

@ -50,6 +50,7 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
private String mMimeType;
private boolean mNeedsUpdating;
private long mLastSyncDate;
private boolean mKeepInSync;
/**
* Create new {@link OCFile} with given path
@ -87,6 +88,23 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
mLocalPath = source.readString();
mMimeType = source.readString();
mNeedsUpdating = source.readInt() == 0;
mKeepInSync = source.readInt() == 1;
mLastSyncDate = source.readLong();
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(mId);
dest.writeLong(mParentId);
dest.writeLong(mLength);
dest.writeLong(mCreationTimestamp);
dest.writeLong(mModifiedTimestamp);
dest.writeString(mRemotePath);
dest.writeString(mLocalPath);
dest.writeString(mMimeType);
dest.writeInt(mNeedsUpdating ? 1 : 0);
dest.writeInt(mKeepInSync ? 1 : 0);
dest.writeLong(mLastSyncDate);
}
/**
@ -248,6 +266,8 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
mCreationTimestamp = 0;
mModifiedTimestamp = 0;
mLastSyncDate = 0;
mKeepInSync = false;
mNeedsUpdating = false;
}
/**
@ -321,23 +341,17 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
mLastSyncDate = lastSyncDate;
}
@Override
public int describeContents() {
return this.hashCode();
public void setKeepInSync(boolean keepInSync) {
mKeepInSync = keepInSync;
}
public boolean keepInSync() {
return mKeepInSync;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(mId);
dest.writeLong(mParentId);
dest.writeLong(mLength);
dest.writeLong(mCreationTimestamp);
dest.writeLong(mModifiedTimestamp);
dest.writeString(mRemotePath);
dest.writeString(mLocalPath);
dest.writeString(mMimeType);
dest.writeInt(mNeedsUpdating ? 1 : 0);
dest.writeLong(mLastSyncDate);
public int describeContents() {
return this.hashCode();
}
@Override

View file

@ -31,7 +31,7 @@ public class ProviderMeta {
public static final String AUTHORITY_FILES = "org.owncloud";
public static final String DB_FILE = "owncloud.db";
public static final String DB_NAME = "filelist";
public static final int DB_VERSION = 1;
public static final int DB_VERSION = 2;
private ProviderMeta() {
}
@ -58,6 +58,7 @@ public class ProviderMeta {
public static final String FILE_PATH = "path";
public static final String FILE_ACCOUNT_OWNER = "file_owner";
public static final String FILE_LAST_SYNC_DATE = "last_sync_date";
public static final String FILE_KEEP_IN_SYNC = "keep_in_sync";
public static final String DEFAULT_SORT_ORDER = FILE_NAME
+ " collate nocase asc";

View file

@ -35,6 +35,7 @@ import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteQueryBuilder;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;
/**
* The ContentProvider for the ownCloud App.
@ -68,6 +69,8 @@ public class FileContentProvider extends ContentProvider {
ProviderTableMeta.FILE_STORAGE_PATH);
mProjectionMap.put(ProviderTableMeta.FILE_LAST_SYNC_DATE,
ProviderTableMeta.FILE_LAST_SYNC_DATE);
mProjectionMap.put(ProviderTableMeta.FILE_KEEP_IN_SYNC,
ProviderTableMeta.FILE_KEEP_IN_SYNC);
}
private static final int SINGLE_FILE = 1;
@ -216,7 +219,11 @@ public class FileContentProvider extends ContentProvider {
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
if (oldVersion == 1 && newVersion >= 2) {
db.execSQL("ALTER TABLE " + ProviderTableMeta.DB_NAME +
" ADD COLUMN " + ProviderTableMeta.FILE_KEEP_IN_SYNC + " INTEGER " +
" DEFAULT 0");
}
}
}

View file

@ -19,6 +19,7 @@
package eu.alefzero.owncloud.syncadapter;
import java.io.IOException;
import java.io.ObjectInputStream.GetField;
import java.util.Vector;
import org.apache.jackrabbit.webdav.DavException;
@ -36,6 +37,7 @@ import android.os.Bundle;
import android.util.Log;
import eu.alefzero.owncloud.datamodel.FileDataStorageManager;
import eu.alefzero.owncloud.datamodel.OCFile;
import eu.alefzero.owncloud.files.services.FileDownloader;
import eu.alefzero.webdav.WebdavEntry;
/**
@ -118,6 +120,17 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
WebdavEntry we = new WebdavEntry(resp.getResponses()[i], getUri().getPath());
OCFile file = fillOCFile(we);
file.setParentId(parentId);
if (getStorageManager().getFileByPath(file.getRemotePath()) != null &&
getStorageManager().getFileByPath(file.getRemotePath()).keepInSync() &&
file.getModificationTimestamp() > getStorageManager().getFileByPath(file.getRemotePath())
.getModificationTimestamp()) {
Intent intent = new Intent(this.getContext(), FileDownloader.class);
intent.putExtra(FileDownloader.EXTRA_ACCOUNT, getAccount());
intent.putExtra(FileDownloader.EXTRA_FILE_PATH, file.getURLDecodedRemotePath());
intent.putExtra(FileDownloader.EXTRA_REMOTE_PATH, file.getRemotePath());
file.setKeepInSync(true);
getContext().startService(intent);
}
getStorageManager().saveFile(file);
if (parentId == 0)
parentId = file.getFileId();

View file

@ -111,7 +111,7 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setSupportProgressBarIndeterminateVisibility(false);
Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(getApplicationContext()));
// Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(getApplicationContext()));
if(savedInstanceState != null) {
mDirs = savedInstanceState.getStringArray(KEY_DIR_ARRAY);

View file

@ -120,9 +120,17 @@ public class FileListListAdapter implements ListAdapter {
view.findViewById(R.id.last_mod).setVisibility(View.VISIBLE);
((TextView)view.findViewById(R.id.file_size)).setText(DisplayUtils.bytesToHumanReadable(file.getFileLength()));
((TextView)view.findViewById(R.id.last_mod)).setText(DisplayUtils.unixTimeToHumanReadable(file.getModificationTimestamp()));
// this if-else is needed even thoe fav icon is visible by default
// because android reuses views in listview
if (!file.keepInSync()) {
view.findViewById(R.id.imageView3).setVisibility(View.GONE);
} else {
view.findViewById(R.id.imageView3).setVisibility(View.VISIBLE);
}
} else {
view.findViewById(R.id.file_size).setVisibility(View.GONE);
view.findViewById(R.id.last_mod).setVisibility(View.GONE);
view.findViewById(R.id.imageView3).setVisibility(View.GONE);
}
}

View file

@ -17,6 +17,27 @@
*/
package eu.alefzero.owncloud.ui.fragment;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.cookie.CookiePolicy;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
import org.apache.commons.httpclient.params.HttpMethodParams;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;
import org.apache.jackrabbit.webdav.client.methods.PropFindMethod;
import org.json.JSONException;
import org.json.JSONObject;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.ActivityNotFoundException;
@ -27,27 +48,36 @@ import android.content.IntentFilter;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory.Options;
import android.graphics.Point;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceActivity.Header;
import android.util.Log;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.webkit.MimeTypeMap;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.actionbarsherlock.app.SherlockFragment;
import eu.alefzero.owncloud.AccountUtils;
import eu.alefzero.owncloud.DisplayUtils;
import eu.alefzero.owncloud.R;
import eu.alefzero.owncloud.authenticator.AccountAuthenticator;
import eu.alefzero.owncloud.datamodel.FileDataStorageManager;
import eu.alefzero.owncloud.datamodel.OCFile;
import eu.alefzero.owncloud.files.services.FileDownloader;
import eu.alefzero.owncloud.utils.OwnCloudVersion;
import eu.alefzero.webdav.WebdavClient;
/**
* This Fragment is used to display the details about a file.
@ -155,14 +185,27 @@ public class FileDetailFragment extends SherlockFragment implements
@Override
public void onClick(View v) {
Toast.makeText(getActivity(), "Downloading", Toast.LENGTH_LONG).show();
Intent i = new Intent(getActivity(), FileDownloader.class);
i.putExtra(FileDownloader.EXTRA_ACCOUNT, mAccount);
i.putExtra(FileDownloader.EXTRA_REMOTE_PATH, mFile.getRemotePath());
i.putExtra(FileDownloader.EXTRA_FILE_PATH, mFile.getURLDecodedRemotePath());
i.putExtra(FileDownloader.EXTRA_FILE_SIZE, mFile.getFileLength());
v.setEnabled(false);
getActivity().startService(i);
if (v.getId() == R.id.fdDownloadBtn) {
Toast.makeText(getActivity(), "Downloading", Toast.LENGTH_LONG).show();
Intent i = new Intent(getActivity(), FileDownloader.class);
i.putExtra(FileDownloader.EXTRA_ACCOUNT, mAccount);
i.putExtra(FileDownloader.EXTRA_REMOTE_PATH, mFile.getRemotePath());
i.putExtra(FileDownloader.EXTRA_FILE_PATH, mFile.getURLDecodedRemotePath());
i.putExtra(FileDownloader.EXTRA_FILE_SIZE, mFile.getFileLength());
v.setEnabled(false);
getActivity().startService(i);
} else if (v.getId() == R.id.fdKeepInSync) {
CheckBox cb = (CheckBox) getView().findViewById(R.id.fdKeepInSync);
mFile.setKeepInSync(cb.isChecked());
FileDataStorageManager fdsm = new FileDataStorageManager(mAccount, getActivity().getApplicationContext().getContentResolver());
fdsm.saveFile(mFile);
if (mFile.keepInSync() && !mFile.isDownloaded()) {
onClick(getView().findViewById(R.id.fdDownloadBtn));
}
}/* else if (v.getId() == R.id.fdShareBtn) {
Thread t = new Thread(new ShareRunnable(mFile.getRemotePath()));
t.start();
}*/
}
@ -215,6 +258,11 @@ public class FileDetailFragment extends SherlockFragment implements
setTimeModified(mFile.getModificationTimestamp());
CheckBox cb = (CheckBox)getView().findViewById(R.id.fdKeepInSync);
cb.setChecked(mFile.keepInSync());
cb.setOnClickListener(this);
//getView().findViewById(R.id.fdShareBtn).setOnClickListener(this);
if (mFile.getStoragePath() != null) {
// Update preview
ImageView preview = (ImageView) getView().findViewById(R.id.fdPreview);
@ -236,13 +284,29 @@ public class FileDetailFragment extends SherlockFragment implements
int width = options.outWidth;
int height = options.outHeight;
int scale = 1;
boolean recycle = false;
if (width >= 2048 || height >= 2048) {
scale = (int) (Math.ceil(Math.max(height, width)/2048.));
options.inSampleSize = scale;
bmp.recycle();
bmp = BitmapFactory.decodeFile(mFile.getStoragePath(), options);
recycle = true;
}
Display display = getActivity().getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int screenwidth = size.x;
Log.e("ASD", "W " + width + " SW " + screenwidth);
if (width > screenwidth) {
scale = (int) (Math.ceil(Math.max(height, width)/screenwidth));
options.inSampleSize = scale;
recycle = true;
}
if (recycle) bmp.recycle();
bmp = BitmapFactory.decodeFile(mFile.getStoragePath(), options);
}
if (bmp != null) {
preview.setImageBitmap(bmp);
@ -406,4 +470,118 @@ public class FileDetailFragment extends SherlockFragment implements
}
// this is a temporary class for sharing purposes, it need to be replacead in transfer service
private class ShareRunnable implements Runnable {
private String mPath;
public ShareRunnable(String path) {
mPath = path;
}
public void run() {
AccountManager am = AccountManager.get(getActivity());
Account account = AccountUtils.getCurrentOwnCloudAccount(getActivity());
OwnCloudVersion ocv = new OwnCloudVersion(am.getUserData(account, AccountAuthenticator.KEY_OC_VERSION));
String url = am.getUserData(account, AccountAuthenticator.KEY_OC_BASE_URL) + AccountUtils.getWebdavPath(ocv);
Log.d("share", "sharing for version " + ocv.toString());
if (ocv.compareTo(new OwnCloudVersion(0x040000)) >= 0) {
String APPS_PATH = "/apps/files_sharing/";
String SHARE_PATH = "ajax/share.php";
String SHARED_PATH = "/apps/files_sharing/get.php?token=";
final String WEBDAV_SCRIPT = "webdav.php";
final String WEBDAV_FILES_LOCATION = "/files/";
WebdavClient wc = new WebdavClient();
HttpConnectionManagerParams params = new HttpConnectionManagerParams();
params.setMaxConnectionsPerHost(wc.getHostConfiguration(), 5);
//wc.getParams().setParameter("http.protocol.single-cookie-header", true);
//wc.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
PostMethod post = new PostMethod(am.getUserData(account, AccountAuthenticator.KEY_OC_BASE_URL) + APPS_PATH + SHARE_PATH);
post.addRequestHeader("Content-type","application/x-www-form-urlencoded; charset=UTF-8" );
post.addRequestHeader("Referer", am.getUserData(account, AccountAuthenticator.KEY_OC_BASE_URL));
List<NameValuePair> formparams = new ArrayList<NameValuePair>();
Log.d("share", mPath+"");
formparams.add(new BasicNameValuePair("sources",mPath));
formparams.add(new BasicNameValuePair("uid_shared_with", "public"));
formparams.add(new BasicNameValuePair("permissions", "0"));
post.setRequestEntity(new StringRequestEntity(URLEncodedUtils.format(formparams, HTTP.UTF_8)));
int status;
try {
PropFindMethod find = new PropFindMethod(url+"/");
find.addRequestHeader("Referer", am.getUserData(account, AccountAuthenticator.KEY_OC_BASE_URL));
Log.d("sharer", ""+ url+"/");
wc.setCredentials(account.name.substring(0, account.name.lastIndexOf('@')), am.getPassword(account));
for (org.apache.commons.httpclient.Header a : find.getRequestHeaders()) {
Log.d("sharer-h", a.getName() + ":"+a.getValue());
}
int status2 = wc.executeMethod(find);
Log.d("sharer", "propstatus "+status2);
GetMethod get = new GetMethod(am.getUserData(account, AccountAuthenticator.KEY_OC_BASE_URL) + "/");
get.addRequestHeader("Referer", am.getUserData(account, AccountAuthenticator.KEY_OC_BASE_URL));
status2 = wc.executeMethod(get);
Log.d("sharer", "getstatus "+status2);
Log.d("sharer", "" + get.getResponseBodyAsString());
for (org.apache.commons.httpclient.Header a : get.getResponseHeaders()) {
Log.d("sharer", a.getName() + ":"+a.getValue());
}
status = wc.executeMethod(post);
for (org.apache.commons.httpclient.Header a : post.getRequestHeaders()) {
Log.d("sharer-h", a.getName() + ":"+a.getValue());
}
for (org.apache.commons.httpclient.Header a : post.getResponseHeaders()) {
Log.d("sharer", a.getName() + ":"+a.getValue());
}
String resp = post.getResponseBodyAsString();
Log.d("share", ""+post.getURI().toString());
Log.d("share", "returned status " + status);
Log.d("share", " " +resp);
if(status != HttpStatus.SC_OK ||resp == null || resp.equals("") || resp.startsWith("false")) {
return;
}
JSONObject jsonObject = new JSONObject (resp);
String jsonStatus = jsonObject.getString("status");
if(!jsonStatus.equals("success")) throw new Exception("Error while sharing file status != success");
String token = jsonObject.getString("data");
String uri = am.getUserData(account, AccountAuthenticator.KEY_OC_BASE_URL) + SHARED_PATH + token;
Log.d("Actions:shareFile ok", "url: " + uri);
} catch (HttpException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else if (ocv.compareTo(new OwnCloudVersion(0x030000)) >= 0) {
}
}
}
}

View file

@ -21,10 +21,12 @@ import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.HashMap;
import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpConnectionManager;
import org.apache.commons.httpclient.HttpVersion;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.methods.GetMethod;
@ -33,6 +35,7 @@ import org.apache.commons.httpclient.methods.PutMethod;
import org.apache.commons.httpclient.params.HttpMethodParams;
import org.apache.commons.httpclient.protocol.Protocol;
import org.apache.http.HttpStatus;
import org.apache.http.params.CoreProtocolPNames;
import org.apache.jackrabbit.webdav.client.methods.DavMethod;
import org.apache.jackrabbit.webdav.client.methods.DeleteMethod;
import org.apache.jackrabbit.webdav.client.methods.MkColMethod;
@ -54,7 +57,16 @@ public class WebdavClient extends HttpClient {
final private static String TAG = "WebdavClient";
private static final String USER_AGENT = "Android-ownCloud";
private OnDatatransferProgressListener mDataTransferListener;
private static HashMap<String, WebdavClient> clients = new HashMap<String, WebdavClient>();
static private MultiThreadedHttpConnectionManager mConnManager = null;
static public MultiThreadedHttpConnectionManager getMultiThreadedConnManager() {
if (mConnManager == null) {
mConnManager = new MultiThreadedHttpConnectionManager();
mConnManager.setMaxConnectionsPerHost(5);
mConnManager.setMaxTotalConnections(5);
}
return mConnManager;
}
/**
* Creates a WebdavClient setup for the current account
@ -62,7 +74,7 @@ public class WebdavClient extends HttpClient {
* @param context The application context
* @return
*/
public WebdavClient (Account account, Context context){
public WebdavClient (Account account, Context context) {
OwnCloudVersion ownCloudVersion = new OwnCloudVersion(AccountManager.get(context).getUserData(account,
AccountAuthenticator.KEY_OC_VERSION));
String baseUrl = AccountManager.get(context).getUserData(account, AccountAuthenticator.KEY_OC_BASE_URL);
@ -71,15 +83,20 @@ public class WebdavClient extends HttpClient {
String password = AccountManager.get(context).getPassword(account);
mUri = Uri.parse(baseUrl + webDavPath);
getParams().setParameter(HttpMethodParams.USER_AGENT, USER_AGENT);
setCredentials(username, password);
}
public WebdavClient() {
super(getMultiThreadedConnManager());
getParams().setParameter(HttpMethodParams.USER_AGENT, USER_AGENT);
getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
allowSelfsignedCertificates();
}
public WebdavClient(){}
public void setCredentials(String username, String password) {
getParams().setAuthenticationPreemptive(true);
//getParams().setAuthenticationPreemptive(true);
getState().setCredentials(AuthScope.ANY,
getCredentials(username, password));
}