diff --git a/.bundle/config b/.bundle/config new file mode 100644 index 0000000000..848943bb52 --- /dev/null +++ b/.bundle/config @@ -0,0 +1,2 @@ +BUNDLE_PATH: "vendor/bundle" +BUNDLE_FORCE_RUBY_PLATFORM: 1 diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000000..481f5d7a1b --- /dev/null +++ b/.eslintignore @@ -0,0 +1,10 @@ +example/ +dist/ +images/ +ios/ +android/ +assets/ +.vscode/ +.github/ +/.eslintrc.js +/metro.config.js diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000000..97110ef76c --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,61 @@ +module.exports = { + root: true, + extends: '@react-native', + plugins: ['import'], + rules: { + // disabled rules + 'prettier/prettier': 'off', + 'react-native/no-inline-styles': 'off', + 'no-fallthrough': 'off', + curly: 'off', + // error rules + semi: 'error', + 'key-spacing': [2, { beforeColon: false, afterColon: true }], + 'require-await': 'error', + indent: [ + 'error', + 2, + { + ignoredNodes: ['TemplateLiteral'], // https://github.com/babel/babel-eslint/issues/681#issuecomment-451336031 + SwitchCase: 1, + }, + ], + 'no-console': 'error', + 'no-debugger': 'error', + 'prefer-const': 'error', + 'no-multiple-empty-lines': 'error', + 'no-unused-vars': 'error', + 'no-trailing-spaces': 'error', + 'brace-style': ['error', '1tbs', { allowSingleLine: true }], + 'react/jsx-boolean-value': 'error', + 'react/jsx-closing-bracket-location': 'error', + 'react/jsx-max-props-per-line': ['error', { maximum: 1, when: 'multiline' }], + 'max-len': [ + 'error', + { + code: 120, + ignoreTemplateLiterals: true, + // FIXME: doesn't work :/ + ignorePattern: '^log\\(', // ignore "log('...')" + ignoreUrls: true, // ignore long urls + }, + ], + 'import/no-unresolved': ['error', { commonjs: true, amd: true }], + 'import/named': 'error', + 'import/namespace': 'error', + 'import/default': 'error', + 'import/export': 'error', + }, + settings: { + 'import/ignore': ['node_modules/react-native/index\\.js$'], // https://github.com/facebook/react-native/issues/28549 + 'import/resolver': { + node: { + extensions: ['.js', '.ts', '.tsx', '.android.js', '.ios.js', '.android.tsx', '.ios.tsx'], + }, + }, + }, + globals: { + WebSocket: true, + URLSearchParams: true, + }, +}; diff --git a/.flowconfig b/.flowconfig deleted file mode 100644 index 66b57e0969..0000000000 --- a/.flowconfig +++ /dev/null @@ -1,89 +0,0 @@ -[ignore] - -# We fork some components by platform. -.*/*.web.js -.*/*.android.js - -# Some modules have their own node_modules with overlap -.*/node_modules/node-haste/.* - -# Ugh -.*/node_modules/babel.* -.*/node_modules/babylon.* -.*/node_modules/invariant.* - -# Ignore react and fbjs where there are overlaps, but don't ignore -# anything that react-native relies on -.*/node_modules/fbjs/lib/Map.js -.*/node_modules/fbjs/lib/fetch.js -.*/node_modules/fbjs/lib/ExecutionEnvironment.js -.*/node_modules/fbjs/lib/ErrorUtils.js - -# Flow has a built-in definition for the 'react' module which we prefer to use -# over the currently-untyped source -.*/node_modules/react/react.js -.*/node_modules/react/lib/React.js -.*/node_modules/react/lib/ReactDOM.js - -.*/__mocks__/.* -.*/__tests__/.* - -.*/commoner/test/source/widget/share.js - -# Ignore commoner tests -.*/node_modules/commoner/test/.* - -# See https://github.com/facebook/flow/issues/442 -.*/react-tools/node_modules/commoner/lib/reader.js - -# Ignore jest -.*/node_modules/jest-cli/.* - -# Ignore Website -.*/website/.* - -.*/node_modules/is-my-json-valid/test/.*\.json -.*/node_modules/iconv-lite/encodings/tables/.*\.json -.*/node_modules/y18n/test/.*\.json -.*/node_modules/spdx-license-ids/spdx-license-ids.json -.*/node_modules/spdx-exceptions/index.json -.*/node_modules/resolve/test/subdirs/node_modules/a/b/c/x.json -.*/node_modules/resolve/lib/core.json -.*/node_modules/jsonparse/samplejson/.*\.json -.*/node_modules/json5/test/.*\.json -.*/node_modules/ua-parser-js/test/.*\.json -.*/node_modules/builtin-modules/builtin-modules.json -.*/node_modules/binary-extensions/binary-extensions.json -.*/node_modules/url-regex/tlds.json -.*/node_modules/joi/.*\.json -.*/node_modules/isemail/.*\.json -.*/node_modules/tr46/.*\.json - -[include] - -[libs] -node_modules/react-native/Libraries/react-native/react-native-interface.js -node_modules/react-native/flow -flow/ - -[options] -module.system=haste - -esproposal.class_static_fields=enable -esproposal.class_instance_fields=enable - -munge_underscores=true - -module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub' -module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\)$' -> 'RelativeImageStub' - -suppress_type=$FlowIssue -suppress_type=$FlowFixMe -suppress_type=$FixMe - -suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-2]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) -suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-2]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ -suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy - -[version] -0.22.0 diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000000..60bf4dd094 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,37 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Add prop `someProp="someValue"` +2. call `cameraRef.current.capture()` +3. See error in console + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If the issue is a visual glitch or UI issue please provide screen shots. + +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + - Browser [e.g. chrome, safari] + - Version [e.g. 22] + +**Smartphone (please complete the following information):** + - Device: [e.g. iPhone6] + - OS: [e.g. iOS8.1] + - Browser [e.g. stock browser, safari] + - Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000000..bbcbbe7d61 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000000..7a37d25945 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,15 @@ +## Summary + + + +## How did you test this change? + + diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000000..782ca28975 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,41 @@ +name: Build +run-name: βοΈ Build examples on ${{ github.event_name == 'pull_request' && 'PR' || 'π±' }} ${{ github.event_name == 'pull_request' && github.event.number || github.ref_name }} + +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] + +jobs: + build-example-ios: + name: build-example-ios + runs-on: macos-latest + steps: + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '2.7.4' + - name: Checkout + uses: actions/checkout@v3 + - name: Install modules + run: yarn + - name: Install example + run: yarn bootstrap + - name: Build + run: cd example/ios && xcodebuild -workspace CameraKitExample.xcworkspace -configuration Debug -scheme CameraKitExample -sdk iphoneos build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO + build-example-android: + name: build-example-android + runs-on: ubuntu-latest # using linux runner for speed + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Validate Gradle Wrapper + uses: gradle/wrapper-validation-action@v1 + - name: Install modules + run: yarn + - name: Install example + run: yarn bootstrap-linux + - name: Build + run: cd example/android && ./gradlew assembleDebug diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml new file mode 100644 index 0000000000..5fd53a991c --- /dev/null +++ b/.github/workflows/linter.yml @@ -0,0 +1,49 @@ +name: Linter +run-name: π©Ί Code checks on ${{ github.event_name == 'pull_request' && 'PR' || 'π±' }} ${{ github.event_name == 'pull_request' && github.event.number || github.ref_name }} + +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] + +jobs: + eslint: + name: ESLint + runs-on: ubuntu-latest # using linux runner for speed + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Install modules + run: yarn + - name: Install example + run: yarn bootstrap-linux + - name: Lint + run: yarn lint + + ios: + name: Lint iOS + runs-on: macos-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Install dependencies + run: brew bundle + - name: Run swiftlint + run: | + if [[ "${{ github.event_name }}" == "pull_request" ]]; then + updatedFiles=$(git --no-pager diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} -- '*.swift') + + if [[ -z "$updatedFiles" ]]; then + echo "No Swift files changed, skipping linting" + exit 0 + fi + + swiftlint --reporter github-actions-logging -- $updatedFiles + else + swiftlint + fi diff --git a/.gitignore b/.gitignore index 81af72ff62..89ef71aa9d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,176 +1,3 @@ - -############ -# Node -############ -# Logs -logs -*.log -npm-debug.log* -package-lock.json - -# Runtime data -pids -*.pid -*.seed - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (http://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules -jspm_packages - -# Optional npm cache directory -.npm - -# Optional REPL history -.node_repl_history - -################ -# JetBrains -################ -.idea - -## File-based project format: -*.iws - -## Plugin-specific files: - -# IntelliJ -/out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties - - -############ -# iOS -############ -# Xcode -# -# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore - -## Build generated -ios/build/ -ios/DerivedData/ - -## Various settings -*.pbxuser -!default.pbxuser -*.mode1v3 -!default.mode1v3 -*.mode2v3 -!default.mode2v3 -*.perspectivev3 -!default.perspectivev3 -ios/xcuserdata/ - -## Other -*.moved-aside -*.xcuserstate - -## Obj-C/Swift specific -*.hmap -*.ipa -*.dSYM.zip -*.dSYM - -# CocoaPods -# -# We recommend against adding the Pods directory to your .gitignore. However -# you should judge for yourself, the pros and cons are mentioned at: -# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control -# -ios/Pods/ - -# Carthage -# -# Add this line if you want to avoid checking in source code from Carthage dependencies. -# Carthage/Checkouts - -Carthage/Build - -# fastlane -# -# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the -# screenshots whenever they are needed. -# For more information about the recommended setup visit: -# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md - -fastlane/report.xml -fastlane/screenshots - - -############ -# Android -############ -# Built application files -*.apk -*.ap_ - -# Files for the Dalvik VM -*.dex - -# Java class files -*.class - -# Generated files -android/bin/ -android/gen/ -android/out/ - -# Gradle files -android/.gradle/ -android/build/ - -# Local configuration file (sdk path, etc) -local.properties - -# Proguard folder generated by Eclipse -android/proguard/ - -# Log Files -*.log - -# Android Studio Navigation editor temp files -android/.navigation/ - -# Android Studio captures folder -android/captures/ - -# Intellij -*.iml - -# Keystore files -*.jks - -################## -# React-Native -################## # OSX # .DS_Store @@ -193,21 +20,72 @@ DerivedData *.hmap *.ipa *.xcuserstate -project.xcworkspace +**/.xcode.env.local -# Android/IJ +# Android/IntelliJ # +build/ .idea .gradle local.properties +*.iml +*.hprof +.cxx/ +*.keystore +!debug.keystore # node.js # node_modules/ npm-debug.log +yarn-error.log + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/ + +**/fastlane/report.xml +**/fastlane/Preview.html +**/fastlane/screenshots +**/fastlane/test_output + +# Bundle artifact +*.jsbundle + +# Ruby / CocoaPods +**/Pods/ +/vendor/bundle/ + +# Temporary files created by Metro to check the health of the file watcher +.metro-health-check* + +# testing +/coverage -# BUCK -buck-out/ -\.buckd/ -android/app/libs -android/keystores/debug.keystore +# Yarn +.yarn/* +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/sdks +!.yarn/versions + +# Project specific + +example/.yarn/* +!example/.yarn/patches +!example/.yarn/plugins +!example/.yarn/releases +!example/.yarn/sdks +!example/.yarn/versions + +ios/build/ +ios/DerivedData/ +dist/ +### Xcode ### +*.xcodeproj/* +!*.xcodeproj/project.pbxproj +!*.xcworkspace/contents.xcworkspacedata diff --git a/.npmignore b/.npmignore index 7725d8967d..94d5d567b7 100644 --- a/.npmignore +++ b/.npmignore @@ -7,3 +7,5 @@ example-android/ android/build/ img/ ios/lib/DerivedData/ +images/ +docs/ diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 0000000000..a4abc02e25 --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,13 @@ +module.exports = { + arrowParens: 'always', + bracketSameLine: true, + tabs: false, + tabWidth: 2, + bracketSpacing: true, + singleQuote: true, + trailingComma: 'all', + printWidth: 120, + semi: true, + jsxBracketSameLine: false, + jsxSingleQuote: false, +}; diff --git a/.swiftlint.yml b/.swiftlint.yml new file mode 100644 index 0000000000..4eaa1b3001 --- /dev/null +++ b/.swiftlint.yml @@ -0,0 +1,21 @@ +included: + - ios + - example/ios + +excluded: + - ios/Pods + - example/ios/Pods + +disabled_rules: + - todo + +line_length: 160 +type_body_length: 400 +function_body_length: 50 + +identifier_name: + excluded: + - on + - x + - y + - at diff --git a/Brewfile b/Brewfile new file mode 100644 index 0000000000..4d9396ec1b --- /dev/null +++ b/Brewfile @@ -0,0 +1,2 @@ +brew 'swiftlint' + diff --git a/Brewfile.lock.json b/Brewfile.lock.json new file mode 100644 index 0000000000..5943b20df8 --- /dev/null +++ b/Brewfile.lock.json @@ -0,0 +1,62 @@ +{ + "entries": { + "brew": { + "swiftlint": { + "version": "0.53.0", + "bottle": { + "rebuild": 0, + "root_url": "https://ghcr.io/v2/homebrew/core", + "files": { + "arm64_sonoma": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/swiftlint/blobs/sha256:240ccda9de55d948d0c635798079074099bfcb73ffda41428900fdc748aeea7b", + "sha256": "240ccda9de55d948d0c635798079074099bfcb73ffda41428900fdc748aeea7b" + }, + "arm64_ventura": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/swiftlint/blobs/sha256:7b7ceb7896c6833965cc4eac9001255d8adde6c5432045d5a8ab6aea8a9e81d9", + "sha256": "7b7ceb7896c6833965cc4eac9001255d8adde6c5432045d5a8ab6aea8a9e81d9" + }, + "arm64_monterey": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/swiftlint/blobs/sha256:78c2a4c3f4a2f6847b484527b0f0f916da71e3ee29e49890fd44b63fe7b38e26", + "sha256": "78c2a4c3f4a2f6847b484527b0f0f916da71e3ee29e49890fd44b63fe7b38e26" + }, + "sonoma": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/swiftlint/blobs/sha256:abdca78dd8a8bd268053b3be195fe891bb74aef5502ab3a6b871ae0c6bb04540", + "sha256": "abdca78dd8a8bd268053b3be195fe891bb74aef5502ab3a6b871ae0c6bb04540" + }, + "ventura": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/swiftlint/blobs/sha256:be711c707bf3b49fa0dd6e2ae576b309aad620f9b56a2c6e7b1ac5cf35cf652a", + "sha256": "be711c707bf3b49fa0dd6e2ae576b309aad620f9b56a2c6e7b1ac5cf35cf652a" + }, + "monterey": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/swiftlint/blobs/sha256:13487d68a971dbe035019364e19d70641af2a18c06e52925d238685b384a7979", + "sha256": "13487d68a971dbe035019364e19d70641af2a18c06e52925d238685b384a7979" + }, + "x86_64_linux": { + "cellar": "/home/linuxbrew/.linuxbrew/Cellar", + "url": "https://ghcr.io/v2/homebrew/core/swiftlint/blobs/sha256:fbbc56fccfcfcd34564feb7325567e2ff3638d3c609396a5c4aa13311c7b26e0", + "sha256": "fbbc56fccfcfcd34564feb7325567e2ff3638d3c609396a5c4aa13311c7b26e0" + } + } + } + } + } + }, + "system": { + "macos": { + "sonoma": { + "HOMEBREW_VERSION": "4.2.0-54-g0b804d4", + "HOMEBREW_PREFIX": "/opt/homebrew", + "Homebrew/homebrew-core": "api", + "CLT": "15.1.0.0.1.1700200546", + "Xcode": "15.0", + "macOS": "14.1" + } + } + } +} diff --git a/LICENSE b/LICENSE index 85e970c11c..d13cc4b26a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,5 @@ The MIT License (MIT) -Copyright (c) 2014 Wix.com - Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights diff --git a/README.md b/README.md index 045668f65a..2185f27c82 100644 --- a/README.md +++ b/README.md @@ -1,105 +1,253 @@ +
+ A high performance, easy to use, rock solid
+ camera library for React Native apps.
+
+ + | +
+
|
+
Note: It is not mandatory to invoke all config set-ups via the handler, but we do so anyway so as to avoid - * races between multiple threads.
- */ - private Handler adapterConfigHandler; - - @Override - public String getName() { - return "GalleryView"; - } - - @Override - protected GalleryView createViewInstance(ThemedReactContext reactContext) { - final HandlerThread handlerThread = new HandlerThread("GalleryViewManager.configThread"); - handlerThread.start(); - adapterConfigHandler = new Handler(handlerThread.getLooper()); - - GalleryView view = new GalleryView(reactContext); - view.setAdapter(new GalleryAdapter(reactContext, view)); - return view; - } - - @Override - protected void onAfterUpdateTransaction(final GalleryView view) { - dispatchRefreshDataOnJobQueue(view, false); - super.onAfterUpdateTransaction(view); - } - - @ReactProp(name = "minimumInteritemSpacing") - public void setItemSpacing(GalleryView view, int itemSpacing) { - view.setItemSpacing(itemSpacing/2); - } - - @ReactProp(name = "minimumLineSpacing") - public void setLineSpacing(GalleryView view, int lineSpacing) { - view.setLineSpacing(lineSpacing/2); - } - - @ReactProp(name = "albumName") - public void setAlbumName(final GalleryView view, final String albumName) { - dispatchOnConfigJobQueue(new Runnable() { - @Override - public void run() { - getViewAdapter(view).setAlbum(albumName); - } - }); - } - - @ReactProp(name = "columnCount") - public void setColumnCount(GalleryView view, int columnCount) { - view.setColumnCount(columnCount); - } - - @ReactProp(name = "selectedImages") - public void setSelectedUris(final GalleryView view, final ReadableArray uris) { - dispatchOnConfigJobQueue(new Runnable() { - @Override - public void run() { - getViewAdapter(view).setSelectedUris(readableArrayToList(uris)); - } - }); - } - - @ReactProp(name = "dirtyImages") - public void setDirtyImages(final GalleryView view, final ReadableArray uris) { - dispatchOnConfigJobQueue(new Runnable() { - @Override - public void run() { - getViewAdapter(view).setDirtyUris(readableArrayToList(uris)); - } - }); - } - - @ReactProp(name = "selectedImageIcon") - public void setSelectedImage(final GalleryView view, final String imageSource) { - dispatchOnConfigJobQueue(new Runnable() { - @Override - public void run() { - final Drawable drawable = ResourceDrawableIdHelper.getIcon(view.getContext(), imageSource); - getViewAdapter(view).setSelectedDrawable(drawable); - } - }); - } - - @ReactProp(name = "unSelectedImageIcon") - public void setUnselectedImage(final GalleryView view, final String imageSource) { - dispatchOnConfigJobQueue(new Runnable() { - @Override - public void run() { - final Drawable drawable = ResourceDrawableIdHelper.getIcon(view.getContext(), imageSource); - getViewAdapter(view).setUnselectedDrawable(drawable); - } - }); - } - - @ReactProp(name = "selection") - public void setSelectionProperties(final GalleryView view, final ReadableMap selectionProps) { - final String selectedImage = getStringSafe(selectionProps, SELECTION_SELECTED_IMAGE_KEY); - final String unselectedImage = getStringSafe(selectionProps, SELECTION_UNSELECTED_IMAGE_KEY); - final Integer position = getIntSafe(selectionProps, SELECTION_POSITION_KEY); - final String size = getStringSafe(selectionProps, SELECTION_SIZE_KEY); - final Boolean enabled = getBooleanSafe(selectionProps, SELECTION_ENABLED_KEY); - final Integer selectionOverlayColor = getIntSafe(selectionProps, SELECTION_OVERLAY_KEY); - dispatchOnConfigJobQueue(new Runnable() { - @Override - public void run() { - final GalleryAdapter viewAdapter = getViewAdapter(view); - - if (selectedImage != null) { - final Drawable selectedDrawable = ResourceDrawableIdHelper.getIcon(view.getContext(), selectedImage); - viewAdapter.setSelectedDrawable(selectedDrawable); - } - - if (unselectedImage != null) { - final Drawable unselectedDrawable = ResourceDrawableIdHelper.getIcon(view.getContext(), unselectedImage); - viewAdapter.setUnselectedDrawable(unselectedDrawable); - } - - if (position != null) { - viewAdapter.setSelectionDrawablePosition(position); - } - - if (size != null) { - final int sizeCode = size.equalsIgnoreCase("large") ? GalleryAdapter.SELECTED_IMAGE_SIZE_LARGE : GalleryAdapter.SELECTED_IMAGE_SIZE_NORMAL; - viewAdapter.setSelectedDrawableSize(sizeCode); - } - - viewAdapter.setShouldEnabledSelection(enabled != null ? enabled : true); - viewAdapter.setSelectionOverlayColor(selectionOverlayColor); - } - }); - } - - @ReactProp(name = "fileTypeSupport") - public void setFileTypeSupport(final GalleryView view, final ReadableMap fileTypeSupport) { - final ReadableArray supportedFileTypes = fileTypeSupport.getArray(SUPPORTED_TYPES_KEY); - final String unsupportedOverlayColor = getStringSafe(fileTypeSupport, UNSUPPORTED_OVERLAY_KEY); - final String unsupportedImageSource = getStringSafe(fileTypeSupport, UNSUPPORTED_IMAGE_KEY); - final String unsupportedText = getStringSafe(fileTypeSupport, UNSUPPORTED_TEXT_KEY); - final String unsupportedTextColor = getStringSafe(fileTypeSupport, UNSUPPORTED_TEXT_COLOR_KEY); - - dispatchOnConfigJobQueue(new Runnable() { - @Override - public void run() { - Drawable unsupportedImage = null; - if(unsupportedImageSource != null) { - unsupportedImage = ResourceDrawableIdHelper.getIcon(view.getContext(), unsupportedImageSource); - } - final Drawable unsupportedFinalImage = unsupportedImage; - final ArrayList