Search in sources :

Example 61 with Display

use of android.view.Display in project android_frameworks_base by DirtyUnicorns.

the class Session method performDrag.

public boolean performDrag(IWindow window, IBinder dragToken, int touchSource, float touchX, float touchY, float thumbCenterX, float thumbCenterY, ClipData data) {
    if (DEBUG_DRAG) {
        Slog.d(TAG_WM, "perform drag: win=" + window + " data=" + data);
    }
    synchronized (mService.mWindowMap) {
        if (mService.mDragState == null) {
            Slog.w(TAG_WM, "No drag prepared");
            throw new IllegalStateException("performDrag() without prepareDrag()");
        }
        if (dragToken != mService.mDragState.mToken) {
            Slog.w(TAG_WM, "Performing mismatched drag");
            throw new IllegalStateException("performDrag() does not match prepareDrag()");
        }
        WindowState callingWin = mService.windowForClientLocked(null, window, false);
        if (callingWin == null) {
            Slog.w(TAG_WM, "Bad requesting window " + window);
            // !!! TODO: throw here?
            return false;
        }
        // !!! TODO: if input is not still focused on the initiating window, fail
        // the drag initiation (e.g. an alarm window popped up just as the application
        // called performDrag()
        mService.mH.removeMessages(H.DRAG_START_TIMEOUT, window.asBinder());
        // !!! TODO: extract the current touch (x, y) in screen coordinates.  That
        // will let us eliminate the (touchX,touchY) parameters from the API.
        // !!! FIXME: put all this heavy stuff onto the mH looper, as well as
        // the actual drag event dispatch stuff in the dragstate
        final DisplayContent displayContent = callingWin.getDisplayContent();
        if (displayContent == null) {
            return false;
        }
        Display display = displayContent.getDisplay();
        mService.mDragState.register(display);
        mService.mInputMonitor.updateInputWindowsLw(true);
        if (!mService.mInputManager.transferTouchFocus(callingWin.mInputChannel, mService.mDragState.mServerChannel)) {
            Slog.e(TAG_WM, "Unable to transfer touch focus");
            mService.mDragState.unregister();
            mService.mDragState = null;
            mService.mInputMonitor.updateInputWindowsLw(true);
            return false;
        }
        mService.mDragState.mData = data;
        mService.mDragState.broadcastDragStartedLw(touchX, touchY);
        mService.mDragState.overridePointerIconLw(touchSource);
        // remember the thumb offsets for later
        mService.mDragState.mThumbOffsetX = thumbCenterX;
        mService.mDragState.mThumbOffsetY = thumbCenterY;
        // Make the surface visible at the proper location
        final SurfaceControl surfaceControl = mService.mDragState.mSurfaceControl;
        if (SHOW_LIGHT_TRANSACTIONS)
            Slog.i(TAG_WM, ">>> OPEN TRANSACTION performDrag");
        SurfaceControl.openTransaction();
        try {
            surfaceControl.setPosition(touchX - thumbCenterX, touchY - thumbCenterY);
            surfaceControl.setLayer(mService.mDragState.getDragLayerLw());
            surfaceControl.setLayerStack(display.getLayerStack());
            surfaceControl.show();
        } finally {
            SurfaceControl.closeTransaction();
            if (SHOW_LIGHT_TRANSACTIONS)
                Slog.i(TAG_WM, "<<< CLOSE TRANSACTION performDrag");
        }
        mService.mDragState.notifyLocationLw(touchX, touchY);
    }
    // success!
    return true;
}
Also used : SurfaceControl(android.view.SurfaceControl) Display(android.view.Display)

Example 62 with Display

use of android.view.Display in project android_frameworks_base by DirtyUnicorns.

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 63 with Display

use of android.view.Display in project android_frameworks_base by DirtyUnicorns.

the class TaskCardView method getStartingCardThumbnailRectForFocusedPosition.

private static Rect getStartingCardThumbnailRectForFocusedPosition(Context context, boolean hasFocus) {
    Resources res = context.getResources();
    TypedValue out = new TypedValue();
    res.getValue(R.integer.selected_scale, out, true);
    float scale = hasFocus ? out.getFloat() : 1;
    int width = res.getDimensionPixelOffset(R.dimen.recents_tv_card_width);
    int widthDelta = (int) (width * scale - width);
    int height = res.getDimensionPixelOffset(R.dimen.recents_tv_screenshot_height);
    int heightDelta = (int) (height * scale - height);
    int topMargin = res.getDimensionPixelOffset(R.dimen.recents_tv_gird_row_top_margin);
    int headerHeight = res.getDimensionPixelOffset(R.dimen.recents_tv_card_extra_badge_size) + res.getDimensionPixelOffset(R.dimen.recents_tv_icon_padding_bottom);
    int headerHeightDelta = (int) (headerHeight * scale - headerHeight);
    int dismissAreaHeight = res.getDimensionPixelOffset(R.dimen.recents_tv_dismiss_icon_top_margin) + res.getDimensionPixelOffset(R.dimen.recents_tv_dismiss_icon_bottom_margin) + res.getDimensionPixelOffset(R.dimen.recents_tv_dismiss_icon_size) + res.getDimensionPixelOffset(R.dimen.recents_tv_dismiss_text_size);
    int dismissAreaHeightDelta = (int) (dismissAreaHeight * scale - dismissAreaHeight);
    int totalHeightDelta = heightDelta + headerHeightDelta + dismissAreaHeightDelta;
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int screenWidth = size.x;
    return new Rect(screenWidth / 2 - width / 2 - widthDelta / 2, topMargin - totalHeightDelta / 2 + (int) (headerHeight * scale), screenWidth / 2 + width / 2 + widthDelta / 2, topMargin - totalHeightDelta / 2 + (int) (headerHeight * scale) + (int) (height * scale));
}
Also used : Rect(android.graphics.Rect) Resources(android.content.res.Resources) Point(android.graphics.Point) Point(android.graphics.Point) TypedValue(android.util.TypedValue) WindowManager(android.view.WindowManager) Display(android.view.Display)

