Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
f14e2b85be | ||
|
a883244505 | ||
|
6cbbd5b049 | ||
|
28c53e740d | ||
|
7e02edcc85 | ||
|
8a56deb957 | ||
|
c14197859a | ||
|
0943823a81 | ||
|
c1dc501e23 | ||
|
73dbf783d6 | ||
|
aa973838db | ||
|
b902228274 | ||
|
7e1dab300a | ||
|
cd9e88033c | ||
|
28b79380df | ||
|
d4ee12f022 |
141
AndroidManifest.xml
Normal file
141
AndroidManifest.xml
Normal file
@ -0,0 +1,141 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- BEGIN_INCLUDE(manifest) -->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="{{android.package}}"
|
||||
android:versionCode="{{android.version_code}}"
|
||||
android:versionName="{{project.version}}"
|
||||
android:installLocation="auto">
|
||||
|
||||
<uses-feature android:name="android.hardware.camera" />
|
||||
<uses-feature android:name="android.hardware.camera.autofocus" />
|
||||
<uses-feature android:required="true" android:glEsVersion="0x00020000" />
|
||||
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="23" />
|
||||
<application
|
||||
{{#has-icons?}}
|
||||
android:icon="@drawable/icon"
|
||||
{{/has-icons?}}
|
||||
android:label="{{project.title}}" android:hasCode="true" android:debuggable="false">
|
||||
|
||||
<!-- For Local Notifications -->
|
||||
<receiver android:name="com.defold.push.LocalNotificationReceiver" >
|
||||
</receiver>
|
||||
|
||||
<!-- For GCM (push) -->
|
||||
<meta-data
|
||||
android:name="com.google.android.gms.version"
|
||||
android:value="@integer/google_play_services_version" />
|
||||
|
||||
<!-- For Facebook -->
|
||||
<meta-data android:name="com.facebook.sdk.ApplicationName"
|
||||
android:value="{{project.title}}" />
|
||||
|
||||
<activity android:name="com.dynamo.android.DefoldActivity"
|
||||
android:label="{{project.title}}"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
|
||||
android:screenOrientation="{{orientation-support}}"
|
||||
android:launchMode="singleTask">
|
||||
<meta-data android:name="android.app.lib_name"
|
||||
android:value="{{exe-name}}" />
|
||||
{{#android.push_field_title}}
|
||||
<meta-data
|
||||
android:name="com.defold.push.field_title"
|
||||
android:value="{{android.push_field_title}}" />
|
||||
{{/android.push_field_title}}
|
||||
{{#android.push_field_text}}
|
||||
<meta-data
|
||||
android:name="com.defold.push.field_text"
|
||||
android:value="{{android.push_field_text}}" />
|
||||
{{/android.push_field_text}}
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name="com.dynamo.android.DispatcherActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar" />
|
||||
<activity android:name="com.facebook.FacebookActivity"
|
||||
android:theme="@android:style/Theme.Translucent.NoTitleBar"
|
||||
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
|
||||
android:label="{{project.title}}" />
|
||||
<activity android:name="com.defold.iap.IapGooglePlayActivity"
|
||||
android:theme="@android:style/Theme.Translucent.NoTitleBar"
|
||||
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
|
||||
android:label="IAP">
|
||||
</activity>
|
||||
|
||||
<!-- For Local Notifications -->
|
||||
<activity android:name="com.defold.push.LocalPushDispatchActivity"
|
||||
android:theme="@android:style/Theme.Translucent.NoTitleBar"
|
||||
android:launchMode="singleTask"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize">
|
||||
<intent-filter>
|
||||
<action android:name="com.defold.push.FORWARD" />
|
||||
<category android:name="com.defold.push" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<!-- For GCM (push) -->
|
||||
<activity android:name="com.defold.push.PushDispatchActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar">
|
||||
<intent-filter>
|
||||
<action android:name="com.defold.push.FORWARD" />
|
||||
<category android:name="com.defold.push" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<receiver
|
||||
android:name="com.defold.push.GcmBroadcastReceiver"
|
||||
android:permission="com.google.android.c2dm.permission.SEND" >
|
||||
<intent-filter>
|
||||
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
|
||||
<action android:name="com.defold.push.FORWARD" />
|
||||
<category android:name="com.defold.push" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<!-- For IAC Invocations -->
|
||||
<activity android:name="com.defold.iac.IACActivity"
|
||||
android:theme="@android:style/Theme.Translucent.NoTitleBar"
|
||||
android:launchMode="singleTask"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="{{android.package}}" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<service android:name="com.defold.adtruth.InstallReceiver"/>
|
||||
<receiver
|
||||
android:name="com.defold.adtruth.InstallReceiver"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="com.android.vending.INSTALL_REFERRER" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<!-- For Amazon IAP -->
|
||||
<receiver android:name="com.amazon.device.iap.ResponseReceiver" >
|
||||
<intent-filter>
|
||||
<action android:name="com.amazon.inapp.purchasing.NOTIFY" android:permission="com.amazon.inapp.purchasing.Permission.NOTIFY" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
</application>
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="com.android.vending.BILLING" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
|
||||
<!-- For GCM (push) -->
|
||||
<!-- NOTE: Package name from actual app here! -->
|
||||
<permission android:name="{{android.package}}.permission.C2D_MESSAGE" android:protectionLevel="signature" />
|
||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||
<!-- NOTE: Package name from actual app here! -->
|
||||
<uses-permission android:name="{{android.package}}.permission.C2D_MESSAGE" />
|
||||
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
|
||||
</manifest>
|
||||
<!-- END_INCLUDE(manifest) -->
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 Defold Foundation
|
||||
|
||||
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
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
11
README.md
11
README.md
@ -6,13 +6,16 @@ It relies on [buffers](https://www.defold.com/ref/buffer/).
|
||||
For the supported set of QRCodes to decode, see the documentation for [Quirc decoded](https://github.com/dlbeer/quirc)
|
||||
The encoder supports the traditional QR code type.
|
||||
|
||||
The QRCode extension itself should be supported on all platforms. However, the example app relies on getting images from the camera
|
||||
and that extension is currently only supports OSX, iOS and Android (and the Android support is very work-in-progress)
|
||||
|
||||
# Example app
|
||||
|
||||
Push the Scan button to start scanning for qrcodes. The camera starts running and the the app scans the
|
||||
camera image for the first qrcode. Similarly, push the QRCode button to create a qrcode:
|
||||
<br/>
|
||||
<img src="./screenshots/scan.png" width="350">
|
||||
<img src="./screenshots/create.png" width="350">
|
||||
<img src="screenshots/scan.png" width="350">
|
||||
<img src="screenshots/create.png" width="350">
|
||||
|
||||
# Lua api:
|
||||
|
||||
@ -26,7 +29,7 @@ Scans an image buffer for any qrcode.
|
||||
|
||||
`height` The height of the image, in texels
|
||||
|
||||
`flip_x` A boolean flag that tells the decoder to flip the image in X first.
|
||||
`flip_x` A boolean flag (1 or 0) that tells the decoder to flip the image in X first.
|
||||
|
||||
-> `string` Returns a the text from the qrcode if successful. Returns nil otherwise
|
||||
|
||||
@ -50,3 +53,5 @@ https://github.com/dlbeer/quirc
|
||||
|
||||
https://github.com/JCash/qrcode
|
||||
|
||||
I also use this site to create test images:
|
||||
https://www.the-qrcode-generator.com/
|
@ -1,7 +1,7 @@
|
||||
[project]
|
||||
title = QRCode
|
||||
version = 0.1
|
||||
dependencies = https://github.com/defold/extension-camera/archive/master.zip,https://github.com/andsve/dirtylarry/archive/master.zip
|
||||
dependencies = https://github.com/defold/extension-camera/archive/dev-android.zip,https://github.com/andsve/dirtylarry/archive/master.zip
|
||||
custom_resources = main/images/defold.png
|
||||
|
||||
[bootstrap]
|
||||
@ -38,6 +38,7 @@ app_icon_180x180 = /icons/Icon-180.png
|
||||
|
||||
[android]
|
||||
package = com.defold.qrcode
|
||||
manifest = /AndroidManifest.xml
|
||||
|
||||
[osx]
|
||||
bundle_identifier = com.defold.qrcode
|
||||
|
@ -13,9 +13,17 @@ function init(self)
|
||||
gui.set_position(bg, vmath.vector3(screen_width/2, screen_height/2, 0))
|
||||
gui.set_size(bg, vmath.vector3(screen_width, screen_height, 0))
|
||||
|
||||
local camera = gui.get_node("camera")
|
||||
gui.set_position(camera, vmath.vector3(screen_width/2, screen_height/2, 0))
|
||||
gui.set_size(camera, vmath.vector3(screen_width/2, screen_height/2, 0))
|
||||
local cameranode = gui.get_node("camera")
|
||||
gui.set_position(cameranode, vmath.vector3(screen_width/2, screen_height/2, 0))
|
||||
gui.set_size(cameranode, vmath.vector3(screen_width/2, screen_height/2, 0))
|
||||
|
||||
self.camera_enabled = camera ~= nil
|
||||
if not self.camera_enabled then
|
||||
local labelnode = gui.get_node("scan_bn/larrylabel")
|
||||
local iconnode = gui.get_node("camera_icon")
|
||||
gui.set_color(labelnode, vmath.vector4(0.5,0.5,0.5,1))
|
||||
gui.set_color(iconnode, vmath.vector4(0.5,0.5,0.5,1))
|
||||
end
|
||||
|
||||
local qrcode = gui.get_node("qrcode")
|
||||
gui.set_position(qrcode, vmath.vector3(screen_width/2, screen_height/2, 0))
|
||||
@ -54,9 +62,11 @@ local function isempty(s)
|
||||
end
|
||||
|
||||
function on_input(self, action_id, action)
|
||||
dirtylarry:button("scan_bn", action_id, action, function ()
|
||||
msg.post("controller", "click", {mode="SCAN"})
|
||||
end)
|
||||
if self.camera_enabled then
|
||||
dirtylarry:button("scan_bn", action_id, action, function ()
|
||||
msg.post("controller", "click", {mode="SCAN"})
|
||||
end)
|
||||
end
|
||||
dirtylarry:button("generate_bn", action_id, action, function ()
|
||||
local text = sys.get_sys_info().device_ident
|
||||
if isempty(text) then
|
||||
|
@ -7,7 +7,7 @@ local function start_scan(self)
|
||||
local quality = camera.CAPTURE_QUALITY_HIGH
|
||||
local type = camera.CAMERA_TYPE_FRONT
|
||||
self.flip = 0
|
||||
if sysinfo.system_name == 'iPhone OS' then
|
||||
if sysinfo.system_name == 'iPhone OS' or sysinfo.system_name == 'Android' then
|
||||
type = camera.CAMERA_TYPE_BACK
|
||||
quality = camera.CAPTURE_QUALITY_MEDIUM
|
||||
self.flip = 1
|
||||
|
@ -1,14 +1,12 @@
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define EXTENSION_NAME QRCode
|
||||
#define LIB_NAME "QRCode"
|
||||
#define MODULE_NAME "qrcode"
|
||||
|
||||
// Defold SDK
|
||||
#define DLIB_LOG_DOMAIN LIB_NAME
|
||||
#include <dmsdk/sdk.h>
|
||||
|
||||
#include "quirc/quirc.h"
|
||||
@ -167,7 +165,7 @@ static int Generate(lua_State* L)
|
||||
free(qr); // free the qr code
|
||||
|
||||
// Transfer ownership to Lua
|
||||
dmScript::LuaHBuffer luabuffer = {buffer, true};
|
||||
dmScript::LuaHBuffer luabuffer(buffer, dmScript::OWNER_LUA);
|
||||
dmScript::PushBuffer(L, luabuffer);
|
||||
lua_pushinteger(L, outsize);
|
||||
return 2;
|
||||
|
@ -31,6 +31,10 @@
|
||||
|
||||
#define QUIRC_PERSPECTIVE_PARAMS 8
|
||||
|
||||
#if defined(DM_PLATFORM_ANDROID)
|
||||
#define UINT8_MAX 255
|
||||
#endif
|
||||
|
||||
#if QUIRC_MAX_REGIONS < UINT8_MAX
|
||||
typedef uint8_t quirc_pixel_t;
|
||||
#elif QUIRC_MAX_REGIONS < UINT16_MAX
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 227 KiB After Width: | Height: | Size: 228 KiB |
Loading…
x
Reference in New Issue
Block a user