AndroidResideMenu icon indicating copy to clipboard operation
AndroidResideMenu copied to clipboard

Handling view hide problem below navigation Bar

Open niteshsirohi1 opened this issue 8 years ago • 1 comments

Change this method in ResideMenu class

   @Override
    protected boolean fitSystemWindows(Rect insets) {
    // Applies the content insets to the view's padding, consuming that
    // content (modifying the insets to be 0),
    // and returning true. This behavior is off by default and can be
    // enabled through setFitsSystemWindows(boolean)
    // in api14+ devices.
    Point appUsableSize = getAppUsableScreenSize(mContext);
    Point realScreenSize = getRealScreenSize(mContext);

    boolean hasBackKey=false;
    // navigation bar at the bottom
    if (appUsableSize.y < realScreenSize.y) {
        hasBackKey=true;
    }
   // This is added to fix soft navigationBar's overlapping to content above LOLLIPOP
    int bottomPadding = viewActivity.getPaddingBottom() + insets.bottom;

    if (hasBackKey ) {//there's a navigation bar
        bottomPadding += getNavigationBarHeight();
    }

    this.setPadding(viewActivity.getPaddingLeft() + insets.left,
            viewActivity.getPaddingTop() + insets.top,
            viewActivity.getPaddingRight() + insets.right,
            bottomPadding);
    insets.left = insets.top = insets.right = insets.bottom = 0;
    return true;
}

And these methods

    public static Point getAppUsableScreenSize(Context context) {
    WindowManager windowManager = (WindowManager)   context.getSystemService(Context.WINDOW_SERVICE);
    Display display = windowManager.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    return size;
 }

  public static Point getRealScreenSize(Context context) {
    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = windowManager.getDefaultDisplay();
    Point size = new Point();

    if (Build.VERSION.SDK_INT >= 17) {
        display.getRealSize(size);
    } else if (Build.VERSION.SDK_INT >= 14) {
        try {
            size.x = (Integer) Display.class.getMethod("getRawWidth").invoke(display);
            size.y = (Integer) Display.class.getMethod("getRawHeight").invoke(display);
        } catch (IllegalAccessException e) {} catch (InvocationTargetException e) {} catch (NoSuchMethodException e) {}
    }

    return size;
}

niteshsirohi1 avatar Feb 22 '17 06:02 niteshsirohi1

What to do for Android P Navigation gesture thing. In that I am not getting App Usable Screen Size and Real Screen Size same.

Nik2505 avatar Mar 04 '19 14:03 Nik2505