Permalink
Browse files

cordova-2.5.0 android

  • Loading branch information...
1 parent 51a92fc commit bb0201ede68bfbf8193285623aee0bd973f66ad6 @don committed Mar 5, 2013
View
40 android/AndroidManifest.xml
@@ -1,22 +1,38 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="6" android:versionName="1.2" package="com.chariotsolutions.nfc.demo.reader">
- <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true"/>
- <uses-permission android:name="android.permission.VIBRATE"/>
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
- <uses-permission android:name="android.permission.NFC"/>
- <application android:debuggable="true" android:icon="@drawable/icon" android:label="@string/app_name">
- <activity android:configChanges="orientation|keyboardHidden" android:label="@string/app_name" android:name="ReaderDemo" android:noHistory="true" android:screenOrientation="nosensor">
+<?xml version='1.0' encoding='utf-8'?>
+<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="1.0" android:windowSoftInputMode="adjustPan" package="com.chariotsolutions.nfc.demo.reader" 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.CAMERA" />
+ <uses-permission android:name="android.permission.VIBRATE" />
+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+ <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
+ <uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.RECEIVE_SMS" />
+ <uses-permission android:name="android.permission.RECORD_AUDIO" />
+ <uses-permission android:name="android.permission.RECORD_VIDEO" />
+ <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
+ <uses-permission android:name="android.permission.READ_CONTACTS" />
+ <uses-permission android:name="android.permission.WRITE_CONTACTS" />
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+ <uses-permission android:name="android.permission.GET_ACCOUNTS" />
+ <uses-permission android:name="android.permission.BROADCAST_STICKY" />
+ <application android:debuggable="true" 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:name="ReaderDemo" android:theme="@android:style/Theme.Black.NoTitleBar">
<intent-filter>
- <action android:name="android.intent.action.MAIN"/>
- <category android:name="android.intent.category.LAUNCHER"/>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<data android:mimeType="text/pg"/>
<category android:name="android.intent.category.DEFAULT"/>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
- <uses-feature android:name="android.hardware.nfc" android:required="false"/>
- <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="17"/>
+ <uses-sdk android:minSdkVersion="7" android:targetSdkVersion="17" />
+ <uses-permission android:name="android.permission.NFC" />
+ <uses-feature android:name="android.hardware.nfc" android:required="false" />
</manifest>
View
17 android/ant.properties
@@ -0,0 +1,17 @@
+# This file is used to override default values used by the Ant build system.
+#
+# This file must be checked into Version Control Systems, as it is
+# integral to the build system of your project.
+
+# This file is only used by the Ant script.
+
+# You can use this to override default values such as
+# 'source.dir' for the location of your java source folder and
+# 'out.dir' for the location of your output folder.
+
+# You can also use it define how the release builds are signed by declaring
+# the following properties:
+# 'key.store' for the location of your keystore and
+# 'key.alias' for the name of the key to use.
+# The password will be asked during the build when you use the 'release' target.
+
View
5 android/assets/www/.gitignore
@@ -1,5 +1,4 @@
index.html
-main.js
-master.css
phonegap-nfc*js
-
+js/
+css/
View
6,461 android/assets/www/cordova-2.5.0.js
6,461 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
11 android/build.xml
@@ -28,6 +28,15 @@
-->
<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.
@@ -41,7 +50,7 @@
<!-- 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 an env var"
+ 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"
/>
View
BIN android/cordova/appinfo.jar
Binary file not shown.
View
24 android/cordova/build
@@ -0,0 +1,24 @@
+# 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.
+
+#!/bin/bash
+
+set -e
+
+CORDOVA_PATH=$( cd "$( dirname "$0" )" && pwd )
+
+bash "$CORDOVA_PATH"/cordova build
View
24 android/cordova/clean
@@ -0,0 +1,24 @@
+# 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.
+
+#!/bin/bash
+
+set -e
+
+CORDOVA_PATH=$( cd "$( dirname "$0" )" && pwd )
+
+bash "$CORDOVA_PATH"/cordova clean
View
159 android/cordova/cordova
@@ -0,0 +1,159 @@
+# 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.
+
+#!/bin/bash
+
+
+PROJECT_PATH=$( cd "$( dirname "$0" )/.." && pwd )
+
+function check_devices {
+# FIXME
+ local devices=`adb devices | awk '/List of devices attached/ { while(getline > 0) { print }}' | grep device`
+ if [ -z "$devices" ] ; then
+ echo "1"
+ else
+ echo "0"
+ fi
+}
+
+function emulate {
+ declare -a avd_list=($(android list avd | grep "Name:" | cut -f 2 -d ":" | xargs))
+ # we need to start adb-server
+ adb start-server 1>/dev/null
+
+ # Do not launch an emulator if there is already one running or if a device is attached
+ if [ $(check_devices) == 0 ] ; then
+ return
+ fi
+
+ local avd_id="1000" #FIXME: hopefully user does not have 1000 AVDs
+ # User has no AVDs
+ if [ ${#avd_list[@]} == 0 ]
+ then
+ echo "You don't have any Android Virtual Devices. Please create at least one AVD."
+ echo "android"
+ fi
+ # User has only one AVD
+ if [ ${#avd_list[@]} == 1 ]
+ then
+ emulator -cpu-delay 0 -no-boot-anim -cache /tmp/cache -avd ${avd_list[0]} 1> /dev/null 2>&1 &
+ # User has more than 1 AVD
+ elif [ ${#avd_list[@]} -gt 1 ]
+ then
+ while [ -z ${avd_list[$avd_id]} ]
+ do
+ echo "Choose from one of the following Android Virtual Devices [0 to $((${#avd_list[@]}-1))]:"
+ for(( i = 0 ; i < ${#avd_list[@]} ; i++ ))
+ do
+ echo "$i) ${avd_list[$i]}"
+ done
+ read -t 5 -p "> " avd_id
+ # default value if input timeout
+ if [ $avd_id -eq 1000 ] ; then avd_id=0 ; fi
+ done
+ emulator -cpu-delay 0 -no-boot-anim -cache /tmp/cache -avd ${avd_list[$avd_id]} 1> /dev/null 2>&1 &
+ fi
+
+}
+
+function clean {
+ ant clean
+}
+# has to be used independently and not in conjunction with other commands
+function log {
+ adb logcat
+}
+
+function run {
+ clean && emulate && wait_for_device && install && launch
+}
+
+function install {
+
+ declare -a devices=($(adb devices | awk '/List of devices attached/ { while(getline > 0) { print }}' | grep device | cut -f 1))
+ local device_id="1000" #FIXME: hopefully user does not have 1000 AVDs
+
+ if [ ${#devices[@]} == 0 ]
+ then
+ # should not reach here. Emulator should launch or device should be attached
+ echo "Emulator not running or device not attached. Could not install debug package"
+ exit 70
+ fi
+
+ if [ ${#devices[@]} == 1 ]
+ then
+ export ANDROID_SERIAL=${devices[0]}
+ # User has more than 1 AVD
+ elif [ ${#devices[@]} -gt 1 ]
+ then
+ while [ -z ${devices[$device_id]} ]
+ do
+ echo "Choose from one of the following devices/emulators [0 to $((${#devices[@]}-1))]:"
+ for(( i = 0 ; i < ${#devices[@]} ; i++ ))
+ do
+ echo "$i) ${devices[$i]}"
+ done
+ read -t 5 -p "> " device_id
+ # default value if input timeout
+ if [ $device_id -eq 1000 ] ; then device_id=0 ; fi
+ done
+ export ANDROID_SERIAL=${devices[$device_id]}
+ fi
+
+ ant debug install
+}
+
+function build {
+ ant debug
+}
+
+function release {
+ ant release
+}
+
+function wait_for_device {
+ local i="0"
+ echo -n "Waiting for device..."
+
+ while [ $i -lt 300 ]
+ do
+ if [ $(check_devices) -eq 0 ]
+ then
+ break
+ else
+ sleep 1
+ i=$[i+1]
+ echo -n "."
+ fi
+ done
+ # Device timeout: emulator has not started in time or device not attached
+ if [ $i -eq 300 ]
+ then
+ echo "device timeout!"
+ exit 69
+ else
+ echo "connected!"
+ fi
+}
+
+function launch {
+ local launch_str=$(java -jar "$PROJECT_PATH"/cordova/appinfo.jar "$PROJECT_PATH"/AndroidManifest.xml)
+ adb shell am start -n $launch_str
+}
+
+# TODO parse arguments
+(cd "$PROJECT_PATH" && $1)
View
24 android/cordova/log
@@ -0,0 +1,24 @@
+# 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.
+
+#!/bin/bash
+
+set -e
+
+CORDOVA_PATH=$( cd "$( dirname "$0" )/.." && pwd )
+
+bash "$CORDOVA_PATH"/cordova/cordova log
View
24 android/cordova/release
@@ -0,0 +1,24 @@
+# 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.
+
+#!/bin/bash
+
+set -e
+
+CORDOVA_PATH=$( cd "$( dirname "$0" )" && pwd )
+
+bash "$CORDOVA_PATH"/cordova release
View
24 android/cordova/run
@@ -0,0 +1,24 @@
+# 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.
+
+#!/bin/bash
+
+set -e
+
+CORDOVA_PATH=$( cd "$( dirname "$0" )" && pwd )
+
+bash "$CORDOVA_PATH"/cordova run
View
BIN android/libs/cordova-2.3.0.jar
Binary file not shown.
View
BIN android/libs/cordova-2.5.0.jar
Binary file not shown.
View
20 android/proguard-project.txt
@@ -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 *;
+#}
View
12 android/res/layout/main.xml
@@ -3,9 +3,11 @@
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
- >
- <WebView android:id="@+id/appView"
- android:layout_height="fill_parent"
- android:layout_width="fill_parent"
- />
+ >
+<TextView
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="Hello World, ReaderDemo"
+ />
</LinearLayout>
+
View
51 android/res/xml/config.xml
@@ -1,28 +1,31 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version='1.0' encoding='utf-8'?>
<cordova>
- <access uri="*" subdomains="true" />
- <log level="DEBUG"/>
- <preference name="useBrowserHistory" value="true"/>
- <preference name="exit-on-suspend" value="false"/>
+ <access origin="http://127.0.0.1*" />
+ <access origin=".*" />
+ <content src="index.html" />
+ <log level="DEBUG" />
+ <preference name="useBrowserHistory" value="true" />
+ <preference name="exit-on-suspend" value="false" />
<plugins>
- <plugin name="App" value="org.apache.cordova.App"/>
- <plugin name="Geolocation" value="org.apache.cordova.GeoBroker"/>
- <plugin name="Device" value="org.apache.cordova.Device"/>
- <plugin name="Accelerometer" value="org.apache.cordova.AccelListener"/>
- <plugin name="Compass" value="org.apache.cordova.CompassListener"/>
- <plugin name="Media" value="org.apache.cordova.AudioHandler"/>
- <plugin name="Camera" value="org.apache.cordova.CameraLauncher"/>
- <plugin name="Contacts" value="org.apache.cordova.ContactManager"/>
- <plugin name="File" value="org.apache.cordova.FileUtils"/>
- <plugin name="NetworkStatus" value="org.apache.cordova.NetworkManager"/>
- <plugin name="Notification" value="org.apache.cordova.Notification"/>
- <plugin name="Storage" value="org.apache.cordova.Storage"/>
- <plugin name="FileTransfer" value="org.apache.cordova.FileTransfer"/>
- <plugin name="Capture" value="org.apache.cordova.Capture"/>
- <plugin name="Battery" value="org.apache.cordova.BatteryListener"/>
- <plugin name="SplashScreen" value="org.apache.cordova.SplashScreen"/>
- <plugin name="Echo" value="org.apache.cordova.Echo"/>
- <plugin name="Globalization" value="org.apache.cordova.Globalization"/>
- <plugin name="NfcPlugin" value="com.chariotsolutions.nfc.plugin.NfcPlugin"/>
+ <plugin name="App" value="org.apache.cordova.App" />
+ <plugin name="Geolocation" value="org.apache.cordova.GeoBroker" />
+ <plugin name="Device" value="org.apache.cordova.Device" />
+ <plugin name="Accelerometer" value="org.apache.cordova.AccelListener" />
+ <plugin name="Compass" value="org.apache.cordova.CompassListener" />
+ <plugin name="Media" value="org.apache.cordova.AudioHandler" />
+ <plugin name="Camera" value="org.apache.cordova.CameraLauncher" />
+ <plugin name="Contacts" value="org.apache.cordova.ContactManager" />
+ <plugin name="File" value="org.apache.cordova.FileUtils" />
+ <plugin name="NetworkStatus" value="org.apache.cordova.NetworkManager" />
+ <plugin name="Notification" value="org.apache.cordova.Notification" />
+ <plugin name="Storage" value="org.apache.cordova.Storage" />
+ <plugin name="FileTransfer" value="org.apache.cordova.FileTransfer" />
+ <plugin name="Capture" value="org.apache.cordova.Capture" />
+ <plugin name="Battery" value="org.apache.cordova.BatteryListener" />
+ <plugin name="SplashScreen" value="org.apache.cordova.SplashScreen" />
+ <plugin name="Echo" value="org.apache.cordova.Echo" />
+ <plugin name="Globalization" value="org.apache.cordova.Globalization" />
+ <plugin name="InAppBrowser" value="org.apache.cordova.InAppBrowser" />
+ <plugin name="NfcPlugin" value="com.chariotsolutions.nfc.plugin.NfcPlugin" />
</plugins>
</cordova>
View
49 android/src/com/chariotsolutions/nfc/demo/reader/ReaderDemo.java
@@ -1,13 +1,36 @@
-package com.chariotsolutions.nfc.demo.reader;
-
-import org.apache.cordova.*;
-import android.os.Bundle;
-
-public class ReaderDemo extends DroidGap {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- super.loadUrl("file:///android_asset/www/index.html");
- }
-}
+/*
+ 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.chariotsolutions.nfc.demo.reader;
+
+import android.os.Bundle;
+import org.apache.cordova.*;
+
+public class ReaderDemo extends DroidGap
+{
+ @Override
+ public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ // Set by <content src="index.html" /> in config.xml
+ super.loadUrl(Config.getStartUrl());
+ //super.loadUrl("file:///android_asset/www/index.html")
+ }
+}
+
View
0 www/master.css → www/css/index.css
File renamed without changes.
View
11 www/index.html
@@ -4,7 +4,7 @@
<meta name="viewport" content="width=320, user-scalable=no" />
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<title>NFC Reader Demo</title>
-<link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title" charset="utf-8">
+<link rel="stylesheet" href="css/index.css" type="text/css" media="screen" title="no title" charset="utf-8">
</head>
<body>
@@ -67,15 +67,12 @@
{{/each}}
</script>
- <!-- <script src="http://debug.phonegap.com/target/target-script-min.js#wtmf"></script> -->
- <script src="http://192.168.1.9:8080/target/target-script-min.js#anonymous"></script>
- <script type="text/javascript" charset="utf-8" src="cordova-2.3.0.js"></script>
+ <script type="text/javascript" charset="utf-8" src="cordova-2.5.0.js"></script>
+ <script type="text/javascript" charset="utf-8" src="js/phonegap-nfc-0.4.3-SNAPSHOT.js"></script>
<script type="text/javascript" charset="utf-8" src="js/handlebars.js"></script>
- <script type="text/javascript" charset="utf-8" src="phonegap-nfc-0.4.3-SNAPSHOT.js"></script>
- <script type="text/javascript" charset="utf-8" src="main.js"></script>
+ <script type="text/javascript" charset="utf-8" src="js/index.js"></script>
<script type="text/javascript">
app.initialize();
</script>
- </script>
</body>
</html>
View
0 www/main.js → www/js/index.js
File renamed without changes.
View
0 www/phonegap-nfc-0.4.3-SNAPSHOT.js → www/js/phonegap-nfc-0.4.3-SNAPSHOT.js
File renamed without changes.

0 comments on commit bb0201e

Please sign in to comment.