Fix identation in SambaDocumentsProvider
This commit is contained in:
parent
baf3ba19f4
commit
d12c7ebdb8
1 changed files with 90 additions and 90 deletions
|
@ -75,75 +75,75 @@ public class SambaDocumentsProvider extends DocumentsProvider {
|
||||||
private static final String TAG = "SambaDocumentsProvider";
|
private static final String TAG = "SambaDocumentsProvider";
|
||||||
|
|
||||||
private static final String[] DEFAULT_ROOT_PROJECTION = {
|
private static final String[] DEFAULT_ROOT_PROJECTION = {
|
||||||
Root.COLUMN_ROOT_ID,
|
Root.COLUMN_ROOT_ID,
|
||||||
Root.COLUMN_DOCUMENT_ID,
|
Root.COLUMN_DOCUMENT_ID,
|
||||||
Root.COLUMN_TITLE,
|
Root.COLUMN_TITLE,
|
||||||
Root.COLUMN_FLAGS,
|
Root.COLUMN_FLAGS,
|
||||||
Root.COLUMN_ICON
|
Root.COLUMN_ICON
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final String[] DEFAULT_DOCUMENT_PROJECTION = {
|
private static final String[] DEFAULT_DOCUMENT_PROJECTION = {
|
||||||
Document.COLUMN_DOCUMENT_ID,
|
Document.COLUMN_DOCUMENT_ID,
|
||||||
Document.COLUMN_DISPLAY_NAME,
|
Document.COLUMN_DISPLAY_NAME,
|
||||||
Document.COLUMN_FLAGS,
|
Document.COLUMN_FLAGS,
|
||||||
Document.COLUMN_MIME_TYPE,
|
Document.COLUMN_MIME_TYPE,
|
||||||
Document.COLUMN_SIZE,
|
Document.COLUMN_SIZE,
|
||||||
Document.COLUMN_LAST_MODIFIED,
|
Document.COLUMN_LAST_MODIFIED,
|
||||||
Document.COLUMN_ICON
|
Document.COLUMN_ICON
|
||||||
};
|
};
|
||||||
|
|
||||||
private final OnTaskFinishedCallback<Uri> mLoadDocumentCallback =
|
private final OnTaskFinishedCallback<Uri> mLoadDocumentCallback =
|
||||||
new OnTaskFinishedCallback<Uri>() {
|
new OnTaskFinishedCallback<Uri>() {
|
||||||
@Override
|
@Override
|
||||||
public void onTaskFinished(@Status int status, @Nullable Uri uri, Exception exception) {
|
public void onTaskFinished(@Status int status, @Nullable Uri uri, Exception exception) {
|
||||||
getContext().getContentResolver().notifyChange(toNotifyUri(uri), null, false);
|
getContext().getContentResolver().notifyChange(toNotifyUri(uri), null, false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private final OnTaskFinishedCallback<DocumentMetadata> mLoadChildrenCallback =
|
private final OnTaskFinishedCallback<DocumentMetadata> mLoadChildrenCallback =
|
||||||
new OnTaskFinishedCallback<DocumentMetadata>() {
|
new OnTaskFinishedCallback<DocumentMetadata>() {
|
||||||
@Override
|
@Override
|
||||||
public void onTaskFinished(@Status int status, DocumentMetadata metadata,
|
public void onTaskFinished(@Status int status, DocumentMetadata metadata,
|
||||||
Exception exception) {
|
Exception exception) {
|
||||||
// Notify remote side that we get the list even though we don't have the stat yet.
|
// Notify remote side that we get the list even though we don't have the stat yet.
|
||||||
// If it failed we still should notify the remote side that the loading failed.
|
// If it failed we still should notify the remote side that the loading failed.
|
||||||
getContext().getContentResolver().notifyChange(
|
getContext().getContentResolver().notifyChange(
|
||||||
toNotifyUri(metadata.getUri()), null, false);
|
toNotifyUri(metadata.getUri()), null, false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private final OnTaskFinishedCallback<String> mWriteFinishedCallback =
|
private final OnTaskFinishedCallback<String> mWriteFinishedCallback =
|
||||||
new OnTaskFinishedCallback<String>() {
|
new OnTaskFinishedCallback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onTaskFinished(
|
public void onTaskFinished(
|
||||||
@Status int status, @Nullable String item, Exception exception) {
|
@Status int status, @Nullable String item, Exception exception) {
|
||||||
final Uri uri = toUri(item);
|
final Uri uri = toUri(item);
|
||||||
try (final CacheResult result = mCache.get(uri)) {
|
try (final CacheResult result = mCache.get(uri)) {
|
||||||
if (result.getState() != CacheResult.CACHE_MISS) {
|
if (result.getState() != CacheResult.CACHE_MISS) {
|
||||||
result.getItem().reset();
|
result.getItem().reset();
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final Uri parentUri = DocumentMetadata.buildParentUri(uri);
|
|
||||||
getContext().getContentResolver().notifyChange(toNotifyUri(parentUri), null, false);
|
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
final Uri parentUri = DocumentMetadata.buildParentUri(uri);
|
||||||
|
getContext().getContentResolver().notifyChange(toNotifyUri(parentUri), null, false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private final OnTaskFinishedCallback<List<String>> mLoadSharesFinishedCallback =
|
private final OnTaskFinishedCallback<List<String>> mLoadSharesFinishedCallback =
|
||||||
new OnTaskFinishedCallback<List<String>>() {
|
new OnTaskFinishedCallback<List<String>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onTaskFinished(
|
public void onTaskFinished(
|
||||||
@OnTaskFinishedCallback.Status int status,
|
@OnTaskFinishedCallback.Status int status,
|
||||||
@Nullable List<String> item,
|
@Nullable List<String> item,
|
||||||
@Nullable Exception exception) {
|
@Nullable Exception exception) {
|
||||||
if (BuildConfig.DEBUG) Log.d(TAG, "Browsing callback");
|
if (BuildConfig.DEBUG) Log.d(TAG, "Browsing callback");
|
||||||
|
|
||||||
mBrowsingStorage = item;
|
mBrowsingStorage = item;
|
||||||
|
|
||||||
getContext().getContentResolver().notifyChange(
|
getContext().getContentResolver().notifyChange(
|
||||||
toNotifyUri(toUri(NetworkBrowser.SMB_BROWSING_URI.toString())), null, false);
|
toNotifyUri(toUri(NetworkBrowser.SMB_BROWSING_URI.toString())), null, false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private final MountedShareChangeListener mShareChangeListener = new MountedShareChangeListener() {
|
private final MountedShareChangeListener mShareChangeListener = new MountedShareChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -189,11 +189,11 @@ public class SambaDocumentsProvider extends DocumentsProvider {
|
||||||
MatrixCursor cursor = new MatrixCursor(projection, mShareManager.size());
|
MatrixCursor cursor = new MatrixCursor(projection, mShareManager.size());
|
||||||
|
|
||||||
cursor.addRow(new Object[] {
|
cursor.addRow(new Object[] {
|
||||||
NetworkBrowser.SMB_BROWSING_URI.toString(),
|
NetworkBrowser.SMB_BROWSING_URI.toString(),
|
||||||
NetworkBrowser.SMB_BROWSING_URI.toString(),
|
NetworkBrowser.SMB_BROWSING_URI.toString(),
|
||||||
getContext().getResources().getString(R.string.browsing_root_name),
|
getContext().getResources().getString(R.string.browsing_root_name),
|
||||||
0,
|
0,
|
||||||
R.drawable.ic_cloud,
|
R.drawable.ic_cloud,
|
||||||
});
|
});
|
||||||
|
|
||||||
for (String uri : mShareManager) {
|
for (String uri : mShareManager) {
|
||||||
|
@ -211,11 +211,11 @@ public class SambaDocumentsProvider extends DocumentsProvider {
|
||||||
name = metadata.getDisplayName();
|
name = metadata.getDisplayName();
|
||||||
|
|
||||||
cursor.addRow(new Object[] {
|
cursor.addRow(new Object[] {
|
||||||
toRootId(metadata),
|
toRootId(metadata),
|
||||||
toDocumentId(parsedUri),
|
toDocumentId(parsedUri),
|
||||||
name,
|
name,
|
||||||
Root.FLAG_SUPPORTS_CREATE | Root.FLAG_SUPPORTS_IS_CHILD,
|
Root.FLAG_SUPPORTS_CREATE | Root.FLAG_SUPPORTS_IS_CHILD,
|
||||||
R.drawable.ic_folder_shared
|
R.drawable.ic_folder_shared
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,7 +273,7 @@ public class SambaDocumentsProvider extends DocumentsProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Cursor queryChildDocuments(String documentId, String[] projection, String sortOrder)
|
public Cursor queryChildDocuments(String documentId, String[] projection, String sortOrder)
|
||||||
throws FileNotFoundException {
|
throws FileNotFoundException {
|
||||||
if (BuildConfig.DEBUG) Log.d(TAG, "Querying children documents under " + documentId);
|
if (BuildConfig.DEBUG) Log.d(TAG, "Querying children documents under " + documentId);
|
||||||
projection = (projection == null) ? DEFAULT_DOCUMENT_PROJECTION : projection;
|
projection = (projection == null) ? DEFAULT_DOCUMENT_PROJECTION : projection;
|
||||||
|
|
||||||
|
@ -304,7 +304,7 @@ public class SambaDocumentsProvider extends DocumentsProvider {
|
||||||
mCache.throwLastExceptionIfAny(uri);
|
mCache.throwLastExceptionIfAny(uri);
|
||||||
|
|
||||||
final LoadDocumentTask task =
|
final LoadDocumentTask task =
|
||||||
new LoadDocumentTask(uri, mClient, mCache, mLoadDocumentCallback);
|
new LoadDocumentTask(uri, mClient, mCache, mLoadDocumentCallback);
|
||||||
mTaskManager.runTask(uri, task);
|
mTaskManager.runTask(uri, task);
|
||||||
cursor.setLoadingTask(task);
|
cursor.setLoadingTask(task);
|
||||||
|
|
||||||
|
@ -321,7 +321,7 @@ public class SambaDocumentsProvider extends DocumentsProvider {
|
||||||
final Map<Uri, DocumentMetadata> childrenMap = metadata.getChildren();
|
final Map<Uri, DocumentMetadata> childrenMap = metadata.getChildren();
|
||||||
if (childrenMap == null || result.getState() == CacheResult.CACHE_EXPIRED) {
|
if (childrenMap == null || result.getState() == CacheResult.CACHE_EXPIRED) {
|
||||||
final LoadChildrenTask task =
|
final LoadChildrenTask task =
|
||||||
new LoadChildrenTask(metadata, mClient, mCache, mLoadChildrenCallback);
|
new LoadChildrenTask(metadata, mClient, mCache, mLoadChildrenCallback);
|
||||||
mTaskManager.runTask(uri, task);
|
mTaskManager.runTask(uri, task);
|
||||||
cursor.setLoadingTask(task);
|
cursor.setLoadingTask(task);
|
||||||
|
|
||||||
|
@ -340,13 +340,13 @@ public class SambaDocumentsProvider extends DocumentsProvider {
|
||||||
}
|
}
|
||||||
if (!isLoading && !docMap.isEmpty()) {
|
if (!isLoading && !docMap.isEmpty()) {
|
||||||
LoadStatTask task = new LoadStatTask(docMap, mClient,
|
LoadStatTask task = new LoadStatTask(docMap, mClient,
|
||||||
new OnTaskFinishedCallback<Map<Uri, DocumentMetadata>>() {
|
new OnTaskFinishedCallback<Map<Uri, DocumentMetadata>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onTaskFinished(
|
public void onTaskFinished(
|
||||||
@Status int status, Map<Uri, DocumentMetadata> item, Exception exception) {
|
@Status int status, Map<Uri, DocumentMetadata> item, Exception exception) {
|
||||||
getContext().getContentResolver().notifyChange(notifyUri, null, false);
|
getContext().getContentResolver().notifyChange(notifyUri, null, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mTaskManager.runTask(uri, task);
|
mTaskManager.runTask(uri, task);
|
||||||
cursor.setLoadingTask(task);
|
cursor.setLoadingTask(task);
|
||||||
|
|
||||||
|
@ -381,7 +381,7 @@ public class SambaDocumentsProvider extends DocumentsProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object[] getDocumentValues(
|
private Object[] getDocumentValues(
|
||||||
String[] projection, DocumentMetadata metadata) {
|
String[] projection, DocumentMetadata metadata) {
|
||||||
Object[] row = new Object[projection.length];
|
Object[] row = new Object[projection.length];
|
||||||
for (int i = 0; i < projection.length; ++i) {
|
for (int i = 0; i < projection.length; ++i) {
|
||||||
switch (projection[i]) {
|
switch (projection[i]) {
|
||||||
|
@ -483,15 +483,15 @@ public class SambaDocumentsProvider extends DocumentsProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String createDocument(String parentDocumentId, String mimeType, String displayName)
|
public String createDocument(String parentDocumentId, String mimeType, String displayName)
|
||||||
throws FileNotFoundException {
|
throws FileNotFoundException {
|
||||||
try {
|
try {
|
||||||
final Uri parentUri = toUri(parentDocumentId);
|
final Uri parentUri = toUri(parentDocumentId);
|
||||||
|
|
||||||
boolean isDir = Document.MIME_TYPE_DIR.equals(mimeType);
|
boolean isDir = Document.MIME_TYPE_DIR.equals(mimeType);
|
||||||
final DirectoryEntry entry = new DirectoryEntry(
|
final DirectoryEntry entry = new DirectoryEntry(
|
||||||
isDir ? DirectoryEntry.DIR : DirectoryEntry.FILE,
|
isDir ? DirectoryEntry.DIR : DirectoryEntry.FILE,
|
||||||
"", // comment
|
"", // comment
|
||||||
displayName);
|
displayName);
|
||||||
final Uri uri = DocumentMetadata.buildChildUri(parentUri, entry);
|
final Uri uri = DocumentMetadata.buildChildUri(parentUri, entry);
|
||||||
|
|
||||||
if (isDir) {
|
if (isDir) {
|
||||||
|
@ -617,15 +617,15 @@ public class SambaDocumentsProvider extends DocumentsProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeDocument(String documentId, String parentDocumentId)
|
public void removeDocument(String documentId, String parentDocumentId)
|
||||||
throws FileNotFoundException {
|
throws FileNotFoundException {
|
||||||
// documentId is hierarchical. It can only have one parent.
|
// documentId is hierarchical. It can only have one parent.
|
||||||
deleteDocument(documentId);
|
deleteDocument(documentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String moveDocument(
|
public String moveDocument(
|
||||||
String sourceDocumentId, String sourceParentDocumentId, String targetParentDocumentId)
|
String sourceDocumentId, String sourceParentDocumentId, String targetParentDocumentId)
|
||||||
throws FileNotFoundException {
|
throws FileNotFoundException {
|
||||||
try {
|
try {
|
||||||
final Uri uri = toUri(sourceDocumentId);
|
final Uri uri = toUri(sourceDocumentId);
|
||||||
final Uri targetParentUri = toUri(targetParentDocumentId);
|
final Uri targetParentUri = toUri(targetParentDocumentId);
|
||||||
|
@ -637,19 +637,19 @@ public class SambaDocumentsProvider extends DocumentsProvider {
|
||||||
final List<String> pathSegmentsOfSource = uri.getPathSegments();
|
final List<String> pathSegmentsOfSource = uri.getPathSegments();
|
||||||
final List<String> pathSegmentsOfTargetParent = targetParentUri.getPathSegments();
|
final List<String> pathSegmentsOfTargetParent = targetParentUri.getPathSegments();
|
||||||
if (pathSegmentsOfSource.isEmpty() ||
|
if (pathSegmentsOfSource.isEmpty() ||
|
||||||
pathSegmentsOfTargetParent.isEmpty() ||
|
pathSegmentsOfTargetParent.isEmpty() ||
|
||||||
!Objects.equals(pathSegmentsOfSource.get(0), pathSegmentsOfTargetParent.get(0))) {
|
!Objects.equals(pathSegmentsOfSource.get(0), pathSegmentsOfTargetParent.get(0))) {
|
||||||
throw new UnsupportedOperationException("Instance move across shares are not supported.");
|
throw new UnsupportedOperationException("Instance move across shares are not supported.");
|
||||||
}
|
}
|
||||||
|
|
||||||
final Uri targetUri = DocumentMetadata
|
final Uri targetUri = DocumentMetadata
|
||||||
.buildChildUri(targetParentUri, uri.getLastPathSegment());
|
.buildChildUri(targetParentUri, uri.getLastPathSegment());
|
||||||
mClient.rename(uri.toString(), targetUri.toString());
|
mClient.rename(uri.toString(), targetUri.toString());
|
||||||
|
|
||||||
revokeDocumentPermission(sourceDocumentId);
|
revokeDocumentPermission(sourceDocumentId);
|
||||||
|
|
||||||
getContext().getContentResolver()
|
getContext().getContentResolver()
|
||||||
.notifyChange(toNotifyUri(DocumentMetadata.buildParentUri(uri)), null, false);
|
.notifyChange(toNotifyUri(DocumentMetadata.buildParentUri(uri)), null, false);
|
||||||
getContext().getContentResolver().notifyChange(toNotifyUri(targetParentUri), null, false);
|
getContext().getContentResolver().notifyChange(toNotifyUri(targetParentUri), null, false);
|
||||||
|
|
||||||
try (CacheResult result = mCache.get(uri)) {
|
try (CacheResult result = mCache.get(uri)) {
|
||||||
|
@ -672,7 +672,7 @@ public class SambaDocumentsProvider extends DocumentsProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ParcelFileDescriptor openDocument(String documentId, String mode,
|
public ParcelFileDescriptor openDocument(String documentId, String mode,
|
||||||
CancellationSignal cancellationSignal) throws FileNotFoundException {
|
CancellationSignal cancellationSignal) throws FileNotFoundException {
|
||||||
if (BuildConfig.DEBUG) Log.d(TAG, "Opening document " + documentId + " with mode " + mode);
|
if (BuildConfig.DEBUG) Log.d(TAG, "Opening document " + documentId + " with mode " + mode);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -680,7 +680,7 @@ public class SambaDocumentsProvider extends DocumentsProvider {
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
OnTaskFinishedCallback<String> callback =
|
OnTaskFinishedCallback<String> callback =
|
||||||
mode.contains("w") ? mWriteFinishedCallback : null;
|
mode.contains("w") ? mWriteFinishedCallback : null;
|
||||||
return mClient.openProxyFile(
|
return mClient.openProxyFile(
|
||||||
uri,
|
uri,
|
||||||
mode,
|
mode,
|
||||||
|
@ -709,13 +709,13 @@ public class SambaDocumentsProvider extends DocumentsProvider {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case "r": {
|
case "r": {
|
||||||
final ReadFileTask task = new ReadFileTask(
|
final ReadFileTask task = new ReadFileTask(
|
||||||
uri, mClient, pipe[1], mBufferPool);
|
uri, mClient, pipe[1], mBufferPool);
|
||||||
mTaskManager.runIoTask(task);
|
mTaskManager.runIoTask(task);
|
||||||
}
|
}
|
||||||
return pipe[0];
|
return pipe[0];
|
||||||
case "w": {
|
case "w": {
|
||||||
final WriteFileTask task =
|
final WriteFileTask task =
|
||||||
new WriteFileTask(uri, mClient, pipe[0], mBufferPool, mWriteFinishedCallback);
|
new WriteFileTask(uri, mClient, pipe[0], mBufferPool, mWriteFinishedCallback);
|
||||||
mTaskManager.runIoTask(task);
|
mTaskManager.runIoTask(task);
|
||||||
return pipe[1];
|
return pipe[1];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue