mirror of
https://github.com/lubosz/overte.git
synced 2025-08-08 03:08:00 +02:00
Fix crash selecting domain for second time. Stop rendering while Goto activity is started
This commit is contained in:
parent
ddbf4417ff
commit
99d8f822b2
8 changed files with 42 additions and 13 deletions
|
@ -139,10 +139,6 @@ void unpackAndroidAssets() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void openGotoActivity(const QString& a) {
|
|
||||||
__activity.callMethod<void>("openGotoActivity", "()V");
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
JNIEXPORT void Java_io_highfidelity_hifiinterface_InterfaceActivity_nativeOnCreate(JNIEnv* env, jobject obj, jobject instance, jobject asset_mgr) {
|
JNIEXPORT void Java_io_highfidelity_hifiinterface_InterfaceActivity_nativeOnCreate(JNIEnv* env, jobject obj, jobject instance, jobject asset_mgr) {
|
||||||
|
@ -154,7 +150,8 @@ JNIEXPORT void Java_io_highfidelity_hifiinterface_InterfaceActivity_nativeOnCrea
|
||||||
qInstallMessageHandler(oldMessageHandler);
|
qInstallMessageHandler(oldMessageHandler);
|
||||||
|
|
||||||
QObject::connect(&AndroidHelper::instance(), &AndroidHelper::androidActivityRequested, [](const QString& a) {
|
QObject::connect(&AndroidHelper::instance(), &AndroidHelper::androidActivityRequested, [](const QString& a) {
|
||||||
__activity.callMethod<void>("openGotoActivity", "()V");
|
QAndroidJniObject string = QAndroidJniObject::fromString(a);
|
||||||
|
__activity.callMethod<void>("openGotoActivity", "(Ljava/lang/String;)V", string.object<jstring>());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,6 +178,8 @@ JNIEXPORT void Java_io_highfidelity_hifiinterface_InterfaceActivity_nativeOnExit
|
||||||
qDebug() << "nativeOnCreate On thread " << QThread::currentThreadId();
|
qDebug() << "nativeOnCreate On thread " << QThread::currentThreadId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT void Java_io_highfidelity_hifiinterface_InterfaceActivity_nativeGoBackFromAndroidActivity(JNIEnv *env, jobject instance) {
|
||||||
|
AndroidHelper::instance().goBackFromAndroidActivity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -106,8 +106,6 @@ public class GotoActivity extends AppCompatActivity {
|
||||||
searchTextView.setTextAppearance(R.style.SearchText);
|
searchTextView.setTextAppearance(R.style.SearchText);
|
||||||
}
|
}
|
||||||
|
|
||||||
preloadQt();
|
|
||||||
|
|
||||||
if (getIntent() == null ||
|
if (getIntent() == null ||
|
||||||
!getIntent().hasExtra(PARAM_NOT_START_INTERFACE_ACTIVITY) ||
|
!getIntent().hasExtra(PARAM_NOT_START_INTERFACE_ACTIVITY) ||
|
||||||
!getIntent().getBooleanExtra(PARAM_NOT_START_INTERFACE_ACTIVITY, false)) {
|
!getIntent().getBooleanExtra(PARAM_NOT_START_INTERFACE_ACTIVITY, false)) {
|
||||||
|
|
|
@ -32,6 +32,7 @@ import android.view.View;
|
||||||
public class InterfaceActivity extends QtActivity {
|
public class InterfaceActivity extends QtActivity {
|
||||||
|
|
||||||
public static final String DOMAIN_URL = "url";
|
public static final String DOMAIN_URL = "url";
|
||||||
|
private static final String TAG = "Interface";
|
||||||
|
|
||||||
//public static native void handleHifiURL(String hifiURLString);
|
//public static native void handleHifiURL(String hifiURLString);
|
||||||
private native long nativeOnCreate(InterfaceActivity instance, AssetManager assetManager);
|
private native long nativeOnCreate(InterfaceActivity instance, AssetManager assetManager);
|
||||||
|
@ -39,6 +40,7 @@ public class InterfaceActivity extends QtActivity {
|
||||||
//private native void nativeOnResume();
|
//private native void nativeOnResume();
|
||||||
private native void nativeOnDestroy();
|
private native void nativeOnDestroy();
|
||||||
private native void nativeGotoUrl(String url);
|
private native void nativeGotoUrl(String url);
|
||||||
|
private native void nativeGoBackFromAndroidActivity();
|
||||||
//private native void nativeOnStop();
|
//private native void nativeOnStop();
|
||||||
//private native void nativeOnStart();
|
//private native void nativeOnStart();
|
||||||
//private native void saveRealScreenSize(int width, int height);
|
//private native void saveRealScreenSize(int width, int height);
|
||||||
|
@ -193,12 +195,22 @@ public class InterfaceActivity extends QtActivity {
|
||||||
if (intent.hasExtra(DOMAIN_URL)) {
|
if (intent.hasExtra(DOMAIN_URL)) {
|
||||||
nativeGotoUrl(intent.getStringExtra(DOMAIN_URL));
|
nativeGotoUrl(intent.getStringExtra(DOMAIN_URL));
|
||||||
}
|
}
|
||||||
|
nativeGoBackFromAndroidActivity();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void openGotoActivity() {
|
public void openGotoActivity(String activityName) {
|
||||||
Intent intent = new Intent(this, GotoActivity.class);
|
switch (activityName) {
|
||||||
intent.putExtra(GotoActivity.PARAM_NOT_START_INTERFACE_ACTIVITY, true);
|
case "Goto": {
|
||||||
startActivity(intent);
|
Intent intent = new Intent(this, GotoActivity.class);
|
||||||
|
intent.putExtra(GotoActivity.PARAM_NOT_START_INTERFACE_ACTIVITY, true);
|
||||||
|
startActivity(intent);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
Log.w(TAG, "Could not open activity by name " + activityName);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -13,4 +13,8 @@
|
||||||
|
|
||||||
void AndroidHelper::requestActivity(const QString &activityName) {
|
void AndroidHelper::requestActivity(const QString &activityName) {
|
||||||
emit androidActivityRequested(activityName);
|
emit androidActivityRequested(activityName);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AndroidHelper::goBackFromAndroidActivity() {
|
||||||
|
emit backFromAndroidActivity();
|
||||||
}
|
}
|
|
@ -22,10 +22,13 @@ public:
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
void requestActivity(const QString &activityName);
|
void requestActivity(const QString &activityName);
|
||||||
|
void goBackFromAndroidActivity();
|
||||||
|
|
||||||
AndroidHelper(AndroidHelper const&) = delete;
|
AndroidHelper(AndroidHelper const&) = delete;
|
||||||
void operator=(AndroidHelper const&) = delete;
|
void operator=(AndroidHelper const&) = delete;
|
||||||
signals:
|
signals:
|
||||||
void androidActivityRequested(const QString &activityName);
|
void androidActivityRequested(const QString &activityName);
|
||||||
|
void backFromAndroidActivity();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AndroidHelper() {}
|
AndroidHelper() {}
|
||||||
|
|
|
@ -7868,7 +7868,18 @@ void Application::saveNextPhysicsStats(QString filename) {
|
||||||
|
|
||||||
void Application::openAndroidActivity(const QString& activityName) {
|
void Application::openAndroidActivity(const QString& activityName) {
|
||||||
#if defined(Q_OS_ANDROID)
|
#if defined(Q_OS_ANDROID)
|
||||||
|
getActiveDisplayPlugin()->deactivate();
|
||||||
AndroidHelper::instance().requestActivity(activityName);
|
AndroidHelper::instance().requestActivity(activityName);
|
||||||
|
connect(&AndroidHelper::instance(), &AndroidHelper::backFromAndroidActivity, this, &Application::restoreAfterAndroidActivity);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void Application::restoreAfterAndroidActivity() {
|
||||||
|
#if defined(Q_OS_ANDROID)
|
||||||
|
if (!getActiveDisplayPlugin() || !getActiveDisplayPlugin()->activate()) {
|
||||||
|
qWarning() << "Could not re-activate display plugin";
|
||||||
|
}
|
||||||
|
disconnect(&AndroidHelper::instance(), &AndroidHelper::backFromAndroidActivity, this, &Application::restoreAfterAndroidActivity);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -454,6 +454,8 @@ private slots:
|
||||||
void handleSandboxStatus(QNetworkReply* reply);
|
void handleSandboxStatus(QNetworkReply* reply);
|
||||||
void switchDisplayMode();
|
void switchDisplayMode();
|
||||||
|
|
||||||
|
void restoreAfterAndroidActivity();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void initDisplay();
|
static void initDisplay();
|
||||||
void init();
|
void init();
|
||||||
|
|
|
@ -34,7 +34,7 @@ function fromQml(message) { // messages are {method, params}, like json-rpc. See
|
||||||
module.exports.onHidden();
|
module.exports.onHidden();
|
||||||
break;
|
break;
|
||||||
case 'openAndroidActivity':
|
case 'openAndroidActivity':
|
||||||
App.openAndroidActivity("Hello");
|
App.openAndroidActivity("Goto");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
print('[goto-android.js] Unrecognized message from AddressBarDialog.qml:', JSON.stringify(message));
|
print('[goto-android.js] Unrecognized message from AddressBarDialog.qml:', JSON.stringify(message));
|
||||||
|
|
Loading…
Reference in a new issue