Skip to content

Commit

Permalink
fix: android 8 downloads, bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
Dwynr committed Apr 18, 2023
1 parent 3584556 commit ee729c2
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 84 deletions.
8 changes: 4 additions & 4 deletions ios/Filen.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Filen/Filen.entitlements;
CURRENT_PROJECT_VERSION = 2056;
CURRENT_PROJECT_VERSION = 2057;
DEVELOPMENT_TEAM = 7YTW5D2K7P;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Filen/Info.plist;
Expand All @@ -657,7 +657,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.0.56;
MARKETING_VERSION = 2.0.57;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down Expand Up @@ -685,15 +685,15 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Filen/Filen.entitlements;
CURRENT_PROJECT_VERSION = 2056;
CURRENT_PROJECT_VERSION = 2057;
DEVELOPMENT_TEAM = 7YTW5D2K7P;
INFOPLIST_FILE = Filen/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.0.56;
MARKETING_VERSION = 2.0.57;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down
2 changes: 1 addition & 1 deletion ios/Filen.xcodeproj/xcshareddata/xcschemes/Filen.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Release"
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"clear-cache": "watchman watch-del-all && rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf $TMPDIR/metro-bundler-cache-*",
"dist-android-clean": "watchman watch-del-all && rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf $TMPDIR/metro-bundler-cache-* && cd ./android && ./gradlew bundleRelease && ./gradlew assembleRelease && cd ..",
"dist-android": "cd ./android && ./gradlew bundleRelease && ./gradlew assembleRelease && cd ..",
"dist-android-apk": "cd ./android && ./gradlew assembleRelease && cd ..",
"splash": "react-native generate-bootsplash bootsplash.png --background-color=#263179 --logo-width=100 --flavor=main --assets-path=src/assets",
"icons": "react-native-svg-app-icon",
"install-release-apk-op": "adb -s 6c7a7e7b install android/app/build/outputs/apk/release/app-release.apk",
Expand Down
32 changes: 32 additions & 0 deletions src/lib/helpers/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,38 @@ export const toExpoFsPathWithoutEncode = (path: string) => {
return path
}

export const toBlobUtilPath = (path: string) => {
if (path.indexOf("file://") !== -1) {
return encodeURI(path.split("file://").join(""))
}

return encodeURI(path)
}

export const toBlobUtilPathWithoutEncode = (path: string) => {
if (path.indexOf("file://") !== -1) {
return path.split("file://").join("")
}

return path
}

export const toBlobUtilPathDecode = (path: string) => {
try {
if (path.indexOf("file://") !== -1) {
return decodeURI(path.split("file://").join(""))
}

return decodeURI(path)
} catch {
if (path.indexOf("file://") !== -1) {
return path.split("file://").join("")
}

return path
}
}

export const getAssetId = (asset: MediaLibrary.Asset) => asset.id

export function msToMinutesAndSeconds(ms: number) {
Expand Down
5 changes: 0 additions & 5 deletions src/lib/services/cameraUpload/cameraUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,6 @@ export const runCameraUpload = async (maxQueue: number = 16): Promise<void> => {

const cameraUploadEnabled = storage.getBoolean("cameraUploadEnabled:" + userId)
const cameraUploadFolderUUID = storage.getString("cameraUploadFolderUUID:" + userId)
const now = Date.now()

if (!cameraUploadEnabled) {
runTimeout = Date.now() + (TIMEOUT - 1000)
Expand Down Expand Up @@ -990,10 +989,6 @@ export const runCameraUpload = async (maxQueue: number = 16): Promise<void> => {

for (let i = 0; i < deltas.length; i++) {
const delta = deltas[i]

if (typeof delta.item.asset == "undefined") continue
if (delta.item.asset.mediaType == "video" || delta.item.asset.mediaType == "unknown") continue

const assetId = getAssetId(delta.item.asset)

if (maxQueue > currentQueue && (typeof FAILED[assetId] !== "number" ? 0 : FAILED[assetId]) < MAX_FAILED) {
Expand Down
112 changes: 38 additions & 74 deletions src/lib/services/download/download.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ReactNativeBlobUtil from "react-native-blob-util"
import { Semaphore, getFileExt, randomIdUnsafe } from "../../helpers"
import { Semaphore, getFileExt, randomIdUnsafe, toBlobUtilPathDecode } from "../../helpers"
import { Platform, DeviceEventEmitter } from "react-native"
import { useStore } from "../../state"
import { i18n } from "../../../i18n"
Expand Down Expand Up @@ -293,85 +293,49 @@ export const queueFileDownload = async ({
})
} else {
if (Platform.OS == "android") {
if (Platform.constants.Version >= 29) {
ReactNativeBlobUtil.MediaCollection.copyToMediaStore(
{
name: file.name,
parentFolder: "",
mimeType: file.mime
},
"Download",
path
)
.then(() => {
fs.unlink(path)
.then(() => {
if (showNotification || useStore.getState().imagePreviewModalVisible) {
showToast({
message: i18n(
storage.getString("lang"),
"fileDownloaded",
true,
["__NAME__"],
[file.name]
)
})
}

callOptionalCallback(null, "")

console.log(file.name + " download done")
})
.catch(err => {
showToast({ message: err.toString() })

callOptionalCallback(err)

console.error(err)
})
})
.catch(err => {
showToast({ message: err.toString() })
ReactNativeBlobUtil.MediaCollection.copyToMediaStore(
{
name: file.name,
parentFolder: "",
mimeType: file.mime
},
"Download",
toBlobUtilPathDecode(path)
)
.then(() => {
fs.unlink(path)
.then(() => {
if (showNotification || useStore.getState().imagePreviewModalVisible) {
showToast({
message: i18n(
storage.getString("lang"),
"fileDownloaded",
true,
["__NAME__"],
[file.name]
)
})
}

callOptionalCallback(err)
callOptionalCallback(null, "")

console.error(err)
})
} else {
try {
if ((await fs.stat(filePath)).exists) {
await fs.unlink(filePath)
}
} catch (e) {
//console.log(e)
}

fs.move(path, filePath)
.then(() => {
if (showNotification || useStore.getState().imagePreviewModalVisible) {
showToast({
message: i18n(
storage.getString("lang"),
"fileDownloaded",
true,
["__NAME__"],
[file.name]
)
})
}
console.log(file.name + " download done")
})
.catch(err => {
showToast({ message: err.toString() })

callOptionalCallback(null, filePath)
callOptionalCallback(err)

console.log(file.name + " download done")
})
.catch(err => {
showToast({ message: err.toString() })
console.error(err)
})
})
.catch(err => {
showToast({ message: err.toString() })

callOptionalCallback(err)
callOptionalCallback(err)

console.error(err)
})
}
console.error(err)
})
} else {
try {
if ((await fs.stat(filePath)).exists) {
Expand Down

0 comments on commit ee729c2

Please sign in to comment.