From 2086889642fb8e1e7bedc6af50e0a68abd3b566b Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Fri, 10 Oct 2014 17:01:52 +0100 Subject: [PATCH] Bug 1081153 - Consolidate BaseGeckoInterface/GeckoApp.setFullScreen() (r=mfinkle) --- mobile/android/base/BaseGeckoInterface.java | 20 ++--------- mobile/android/base/GeckoApp.java | 21 ++--------- mobile/android/base/moz.build | 1 + mobile/android/base/util/ActivityUtils.java | 39 +++++++++++++++++++++ 4 files changed, 44 insertions(+), 37 deletions(-) create mode 100644 mobile/android/base/util/ActivityUtils.java diff --git a/mobile/android/base/BaseGeckoInterface.java b/mobile/android/base/BaseGeckoInterface.java index 52b4318a3179..976958d530a5 100644 --- a/mobile/android/base/BaseGeckoInterface.java +++ b/mobile/android/base/BaseGeckoInterface.java @@ -7,6 +7,7 @@ package org.mozilla.gecko; import org.mozilla.gecko.AppConstants.Versions; import org.mozilla.gecko.prompts.PromptService; +import org.mozilla.gecko.util.ActivityUtils; import org.mozilla.gecko.util.HardwareUtils; import org.mozilla.gecko.util.ThreadUtils; @@ -73,24 +74,7 @@ public class BaseGeckoInterface implements GeckoAppShell.GeckoInterface { ThreadUtils.postToUiThread(new Runnable() { @Override public void run() { - // Hide/show the system notification bar - Window window = getActivity().getWindow(); - - if (Versions.feature11Plus) { - final int newVis; - if (fullscreen) { - newVis = View.SYSTEM_UI_FLAG_FULLSCREEN | - View.SYSTEM_UI_FLAG_LOW_PROFILE; - } else { - newVis = View.SYSTEM_UI_FLAG_VISIBLE; - } - - window.getDecorView().setSystemUiVisibility(newVis); - } else { - window.setFlags(fullscreen ? - WindowManager.LayoutParams.FLAG_FULLSCREEN : 0, - WindowManager.LayoutParams.FLAG_FULLSCREEN); - } + ActivityUtils.setFullScreen(getActivity(), fullscreen); } }); } diff --git a/mobile/android/base/GeckoApp.java b/mobile/android/base/GeckoApp.java index 12aae6571b6b..220ae8c941b9 100644 --- a/mobile/android/base/GeckoApp.java +++ b/mobile/android/base/GeckoApp.java @@ -47,6 +47,7 @@ import org.mozilla.gecko.prompts.PromptService; import org.mozilla.gecko.updater.UpdateService; import org.mozilla.gecko.updater.UpdateServiceHelper; import org.mozilla.gecko.util.ActivityResultHandler; +import org.mozilla.gecko.util.ActivityUtils; import org.mozilla.gecko.util.EventCallback; import org.mozilla.gecko.util.FileUtils; import org.mozilla.gecko.util.GeckoEventListener; @@ -103,7 +104,6 @@ import android.view.View; import android.view.ViewGroup; import android.view.ViewStub; import android.view.Window; -import android.view.WindowManager; import android.widget.AbsoluteLayout; import android.widget.FrameLayout; import android.widget.ListView; @@ -1075,24 +1075,7 @@ public abstract class GeckoApp ThreadUtils.postToUiThread(new Runnable() { @Override public void run() { - // Hide/show the system notification bar - Window window = getWindow(); - - if (Versions.feature11Plus) { - final int newVis; - if (fullscreen) { - newVis = View.SYSTEM_UI_FLAG_FULLSCREEN | - View.SYSTEM_UI_FLAG_LOW_PROFILE; - } else { - newVis = View.SYSTEM_UI_FLAG_VISIBLE; - } - - window.getDecorView().setSystemUiVisibility(newVis); - } else { - window.setFlags(fullscreen ? - WindowManager.LayoutParams.FLAG_FULLSCREEN : 0, - WindowManager.LayoutParams.FLAG_FULLSCREEN); - } + ActivityUtils.setFullScreen(GeckoApp.this, fullscreen); } }); } diff --git a/mobile/android/base/moz.build b/mobile/android/base/moz.build index 36dbb387254c..c642e34a7750 100644 --- a/mobile/android/base/moz.build +++ b/mobile/android/base/moz.build @@ -47,6 +47,7 @@ gujar = add_java_jar('gecko-util') gujar.sources += [ 'util/ActivityResultHandler.java', 'util/ActivityResultHandlerMap.java', + 'util/ActivityUtils.java', 'util/Clipboard.java', 'util/EventCallback.java', 'util/FileUtils.java', diff --git a/mobile/android/base/util/ActivityUtils.java b/mobile/android/base/util/ActivityUtils.java new file mode 100644 index 000000000000..2e68625ea74c --- /dev/null +++ b/mobile/android/base/util/ActivityUtils.java @@ -0,0 +1,39 @@ +/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +package org.mozilla.gecko.util; + +import android.app.Activity; +import android.view.View; +import android.view.Window; +import android.view.WindowManager; + +import org.mozilla.gecko.AppConstants.Versions; + +public class ActivityUtils { + private ActivityUtils() { + } + + public static void setFullScreen(Activity activity, boolean fullscreen) { + // Hide/show the system notification bar + Window window = activity.getWindow(); + + if (Versions.feature11Plus) { + final int newVis; + if (fullscreen) { + newVis = View.SYSTEM_UI_FLAG_FULLSCREEN | + View.SYSTEM_UI_FLAG_LOW_PROFILE; + } else { + newVis = View.SYSTEM_UI_FLAG_VISIBLE; + } + + window.getDecorView().setSystemUiVisibility(newVis); + } else { + window.setFlags(fullscreen ? + WindowManager.LayoutParams.FLAG_FULLSCREEN : 0, + WindowManager.LayoutParams.FLAG_FULLSCREEN); + } + } +}