working on pause -> away mode. Even doesn't seem to be firing. Also found a spot where I left commented out code from lifecycle testing.

This commit is contained in:
amer cerkic 2019-02-21 16:33:25 -08:00
parent 6f5d0b7191
commit 9097d9c57c
8 changed files with 34 additions and 9 deletions

View file

@ -61,7 +61,7 @@ extern "C" {
Java_io_highfidelity_oculus_OculusMobileActivity_nativeInitOculusPlatform(JNIEnv *env, jobject obj){ Java_io_highfidelity_oculus_OculusMobileActivity_nativeInitOculusPlatform(JNIEnv *env, jobject obj){
initOculusPlatform(env, obj); initOculusPlatform(env, obj);
} }
QAndroidJniObject __interfaceActivity; QAndroidJniObject __interfaceActivity;
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
Java_io_highfidelity_oculus_OculusMobileActivity_questNativeOnCreate(JNIEnv *env, jobject obj) { Java_io_highfidelity_oculus_OculusMobileActivity_questNativeOnCreate(JNIEnv *env, jobject obj) {
@ -80,6 +80,10 @@ QAndroidJniObject __interfaceActivity;
}); });
} }
JNIEXPORT void JNICALL
Java_io_highfidelity_oculus_OculusMobileActivity_questNativeAwayMode(JNIEnv *env, jobject obj) {
AndroidHelper::instance().toggleAwayMode();
}
JNIEXPORT void Java_io_highfidelity_oculus_OculusMobileActivity_questOnAppAfterLoad(JNIEnv* env, jobject obj) { JNIEXPORT void Java_io_highfidelity_oculus_OculusMobileActivity_questOnAppAfterLoad(JNIEnv* env, jobject obj) {

View file

@ -34,6 +34,7 @@ public class OculusMobileActivity extends QtActivity implements SurfaceHolder.Ca
private native void questNativeOnResume(); private native void questNativeOnResume();
private native void questOnAppAfterLoad(); private native void questOnAppAfterLoad();
private native void questNativeAwayMode();
private SurfaceView mView; private SurfaceView mView;
private SurfaceHolder mSurfaceHolder; private SurfaceHolder mSurfaceHolder;
@ -55,6 +56,7 @@ public class OculusMobileActivity extends QtActivity implements SurfaceHolder.Ca
runOnUiThread(() -> { runOnUiThread(() -> {
setContentView(mView); setContentView(mView);
questOnAppAfterLoad(); questOnAppAfterLoad();
}); });
@ -91,12 +93,14 @@ public class OculusMobileActivity extends QtActivity implements SurfaceHolder.Ca
questNativeOnPause(); questNativeOnPause();
nativeOnPause(); nativeOnPause();
isPausing=true; isPausing=true;
} }
@Override @Override
protected void onStop(){ protected void onStop(){
super.onStop(); super.onStop();
Log.w(TAG, "QQQ_ Onstop called"); Log.w(TAG, "QQQ_ Onstop called");
questNativeAwayMode();
} }
@Override @Override
@ -104,6 +108,7 @@ public class OculusMobileActivity extends QtActivity implements SurfaceHolder.Ca
super.onRestart(); super.onRestart();
Log.w(TAG, "QQQ_ onRestart called ****"); Log.w(TAG, "QQQ_ onRestart called ****");
questOnAppAfterLoad(); questOnAppAfterLoad();
questNativeAwayMode();
} }
@Override @Override
@ -123,8 +128,7 @@ public class OculusMobileActivity extends QtActivity implements SurfaceHolder.Ca
@Override @Override
public void surfaceDestroyed(SurfaceHolder holder) { public void surfaceDestroyed(SurfaceHolder holder) {
Log.w(TAG, "QQQ_ surfaceDestroyed ***************************************************"); Log.w(TAG, "QQQ_ surfaceDestroyed ***************************************************");
// nativeOnSurfaceChanged(null); nativeOnSurfaceChanged(null);
// mSurfaceHolder = null; mSurfaceHolder = null;
} }
} }

View file

@ -45,6 +45,10 @@ void AndroidHelper::notifyBeforeEnterBackground() {
emit beforeEnterBackground(); emit beforeEnterBackground();
} }
void AndroidHelper::notifyToggleAwayMode() {
emit toggleAwayMode();
}
void AndroidHelper::notifyEnterBackground() { void AndroidHelper::notifyEnterBackground() {
emit enterBackground(); emit enterBackground();
} }

