diff --git a/android/app/src/main/java/io/highfidelity/hifiinterface/InterfaceActivity.java b/android/app/src/main/java/io/highfidelity/hifiinterface/InterfaceActivity.java
index 93d6725994..812252663a 100644
--- a/android/app/src/main/java/io/highfidelity/hifiinterface/InterfaceActivity.java
+++ b/android/app/src/main/java/io/highfidelity/hifiinterface/InterfaceActivity.java
@@ -41,8 +41,8 @@ public class InterfaceActivity extends QtActivity {
private native void nativeOnDestroy();
private native void nativeGotoUrl(String url);
private native void nativeGoBackFromAndroidActivity();
- //private native void nativeOnStop();
- //private native void nativeOnStart();
+ private native void nativeEnterBackground();
+ private native void nativeEnterForeground();
//private native void saveRealScreenSize(int width, int height);
//private native void setAppVersion(String version);
private native long nativeOnExitVr();
@@ -124,14 +124,13 @@ public class InterfaceActivity extends QtActivity {
@Override
protected void onStart() {
super.onStart();
-// nativeOnStart();
+ nativeEnterForeground();
}
@Override
protected void onStop() {
- Log.d("[Background]","Calling nativeOnStop from InterfaceActivity");
-// nativeOnStop();
super.onStop();
+ nativeEnterBackground();
}
@Override
diff --git a/interface/resources/icons/+android/backward.svg b/interface/resources/icons/+android/backward.svg
old mode 100644
new mode 100755
index ae0893fc66..ad102b886e
--- a/interface/resources/icons/+android/backward.svg
+++ b/interface/resources/icons/+android/backward.svg
@@ -1,70 +1,15 @@
-
-
-
-
\ No newline at end of file
+
+
+
diff --git a/interface/resources/icons/+android/myview-a.svg b/interface/resources/icons/+android/myview-a.svg
index 307b559c95..9964678074 100755
--- a/interface/resources/icons/+android/myview-a.svg
+++ b/interface/resources/icons/+android/myview-a.svg
@@ -1,56 +1,19 @@
-
-
-
-
\ No newline at end of file
+
+
+
diff --git a/interface/resources/qml/hifi/+android/ActionBar.qml b/interface/resources/qml/hifi/+android/ActionBar.qml
new file mode 100644
index 0000000000..7152c829bc
--- /dev/null
+++ b/interface/resources/qml/hifi/+android/ActionBar.qml
@@ -0,0 +1,71 @@
+import QtQuick 2.5
+import QtQuick.Controls 1.4
+import QtQuick.Controls.Styles 1.4
+import QtQuick.Layouts 1.3
+import Qt.labs.settings 1.0
+import "../../styles-uit"
+import "../../controls-uit" as HifiControlsUit
+import "../../controls" as HifiControls
+import ".."
+
+Item {
+ id: actionBar
+ x:0
+ y:0
+ width: 300
+ height: 300
+ z: -1
+
+ signal sendToScript(var message);
+ signal windowClosed();
+
+ property bool shown: true
+
+ onShownChanged: {
+ actionBar.visible = shown;
+ }
+
+ Rectangle {
+ anchors.fill : parent
+ color: "transparent"
+ Flow {
+ id: flowMain
+ spacing: 10
+ flow: Flow.TopToBottom
+ layoutDirection: Flow.TopToBottom
+ anchors.fill: parent
+ anchors.margins: 4
+ }
+ }
+
+ Component.onCompleted: {
+ // put on bottom
+ x = 50;
+ y = 0;
+ width = 300;
+ height = 300;
+ }
+
+ function addButton(properties) {
+ var component = Qt.createComponent("button.qml");
+ if (component.status == Component.Ready) {
+ var button = component.createObject(flowMain);
+ // copy all properites to button
+ var keys = Object.keys(properties).forEach(function (key) {
+ button[key] = properties[key];
+ });
+ return button;
+ } else if( component.status == Component.Error) {
+ console.log("Load button errors " + component.errorString());
+ }
+ }
+
+ function urlHelper(src) {
+ if (src.match(/\bhttp/)) {
+ return src;
+ } else {
+ return "../../../" + src;
+ }
+ }
+
+}
diff --git a/interface/resources/qml/hifi/+android/AudioBar.qml b/interface/resources/qml/hifi/+android/AudioBar.qml
index f524595ef5..a6d4e28813 100644
--- a/interface/resources/qml/hifi/+android/AudioBar.qml
+++ b/interface/resources/qml/hifi/+android/AudioBar.qml
@@ -40,7 +40,7 @@ Item {
Component.onCompleted: {
// put on bottom
- x = 0;
+ x = parent.width-300;
y = 0;
width = 300;
height = 300;
diff --git a/interface/resources/qml/hifi/+android/modesbar.qml b/interface/resources/qml/hifi/+android/modesbar.qml
index fe71314ece..451921f155 100644
--- a/interface/resources/qml/hifi/+android/modesbar.qml
+++ b/interface/resources/qml/hifi/+android/modesbar.qml
@@ -10,7 +10,7 @@ import ".."
Item {
id: modesbar
- y:60
+ y:20
Rectangle {
anchors.fill : parent
color: "transparent"
@@ -25,9 +25,9 @@ Item {
}
Component.onCompleted: {
- width = 300 + 30; // That 30 is extra regardless the qty of items shown
- height = 300 + 30;
- x=Window.innerWidth - width;
+ width = 300; // That 30 is extra regardless the qty of items shown
+ height = 300;
+ x=parent.width - 540;
}
function addButton(properties) {
diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp
index e943157954..80775e1930 100644
--- a/interface/src/Application.cpp
+++ b/interface/src/Application.cpp
@@ -242,6 +242,7 @@ extern "C" {
#if defined(Q_OS_ANDROID)
#include
+#include
#endif
enum ApplicationEvent {
@@ -7870,7 +7871,8 @@ void Application::saveNextPhysicsStats(QString filename) {
void Application::openAndroidActivity(const QString& activityName) {
#if defined(Q_OS_ANDROID)
- getActiveDisplayPlugin()->deactivate();
+ qDebug() << "[Background-HIFI] Application::openAndroidActivity";
+ //getActiveDisplayPlugin()->deactivate();
AndroidHelper::instance().requestActivity(activityName);
connect(&AndroidHelper::instance(), &AndroidHelper::backFromAndroidActivity, this, &Application::restoreAfterAndroidActivity);
#endif
@@ -7878,11 +7880,63 @@ void Application::openAndroidActivity(const QString& activityName) {
void Application::restoreAfterAndroidActivity() {
#if defined(Q_OS_ANDROID)
- if (!getActiveDisplayPlugin() || !getActiveDisplayPlugin()->activate()) {
+ qDebug() << "[Background-HIFI] restoreAfterAndroidActivity: this wouldn't be needed";
+
+ /*if (!getActiveDisplayPlugin() || !getActiveDisplayPlugin()->activate()) {
qWarning() << "Could not re-activate display plugin";
- }
+ }*/
disconnect(&AndroidHelper::instance(), &AndroidHelper::backFromAndroidActivity, this, &Application::restoreAfterAndroidActivity);
#endif
}
+#if defined(Q_OS_ANDROID)
+void Application::enterBackground() {
+ qDebug() << "[Background-HIFI] enterBackground begin";
+ QMetaObject::invokeMethod(DependencyManager::get().data(),
+ "stop", Qt::BlockingQueuedConnection);
+ qDebug() << "[Background-HIFI] deactivating display plugin";
+ getActiveDisplayPlugin()->deactivate();
+ qDebug() << "[Background-HIFI] enterBackground end";
+}
+void Application::enterForeground() {
+ qDebug() << "[Background-HIFI] enterForeground qApp?" << (qApp?"yeah":"false");
+ if (qApp && DependencyManager::isSet()) {
+ qDebug() << "[Background-HIFI] audioclient.start()";
+ QMetaObject::invokeMethod(DependencyManager::get().data(),
+ "start", Qt::BlockingQueuedConnection);
+ } else {
+ qDebug() << "[Background-HIFI] audioclient.start() not done";
+ }
+ if (!getActiveDisplayPlugin() || !getActiveDisplayPlugin()->activate()) {
+ qWarning() << "[Background-HIFI] Could not re-activate display plugin";
+ }
+
+}
+
+extern "C" {
+
+
+JNIEXPORT void
+Java_io_highfidelity_hifiinterface_InterfaceActivity_nativeEnterBackground(JNIEnv *env, jobject obj) {
+ qDebug() << "[Background-HIFI] nativeEnterBackground";
+ if (qApp) {
+ qDebug() << "[Background-HIFI] nativeEnterBackground begin (qApp)";
+ qApp->enterBackground();
+ }
+}
+
+JNIEXPORT void
+Java_io_highfidelity_hifiinterface_InterfaceActivity_nativeEnterForeground(JNIEnv *env, jobject obj) {
+ qDebug() << "[Background-HIFI] nativeEnterForeground";
+ if (qApp) {
+ qDebug() << "[Background-HIFI] nativeEnterForeground begin (qApp)";
+ qApp->enterForeground();
+ }
+}
+
+
+}
+
+#endif
+
#include "Application.moc"
diff --git a/interface/src/Application.h b/interface/src/Application.h
index ab55861930..ec49aa055f 100644
--- a/interface/src/Application.h
+++ b/interface/src/Application.h
@@ -292,6 +292,11 @@ public:
void replaceDomainContent(const QString& url);
+#if defined(Q_OS_ANDROID)
+ void enterBackground();
+ void enterForeground();
+#endif
+
signals:
void svoImportRequested(const QString& url);
diff --git a/scripts/+android/defaultScripts.js b/scripts/+android/defaultScripts.js
index 11aee6a9d2..98fbb4b1a7 100644
--- a/scripts/+android/defaultScripts.js
+++ b/scripts/+android/defaultScripts.js
@@ -14,7 +14,7 @@
var DEFAULT_SCRIPTS_COMBINED = [
"system/progress.js",
"system/+android/touchscreenvirtualpad.js",
- "system/+android/bottombar.js",
+ "system/+android/actionbar.js",
"system/+android/audio.js" ,
"system/+android/modes.js",
"system/+android/stats.js"/*,
diff --git a/scripts/system/+android/actionbar.js b/scripts/system/+android/actionbar.js
new file mode 100644
index 0000000000..9aed1e6cf9
--- /dev/null
+++ b/scripts/system/+android/actionbar.js
@@ -0,0 +1,53 @@
+"use strict";
+//
+// backbutton.js
+// scripts/system/+android
+//
+// Created by Gabriel Calero & Cristian Duarte on Apr 06, 2018
+// Copyright 2018 High Fidelity, Inc.
+//
+// Distributed under the Apache License, Version 2.0.
+// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
+//
+(function() { // BEGIN LOCAL_SCOPE
+
+var actionbar;
+var backButton;
+
+var logEnabled = true;
+
+function printd(str) {
+ if (logEnabled)
+ print("[actionbar.js] " + str);
+}
+
+function init() {
+ actionbar = new QmlFragment({
+ qml: "hifi/ActionBar.qml"
+ });
+ backButton = actionbar.addButton({
+ icon: "icons/+android/backward.svg",
+ activeIcon: "icons/+android/backward.svg",
+ text: "",
+ bgOpacity: 0.0,
+ activeBgOpacity: 0.0,
+ bgColor: "#FFFFFF"
+ });
+
+ backButton.clicked.connect(onBackPressed);
+}
+
+function onBackPressed() {
+ App.openAndroidActivity("Goto");
+}
+
+
+Script.scriptEnding.connect(function () {
+ if(backButton) {
+ backButton.clicked.disconnect(onBackPressed);
+ }
+});
+
+init();
+
+}()); // END LOCAL_SCOPE