use of android.view.Display in project NewPipe by TeamNewPipe.
the class PlayVideoActivity method getNavigationBarWidth.
private int getNavigationBarWidth() {
if (Build.VERSION.SDK_INT >= 17) {
Display d = getWindowManager().getDefaultDisplay();
DisplayMetrics realDisplayMetrics = new DisplayMetrics();
d.getRealMetrics(realDisplayMetrics);
DisplayMetrics displayMetrics = new DisplayMetrics();
d.getMetrics(displayMetrics);
int realWidth = realDisplayMetrics.widthPixels;
int displayWidth = displayMetrics.widthPixels;
return realWidth - displayWidth;
} else {
return 50;
}
}
use of android.view.Display in project Signal-Android by WhisperSystems.
the class ConversationPopupActivity method onCreate.
@Override
protected void onCreate(Bundle bundle, @NonNull MasterSecret masterSecret) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND, WindowManager.LayoutParams.FLAG_DIM_BEHIND);
WindowManager.LayoutParams params = getWindow().getAttributes();
params.alpha = 1.0f;
params.dimAmount = 0.1f;
params.gravity = Gravity.TOP;
getWindow().setAttributes(params);
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
if (height > width)
getWindow().setLayout((int) (width * .85), (int) (height * .5));
else
getWindow().setLayout((int) (width * .7), (int) (height * .75));
super.onCreate(bundle, masterSecret);
titleView.setOnClickListener(null);
}
use of android.view.Display in project Fairphone by Kwamecorp.
the class LauncherTransitionable method mapConfigurationOriActivityInfoOri.
private int mapConfigurationOriActivityInfoOri(int configOri) {
final Display d = getWindowManager().getDefaultDisplay();
int naturalOri = Configuration.ORIENTATION_LANDSCAPE;
switch(d.getRotation()) {
case Surface.ROTATION_0:
case Surface.ROTATION_180:
// We are currently in the same basic orientation as the natural
// orientation
naturalOri = configOri;
break;
case Surface.ROTATION_90:
case Surface.ROTATION_270:
// We are currently in the other basic orientation to the natural
// orientation
naturalOri = (configOri == Configuration.ORIENTATION_LANDSCAPE) ? Configuration.ORIENTATION_PORTRAIT : Configuration.ORIENTATION_LANDSCAPE;
break;
}
int[] oriMap = { ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE, ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT, ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE };
// Since the map starts at portrait, we need to offset if this device's
// natural orientation
// is landscape.
int indexOffset = 0;
if (naturalOri == Configuration.ORIENTATION_LANDSCAPE) {
indexOffset = 1;
}
return oriMap[(d.getRotation() + indexOffset) % 4];
}
use of android.view.Display in project Fairphone by Kwamecorp.
the class Workspace method getCellLayoutMetrics.
static Rect getCellLayoutMetrics(Launcher launcher, int orientation) {
Resources res = launcher.getResources();
Display display = launcher.getWindowManager().getDefaultDisplay();
Point smallestSize = new Point();
Point largestSize = new Point();
display.getCurrentSizeRange(smallestSize, largestSize);
if (orientation == CellLayout.LANDSCAPE) {
if (mLandscapeCellLayoutMetrics == null) {
int paddingLeft = res.getDimensionPixelSize(R.dimen.workspace_left_padding_land);
int paddingRight = res.getDimensionPixelSize(R.dimen.workspace_right_padding_land);
int paddingTop = res.getDimensionPixelSize(R.dimen.workspace_top_padding_land);
int paddingBottom = res.getDimensionPixelSize(R.dimen.workspace_bottom_padding_land);
int width = largestSize.x - paddingLeft - paddingRight;
int height = smallestSize.y - paddingTop - paddingBottom;
mLandscapeCellLayoutMetrics = new Rect();
CellLayout.getMetrics(mLandscapeCellLayoutMetrics, res, width, height, LauncherModel.getCellCountX(), LauncherModel.getCellCountY(), orientation);
}
return mLandscapeCellLayoutMetrics;
} else if (orientation == CellLayout.PORTRAIT) {
if (mPortraitCellLayoutMetrics == null) {
int paddingLeft = res.getDimensionPixelSize(R.dimen.workspace_left_padding_land);
int paddingRight = res.getDimensionPixelSize(R.dimen.workspace_right_padding_land);
int paddingTop = res.getDimensionPixelSize(R.dimen.workspace_top_padding_land);
int paddingBottom = res.getDimensionPixelSize(R.dimen.workspace_bottom_padding_land);
int width = smallestSize.x - paddingLeft - paddingRight;
int height = largestSize.y - paddingTop - paddingBottom;
mPortraitCellLayoutMetrics = new Rect();
CellLayout.getMetrics(mPortraitCellLayoutMetrics, res, width, height, LauncherModel.getCellCountX(), LauncherModel.getCellCountY(), orientation);
}
return mPortraitCellLayoutMetrics;
}
return null;
}
use of android.view.Display in project Fairphone by Kwamecorp.
the class Workspace method initWorkspace.
/**
* Initializes various states for this workspace.
*/
protected void initWorkspace() {
Context context = getContext();
mCurrentPage = mDefaultPage;
Launcher.setScreen(mCurrentPage);
LauncherApplication app = (LauncherApplication) context.getApplicationContext();
mIconCache = app.getIconCache();
setWillNotDraw(false);
setChildrenDrawnWithCacheEnabled(true);
final Resources res = getResources();
try {
mBackground = res.getDrawable(R.drawable.apps_customize_bg);
} catch (Resources.NotFoundException e) {
// In this case, we will skip drawing background protection
}
mWallpaperOffset = new WallpaperOffsetInterpolator();
Display display = mLauncher.getWindowManager().getDefaultDisplay();
display.getSize(mDisplaySize);
mWallpaperTravelWidth = (int) (mDisplaySize.x * wallpaperTravelToScreenWidthRatio(mDisplaySize.x, mDisplaySize.y));
mMaxDistanceForFolderCreation = (0.55f * res.getDimensionPixelSize(R.dimen.app_icon_size));
mFlingThresholdVelocity = (int) (FLING_THRESHOLD_VELOCITY * mDensity);
}
Aggregations