Skip to content

Commit 5bc866d

Browse files
committed
Initial commit
0 parents  commit 5bc866d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+9361
-0
lines changed

.gitignore

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# Xcode
6+
#
7+
build/
8+
*.pbxuser
9+
!default.pbxuser
10+
*.mode1v3
11+
!default.mode1v3
12+
*.mode2v3
13+
!default.mode2v3
14+
*.perspectivev3
15+
!default.perspectivev3
16+
xcuserdata
17+
*.xccheckout
18+
*.moved-aside
19+
DerivedData
20+
*.hmap
21+
*.ipa
22+
*.xcuserstate
23+
project.xcworkspace
24+
25+
# Android/IntelliJ
26+
#
27+
build/
28+
.idea
29+
.gradle
30+
local.properties
31+
*.iml
32+
33+
# node.js
34+
#
35+
node_modules/
36+
npm-debug.log
37+
yarn-error.log
38+
39+
# BUCK
40+
buck-out/
41+
\.buckd/
42+
43+
# fastlane
44+
#
45+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
46+
# screenshots whenever they are needed.
47+
# For more information about the recommended setup visit:
48+
# https://docs.fastlane.tools/best-practices/source-control/
49+
50+
*/fastlane/report.xml
51+
*/fastlane/Preview.html
52+
*/fastlane/screenshots
53+
54+
# Bundle artifact
55+
*.jsbundle
56+
57+
# CocoaPods
58+
/ios/Pods/

App.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from 'react';
2+
import Scan from './src/scan';
3+
4+
const App = () => {
5+
return (
6+
<Scan />
7+
);
8+
};
9+
10+
export default App;

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# VScanner
2+
Demo app to implement QR Code scanning using RN Camera in a react-native application.
3+
4+
https://codemaker2015.medium.com/qr-code-scanner-app-in-react-native-3a4e574d052d
5+
6+
# Demo
7+
![demo](demo/demo.gif)
8+
9+
# Contact
10+
<a href="mailto:[email protected]">Vishnu Sivan</a>

__tests__/App-test.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @format
3+
*/
4+
5+
import 'react-native';
6+
import React from 'react';
7+
import App from '../App';
8+
9+
// Note: test renderer must be required after react-native.
10+
import renderer from 'react-test-renderer';
11+
12+
it('renders correctly', () => {
13+
renderer.create(<App />);
14+
});

android/app/BUCK

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# To learn about Buck see [Docs](https://buckbuild.com/).
2+
# To run your application with Buck:
3+
# - install Buck
4+
# - `npm start` - to start the packager
5+
# - `cd android`
6+
# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
7+
# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
8+
# - `buck install -r android/app` - compile, install and run application
9+
#
10+
11+
load(":build_defs.bzl", "create_aar_targets", "create_jar_targets")
12+
13+
lib_deps = []
14+
15+
create_aar_targets(glob(["libs/*.aar"]))
16+
17+
create_jar_targets(glob(["libs/*.jar"]))
18+
19+
android_library(
20+
name = "all-libs",
21+
exported_deps = lib_deps,
22+
)
23+
24+
android_library(
25+
name = "app-code",
26+
srcs = glob([
27+
"src/main/java/**/*.java",
28+
]),
29+
deps = [
30+
":all-libs",
31+
":build_config",
32+
":res",
33+
],
34+
)
35+
36+
android_build_config(
37+
name = "build_config",
38+
package = "com.qrcode",
39+
)
40+
41+
android_resource(
42+
name = "res",
43+
package = "com.qrcode",
44+
res = "src/main/res",
45+
)
46+
47+
android_binary(
48+
name = "app",
49+
keystore = "//android/keystores:debug",
50+
manifest = "src/main/AndroidManifest.xml",
51+
package_type = "debug",
52+
deps = [
53+
":app-code",
54+
],
55+
)

android/app/build.gradle

