Search in sources :

Example 81 with Display

use of android.view.Display in project platform_frameworks_base by android.

the class FakeBackgroundService method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    mHandler.sendEmptyMessageDelayed(MSG_TICK, TICK_DELAY);
    final WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    final Display display = wm.getDefaultDisplay();
    // Make a fake window that is always around eating graphics resources.
    FakeView view = new FakeView(this);
    Dialog dialog = new Dialog(this, android.R.style.Theme_Holo_Dialog);
    dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
    dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED | WindowManager.LayoutParams.FLAG_DIM_BEHIND);
    dialog.getWindow().setDimAmount(0);
    dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();
    int maxSize = display.getMaximumSizeDimension();
    maxSize *= 2;
    lp.x = maxSize;
    lp.y = maxSize;
    lp.setTitle(getPackageName() + ":background");
    dialog.getWindow().setAttributes(lp);
    dialog.getWindow().setContentView(view);
    dialog.show();
}
Also used : Dialog(android.app.Dialog) WindowManager(android.view.WindowManager) Display(android.view.Display)

Example 82 with Display

use of android.view.Display in project platform_frameworks_base by android.

the class DividerView method updateDisplayInfo.

private void updateDisplayInfo() {
    final DisplayManager displayManager = (DisplayManager) mContext.getSystemService(Context.DISPLAY_SERVICE);
    Display display = displayManager.getDisplay(Display.DEFAULT_DISPLAY);
    final DisplayInfo info = new DisplayInfo();
    display.getDisplayInfo(info);
    mDisplayWidth = info.logicalWidth;
    mDisplayHeight = info.logicalHeight;
    mSnapAlgorithm = null;
    initializeSnapAlgorithm();
}
Also used : DisplayInfo(android.view.DisplayInfo) DisplayManager(android.hardware.display.DisplayManager) Display(android.view.Display)

Example 83 with Display

use of android.view.Display in project platform_frameworks_base by android.

the class DividerView method calculateAppSurfaceFlingerVsyncOffsetMs.

/**
     * This method calculates the offset between vsync-surfaceflinger and vsync-app. If vsync-app
     * is a couple of milliseconds before vsync-sf, a touch or animation event that causes the
     * stacks to be resized are sometimes processed before the vsync-sf tick, and sometimes after,
     * which leads to jank. Figure out this difference here and then post all the touch/animation
     * events to start being processed at vsync-sf.
     *
     * @return The offset between vsync-app and vsync-sf, or 0 if vsync app happens after vsync-sf.
     */
private long calculateAppSurfaceFlingerVsyncOffsetMs() {
    Display display = getDisplay();
    // Calculate vsync offset from SurfaceFlinger.
    // See frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp:getDisplayConfigs
    long vsyncPeriod = (long) (ONE_S_IN_NS / display.getRefreshRate());
    long sfVsyncOffset = vsyncPeriod - (display.getPresentationDeadlineNanos() - ONE_MS_IN_NS);
    return Math.max(0, (sfVsyncOffset - display.getAppVsyncOffsetNanos()) / ONE_MS_IN_NS);
}
Also used : Display(android.view.Display)

Example 84 with Display

use of android.view.Display in project platform_frameworks_base by android.

the class NavBarTuner method inflatePreview.

private void inflatePreview(ViewGroup view) {
    Display display = getActivity().getWindowManager().getDefaultDisplay();
    boolean isRotated = display.getRotation() == Surface.ROTATION_90 || display.getRotation() == Surface.ROTATION_270;
    Configuration config = new Configuration(getContext().getResources().getConfiguration());
    boolean isPhoneLandscape = isRotated && (config.smallestScreenWidthDp < 600);
    final float scale = isPhoneLandscape ? PREVIEW_SCALE_LANDSCAPE : PREVIEW_SCALE;
    config.densityDpi = (int) (config.densityDpi * scale);
    mPreview = (PreviewNavInflater) LayoutInflater.from(getContext().createConfigurationContext(config)).inflate(R.layout.nav_bar_tuner_inflater, view, false);
    final ViewGroup.LayoutParams layoutParams = mPreview.getLayoutParams();
    layoutParams.width = (int) ((isPhoneLandscape ? display.getHeight() : display.getWidth()) * scale);
    // Not sure why, but the height dimen is not being scaled with the dp, set it manually
    // for now.
    layoutParams.height = (int) (layoutParams.height * scale);
    if (isPhoneLandscape) {
        int width = layoutParams.width;
        layoutParams.width = layoutParams.height;
        layoutParams.height = width;
    }
    view.addView(mPreview);
    if (isRotated) {
        mPreview.findViewById(R.id.rot0).setVisibility(View.GONE);
        final View rot90 = mPreview.findViewById(R.id.rot90);
    } else {
        mPreview.findViewById(R.id.rot90).setVisibility(View.GONE);
        final View rot0 = mPreview.findViewById(R.id.rot0);
    }
}
Also used : Configuration(android.content.res.Configuration) ViewGroup(android.view.ViewGroup) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) Display(android.view.Display)

