diff --git a/interface/resources/icons/+android/myview-a.svg b/interface/resources/icons/+android/myview-a.svg new file mode 100755 index 0000000000..307b559c95 --- /dev/null +++ b/interface/resources/icons/+android/myview-a.svg @@ -0,0 +1,56 @@ + + + +image/svg+xmlAsset 3 \ No newline at end of file diff --git a/interface/resources/icons/+android/myview-hover.svg b/interface/resources/icons/+android/myview-hover.svg new file mode 100755 index 0000000000..49656ad294 --- /dev/null +++ b/interface/resources/icons/+android/myview-hover.svg @@ -0,0 +1,54 @@ + + + +image/svg+xmlAsset 3 \ No newline at end of file diff --git a/interface/resources/icons/+android/myview-i.svg b/interface/resources/icons/+android/myview-i.svg new file mode 100755 index 0000000000..574f51c615 --- /dev/null +++ b/interface/resources/icons/+android/myview-i.svg @@ -0,0 +1,56 @@ + + + +image/svg+xmlAsset 3 \ No newline at end of file diff --git a/interface/resources/icons/+android/radar-a.svg b/interface/resources/icons/+android/radar-a.svg new file mode 100755 index 0000000000..e4b157f827 --- /dev/null +++ b/interface/resources/icons/+android/radar-a.svg @@ -0,0 +1 @@ +Asset 1 \ No newline at end of file diff --git a/interface/resources/icons/+android/radar-hover.svg b/interface/resources/icons/+android/radar-hover.svg new file mode 100755 index 0000000000..e4b157f827 --- /dev/null +++ b/interface/resources/icons/+android/radar-hover.svg @@ -0,0 +1 @@ +Asset 1 \ No newline at end of file diff --git a/interface/resources/icons/+android/radar-i.svg b/interface/resources/icons/+android/radar-i.svg new file mode 100755 index 0000000000..3994a775d3 --- /dev/null +++ b/interface/resources/icons/+android/radar-i.svg @@ -0,0 +1 @@ +Asset 1 \ No newline at end of file diff --git a/interface/resources/qml/hifi/+android/modesbar.qml b/interface/resources/qml/hifi/+android/modesbar.qml new file mode 100644 index 0000000000..8ce455c2c1 --- /dev/null +++ b/interface/resources/qml/hifi/+android/modesbar.qml @@ -0,0 +1,73 @@ +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: modesbar + y:60 + Rectangle { + anchors.fill : parent + color: "transparent" + Flow { + id: flowMain + spacing: 0 + flow: Flow.TopToBottom + layoutDirection: Flow.TopToBottom + anchors.fill: parent + anchors.margins: 4 + } + } + + Component.onCompleted: { + width = 330; + height = 330; + x=Window.innerWidth - width; + } + + function addButton(properties) { + var component = Qt.createComponent("button.qml"); + console.log("load button"); + if (component.status == Component.Ready) { + console.log("load button 2"); + 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 removeButton(name) { + } + + function urlHelper(src) { + if (src.match(/\bhttp/)) { + return src; + } else { + return "../../../" + src; + } + } + + function fromScript(message) { + switch (message.type) { + case "allButtonsShown": + modesbar.height = flowMain.children.length * 100 + 10; + break; + case "inactiveButtonsHidden": + modesbar.height = 100 + 10; + break; + default: + break; + } + } + +} diff --git a/scripts/+android/defaultScripts.js b/scripts/+android/defaultScripts.js index 2a4af9afbf..a61c205980 100644 --- a/scripts/+android/defaultScripts.js +++ b/scripts/+android/defaultScripts.js @@ -15,7 +15,8 @@ var DEFAULT_SCRIPTS_COMBINED = [ "system/progress.js", "system/+android/touchscreenvirtualpad.js", "system/+android/bottombar.js", - "system/+android/audio.js" /*, + "system/+android/audio.js" /, + "system/+android/modes.js"*, "system/away.js", "system/controllers/controllerDisplayManager.js", "system/controllers/handControllerGrabAndroid.js", diff --git a/scripts/system/+android/modes.js b/scripts/system/+android/modes.js new file mode 100644 index 0000000000..0be53c2fc4 --- /dev/null +++ b/scripts/system/+android/modes.js @@ -0,0 +1,187 @@ +"use strict"; +// +// modes.js +// scripts/system/ +// +// Created by Gabriel Calero & Cristian Duarte on Jan 23, 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 modesbar; +var modesButtons; +var currentSelectedBtn; + +var SETTING_CURRENT_MODE_KEY = 'Android/Mode'; +var MODE_VR = "VR", MODE_RADAR = "RADAR", MODE_MY_VIEW = "MY VIEW"; +var DEFAULT_MODE = MODE_RADAR; +var logEnabled = true; + +function printd(str) { + if (logEnabled) { + print("[modes.js] " + str); + } +} + +function init() { + setupModesBar(); +} + +function shutdown() { + +} + +function setupModesBar() { + + var bar = new QmlFragment({ + qml: "hifi/modesbar.qml" + }); + var buttonRadarMode = bar.addButton({ + icon: "icons/radar-i.svg", + activeIcon: "icons/radar-a.svg", + hoverIcon: "icons/radar-a.svg", + activeBgOpacity: 0.0, + hoverBgOpacity: 0.0, + activeHoverBgOpacity: 0.0, + text: "RADAR", + height:240, + bottomMargin: 6, + textSize: 45 + }); + var buttonMyViewMode = bar.addButton({ + icon: "icons/myview-i.svg", + activeIcon: "icons/myview-a.svg", + hoverIcon: "icons/myview-a.svg", + activeBgOpacity: 0.0, + hoverBgOpacity: 0.0, + activeHoverBgOpacity: 0.0, + text: "MY VIEW", + height: 240, + bottomMargin: 6, + textSize: 45 + }); + + modesButtons = [buttonRadarMode, buttonMyViewMode]; + + var mode = getCurrentModeSetting(); + + var buttonsRevealed = false; + bar.sendToQml({type: "inactiveButtonsHidden"}); + + modesbar = { + restoreMyViewButton: function() { + switchModeButtons(buttonMyViewMode); + saveCurrentModeSetting(MODE_MY_VIEW); + }, + sendToQml: function(o) { bar.sendToQml(o); }, + qmlFragment: bar + }; + + buttonRadarMode.clicked.connect(function() { + //if (connections.isVisible()) return; + saveCurrentModeSetting(MODE_RADAR); + printd("Radar clicked"); + onButtonClicked(buttonRadarMode, function() { + //radar.startRadarMode(); + }); + }); + buttonMyViewMode.clicked.connect(function() { + //if (connections.isVisible()) return; + saveCurrentModeSetting(MODE_MY_VIEW); + printd("My View clicked"); + onButtonClicked(buttonMyViewMode, function() { + if (currentSelectedBtn == buttonRadarMode) { + //radar.endRadarMode(); + } + }); + }); + + var savedButton; + if (mode == MODE_MY_VIEW) { + savedButton = buttonMyViewMode; + } else { + savedButton = buttonRadarMode; + } + printd("[MODE] previous mode " + mode); + + savedButton.clicked(); +} + +function saveCurrentModeSetting(mode) { + Settings.setValue(SETTING_CURRENT_MODE_KEY, mode); +} + +function getCurrentModeSetting(mode) { + return Settings.getValue(SETTING_CURRENT_MODE_KEY, DEFAULT_MODE); +} + +function showAllButtons() { + for (var i=0; i