+222
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
apply plugin: "com.android.application"
2+
3+
import com.android.build.OutputFile
4+
5+
/**
6+
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
7+
* and bundleReleaseJsAndAssets).
8+
* These basically call `react-native bundle` with the correct arguments during the Android build
9+
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
10+
* bundle directly from the development server. Below you can see all the possible configurations
11+
* and their defaults. If you decide to add a configuration block, make sure to add it before the
12+
* `apply from: "../../node_modules/react-native/react.gradle"` line.
13+
*
14+
* project.ext.react = [
15+
* // the name of the generated asset file containing your JS bundle
16+
* bundleAssetName: "index.android.bundle",
17+
*
18+
* // the entry file for bundle generation
19+
* entryFile: "index.android.js",
20+
*
21+
* // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
22+
* bundleCommand: "ram-bundle",
23+
*
24+
* // whether to bundle JS and assets in debug mode
25+
* bundleInDebug: false,
26+
*
27+
* // whether to bundle JS and assets in release mode
28+
* bundleInRelease: true,
29+
*
30+
* // whether to bundle JS and assets in another build variant (if configured).
31+
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
32+
* // The configuration property can be in the following formats
33+
* // 'bundleIn${productFlavor}${buildType}'
34+
* // 'bundleIn${buildType}'
35+
* // bundleInFreeDebug: true,
36+
* // bundleInPaidRelease: true,
37+
* // bundleInBeta: true,
38+
*
39+
* // whether to disable dev mode in custom build variants (by default only disabled in release)
40+
* // for example: to disable dev mode in the staging build type (if configured)
41+
* devDisabledInStaging: true,
42+
* // The configuration property can be in the following formats
43+
* // 'devDisabledIn${productFlavor}${buildType}'
44+
* // 'devDisabledIn${buildType}'
45+
*
46+
* // the root of your project, i.e. where "package.json" lives
47+
* root: "../../",
48+
*
49+
* // where to put the JS bundle asset in debug mode
50+
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
51+
*
52+
* // where to put the JS bundle asset in release mode
53+
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
54+
*
55+
* // where to put drawable resources / React Native assets, e.g. the ones you use via
56+
* // require('./image.png')), in debug mode
57+
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
58+
*
59+
* // where to put drawable resources / React Native assets, e.g. the ones you use via
60+
* // require('./image.png')), in release mode
61+
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
62+
*
63+
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
64+
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
65+
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
66+
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
67+
* // for example, you might want to remove it from here.
68+
* inputExcludes: ["android/**", "ios/**"],
69+
*
70+
* // override which node gets called and with what additional arguments
71+
* nodeExecutableAndArgs: ["node"],
72+
*
73+
* // supply additional arguments to the packager
74+
* extraPackagerArgs: []
75+
* ]
76+
*/
77+
78+
project.ext.react = [
79+
entryFile: "index.js",
80+
enableHermes: false, // clean and rebuild if changing
81+
]
82+
83+
apply from: "../../node_modules/react-native/react.gradle"
84+
85+
/**
86+
* Set this to true to create two separate APKs instead of one:
87+
* - An APK that only works on ARM devices
88+
* - An APK that only works on x86 devices
89+
* The advantage is the size of the APK is reduced by about 4MB.
90+
* Upload all the APKs to the Play Store and people will download
91+
* the correct one based on the CPU architecture of their device.
92+
*/
93+
def enableSeparateBuildPerCPUArchitecture = false
94+
95+
/**
96+
* Run Proguard to shrink the Java bytecode in release builds.
97+
*/
98+
def enableProguardInReleaseBuilds = false
99+
100+
/**
101+
* The preferred build flavor of JavaScriptCore.
102+
*
103+
* For example, to use the international variant, you can use:
104+
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
105+
*
106+
* The international variant includes ICU i18n library and necessary data
107+
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
108+
* give correct results when using with locales other than en-US. Note that
109+
* this variant is about 6MiB larger per architecture than default.
110+
*/
111+
def jscFlavor = 'org.webkit:android-jsc:+'
112+
113+
/**
114+
* Whether to enable the Hermes VM.
115+
*
116+
* This should be set on project.ext.react and mirrored here. If it is not set
117+
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
118+
* and the benefits of using Hermes will therefore be sharply reduced.
119+
*/
120+
def enableHermes = project.ext.react.get("enableHermes", false);
121+
122+
android {
123+
compileSdkVersion rootProject.ext.compileSdkVersion
124+
125+
compileOptions {
126+
sourceCompatibility JavaVersion.VERSION_1_8
127+
targetCompatibility JavaVersion.VERSION_1_8
128+
}
129+
defaultConfig {
130+
applicationId "com.qrcode"
131+
minSdkVersion rootProject.ext.minSdkVersion
132+
targetSdkVersion rootProject.ext.targetSdkVersion
133+
versionCode 1
134+
versionName "1.0"
135+
missingDimensionStrategy 'react-native-camera', 'general'
136+
137+
}
138+
signingConfigs {
139+
release {
140+
if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
141+
storeFile file(MYAPP_UPLOAD_STORE_FILE)
142+
storePassword MYAPP_UPLOAD_STORE_PASSWORD
143+
keyAlias MYAPP_UPLOAD_KEY_ALIAS
144+
keyPassword MYAPP_UPLOAD_KEY_PASSWORD
145+
}
146+
}
147+
}
148+
splits {
149+
abi {
150+
reset()
151+
enable enableSeparateBuildPerCPUArchitecture
152+
universalApk false // If true, also generate a universal APK
153+
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
154+
}
155+
}
156+
signingConfigs {
157+
debug {
158+
storeFile file('debug.keystore')
159+
storePassword 'android'
160+
keyAlias 'androiddebugkey'
161+
keyPassword 'android'
162+
}
163+
}
164+
buildTypes {
165+
debug {
166+
signingConfig signingConfigs.debug
167+
}
168+
release {
169+
// Caution! In production, you need to generate your own keystore file.
170+
// see https://facebook.github.io/react-native/docs/signed-apk-android.
171+
signingConfig signingConfigs.debug
172+
signingConfig signingConfigs.release
173+
minifyEnabled enableProguardInReleaseBuilds
174+
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
175+
}
176+
}
177+
// applicationVariants are e.g. debug, release
178+
applicationVariants.all { variant ->
179+
variant.outputs.each { output ->
180+
// For each separate APK per architecture, set a unique version code as described here:
181+
// https://developer.android.com/studio/build/configure-apk-splits.html
182+
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
183+
def abi = output.getFilter(OutputFile.ABI)
184+
if (abi != null) { // null for the universal-debug, universal-release variants
185+
output.versionCodeOverride =
186+
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
187+
}
188+
189+
}
190+
}
191+
192+
packagingOptions {
193+
pickFirst '**/armeabi-v7a/libc++_shared.so'
194+
pickFirst '**/x86/libc++_shared.so'
195+
pickFirst '**/arm64-v8a/libc++_shared.so'
196+
pickFirst '**/x86_64/libc++_shared.so'
197+
pickFirst '**/x86/libjsc.so'
198+
pickFirst '**/armeabi-v7a/libjsc.so'
199+
}
200+
}
201+
202+
dependencies {
203+
implementation fileTree(dir: "libs", include: ["*.jar"])
204+
implementation "com.facebook.react:react-native:+" // From node_modules
205+
206+
if (enableHermes) {
207+
def hermesPath = "../../node_modules/hermesvm/android/";
208+
debugImplementation files(hermesPath + "hermes-debug.aar")
209+
releaseImplementation files(hermesPath + "hermes-release.aar")
210+
} else {
211+
implementation jscFlavor
212+
}
213+
}
214+
215+
// Run this once to be able to run the application with BUCK
216+
// puts all compile dependencies into folder libs for BUCK to use
217+
task copyDownloadableDepsToLibs(type: Copy) {
218+
from configurations.compile
219+
into 'libs'
220+
}
221+
222+
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

android/app/build_defs.bzl

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""Helper definitions to glob .aar and .jar targets"""
2+
3+
def create_aar_targets(aarfiles):
4+
for aarfile in aarfiles:
5+
name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")]
6+
lib_deps.append(":" + name)
7+
android_prebuilt_aar(
8+
name = name,
9+
aar = aarfile,
10+
)
11+
12+
def create_jar_targets(jarfiles):
13+
for jarfile in jarfiles:
14+
name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")]
15+
lib_deps.append(":" + name)
16+
prebuilt_jar(
17+
name = name,
18+
binary_jar = jarfile,
19+
)

android/app/debug.keystore

2.22 KB
Binary file not shown.

android/app/my-upload-key.keystore

2.57 KB
Binary file not shown.

0 commit comments

Comments
 (0)