mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 14:12:50 +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" {
|
||||
|
||||
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);
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
preloadQt();
|
||||
|
||||
if (getIntent() == null ||
|
||||
!getIntent().hasExtra(PARAM_NOT_START_INTERFACE_ACTIVITY) ||
|
||||
!getIntent().getBooleanExtra(PARAM_NOT_START_INTERFACE_ACTIVITY, false)) {
|
||||
|
|
|
@ -32,6 +32,7 @@ import android.view.View;
|
|||
public class InterfaceActivity extends QtActivity {
|
||||
|
||||
public static final String DOMAIN_URL = "url";
|
||||
private static final String TAG = "Interface";
|
||||
|
||||
//public static native void handleHifiURL(String hifiURLString);
|
||||
private native long nativeOnCreate(InterfaceActivity instance, AssetManager assetManager);
|
||||
|
@ -39,6 +40,7 @@ public class InterfaceActivity extends QtActivity {
|
|||
//private native void nativeOnResume();
|
||||
private native void nativeOnDestroy();
|
||||
private native void nativeGotoUrl(String url);
|
||||
private native void nativeGoBackFromAndroidActivity();
|
||||
//private native void nativeOnStop();
|
||||
//private native void nativeOnStart();
|
||||
//private native void saveRealScreenSize(int width, int height);
|
||||
|
@ -193,12 +195,22 @@ public class InterfaceActivity extends QtActivity {
|
|||
if (intent.hasExtra(DOMAIN_URL)) {
|
||||
nativeGotoUrl(intent.getStringExtra(DOMAIN_URL));
|
||||
}
|
||||
nativeGoBackFromAndroidActivity();
|
||||
}
|
||||
|
||||
public void openGotoActivity() {
|
||||
Intent intent = new Intent(this, GotoActivity.class);
|
||||
intent.putExtra(GotoActivity.PARAM_NOT_START_INTERFACE_ACTIVITY, true);
|
||||
startActivity(intent);
|
||||
public void openGotoActivity(String activityName) {
|
||||
switch (activityName) {
|
||||
case "Goto": {
|
||||
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) {
|
||||
emit androidActivityRequested(activityName);
|
||||
}
|
||||
|
||||
void AndroidHelper::goBackFromAndroidActivity() {
|
||||
emit backFromAndroidActivity();
|
||||
}
|
|
@ -22,10 +22,13 @@ public:
|
|||
return instance;
|
||||
}
|
||||
void requestActivity(const QString &activityName);
|
||||
void goBackFromAndroidActivity();
|
||||
|
||||
AndroidHelper(AndroidHelper const&) = delete;
|
||||
void operator=(AndroidHelper const&) = delete;
|
||||
signals:
|
||||
void androidActivityRequested(const QString &activityName);
|
||||
void backFromAndroidActivity();
|
||||
|
||||
private:
|
||||
AndroidHelper() {}
|
||||
|
|
|
@ -7868,7 +7868,18 @@ void Application::saveNextPhysicsStats(QString filename) {
|
|||
|
||||
void Application::openAndroidActivity(const QString& activityName) {
|
||||
#if defined(Q_OS_ANDROID)
|
||||
getActiveDisplayPlugin()->deactivate();
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
@ -454,6 +454,8 @@ private slots:
|
|||
void handleSandboxStatus(QNetworkReply* reply);
|
||||
void switchDisplayMode();
|
||||
|
||||
void restoreAfterAndroidActivity();
|
||||
|
||||
private:
|
||||
static void initDisplay();
|
||||
void init();
|
||||
|
|
|
@ -34,7 +34,7 @@ function fromQml(message) { // messages are {method, params}, like json-rpc. See
|
|||
module.exports.onHidden();
|
||||
break;
|
||||
case 'openAndroidActivity':
|
||||
App.openAndroidActivity("Hello");
|
||||
App.openAndroidActivity("Goto");
|
||||
break;
|
||||
default:
|
||||
print('[goto-android.js] Unrecognized message from AddressBarDialog.qml:', JSON.stringify(message));
|
||||
|
|
Loading…
Reference in a new issue