Bug 1081153 - Consolidate BaseGeckoInterface/GeckoApp.setFullScreen() (r=mfinkle)

This commit is contained in:
Lucas Rocha 2014-10-10 17:01:52 +01:00
Родитель 6136e1984c
Коммит 2086889642
4 изменённых файлов: 44 добавлений и 37 удалений

Просмотреть файл

@ -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);
}
});
}

Просмотреть файл

@ -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);
}
});
}

Просмотреть файл

@ -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',

Просмотреть файл

@ -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);
}
}
}