Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
TranceLove committed Sep 21, 2024
1 parent ba93d8f commit 092ccb0
Show file tree
Hide file tree
Showing 39 changed files with 1,773 additions and 1,611 deletions.
8 changes: 5 additions & 3 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 All @@ -60,8 +61,8 @@ android {

release {
signingConfig signingConfigs.release

minifyEnabled true
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.cfg'
buildConfigField "String", "CRYPTO_IV", "\"LxbHiJhhUXcj\""
buildConfigField "String", "FTP_SERVER_KEYSTORE_PASSWORD", "\"vishal007\""
Expand Down Expand Up @@ -174,7 +175,7 @@ dependencies {
testImplementation libs.jsoup
testImplementation libs.room.migration
testImplementation libs.mockk
testImplementation libs.kotlin.coroutine.test
testImplementation libs.kotlin.coroutines.test
testImplementation libs.androidX.core.testing
kspTest libs.auto.service
testImplementation 'ch.qos.logback:logback-classic:1.4.14'
Expand Down Expand Up @@ -257,6 +258,7 @@ dependencies {
implementation project(':file_operations')
implementation project(':portscanner')

implementation libs.kotlin.coroutines.jdk8
implementation libs.kotlin.stdlib.jdk8
implementation libs.acra.core
implementation libs.slf4j.api
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 @@ -37,6 +37,7 @@
import com.amaze.filemanager.R;
import com.amaze.filemanager.crashreport.AcraReportSenderFactory;
import com.amaze.filemanager.crashreport.ErrorActivity;
import com.amaze.filemanager.database.CloudHandler;
import com.amaze.filemanager.database.ExplorerDatabase;
import com.amaze.filemanager.database.UtilitiesDatabase;
import com.amaze.filemanager.database.UtilsHandler;
Expand Down Expand Up @@ -75,18 +76,19 @@
reportSenderFactoryClasses = AcraReportSenderFactory.class)
public class AppConfig extends GlideApplication {

private Logger log = null;
private static final Logger log = LoggerFactory.getLogger(AppConfig.class);

private UtilitiesProvider utilsProvider;
private UtilsHandler utilsHandler;

private CloudHandler cloudHandler;

private WeakReference<Context> mainActivityContext;
private static ScreenUtils screenUtils;

private static AppConfig instance;

private UtilitiesDatabase utilitiesDatabase;

private ExplorerDatabase explorerDatabase;

private TrashBinConfig trashBinConfig;
Expand All @@ -111,13 +113,13 @@ public void onCreate() {

utilsProvider = new UtilitiesProvider(this);
utilsHandler = new UtilsHandler(this, utilitiesDatabase);
cloudHandler = new CloudHandler(this, explorerDatabase);

runInBackground(Config::registerSmbURLHandler);

// disabling file exposure method check for api n+
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
StrictMode.setVmPolicy(builder.build());
log = LoggerFactory.getLogger(AppConfig.class);
}

@Override
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 @@ -61,9 +61,11 @@
import com.amaze.filemanager.utils.OnAsyncTaskFinished;
import com.amaze.filemanager.utils.OnFileFound;
import com.amaze.filemanager.utils.Utils;
import com.amaze.filemanager.utils.omh.OmhCredentialsWrapper;
import com.amaze.trashbin.TrashBin;
import com.amaze.trashbin.TrashBinFile;
import com.cloudrail.si.interfaces.CloudStorage;
import com.openmobilehub.android.auth.core.OmhCredentials;

import android.content.ContentResolver;
import android.content.Context;
Expand Down Expand Up @@ -98,7 +100,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,11 +763,9 @@ private List<LayoutElementParcelable> listCloud(
if (cloudCache != null && !forceReload) {
list = cloudCache;
} else {
CloudStorage cloudStorage = dataUtils.getAccount(openmode);
list = new ArrayList<>();
listCloudInternal(
path,
cloudStorage,
openmode,
file -> {
LayoutElementParcelable elem = createListParcelables(file);
Expand Down Expand Up @@ -842,7 +842,7 @@ private void listDocumentFilesInternal(OnFileFound fileFound) {
}

private void listCloudInternal(
String path, CloudStorage cloudStorage, OpenMode openMode, OnFileFound fileFoundCallback)
String path, OpenMode openMode, OnFileFound fileFoundCallback)
throws CloudPluginException {
final Context context = this.context.get();

Expand All @@ -855,6 +855,6 @@ private void listCloudInternal(
throw new CloudPluginException();
}

CloudUtil.getCloudFiles(path, cloudStorage, openMode, fileFoundCallback);
CloudUtil.getCloudFilesAsync(context, path, openMode, fileFoundCallback);
}
}
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 092ccb0

Please sign in to comment.