diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 569526cdc702041de88b413a3fa191d74e991890..e7c50a83b8d721b42e05f4f950eccb239c39b13b 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -109,7 +109,6 @@ iOSBuild { BUNDLE.files = $$files($$PWD/ios/AppIcon*.png) $$PWD/ios/QGCLaunchScreen.xib QMAKE_BUNDLE_DATA += BUNDLE LIBS += -framework AVFoundation - OBJECTIVE_SOURCES += src/audio/QGCAudioWorker_iOS.mm #-- Info.plist (need an "official" one for the App Store) ForAppStore { message(App Store Build) @@ -365,6 +364,16 @@ HEADERS += \ src/ViewWidgets/ViewWidgetController.h \ } +iOSBuild { + OBJECTIVE_SOURCES += \ + src/audio/QGCAudioWorker_iOS.mm \ + src/MobileScreenMgr.mm \ +} +AndroidBuild { + SOURCES += src/MobileScreenMgr.cc \ +} + + SOURCES += \ src/audio/QGCAudioWorker.cpp \ src/CmdLineOptParser.cc \ diff --git a/src/MobileScreenMgr.cc b/src/MobileScreenMgr.cc new file mode 100644 index 0000000000000000000000000000000000000000..1945ab3d9e4db632cf930d698469979e1f61deb6 --- /dev/null +++ b/src/MobileScreenMgr.cc @@ -0,0 +1,38 @@ +/*===================================================================== + + QGroundControl Open Source Ground Control Station + + (c) 2009 - 2014 QGROUNDCONTROL PROJECT + + This file is part of the QGROUNDCONTROL project + + QGROUNDCONTROL is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + QGROUNDCONTROL is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with QGROUNDCONTROL. If not, see . + + ======================================================================*/ + +#include "MobileScreenMgr.h" + +#include +#include + +static const char* kJniClassName = "org/qgroundcontrol/qgchelper/UsbDeviceJNI"; + +void MobileScreenMgr::setKeepScreenOn(bool keepScreenOn) +{ + if (keepScreenOn) { + QAndroidJniObject::callStaticMethod(kJniClassName, "keepScreenOn", "()V"); + } else { + QAndroidJniObject::callStaticMethod(kJniClassName, "restoreScreenOn", "()V"); + } +} diff --git a/src/MobileScreenMgr.h b/src/MobileScreenMgr.h new file mode 100644 index 0000000000000000000000000000000000000000..3b019101d22e4a48d3bc4b2adb1de050ccccc4e7 --- /dev/null +++ b/src/MobileScreenMgr.h @@ -0,0 +1,36 @@ +/*===================================================================== + + QGroundControl Open Source Ground Control Station + + (c) 2009 - 2014 QGROUNDCONTROL PROJECT + + This file is part of the QGROUNDCONTROL project + + QGROUNDCONTROL is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + QGROUNDCONTROL is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with QGROUNDCONTROL. If not, see . + + ======================================================================*/ + +#ifndef MobileScreenMgr_H +#define MobileScreenMgr_H + +#ifdef __mobile__ +class MobileScreenMgr { + +public: + /// Turns on/off screen sleep on mobile devices + static void setKeepScreenOn(bool keepScreenOn); +}; +#endif + +#endif diff --git a/src/MobileScreenMgr.mm b/src/MobileScreenMgr.mm new file mode 100644 index 0000000000000000000000000000000000000000..50afcc96156f478660451cad4e5f356df88b30b5 --- /dev/null +++ b/src/MobileScreenMgr.mm @@ -0,0 +1,32 @@ +/*===================================================================== + + QGroundControl Open Source Ground Control Station + + (c) 2009 - 2014 QGROUNDCONTROL PROJECT + + This file is part of the QGROUNDCONTROL project + + QGROUNDCONTROL is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + QGROUNDCONTROL is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with QGROUNDCONTROL. If not, see . + + ======================================================================*/ + +#include "MobileScreenMgr.h" + +#import +#import + +void MobileScreenMgr::setKeepScreenOn(bool keepScreenOn) +{ + [[UIApplication sharedApplication] setIdleTimerDisabled: (keepScreenOn ? YES : NO)]; +} diff --git a/src/Vehicle/MultiVehicleManager.cc b/src/Vehicle/MultiVehicleManager.cc index 14523ff40bf1f9d7def42dc22f945196a2846a22..9f7a9a9dbf2fe1df6d79f47834bee3d642a19a9e 100644 --- a/src/Vehicle/MultiVehicleManager.cc +++ b/src/Vehicle/MultiVehicleManager.cc @@ -30,21 +30,16 @@ #include "UAS.h" #include "QGCApplication.h" -#include - -#if defined __android__ -#include -#include +#ifdef __mobile__ +#include "MobileScreenMgr.h" #endif +#include + QGC_LOGGING_CATEGORY(MultiVehicleManagerLog, "MultiVehicleManagerLog") const char* MultiVehicleManager::_gcsHeartbeatEnabledKey = "gcsHeartbeatEnabled"; -#if defined __android__ -static const char* kJniClassName = "org/qgroundcontrol/qgchelper/UsbDeviceJNI"; -#endif - MultiVehicleManager::MultiVehicleManager(QGCApplication* app) : QGCTool(app) , _activeVehicleAvailable(false) @@ -126,11 +121,11 @@ void MultiVehicleManager::_vehicleHeartbeatInfo(LinkInterface* link, int vehicle // Mark link as active link->setActive(true); -#if defined __android__ +#ifdef __mobile__ if(_vehicles.count() == 1) { - //-- Once a vehicle is connected, keep Android screen from going off + //-- Once a vehicle is connected, keep screen from going off qCDebug(MultiVehicleManagerLog) << "QAndroidJniObject::keepScreenOn"; - QAndroidJniObject::callStaticMethod(kJniClassName, "keepScreenOn", "()V"); + MobileScreenMgr::setKeepScreenOn(true); } #endif @@ -167,11 +162,11 @@ void MultiVehicleManager::_deleteVehiclePhase1(Vehicle* vehicle) emit parameterReadyVehicleAvailableChanged(false); emit vehicleRemoved(vehicle); -#if defined __android__ +#ifdef __mobile__ if(_vehicles.count() == 0) { - //-- Once no vehicles are connected, we no longer need to keep Android screen from going off + //-- Once no vehicles are connected, we no longer need to keep screen from going off qCDebug(MultiVehicleManagerLog) << "QAndroidJniObject::restoreScreenOn"; - QAndroidJniObject::callStaticMethod(kJniClassName, "restoreScreenOn", "()V"); + MobileScreenMgr::setKeepScreenOn(true); } #endif diff --git a/src/ui/preferences/MockLink.qml b/src/ui/preferences/MockLink.qml index c6e9aeeaef82494c8ce0836b8efb0d0abd327727..0f1e4a3ca87282b2c831a6b95d88c9cbe0020012 100644 --- a/src/ui/preferences/MockLink.qml +++ b/src/ui/preferences/MockLink.qml @@ -32,17 +32,19 @@ Rectangle { color: qgcPal.window anchors.fill: parent + readonly property real _margins: ScreenTools.defaultFontPixelHeight + QGCPalette { id: qgcPal; colorGroupEnabled: true } QGCFlickable { anchors.fill: parent - contentWidth: column.width - contentHeight: column.height + contentWidth: column.width + (_margins * 2) + contentHeight: column.height + (_margins * 2) clip: true Column { id: column - anchors.margins: ScreenTools.defaultFontPixelHeight + anchors.margins: _margins anchors.left: parent.left anchors.top: parent.top spacing: ScreenTools.defaultFontPixelHeight