Search in sources :

Example 21 with Display

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

the class UiDevice method dumpWindowHierarchy.

/**
     * Helper method used for debugging to dump the current window's layout hierarchy.
     * The file root location is /data/local/tmp
     *
     * @param fileName
     * @since API Level 16
     */
public void dumpWindowHierarchy(String fileName) {
    Tracer.trace(fileName);
    AccessibilityNodeInfo root = getAutomatorBridge().getQueryController().getAccessibilityRootNode();
    if (root != null) {
        Display display = getAutomatorBridge().getDefaultDisplay();
        Point size = new Point();
        display.getSize(size);
        AccessibilityNodeInfoDumper.dumpWindowToFile(root, new File(new File(Environment.getDataDirectory(), "local/tmp"), fileName), display.getRotation(), size.x, size.y);
    }
}
Also used : AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) Point(android.graphics.Point) File(java.io.File) Display(android.view.Display)

Example 22 with Display

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

the class UiDevice method getDisplaySizeDp.

/**
     * Returns the display size in dp (device-independent pixel)
     *
     * The returned display size is adjusted per screen rotation. Also this will return the actual
     * size of the screen, rather than adjusted per system decorations (like status bar).
     *
     * @return a Point containing the display size in dp
     */
public Point getDisplaySizeDp() {
    Tracer.trace();
    Display display = getAutomatorBridge().getDefaultDisplay();
    Point p = new Point();
    display.getRealSize(p);
    DisplayMetrics metrics = new DisplayMetrics();
    display.getRealMetrics(metrics);
    float dpx = p.x / metrics.density;
    float dpy = p.y / metrics.density;
    p.x = Math.round(dpx);
    p.y = Math.round(dpy);
    return p;
}
Also used : Point(android.graphics.Point) DisplayMetrics(android.util.DisplayMetrics) Display(android.view.Display)

Example 23 with Display

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

the class UiDevice method getDisplayWidth.

/**
     * Gets the width of the display, in pixels. The width and height details
     * are reported based on the current orientation of the display.
     * @return width in pixels or zero on failure
     * @since API Level 16
     */
public int getDisplayWidth() {
    Tracer.trace();
    Display display = getAutomatorBridge().getDefaultDisplay();
    Point p = new Point();
    display.getSize(p);
    return p.x;
}
Also used : Point(android.graphics.Point) Display(android.view.Display)

Example 24 with Display

use of android.view.Display in project Reachability by sakebook.

the class Reachability method getHalfWindow.

private float getHalfWindow() {
    WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    return (size.y / 5) * 2;
}
Also used : Point(android.graphics.Point) WindowManager(android.view.WindowManager) Display(android.view.Display)

Example 25 with Display

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

the class Launcher method setWallpaperDimension.

private void setWallpaperDimension() {
    IBinder binder = ServiceManager.getService(WALLPAPER_SERVICE);
    IWallpaperService wallpaperService = IWallpaperService.Stub.asInterface(binder);
    Display display = getWindowManager().getDefaultDisplay();
    boolean isPortrait = display.getWidth() < display.getHeight();
    final int width = isPortrait ? display.getWidth() : display.getHeight();
    final int height = isPortrait ? display.getHeight() : display.getWidth();
    try {
        wallpaperService.setDimensionHints(width * WALLPAPER_SCREENS_SPAN, height);
    } catch (RemoteException e) {
    // System is dead!
    }
}
Also used : IBinder(android.os.IBinder) RemoteException(android.os.RemoteException) IWallpaperService(android.app.IWallpaperService) Display(android.view.Display)

Aggregations

Display (android.view.Display)478 Point (android.graphics.Point)231 WindowManager (android.view.WindowManager)201 DisplayMetrics (android.util.DisplayMetrics)78 SuppressLint (android.annotation.SuppressLint)29 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 Method (java.lang.reflect.Method)23 RemoteException (android.os.RemoteException)22 Canvas (android.graphics.Canvas)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 Context (android.content.Context)15