Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
TranceLove committed Sep 22, 2024
1 parent ba93d8f commit 5221443
Show file tree
Hide file tree
Showing 111 changed files with 2,574 additions and 2,267 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 @@ -30,6 +30,7 @@

import androidx.annotation.NonNull;

@Deprecated(forRemoval = true)
public class CloudLoaderAsyncTask extends AsyncTask<Void, Void, Boolean> {

private final WeakReference<MainActivity> mainActivity;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.amaze.filemanager.asynchronous.asynctasks.cloud

import android.database.Cursor
import com.amaze.filemanager.database.CloudHandler
import com.amaze.filemanager.ui.activities.MainActivity
import java.util.concurrent.Callable

class CloudLoaderCallable(
mainActivity: MainActivity,
private val cloudHandler: CloudHandler,
private val data: Cursor?,
) : Callable<Boolean> {
override fun call(): Boolean {
return true
}
}
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 @@ -21,7 +21,6 @@
package com.amaze.filemanager.adapters.data;

import java.io.File;
import java.util.Calendar;

import com.amaze.filemanager.fileoperations.filesystem.OpenMode;
import com.amaze.filemanager.filesystem.HybridFileParcelable;
Expand All @@ -38,9 +37,7 @@

public class LayoutElementParcelable implements Parcelable, ComparableParcelable {

private static final String CURRENT_YEAR =
String.valueOf(Calendar.getInstance().get(Calendar.YEAR));

public final String cloudFileId;
public final boolean isBack;
public final int filetype;
public final IconDataParcelable iconData;
Expand All @@ -62,6 +59,7 @@ public LayoutElementParcelable(
this(
c,
true,
"",
new File("..").getName(),
"..",
"",
Expand All @@ -77,6 +75,7 @@ public LayoutElementParcelable(

public LayoutElementParcelable(
@NonNull Context c,
String cloudFileId,
String path,
String permissions,
String symlink,
Expand All @@ -89,6 +88,7 @@ public LayoutElementParcelable(
OpenMode openMode) {
this(
c,
cloudFileId,
new File(path).getName(),
path,
permissions,
Expand All @@ -104,6 +104,7 @@ public LayoutElementParcelable(

public LayoutElementParcelable(
@NonNull Context c,
String cloudFileId,
String title,
String path,
String permissions,
Expand All @@ -118,6 +119,7 @@ public LayoutElementParcelable(
this(
c,
false,
cloudFileId,
title,
path,
permissions,
Expand All @@ -134,6 +136,7 @@ public LayoutElementParcelable(
public LayoutElementParcelable(
@NonNull Context c,
boolean isBack,
String cloudFileId,
String title,
String path,
String permissions,
Expand Down Expand Up @@ -180,7 +183,7 @@ public LayoutElementParcelable(
} else {
this.iconData = new IconDataParcelable(IconDataParcelable.IMAGE_RES, fallbackIcon);
}

this.cloudFileId = cloudFileId;
this.title = title;
this.desc = path;
this.permissions = permissions.trim();
Expand Down Expand Up @@ -228,6 +231,7 @@ public String toString() {
public LayoutElementParcelable(Parcel im) {
filetype = im.readInt();
iconData = im.readParcelable(IconDataParcelable.class.getClassLoader());
cloudFileId = im.readString();
title = im.readString();
desc = im.readString();
permissions = im.readString();
Expand All @@ -253,6 +257,7 @@ public int describeContents() {
public void writeToParcel(Parcel p1, int p2) {
p1.writeInt(filetype);
p1.writeParcelable(iconData, 0);
p1.writeString(cloudFileId);
p1.writeString(title);
p1.writeString(desc);
p1.writeString(permissions);
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 @@ -36,7 +36,6 @@
import com.amaze.filemanager.filesystem.HybridFile;
import com.amaze.filemanager.filesystem.HybridFileParcelable;
import com.amaze.filemanager.filesystem.SafRootHolder;
import com.amaze.filemanager.filesystem.cloud.CloudUtil;
import com.amaze.filemanager.filesystem.files.CryptUtil;
import com.amaze.filemanager.filesystem.files.MediaConnectionUtils;
import com.amaze.filemanager.ui.activities.MainActivity;
Expand All @@ -45,7 +44,6 @@
import com.amaze.filemanager.ui.notifications.NotificationConstants;
import com.amaze.filemanager.utils.DataUtils;
import com.amaze.filemanager.utils.OTGUtil;
import com.cloudrail.si.interfaces.CloudStorage;

import android.app.NotificationManager;
import android.content.Context;
Expand All @@ -70,7 +68,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 +172,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 @@ -63,7 +63,6 @@
import com.amaze.filemanager.utils.Utils;
import com.amaze.trashbin.TrashBin;
import com.amaze.trashbin.TrashBinFile;
import com.cloudrail.si.interfaces.CloudStorage;

import android.content.ContentResolver;
import android.content.Context;
Expand Down Expand Up @@ -93,31 +92,55 @@ public class LoadFilesListTask

private static final Logger LOG = LoggerFactory.getLogger(LoadFilesListTask.class);

private String cloudFolderId;
private String path;
private WeakReference<MainFragment> mainFragmentReference;
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;

public LoadFilesListTask(
Context context,
String path,
MainFragment mainFragment,
OpenMode openmode,
@NonNull Context context,
@NonNull String path,
@NonNull MainFragment mainFragment,
@NonNull OpenMode openmode,
boolean showThumbs,
boolean showHiddenFiles,
boolean forceReload,
OnAsyncTaskFinished<Pair<OpenMode, List<LayoutElementParcelable>>> l) {
@NonNull OnAsyncTaskFinished<Pair<OpenMode, List<LayoutElementParcelable>>> listener) {
this(
context,
null,
path,
mainFragment,
openmode,
showThumbs,
showHiddenFiles,
forceReload,
listener);
}

public LoadFilesListTask(
@NonNull Context context,
@Nullable String cloudFolderId,
@NonNull String path,
@NonNull MainFragment mainFragment,
@NonNull OpenMode openmode,
boolean showThumbs,
boolean showHiddenFiles,
boolean forceReload,
OnAsyncTaskFinished<Pair<OpenMode, List<LayoutElementParcelable>>> listener) {
this.cloudFolderId = cloudFolderId == null ? "" : cloudFolderId;
this.path = path;
this.mainFragmentReference = new WeakReference<>(mainFragment);
this.openmode = openmode;
this.context = new WeakReference<>(context);
this.showThumbs = showThumbs;
this.showHiddenFiles = showHiddenFiles;
this.listener = l;
this.listener = listener;
this.forceReload = forceReload;
}

Expand Down Expand Up @@ -360,6 +383,7 @@ private void postListCustomPathProcess(
LayoutElementParcelable layoutElement =
new LayoutElementParcelable(
context,
baseFile.getCloudFileId(),
baseFile.getName(context),
baseFile.getPath(),
baseFile.getPermission(),
Expand Down Expand Up @@ -646,6 +670,7 @@ else if (cursor.getCount() > 0 && cursor.moveToFirst()) {
LayoutElementParcelable element =
new LayoutElementParcelable(
ctx,
"",
dir.getAbsolutePath(),
"",
"",
Expand Down Expand Up @@ -761,11 +786,9 @@ private List<LayoutElementParcelable> listCloud(
if (cloudCache != null && !forceReload) {
list = cloudCache;
} else {
CloudStorage cloudStorage = dataUtils.getAccount(openmode);
list = new ArrayList<>();
listCloudInternal(
path,
cloudStorage,
cloudFolderId,
openmode,
file -> {
LayoutElementParcelable elem = createListParcelables(file);
Expand Down Expand Up @@ -842,7 +865,7 @@ private void listDocumentFilesInternal(OnFileFound fileFound) {
}

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

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

CloudUtil.getCloudFiles(path, cloudStorage, openMode, fileFoundCallback);
CloudUtil.getCloudFilesAsync(context, cloudFolderId, openMode, fileFoundCallback);
}
}
Loading

0 comments on commit 5221443

Please sign in to comment.