mirror of https://github.com/BTCPrivate/copay.git
Merge pull request #936 from yemel/feature/android-cordova
Android - Migration to Cordova + Crosswalk Framework
This commit is contained in:
commit
560702df58
|
@ -54,6 +54,13 @@ android/package
|
|||
android/*.apk
|
||||
android/*.keystore
|
||||
|
||||
mobile/*.keystore
|
||||
mobile/assets/www
|
||||
mobile/bin/*
|
||||
mobile/gen/*
|
||||
mobile/cordova/*
|
||||
mobile/CordovaLib/*
|
||||
|
||||
coverage/
|
||||
|
||||
shell/bin/linux
|
||||
|
|
12
index.html
12
index.html
|
@ -692,6 +692,9 @@
|
|||
<input type="text" id="address" name="address" ng-disabled="loading"
|
||||
placeholder="Send to" ng-model="address" valid-address required>
|
||||
</div>
|
||||
<div class="small-2 columns" ng-hide="!isCordova">
|
||||
<a class="postfix button secondary" ng-click="scannerIntent()"><i class="fi-camera"></i></a>
|
||||
</div>
|
||||
<div class="small-2 columns" ng-hide="showScanner || !isHttp">
|
||||
<a class="postfix button secondary" ng-click="openScanner()"><i class="fi-camera"></i></a>
|
||||
</div>
|
||||
|
@ -1028,6 +1031,15 @@ on supported browsers please check <a href="http://www.webrtc.org/">http://www.w
|
|||
<script src="js/controllers/settings.js"></script>
|
||||
<script src="js/controllers/uriPayment.js"></script>
|
||||
|
||||
<!-- PLACEHOLDER: CORDOVA SRIPT -->
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
|
||||
function onDeviceReady() {
|
||||
setTimeout(function(){ navigator.splashscreen.hide(); }, 2000);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script src="js/init.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -32,6 +32,7 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
|
||||
// Detect protocol
|
||||
$scope.isHttp = ($window.location.protocol.indexOf('http') === 0);
|
||||
$scope.isCordova = typeof(window.cordova) != 'undefined';
|
||||
|
||||
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
|
||||
window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
|
||||
|
@ -194,6 +195,25 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
}, 500);
|
||||
};
|
||||
|
||||
$scope.scannerIntent = function() {
|
||||
cordova.plugins.barcodeScanner.scan(
|
||||
function onSuccess(result) {
|
||||
if (result.cancelled) return;
|
||||
|
||||
var bip21 = copay.Structure.parseBitcoinURI(result.text);
|
||||
$scope.address = bip21.address;
|
||||
|
||||
if (bip21.amount) {
|
||||
$scope.amount = bip21.amount * bitcore.util.COIN * satToUnit;
|
||||
}
|
||||
|
||||
$rootScope.$digest();
|
||||
},
|
||||
function onError(error) {
|
||||
alert('Scanning error');
|
||||
});
|
||||
}
|
||||
|
||||
$scope.toggleAddressBookEntry = function(key) {
|
||||
var w = $rootScope.wallet;
|
||||
w.toggleAddressBookEntry(key);
|
||||
|
|
|
@ -59,13 +59,16 @@ Structure.parseBitcoinURI = function(uri) {
|
|||
data = splitDots[1];
|
||||
var splitQuestion = data.split('?');
|
||||
ret.address = splitQuestion[0];
|
||||
var search = splitQuestion[1];
|
||||
data = JSON.parse('{"' + search.replace(/&/g, '","').replace(/=/g, '":"') + '"}',
|
||||
function(key, value) {
|
||||
return key === "" ? value : decodeURIComponent(value);
|
||||
});
|
||||
ret.amount = parseFloat(data.amount);
|
||||
ret.message = data.message;
|
||||
|
||||
if (splitQuestion.length > 1) {
|
||||
var search = splitQuestion[1];
|
||||
data = JSON.parse('{"' + search.replace(/&/g, '","').replace(/=/g, '":"') + '"}',
|
||||
function(key, value) {
|
||||
return key === "" ? value : decodeURIComponent(value);
|
||||
});
|
||||
ret.amount = parseFloat(data.amount);
|
||||
ret.message = data.message;
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
|
|
@ -30,13 +30,14 @@ BackupService.prototype.download = function(wallet) {
|
|||
}
|
||||
|
||||
// throw an email intent if we are in the mobile version
|
||||
if (window.xwalk) {
|
||||
if (window.cordova) {
|
||||
var name = wallet.name ? wallet.name + ' ' : '';
|
||||
var partial = partial ? 'Partial ' : '';
|
||||
var subject = 'Copay - ' + name + 'Wallet ' + partial + 'Backup';
|
||||
var body = 'This is the encrypted backup of the wallet ' + wallet.id + ':\n\n' + ew;
|
||||
var mailURL = encodeURI('mailto:?subject=' + subject + '&body=' + body);
|
||||
return window.open(mailURL,'_blank');
|
||||
return window.plugin.email.open({
|
||||
subject: 'Copay - ' + name + 'Wallet ' + partial + 'Backup',
|
||||
body: 'Here is the encrypted backup of the wallet ' + wallet.id,
|
||||
attachments: ['base64:' + filename + '//' + btoa(ew)]
|
||||
});
|
||||
}
|
||||
|
||||
// otherwise lean on the browser implementation
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<manifest android:hardwareAccelerated="true" android:versionCode="3" android:versionName="0.4.1" android:windowSoftInputMode="adjustPan" package="com.bitpay.copay" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name">
|
||||
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/app_name" android:launchMode="singleTop" android:name="Copay" android:theme="@android:style/Theme.Black.NoTitleBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:clearTaskOnLaunch="true" android:configChanges="orientation|keyboardHidden" android:exported="false" android:name="com.google.zxing.client.android.CaptureActivity" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:windowSoftInputMode="stateAlwaysHidden">
|
||||
<intent-filter>
|
||||
<action android:name="com.phonegap.plugins.barcodescanner.SCAN" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:label="@string/share_name" android:name="com.google.zxing.client.android.encode.EncodeActivity">
|
||||
<intent-filter>
|
||||
<action android:name="com.phonegap.plugins.barcodescanner.ENCODE" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:label="@string/share_name" android:name="com.google.zxing.client.android.HelpActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<provider android:authorities="com.bitpay.copay.plugin.emailcomposer.attachmentprovider" android:name="de.appplant.cordova.plugin.emailcomposer.AttachmentProvider" />
|
||||
</application>
|
||||
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.FLASHLIGHT" />
|
||||
<uses-feature android:name="android.hardware.camera" android:required="false" />
|
||||
</manifest>
|
|
@ -0,0 +1,76 @@
|
|||
#! /bin/bash
|
||||
|
||||
# Description: This script compiles and copy the needed files to later package the application for Android
|
||||
|
||||
OpenColor="\033["
|
||||
Red="1;31m"
|
||||
Yellow="1;33m"
|
||||
Green="1;32m"
|
||||
CloseColor="\033[0m"
|
||||
|
||||
# Check function OK
|
||||
checkOK() {
|
||||
if [ $? != 0 ]; then
|
||||
echo "${OpenColor}${Red}* ERROR. Exiting...${CloseColor}"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Configs
|
||||
BUILDDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
APPDIR="$BUILDDIR/assets/www"
|
||||
VERSION=`cut -d '"' -f2 $BUILDDIR/../version.js`
|
||||
RELEASE=false
|
||||
RUN=false
|
||||
|
||||
if [[ $1 = "--release" ]]
|
||||
then
|
||||
RELEASE=true
|
||||
fi
|
||||
|
||||
if [[ $1 = "-r" ]]
|
||||
then
|
||||
RUN=true
|
||||
fi
|
||||
|
||||
# Move to the build directory
|
||||
cd $BUILDDIR
|
||||
|
||||
[ -z "$CROSSWALK" ] && { echo "${OpenColor}${Red}* Need to set CROSSWALK environment variable${CloseColor}"; exit 1; }
|
||||
|
||||
# Create/Clean temp dir
|
||||
echo "${OpenColor}${Green}* Checking temp dir...${CloseColor}"
|
||||
if [ -d $APPDIR ]; then
|
||||
rm -rf $APPDIR
|
||||
fi
|
||||
|
||||
mkdir -p $APPDIR
|
||||
|
||||
# Re-compile copayBundle.js
|
||||
echo "${OpenColor}${Green}* Generating copay bundle...${CloseColor}"
|
||||
grunt --target=dev shell
|
||||
checkOK
|
||||
|
||||
# Copy all app files
|
||||
echo "${OpenColor}${Green}* Copying all app files...${CloseColor}"
|
||||
cd $BUILDDIR/..
|
||||
cp -af {css,font,img,js,lib,sound,config.js,version.js,$BUILDDIR/cordova.js,$BUILDDIR/cordova_plugins.js,$BUILDDIR/plugins} $APPDIR
|
||||
checkOK
|
||||
sed "s/<\!-- PLACEHOLDER: CORDOVA SRIPT -->/<script type='text\/javascript' charset='utf-8' src='cordova.js'><\/script>/g" index.html > $APPDIR/index.html
|
||||
checkOK
|
||||
|
||||
# Building the APK
|
||||
echo "${OpenColor}${Green}* Building APK file...${CloseColor}"
|
||||
cd $BUILDDIR
|
||||
if [[ $RUN == true ]]
|
||||
then
|
||||
./cordova/run
|
||||
elif [[ $RELEASE == true ]]
|
||||
then
|
||||
./cordova/build --release
|
||||
else
|
||||
./cordova/build
|
||||
fi
|
||||
checkOK
|
||||
|
||||
echo "${OpenColor}${Yellow}\nAwesome! We have a brand new APK, enjoy it!${CloseColor}"
|
|
@ -0,0 +1,92 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="Copay" default="help">
|
||||
|
||||
<!-- The local.properties file is created and updated by the 'android' tool.
|
||||
It contains the path to the SDK. It should *NOT* be checked into
|
||||
Version Control Systems. -->
|
||||
<property file="local.properties" />
|
||||
|
||||
<!-- The ant.properties file can be created by you. It is only edited by the
|
||||
'android' tool to add properties to it.
|
||||
This is the place to change some Ant specific build properties.
|
||||
Here are some properties you may want to change/update:
|
||||
|
||||
source.dir
|
||||
The name of the source directory. Default is 'src'.
|
||||
out.dir
|
||||
The name of the output directory. Default is 'bin'.
|
||||
|
||||
For other overridable properties, look at the beginning of the rules
|
||||
files in the SDK, at tools/ant/build.xml
|
||||
|
||||
Properties related to the SDK location or the project target should
|
||||
be updated using the 'android' tool with the 'update' action.
|
||||
|
||||
This file is an integral part of the build system for your
|
||||
application and should be checked into Version Control Systems.
|
||||
|
||||
-->
|
||||
<property file="ant.properties" />
|
||||
|
||||
<!-- if sdk.dir was not set from one of the property file, then
|
||||
get it from the ANDROID_HOME env var.
|
||||
This must be done before we load project.properties since
|
||||
the proguard config can use sdk.dir -->
|
||||
<property environment="env" />
|
||||
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
|
||||
<isset property="env.ANDROID_HOME" />
|
||||
</condition>
|
||||
|
||||
<!-- The project.properties file is created and updated by the 'android'
|
||||
tool, as well as ADT.
|
||||
|
||||
This contains project specific properties such as project target, and library
|
||||
dependencies. Lower level build properties are stored in ant.properties
|
||||
(or in .classpath for Eclipse projects).
|
||||
|
||||
This file is an integral part of the build system for your
|
||||
application and should be checked into Version Control Systems. -->
|
||||
<loadproperties srcFile="project.properties" />
|
||||
|
||||
<!-- quick check on sdk.dir -->
|
||||
<fail
|
||||
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
|
||||
unless="sdk.dir"
|
||||
/>
|
||||
|
||||
<!--
|
||||
Import per project custom build rules if present at the root of the project.
|
||||
This is the place to put custom intermediary targets such as:
|
||||
-pre-build
|
||||
-pre-compile
|
||||
-post-compile (This is typically used for code obfuscation.
|
||||
Compiled code location: ${out.classes.absolute.dir}
|
||||
If this is not done in place, override ${out.dex.input.absolute.dir})
|
||||
-post-package
|
||||
-post-build
|
||||
-pre-clean
|
||||
-->
|
||||
<import file="custom_rules.xml" optional="true" />
|
||||
|
||||
<!-- Import the actual build file.
|
||||
|
||||
To customize existing targets, there are two options:
|
||||
- Customize only one target:
|
||||
- copy/paste the target into this file, *before* the
|
||||
<import> task.
|
||||
- customize it to your needs.
|
||||
- Customize the whole content of build.xml
|
||||
- copy/paste the content of the rules files (minus the top node)
|
||||
into this file, replacing the <import> task.
|
||||
- customize to your needs.
|
||||
|
||||
***********************
|
||||
****** IMPORTANT ******
|
||||
***********************
|
||||
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
|
||||
in order to avoid having your file be overridden by tools such as "android update project"
|
||||
-->
|
||||
<!-- version-tag: 1 -->
|
||||
<import file="${sdk.dir}/tools/ant/build.xml" />
|
||||
|
||||
</project>
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,33 @@
|
|||
cordova.define('cordova/plugin_list', function(require, exports, module) {
|
||||
module.exports = [
|
||||
{
|
||||
"file": "plugins/de.appplant.cordova.plugin.email-composer/www/email_composer.js",
|
||||
"id": "de.appplant.cordova.plugin.email-composer.EmailComposer",
|
||||
"clobbers": [
|
||||
"plugin.email"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/com.phonegap.plugins.barcodescanner/www/barcodescanner.js",
|
||||
"id": "com.phonegap.plugins.barcodescanner.BarcodeScanner",
|
||||
"clobbers": [
|
||||
"cordova.plugins.barcodeScanner"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/org.apache.cordova.splashscreen/www/splashscreen.js",
|
||||
"id": "org.apache.cordova.splashscreen.SplashScreen",
|
||||
"clobbers": [
|
||||
"navigator.splashscreen"
|
||||
]
|
||||
}
|
||||
];
|
||||
module.exports.metadata =
|
||||
// TOP OF METADATA
|
||||
{
|
||||
"de.appplant.cordova.plugin.email-composer": "0.8.2dev",
|
||||
"com.phonegap.plugins.barcodescanner": "1.0.1",
|
||||
"org.apache.cordova.splashscreen": "0.3.0"
|
||||
}
|
||||
// BOTTOM OF METADATA
|
||||
});
|
Binary file not shown.
|
@ -0,0 +1,10 @@
|
|||
# This file is automatically generated by Android Tools.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file must *NOT* be checked into Version Control Systems,
|
||||
# as it contains information specific to your local configuration.
|
||||
|
||||
# location of the SDK. This is only used by Ant
|
||||
# For customization when using a Version Control System, please read the
|
||||
# header note.
|
||||
sdk.dir=/Users/yemeljardi/Documents/sdk
|
|
@ -0,0 +1,89 @@
|
|||
cordova.define("com.phonegap.plugins.barcodescanner.BarcodeScanner", function(require, exports, module) { /**
|
||||
* cordova is available under *either* the terms of the modified BSD license *or* the
|
||||
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
|
||||
*
|
||||
* Copyright (c) Matt Kane 2010
|
||||
* Copyright (c) 2011, IBM Corporation
|
||||
*/
|
||||
|
||||
|
||||
var exec = require("cordova/exec");
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @returns {BarcodeScanner}
|
||||
*/
|
||||
function BarcodeScanner() {
|
||||
|
||||
/**
|
||||
* Encoding constants.
|
||||
*
|
||||
* @type Object
|
||||
*/
|
||||
this.Encode = {
|
||||
TEXT_TYPE: "TEXT_TYPE",
|
||||
EMAIL_TYPE: "EMAIL_TYPE",
|
||||
PHONE_TYPE: "PHONE_TYPE",
|
||||
SMS_TYPE: "SMS_TYPE"
|
||||
// CONTACT_TYPE: "CONTACT_TYPE", // TODO: not implemented, requires passing a Bundle class from Javascript to Java
|
||||
// LOCATION_TYPE: "LOCATION_TYPE" // TODO: not implemented, requires passing a Bundle class from Javascript to Java
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Read code from scanner.
|
||||
*
|
||||
* @param {Function} successCallback This function will recieve a result object: {
|
||||
* text : '12345-mock', // The code that was scanned.
|
||||
* format : 'FORMAT_NAME', // Code format.
|
||||
* cancelled : true/false, // Was canceled.
|
||||
* }
|
||||
* @param {Function} errorCallback
|
||||
*/
|
||||
BarcodeScanner.prototype.scan = function (successCallback, errorCallback) {
|
||||
if (errorCallback == null) {
|
||||
errorCallback = function () {
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof errorCallback != "function") {
|
||||
console.log("BarcodeScanner.scan failure: failure parameter not a function");
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof successCallback != "function") {
|
||||
console.log("BarcodeScanner.scan failure: success callback parameter must be a function");
|
||||
return;
|
||||
}
|
||||
|
||||
exec(successCallback, errorCallback, 'BarcodeScanner', 'scan', []);
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
BarcodeScanner.prototype.encode = function (type, data, successCallback, errorCallback, options) {
|
||||
if (errorCallback == null) {
|
||||
errorCallback = function () {
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof errorCallback != "function") {
|
||||
console.log("BarcodeScanner.encode failure: failure parameter not a function");
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof successCallback != "function") {
|
||||
console.log("BarcodeScanner.encode failure: success callback parameter must be a function");
|
||||
return;
|
||||
}
|
||||
|
||||
exec(successCallback, errorCallback, 'BarcodeScanner', 'encode', [
|
||||
{"type": type, "data": data, "options": options}
|
||||
]);
|
||||
};
|
||||
|
||||
var barcodeScanner = new BarcodeScanner();
|
||||
module.exports = barcodeScanner;
|
||||
|
||||
|
||||
});
|
|
@ -0,0 +1,108 @@
|
|||
cordova.define("de.appplant.cordova.plugin.email-composer.EmailComposer", function(require, exports, module) { /*
|
||||
Copyright 2013-2014 appPlant UG
|
||||
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
|
||||
var EmailComposer = function () {
|
||||
|
||||
};
|
||||
|
||||
EmailComposer.prototype = {
|
||||
/**
|
||||
* Displays the email composer pre-filled with data.
|
||||
*
|
||||
* @param {Object} options
|
||||
* Different properties of the email like the body, subject
|
||||
* @param {Function} callback
|
||||
* A callback function to be called with the result
|
||||
* @param {Object?} scope
|
||||
* The scope of the callback
|
||||
*/
|
||||
open: function (options, callback, scope) {
|
||||
var callbackFn = this.createCallbackFn(callback, scope),
|
||||
options = options || {};
|
||||
|
||||
var defaults = {
|
||||
subject: null,
|
||||
body: null,
|
||||
to: null,
|
||||
cc: null,
|
||||
bcc: null,
|
||||
attachments: null,
|
||||
isHtml: true
|
||||
}
|
||||
|
||||
for (var key in defaults) {
|
||||
if (options[key] !== undefined) {
|
||||
defaults[key] = options[key];
|
||||
} else {
|
||||
console.log('EmailComposer plugin: unknown property "' + key + '"');
|
||||
}
|
||||
}
|
||||
|
||||
cordova.exec(callbackFn, null, 'EmailComposer', 'open', [options]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Alias für `open()`.
|
||||
*/
|
||||
openDraft: function () {
|
||||
this.open.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* Verifies if sending emails is supported on the device.
|
||||
*
|
||||
* @param {Function} callback
|
||||
* A callback function to be called with the result
|
||||
* @param {Object} scope
|
||||
* The scope of the callback
|
||||
*/
|
||||
isServiceAvailable: function (callback, scope) {
|
||||
var callbackFn = this.createCallbackFn(callback, scope);
|
||||
|
||||
cordova.exec(callbackFn, null, 'EmailComposer', 'isServiceAvailable', []);
|
||||
},
|
||||
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
* Creates a callback, which will be executed within a specific scope.
|
||||
*
|
||||
* @param {Function} callbackFn
|
||||
* The callback function
|
||||
* @param {Object} scope
|
||||
* The scope for the function
|
||||
*
|
||||
* @return {Function}
|
||||
* The new callback function
|
||||
*/
|
||||
createCallbackFn: function (callbackFn, scope) {
|
||||
return function () {
|
||||
if (typeof callbackFn == 'function') {
|
||||
callbackFn.apply(scope || this, arguments);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var plugin = new EmailComposer();
|
||||
|
||||
module.exports = plugin;
|
||||
});
|
|
@ -0,0 +1,35 @@
|
|||
cordova.define("org.apache.cordova.splashscreen.SplashScreen", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
var exec = require('cordova/exec');
|
||||
|
||||
var splashscreen = {
|
||||
show:function() {
|
||||
exec(null, null, "SplashScreen", "show", []);
|
||||
},
|
||||
hide:function() {
|
||||
exec(null, null, "SplashScreen", "hide", []);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = splashscreen;
|
||||
|
||||
});
|
|
@ -0,0 +1,20 @@
|
|||
# To enable ProGuard in your project, edit project.properties
|
||||
# to define the proguard.config property as described in that file.
|
||||
#
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in ${sdk.dir}/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the ProGuard
|
||||
# include property in project.properties.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
|
@ -0,0 +1,17 @@
|
|||
# This file is automatically generated by Android Tools.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file must be checked in Version Control Systems.
|
||||
#
|
||||
# To customize properties used by the Ant build system edit
|
||||
# "ant.properties", and override values to adapt the script to your
|
||||
# project structure.
|
||||
#
|
||||
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
|
||||
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
||||
|
||||
android.library.reference.1=CordovaLib
|
||||
# Project target.
|
||||
target=android-19
|
||||
key.store=copay.keystore
|
||||
key.alias=copay_play
|
Binary file not shown.
After Width: | Height: | Size: 8.0 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 6.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
|
@ -0,0 +1,48 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (C) 2008 ZXing authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:fillViewport="true"
|
||||
android:background="@color/encode_view"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center">
|
||||
|
||||
<ImageView android:id="@+id/image_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:scaleType="center"/>
|
||||
|
||||
<ScrollView android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="center">
|
||||
|
||||
<TextView android:id="@+id/contents_text_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/contents_text"
|
||||
android:paddingRight="8dip"
|
||||
android:paddingTop="8dip"
|
||||
android:paddingBottom="8dip"/>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</LinearLayout>
|
|
@ -0,0 +1,90 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (C) 2008 ZXing authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:padding="8dip">
|
||||
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/msg_share_explanation"
|
||||
android:paddingBottom="12dip"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingBottom="12dip">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/share_via_barcode"
|
||||
android:paddingRight="24dip"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<Button android:id="@+id/share_app_button"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/button_share_app"/>
|
||||
|
||||
<Button android:id="@+id/share_contact_button"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/button_share_contact"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<Button android:id="@+id/share_bookmark_button"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/button_share_bookmark"/>
|
||||
|
||||
<Button android:id="@+id/share_clipboard_button"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/button_share_clipboard"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<EditText android:id="@+id/share_text_view"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/msg_share_text"
|
||||
android:singleLine="true"
|
||||
android:selectAllOnFocus="true"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -0,0 +1,219 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (C) 2008 ZXing authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<SurfaceView android:id="@+id/preview_view"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"/>
|
||||
|
||||
<com.google.zxing.client.android.ViewfinderView
|
||||
android:id="@+id/viewfinder_view"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"/>
|
||||
|
||||
<LinearLayout android:id="@+id/result_view"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="@color/result_view"
|
||||
android:visibility="gone"
|
||||
android:baselineAligned="false">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="top"
|
||||
android:padding="@dimen/standard_padding">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:gravity="right">
|
||||
|
||||
<ImageView android:id="@+id/barcode_image_view"
|
||||
android:layout_width="150dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxWidth="150dip"
|
||||
android:maxHeight="150dip"
|
||||
android:layout_marginBottom="@dimen/half_padding"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerInside"/>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/msg_default_format"
|
||||
android:textColor="@color/result_minor_text"
|
||||
android:textStyle="bold"
|
||||
android:paddingRight="@dimen/half_padding"/>
|
||||
|
||||
<TextView android:id="@+id/format_text_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/result_minor_text"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/msg_default_type"
|
||||
android:textColor="@color/result_minor_text"
|
||||
android:textStyle="bold"
|
||||
android:paddingRight="@dimen/half_padding"/>
|
||||
|
||||
<TextView android:id="@+id/type_text_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/result_minor_text"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/msg_default_time"
|
||||
android:textColor="@color/result_minor_text"
|
||||
android:textStyle="bold"
|
||||
android:paddingRight="@dimen/half_padding"/>
|
||||
|
||||
<TextView android:id="@+id/time_text_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/result_minor_text"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView android:id="@+id/meta_text_view_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/msg_default_meta"
|
||||
android:textColor="@color/result_minor_text"
|
||||
android:textStyle="bold"
|
||||
android:paddingRight="@dimen/half_padding"/>
|
||||
|
||||
<TextView android:id="@+id/meta_text_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/result_minor_text"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView android:id="@+id/contents_text_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/result_text"
|
||||
android:textColorLink="@color/result_text"
|
||||
android:textSize="22sp"
|
||||
android:paddingLeft="12dip"
|
||||
android:autoLink="web"/>
|
||||
|
||||
<TextView android:id="@+id/contents_supplement_text_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/result_text"
|
||||
android:textColorLink="@color/result_text"
|
||||
android:paddingLeft="12dip"
|
||||
android:autoLink="web"
|
||||
android:clickable="true"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout android:id="@+id/result_button_view"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center">
|
||||
|
||||
<Button android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<Button android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<Button android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<Button android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<Button android:id="@+id/shopper_button"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:drawableLeft="@drawable/shopper_icon"
|
||||
android:text="@string/button_google_shopper"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView android:id="@+id/status_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|center_horizontal"
|
||||
android:background="@color/transparent"
|
||||
android:text="@string/msg_default_status"
|
||||
android:textColor="@color/status_text"/>
|
||||
|
||||
</FrameLayout>
|
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (C) 2008 ZXing authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/half_padding">
|
||||
|
||||
<TextView android:id="@+id/bookmark_title"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"/>
|
||||
|
||||
<TextView android:id="@+id/bookmark_url"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="false"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -0,0 +1,218 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (C) 2008 ZXing authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<SurfaceView android:id="@+id/preview_view"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"/>
|
||||
|
||||
<com.google.zxing.client.android.ViewfinderView
|
||||
android:id="@+id/viewfinder_view"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"/>
|
||||
|
||||
<LinearLayout android:id="@+id/result_view"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="@color/result_view"
|
||||
android:visibility="gone"
|
||||
android:baselineAligned="false">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:padding="@dimen/standard_padding">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:gravity="right|center_vertical">
|
||||
|
||||
<ImageView android:id="@+id/barcode_image_view"
|
||||
android:layout_width="160dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxWidth="160dip"
|
||||
android:maxHeight="160dip"
|
||||
android:layout_marginBottom="@dimen/half_padding"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerInside"/>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/msg_default_format"
|
||||
android:textColor="@color/result_minor_text"
|
||||
android:textStyle="bold"
|
||||
android:paddingRight="@dimen/half_padding"/>
|
||||
|
||||
<TextView android:id="@+id/format_text_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/result_minor_text"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/msg_default_type"
|
||||
android:textColor="@color/result_minor_text"
|
||||
android:textStyle="bold"
|
||||
android:paddingRight="@dimen/half_padding"/>
|
||||
|
||||
<TextView android:id="@+id/type_text_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/result_minor_text"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/msg_default_time"
|
||||
android:textColor="@color/result_minor_text"
|
||||
android:textStyle="bold"
|
||||
android:paddingRight="@dimen/half_padding"/>
|
||||
|
||||
<TextView android:id="@+id/time_text_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/result_minor_text"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView android:id="@+id/meta_text_view_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/msg_default_meta"
|
||||
android:textColor="@color/result_minor_text"
|
||||
android:textStyle="bold"
|
||||
android:paddingRight="@dimen/half_padding"/>
|
||||
|
||||
<TextView android:id="@+id/meta_text_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/result_minor_text"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView android:id="@+id/contents_text_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/result_text"
|
||||
android:textColorLink="@color/result_text"
|
||||
android:textSize="22sp"
|
||||
android:paddingLeft="12dip"
|
||||
android:autoLink="web"/>
|
||||
|
||||
<TextView android:id="@+id/contents_supplement_text_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/result_text"
|
||||
android:textColorLink="@color/result_text"
|
||||
android:paddingLeft="12dip"
|
||||
android:autoLink="web"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout android:id="@+id/result_button_view"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center">
|
||||
|
||||
<Button android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<Button android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<Button android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<Button android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<Button android:id="@+id/shopper_button"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:drawableLeft="@drawable/shopper_icon"
|
||||
android:text="@string/button_google_shopper"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView android:id="@+id/status_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|center_horizontal"
|
||||
android:background="@color/transparent"
|
||||
android:text="@string/msg_default_status"
|
||||
android:textColor="@color/status_text"/>
|
||||
|
||||
</FrameLayout>
|
|
@ -0,0 +1,49 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (C) 2008 ZXing authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:fillViewport="true"
|
||||
android:background="@color/encode_view"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center">
|
||||
|
||||
<ImageView android:id="@+id/image_view"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:scaleType="center"/>
|
||||
|
||||
<ScrollView android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center">
|
||||
|
||||
<TextView android:id="@+id/contents_text_view"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/contents_text"
|
||||
android:paddingBottom="@dimen/standard_padding"
|
||||
android:paddingLeft="@dimen/standard_padding"
|
||||
android:paddingRight="@dimen/standard_padding"/>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</LinearLayout>
|
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (C) 2008 ZXing authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<WebView android:id="@+id/help_contents"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center"
|
||||
android:paddingTop="@dimen/half_padding"
|
||||
android:weightSum="1">
|
||||
|
||||
<Button android:id="@+id/back_button"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.5"
|
||||
android:text="@string/button_back"/>
|
||||
|
||||
<Button android:id="@+id/done_button"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.5"
|
||||
android:text="@string/button_done"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/standard_padding">
|
||||
|
||||
<TextView android:id="@+id/history_title"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:singleLine="true"/>
|
||||
|
||||
<TextView android:id="@+id/history_detail"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:singleLine="false"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -0,0 +1,51 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (C) 2008 ZXing authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0">
|
||||
|
||||
<EditText android:id="@+id/query_text_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="left|center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:singleLine="true"
|
||||
android:selectAllOnFocus="true"
|
||||
android:inputType="text"/>
|
||||
|
||||
<Button android:id="@+id/query_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0"
|
||||
android:text="@string/button_search_book_contents"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<ListView android:id="@+id/result_list_view"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (C) 2008 ZXing authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="@dimen/standard_padding"
|
||||
android:paddingBottom="@dimen/half_padding"
|
||||
android:enabled="false"
|
||||
android:singleLine="true"/>
|
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (C) 2008 ZXing authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.zxing.client.android.book.SearchBookContentsListItem
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/standard_padding">
|
||||
|
||||
<TextView android:id="@+id/page_number_view"
|
||||
android:layout_width="75dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="left|top"
|
||||
android:layout_marginRight="@dimen/standard_padding"
|
||||
android:singleLine="false"
|
||||
android:textStyle="bold"/>
|
||||
|
||||
<TextView android:id="@+id/snippet_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="left|top"
|
||||
android:singleLine="false"/>
|
||||
|
||||
</com.google.zxing.client.android.book.SearchBookContentsListItem>
|
|
@ -0,0 +1,96 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (C) 2008 ZXing authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!-- ScrollView wrapper is to accommodate small screens. -->
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center">
|
||||
|
||||
<!-- Must wrap the rest in one layout -->
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/standard_padding">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/msg_share_explanation"
|
||||
android:paddingBottom="@dimen/standard_padding"/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/share_via_barcode"
|
||||
android:paddingBottom="@dimen/standard_padding"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingBottom="@dimen/standard_padding">
|
||||
|
||||
<Button android:id="@+id/share_app_button"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/button_share_app"/>
|
||||
|
||||
<Button android:id="@+id/share_bookmark_button"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/button_share_bookmark"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingBottom="@dimen/standard_padding">
|
||||
|
||||
<Button android:id="@+id/share_contact_button"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/button_share_contact"/>
|
||||
|
||||
<Button android:id="@+id/share_clipboard_button"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/button_share_clipboard"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<EditText android:id="@+id/share_text_view"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/msg_share_text"
|
||||
android:singleLine="true"
|
||||
android:selectAllOnFocus="true"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (C) 2012 ZXing authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- removed nonfunctional menu - see file history to retrieve -->
|
||||
</menu>
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (C) 2012 ZXing authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- removed nonfunctional menu - see file history to retrieve -->
|
||||
</menu>
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (C) 2012 ZXing authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@+id/menu_history_send"
|
||||
android:title="@string/history_send"
|
||||
android:icon="@android:drawable/ic_menu_share"
|
||||
android:orderInCategory="1"/>
|
||||
<item android:id="@+id/menu_history_clear_text"
|
||||
android:title="@string/history_clear_text"
|
||||
android:icon="@android:drawable/ic_menu_delete"
|
||||
android:orderInCategory="2"/>
|
||||
</menu>
|
Binary file not shown.
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<resources>
|
||||
<string-array name="country_codes">
|
||||
<item>-</item>
|
||||
<item>AR</item>
|
||||
<item>AU</item>
|
||||
<item>BR</item>
|
||||
<item>BG</item>
|
||||
<item>CA</item>
|
||||
<item>CN</item>
|
||||
<item>CZ</item>
|
||||
<item>DE</item>
|
||||
<item>DK</item>
|
||||
<item>ES</item>
|
||||
<item>FI</item>
|
||||
<item>FR</item>
|
||||
<item>GB</item>
|
||||
<item>GR</item>
|
||||
<item>HU</item>
|
||||
<item>ID</item>
|
||||
<item>IT</item>
|
||||
<item>JP</item>
|
||||
<item>KR</item>
|
||||
<item>NL</item>
|
||||
<item>PL</item>
|
||||
<item>PT</item>
|
||||
<item>RU</item>
|
||||
<item>SE</item>
|
||||
<item>SK</item>
|
||||
<item>SI</item>
|
||||
<item>TR</item>
|
||||
<item>TW</item>
|
||||
<item>US</item>
|
||||
</string-array>
|
||||
</resources>
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (C) 2008 ZXing authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<color name="contents_text">#ff000000</color>
|
||||
<color name="encode_view">#ffffffff</color>
|
||||
<color name="possible_result_points">#c0ffbd21</color> <!-- Android standard ICS color -->
|
||||
<color name="result_minor_text">#ffc0c0c0</color>
|
||||
<color name="result_points">#c099cc00</color> <!-- Android standard ICS color -->
|
||||
<color name="result_text">#ffffffff</color>
|
||||
<color name="result_view">#b0000000</color>
|
||||
<color name="status_text">#ffffffff</color>
|
||||
<color name="transparent">#00000000</color>
|
||||
<color name="viewfinder_laser">#ffcc0000</color> <!-- Android standard ICS color -->
|
||||
<color name="viewfinder_mask">#60000000</color>
|
||||
</resources>
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<resources>
|
||||
<dimen name="standard_padding">8dip</dimen>
|
||||
<dimen name="half_padding">4dip</dimen>
|
||||
</resources>
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (C) 2008 ZXing authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<item type="id" name="decode"/>
|
||||
<item type="id" name="decode_failed"/>
|
||||
<item type="id" name="decode_succeeded"/>
|
||||
<item type="id" name="launch_product_query"/>
|
||||
<item type="id" name="quit"/>
|
||||
<item type="id" name="restart_preview"/>
|
||||
<item type="id" name="return_scan_result"/>
|
||||
</resources>
|
|
@ -0,0 +1,123 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<resources>
|
||||
<string name="app_name">Copay</string>
|
||||
<string name="app_picker_name">Applications</string>
|
||||
<string name="bookmark_picker_name">Bookmarks</string>
|
||||
<string name="button_add_calendar">Add to calendar</string>
|
||||
<string name="button_add_contact">Add contact</string>
|
||||
<string name="button_back">Back</string>
|
||||
<string name="button_book_search">Book Search</string>
|
||||
<string name="button_cancel">Cancel</string>
|
||||
<string name="button_custom_product_search">Custom search</string>
|
||||
<string name="button_dial">Dial number</string>
|
||||
<string name="button_done">Done</string>
|
||||
<string name="button_email">Send email</string>
|
||||
<string name="button_get_directions">Get directions</string>
|
||||
<string name="button_google_shopper">Shopper</string>
|
||||
<string name="button_mms">Send MMS</string>
|
||||
<string name="button_ok">OK</string>
|
||||
<string name="button_open_browser">Open browser</string>
|
||||
<string name="button_product_search">Product Search</string>
|
||||
<string name="button_search_book_contents">Search contents</string>
|
||||
<string name="button_share_app">Application</string>
|
||||
<string name="button_share_bookmark">Bookmark</string>
|
||||
<string name="button_share_by_email">Share via email</string>
|
||||
<string name="button_share_by_sms">Share via SMS</string>
|
||||
<string name="button_share_clipboard">Clipboard</string>
|
||||
<string name="button_share_contact">Contact</string>
|
||||
<string name="button_show_map">Show map</string>
|
||||
<string name="button_sms">Send SMS</string>
|
||||
<string name="button_web_search">Web search</string>
|
||||
<string name="button_wifi">Connect to Network</string>
|
||||
<string name="contents_contact">Contact info</string>
|
||||
<string name="contents_email">Email address</string>
|
||||
<string name="contents_location">Geographic coordinates</string>
|
||||
<string name="contents_phone">Phone number</string>
|
||||
<string name="contents_sms">SMS address</string>
|
||||
<string name="contents_text">Plain text</string>
|
||||
<string name="history_clear_text">Clear history</string>
|
||||
<string name="history_clear_one_history_text">Clear</string>
|
||||
<string name="history_email_title">Barcode Scanner history</string>
|
||||
<string name="history_empty">Empty</string>
|
||||
<string name="history_empty_detail">No barcode scans have been recorded</string>
|
||||
<string name="history_send">Send history</string>
|
||||
<string name="history_title">History</string>
|
||||
<string name="menu_encode_mecard">Use MECARD</string>
|
||||
<string name="menu_encode_vcard">Use vCard</string>
|
||||
<string name="menu_help">Help</string>
|
||||
<string name="menu_history">History</string>
|
||||
<string name="menu_share">Share</string>
|
||||
<string name="msg_bulk_mode_scanned">Bulk mode: barcode scanned and saved</string>
|
||||
<string name="msg_camera_framework_bug">Sorry, the Android camera encountered a problem. You may need to restart the device.</string>
|
||||
<string name="msg_default_format">Format</string>
|
||||
<string name="msg_default_meta">Metadata</string>
|
||||
<string name="msg_default_mms_subject">Hi</string>
|
||||
<string name="msg_default_status">Place a barcode inside the viewfinder rectangle to scan it.</string>
|
||||
<string name="msg_default_time">Time</string>
|
||||
<string name="msg_default_type">Type</string>
|
||||
<string name="msg_encode_contents_failed">Could not encode a barcode from the data provided.</string>
|
||||
<string name="msg_google_books">Google Books</string>
|
||||
<string name="msg_google_product">Google Product Search</string>
|
||||
<string name="msg_google_shopper_missing">Google Shopper is not installed</string>
|
||||
<string name="msg_install_google_shopper">Google Shopper combines barcode scanning with online and local prices, reviews and more without opening the browser. Would you like to try it?</string>
|
||||
<string name="msg_intent_failed">Sorry, the requested application could not be launched. The barcode contents may be invalid.</string>
|
||||
<string name="msg_redirect">Redirect</string>
|
||||
<string name="msg_sbc_book_not_searchable">Sorry, this book is not searchable.</string>
|
||||
<string name="msg_sbc_failed">Sorry, the search encountered a problem.</string>
|
||||
<string name="msg_sbc_no_page_returned">No page returned</string>
|
||||
<string name="msg_sbc_page">Page</string>
|
||||
<string name="msg_sbc_results">Results</string>
|
||||
<string name="msg_sbc_searching_book">Searching book\u2026</string>
|
||||
<string name="msg_sbc_snippet_unavailable">Snippet not available</string>
|
||||
<string name="msg_sbc_unknown_page">Unknown page</string>
|
||||
<string name="msg_share_explanation">You can share data by displaying a barcode on your screen and scanning it with another phone.</string>
|
||||
<string name="msg_share_subject_line">Here are the contents of a barcode I scanned</string>
|
||||
<string name="msg_share_text">Or type some text and press Enter</string>
|
||||
<string name="msg_sure">Are you sure?</string>
|
||||
<string name="msg_unmount_usb">Sorry, the SD card is not accessible.</string>
|
||||
<string name="preferences_actions_title">When a barcode is found\u2026</string>
|
||||
<string name="preferences_auto_focus_title">Use auto focus</string>
|
||||
<string name="preferences_bulk_mode_summary">Scan and save many barcodes continuously</string>
|
||||
<string name="preferences_bulk_mode_title">Bulk scan mode</string>
|
||||
<string name="preferences_copy_to_clipboard_title">Copy to clipboard</string>
|
||||
<string formatted="false" name="preferences_custom_product_search_summary">Substitutions: %s = contents, %f = format, %t = type</string>
|
||||
<string name="preferences_custom_product_search_title">Custom search URL</string>
|
||||
<string name="preferences_decode_1D_title">1D barcodes</string>
|
||||
<string name="preferences_decode_Data_Matrix_title">Data Matrix</string>
|
||||
<string name="preferences_decode_QR_title">QR Codes</string>
|
||||
<string name="preferences_device_bug_workarounds_title">Device Bug Workarounds</string>
|
||||
<string name="preferences_disable_continuous_focus_summary">Use only standard focus mode</string>
|
||||
<string name="preferences_disable_continuous_focus_title">No continuous focus</string>
|
||||
<string name="preferences_disable_exposure_title">No exposure</string>
|
||||
<string name="preferences_front_light_summary">Improves scanning in low light on some phones, but may cause glare. Does not work on all phones.</string>
|
||||
<string name="preferences_front_light_title">Use front light</string>
|
||||
<string name="preferences_general_title">General settings</string>
|
||||
<string name="preferences_name">Settings</string>
|
||||
<string name="preferences_play_beep_title">Beep</string>
|
||||
<string name="preferences_remember_duplicates_summary">Store multiple scans of the same barcode in History</string>
|
||||
<string name="preferences_remember_duplicates_title">Remember duplicates</string>
|
||||
<string name="preferences_result_title">Result settings</string>
|
||||
<string name="preferences_scanning_title">When scanning for barcodes, decode\u2026</string>
|
||||
<string name="preferences_search_country">Search country</string>
|
||||
<string name="preferences_try_bsplus">Try Barcode Scanner+</string>
|
||||
<string name="preferences_try_bsplus_summary">Enhanced with new features and interface</string>
|
||||
<string name="preferences_supplemental_summary">Try to retrieve more information about the barcode contents</string>
|
||||
<string name="preferences_supplemental_title">Retrieve more info</string>
|
||||
<string name="preferences_vibrate_title">Vibrate</string>
|
||||
<string name="result_address_book">Found contact info</string>
|
||||
<string name="result_calendar">Found calendar event</string>
|
||||
<string name="result_email_address">Found email address</string>
|
||||
<string name="result_geo">Found geographic coordinates</string>
|
||||
<string name="result_isbn">Found book</string>
|
||||
<string name="result_product">Found product</string>
|
||||
<string name="result_sms">Found SMS address</string>
|
||||
<string name="result_tel">Found phone number</string>
|
||||
<string name="result_text">Found plain text</string>
|
||||
<string name="result_uri">Found URL</string>
|
||||
<string name="result_wifi">Found WLAN Configuration</string>
|
||||
<string name="sbc_name">Google Book Search</string>
|
||||
<string name="share_name">Share via barcode</string>
|
||||
<string name="wifi_changing_network">Requesting connection to network\u2026</string>
|
||||
<string name="wifi_ssid_label">Network Name</string>
|
||||
<string name="wifi_type_label">Type</string>
|
||||
</resources>
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<widget id="com.bitpay.copay" version="2.0.0" xmlns="http://www.w3.org/ns/widgets">
|
||||
<name>Copay</name>
|
||||
<description>
|
||||
A secure bitcoin wallet for friends and companies
|
||||
</description>
|
||||
<author email="support@bitpay.com" href="http://copay.io">
|
||||
Bitpay Inc.
|
||||
</author>
|
||||
<access origin="*" />
|
||||
<content src="index.html" />
|
||||
<preference name="loglevel" value="DEBUG" />
|
||||
<preference name="splashscreen" value="screen" />
|
||||
<preference name="splashScreenDelay" value="10000" />
|
||||
<preference name="backgroundColor" value="0x2C3E50" />
|
||||
<feature name="App">
|
||||
<param name="android-package" value="com.bitpay.copay" />
|
||||
</feature>
|
||||
<feature name="Vibration">
|
||||
<param name="android-package" value="org.apache.cordova.vibration.Vibration" />
|
||||
</feature>
|
||||
<feature name="BarcodeScanner">
|
||||
<param name="android-package" value="com.phonegap.plugins.barcodescanner.BarcodeScanner" />
|
||||
</feature>
|
||||
<feature name="EmailComposer">
|
||||
<param name="android-package" value="de.appplant.cordova.plugin.emailcomposer.EmailComposer" />
|
||||
</feature>
|
||||
<feature name="SplashScreen">
|
||||
<param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen" />
|
||||
</feature>
|
||||
</widget>
|
|
@ -0,0 +1,102 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2008 ZXing authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<PreferenceCategory android:title="@string/preferences_scanning_title">
|
||||
<CheckBoxPreference
|
||||
android:key="preferences_decode_1D"
|
||||
android:defaultValue="true"
|
||||
android:title="@string/preferences_decode_1D_title"/>
|
||||
<CheckBoxPreference
|
||||
android:key="preferences_decode_QR"
|
||||
android:defaultValue="true"
|
||||
android:title="@string/preferences_decode_QR_title"/>
|
||||
<CheckBoxPreference
|
||||
android:key="preferences_decode_Data_Matrix"
|
||||
android:defaultValue="true"
|
||||
android:title="@string/preferences_decode_Data_Matrix_title"/>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/preferences_actions_title">
|
||||
<CheckBoxPreference
|
||||
android:key="preferences_play_beep"
|
||||
android:defaultValue="true"
|
||||
android:title="@string/preferences_play_beep_title"/>
|
||||
<CheckBoxPreference
|
||||
android:key="preferences_vibrate"
|
||||
android:defaultValue="false"
|
||||
android:title="@string/preferences_vibrate_title"/>
|
||||
<CheckBoxPreference
|
||||
android:key="preferences_copy_to_clipboard"
|
||||
android:defaultValue="true"
|
||||
android:title="@string/preferences_copy_to_clipboard_title"/>
|
||||
<CheckBoxPreference
|
||||
android:key="preferences_remember_duplicates"
|
||||
android:defaultValue="false"
|
||||
android:title="@string/preferences_remember_duplicates_title"
|
||||
android:summary="@string/preferences_remember_duplicates_summary"/>
|
||||
<CheckBoxPreference
|
||||
android:key="preferences_supplemental"
|
||||
android:defaultValue="true"
|
||||
android:title="@string/preferences_supplemental_title"
|
||||
android:summary="@string/preferences_supplemental_summary"/>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/preferences_result_title">
|
||||
<EditTextPreference
|
||||
android:key="preferences_custom_product_search"
|
||||
android:title="@string/preferences_custom_product_search_title"
|
||||
android:summary="@string/preferences_custom_product_search_summary"/>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/preferences_general_title">
|
||||
<CheckBoxPreference
|
||||
android:key="preferences_front_light"
|
||||
android:defaultValue="false"
|
||||
android:title="@string/preferences_front_light_title"
|
||||
android:summary="@string/preferences_front_light_summary"/>
|
||||
<CheckBoxPreference
|
||||
android:key="preferences_auto_focus"
|
||||
android:defaultValue="true"
|
||||
android:title="@string/preferences_auto_focus_title"/>
|
||||
<CheckBoxPreference
|
||||
android:key="preferences_bulk_mode"
|
||||
android:defaultValue="false"
|
||||
android:title="@string/preferences_bulk_mode_title"
|
||||
android:summary="@string/preferences_bulk_mode_summary"/>
|
||||
<ListPreference
|
||||
android:key="preferences_search_country"
|
||||
android:defaultValue="-"
|
||||
android:entries="@array/country_codes"
|
||||
android:entryValues="@array/country_codes"
|
||||
android:title="@string/preferences_search_country"/>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/preferences_device_bug_workarounds_title">
|
||||
<CheckBoxPreference
|
||||
android:key="preferences_disable_continuous_focus"
|
||||
android:defaultValue="true"
|
||||
android:title="@string/preferences_disable_continuous_focus_title"
|
||||
android:summary="@string/preferences_disable_continuous_focus_summary"/>
|
||||
<!--
|
||||
<CheckBoxPreference
|
||||
android:key="preferences_disable_exposure"
|
||||
android:defaultValue="false"
|
||||
android:title="@string/preferences_disable_exposure_title"/>
|
||||
-->
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/preferences_try_bsplus">
|
||||
<com.google.zxing.client.android.pref.BSPlusPreference
|
||||
android:title="@string/preferences_try_bsplus"
|
||||
android:summary="@string/preferences_try_bsplus_summary"/>
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
|
||||
package com.bitpay.copay;
|
||||
|
||||
import android.os.Bundle;
|
||||
import org.apache.cordova.*;
|
||||
|
||||
public class Copay extends CordovaActivity
|
||||
{
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
super.init();
|
||||
// Set by <content src="index.html" /> in config.xml
|
||||
super.loadUrl(Config.getStartUrl());
|
||||
//super.loadUrl("file:///android_asset/www/index.html");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,169 @@
|
|||
/**
|
||||
* PhoneGap is available under *either* the terms of the modified BSD license *or* the
|
||||
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
|
||||
*
|
||||
* Copyright (c) Matt Kane 2010
|
||||
* Copyright (c) 2011, IBM Corporation
|
||||
* Copyright (c) 2013, Maciej Nux Jaros
|
||||
*/
|
||||
package com.phonegap.plugins.barcodescanner;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
import org.apache.cordova.CordovaPlugin;
|
||||
import org.apache.cordova.CallbackContext;
|
||||
import org.apache.cordova.PluginResult;
|
||||
|
||||
/**
|
||||
* This calls out to the ZXing barcode reader and returns the result.
|
||||
*
|
||||
* @sa https://github.com/apache/cordova-android/blob/master/framework/src/org/apache/cordova/CordovaPlugin.java
|
||||
*/
|
||||
public class BarcodeScanner extends CordovaPlugin {
|
||||
public static final int REQUEST_CODE = 0x0ba7c0de;
|
||||
|
||||
private static final String SCAN = "scan";
|
||||
private static final String ENCODE = "encode";
|
||||
private static final String CANCELLED = "cancelled";
|
||||
private static final String FORMAT = "format";
|
||||
private static final String TEXT = "text";
|
||||
private static final String DATA = "data";
|
||||
private static final String TYPE = "type";
|
||||
private static final String SCAN_INTENT = "com.phonegap.plugins.barcodescanner.SCAN";
|
||||
private static final String ENCODE_DATA = "ENCODE_DATA";
|
||||
private static final String ENCODE_TYPE = "ENCODE_TYPE";
|
||||
private static final String ENCODE_INTENT = "com.phonegap.plugins.barcodescanner.ENCODE";
|
||||
private static final String TEXT_TYPE = "TEXT_TYPE";
|
||||
private static final String EMAIL_TYPE = "EMAIL_TYPE";
|
||||
private static final String PHONE_TYPE = "PHONE_TYPE";
|
||||
private static final String SMS_TYPE = "SMS_TYPE";
|
||||
|
||||
private static final String LOG_TAG = "BarcodeScanner";
|
||||
|
||||
private CallbackContext callbackContext;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public BarcodeScanner() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the request.
|
||||
*
|
||||
* This method is called from the WebView thread. To do a non-trivial amount of work, use:
|
||||
* cordova.getThreadPool().execute(runnable);
|
||||
*
|
||||
* To run on the UI thread, use:
|
||||
* cordova.getActivity().runOnUiThread(runnable);
|
||||
*
|
||||
* @param action The action to execute.
|
||||
* @param args The exec() arguments.
|
||||
* @param callbackContext The callback context used when calling back into JavaScript.
|
||||
* @return Whether the action was valid.
|
||||
*
|
||||
* @sa https://github.com/apache/cordova-android/blob/master/framework/src/org/apache/cordova/CordovaPlugin.java
|
||||
*/
|
||||
@Override
|
||||
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) {
|
||||
this.callbackContext = callbackContext;
|
||||
|
||||
if (action.equals(ENCODE)) {
|
||||
JSONObject obj = args.optJSONObject(0);
|
||||
if (obj != null) {
|
||||
String type = obj.optString(TYPE);
|
||||
String data = obj.optString(DATA);
|
||||
|
||||
// If the type is null then force the type to text
|
||||
if (type == null) {
|
||||
type = TEXT_TYPE;
|
||||
}
|
||||
|
||||
if (data == null) {
|
||||
callbackContext.error("User did not specify data to encode");
|
||||
return true;
|
||||
}
|
||||
|
||||
encode(type, data);
|
||||
} else {
|
||||
callbackContext.error("User did not specify data to encode");
|
||||
return true;
|
||||
}
|
||||
} else if (action.equals(SCAN)) {
|
||||
scan();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts an intent to scan and decode a barcode.
|
||||
*/
|
||||
public void scan() {
|
||||
Intent intentScan = new Intent(SCAN_INTENT);
|
||||
intentScan.addCategory(Intent.CATEGORY_DEFAULT);
|
||||
|
||||
this.cordova.startActivityForResult((CordovaPlugin) this, intentScan, REQUEST_CODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the barcode scanner intent completes.
|
||||
*
|
||||
* @param requestCode The request code originally supplied to startActivityForResult(),
|
||||
* allowing you to identify who this result came from.
|
||||
* @param resultCode The integer result code returned by the child activity through its setResult().
|
||||
* @param intent An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
|
||||
*/
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
||||
if (requestCode == REQUEST_CODE) {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
JSONObject obj = new JSONObject();
|
||||
try {
|
||||
obj.put(TEXT, intent.getStringExtra("SCAN_RESULT"));
|
||||
obj.put(FORMAT, intent.getStringExtra("SCAN_RESULT_FORMAT"));
|
||||
obj.put(CANCELLED, false);
|
||||
} catch (JSONException e) {
|
||||
Log.d(LOG_TAG, "This should never happen");
|
||||
}
|
||||
//this.success(new PluginResult(PluginResult.Status.OK, obj), this.callback);
|
||||
this.callbackContext.success(obj);
|
||||
} else if (resultCode == Activity.RESULT_CANCELED) {
|
||||
JSONObject obj = new JSONObject();
|
||||
try {
|
||||
obj.put(TEXT, "");
|
||||
obj.put(FORMAT, "");
|
||||
obj.put(CANCELLED, true);
|
||||
} catch (JSONException e) {
|
||||
Log.d(LOG_TAG, "This should never happen");
|
||||
}
|
||||
//this.success(new PluginResult(PluginResult.Status.OK, obj), this.callback);
|
||||
this.callbackContext.success(obj);
|
||||
} else {
|
||||
//this.error(new PluginResult(PluginResult.Status.ERROR), this.callback);
|
||||
this.callbackContext.error("Unexpected error");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initiates a barcode encode.
|
||||
*
|
||||
* @param type Endoiding type.
|
||||
* @param data The data to encode in the bar code.
|
||||
*/
|
||||
public void encode(String type, String data) {
|
||||
Intent intentEncode = new Intent(ENCODE_INTENT);
|
||||
intentEncode.putExtra(ENCODE_TYPE, type);
|
||||
intentEncode.putExtra(ENCODE_DATA, data);
|
||||
|
||||
this.cordova.getActivity().startActivity(intentEncode);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
Copyright 2013-2014 appPlant UG
|
||||
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
|
||||
package de.appplant.cordova.plugin.emailcomposer;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
import android.content.ContentProvider;
|
||||
import android.content.ContentValues;
|
||||
import android.content.UriMatcher;
|
||||
import android.database.Cursor;
|
||||
import android.database.MatrixCursor;
|
||||
import android.net.Uri;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.provider.MediaStore;
|
||||
import android.webkit.MimeTypeMap;
|
||||
|
||||
public class AttachmentProvider extends ContentProvider {
|
||||
|
||||
public static final String AUTHORITY = ".plugin.emailcomposer.attachmentprovider";
|
||||
|
||||
private UriMatcher uriMatcher;
|
||||
|
||||
@Override
|
||||
public boolean onCreate() {
|
||||
String pkgName = this.getContext().getPackageName();
|
||||
|
||||
uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
|
||||
|
||||
uriMatcher.addURI(pkgName + AUTHORITY, "*", 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
|
||||
switch(uriMatcher.match(uri)) {
|
||||
case 1:
|
||||
String storage = getContext().getCacheDir() + EmailComposer.STORAGE_FOLDER;
|
||||
String path = storage + File.separator + uri.getLastPathSegment();
|
||||
|
||||
File file = new File(path);
|
||||
ParcelFileDescriptor pfd = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
|
||||
|
||||
return pfd;
|
||||
default:
|
||||
throw new FileNotFoundException("Unsupported uri: " + uri.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(Uri arg0, ContentValues arg1, String arg2, String[] arg3) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Uri arg0, String arg1, String[] arg2) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uri insert(Uri arg0, ContentValues arg1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType(Uri arg0) {
|
||||
String fileExtension = MimeTypeMap.getFileExtensionFromUrl(arg0.getPath());
|
||||
String type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileExtension);
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
|
||||
MatrixCursor result = new MatrixCursor(projection);
|
||||
Object[] row = new Object[projection.length];
|
||||
long fileSize = 0;
|
||||
|
||||
String fileLocation = getContext().getCacheDir() + File.separator + uri.getLastPathSegment();
|
||||
File tempFile = new File(fileLocation);
|
||||
fileSize = tempFile.length();
|
||||
|
||||
for (int i=0; i<projection.length; i++) {
|
||||
if (projection[i].compareToIgnoreCase(MediaStore.MediaColumns.DISPLAY_NAME) == 0) {
|
||||
row[i] = uri.getLastPathSegment();
|
||||
} else if (projection[i].compareToIgnoreCase(MediaStore.MediaColumns.SIZE) == 0) {
|
||||
row[i] = fileSize;
|
||||
}
|
||||
}
|
||||
|
||||
result.addRow(row);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,413 @@
|
|||
/*
|
||||
Copyright 2013-2014 appPlant UG
|
||||
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
|
||||
package de.appplant.cordova.plugin.emailcomposer;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.res.AssetManager;
|
||||
import android.content.res.Resources;
|
||||
import android.net.Uri;
|
||||
import android.text.Html;
|
||||
import android.util.Base64;
|
||||
|
||||
import org.apache.cordova.CordovaPlugin;
|
||||
import org.apache.cordova.CallbackContext;
|
||||
import org.apache.cordova.PluginResult;
|
||||
|
||||
public class EmailComposer extends CordovaPlugin {
|
||||
|
||||
static protected final String STORAGE_FOLDER = File.separator + "email_composer";
|
||||
|
||||
private CallbackContext command;
|
||||
|
||||
@Override
|
||||
public boolean execute (String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
|
||||
|
||||
this.command = callbackContext;
|
||||
|
||||
// Eine E-Mail soll versendet werden
|
||||
if ("open".equals(action)) {
|
||||
open(args);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Es soll überprüft werden, ob ein Dienst zum Versenden der E-Mail zur Verfügung steht
|
||||
if ("isServiceAvailable".equals(action)) {
|
||||
isServiceAvailable();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Returning false results in a "MethodNotFound" error.
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Überprüft, ob Emails versendet werden können.
|
||||
*/
|
||||
private void isServiceAvailable () {
|
||||
Boolean available = isEmailAccountConfigured();
|
||||
PluginResult result = new PluginResult(PluginResult.Status.OK, available);
|
||||
|
||||
command.sendPluginResult(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Öffnet den Email-Kontroller mit vorausgefüllten Daten.
|
||||
*/
|
||||
private void open (JSONArray args) throws JSONException {
|
||||
JSONObject properties = args.getJSONObject(0);
|
||||
Intent draft = getDraftWithProperties(properties);
|
||||
|
||||
openDraft(draft);
|
||||
}
|
||||
|
||||
/**
|
||||
* Erstellt den ViewController für Mails und fügt die übergebenen Eigenschaften ein.
|
||||
*
|
||||
* @param {JSONObject} params (Subject, Body, Recipients, ...)
|
||||
*/
|
||||
private Intent getDraftWithProperties (JSONObject params) throws JSONException {
|
||||
Intent mail = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
|
||||
|
||||
if (params.has("subject"))
|
||||
setSubject(params.getString("subject"), mail);
|
||||
if (params.has("body"))
|
||||
setBody(params.getString("body"), params.optBoolean("isHtml"), mail);
|
||||
if (params.has("to"))
|
||||
setRecipients(params.getJSONArray("to"), mail);
|
||||
if (params.has("cc"))
|
||||
setCcRecipients(params.getJSONArray("cc"), mail);
|
||||
if (params.has("bcc"))
|
||||
setBccRecipients(params.getJSONArray("bcc"), mail);
|
||||
if (params.has("attachments"))
|
||||
setAttachments(params.getJSONArray("attachments"), mail);
|
||||
|
||||
mail.setType("application/octet-stream");
|
||||
|
||||
return mail;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zeigt den ViewController zum Versenden/Bearbeiten der Mail an.
|
||||
*/
|
||||
private void openDraft (final Intent draft) {
|
||||
final EmailComposer plugin = this;
|
||||
|
||||
cordova.getThreadPool().execute( new Runnable() {
|
||||
public void run() {
|
||||
cordova.startActivityForResult(plugin, Intent.createChooser(draft, "Select Email App"), 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Setzt den Subject der Mail.
|
||||
*/
|
||||
private void setSubject (String subject, Intent draft) {
|
||||
draft.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setzt den Body der Mail.
|
||||
*/
|
||||
private void setBody (String body, Boolean isHTML, Intent draft) {
|
||||
if (isHTML) {
|
||||
draft.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(body));
|
||||
draft.setType("text/html");
|
||||
} else {
|
||||
draft.putExtra(android.content.Intent.EXTRA_TEXT, body);
|
||||
draft.setType("text/plain");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Setzt die Empfänger der Mail.
|
||||
*/
|
||||
private void setRecipients (JSONArray recipients, Intent draft) throws JSONException {
|
||||
String[] receivers = new String[recipients.length()];
|
||||
|
||||
for (int i = 0; i < recipients.length(); i++) {
|
||||
receivers[i] = recipients.getString(i);
|
||||
}
|
||||
|
||||
draft.putExtra(android.content.Intent.EXTRA_EMAIL, receivers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setzt die CC-Empfänger der Mail.
|
||||
*/
|
||||
private void setCcRecipients (JSONArray ccRecipients, Intent draft) throws JSONException {
|
||||
String[] receivers = new String[ccRecipients.length()];
|
||||
|
||||
for (int i = 0; i < ccRecipients.length(); i++) {
|
||||
receivers[i] = ccRecipients.getString(i);
|
||||
}
|
||||
|
||||
draft.putExtra(android.content.Intent.EXTRA_CC, receivers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setzt die BCC-Empfänger der Mail.
|
||||
*/
|
||||
private void setBccRecipients (JSONArray bccRecipients, Intent draft) throws JSONException {
|
||||
String[] receivers = new String[bccRecipients.length()];
|
||||
|
||||
for (int i = 0; i < bccRecipients.length(); i++) {
|
||||
receivers[i] = bccRecipients.getString(i);
|
||||
}
|
||||
|
||||
draft.putExtra(android.content.Intent.EXTRA_BCC, receivers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fügt die Anhände zur Mail hinzu.
|
||||
*/
|
||||
private void setAttachments (JSONArray attachments, Intent draft) throws JSONException {
|
||||
ArrayList<Uri> attachmentUris = new ArrayList<Uri>();
|
||||
|
||||
for (int i = 0; i < attachments.length(); i++) {
|
||||
Uri attachmentUri = getUriForPath(attachments.getString(i));
|
||||
|
||||
attachmentUris.add(attachmentUri);
|
||||
}
|
||||
|
||||
draft.putParcelableArrayListExtra(Intent.EXTRA_STREAM, attachmentUris);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt an, ob es eine Anwendung gibt, welche E-Mails versenden kann.
|
||||
*/
|
||||
private Boolean isEmailAccountConfigured () {
|
||||
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto","max@mustermann.com", null));
|
||||
Boolean available = cordova.getActivity().getPackageManager().queryIntentActivities(intent, 0).size() > 1;
|
||||
|
||||
return available;
|
||||
}
|
||||
|
||||
/**
|
||||
* The URI for an attachment path.
|
||||
*
|
||||
* @param {String} path
|
||||
* The given path to the attachment
|
||||
*
|
||||
* @return The URI pointing to the given path
|
||||
*/
|
||||
private Uri getUriForPath (String path) {
|
||||
if (path.startsWith("res:")) {
|
||||
return getUriForResourcePath(path);
|
||||
} else if (path.startsWith("file:")) {
|
||||
return getUriForAbsolutePath(path);
|
||||
} else if (path.startsWith("www:")) {
|
||||
return getUriForAssetPath(path);
|
||||
} else if (path.startsWith("base64:")) {
|
||||
return getUriForBase64Content(path);
|
||||
}
|
||||
|
||||
return Uri.parse(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* The URI for a file.
|
||||
*
|
||||
* @param {String} path
|
||||
* The given absolute path
|
||||
*
|
||||
* @return The URI pointing to the given path
|
||||
*/
|
||||
private Uri getUriForAbsolutePath (String path) {
|
||||
String absPath = path.replaceFirst("file://", "");
|
||||
File file = new File(absPath);
|
||||
|
||||
if (!file.exists()) {
|
||||
System.err.println("Attachment path not found: " + file.getAbsolutePath());
|
||||
}
|
||||
|
||||
return Uri.fromFile(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* The URI for an asset.
|
||||
*
|
||||
* @param {String} path
|
||||
* The given asset path
|
||||
*
|
||||
* @return The URI pointing to the given path
|
||||
*/
|
||||
private Uri getUriForAssetPath (String path) {
|
||||
String resPath = path.replaceFirst("www:/", "www");
|
||||
String fileName = resPath.substring(resPath.lastIndexOf('/') + 1);
|
||||
String storage = cordova.getActivity().getExternalCacheDir().toString() + STORAGE_FOLDER;
|
||||
|
||||
File file = new File(storage, fileName);
|
||||
|
||||
new File(storage).mkdir();
|
||||
|
||||
try {
|
||||
AssetManager assets = cordova.getActivity().getAssets();
|
||||
|
||||
FileOutputStream outStream = new FileOutputStream(file);
|
||||
InputStream inputStream = assets.open(resPath);
|
||||
|
||||
copyFile(inputStream, outStream);
|
||||
outStream.flush();
|
||||
outStream.close();
|
||||
} catch (Exception e) {
|
||||
System.err.println("Attachment asset not found: assets/" + resPath);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return Uri.fromFile(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* The URI for a resource.
|
||||
*
|
||||
* @param {String} path
|
||||
* The given relative path
|
||||
*
|
||||
* @return The URI pointing to the given path
|
||||
*/
|
||||
private Uri getUriForResourcePath (String path) {
|
||||
String resPath = path.replaceFirst("res://", "");
|
||||
String fileName = resPath.substring(resPath.lastIndexOf('/') + 1);
|
||||
String resName = fileName.substring(0, fileName.lastIndexOf('.'));
|
||||
String extension = resPath.substring(resPath.lastIndexOf('.'));
|
||||
String storage = cordova.getActivity().getExternalCacheDir().toString() + STORAGE_FOLDER;
|
||||
|
||||
int resId = getResId(resPath);
|
||||
File file = new File(storage, resName + extension);
|
||||
|
||||
if (resId == 0) {
|
||||
System.err.println("Attachment resource not found: " + resPath);
|
||||
}
|
||||
|
||||
new File(storage).mkdir();
|
||||
|
||||
try {
|
||||
Resources res = cordova.getActivity().getResources();
|
||||
FileOutputStream outStream = new FileOutputStream(file);
|
||||
InputStream inputStream = res.openRawResource(resId);
|
||||
|
||||
copyFile(inputStream, outStream);
|
||||
outStream.flush();
|
||||
outStream.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return Uri.fromFile(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* The URI for a base64 encoded content.
|
||||
*
|
||||
* @param {String} content
|
||||
* The given base64 encoded content
|
||||
*
|
||||
* @return The URI including the given content
|
||||
*/
|
||||
private Uri getUriForBase64Content (String content) {
|
||||
String resName = content.substring(content.indexOf(":") + 1, content.indexOf("//"));
|
||||
String resData = content.substring(content.indexOf("//") + 2);
|
||||
byte[] bytes = Base64.decode(resData, 0);
|
||||
String storage = this.cordova.getActivity().getCacheDir() + STORAGE_FOLDER;
|
||||
File file = new File(storage, resName);
|
||||
|
||||
new File(storage).mkdir();
|
||||
|
||||
try {
|
||||
FileOutputStream outStream = new FileOutputStream(file);
|
||||
|
||||
outStream.write(bytes);
|
||||
outStream.flush();
|
||||
outStream.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
String pkgName = getPackageName();
|
||||
String uriPath = pkgName + AttachmentProvider.AUTHORITY + "/" + resName;
|
||||
|
||||
return Uri.parse("content://" + uriPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an InputStream to an OutputStream
|
||||
*
|
||||
* @param {InputStream} in
|
||||
* @param {OutputStream} out
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private void copyFile (InputStream in, OutputStream out) throws IOException {
|
||||
byte[] buffer = new byte[1024];
|
||||
int read;
|
||||
|
||||
while((read = in.read(buffer)) != -1){
|
||||
out.write(buffer, 0, read);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* The resource ID for the given resource.
|
||||
*/
|
||||
private int getResId (String resPath) {
|
||||
Resources res = cordova.getActivity().getResources();
|
||||
|
||||
String pkgName = getPackageName();
|
||||
String dirName = resPath.substring(0, resPath.lastIndexOf('/'));
|
||||
String fileName = resPath.substring(resPath.lastIndexOf('/') + 1);
|
||||
String resName = fileName.substring(0, fileName.lastIndexOf('.'));
|
||||
|
||||
int resId = res.getIdentifier(resName, dirName, pkgName);
|
||||
|
||||
return resId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* The name for the package.
|
||||
*/
|
||||
private String getPackageName () {
|
||||
return cordova.getActivity().getPackageName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
||||
super.onActivityResult(requestCode, resultCode, intent);
|
||||
|
||||
command.success();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
|
||||
package org.apache.cordova.splashscreen;
|
||||
|
||||
import org.apache.cordova.CallbackContext;
|
||||
import org.apache.cordova.CordovaPlugin;
|
||||
import org.json.JSONArray;
|
||||
|
||||
public class SplashScreen extends CordovaPlugin {
|
||||
|
||||
@Override
|
||||
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) {
|
||||
if (action.equals("hide")) {
|
||||
this.webView.postMessage("splashscreen", "hide");
|
||||
} else if (action.equals("show")){
|
||||
this.webView.postMessage("splashscreen", "show");
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
callbackContext.success();
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,124 @@
|
|||
/*
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
package org.apache.cordova.vibration;
|
||||
|
||||
import org.apache.cordova.CallbackContext;
|
||||
import org.apache.cordova.CordovaPlugin;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import android.content.Context;
|
||||
import android.os.Vibrator;
|
||||
|
||||
/**
|
||||
* This class provides access to vibration on the device.
|
||||
*/
|
||||
public class Vibration extends CordovaPlugin {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public Vibration() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the request and returns PluginResult.
|
||||
*
|
||||
* @param action The action to execute.
|
||||
* @param args JSONArray of arguments for the plugin.
|
||||
* @param callbackContext The callback context used when calling back into JavaScript.
|
||||
* @return True when the action was valid, false otherwise.
|
||||
*/
|
||||
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
|
||||
if (action.equals("vibrate")) {
|
||||
this.vibrate(args.getLong(0));
|
||||
}
|
||||
else if (action.equals("vibrateWithPattern")) {
|
||||
JSONArray pattern = args.getJSONArray(0);
|
||||
int repeat = args.getInt(1);
|
||||
long[] patternArray = new long[pattern.length()];
|
||||
for (int i = 0; i < pattern.length(); i++) {
|
||||
patternArray[i] = pattern.getLong(i);
|
||||
}
|
||||
this.vibrateWithPattern(patternArray, repeat);
|
||||
}
|
||||
else if (action.equals("cancelVibration")) {
|
||||
this.cancelVibration();
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only alert and confirm are async.
|
||||
callbackContext.success();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// LOCAL METHODS
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Vibrates the device for a given amount of time.
|
||||
*
|
||||
* @param time Time to vibrate in ms.
|
||||
*/
|
||||
public void vibrate(long time) {
|
||||
// Start the vibration, 0 defaults to half a second.
|
||||
if (time == 0) {
|
||||
time = 500;
|
||||
}
|
||||
Vibrator vibrator = (Vibrator) this.cordova.getActivity().getSystemService(Context.VIBRATOR_SERVICE);
|
||||
vibrator.vibrate(time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vibrates the device with a given pattern.
|
||||
*
|
||||
* @param pattern Pattern with which to vibrate the device.
|
||||
* Pass in an array of longs that
|
||||
* are the durations for which to
|
||||
* turn on or off the vibrator in
|
||||
* milliseconds. The first value
|
||||
* indicates the number of milliseconds
|
||||
* to wait before turning the vibrator
|
||||
* on. The next value indicates the
|
||||
* number of milliseconds for which
|
||||
* to keep the vibrator on before
|
||||
* turning it off. Subsequent values
|
||||
* alternate between durations in
|
||||
* milliseconds to turn the vibrator
|
||||
* off or to turn the vibrator on.
|
||||
*
|
||||
* @param repeat Optional index into the pattern array at which
|
||||
* to start repeating, or -1 for no repetition (default).
|
||||
*/
|
||||
public void vibrateWithPattern(long[] pattern, int repeat) {
|
||||
Vibrator vibrator = (Vibrator) this.cordova.getActivity().getSystemService(Context.VIBRATOR_SERVICE);
|
||||
vibrator.vibrate(pattern, repeat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Immediately cancels any currently running vibration.
|
||||
*/
|
||||
public void cancelVibration() {
|
||||
Vibrator vibrator = (Vibrator) this.cordova.getActivity().getSystemService(Context.VIBRATOR_SERVICE);
|
||||
vibrator.cancel();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue