From 0fb3cb2f56fdd4f0c669deb2aa399d526b101382 Mon Sep 17 00:00:00 2001 From: Mike <7153163+hackbar@users.noreply.github.com> Date: Sun, 8 Oct 2017 00:35:26 -0700 Subject: [PATCH 1/2] Android: Use the system "immersive" mode for fullscreen, and simplify how it's called. The user will get a brief system popup tutorial the first time it's used, so we don't need to show them the menu every time. Once they enable it by pulling down, hide again after 3s. --- .../activities/EmulationActivity.java | 131 ++++-------------- 1 file changed, 30 insertions(+), 101 deletions(-) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java index 2753735200..7d4c1dd74e 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java @@ -8,7 +8,6 @@ import android.content.SharedPreferences; import android.hardware.usb.UsbManager; import android.os.Bundle; import android.os.Handler; -import android.os.Message; import android.preference.PreferenceManager; import android.support.annotation.IntDef; import android.support.v4.app.ActivityOptionsCompat; @@ -62,24 +61,10 @@ public final class EmulationActivity extends AppCompatActivity private int mPosition; private boolean mDeviceHasTouchScreen; - private boolean mSystemUiVisible; private boolean mMenuVisible; private static boolean sIsGameCubeGame; - /** - * Handlers are a way to pass a message to an Activity telling it to do something - * on the UI thread. This Handler responds to any message, even blank ones, by - * hiding the system UI. - */ - private Handler mSystemUiHider = new Handler() - { - @Override - public void handleMessage(Message msg) - { - hideSystemUI(); - } - }; private String mScreenPath; private String mSelectedTitle; @@ -186,32 +171,28 @@ public final class EmulationActivity extends AppCompatActivity // Get a handle to the Window containing the UI. mDecorView = getWindow().getDecorView(); - - // Set these options now so that the SurfaceView the game renders into is the right size. - mDecorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | - View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | - View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); - - // Set the ActionBar to follow the navigation/status bar's visibility changes. - mDecorView.setOnSystemUiVisibilityChangeListener( - new View.OnSystemUiVisibilityChangeListener() + mDecorView.setOnSystemUiVisibilityChangeListener + (new View.OnSystemUiVisibilityChangeListener() { + @Override + public void onSystemUiVisibilityChange(int visibility) { + if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) { - @Override - public void onSystemUiVisibilityChange(int flags) + // Go back to immersive fullscreen mode in 3s + Handler handler = new Handler(getMainLooper()); + handler.postDelayed(new Runnable() { - mSystemUiVisible = (flags & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0; - - if (mSystemUiVisible) + @Override + public void run() { - getSupportActionBar().show(); - hideSystemUiAfterDelay(); + enableFullscreenImmersive(); } - else - { - getSupportActionBar().hide(); - } - } - }); + }, + 3000 /* 3s */); + } + } + }); + // Set these options now so that the SurfaceView the game renders into is the right size. + enableFullscreenImmersive(); } else { @@ -283,38 +264,6 @@ public final class EmulationActivity extends AppCompatActivity } - @Override - protected void onPostCreate(Bundle savedInstanceState) - { - super.onPostCreate(savedInstanceState); - - if (mDeviceHasTouchScreen) - { - // Give the user a few seconds to see what the controls look like, then hide them. - hideSystemUiAfterDelay(); - } - } - - @Override - public void onWindowFocusChanged(boolean hasFocus) - { - super.onWindowFocusChanged(hasFocus); - - if (mDeviceHasTouchScreen) - { - if (hasFocus) - { - hideSystemUiAfterDelay(); - } - else - { - // If the window loses focus (i.e. a dialog box, or a popup menu is on screen - // stop hiding the UI. - mSystemUiHider.removeMessages(0); - } - } - } - @Override public void onBackPressed() { @@ -335,6 +284,18 @@ public final class EmulationActivity extends AppCompatActivity } + private void enableFullscreenImmersive() + { + // It would be nice to use IMMERSIVE_STICKY, but that doesn't show the toolbar. + mDecorView.setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE | + View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | + View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | + View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | + View.SYSTEM_UI_FLAG_FULLSCREEN | + View.SYSTEM_UI_FLAG_IMMERSIVE); + } + private void toggleMenu() { boolean result = getSupportFragmentManager().popBackStackImmediate( @@ -767,38 +728,6 @@ public final class EmulationActivity extends AppCompatActivity return true; } - private void hideSystemUiAfterDelay() - { - // Clear any pending hide events. - mSystemUiHider.removeMessages(0); - - // Add a new hide event, to occur 3 seconds from now. - mSystemUiHider.sendEmptyMessageDelayed(0, 3000); - } - - private void hideSystemUI() - { - mSystemUiVisible = false; - - mDecorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | - View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | - View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | - View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | - View.SYSTEM_UI_FLAG_FULLSCREEN | - View.SYSTEM_UI_FLAG_IMMERSIVE); - } - - private void showSystemUI() - { - mSystemUiVisible = true; - - mDecorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | - View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | - View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); - - hideSystemUiAfterDelay(); - } - private void showSubMenu(SaveLoadStateFragment.SaveOrLoad saveOrLoad) { // Get rid of any visible submenu From 5cb1a08b1332ee0fe6550f8732629965bf919ed7 Mon Sep 17 00:00:00 2001 From: Mike <7153163+hackbar@users.noreply.github.com> Date: Wed, 25 Oct 2017 21:31:06 -0700 Subject: [PATCH 2/2] Android: Only specify the transition name for the target Activity. The source Views don't need the transition name. We could get the name from the sharedView via getTransitionName, but since the TV ImageCardView isn't inflated in XML it would be to be manually set. I'm not sure if that would be any cleaner than this. --- Source/Android/app/src/main/res/layout/card_game.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/Android/app/src/main/res/layout/card_game.xml b/Source/Android/app/src/main/res/layout/card_game.xml index f831b01f3d..1ee76e3471 100644 --- a/Source/Android/app/src/main/res/layout/card_game.xml +++ b/Source/Android/app/src/main/res/layout/card_game.xml @@ -18,7 +18,6 @@ android:id="@+id/image_game_screen" android:layout_width="match_parent" android:layout_height="0dp" - android:transitionName="image_game_screenshot" android:layout_weight="1" tools:src="@drawable/placeholder_screenshot" tools:scaleType="centerCrop"/>