mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 07:05:49 +03:00
Fixed problem with some special characters when opening files; renamed WebdavUtils.encode to WebdavUtils.encodePath; fixed null pointer exception in preview
This commit is contained in:
parent
c6b553f635
commit
45f89711be
6 changed files with 19 additions and 16 deletions
|
@ -18,7 +18,7 @@
|
|||
-->
|
||||
<manifest package="eu.alefzero.owncloud"
|
||||
android:versionCode="1"
|
||||
android:versionName="0.1.161B" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
android:versionName="0.1.162B" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
|
||||
|
|
|
@ -220,7 +220,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
|
|||
for (int i=0; i < files.size() && !mCancellation; i++) {
|
||||
OCFile newFile = files.get(i);
|
||||
if (newFile.getMimetype().equals("DIR")) {
|
||||
fetchData(getUri().toString() + WebdavUtils.encode(newFile.getRemotePath()), syncResult, newFile.getFileId());
|
||||
fetchData(getUri().toString() + WebdavUtils.encodePath(newFile.getRemotePath()), syncResult, newFile.getFileId());
|
||||
}
|
||||
}
|
||||
if (mCancellation) Log.d(TAG, "Leaving " + uri + " because cancellation request");
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.io.File;
|
|||
import eu.alefzero.owncloud.R;
|
||||
import eu.alefzero.owncloud.authenticator.AccountAuthenticator;
|
||||
import eu.alefzero.owncloud.db.ProviderMeta.ProviderTableMeta;
|
||||
import eu.alefzero.webdav.WebdavUtils;
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.content.Context;
|
||||
|
@ -84,7 +85,7 @@ public class FileListActionListAdapter implements ListAdapter {
|
|||
.getSystemService(Context.ACCOUNT_SERVICE);
|
||||
String ocurl = accm.getUserData(mAccount,
|
||||
AccountAuthenticator.KEY_OC_URL);
|
||||
ocurl += mFilePath + Uri.encode(mFilename);
|
||||
ocurl += WebdavUtils.encodePath(mFilePath + mFilename);
|
||||
intent.setData(Uri.parse(ocurl));
|
||||
} else {
|
||||
intent.putExtra("toDownload", false);
|
||||
|
|
|
@ -197,6 +197,7 @@ public class FileDetailFragment extends SherlockFragment implements
|
|||
IntentFilter filter = new IntentFilter(
|
||||
FileDownloader.DOWNLOAD_FINISH_MESSAGE);
|
||||
getActivity().registerReceiver(mDownloadFinishReceiver, filter);
|
||||
mPreview = (ImageView)mView.findViewById(R.id.fdPreview);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -340,9 +341,10 @@ public class FileDetailFragment extends SherlockFragment implements
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
String storagePath = mFile.getStoragePath();
|
||||
String encodedStoragePath = WebdavUtils.encodePath(storagePath);
|
||||
try {
|
||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||
i.setDataAndType(Uri.parse("file://"+ storagePath), mFile.getMimetype());
|
||||
i.setDataAndType(Uri.parse("file://"+ encodedStoragePath), mFile.getMimetype());
|
||||
i.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||
startActivity(i);
|
||||
|
||||
|
@ -354,7 +356,7 @@ public class FileDetailFragment extends SherlockFragment implements
|
|||
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||
mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(storagePath.substring(storagePath.lastIndexOf('.') + 1));
|
||||
if (mimeType != null && !mimeType.equals(mFile.getMimetype())) {
|
||||
i.setDataAndType(Uri.parse("file://"+mFile.getStoragePath()), mimeType);
|
||||
i.setDataAndType(Uri.parse("file://"+ encodedStoragePath), mimeType);
|
||||
i.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||
startActivity(i);
|
||||
toastIt = false;
|
||||
|
@ -644,11 +646,11 @@ public class FileDetailFragment extends SherlockFragment implements
|
|||
String baseUrl = am.getUserData(mAccount, AccountAuthenticator.KEY_OC_BASE_URL);
|
||||
OwnCloudVersion ocv = new OwnCloudVersion(am.getUserData(mAccount, AccountAuthenticator.KEY_OC_VERSION));
|
||||
String webdav_path = AccountUtils.getWebdavPath(ocv);
|
||||
Log.d("ASD", ""+baseUrl + webdav_path + WebdavUtils.encode(mOld.getRemotePath()));
|
||||
Log.d("ASD", ""+baseUrl + webdav_path + WebdavUtils.encodePath(mOld.getRemotePath()));
|
||||
|
||||
Log.e("ASD", Uri.parse(baseUrl).getPath() == null ? "" : Uri.parse(baseUrl).getPath() + webdav_path + WebdavUtils.encode(mNew.getRemotePath()));
|
||||
LocalMoveMethod move = new LocalMoveMethod(baseUrl + webdav_path + WebdavUtils.encode(mOld.getRemotePath()),
|
||||
Uri.parse(baseUrl).getPath() == null ? "" : Uri.parse(baseUrl).getPath() + webdav_path + WebdavUtils.encode(mNew.getRemotePath()));
|
||||
Log.e("ASD", Uri.parse(baseUrl).getPath() == null ? "" : Uri.parse(baseUrl).getPath() + webdav_path + WebdavUtils.encodePath(mNew.getRemotePath()));
|
||||
LocalMoveMethod move = new LocalMoveMethod(baseUrl + webdav_path + WebdavUtils.encodePath(mOld.getRemotePath()),
|
||||
Uri.parse(baseUrl).getPath() == null ? "" : Uri.parse(baseUrl).getPath() + webdav_path + WebdavUtils.encodePath(mNew.getRemotePath()));
|
||||
|
||||
try {
|
||||
int status = wc.executeMethod(move);
|
||||
|
@ -772,9 +774,9 @@ public class FileDetailFragment extends SherlockFragment implements
|
|||
String baseUrl = am.getUserData(mAccount, AccountAuthenticator.KEY_OC_BASE_URL);
|
||||
OwnCloudVersion ocv = new OwnCloudVersion(am.getUserData(mAccount, AccountAuthenticator.KEY_OC_VERSION));
|
||||
String webdav_path = AccountUtils.getWebdavPath(ocv);
|
||||
Log.d("ASD", ""+baseUrl + webdav_path + WebdavUtils.encode(mFileToRemove.getRemotePath()));
|
||||
Log.d("ASD", ""+baseUrl + webdav_path + WebdavUtils.encodePath(mFileToRemove.getRemotePath()));
|
||||
|
||||
DeleteMethod delete = new DeleteMethod(baseUrl + webdav_path + WebdavUtils.encode(mFileToRemove.getRemotePath()));
|
||||
DeleteMethod delete = new DeleteMethod(baseUrl + webdav_path + WebdavUtils.encodePath(mFileToRemove.getRemotePath()));
|
||||
HttpMethodParams params = delete.getParams();
|
||||
params.setSoTimeout(1000);
|
||||
delete.setParams(params);
|
||||
|
|
|
@ -122,7 +122,7 @@ public class WebdavClient extends HttpClient {
|
|||
*/
|
||||
public boolean downloadFile(String remoteFilepath, File targetPath) {
|
||||
boolean ret = false;
|
||||
GetMethod get = new GetMethod(mUri.toString() + WebdavUtils.encode(remoteFilepath));
|
||||
GetMethod get = new GetMethod(mUri.toString() + WebdavUtils.encodePath(remoteFilepath));
|
||||
HttpMethodParams params = get.getParams();
|
||||
params.setSoTimeout(0); // that means "infinite timeout"; it's the default value, but let's make it explicit
|
||||
get.setParams(params);
|
||||
|
@ -163,7 +163,7 @@ public class WebdavClient extends HttpClient {
|
|||
* @return
|
||||
*/
|
||||
public boolean deleteFile(String remoteFilePath){
|
||||
DavMethod delete = new DeleteMethod(mUri.toString() + WebdavUtils.encode(remoteFilePath));
|
||||
DavMethod delete = new DeleteMethod(mUri.toString() + WebdavUtils.encodePath(remoteFilePath));
|
||||
try {
|
||||
executeMethod(delete);
|
||||
} catch (Throwable e) {
|
||||
|
@ -196,7 +196,7 @@ public class WebdavClient extends HttpClient {
|
|||
FileRequestEntity entity = new FileRequestEntity(f, contentType);
|
||||
entity.setOnDatatransferProgressListener(mDataTransferListener);
|
||||
Log.e("ASD", f.exists() + " " + entity.getContentLength());
|
||||
PutMethod put = new PutMethod(mUri.toString() + WebdavUtils.encode(remoteTarget));
|
||||
PutMethod put = new PutMethod(mUri.toString() + WebdavUtils.encodePath(remoteTarget));
|
||||
HttpMethodParams params = put.getParams();
|
||||
params.setSoTimeout(0); // that means "infinite timeout"; it's the default value, but let's make it explicit
|
||||
put.setParams(params);
|
||||
|
@ -242,7 +242,7 @@ public class WebdavClient extends HttpClient {
|
|||
*/
|
||||
public boolean createDirectory(String path) {
|
||||
try {
|
||||
MkColMethod mkcol = new MkColMethod(mUri.toString() + WebdavUtils.encode(path));
|
||||
MkColMethod mkcol = new MkColMethod(mUri.toString() + WebdavUtils.encodePath(path));
|
||||
int status = executeMethod(mkcol);
|
||||
Log.d(TAG, "Status returned " + status);
|
||||
Log.d(TAG, "uri: " + mkcol.getURI().toString());
|
||||
|
|
|
@ -68,7 +68,7 @@ public class WebdavUtils {
|
|||
* @param remoteFilePath Path
|
||||
* @return Encoded path according to RFC 2396, always starting with "/"
|
||||
*/
|
||||
public static String encode(String remoteFilePath) {
|
||||
public static String encodePath(String remoteFilePath) {
|
||||
String encodedPath = Uri.encode(remoteFilePath, "/");
|
||||
if (!encodedPath.startsWith("/"))
|
||||
encodedPath = "/" + encodedPath;
|
||||
|
|
Loading…
Reference in a new issue