From 67d097662b09baa38f540d4ec6f33993cd46e03b Mon Sep 17 00:00:00 2001 From: sultanmyrza Date: Mon, 24 Jul 2023 18:07:51 +0800 Subject: [PATCH 1/6] fix(custom-camera): capture images on Android 13 --- .../custom-camera/custom-camera.page.html | 1 + .../home/custom-camera/custom-camera.page.ts | 32 +++++++++++++++-- .../pre-publish-mode.component.ts | 34 +++++++++++++++---- 3 files changed, 57 insertions(+), 10 deletions(-) diff --git a/src/app/features/home/custom-camera/custom-camera.page.html b/src/app/features/home/custom-camera/custom-camera.page.html index 301dc8ffe..8e439ce53 100644 --- a/src/app/features/home/custom-camera/custom-camera.page.html +++ b/src/app/features/home/custom-camera/custom-camera.page.html @@ -150,6 +150,7 @@ *ngIf="(mode$ | ngrxPush) === 'pre-publish'" [curCaptureFileSize]="curCaptureFileSize" [curCaptureFilePath]="curCaptureFilePath" + [curCaptureFileName]="curCaptureFileName" [curCaptureMimeType]="curCaptureMimeType" [curCaptureSrc]="curCaptureSrc" (confirm)="confirmCurrentCapture()" diff --git a/src/app/features/home/custom-camera/custom-camera.page.ts b/src/app/features/home/custom-camera/custom-camera.page.ts index 90bb66332..a64eee09e 100644 --- a/src/app/features/home/custom-camera/custom-camera.page.ts +++ b/src/app/features/home/custom-camera/custom-camera.page.ts @@ -79,6 +79,7 @@ export class CustomCameraPage implements OnInit, OnDestroy { curCaptureFileSize?: number; curCaptureFilePath?: string; + curCaptureFileName?: string; curCaptureMimeType?: 'image/jpeg' | 'video/mp4'; curCaptureType?: MediaType = 'image'; curCaptureSrc?: string; @@ -137,8 +138,32 @@ export class CustomCameraPage implements OnInit, OnDestroy { }); } - private handleCaptureSuccessResult(result: CaptureSuccessResult) { - this.prepareForPublishing(result, CameraSource.Camera); + private async handleCaptureSuccessResult(result: CaptureSuccessResult) { + const resultCopy = await this.copyResultIfNeeded(result); + this.prepareForPublishing(resultCopy, CameraSource.Camera); + } + + private async copyResultIfNeeded(result: CaptureSuccessResult) { + /** + * WORKAROUND: https://github.com/numbersprotocol/capture-lite/issues/2904 + * On Android 13 capacitor filesystem plugin need to pass directory parameter to be + * able to re-write media file (aka when we edit image and save it the same file). + * Therefore we copy image to cache so we can re-write it if user crop/filter the image. + * + */ + if (this.platform.is('android') && result.mimeType.startsWith('image/')) { + const originalFilePath = result.path; + const readFileResult = await Filesystem.readFile({ path: result.path }); + const writeFileResult = await Filesystem.writeFile({ + data: readFileResult.data, + path: `${result.name}`, + directory: Directory.Cache, + recursive: true, + }); + result.path = writeFileResult.uri; + await Filesystem.deleteFile({ path: originalFilePath }); + } + return result; } private handleCaptureErrorResult(result: CaptureErrorResult) { @@ -151,6 +176,7 @@ export class CustomCameraPage implements OnInit, OnDestroy { ) { this.curCaptureFileSize = result.size; this.curCaptureFilePath = result.path; + this.curCaptureFileName = result.name; this.curCaptureMimeType = result.mimeType; this.curCaptureType = result.mimeType === 'image/jpeg' ? 'image' : 'video'; this.curCaptureSrc = Capacitor.convertFileSrc(result.path); @@ -323,7 +349,7 @@ export class CustomCameraPage implements OnInit, OnDestroy { const readFileResult = await Filesystem.readFile({ path: file.path }); const writeFileresult = await Filesystem.writeFile({ data: readFileResult.data, - path: `${Date.now()}/${file.name}`, + path: `${file.name}`, directory: Directory.Cache, recursive: true, }); diff --git a/src/app/features/home/custom-camera/pre-publish-mode/pre-publish-mode.component.ts b/src/app/features/home/custom-camera/pre-publish-mode/pre-publish-mode.component.ts index f13419563..b79dc697f 100644 --- a/src/app/features/home/custom-camera/pre-publish-mode/pre-publish-mode.component.ts +++ b/src/app/features/home/custom-camera/pre-publish-mode/pre-publish-mode.component.ts @@ -7,8 +7,8 @@ import { Output, ViewChild, } from '@angular/core'; -import { FilesystemPlugin } from '@capacitor/filesystem'; -import { AlertController } from '@ionic/angular'; +import { Directory, FilesystemPlugin } from '@capacitor/filesystem'; +import { AlertController, Platform } from '@ionic/angular'; import { TranslocoService } from '@ngneat/transloco'; import { ColorMatrix, getEditorDefaults } from '@pqina/pintura'; import { @@ -62,6 +62,8 @@ export class PrePublishModeComponent { readonly curCaptureFilePath$ = new ReplaySubject(1); + readonly curCaptureFileName$ = new ReplaySubject(1); + readonly curCaptureMimeType$ = new ReplaySubject(1); readonly curCaptureSrc$ = new ReplaySubject(1); @@ -108,6 +110,11 @@ export class PrePublishModeComponent { if (value) this.curCaptureFilePath$.next(value); } + @Input() + set curCaptureFileName(value: string | undefined) { + if (value) this.curCaptureFileName$.next(value); + } + @Input() set curCaptureMimeType(value: CaptureMimeType | undefined) { if (value) this.curCaptureMimeType$.next(value); @@ -129,7 +136,8 @@ export class PrePublishModeComponent { private readonly filesystemPlugin: FilesystemPlugin, private readonly errorService: ErrorService, private readonly alertController: AlertController, - private readonly translocoService: TranslocoService + private readonly translocoService: TranslocoService, + private readonly platform: Platform ) {} handleEditorUpdate(imageState: any): void { @@ -150,12 +158,24 @@ export class PrePublishModeComponent { async handleEditorProcess(imageWriterResult: any): Promise { const base64 = await blobToBase64(imageWriterResult.dest as File); - combineLatest([this.curCaptureFilePath$, of(base64)]) + combineLatest([ + this.curCaptureFilePath$, + of(base64), + this.isImage$, + this.curCaptureFileName$, + ]) .pipe( first(), - switchMap(([path, data]) => - this.filesystemPlugin.writeFile({ path, data }) - ), + switchMap(([path, data, isImage, fileName]) => { + if (this.platform.is('android') && isImage) { + return this.filesystemPlugin.writeFile({ + path: fileName, + data: data, + directory: Directory.Cache, + }); + } + return this.filesystemPlugin.writeFile({ path, data }); + }), tap(() => this.isProcessingImage$.next(false)), tap(() => this.confirm.emit(true)), catchError((error: unknown) => { From 2dc4606f1a2f7ea1def6449f87d484edf27674ae Mon Sep 17 00:00:00 2001 From: sultanmyrza Date: Mon, 31 Jul 2023 13:49:34 +0800 Subject: [PATCH 2/6] chore(plugin): bump push notifications, to 5.0.6 --- ios/App/Podfile.lock | 8 ++++---- package-lock.json | 28 ++++++++++++++-------------- package.json | 4 ++-- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/ios/App/Podfile.lock b/ios/App/Podfile.lock index 7ced0465a..8c9d684f9 100644 --- a/ios/App/Podfile.lock +++ b/ios/App/Podfile.lock @@ -33,13 +33,13 @@ PODS: - Capacitor - CapacitorGeolocation (5.0.4): - Capacitor - - CapacitorLocalNotifications (5.0.4): + - CapacitorLocalNotifications (5.0.6): - Capacitor - CapacitorNativeSettings (4.0.3): - Capacitor - CapacitorNetwork (5.0.4): - Capacitor - - CapacitorPushNotifications (5.0.4): + - CapacitorPushNotifications (5.0.6): - Capacitor - CapacitorShare (5.0.4): - Capacitor @@ -231,10 +231,10 @@ SPEC CHECKSUMS: CapacitorDevice: eb4b5e3b42ac35d2527f20aad296b59e0785dc8d CapacitorFilesystem: e1bdfab09b95b181c844c16abcfda45ec8e8ed6b CapacitorGeolocation: 33015be1ef496585a60da9efa1c5642ff8624db3 - CapacitorLocalNotifications: 2c95d27ccf9cc28ecc59d69b54d29074c1740172 + CapacitorLocalNotifications: c2d8b14794064fd4814b1d6c4ddbac8029afa295 CapacitorNativeSettings: b6f40955945bc659f966a43fa54fc6be192d8f9b CapacitorNetwork: e2bd0bf1614aca34bb976f125a756a8a3df1c81a - CapacitorPushNotifications: 3704ac3dac68a9bfc669fb384cbc7beec9b1f100 + CapacitorPushNotifications: 7eb70469f1fcc3dec07126336d4896520e4991db CapacitorShare: 427bba238a1e3f116b2b349019aec6ea7f42cebd CapacitorSplashScreen: 93a389d4f7673c08214ae25bb6f21d867d5305c5 CapacitorStorage: 8ec2cf8fec179d829288b16c6fba6c3c43d2bdc9 diff --git a/package-lock.json b/package-lock.json index 46e3e0548..9f02cb177 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,9 +34,9 @@ "@capacitor/filesystem": "^5.0.4", "@capacitor/geolocation": "^5.0.4", "@capacitor/ios": "^5.0.5", - "@capacitor/local-notifications": "^5.0.4", + "@capacitor/local-notifications": "^5.0.6", "@capacitor/network": "^5.0.4", - "@capacitor/push-notifications": "^5.0.4", + "@capacitor/push-notifications": "^5.0.6", "@capacitor/share": "^5.0.4", "@capacitor/splash-screen": "^5.0.4", "@capacitor/storage": "^1.2.4", @@ -3426,9 +3426,9 @@ } }, "node_modules/@capacitor/local-notifications": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/@capacitor/local-notifications/-/local-notifications-5.0.4.tgz", - "integrity": "sha512-In+BNDun9lkJ/0nIl0KjbJrQjkopoF1lVC2oAdUYA0+xvorq7hq4SO2shljMkqdhzQcfy7uwjgDqToik1jtsRg==", + "version": "5.0.6", + "resolved": "https://registry.npmjs.org/@capacitor/local-notifications/-/local-notifications-5.0.6.tgz", + "integrity": "sha512-DB+ZBjv3Ri/0mtSzjMxLMHNGfg5m615ewDfQxp++mu7pYUM1RkxfSiigw73+PlZXDow1YNQJRlzTkwEKs6Pf+g==", "peerDependencies": { "@capacitor/core": "^5.0.0" } @@ -3442,9 +3442,9 @@ } }, "node_modules/@capacitor/push-notifications": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/@capacitor/push-notifications/-/push-notifications-5.0.4.tgz", - "integrity": "sha512-q/3iCmsvvOjgH7fhfSVGQC7e85bVAgwAuSFzWAg5Sg6hq/XZnxK/TyQJ3M2DVfIfyHUc1OBXsMgi8vCQ4UhPAg==", + "version": "5.0.6", + "resolved": "https://registry.npmjs.org/@capacitor/push-notifications/-/push-notifications-5.0.6.tgz", + "integrity": "sha512-o4/EcP13XduazhJkoVWEVrRD07YcqT9Uz0pQ48SItRNjtgDhcQW1vAEo6tSL6FVA5NkxNhJikk8TUeXobgOhEg==", "peerDependencies": { "@capacitor/core": "^5.0.0" } @@ -26396,9 +26396,9 @@ "requires": {} }, "@capacitor/local-notifications": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/@capacitor/local-notifications/-/local-notifications-5.0.4.tgz", - "integrity": "sha512-In+BNDun9lkJ/0nIl0KjbJrQjkopoF1lVC2oAdUYA0+xvorq7hq4SO2shljMkqdhzQcfy7uwjgDqToik1jtsRg==", + "version": "5.0.6", + "resolved": "https://registry.npmjs.org/@capacitor/local-notifications/-/local-notifications-5.0.6.tgz", + "integrity": "sha512-DB+ZBjv3Ri/0mtSzjMxLMHNGfg5m615ewDfQxp++mu7pYUM1RkxfSiigw73+PlZXDow1YNQJRlzTkwEKs6Pf+g==", "requires": {} }, "@capacitor/network": { @@ -26408,9 +26408,9 @@ "requires": {} }, "@capacitor/push-notifications": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/@capacitor/push-notifications/-/push-notifications-5.0.4.tgz", - "integrity": "sha512-q/3iCmsvvOjgH7fhfSVGQC7e85bVAgwAuSFzWAg5Sg6hq/XZnxK/TyQJ3M2DVfIfyHUc1OBXsMgi8vCQ4UhPAg==", + "version": "5.0.6", + "resolved": "https://registry.npmjs.org/@capacitor/push-notifications/-/push-notifications-5.0.6.tgz", + "integrity": "sha512-o4/EcP13XduazhJkoVWEVrRD07YcqT9Uz0pQ48SItRNjtgDhcQW1vAEo6tSL6FVA5NkxNhJikk8TUeXobgOhEg==", "requires": {} }, "@capacitor/share": { diff --git a/package.json b/package.json index 8d5cdd7ca..427be7ebe 100644 --- a/package.json +++ b/package.json @@ -45,9 +45,9 @@ "@capacitor/filesystem": "^5.0.4", "@capacitor/geolocation": "^5.0.4", "@capacitor/ios": "^5.0.5", - "@capacitor/local-notifications": "^5.0.4", + "@capacitor/local-notifications": "^5.0.6", "@capacitor/network": "^5.0.4", - "@capacitor/push-notifications": "^5.0.4", + "@capacitor/push-notifications": "^5.0.6", "@capacitor/share": "^5.0.4", "@capacitor/splash-screen": "^5.0.4", "@capacitor/storage": "^1.2.4", From c53bb54f8b347e3461b15223d3acdb841465aae5 Mon Sep 17 00:00:00 2001 From: sultanmyrza Date: Tue, 1 Aug 2023 13:23:41 +0800 Subject: [PATCH 3/6] chore: bump app version to 0.82.4 --- android/app/build.gradle | 4 ++-- ios/App/App.xcodeproj/project.pbxproj | 8 ++++---- package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 58d87ee78..38fe0ecac 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId "io.numbersprotocol.capturelite" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 823 - versionName "0.82.3" + versionCode 824 + versionName "0.82.4" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildFeatures { diff --git a/ios/App/App.xcodeproj/project.pbxproj b/ios/App/App.xcodeproj/project.pbxproj index 03d5e3889..20410941e 100644 --- a/ios/App/App.xcodeproj/project.pbxproj +++ b/ios/App/App.xcodeproj/project.pbxproj @@ -368,13 +368,13 @@ CODE_SIGN_ENTITLEMENTS = App/App.entitlements; CODE_SIGN_IDENTITY = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 823; + CURRENT_PROJECT_VERSION = 824; DEVELOPMENT_TEAM = G7NB5YCKAP; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = G7NB5YCKAP; INFOPLIST_FILE = App/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - MARKETING_VERSION = 0.82.3; + MARKETING_VERSION = 0.82.4; OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\""; PRODUCT_BUNDLE_IDENTIFIER = io.numbersprotocol.capturelite; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -395,13 +395,13 @@ CODE_SIGN_ENTITLEMENTS = App/App.entitlements; CODE_SIGN_IDENTITY = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 823; + CURRENT_PROJECT_VERSION = 824; DEVELOPMENT_TEAM = G7NB5YCKAP; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = G7NB5YCKAP; INFOPLIST_FILE = App/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - MARKETING_VERSION = 0.82.3; + MARKETING_VERSION = 0.82.4; PRODUCT_BUNDLE_IDENTIFIER = io.numbersprotocol.capturelite; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = NumbersAppDistributionV4; diff --git a/package-lock.json b/package-lock.json index 9f02cb177..94f5640cc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "capture-lite", - "version": "0.82.3", + "version": "0.82.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "capture-lite", - "version": "0.82.3", + "version": "0.82.4", "dependencies": { "packages": "^0.0.8", "@angular/animations": "^14.2.0", diff --git a/package.json b/package.json index 427be7ebe..2fe4f6ced 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "capture-lite", - "version": "0.82.3", + "version": "0.82.4", "author": "numbersprotocol", "homepage": "https://numbersprotocol.io/", "scripts": { From 64f0be47c4008ca7d38254294e2d15f650a68ed8 Mon Sep 17 00:00:00 2001 From: sultanmyrza Date: Tue, 1 Aug 2023 13:24:53 +0800 Subject: [PATCH 4/6] chore: update CHANGELOG.md for 0.82.4 --- CHANGELOG.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81cbca1a8..4fef9b3fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.82.4] - 2023-08-01 + +### Fixed + +1. Fix User can’t register asset when using capture camera (#2930) +1. Fix can't register new account on some android device (#2953) + ## [0.82.3] - 2023-07-28 ### Fixed @@ -21,8 +28,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -1. Fix can't register new account on some android device (#2928) -1. Fix User can’t register asset when using capture camera (#2930) 1. Fix Change capture tab VALIDATED to VERIFIED (#2939) 1. Fix 4k videos can not generate thumbnail on some android devices (Android only) (#2923). reverted (#2938) 1. Fix show correct error mesage for sign up duplicate username error (#2926) @@ -2159,8 +2164,9 @@ This is the first release! _Capture Lite_ is a cross-platform app adapted from [ - Web - see the demo [here](https://github.com/numbersprotocol/capture-lite#demo-app) - Android - the APK file `app-debug.apk` is attached to this release -[unreleased]: https://github.com/numbersprotocol/capture-lite/compare/0.82.3...HEAD -[0.82.3]: https://github.com/numbersprotocol/capture-lite/compare/0.82.2...0.23.3 +[unreleased]: https://github.com/numbersprotocol/capture-lite/compare/0.82.4...HEAD +[0.82.4]: https://github.com/numbersprotocol/capture-lite/compare/0.82.3...0.82.4 +[0.82.3]: https://github.com/numbersprotocol/capture-lite/compare/0.82.2...0.82.3 [0.82.2]: https://github.com/numbersprotocol/capture-lite/compare/0.81.2...0.82.2 [0.81.2]: https://github.com/numbersprotocol/capture-lite/compare/0.79.0...0.81.2 [0.79.0]: https://github.com/numbersprotocol/capture-lite/compare/0.78.0...0.79.0 From 91a457c87c7ede48d591fa3c809509cda726b987 Mon Sep 17 00:00:00 2001 From: sultanmyrza Date: Tue, 1 Aug 2023 14:33:53 +0800 Subject: [PATCH 5/6] feat(ci): Update GitHub Actions workflow This commit updates the GitHub Actions workflow in the `.github/workflows/test.yml` file. The changes include adjusting the trigger conditions for the workflow. Previously, the workflow ran on push events for branches `master`, `develop`, `feature-*`, `fix-*`, and `hotfix-*`. Now, the workflow will also trigger on pull requests. This modification ensures that the workflow runs when pull requests are created or updated, providing better coverage for continuous integration testing. --- .github/workflows/test.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 118737525..16199a750 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,8 +1,6 @@ name: test -on: - push: - branches: [master, develop, 'feature-*', 'fix-*', 'hotfix-*'] +on: [push, pull_request] jobs: lint: From 5aeeb3b35ecac7c591c97dd02e04c23f82fd5872 Mon Sep 17 00:00:00 2001 From: sultanmyrza Date: Tue, 1 Aug 2023 15:47:38 +0800 Subject: [PATCH 6/6] hotfix(media): Simplify removeCSSClass method This commit simplifies the `removeCSSClass` method in the `MediaComponent` by removing the commented code and consolidating the removal of the CSS class from the `body` and `ion-app` elements in a single conditional block. The method now checks for the existence of the `body` and `ion-app` elements before attempting to remove the CSS class, ensuring a more concise and efficient implementation. --- .../shared/media/component/media.component.ts | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/app/shared/media/component/media.component.ts b/src/app/shared/media/component/media.component.ts index 4d5ada0ab..027a5b05d 100644 --- a/src/app/shared/media/component/media.component.ts +++ b/src/app/shared/media/component/media.component.ts @@ -175,15 +175,15 @@ export class MediaComponent implements AfterViewInit, OnDestroy { * and the native player is no longer needed. */ private removeCSSClass() { - // Remove the CSS class from the body element - this.renderer.removeClass( - this.elementRef.nativeElement.ownerDocument.body, - this.globalCSSClass - ); - // Remove the CSS class from the ion-app element - this.renderer.removeClass( - this.elementRef.nativeElement.ownerDocument.querySelector('ion-app'), - this.globalCSSClass - ); + const bodyElement = this.elementRef.nativeElement.ownerDocument.body; + const ionAppElement = + this.elementRef.nativeElement.ownerDocument.querySelector('ion-app'); + + if (bodyElement && ionAppElement) { + // Remove the CSS class from the body element + this.renderer.removeClass(bodyElement, this.globalCSSClass); + // Remove the CSS class from the ion-app element + this.renderer.removeClass(ionAppElement, this.globalCSSClass); + } } }