Fixes for Android

This commit is contained in:
Gabriel Calero 2018-01-04 17:36:10 -03:00
parent 32494a8e24
commit 8cac98545a
4 changed files with 37 additions and 20 deletions

View file

@ -63,8 +63,6 @@
</activity>
</application>
<!-- Tell the system this app requires OpenGL ES 3.0. -->
<uses-feature android:glEsVersion="0x00030000" android:required="true" />
<uses-feature android:name="android.software.vr.mode" android:required="true"/>
<uses-feature android:name="android.hardware.vr.high_performance" android:required="true"/>

View file

@ -457,9 +457,7 @@ task cleanDependencies(type: Delete) {
task generateAssetsFileList() {
doLast {
def assetsPath = "${appDir}/src/main/assets/"
//def assetsPath = "/Users/cduarte/dev/workspace-hifi/hifiparallel/build_android_hifiqt59/interface/apk/assets/"
def addedByAndroidDeployQtName = "--Added-by-androiddeployqt--/"
//def addedByAndroidDeployQtName = "--Added-by-androiddeployqt--/"
def addedByAndroidDeployQtPath = assetsPath + addedByAndroidDeployQtName
@ -468,7 +466,6 @@ task generateAssetsFileList() {
throw new GradleScriptException("Failed to create directory " + addedByAndroidDeployQtPath, null);
}
def outputFilename = "/qt_cache_pregenerated_file_list"
//def outputFilename = "/qt_cache_pregenerated_file_list2"
def outputFile = new File(addedByAndroidDeployQtPath + outputFilename);
Map<String, List<String>> directoryContents = new TreeMap<>();
@ -483,10 +480,6 @@ task generateAssetsFileList() {
fileName += "/"
}
/*println ("full: [" + file.getAbsolutePath() + "]\n\t"
+ "path: [" + pathName + "]\n\t"
+ "name: [" + fileName + "]\n\t");*/
if (!directoryContents.containsKey(pathName)) {
directoryContents[pathName] = new ArrayList<String>()
}
@ -497,16 +490,12 @@ task generateAssetsFileList() {
DataOutputStream fos = new DataOutputStream(new FileOutputStream(outputFile));
for (Map.Entry<String, List<String>> e: directoryContents.entrySet()) {
def entryList = e.getValue()
//stream << it.key() << entryList.size();
fos.writeInt(e.key.length()*2); // 2 bytes per char
fos.writeChars(e.key);
fos.writeInt(entryList.size());
//println ("dir: " + e.key + " size: " + entryList.size());
for (String entry: entryList) {
fos.writeInt(entry.length()*2);
fos.writeChars(entry);
//println("\tentry: " + entry);
//stream << entry;
}
}
fos.close();

View file

@ -12,7 +12,7 @@ function(JOIN VALUES GLUE OUTPUT)
endfunction()
if ANDROID OR (NOT DEV_BUILD)
if (ANDROID OR NOT DEV_BUILD)
set(INTERFACE_QML_QRC ${CMAKE_CURRENT_BINARY_DIR}/qml.qrc)
generate_qrc(OUTPUT ${INTERFACE_QML_QRC} PATH ${CMAKE_CURRENT_SOURCE_DIR}/resources GLOBS *.qml *.qss *.js *.html *.ttf *.gif *.svg *.png *.jpg)
endif()
@ -82,7 +82,7 @@ qt5_wrap_ui(QT_UI_HEADERS "${QT_UI_FILES}")
# add them to the interface source files
set(INTERFACE_SRCS ${INTERFACE_SRCS} "${QT_UI_HEADERS}" "${QT_RESOURCES}")
if (NOT DEV_BUILD)
if (ANDROID OR NOT DEV_BUILD)
list(APPEND INTERFACE_SRCS ${INTERFACE_QML_QRC})
endif()
@ -267,6 +267,8 @@ include_directories("${PROJECT_SOURCE_DIR}/src")
if (ANDROID)
#set(ANDROID_PLATFORM_QT_LIBRARIES Qt5::WebView)
find_library(ANDROID_LOG_LIB log)
target_link_libraries(${TARGET_NAME} ${ANDROID_LOG_LIB})
else()
set(NON_ANDROID_PLATFORM_QT_LIBRARIES Qt5::WebEngine)
endif ()

View file

@ -212,6 +212,7 @@
#include "webbrowser/WebBrowserSuggestionsEngine.h"
#ifdef ANDROID
#include <QtAndroidExtras/QAndroidJniObject>
#include <android/log.h>
#endif
// On Windows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU
// FIXME seems to be broken.
@ -556,7 +557,34 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt
if (!logMessage.isEmpty()) {
#ifdef Q_OS_WIN
OutputDebugStringA(logMessage.toLocal8Bit().constData());
OutputDebugStringA("\n");
OutputDebugStringA("\n");i
#elif defined Q_OS_ANDROID
QString report=message;
if (context.file && !QString(context.file).isEmpty()) {
report+=" at ";
report+=QString(context.file);
report+=" : ";
report+=QString::number(context.line);
}
const char*const local=report.toLocal8Bit().constData();
switch (type) {
case QtDebugMsg:
__android_log_write(ANDROID_LOG_DEBUG,"Interface",local);
break;
case QtInfoMsg:
__android_log_write(ANDROID_LOG_INFO,"Interface",local);
break;
case QtWarningMsg:
__android_log_write(ANDROID_LOG_WARN,"Interface",local);
break;
case QtCriticalMsg:
__android_log_write(ANDROID_LOG_ERROR,"Interface",local);
break;
case QtFatalMsg:
default:
__android_log_write(ANDROID_LOG_FATAL,"Interface",local);
abort();
}
#endif
qApp->getLogger()->addMessage(qPrintable(logMessage + "\n"));
}
@ -845,10 +873,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
#endif
_logger = new FileLogger(this);
#ifndef Q_OS_ANDROID
// this prevents using logcat
qInstallMessageHandler(messageHandler);
#endif
QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "styles/Inconsolata.otf");
_window->setWindowTitle("High Fidelity Interface");
@ -2344,8 +2369,11 @@ void Application::initializeUi() {
offscreenUi->setProxyWindow(_window->windowHandle());
// OffscreenUi is a subclass of OffscreenQmlSurface specifically designed to
// support the window management and scripting proxies for VR use
#ifndef Q_OS_ANDROID
offscreenUi->createDesktop(QString("hifi/Desktop.qml"));
#else
offscreenUi->createDesktop(QString("qrc:///qml/hifi/Desktop.qml"));
#endif
// FIXME either expose so that dialogs can set this themselves or
// do better detection in the offscreen UI of what has focus
offscreenUi->setNavigationFocused(false);