fix errors in DropboxV2+WebDav implementation

This commit is contained in:
Philipp Crocoll 2016-11-28 11:44:36 +01:00
parent 31f02eca61
commit 08b7e42a33
7 changed files with 82 additions and 14 deletions

View File

@ -425,6 +425,8 @@ public class DropboxV2Storage extends JavaFileStorageBase
//querying root is not supported
if ((filename.equals("")) || (filename.equals("/")))
return getRootFileEntry();
if (filename.endsWith("/"))
filename = filename.substring(0,filename.length()-1);
Metadata dbEntry = dbxClient.files().getMetadata(filename);
return convertToFileEntry(dbEntry);

View File

@ -3,6 +3,7 @@ package keepass2android.javafilestorage;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
@ -265,7 +266,7 @@ public class WebDavStorage extends JavaFileStorageBase {
e.displayName = okprop.DisplayName;
if (e.displayName == null)
{
e.displayName = getDisplayName(r.href);
e.displayName = getDisplayNameFromHref(r.href);
}
e.path = r.href;
@ -418,15 +419,28 @@ public class WebDavStorage extends JavaFileStorageBase {
}
String getDisplayNameFromHref(String href)
{
if (href.endsWith("/"))
href = href.substring(0, href.length()-1);
int lastIndex = href.lastIndexOf("/");
if (lastIndex >= 0)
return href.substring(lastIndex + 1);
else
return href;
}
@Override
public String getDisplayName(String path) {
if (path.endsWith("/"))
path = path.substring(0, path.length()-1);
int lastIndex = path.lastIndexOf("/");
if (lastIndex >= 0)
return path.substring(lastIndex + 1);
else
return path;
try {
ConnectionInfo ci = splitStringToConnectionInfo(path);
return ci.URL;
}
catch (Exception e)
{
return getDisplayNameFromHref(path);
}
}

View File

@ -304,8 +304,17 @@ public abstract class Kp2aFileProvider extends BaseFileProvider {
Log.d(CLASSNAME, "parent file is null");
return null;
}
FileEntry e = this.getFileEntryCached(parentPath);
FileEntry e;
try {
e = this.getFileEntryCached(parentPath);
}
catch (Exception ex)
{
ex.printStackTrace();
return null;
}
if (e == null)
return null;
matrixCursor = BaseFileProviderUtils.newBaseFileCursor();

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -15,7 +15,7 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="85.13.147.153"
android:text=""
android:layout_weight="1"
android:inputType="textNoSuggestions"
android:hint="@string/hint_sftp_host" />
@ -45,7 +45,7 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="f00c530c"
android:text=""
android:hint="@string/hint_username" />
<EditText
@ -53,7 +53,7 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:text="2C4vsSt8MhNEaqv5"
android:text=""
android:singleLine="true"
android:hint="@string/hint_pass" />

View File

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="12dip"
>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/http_url"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:layout_weight="1"
android:text="https://webdav.mc.gmx.net/subfolder/"
android:inputType="textNoSuggestions"
android:hint="@string/hint_http_url" />
</LinearLayout>
<EditText
android:id="@+id/http_user"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:text=""
android:hint="@string/hint_username" />
<EditText
android:id="@+id/http_password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:singleLine="true"
android:text=""
android:hint="@string/hint_pass" />
</LinearLayout>