Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Point;
import android.view.Display;
import android.view.WindowManager;
Expand Down Expand Up @@ -38,12 +40,26 @@ public static Point getModalHostSize(Context context) {
// getSize will return the dimensions of the screen in its current orientation
display.getSize(SIZE_POINT);

int[] attrs = {android.R.attr.windowFullscreen};
Resources.Theme theme = context.getTheme();
TypedArray ta = theme.obtainStyledAttributes(attrs);
boolean windowFullscreen = ta.getBoolean(0, false);

// We need to add the status bar height to the height if we have a fullscreen window,
// because Display.getCurrentSizeRange doesn't include it.
Resources resources = context.getResources();
int statusBarId = resources.getIdentifier("status_bar_height", "dimen", "android");
int statusBarHeight = 0;
if (windowFullscreen && statusBarId > 0) {
statusBarHeight = (int) resources.getDimension(statusBarId);
}

if (SIZE_POINT.x < SIZE_POINT.y) {
// If we are vertical the width value comes from min width and height comes from max height
return new Point(MIN_POINT.x, MAX_POINT.y);
return new Point(MIN_POINT.x, MAX_POINT.y + statusBarHeight);
} else {
// If we are horizontal the width value comes from max width and height comes from min height
return new Point(MAX_POINT.x, MIN_POINT.y);
return new Point(MAX_POINT.x, MIN_POINT.y + statusBarHeight);
}
}
}