summaryrefslogtreecommitdiffstats
path: root/src/android/nfc
diff options
context:
space:
mode:
authorPeter Rustler <peter.rustler@basyskom.com>2015-01-07 12:54:32 +0100
committerAlex Blasche <alexander.blasche@theqtcompany.com>2015-02-02 08:01:34 +0000
commitdc86d37695458b07fdf670863e9fedfa5bccea87 (patch)
treee604378f46dd16b29a3f790e8a8086be868567df /src/android/nfc
parent0b502a8e1a4e5c61e1136967dbeb02589f927f58 (diff)
Cleanup of directory structure and pro files for NFC for Android
After squashing the nfc related build files were in folder jar. This should be named nfc. Additionally the files in that folder became a cleanup and missing values in pro/pri/xml files were added. Change-Id: I2da12c516b3cce6c4f7a7c35b37316ed343a5782 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/android/nfc')
-rw-r--r--src/android/nfc/AndroidManifest.xml7
-rw-r--r--src/android/nfc/bundledjar.pro3
-rw-r--r--src/android/nfc/distributedjar.pro2
-rw-r--r--src/android/nfc/nfc.pri13
-rw-r--r--src/android/nfc/nfc.pro3
-rw-r--r--src/android/nfc/src/org/qtproject/qt5/android/nfc/QtNfc.java139
6 files changed, 167 insertions, 0 deletions
diff --git a/src/android/nfc/AndroidManifest.xml b/src/android/nfc/AndroidManifest.xml
new file mode 100644
index 00000000..2ba062ae
--- /dev/null
+++ b/src/android/nfc/AndroidManifest.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="org.qtproject.qt5.android.nfc"
+ android:versionCode="1"
+ android:versionName="1.0">
+ <supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
+</manifest>
diff --git a/src/android/nfc/bundledjar.pro b/src/android/nfc/bundledjar.pro
new file mode 100644
index 00000000..37f7fc82
--- /dev/null
+++ b/src/android/nfc/bundledjar.pro
@@ -0,0 +1,3 @@
+TARGET = QtNfc-bundled
+CONFIG += bundled_jar_file
+include(nfc.pri)
diff --git a/src/android/nfc/distributedjar.pro b/src/android/nfc/distributedjar.pro
new file mode 100644
index 00000000..ed65c50a
--- /dev/null
+++ b/src/android/nfc/distributedjar.pro
@@ -0,0 +1,2 @@
+TARGET = QtNfc
+include(nfc.pri)
diff --git a/src/android/nfc/nfc.pri b/src/android/nfc/nfc.pri
new file mode 100644
index 00000000..65f197ca
--- /dev/null
+++ b/src/android/nfc/nfc.pri
@@ -0,0 +1,13 @@
+CONFIG += java
+DESTDIR = $$[QT_INSTALL_PREFIX/get]/jar
+API_VERSION = android-10
+
+PATHPREFIX = $$PWD/src/org/qtproject/qt5/android/nfc
+
+JAVACLASSPATH += $$PWD/src/
+JAVASOURCES += \
+ $$PWD/src/org/qtproject/qt5/android/nfc/QtNfc.java
+
+# install
+target.path = $$[QT_INSTALL_PREFIX]/jar
+INSTALLS += target
diff --git a/src/android/nfc/nfc.pro b/src/android/nfc/nfc.pro
new file mode 100644
index 00000000..70373fe1
--- /dev/null
+++ b/src/android/nfc/nfc.pro
@@ -0,0 +1,3 @@
+TEMPLATE = subdirs
+SUBDIRS += bundledjar.pro distributedjar.pro
+
diff --git a/src/android/nfc/src/org/qtproject/qt5/android/nfc/QtNfc.java b/src/android/nfc/src/org/qtproject/qt5/android/nfc/QtNfc.java
new file mode 100644
index 00000000..bb1375ac
--- /dev/null
+++ b/src/android/nfc/src/org/qtproject/qt5/android/nfc/QtNfc.java
@@ -0,0 +1,139 @@
+/***************************************************************************
+**
+** Copyright (C) 2013 Centria research and development
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtNfc module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+package org.qtproject.qt5.android.nfc;
+
+import java.lang.Thread;
+import java.lang.Runnable;
+
+import android.os.Parcelable;
+import android.os.Looper;
+import android.content.Context;
+import android.app.Activity;
+import android.app.PendingIntent;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.nfc.NfcAdapter;
+import android.content.IntentFilter.MalformedMimeTypeException;
+import android.os.Bundle;
+//import android.util.Log;
+import android.content.BroadcastReceiver;
+
+public class QtNfc
+{
+ /* static final QtNfc m_nfc = new QtNfc(); */
+ static private final String TAG = "QtNfc";
+ static public NfcAdapter m_adapter = null;
+ static public PendingIntent m_pendingIntent = null;
+ static public IntentFilter[] m_filters;
+ static public Activity m_activity;
+
+ static public void setActivity(Activity activity, Object activityDelegate)
+ {
+ //Log.d(TAG, "setActivity " + activity);
+ m_activity = activity;
+ m_adapter = NfcAdapter.getDefaultAdapter(m_activity);
+ if (m_adapter == null) {
+ //Log.e(TAG, "No NFC available");
+ return;
+ }
+ m_pendingIntent = PendingIntent.getActivity(
+ m_activity,
+ 0,
+ new Intent(m_activity, m_activity.getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP),
+ 0);
+
+ //Log.d(TAG, "Pending intent:" + m_pendingIntent);
+
+ IntentFilter filter = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
+
+ m_filters = new IntentFilter[]{
+ filter
+ };
+
+ try {
+ filter.addDataType("*/*");
+ } catch(MalformedMimeTypeException e) {
+ throw new RuntimeException("Fail", e);
+ }
+
+ //Log.d(TAG, "Thread:" + Thread.currentThread().getId());
+ }
+
+ static public void start()
+ {
+ if (m_adapter == null) return;
+ m_activity.runOnUiThread(new Runnable() {
+ public void run() {
+ //Log.d(TAG, "Enabling NFC");
+ m_adapter.enableForegroundDispatch(m_activity, m_pendingIntent, null, null);
+ }
+ });
+ }
+
+ static public void stop()
+ {
+ if (m_adapter == null) return;
+ m_activity.runOnUiThread(new Runnable() {
+ public void run() {
+ //Log.d(TAG, "Disabling NFC");
+ m_adapter.disableForegroundDispatch(m_activity);
+ }
+ });
+ }
+
+ static public boolean isAvailable()
+ {
+ m_adapter = NfcAdapter.getDefaultAdapter(m_activity);
+ if (m_adapter == null) {
+ //Log.e(TAG, "No NFC available (Adapter is null)");
+ return false;
+ }
+ return m_adapter.isEnabled();
+ }
+
+ public static native void newIntent(Intent intent);
+
+ static public void onNewIntent(Intent intent)
+ {
+ newIntent(intent);
+ }
+}