Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Add Dropbox/Onedrive plugins
  • Loading branch information
TranceLove committed Sep 10, 2024
1 parent ba93d8f commit f39ba14
Show file tree
Hide file tree
Showing 30 changed files with 1,125 additions and 1,135 deletions.
13 changes: 9 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ android {
properties.load(project.rootProject.file('local.properties').newDataInputStream())

buildConfigField "String", "GOOGLE_CLIENT_ID", "\"${properties.getProperty('GOOGLE_CLIENT_ID')}\""
buildConfigField "String", "DROPBOX_APP_KEY", "\"${properties.getProperty('DROPBOX_APP_KEY')}\""
}

signingConfigs {
Expand Down Expand Up @@ -266,11 +267,15 @@ dependencies {
implementation libs.gson
implementation libs.amaze.trashBin

implementation("com.openmobilehub.android.auth:plugin-google-gms:2.0.0")
implementation("com.openmobilehub.android.auth:plugin-google-non-gms:2.0.0")
implementation("com.openmobilehub.android.auth:plugin-google-gms:2.0.4")
implementation("com.openmobilehub.android.auth:plugin-google-non-gms:2.0.4")
implementation("com.openmobilehub.android.auth:plugin-microsoft:2.0.4")
implementation("com.openmobilehub.android.auth:plugin-dropbox:2.0.4")

implementation("com.openmobilehub.android.storage:plugin-googledrive-gms:2.0.0-alpha")
implementation("com.openmobilehub.android.storage:plugin-googledrive-non-gms:2.0.0-alpha")
implementation("com.openmobilehub.android.storage:plugin-googledrive-gms:2.0.4-alpha")
implementation("com.openmobilehub.android.storage:plugin-googledrive-non-gms:2.0.4-alpha")
implementation("com.openmobilehub.android.storage:plugin-onedrive:2.0.4-alpha")
implementation("com.openmobilehub.android.storage:plugin-dropbox:2.0.4-alpha")
}

kotlin {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class HiddenAdapter(
val task = DeleteTask(context, false)
task.execute(filesToDelete)
}
DataUtils.getInstance().removeHiddenFile(hiddenFiles[position].path)
DataUtils.removeHiddenFile(hiddenFiles[position].path)
hiddenFiles.remove(hiddenFiles[position])
notifyItemRemoved(position)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public class DeleteTask
private CompressedExplorerFragment compressedExplorerFragment;

private boolean doDeletePermanently;
private final DataUtils dataUtils = DataUtils.getInstance();
private final DataUtils dataUtils = DataUtils.INSTANCE;

public DeleteTask(@NonNull Context applicationContext, @NonNull boolean doDeletePermanently) {
this.applicationContext = applicationContext.getApplicationContext();
Expand Down Expand Up @@ -174,14 +174,15 @@ private boolean doDeleteFile(@NonNull HybridFileParcelable file) throws Exceptio
case BOX:
case GDRIVE:
case ONEDRIVE:
CloudStorage cloudStorage = dataUtils.getAccount(file.getMode());
try {
cloudStorage.delete(CloudUtil.stripPath(file.getMode(), file.getPath()));
return true;
} catch (Exception e) {
LOG.warn("failed to delete cloud files", e);
return false;
}
return false;
// CloudStorage cloudStorage = dataUtils.getAccount(file.getMode());
// try {
// cloudStorage.delete(CloudUtil.stripPath(file.getMode(), file.getPath()));
// return true;
// } catch (Exception e) {
// LOG.warn("failed to delete cloud files", e);
// return false;
// }
default:
try {
/* SMB and SFTP (or any remote files that may support in the future) should not be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public class LoadFilesListTask
private WeakReference<Context> context;
private OpenMode openmode;
private boolean showHiddenFiles, showThumbs;
private DataUtils dataUtils = DataUtils.getInstance();
private DataUtils dataUtils = DataUtils.INSTANCE;
private OnAsyncTaskFinished<Pair<OpenMode, List<LayoutElementParcelable>>> listener;
private boolean forceReload;

Expand Down Expand Up @@ -761,16 +761,16 @@ private List<LayoutElementParcelable> listCloud(
if (cloudCache != null && !forceReload) {
list = cloudCache;
} else {
CloudStorage cloudStorage = dataUtils.getAccount(openmode);
// CloudStorage cloudStorage = dataUtils.getAccount(openmode);
list = new ArrayList<>();
listCloudInternal(
path,
cloudStorage,
openmode,
file -> {
LayoutElementParcelable elem = createListParcelables(file);
if (elem != null) list.add(elem);
});
// listCloudInternal(
// path,
// cloudStorage,
// openmode,
// file -> {
// LayoutElementParcelable elem = createListParcelables(file);
// if (elem != null) list.add(elem);
// });
mainActivityViewModel.putInCache(path, list);
}
return list;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,24 +133,24 @@ private MoveFilesReturn processFile(
case BOX:
case ONEDRIVE:
case GDRIVE:
DataUtils dataUtils = DataUtils.getInstance();

CloudStorage cloudStorage = dataUtils.getAccount(mode);
if (baseFile.getMode() == mode) {
// source and target both in same filesystem, use API method
try {
cloudStorage.move(
CloudUtil.stripPath(mode, baseFile.getPath()), CloudUtil.stripPath(mode, destPath));
} catch (RuntimeException e) {
LOG.warn("failed to move file in cloud filesystem", e);
return new MoveFilesReturn(false, false, destinationSize, totalBytes);
}
} else {
// not in same filesystem, execute service
return new MoveFilesReturn(false, false, destinationSize, totalBytes);
}
default:
return new MoveFilesReturn(false, false, destinationSize, totalBytes);
// DataUtils dataUtils = DataUtils.INSTANCE;
//
// CloudStorage cloudStorage = dataUtils.getAccount(mode);
// if (baseFile.getMode() == mode) {
// // source and target both in same filesystem, use API method
// try {
// cloudStorage.move(
// CloudUtil.stripPath(mode, baseFile.getPath()), CloudUtil.stripPath(mode, destPath));
// } catch (RuntimeException e) {
// LOG.warn("failed to move file in cloud filesystem", e);
// return new MoveFilesReturn(false, false, destinationSize, totalBytes);
// }
// } else {
// // not in same filesystem, execute service
// return new MoveFilesReturn(false, false, destinationSize, totalBytes);
// }
// default:
// return new MoveFilesReturn(false, false, destinationSize, totalBytes);
}

return null;
Expand Down
14 changes: 7 additions & 7 deletions app/src/main/java/com/amaze/filemanager/filesystem/FileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public static final void writeUriToStorage(
}

String finalFilePath = currentPath + "/" + filename;
DataUtils dataUtils = DataUtils.getInstance();
DataUtils dataUtils = DataUtils.INSTANCE;

HybridFile hFile = new HybridFile(OpenMode.UNKNOWN, currentPath);
hFile.generateMode(mainActivity);
Expand Down Expand Up @@ -199,12 +199,12 @@ public static final void writeUriToStorage(
case BOX:
case ONEDRIVE:
case GDRIVE:
OpenMode mode = hFile.getMode();

CloudStorage cloudStorage = dataUtils.getAccount(mode);
String path = CloudUtil.stripPath(mode, finalFilePath);
cloudStorage.upload(path, bufferedInputStream, documentFile.length(), true);
retval.add(path);
// OpenMode mode = hFile.getMode();
//
// CloudStorage cloudStorage = dataUtils.getAccount(mode);
// String path = CloudUtil.stripPath(mode, finalFilePath);
// cloudStorage.upload(path, bufferedInputStream, documentFile.length(), true);
// retval.add(path);
break;
case OTG:
DocumentFile documentTargetFile =
Expand Down
Loading

0 comments on commit f39ba14

Please sign in to comment.