From c01bca686e48da1ee2530f9cb91d0d341a9ac34a Mon Sep 17 00:00:00 2001 From: Imanol Fernandez Date: Tue, 12 Mar 2019 17:36:56 +0100 Subject: [PATCH] Discard back button presses to exit the app in WaveVR and Daydream --- .../mozilla/vrbrowser/PlatformActivity.java | 26 +++++++++---------- .../mozilla/vrbrowser/PlatformActivity.java | 7 +++++ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/app/src/googlevr/java/org/mozilla/vrbrowser/PlatformActivity.java b/app/src/googlevr/java/org/mozilla/vrbrowser/PlatformActivity.java index e104902bf..dc7529f29 100644 --- a/app/src/googlevr/java/org/mozilla/vrbrowser/PlatformActivity.java +++ b/app/src/googlevr/java/org/mozilla/vrbrowser/PlatformActivity.java @@ -107,19 +107,12 @@ public void onDrawFrame(GL10 gl) { mLayout.setAsyncReprojectionEnabled(true); mLayout.setPresentationView(mView); - - try { - final Class flatActivityClass = Class.forName(FLAT_ACTIVITY_CLASSNAME); - mLayout.getUiLayout().setCloseButtonListener(new Runnable() { - @Override - public void run() { - startActivity(new Intent(PlatformActivity.this, flatActivityClass)); - } - }); - } - catch (ClassNotFoundException e) { - Log.e(LOGTAG,"Class not found: " + e.toString()); - } + mLayout.getUiLayout().setCloseButtonListener(new Runnable() { + @Override + public void run() { + finish(); + } + }); setImmersiveSticky(); setContentView(mLayout); @@ -200,6 +193,13 @@ private void notifyPendingEvents() { } } + @Override + public void onBackPressed() { + // Discard back button presses that would otherwise exit the app, + // as the UI standard on this platform is to require the use of + // the Daydream button to exit application. + } + private native void activityCreated(Object aAssetManager, final long aContext); private native void activityPaused(); private native void activityResumed(); diff --git a/app/src/wavevr/java/org/mozilla/vrbrowser/PlatformActivity.java b/app/src/wavevr/java/org/mozilla/vrbrowser/PlatformActivity.java index 6c20dc1bb..a147ee7f3 100644 --- a/app/src/wavevr/java/org/mozilla/vrbrowser/PlatformActivity.java +++ b/app/src/wavevr/java/org/mozilla/vrbrowser/PlatformActivity.java @@ -37,6 +37,13 @@ public void run() { }); } + @Override + public void onBackPressed() { + // Discard back button presses that would otherwise exit the app, + // as the UI standard on this platform is to require the use of + // the system menu to exit applications. + } + protected native void queueRunnable(Runnable aRunnable); protected native void initializeJava(AssetManager aAssets); }