Backed out changeset 4fb119706335 (bug 1126479)

This commit is contained in:
Sebastian Hengst 2017-08-15 18:29:58 +02:00
Родитель 571612717d
Коммит 17ffe72e5d
2 изменённых файлов: 27 добавлений и 66 удалений

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

@ -40,7 +40,6 @@ import org.mozilla.gecko.icons.decoders.FaviconDecoder;
import org.mozilla.gecko.icons.decoders.LoadFaviconResult;
import org.mozilla.gecko.prompts.PromptService;
import org.mozilla.gecko.R;
import org.mozilla.gecko.util.ActivityUtils;
import org.mozilla.gecko.util.ColorUtil;
import org.mozilla.gecko.util.FileUtils;
@ -54,8 +53,6 @@ public class WebAppActivity extends AppCompatActivity
private GeckoView mGeckoView;
private PromptService mPromptService;
private boolean mIsFullScreenMode;
private boolean mIsFullScreenContent;
private Uri mScope;
@Override
@ -77,15 +74,6 @@ public class WebAppActivity extends AppCompatActivity
mGeckoView = new GeckoView(this);
mGeckoView.setNavigationListener(this);
mGeckoView.setContentListener(new GeckoView.ContentListener() {
public void onTitleChange(GeckoView view, String title) {}
public void onContextMenu(GeckoView view, int screenX, int screenY,
String uri, String elementSrc) {}
public void onFullScreen(GeckoView view, boolean fullScreen) {
updateFullScreenContent(fullScreen);
}
});
mPromptService = new PromptService(this, mGeckoView.getEventDispatcher());
final GeckoViewSettings settings = mGeckoView.getSettings();
@ -121,22 +109,6 @@ public class WebAppActivity extends AppCompatActivity
outState.putParcelable(SAVED_INTENT, getIntent());
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
if (hasFocus) {
updateFullScreen();
}
}
@Override
public void onBackPressed() {
if (mIsFullScreenContent) {
mGeckoView.exitFullScreen();
} else {
super.onBackPressed();
}
}
private void loadManifest(String manifestPath) {
if (TextUtils.isEmpty(manifestPath)) {
Log.e(LOGTAG, "Missing manifest");
@ -153,7 +125,6 @@ public class WebAppActivity extends AppCompatActivity
}
updateScreenOrientation(manifestField);
updateDisplayMode(manifestField);
} catch (IOException | JSONException e) {
Log.e(LOGTAG, "Failed to read manifest", e);
}
@ -199,8 +170,6 @@ public class WebAppActivity extends AppCompatActivity
private void updateDisplayMode(JSONObject manifest) {
String displayMode = manifest.optString("display");
updateFullScreenMode(displayMode.equals("fullscreen"));
GeckoViewSettings.DisplayMode mode;
switch (displayMode) {
case "standalone":
@ -323,23 +292,4 @@ public class WebAppActivity extends AppCompatActivity
startActivity(intent);
}
}
private void updateFullScreen() {
boolean fullScreen = mIsFullScreenContent || mIsFullScreenMode;
if (ActivityUtils.isFullScreen(this) == fullScreen) {
return;
}
ActivityUtils.setFullScreen(this, fullScreen);
}
private void updateFullScreenContent(boolean fullScreen) {
mIsFullScreenContent = fullScreen;
updateFullScreen();
}
private void updateFullScreenMode(boolean fullScreen) {
mIsFullScreenMode = fullScreen;
updateFullScreen();
}
}

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

@ -22,30 +22,41 @@ public class ActivityUtils {
// Hide/show the system notification bar
Window window = activity.getWindow();
int newVis;
if (fullscreen) {
newVis = View.SYSTEM_UI_FLAG_FULLSCREEN;
if (Build.VERSION.SDK_INT >= 19) {
newVis |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
if (Build.VERSION.SDK_INT >= 16) {
int newVis;
if (fullscreen) {
newVis = View.SYSTEM_UI_FLAG_FULLSCREEN;
if (Build.VERSION.SDK_INT >= 19) {
newVis |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
} else {
newVis |= View.SYSTEM_UI_FLAG_LOW_PROFILE;
}
} else {
newVis |= View.SYSTEM_UI_FLAG_LOW_PROFILE;
newVis = View.SYSTEM_UI_FLAG_VISIBLE;
}
} else {
newVis = View.SYSTEM_UI_FLAG_VISIBLE;
}
window.getDecorView().setSystemUiVisibility(newVis);
window.getDecorView().setSystemUiVisibility(newVis);
} else {
window.setFlags(fullscreen ?
WindowManager.LayoutParams.FLAG_FULLSCREEN : 0,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
public static boolean isFullScreen(final Activity activity) {
final Window window = activity.getWindow();
final int vis = window.getDecorView().getSystemUiVisibility();
return (vis & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0;
if (Build.VERSION.SDK_INT >= 16) {
final int vis = window.getDecorView().getSystemUiVisibility();
return (vis & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0;
}
final int flags = window.getAttributes().flags;
return ((flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0);
}
/**