Example 85 with Display

use of android.view.Display in project platform_frameworks_base by android.

the class WallpaperCropActivity method cropImageAndSetWallpaper.

protected void cropImageAndSetWallpaper(Uri uri, OnBitmapCroppedHandler onBitmapCroppedHandler, final boolean finishActivityWhenDone) {
    boolean centerCrop = getResources().getBoolean(R.bool.center_crop);
    // Get the crop
    boolean ltr = mCropView.getLayoutDirection() == View.LAYOUT_DIRECTION_LTR;
    Display d = getWindowManager().getDefaultDisplay();
    Point displaySize = new Point();
    d.getSize(displaySize);
    boolean isPortrait = displaySize.x < displaySize.y;
    Point defaultWallpaperSize = getDefaultWallpaperSize(getResources(), getWindowManager());
    // Get the crop
    RectF cropRect = mCropView.getCrop();
    Point inSize = mCropView.getSourceDimensions();
    int cropRotation = mCropView.getImageRotation();
    float cropScale = mCropView.getWidth() / (float) cropRect.width();
    Matrix rotateMatrix = new Matrix();
    rotateMatrix.setRotate(cropRotation);
    float[] rotatedInSize = new float[] { inSize.x, inSize.y };
    rotateMatrix.mapPoints(rotatedInSize);
    rotatedInSize[0] = Math.abs(rotatedInSize[0]);
    rotatedInSize[1] = Math.abs(rotatedInSize[1]);
    // Due to rounding errors in the cropview renderer the edges can be slightly offset
    // therefore we ensure that the boundaries are sanely defined
    cropRect.left = Math.max(0, cropRect.left);
    cropRect.right = Math.min(rotatedInSize[0], cropRect.right);
    cropRect.top = Math.max(0, cropRect.top);
    cropRect.bottom = Math.min(rotatedInSize[1], cropRect.bottom);
    // ADJUST CROP WIDTH
    // Extend the crop all the way to the right, for parallax
    // (or all the way to the left, in RTL)
    float extraSpace;
    if (centerCrop) {
        extraSpace = 2f * Math.min(rotatedInSize[0] - cropRect.right, cropRect.left);
    } else {
        extraSpace = ltr ? rotatedInSize[0] - cropRect.right : cropRect.left;
    }
    // Cap the amount of extra width
    float maxExtraSpace = defaultWallpaperSize.x / cropScale - cropRect.width();
    extraSpace = Math.min(extraSpace, maxExtraSpace);
    if (centerCrop) {
        cropRect.left -= extraSpace / 2f;
        cropRect.right += extraSpace / 2f;
    } else {
        if (ltr) {
            cropRect.right += extraSpace;
        } else {
            cropRect.left -= extraSpace;
        }
    }
    // ADJUST CROP HEIGHT
    if (isPortrait) {
        cropRect.bottom = cropRect.top + defaultWallpaperSize.y / cropScale;
    } else {
        // LANDSCAPE
        float extraPortraitHeight = defaultWallpaperSize.y / cropScale - cropRect.height();
        float expandHeight = Math.min(Math.min(rotatedInSize[1] - cropRect.bottom, cropRect.top), extraPortraitHeight / 2);
        cropRect.top -= expandHeight;
        cropRect.bottom += expandHeight;
    }
    final int outWidth = (int) Math.round(cropRect.width() * cropScale);
    final int outHeight = (int) Math.round(cropRect.height() * cropScale);
    Runnable onEndCrop = new Runnable() {

        public void run() {
            if (finishActivityWhenDone) {
                setResult(Activity.RESULT_OK);
                finish();
            }
        }
    };
    BitmapCropTask cropTask = new BitmapCropTask(this, uri, cropRect, cropRotation, outWidth, outHeight, true, false, onEndCrop);
    if (onBitmapCroppedHandler != null) {
        cropTask.setOnBitmapCropped(onBitmapCroppedHandler);
    }
    cropTask.execute();
}
Also used : RectF(android.graphics.RectF) Matrix(android.graphics.Matrix) Point(android.graphics.Point) Point(android.graphics.Point) Paint(android.graphics.Paint) Display(android.view.Display)

Aggregations

Display (android.view.Display)697 Point (android.graphics.Point)356 WindowManager (android.view.WindowManager)349 DisplayMetrics (android.util.DisplayMetrics)126 View (android.view.View)57 TextView (android.widget.TextView)54 LinearLayout (android.widget.LinearLayout)45 SuppressLint (android.annotation.SuppressLint)43 Method (java.lang.reflect.Method)41 ImageView (android.widget.ImageView)39 Bitmap (android.graphics.Bitmap)38 Resources (android.content.res.Resources)36 Intent (android.content.Intent)34 Camera (android.hardware.Camera)31 Context (android.content.Context)26 Rect (android.graphics.Rect)25 IOException (java.io.IOException)24 ViewGroup (android.view.ViewGroup)23 Canvas (android.graphics.Canvas)22 RemoteException (android.os.RemoteException)22