diff --git a/src/androidextras/android/android.pri b/src/androidextras/android/android.pri new file mode 100644 index 0000000000000000000000000000000000000000..58693126028dc357a8b6dff5d200f036df1a822a --- /dev/null +++ b/src/androidextras/android/android.pri @@ -0,0 +1,4 @@ +SOURCES += \ + $$PWD/qandroidfunctions.cpp +HEADERS += \ + $$PWD/qandroidfunctions.h \ No newline at end of file diff --git a/src/androidextras/android/qandroidfunctions.cpp b/src/androidextras/android/qandroidfunctions.cpp new file mode 100644 index 0000000000000000000000000000000000000000..55bc50a8504cb9636c068aa9f3b65ed52894b24c --- /dev/null +++ b/src/androidextras/android/qandroidfunctions.cpp @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part 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$ +** +****************************************************************************/ + +#include "qandroidfunctions.h" + +#include <QtCore/private/qjnihelpers_p.h> + +QT_BEGIN_NAMESPACE + +/*! + \namespace QtAndroid + \inmodule QtAndroidExtras + \since 5.3 + \brief The QtAndroid namespace provides miscellaneous functions to aid Android development. + \inheaderfile QtAndroid +*/ + +/*! + \since 5.3 + \fn QAndroidJniObject QtAndroid::androidActivity() + + Returns a handle to this applications main Activity + + \sa QAndroidJniObject +*/ +QAndroidJniObject QtAndroid::androidActivity() +{ + return QtAndroidPrivate::activity(); +} + +QT_END_NAMESPACE diff --git a/src/androidextras/android/qandroidfunctions.h b/src/androidextras/android/qandroidfunctions.h new file mode 100644 index 0000000000000000000000000000000000000000..ffd7c3bcdb970f200a7fcdfc70e4d085eeac7c0a --- /dev/null +++ b/src/androidextras/android/qandroidfunctions.h @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part 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$ +** +****************************************************************************/ + +#ifndef QANDROIDFUNCTIONS_H +#define QANDROIDFUNCTIONS_H + +#if 0 +#pragma qt_class(QtAndroid) +#endif + +#include <QtAndroidExtras/qandroidextrasglobal.h> +#include <QtAndroidExtras/qandroidjniobject.h> + +QT_BEGIN_NAMESPACE + +namespace QtAndroid +{ + Q_ANDROIDEXTRAS_EXPORT QAndroidJniObject androidActivity(); +} + +QT_END_NAMESPACE + +#endif // QANDROIDFUNCTIONS_H diff --git a/src/androidextras/androidextras.pro b/src/androidextras/androidextras.pro index 24d43710ec1ef25e74d1ab5055c692d8f2fc9638..78bd8eb8a83b9c80a9eaffce5e9d3c19704af4a7 100644 --- a/src/androidextras/androidextras.pro +++ b/src/androidextras/androidextras.pro @@ -4,5 +4,7 @@ QMAKE_DOCS = \ $$PWD/doc/qtandroidextras.qdocconf QT -= gui QT += core-private + load(qt_module) include(jni/jni.pri) +include(android/android.pri) diff --git a/src/androidextras/doc/qtandroidextras.qdocconf b/src/androidextras/doc/qtandroidextras.qdocconf index c1f7806a16e7ffa9811783717a70a848547e4146..ab6b5d02af2d4cd0f14e3172240122aad760edac 100644 --- a/src/androidextras/doc/qtandroidextras.qdocconf +++ b/src/androidextras/doc/qtandroidextras.qdocconf @@ -1,5 +1,7 @@ include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) +Cpp.ignoretokens += Q_ANDROIDEXTRAS_EXPORT + project = QtAndroidExtras description = Qt Android Extras Reference Documentation url = http://qt-project.org/doc/qt-$QT_VER @@ -19,10 +21,10 @@ qhp.QtAndroidExtras.filterAttributes = qtandroidextras $QT_VERSION qtrefdoc qhp.QtAndroidExtras.customFilters.Qt.name = QtAndroidExtras $QT_VERSION qhp.QtAndroidExtras.customFilters.Qt.filterAttributes = qtandroidextras $QT_VERSION -qhp.QtAndroidExtras.subprojects = classes -qhp.QtAndroidExtras.subprojects.classes.title = C++ Classes +qhp.QtAndroidExtras.subprojects = classes examples +qhp.QtAndroidExtras.subprojects.classes.title = C++ Classes and Namespaces qhp.QtAndroidExtras.subprojects.classes.indexTitle = Qt Android Extras C++ Classes -qhp.QtAndroidExtras.subprojects.classes.selectors = class fake:headerfile +qhp.QtAndroidExtras.subprojects.classes.selectors = class function namespace fake:headerfile qhp.QtAndroidExtras.subprojects.classes.sortPages = true qhp.QtAndroidExtras.subprojects.examples.title = Examples qhp.QtAndroidExtras.subprojects.examples.indexTitle = Qt Android Extras Examples diff --git a/src/androidextras/doc/src/qtandroidextras-index.qdoc b/src/androidextras/doc/src/qtandroidextras-index.qdoc index 74ca2493b09855b45c6d8e4d621141622dd16f39..c9eaadb56855287c765111c3809b560b3d4b168d 100644 --- a/src/androidextras/doc/src/qtandroidextras-index.qdoc +++ b/src/androidextras/doc/src/qtandroidextras-index.qdoc @@ -50,7 +50,7 @@ Links to the API reference materials: \list - \li \l{Qt Android Extras C++ Classes}{C++ Classes} + \li \l{Qt Android Extras C++ Classes}{C++ Classes and Namespaces} \endlist \section1 Examples diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 94b6dd82c6761c262751f37764b76afc92f2b063..bf54603d28af500a93d579af1258b6219a3d08a0 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -2,4 +2,5 @@ TEMPLATE = subdirs SUBDIRS += \ cmake \ qandroidjnienvironment \ - qandroidjniobject + qandroidjniobject \ + qandroidfunctions diff --git a/tests/auto/qandroidfunctions/qandroidfunctions.pro b/tests/auto/qandroidfunctions/qandroidfunctions.pro new file mode 100644 index 0000000000000000000000000000000000000000..813b2147353199ffaee09a21c8d48289fab01cfa --- /dev/null +++ b/tests/auto/qandroidfunctions/qandroidfunctions.pro @@ -0,0 +1,4 @@ +CONFIG += testcase +TARGET = tst_qandroidfunctions +QT += testlib androidextras +SOURCES += tst_qandroidfunctions.cpp diff --git a/tests/auto/qandroidfunctions/tst_qandroidfunctions.cpp b/tests/auto/qandroidfunctions/tst_qandroidfunctions.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9f6bfd947b094032c51dc233199893f6332cbdf2 --- /dev/null +++ b/tests/auto/qandroidfunctions/tst_qandroidfunctions.cpp @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite 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$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include <QtAndroidExtras/QtAndroid> + +class tst_QAndroidFunctions : public QObject +{ + Q_OBJECT +private slots: + void testAndroidActivity(); +}; + +void tst_QAndroidFunctions::testAndroidActivity() +{ + QAndroidJniObject activity = QtAndroid::androidActivity(); + QVERIFY(activity.isValid()); + QVERIFY(activity.callMethod<jboolean>("isTaskRoot")); +} + +QTEST_APPLESS_MAIN(tst_QAndroidFunctions) + +#include "tst_qandroidfunctions.moc"