View file

@ -31,6 +31,7 @@ public:
void notifyEnterForeground(); void notifyEnterForeground();
void notifyBeforeEnterBackground(); void notifyBeforeEnterBackground();
void notifyEnterBackground(); void notifyEnterBackground();
void notifyToggleAwayMode();
void performHapticFeedback(int duration); void performHapticFeedback(int duration);
void processURL(const QString &url); void processURL(const QString &url);
@ -55,7 +56,7 @@ signals:
void enterForeground(); void enterForeground();
void beforeEnterBackground(); void beforeEnterBackground();
void enterBackground(); void enterBackground();
void toggleAwayMode();
void hapticFeedbackRequested(int duration); void hapticFeedbackRequested(int duration);
void handleSignupCompleted(); void handleSignupCompleted();

View file

@ -2411,6 +2411,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
connect(&AndroidHelper::instance(), &AndroidHelper::beforeEnterBackground, this, &Application::beforeEnterBackground); connect(&AndroidHelper::instance(), &AndroidHelper::beforeEnterBackground, this, &Application::beforeEnterBackground);
connect(&AndroidHelper::instance(), &AndroidHelper::enterBackground, this, &Application::enterBackground); connect(&AndroidHelper::instance(), &AndroidHelper::enterBackground, this, &Application::enterBackground);
connect(&AndroidHelper::instance(), &AndroidHelper::enterForeground, this, &Application::enterForeground); connect(&AndroidHelper::instance(), &AndroidHelper::enterForeground, this, &Application::enterForeground);
connect(&AndroidHelper::instance(), &AndroidHelper::toggleAwayMode, this, &Application::toggleAwayMode);
AndroidHelper::instance().notifyLoadComplete(); AndroidHelper::instance().notifyLoadComplete();
#endif #endif
pauseUntilLoginDetermined(); pauseUntilLoginDetermined();
@ -9135,6 +9137,8 @@ void Application::beforeEnterBackground() {
clearDomainOctreeDetails(); clearDomainOctreeDetails();
} }
void Application::enterBackground() { void Application::enterBackground() {
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(),
"stop", Qt::BlockingQueuedConnection); "stop", Qt::BlockingQueuedConnection);
@ -9160,4 +9164,10 @@ void Application::enterForeground() {
} }
#endif #endif
void Application::toggleAwayMode(){
auto key = QKeyEvent(QEvent::KeyPress,Qt::Key_Escape,Qt::NoModifier);
_keyboardMouseDevice->keyPressEvent(&key);
qDebug()<<"QQQ_ AWAY MODE ";
}
#include "Application.moc" #include "Application.moc"

View file

@ -338,7 +338,8 @@ public:
void beforeEnterBackground(); void beforeEnterBackground();
void enterBackground(); void enterBackground();
void enterForeground(); void enterForeground();
#endif void toggleAwayMode();
#endif
signals: signals:
void svoImportRequested(const QString& url); void svoImportRequested(const QString& url);

View file

@ -14,8 +14,8 @@
var DEFAULT_SCRIPTS_COMBINED = [ var DEFAULT_SCRIPTS_COMBINED = [
"system/request-service.js", "system/request-service.js",
"system/progress.js", "system/progress.js",
//"system/away.js", "system/away.js",
"system/hmd.js", //"system/hmd.js",
"system/menu.js", "system/menu.js",
"system/bubble.js", "system/bubble.js",
"system/pal.js", // "system/mod.js", // older UX, if you prefer "system/pal.js", // "system/mod.js", // older UX, if you prefer

View file

@ -154,7 +154,7 @@ function goAway(fromStartup) {
if (!isEnabled || isAway) { if (!isEnabled || isAway) {
return; return;
} }
console.warn('QQQ_ JS going away);
// If we're entering away mode from some other state than startup, then we create our move timer immediately. // If we're entering away mode from some other state than startup, then we create our move timer immediately.
// However if we're just stating up, we need to delay this process so that we don't think the initial teleport // However if we're just stating up, we need to delay this process so that we don't think the initial teleport
// is actually a move. // is actually a move.
@ -176,6 +176,7 @@ function goActive() {
return; return;
} }
console.warn('QQQ_ JS going active);
UserActivityLogger.toggledAway(false); UserActivityLogger.toggledAway(false);
MyAvatar.isAway = false; MyAvatar.isAway = false;