Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'ocr', 'scanner' and 'backup' features to isAvailable #988

Merged
merged 4 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"cozy-clisk": "^0.22.3",
"cozy-device-helper": "^2.7.0",
"cozy-flags": "^2.11.0",
"cozy-intent": "^2.17.1",
"cozy-intent": "^2.18.0",
"cozy-logger": "^1.10.0",
"cozy-minilog": "3.3.0",
"date-fns": "2.29.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const makeMetadata = routeName => {
routeName,
statusBarHeight,
version,
backup_available: true
backup_available: true // deprecated
})
}

Expand Down
18 changes: 15 additions & 3 deletions src/libs/intents/localMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { getDeviceName } from 'react-native-device-info'

import CozyClient from 'cozy-client'
import { FlagshipUI, NativeMethodsRegister } from 'cozy-intent'
import Minilog from 'cozy-minilog'

import * as RootNavigation from '/libs/RootNavigation'
import {
Expand Down Expand Up @@ -55,6 +56,8 @@ import {
requestPermissions
} from '/app/domain/nativePermissions'

const log = Minilog('localMethods')

export const asyncLogout = async (client?: CozyClient): Promise<null> => {
if (!client) {
throw new Error('Logout should not be called with undefined client')
Expand All @@ -81,6 +84,12 @@ const backToHome = (): Promise<null> => {
const isAvailable = (featureName: string): Promise<boolean> => {
if (featureName === 'geolocationTracking') {
return Promise.resolve(true)
} else if (featureName === 'ocr') {
return Promise.resolve(isOcrAvailable())
} else if (featureName === 'backup') {
return Promise.resolve(true)
} else if (featureName === 'scanner') {
return Promise.resolve(isScannerAvailable())
}

return Promise.resolve(false)
Expand Down Expand Up @@ -180,7 +189,6 @@ interface CustomMethods {
setGeolocationTrackingId: typeof setGeolocationTrackingId
forceUploadGeolocationTrackingData: typeof forceUploadGeolocationTrackingData
getDeviceInfo: typeof getDeviceInfo
isAvailable: typeof isAvailable
}

const prepareBackupWithClient = (
Expand Down Expand Up @@ -251,9 +259,13 @@ export const localMethods = (
openAppOSSettings,
isNativePassInstalledOnDevice,
scanDocument,
isScannerAvailable: () => Promise.resolve(isScannerAvailable()),
isScannerAvailable: (): Promise<boolean> => {
log.debug(
"Please use intent.call('isAvailable', 'scanner') instead of intent.call('isScannerAvailable')"
)
return Promise.resolve(isScannerAvailable())
},
ocr: processOcr,
isOcrAvailable: () => Promise.resolve(isOcrAvailable()),
// For now setTheme is only used for the home theme
setTheme: setHomeThemeIntent,
prepareBackup: () => prepareBackupWithClient(client),
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6422,10 +6422,10 @@ cozy-flags@^2.11.0:
dependencies:
microee "^0.0.6"

cozy-intent@^2.17.1:
version "2.17.1"
resolved "https://registry.yarnpkg.com/cozy-intent/-/cozy-intent-2.17.1.tgz#dac7a9ee5bdef19c735bc2ebd0421f3214c18c5d"
integrity sha512-BpeDO/bML15BoV6snSdlt1Smj84oV638NUdhxCqcfYqpiUNkNKu9Ur8zQ+OfFJpYSkeijvJvYallvcV8ZPl3dw==
cozy-intent@^2.18.0:
version "2.18.0"
resolved "https://registry.yarnpkg.com/cozy-intent/-/cozy-intent-2.18.0.tgz#9a1f0f3017f45d7b7c86710e01326f9b08ae69d8"
integrity sha512-iTt26OGLY9YwolJnu9Ylct8NCap6lE8rxF7ftK0RYEr/i2/hQHcoMZ2gEHXabyoPqLE6NynsJ9xYlKbdFUb+VA==
dependencies:
post-me "0.4.5"

Expand Down
Loading