Example 64 with Display

use of android.view.Display in project android_frameworks_base by DirtyUnicorns.

the class TaskCardView method getStartingCardThumbnailRectForStartPosition.

private static Rect getStartingCardThumbnailRectForStartPosition(Context context, boolean hasFocus) {
    Resources res = context.getResources();
    int width = res.getDimensionPixelOffset(R.dimen.recents_tv_card_width);
    int totalSpacing = res.getDimensionPixelOffset(R.dimen.recents_tv_gird_card_spacing) * 2;
    if (hasFocus) {
        totalSpacing += res.getDimensionPixelOffset(R.dimen.recents_tv_gird_focused_card_delta);
    }
    int height = res.getDimensionPixelOffset(R.dimen.recents_tv_screenshot_height);
    int topMargin = res.getDimensionPixelOffset(R.dimen.recents_tv_gird_row_top_margin);
    int headerHeight = res.getDimensionPixelOffset(R.dimen.recents_tv_card_extra_badge_size) + res.getDimensionPixelOffset(R.dimen.recents_tv_icon_padding_bottom);
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int screenWidth = size.x;
    return new Rect(screenWidth / 2 + width / 2 + totalSpacing, topMargin + headerHeight, screenWidth / 2 + width / 2 + totalSpacing + width, topMargin + headerHeight + height);
}
Also used : Rect(android.graphics.Rect) Resources(android.content.res.Resources) Point(android.graphics.Point) Point(android.graphics.Point) WindowManager(android.view.WindowManager) Display(android.view.Display)

Example 65 with Display

use of android.view.Display in project android_frameworks_base by AOSPA.

the class TaskCardView method getStartingCardThumbnailRectForFocusedPosition.

private static Rect getStartingCardThumbnailRectForFocusedPosition(Context context, boolean hasFocus) {
    Resources res = context.getResources();
    TypedValue out = new TypedValue();
    res.getValue(R.integer.selected_scale, out, true);
    float scale = hasFocus ? out.getFloat() : 1;
    int width = res.getDimensionPixelOffset(R.dimen.recents_tv_card_width);
    int widthDelta = (int) (width * scale - width);
    int height = res.getDimensionPixelOffset(R.dimen.recents_tv_screenshot_height);
    int heightDelta = (int) (height * scale - height);
    int topMargin = res.getDimensionPixelOffset(R.dimen.recents_tv_gird_row_top_margin);
    int headerHeight = res.getDimensionPixelOffset(R.dimen.recents_tv_card_extra_badge_size) + res.getDimensionPixelOffset(R.dimen.recents_tv_icon_padding_bottom);
    int headerHeightDelta = (int) (headerHeight * scale - headerHeight);
    int dismissAreaHeight = res.getDimensionPixelOffset(R.dimen.recents_tv_dismiss_icon_top_margin) + res.getDimensionPixelOffset(R.dimen.recents_tv_dismiss_icon_bottom_margin) + res.getDimensionPixelOffset(R.dimen.recents_tv_dismiss_icon_size) + res.getDimensionPixelOffset(R.dimen.recents_tv_dismiss_text_size);
    int dismissAreaHeightDelta = (int) (dismissAreaHeight * scale - dismissAreaHeight);
    int totalHeightDelta = heightDelta + headerHeightDelta + dismissAreaHeightDelta;
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int screenWidth = size.x;
    return new Rect(screenWidth / 2 - width / 2 - widthDelta / 2, topMargin - totalHeightDelta / 2 + (int) (headerHeight * scale), screenWidth / 2 + width / 2 + widthDelta / 2, topMargin - totalHeightDelta / 2 + (int) (headerHeight * scale) + (int) (height * scale));
}
Also used : Rect(android.graphics.Rect) Resources(android.content.res.Resources) Point(android.graphics.Point) Point(android.graphics.Point) TypedValue(android.util.TypedValue) WindowManager(android.view.WindowManager) 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