Skip to content

Commit

Permalink
feat(clipboard): use capacitor clipboard for maximum support
Browse files Browse the repository at this point in the history
  • Loading branch information
AmitMY committed Jan 31, 2024
1 parent 2c25bbb commit 9a6bf0c
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 6 deletions.
1 change: 1 addition & 0 deletions android/app/capacitor.build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dependencies {
implementation project(':capacitor-firebase-app-check')
implementation project(':capacitor-firebase-crashlytics')
implementation project(':capacitor-firebase-performance')
implementation project(':capacitor-clipboard')
implementation project(':capacitor-filesystem')
implementation project(':capacitor-keyboard')
implementation project(':capacitor-share')
Expand Down
4 changes: 4 additions & 0 deletions android/app/src/main/assets/capacitor.plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
"pkg": "@capacitor-firebase/performance",
"classpath": "io.capawesome.capacitorjs.plugins.firebase.performance.FirebasePerformancePlugin"
},
{
"pkg": "@capacitor/clipboard",
"classpath": "com.capacitorjs.plugins.clipboard.ClipboardPlugin"
},
{
"pkg": "@capacitor/filesystem",
"classpath": "com.capacitorjs.plugins.filesystem.FilesystemPlugin"
Expand Down
3 changes: 3 additions & 0 deletions android/capacitor.settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ project(':capacitor-firebase-crashlytics').projectDir = new File('../node_module
include ':capacitor-firebase-performance'
project(':capacitor-firebase-performance').projectDir = new File('../node_modules/@capacitor-firebase/performance/android')

include ':capacitor-clipboard'
project(':capacitor-clipboard').projectDir = new File('../node_modules/@capacitor/clipboard/android')

include ':capacitor-filesystem'
project(':capacitor-filesystem').projectDir = new File('../node_modules/@capacitor/filesystem/android')

Expand Down
1 change: 1 addition & 0 deletions ios/App/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def capacitor_pods
pod 'CapacitorFirebaseAppCheck', :path => '../../node_modules/@capacitor-firebase/app-check'
pod 'CapacitorFirebaseCrashlytics', :path => '../../node_modules/@capacitor-firebase/crashlytics'
pod 'CapacitorFirebasePerformance', :path => '../../node_modules/@capacitor-firebase/performance'
pod 'CapacitorClipboard', :path => '../../node_modules/@capacitor/clipboard'
pod 'CapacitorFilesystem', :path => '../../node_modules/@capacitor/filesystem'
pod 'CapacitorKeyboard', :path => '../../node_modules/@capacitor/keyboard'
pod 'CapacitorShare', :path => '../../node_modules/@capacitor/share'
Expand Down
8 changes: 7 additions & 1 deletion ios/App/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ PODS:
- CapacitorBlobWriter (0.0.1):
- Capacitor
- GCDWebServer (~> 3.0)
- CapacitorClipboard (5.0.7):
- Capacitor
- CapacitorCordova (5.6.0)
- CapacitorFilesystem (5.2.1):
- Capacitor
Expand Down Expand Up @@ -161,6 +163,7 @@ PODS:
DEPENDENCIES:
- "Capacitor (from `../../node_modules/@capacitor/ios`)"
- CapacitorBlobWriter (from `../../node_modules/capacitor-blob-writer`)
- "CapacitorClipboard (from `../../node_modules/@capacitor/clipboard`)"
- "CapacitorCordova (from `../../node_modules/@capacitor/ios`)"
- "CapacitorFilesystem (from `../../node_modules/@capacitor/filesystem`)"
- "CapacitorFirebaseAnalytics (from `../../node_modules/@capacitor-firebase/analytics`)"
Expand Down Expand Up @@ -199,6 +202,8 @@ EXTERNAL SOURCES:
:path: "../../node_modules/@capacitor/ios"
CapacitorBlobWriter:
:path: "../../node_modules/capacitor-blob-writer"
CapacitorClipboard:
:path: "../../node_modules/@capacitor/clipboard"
CapacitorCordova:
:path: "../../node_modules/@capacitor/ios"
CapacitorFilesystem:
Expand All @@ -223,6 +228,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
Capacitor: ebfc16cdb8116d04c101686b080342872da42d43
CapacitorBlobWriter: 110eeaf80611f19bf01a8a05ff3672149ed0baad
CapacitorClipboard: 45e5e25f2271f98712985d422776cdc5a779cca1
CapacitorCordova: 931b48fcdbc9bc985fc2f16cec9f77c794a27729
CapacitorFilesystem: 9f3e3c7fea2fff12f46dd5b07a2914f2103e4cfc
CapacitorFirebaseAnalytics: 7f6190fba37be5997caedaac402f76be2f740e39
Expand Down Expand Up @@ -252,6 +258,6 @@ SPEC CHECKSUMS:
PromisesObjC: 09985d6d70fbe7878040aa746d78236e6946d2ef
PromisesSwift: cf9eb58666a43bbe007302226e510b16c1e10959

PODFILE CHECKSUM: d76aee4438d97af52b49960cf18e0f19851aa1ab
PODFILE CHECKSUM: b55777bf5f1282c527720da8f3519d9855fea953

COCOAPODS: 1.15.0
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"@capacitor-firebase/crashlytics": "5.4.0",
"@capacitor-firebase/performance": "5.4.0",
"@capacitor/android": "5.6.0",
"@capacitor/clipboard": "5.0.7",
"@capacitor/core": "5.6.0",
"@capacitor/filesystem": "5.2.1",
"@capacitor/ios": "5.6.0",
Expand Down Expand Up @@ -150,6 +151,7 @@
"karma-spec-reporter": "0.0.36",
"lint-staged": "15.2.1",
"marked": "11.2.0",
"npm-license-crawler": "0.2.1",
"open": "10.0.3",
"pwa-asset-generator": "6.3.1",
"sitemap": "7.1.1",
Expand All @@ -158,7 +160,6 @@
"tsx": "4.7.0",
"typescript": "5.2.2",
"webpack-bundle-analyzer": "4.10.1",
"zod": "3.22.4",
"npm-license-crawler": "0.2.1"
"zod": "3.22.4"
}
}
4 changes: 3 additions & 1 deletion src/app/core/helpers/app-check/app-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ export class AppCheck {
static isInitialized = false;

static async getToken(): Promise<string> {
const {FirebaseAppCheck} = await import('@capacitor-firebase/app-check');
const {FirebaseAppCheck} = await import(
/* webpackChunkName: "@capacitor-firebase/app-check" */ '@capacitor-firebase/app-check'
);
if (!AppCheck.isInitialized) {
await FirebaseAppCheck.initialize({siteKey: environment.reCAPTCHAKey, debug: !environment.production});
}
Expand Down
5 changes: 3 additions & 2 deletions src/app/modules/translate/translate.state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,11 @@ export class TranslateState implements NgxsOnInit {
const {spokenLanguageText} = getState();

try {
await navigator.clipboard.writeText(spokenLanguageText);
const {Clipboard} = await import(/* webpackChunkName: "@capacitor/clipboard" */ '@capacitor/clipboard');
await Clipboard.write({string: spokenLanguageText});
} catch (e) {
console.error(e);
alert(`Copying on this device is not supported`);
alert(e.message);
}
}

Expand Down

0 comments on commit 9a6bf0c

Please sign in to comment.