moved asset loading to the permissions screen, added the onNotifyAppLoaded signal connect function as well as binding to the qtread with the ui thread.

This commit is contained in:
amerhifi 2019-02-08 13:45:53 -08:00
parent 8848d0210a
commit e8a35c63c7
6 changed files with 34 additions and 13 deletions

View file

@ -1,3 +1,4 @@
package io.highfidelity.hifiinterface; package io.highfidelity.hifiinterface;
import android.app.Activity; import android.app.Activity;

View file

@ -42,21 +42,31 @@ extern "C" {
Java_io_highfidelity_questInterface_QuestActivity_nativeInitOculusPlatform(JNIEnv *env, jobject obj){ Java_io_highfidelity_questInterface_QuestActivity_nativeInitOculusPlatform(JNIEnv *env, jobject obj){
initOculusPlatform(env, obj); initOculusPlatform(env, obj);
} }
QAndroidJniObject __interfaceActivity;
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
Java_io_highfidelity_questInterface_QuestActivity_questNativeOnCreate(JNIEnv *env, jobject obj) { Java_io_highfidelity_questInterface_QuestActivity_questNativeOnCreate(JNIEnv *env, jobject obj) {
__android_log_print(ANDROID_LOG_WARN, "QQQ","questNativeOnCreate called");
initOculusPlatform(env, obj); initOculusPlatform(env, obj);
__interfaceActivity = QAndroidJniObject (obj);
QObject::connect(&AndroidHelper::instance(), &AndroidHelper::qtAppLoadComplete, []() {
if(qApp) { QObject::connect(&AndroidHelper::instance(), &AndroidHelper::qtAppLoadComplete, []() {
QThread *thr = qApp->thread(); __interfaceActivity.callMethod<void>("onAppLoadedComplete", "()V");
AndroidHelper::instance().moveToThread(thr);
} QObject::disconnect(&AndroidHelper::instance(), &AndroidHelper::qtAppLoadComplete, nullptr,
else{ nullptr);
__android_log_print(ANDROID_LOG_ERROR,"QQQ_", "APP is not valid"); });
}
QObject::disconnect(&AndroidHelper::instance(), &AndroidHelper::qtAppLoadComplete,
nullptr, nullptr);
});
} }
JNIEXPORT void Java_io_highfidelity_questInterface_QuestActivity_questOnAppAfterLoad(JNIEnv* env, jobject obj) {
AndroidHelper::instance().moveToThread(qApp->thread());
}
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
Java_io_highfidelity_questInterface_QuestActivity_questNativeOnDestroy(JNIEnv *env, jobject obj) { Java_io_highfidelity_questInterface_QuestActivity_questNativeOnDestroy(JNIEnv *env, jobject obj) {
} }

View file

@ -6,6 +6,8 @@ import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.os.Bundle; import android.os.Bundle;
import io.highfidelity.utils.HifiUtils;
public class PermissionsChecker extends Activity { public class PermissionsChecker extends Activity {
private static final int REQUEST_PERMISSIONS = 20; private static final int REQUEST_PERMISSIONS = 20;
private static final String TAG = PermissionsChecker.class.getName(); private static final String TAG = PermissionsChecker.class.getName();
@ -44,6 +46,7 @@ public class PermissionsChecker extends Activity {
} }
private void launchActivityWithPermissions() { private void launchActivityWithPermissions() {
HifiUtils.upackAssets(getAssets(), getCacheDir().getAbsolutePath());
startActivity(new Intent(this, QuestActivity.class)); startActivity(new Intent(this, QuestActivity.class));
} }

View file

@ -13,6 +13,7 @@ package io.highfidelity.questInterface;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.view.WindowManager; import android.view.WindowManager;
import io.highfidelity.oculus.OculusMobileActivity; import io.highfidelity.oculus.OculusMobileActivity;
@ -23,15 +24,20 @@ public class QuestActivity extends OculusMobileActivity {
private native void questNativeOnDestroy(); private native void questNativeOnDestroy();
private native void questNativeOnPause(); private native void questNativeOnPause();
private native void questNativeOnResume(); private native void questNativeOnResume();
private native void questOnAppAfterLoad();
String TAG = OculusMobileActivity.class.getSimpleName();
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
HifiUtils.upackAssets(getAssets(), getCacheDir().getAbsolutePath());
questNativeOnCreate(); questNativeOnCreate();
} }
public void onAppLoadedComplete() {
Log.w(TAG, "QQQ Load Completed");
runOnUiThread(() -> {
questOnAppAfterLoad();
});
}
@Override @Override
protected void onPause() { protected void onPause() {

View file

@ -44,11 +44,11 @@ public class OculusMobileActivity extends QtActivity implements SurfaceHolder.Ca
// Create a native surface for VR rendering (Qt GL surfaces are not suitable // Create a native surface for VR rendering (Qt GL surfaces are not suitable
// because of the lack of fine control over the surface callbacks) // because of the lack of fine control over the surface callbacks)
mView = new SurfaceView(this); mView = new SurfaceView(this);
mView.getHolder().addCallback(this); mView.getHolder().addCallback(this);
setContentView(mView); setContentView(mView);
// Forward the create message to the JNI code
nativeOnCreate(); nativeOnCreate();
// Forward the create message to the JNI code
} }
@Override @Override

View file

@ -2428,6 +2428,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
connect(&AndroidHelper::instance(), &AndroidHelper::enterForeground, this, &Application::enterForeground); connect(&AndroidHelper::instance(), &AndroidHelper::enterForeground, this, &Application::enterForeground);
AndroidHelper::instance().notifyLoadComplete(); AndroidHelper::instance().notifyLoadComplete();
#endif #endif
AndroidHelper::instance().notifyLoadComplete();
pauseUntilLoginDetermined(); pauseUntilLoginDetermined();
} }