OneDrive: handle null modification time

WebDav: use custom HostnameVerifier to allow to ignore certificate problems
File chooser: improve error reporting in C# app
FileSelectHelper: fix issue with incorrect handling of default scheme in webdav dialog
release 1.01-c
This commit is contained in:
Philipp Crocoll
2017-01-27 21:03:53 +01:00
parent 7ccf55f84f
commit 14f7167340
12 changed files with 129 additions and 38 deletions

View File

@@ -1024,6 +1024,8 @@ public class FragmentFiles extends Fragment implements
String errMsg = null;
boolean errorMessageInDialog = false;
String log = "";
@Override
protected Bundle doInBackground(Void... params) {
/*
@@ -1032,6 +1034,12 @@ public class FragmentFiles extends Fragment implements
Uri path = (Uri) (savedInstanceState != null ? savedInstanceState
.getParcelable(CURRENT_LOCATION) : null);
log += "savedInstanceState != null ? " + (savedInstanceState != null);
log += "\npath != null ? " + (path != null);
if (path != null) log += path;
log += "\nmRoot != null ? " + (mRoot != null);
if (mRoot != null) log += mRoot;
if (mRoot != null) {
Uri queryUri = BaseFile.genContentUriApi(mRoot.getAuthority())
.buildUpon()
@@ -1042,10 +1050,11 @@ public class FragmentFiles extends Fragment implements
Cursor cursor = getActivity().getContentResolver().query(
queryUri,
null, null, null, null);
log += "\ncursor != null ? " + (cursor != null);
if (cursor != null) {
cursor.moveToFirst();
errMsg = getString(R.string.afc_msg_cannot_connect_to_file_provider_service) + " " + cursor.getString(0);
errMsg = getString(R.string.afc_msg_cannot_connect_to_file_provider_service) + " " + " " + cursor.getString(0);
errorMessageInDialog = true;
return null;
}
@@ -1057,6 +1066,7 @@ public class FragmentFiles extends Fragment implements
/*
* Selected file
*/
log += "try selected file ";
if (path == null) {
path = (Uri) getArguments().getParcelable(
FileChooserActivity.EXTRA_SELECT_FILE);
@@ -1067,15 +1077,23 @@ public class FragmentFiles extends Fragment implements
path = BaseFileProviderUtils.getParentFile(
getActivity(), path);
}
log += "success ? " + (path != null);
/*
* Rootpath
*/
if (path == null
|| !BaseFileProviderUtils.isDirectory(getActivity(),
path)) {
log += "rootpath";
if ((path == null)
|| (!BaseFileProviderUtils.isDirectory(getActivity(),
path))) {
log += " assign";
path = mRoot;
}
if (path != null) {
log += " path=" + path;
log += " isdir?" + BaseFileProviderUtils.isDirectory(getActivity(),
path);
}
/*
* Last location
@@ -1084,29 +1102,35 @@ public class FragmentFiles extends Fragment implements
&& DisplayPrefs.isRememberLastLocation(getActivity())) {
String lastLocation = DisplayPrefs
.getLastLocation(getActivity());
if (lastLocation != null)
if (lastLocation != null) {
path = Uri.parse(lastLocation);
log += " from last loc";
}
}
if (path == null
|| !BaseFileProviderUtils.isDirectory(getActivity(),
path))
path)) {
path = BaseFileProviderUtils.getDefaultPath(
getActivity(),
path == null ? mFileProviderAuthority : path
.getAuthority());
log += " getDefault. path==null?" + (path == null);
}
}
catch (Exception ex)
{
errMsg = getString(R.string.afc_msg_cannot_connect_to_file_provider_service) + " " + ex.toString();
errMsg = getString(R.string.afc_msg_cannot_connect_to_file_provider_service) + " " + ex.toString() ;
errorMessageInDialog = true;
return null;
}
if (path == null)
if (path == null) {
errMsg = "Did not find initial path.";
errorMessageInDialog = true;
return null;
}
if (BuildConfig.DEBUG)
Log.d(CLASSNAME, "loadInitialPath() >> " + path);
@@ -1117,6 +1141,7 @@ public class FragmentFiles extends Fragment implements
result.putParcelable(PATH, path);
return result;
} else {
errorMessageInDialog = true;
errMsg = getString(R.string.afc_pmsg_cannot_access_dir,
BaseFileProviderUtils.getFileName(getActivity(),
path));
@@ -1162,7 +1187,7 @@ public class FragmentFiles extends Fragment implements
}
} else
showCannotConnectToServiceAndWaitForTheUserToFinish();
showCannotConnectToServiceAndWaitForTheUserToFinish("loadInitialPath");
}// onPostExecute()
}.execute();
@@ -1195,9 +1220,9 @@ public class FragmentFiles extends Fragment implements
/**
* As the name means...
*/
private void showCannotConnectToServiceAndWaitForTheUserToFinish() {
private void showCannotConnectToServiceAndWaitForTheUserToFinish(String info) {
Dlg.showError(getActivity(),
R.string.afc_msg_cannot_connect_to_file_provider_service,
getActivity().getString(R.string.afc_msg_cannot_connect_to_file_provider_service) + " " + info,
new DialogInterface.OnCancelListener() {
@Override
@@ -1808,7 +1833,7 @@ public class FragmentFiles extends Fragment implements
* a directory, of course.
* @since v4.3 beta
*/
private void goTo(Uri dir) {
private void goTo(final Uri dir) {
new LoadingDialog<Uri, String, Bundle>(getActivity(), false) {
/**
@@ -1866,7 +1891,7 @@ public class FragmentFiles extends Fragment implements
Dlg.toast(getActivity(), errMsg, Dlg.LENGTH_SHORT);
}
else
showCannotConnectToServiceAndWaitForTheUserToFinish();
showCannotConnectToServiceAndWaitForTheUserToFinish("goTo: " + dir.toString());
}// onPostExecute()
}.execute(dir);

View File

@@ -66,6 +66,9 @@ public abstract class Kp2aFileProvider extends BaseFileProvider {
@Override
public boolean onCreate() {
Log.d("KP2A_FC_P", "onCreate");
BaseFileProviderUtils.registerProviderInfo(_ID,
getAuthority());
@@ -84,7 +87,7 @@ public abstract class Kp2aFileProvider extends BaseFileProvider {
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
if (Utils.doLog())
Log.d(CLASSNAME, "delete() >> " + uri);
Log.d("KP2A_FC_P", "delete() >> " + uri);
int count = 0;
@@ -136,7 +139,7 @@ public abstract class Kp2aFileProvider extends BaseFileProvider {
@Override
public Uri insert(Uri uri, ContentValues values) {
if (Utils.doLog())
Log.d(CLASSNAME, "insert() >> " + uri);
Log.d("KP2A_FC_P", "insert() >> " + uri);
switch (URI_MATCHER.match(uri)) {
case URI_DIRECTORY:
@@ -184,7 +187,7 @@ public abstract class Kp2aFileProvider extends BaseFileProvider {
public Cursor query(Uri uri, String[] projection, String selection,
String[] selectionArgs, String sortOrder) {
if (Utils.doLog())
Log.d(CLASSNAME, String.format(
Log.d("KP2A_FC_P", String.format(
"query() >> uri = %s (%s) >> match = %s", uri,
uri.getLastPathSegment(), URI_MATCHER.match(uri)));
@@ -223,10 +226,13 @@ public abstract class Kp2aFileProvider extends BaseFileProvider {
try
{
checkConnection(uri);
Log.d("KP2A_FC_P", "checking connection for " + uri + " ok.");
return null;
}
catch (Exception e)
{
Log.d("KP2A_FC_P","Check connection failed with: " + e.toString());
MatrixCursor matrixCursor = new MatrixCursor(BaseFileProviderUtils.CONNECTION_CHECK_CURSOR_COLUMNS);
RowBuilder newRow = matrixCursor.newRow();
String message = e.getLocalizedMessage();
@@ -244,11 +250,17 @@ public abstract class Kp2aFileProvider extends BaseFileProvider {
{
String path = Uri.parse(
uri.getQueryParameter(BaseFile.PARAM_SOURCE)).toString();
getFileEntry(path);
StringBuilder sb = new StringBuilder();
FileEntry result = getFileEntry(path, sb);
if (result == null)
throw new Exception(sb.toString());
}
catch (FileNotFoundException ex)
{
Log.d("KP2A_FC_P","File not found. Ignore.");
return;
}
}
@@ -269,7 +281,7 @@ public abstract class Kp2aFileProvider extends BaseFileProvider {
String lastPathSegment = uri.getLastPathSegment();
//Log.d(CLASSNAME, "lastPathSegment:" + lastPathSegment);
Log.d("KP2A_FC_P", "lastPathSegment:" + lastPathSegment);
if (BaseFile.CMD_CANCEL.equals(lastPathSegment)) {
int taskId = ProviderUtils.getIntQueryParam(uri,
@@ -354,6 +366,7 @@ public abstract class Kp2aFileProvider extends BaseFileProvider {
} else if (BaseFile.CMD_CHECK_CONNECTION.equals(lastPathSegment))
{
Log.d("KP2A_FC_P","Check connection...");
return getCheckConnectionCursor(uri);
}
@@ -591,7 +604,7 @@ public abstract class Kp2aFileProvider extends BaseFileProvider {
FileEntry newEntry ;
try {
//it's not -> query the information.
newEntry = getFileEntry(filename);
newEntry = getFileEntry(filename, null);
} catch (Exception e) {
e.printStackTrace();
return null;
@@ -680,11 +693,11 @@ public abstract class Kp2aFileProvider extends BaseFileProvider {
});
} catch (CancellationException e) {
if (Utils.doLog())
Log.d(CLASSNAME, "sortFiles() >> cancelled...");
Log.d("KP2A_FC_P", "sortFiles() >> cancelled...");
}
catch (Exception e)
{
Log.d(CLASSNAME, "sortFiles() >> "+e);
Log.d("KP2A_FC_P", "sortFiles() >> "+e);
throw e;
}
}// sortFiles()
@@ -721,11 +734,11 @@ public abstract class Kp2aFileProvider extends BaseFileProvider {
if (targetParent != null && targetParent.startsWith(source))
{
if (Utils.doLog())
Log.d(CLASSNAME, source+" is parent of "+target);
Log.d("KP2A_FC_P", source+" is parent of "+target);
return BaseFileProviderUtils.newClosedCursor();
}
if (Utils.doLog())
Log.d(CLASSNAME, source+" is no parent of "+target);
Log.d("KP2A_FC_P", source+" is no parent of "+target);
return null;
}// doCheckAncestor()
@@ -764,27 +777,27 @@ public abstract class Kp2aFileProvider extends BaseFileProvider {
path = removeTrailingSlash(path);
if (path.indexOf("://") == -1)
{
Log.d(CLASSNAME, "invalid path: " + path);
Log.d("KP2A_FC_P", "invalid path: " + path);
return null;
}
String pathWithoutProtocol = path.substring(path.indexOf("://")+3);
int lastSlashPos = path.lastIndexOf("/");
if (pathWithoutProtocol.indexOf("/") == -1)
{
Log.d(CLASSNAME, "parent of " + path +" is null");
Log.d("KP2A_FC_P", "parent of " + path +" is null");
return null;
}
else
{
String parent = path.substring(0, lastSlashPos)+"/";
Log.d(CLASSNAME, "parent of " + path +" is "+parent);
Log.d("KP2A_FC_P", "parent of " + path +" is "+parent);
return parent;
}
}
protected abstract FileEntry getFileEntry(String path) throws Exception;
protected abstract FileEntry getFileEntry(String path, StringBuilder errorMessageBuilder) throws Exception;
/**
* Lists all file inside {@code dirName}.