Search in sources :

Example 26 with Display

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;
    }
}
Also used : DisplayMetrics(android.util.DisplayMetrics) Display(android.view.Display)

Example 27 with Display

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);
}
Also used : WindowManager(android.view.WindowManager) Display(android.view.Display)

Example 28 with Display

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];
}
Also used : SuppressLint(android.annotation.SuppressLint) Display(android.view.Display)

Example 29 with Display

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;
}
Also used : Rect(android.graphics.Rect) Resources(android.content.res.Resources) Point(android.graphics.Point) Point(android.graphics.Point) Display(android.view.Display)

Example 30 with Display

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);
}
Also used : Context(android.content.Context) Resources(android.content.res.Resources) Display(android.view.Display)

Aggregations

Display (android.view.Display)468 Point (android.graphics.Point)224 WindowManager (android.view.WindowManager)193 DisplayMetrics (android.util.DisplayMetrics)75 SuppressLint (android.annotation.SuppressLint)28 Resources (android.content.res.Resources)25 Bitmap (android.graphics.Bitmap)25 LinearLayout (android.widget.LinearLayout)25 Rect (android.graphics.Rect)23 View (android.view.View)23 RemoteException (android.os.RemoteException)22 Canvas (android.graphics.Canvas)21 Method (java.lang.reflect.Method)21 VirtualDisplay (android.hardware.display.VirtualDisplay)20 TextView (android.widget.TextView)18 Dialog (android.app.Dialog)17 Camera (android.hardware.Camera)17 Intent (android.content.Intent)16 ViewGroup (android.view.ViewGroup)16 ImageView (android.widget.ImageView)15