Merge remote-tracking branch 'gcgithub/android_goto_splash' into android_places_goto

This commit is contained in:
Cristian Luis Duarte 2018-04-19 12:11:29 -03:00
commit 5be9959424
13 changed files with 36 additions and 64 deletions

View file

@ -1,7 +1,7 @@
{
"hifi_domains" : [
{
"name": "You last location",
"name": "Your last location",
"url": "",
"thumbnail": ""
},

View file

@ -202,7 +202,7 @@ public class InterfaceActivity extends QtActivity {
public void openGotoActivity(String activityName) {
switch (activityName) {
case "Goto": {
case "Home": {
Intent intent = new Intent(this, HomeActivity.class);
startActivity(intent);
break;

View file

@ -15,7 +15,6 @@
#include <QObject>
#include <QThread>
#include <AccountManager.h>
#include <QtAndroidExtras/QAndroidJniObject>
class AndroidHelper : public QObject {
Q_OBJECT

View file

@ -7866,71 +7866,29 @@ void Application::saveNextPhysicsStats(QString filename) {
void Application::openAndroidActivity(const QString& activityName) {
#if defined(Q_OS_ANDROID)
qDebug() << "[Background-HIFI] Application::openAndroidActivity";
//getActiveDisplayPlugin()->deactivate();
AndroidHelper::instance().requestActivity(activityName);
connect(&AndroidHelper::instance(), &AndroidHelper::backFromAndroidActivity, this, &Application::restoreAfterAndroidActivity);
#endif
}
void Application::restoreAfterAndroidActivity() {
#if defined(Q_OS_ANDROID)
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<AudioClient>().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<AudioClient>()) {
qDebug() << "[Background-HIFI] audioclient.start()";
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(),
"start", Qt::BlockingQueuedConnection);
} else {
qDebug() << "[Background-HIFI] audioclient.start() not done";
qDebug() << "Could not start AudioClient";
}
if (!getActiveDisplayPlugin() || !getActiveDisplayPlugin()->activate()) {
qWarning() << "[Background-HIFI] Could not re-activate display plugin";
qWarning() << "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();
}
}
}
#include "Application_jni.cpp"
#endif

View file

@ -459,8 +459,6 @@ private slots:
void handleSandboxStatus(QNetworkReply* reply);
void switchDisplayMode();
void restoreAfterAndroidActivity();
private:
static void initDisplay();
void init();

View file

@ -0,0 +1,18 @@
extern "C" {
JNIEXPORT void
Java_io_highfidelity_hifiinterface_InterfaceActivity_nativeEnterBackground(JNIEnv *env, jobject obj) {
if (qApp) {
qApp->enterBackground();
}
}
JNIEXPORT void
Java_io_highfidelity_hifiinterface_InterfaceActivity_nativeEnterForeground(JNIEnv *env, jobject obj) {
if (qApp) {
qApp->enterForeground();
}
}
}

View file

@ -15,7 +15,6 @@ import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.WindowManager;
import android.util.Log;
import org.qtproject.qt5.android.bindings.QtActivity;
public class InterfaceActivity extends QtActivity {

View file

@ -38,7 +38,7 @@ function init() {
}
function onBackPressed() {
App.openAndroidActivity("Goto");
App.openAndroidActivity("Home");
}

View file

@ -34,7 +34,7 @@ function fromQml(message) { // messages are {method, params}, like json-rpc. See
module.exports.onHidden();
break;
case 'openAndroidActivity':
App.openAndroidActivity("Goto");
App.openAndroidActivity("Home");
break;
default:
print('[goto-android.js] Unrecognized message from AddressBarDialog.qml:', JSON.stringify(message));