[WIP] update the code to reflect the update in function signatures in DataUtils

This commit is contained in:
VishnuSanal
2024-08-25 21:13:40 +05:30
parent d8cb3996c9
commit 51c8bbee26
3 changed files with 49 additions and 22 deletions
@@ -91,11 +91,15 @@ import com.amaze.filemanager.utils.DataUtils;
import com.amaze.filemanager.utils.OTGUtil;
import com.amaze.filemanager.utils.OnFileFound;
import com.amaze.filemanager.utils.Utils;
import com.amaze.filemanager.utils.omh.CoroutineCallback;
import com.amaze.filemanager.utils.omh.OMHClientHelper;
import com.amaze.filemanager.utils.smb.SmbUtil;
import com.amaze.trashbin.TrashBin;
import com.amaze.trashbin.TrashBinFile;
import com.cloudrail.si.interfaces.CloudStorage;
import com.cloudrail.si.types.SpaceAllocation;
import com.openmobilehub.android.storage.core.model.OmhStorageEntity;
import com.openmobilehub.android.storage.core.model.OmhStorageMetadata;
import android.content.ContentResolver;
import android.content.Context;
@@ -414,11 +418,20 @@ public class HybridFile {
case GDRIVE:
s =
Single.fromCallable(
() ->
dataUtils
.getAccount(mode)
.getMetadata(CloudUtil.stripPath(mode, path))
.getSize())
() -> {
OmhStorageMetadata metadata =
(OmhStorageMetadata)
OMHClientHelper.getGoogleStorageClient(context)
.getFileMetadata(
dataUtils.getAccount(mode).getOmhStorageEntity().getId(),
CoroutineCallback.Companion.call((result, error) -> {}));
OmhStorageEntity entity = metadata.getEntity();
if (entity instanceof OmhStorageEntity.OmhFile)
return ((OmhStorageEntity.OmhFile) entity).getSize().longValue();
else return 0L;
})
.subscribeOn(Schedulers.io())
.blockingGet();
return s;
@@ -609,6 +622,7 @@ public class HybridFile {
*
* @deprecated use {@link #isDirectory(Context)} to handle content resolvers
*/
@Deprecated
public boolean isDirectory() {
boolean isDirectory;
switch (mode) {
@@ -686,11 +700,18 @@ public class HybridFile {
case GDRIVE:
case ONEDRIVE:
return Single.fromCallable(
() ->
dataUtils
.getAccount(mode)
.getMetadata(CloudUtil.stripPath(mode, path))
.getFolder())
() -> {
OmhStorageMetadata metadata =
(OmhStorageMetadata)
OMHClientHelper.getGoogleStorageClient(context)
.getFileMetadata(
dataUtils.getAccount(mode).getOmhStorageEntity().getId(),
CoroutineCallback.Companion.call((result, error) -> {}));
OmhStorageEntity entity = metadata.getEntity();
return entity instanceof OmhStorageEntity.OmhFolder;
})
.subscribeOn(Schedulers.io())
.blockingGet();
case TRASH_BIN:
@@ -703,6 +724,7 @@ public class HybridFile {
/**
* @deprecated use {@link #folderSize(Context)}
*/
@Deprecated
public long folderSize() {
long size = 0L;
@@ -783,7 +805,12 @@ public class HybridFile {
case ONEDRIVE:
size =
FileUtils.folderSizeCloud(
mode, dataUtils.getAccount(mode).getMetadata(CloudUtil.stripPath(mode, path)));
mode,
(OmhStorageMetadata)
OMHClientHelper.getGoogleStorageClient(context)
.getFileMetadata(
dataUtils.getAccount(mode).getOmhStorageEntity().getId(),
CoroutineCallback.Companion.call((resultValue, error) -> {})));
break;
case FTP:
default:
@@ -821,7 +848,9 @@ public class HybridFile {
case BOX:
case GDRIVE:
case ONEDRIVE:
SpaceAllocation spaceAllocation = dataUtils.getAccount(mode).getAllocation();
SpaceAllocation spaceAllocation =
((OmhStorageEntity.OmhFolder) dataUtils.getAccount(mode).getOmhStorageEntity())
.get.getAllocation();
size = spaceAllocation.getTotal() - spaceAllocation.getUsed();
break;
case SFTP:
@@ -66,6 +66,7 @@ import com.cloudrail.si.interfaces.CloudStorage;
import com.cloudrail.si.types.CloudMetaData;
import com.googlecode.concurrenttrees.radix.ConcurrentRadixTree;
import com.googlecode.concurrenttrees.radix.node.concrete.voidvalue.VoidValue;
import com.openmobilehub.android.storage.core.model.OmhStorageMetadata;
import android.Manifest;
import android.animation.Animator;
@@ -169,7 +170,7 @@ public class FileUtils {
}
}
public static long folderSizeCloud(OpenMode openMode, CloudMetaData sourceFileMeta) {
public static long folderSizeCloud(OpenMode openMode, OmhStorageMetadata sourceFileMeta) {
DataUtils dataUtils = DataUtils.getInstance();
long length = 0;
@@ -391,7 +391,6 @@ public class MainActivity extends PermissionsActivity
authClient = OMHClientHelper.getGoogleAuthClient(getApplication());
storageClient = OMHClientHelper.getGoogleStorageClient(MainActivity.this);
AsyncTask.execute(
new Runnable() {
@Override
@@ -405,15 +404,13 @@ public class MainActivity extends PermissionsActivity
for (OmhStorageEntity omhStorageEntity : rootFileList) {
OmhStorageMetadata fileMetadata = (OmhStorageMetadata) storageClient.getFileMetadata(
omhStorageEntity.getId(),
CoroutineCallback.Companion.call((result, error) -> {
}));
OmhStorageMetadata fileMetadata =
(OmhStorageMetadata)
storageClient.getFileMetadata(
omhStorageEntity.getId(),
CoroutineCallback.Companion.call((result, error) -> {}));
Log.e(
"vishnu",
"run: "
+ fileMetadata);
Log.e("vishnu", "run: " + fileMetadata);
}
}
});