Example usage for android.view Display getRectSize

List of usage examples for android.view Display getRectSize

Introduction

In this page you can find the example usage for android.view Display getRectSize.

Prototype

public void getRectSize(Rect outSize) 

Source Link

Document

Gets the size of the display as a rectangle, in pixels.

Usage

From source file:org.acra.collector.DisplayManagerCollector.java

@NonNull
private static String collectRectSize(@NonNull Display display) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
        final Rect size = new Rect();
        display.getRectSize(size);
        return display.getDisplayId() + ".rectSize=[" + size.top + ',' + size.left + ',' + size.width() + ','
                + size.height() + ']' + '\n';
    }/*from w  w  w. j a  va 2s . c  o  m*/
    return "";
}

From source file:me.wimanacra.collector.DisplayManagerCollector.java

private static void collectRectSize(@NonNull Display display, JSONObject container) throws JSONException {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
        final Rect size = new Rect();
        display.getRectSize(size);
        container.put("rectSize",
                new JSONArray(Arrays.asList(size.top, size.left, size.width(), size.height())));
    }//  www.  j  a  v  a 2s.c  o m
}

From source file:org.sufficientlysecure.keychain.gm.GmAccessibilityService.java

@SuppressLint("RtlHardcoded")
private void drawOverlay(AccessibilityNodeInfo node, View.OnClickListener onClickListener) {

    mOverlay = new FrameLayout(this);

    // must be encapsulated into FrameLayout for animation
    FrameLayout mAnimatedChild = new FrameLayout(this);
    LayoutInflater systemInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final Context contextThemeWrapper = new ContextThemeWrapper(this, R.style.FixedBottomSheetTheme);
    LayoutInflater inflater = systemInflater.cloneInContext(contextThemeWrapper);

    View child = inflater.inflate(R.layout.fixed_bottom_sheet, null);
    mAnimatedChild.addView(child);//from  ww  w . j  a va  2  s .  c o  m

    Button b = (Button) child.findViewById(R.id.fixed_bottom_sheet_button);
    b.setText(R.string.decrypt_with_openkeychain);
    b.setOnClickListener(onClickListener);

    ImageButton close = (ImageButton) child.findViewById(R.id.fixed_bottom_sheet_close);
    close.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            closeOverlay();
        }
    });

    Rect webviewRect = new Rect();
    node.getBoundsInScreen(webviewRect);

    Display display = mWindowManager.getDefaultDisplay();
    Rect displayRect = new Rect();
    display.getRectSize(displayRect);

    int xpos = webviewRect.left;
    int ypos = webviewRect.top - getStatusBarHeight() < getToolbarHeight() ? getToolbarHeight()
            : webviewRect.top - getStatusBarHeight();

    int width = webviewRect.width();
    int height = webviewRect.bottom < displayRect.height()
            ? webviewRect.bottom - getToolbarHeight() - getStatusBarHeight()
            : displayRect.height() - ypos - getStatusBarHeight();

    WindowManager.LayoutParams params = new WindowManager.LayoutParams(width, height, xpos, ypos,
            WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
            PixelFormat.TRANSLUCENT);
    params.gravity = Gravity.TOP | Gravity.LEFT;
    params.windowAnimations = R.style.OverlayAnimation;
    mWindowManager.addView(mOverlay, params);
    mOverlay.addView(mAnimatedChild);
}

From source file:org.alfresco.mobile.android.application.extension.samsung.pen.SNoteEditorActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    AnalyticsHelper.reportScreen(this, AnalyticsManager.SCREEN_SAMSUNG_SNOTE_EDITOR);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.snote_editor);
    context = this;

    // TOOLBAR//from   w  ww  .  java  2s . c  o m
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    if (toolbar != null) {
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);
    }

    // Retrieve information
    String action = getIntent().getAction();
    if (Intent.ACTION_VIEW.equals(action)) {
        if (getIntent().getData() != null) {
            String filePath = BaseActionUtils.getPath(this, getIntent().getData());
            file = new File(filePath);
        } else {
            AlfrescoNotificationManager.getInstance(this).showLongToast(getString(R.string.editor_error_open));
            finish();
            return;
        }
    }

    // Init Spen
    boolean isSpenFeatureEnabled = false;
    Spen spenPackage = new Spen();
    try {
        spenPackage.initialize(this);
        isSpenFeatureEnabled = spenPackage.isFeatureEnabled(Spen.DEVICE_PEN);
    } catch (SsdkUnsupportedException e) {
        if (SNoteUtils.processUnsupportedException(this, e)) {
            return;
        }
    } catch (Exception e1) {
        Log.e(TAG, Log.getStackTraceString(e1));
        finish();
    }

    FrameLayout spenViewContainer = (FrameLayout) findViewById(R.id.spenViewContainer);
    RelativeLayout spenViewLayout = (RelativeLayout) findViewById(R.id.spenViewLayout);

    // PEN SETTINGS
    spenSettingView = new SpenSettingPenLayout(context, "", spenViewLayout);
    if (spenSettingView == null) {
        finish();
    }
    spenViewContainer.addView(spenSettingView);

    // ERASER SETTINGS
    eraserSettingView = new SpenSettingEraserLayout(context, "", spenViewLayout);
    if (eraserSettingView == null) {
        finish();
    }
    spenViewContainer.addView(eraserSettingView);

    // TEXT SETTINGS
    textSettingView = new SpenSettingTextLayout(context, "", new HashMap<String, String>(), spenViewLayout);
    if (textSettingView == null) {
        finish();
    }
    spenViewContainer.addView(textSettingView);

    // SELECTION SETTINGS
    selectionSettingView = new SpenSettingSelectionLayout(context, "", spenViewLayout);
    if (textSettingView == null) {
        finish();
    }
    spenViewContainer.addView(selectionSettingView);

    // SURFACE VIEW
    spenSurfaceView = new SpenSurfaceView(context);
    if (spenSurfaceView == null) {
        finish();
    }
    spenViewLayout.addView(spenSurfaceView);
    spenSettingView.setCanvasView(spenSurfaceView);
    eraserSettingView.setCanvasView(spenSurfaceView);
    textSettingView.setCanvasView(spenSurfaceView);
    selectionSettingView.setCanvasView(spenSurfaceView);

    // NOTE DOCUMENT
    Display display = getWindowManager().getDefaultDisplay();
    Rect mScreenRect = new Rect();
    display.getRectSize(mScreenRect);
    try {
        if (file != null && file.length() > 0) {
            spenNoteDoc = new SpenNoteDoc(context, file.getAbsolutePath(), mScreenRect.width(),
                    SpenNoteDoc.MODE_WRITABLE);
            if (spenNoteDoc.getPageCount() == 0) {
                spenPageDoc = spenNoteDoc.appendPage();
            } else {
                spenPageDoc = spenNoteDoc.getPage(spenNoteDoc.getLastEditedPageIndex());
            }
        } else {
            spenNoteDoc = new SpenNoteDoc(context, SpenNoteDoc.ORIENTATION_LANDSCAPE,
                    (mScreenRect.width() > mScreenRect.height()) ? mScreenRect.width() : mScreenRect.height(),
                    (mScreenRect.width() < mScreenRect.height()) ? mScreenRect.width() : mScreenRect.height());
            spenPageDoc = spenNoteDoc.appendPage();
            spenPageDoc.setBackgroundColor(getResources().getColor(android.R.color.white));
            spenPageDoc.clearHistory();
        }
    } catch (Exception e) {
        finish();
    }

    // Display Document
    spenSurfaceView.setPageDoc(spenPageDoc, true);
    spenSurfaceView.setBlankColor(getResources().getColor(R.color.grey_light));

    if (!isSpenFeatureEnabled) {
        mToolType = SpenSurfaceView.TOOL_FINGER;
        spenSurfaceView.setToolTypeAction(mToolType, SpenSurfaceView.ACTION_STROKE);

        // Touch listener for swipe if on Finger mode
        gdt = new GestureDetector(context, new GestureListener());
        spenSurfaceView.setOnTouchListener(touchListener);
    }

    // Init Pages
    mTxtView = (TextView) findViewById(R.id.spen_page);
    mTxtView.setText(String.format(getString(R.string.editor_paging),
            String.valueOf((spenNoteDoc.getPageIndexById(spenPageDoc.getId()) + 1)),
            spenNoteDoc.getPageCount()));

    // INIT Setting & Listeners
    initSettingInfo();
    spenSurfaceView.setTouchListener(penTouchListener);
    spenSurfaceView.setControlListener(controlListener);
    spenSurfaceView.setFlickListener(mFlickListener);

}