• Skip to content
  • Skip to link menu
KDE API Documentation - ApplicationAndroid.cpp Source File (GCompris-qt)
  • KDE Home
  • Contact Us
 

GCompris-qt

  • src
  • core
ApplicationAndroid.cpp
1 /* GCompris - ApplicationSettingsAndroid.cpp
2  *
3  * Copyright (C) 2014 Bruno Coudoin <bruno.coudoin@gcompris.net>
4  *
5  * Authors:
6  * Bruno Coudoin <bruno.coudoin@gcompris.net>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #include "ApplicationSettings.h"
23 #include "ApplicationInfo.h"
24 #include <QtAndroidExtras/QAndroidJniObject>
25 #include <QDebug>
26 
27 void ApplicationSettings::setDemoMode(const bool newDemoMode)
28 {
29  if(!newDemoMode) {
30  // Call Google play store
31  QAndroidJniObject::callStaticMethod<void>("net/gcompris/GComprisActivity",
32  "buyGCompris");
33  } else {
34  // Going back to demo mode, should never happens except for testing
35  ApplicationSettings::getInstance()->bought(false);
36  }
37 }
38 
39 void ApplicationSettings::checkPayment() {
40 #if defined(WITH_ACTIVATION_CODE)
41  QAndroidJniObject::callStaticMethod<void>("net/gcompris/GComprisActivity",
42  "checkPayment");
43 #endif
44 }
45 
46 static void bought(JNIEnv *, jclass /*clazz*/, jboolean b)
47 {
48  ApplicationSettings::getInstance()->bought(b);
49 }
50 
51 static JNINativeMethod methods[] = {
52  {"bought", "(Z)V", (void *)bought}
53 };
54 
55 bool ApplicationInfo::requestAudioFocus() const
56 {
57  qDebug() << "requestAudioFocus";
58  return QAndroidJniObject::callStaticMethod<jboolean>("net/gcompris/GComprisActivity",
59  "requestAudioFocus");
60 }
61 
62 void ApplicationInfo::abandonAudioFocus() const
63 {
64  QAndroidJniObject::callStaticMethod<void>("net/gcompris/GComprisActivity",
65  "abandonAudioFocus");
66 }
67 
68 jint JNICALL JNI_OnLoad(JavaVM *vm, void *)
69 {
70  JNIEnv *env;
71  if (vm->GetEnv(reinterpret_cast<void **>(&env), JNI_VERSION_1_4) != JNI_OK)
72  return JNI_FALSE;
73 
74  jclass clazz = env->FindClass("net/gcompris/GComprisActivity");
75  if (env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])) < 0)
76  return JNI_FALSE;
77 
78  return JNI_VERSION_1_4;
79 }
ApplicationInfo::requestAudioFocus
Q_INVOKABLE bool requestAudioFocus() const
Request GCompris to take the Audio Focus at the system level.
Definition: ApplicationAndroid.cpp:55
ApplicationInfo::abandonAudioFocus
Q_INVOKABLE void abandonAudioFocus() const
Abandon the Audio Focus.
Definition: ApplicationAndroid.cpp:62
This file is part of the KDE documentation.
Documentation copyright © 1996-2015 The KDE developers.
Generated on Tue Jun 2 2015 21:47:47 by doxygen 1.8.9.1 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

GCompris-qt

Skip menu "GCompris-qt"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • File List
  • Modules

Class Picker

Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal