find shelf position & autohide is enabled or not in android for Chromebook

151 views Asked by At

this question is part of this question #1

I'm creating features to capture screenshot into Android app. After capturing a screenshot, I am cropping navigation bar height from bitmap using below code. where height - getNavBarHeight() will crop bitmap from the bottom(So this is used when the shelf is at the bottom side). But Chromebook gives the facility to move shelf at left, bottom right (See screenshots). So as per todo, I need to crop bitmap accordingly

if (Utils.isChromeBookDevice(FloatingOverlayViewService.this)) {
    bitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height - getNavBarHeight());//width & height is width & height of entire screen
    // TODO: 9/11/20 if shelf is in left x = getNavBarHeight(),
    //  if shelf is in right width = width - getNavBarHeight(),
    //  if shelf is in bottom height  = height - getNavBarHeight()
} else
    bitmap = Bitmap.createBitmap(bitmap, 0, statusBarHeight, width, height - statusBarHeight);

/** return the height of navigation bar */
private int getNavBarHeight() {
    int result = 0;
    int resourceId = getResources().getIdentifier("navigation_bar_height", "dimen", "android");
    if (resourceId > 0) {
        return getResources().getDimensionPixelSize(resourceId);
    }
    return result;
}

So the main question is how to crop navigation bar when it is at the left or right side?

You can see my problem in these screenshots when the shelf is at the bottom I can crop it using the above code. But what about left and right?

and question #2 is when the shelf is auto-hidden I don't need to crop navigation bar using the above code. So Also I need to detect that autohide shelf is on or off

0

There are 0 answers