AndroidResideMenu icon indicating copy to clipboard operation
AndroidResideMenu copied to clipboard

Bottom White Bar in the larger screen size

Open Paridhi2502 opened this issue 6 years ago • 5 comments

Hello,

I have facing a issue is that on larger screen like in cell SAMSUNG GALAXY 7 bottom white bar is showing. Please have a look and help to resolved this issue.

Paridhi2502 avatar Apr 09 '18 06:04 Paridhi2502

any updates on same? I am facing the same issue of bottom bar.

swapnils-cuelogic avatar Jun 11 '18 14:06 swapnils-cuelogic

Nops

On Mon, Jun 11, 2018 at 8:02 PM, Swapnil Sonar [email protected] wrote:

any updates on same? I am facing the same issue of bottom bar.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/SpecialCyCi/AndroidResideMenu/issues/144#issuecomment-396264489, or mute the thread https://github.com/notifications/unsubscribe-auth/Aff_fErs5ywYhcwUeOE7O0SqM0YYklIeks5t7n99gaJpZM4TL_Wl .

-- Regards,

Paridhi Kothari Sr. Android developer Softinator Techlabs

Paridhi2502 avatar Jun 13 '18 06:06 Paridhi2502

Hello @Paridhi2502 if you are using something like below DecoreView in activity please remove these lines this worked for me.

View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
decorView.setSystemUiVisibility(uiOptions);

ArisChoice avatar Jul 11 '18 06:07 ArisChoice

Hi.. I am still facing the white bar at the bottom in my device samsung plus 8 and tablet mobile. Android version is 8. img-20181004-wa0000

I am attaching the screenshot of device and also sending reside menu java class (i have modified it).. Please have a look and let me know.

public class ResideMenu extends FrameLayout {

public static final int DIRECTION_LEFT = 0;
// public static final int DIRECTION_RIGHT = 1;
private static final int PRESSED_MOVE_HORIZONTAL = 2;
private static final int PRESSED_DOWN = 3;
private static final int PRESSED_DONE = 4;
private static final int PRESSED_MOVE_VERTICAL = 5;
private ImageView mresidemenu_cross_click;
private ImageView imageViewShadow;
private ImageView imageViewBackground;
private LinearLayout layoutLeftMenu;
//  private LinearLayout layoutRightMenu;
private View scrollViewLeftMenu;
// private View scrollViewRightMenu;
private View scrollViewMenu;
/**
 * Current attaching activity.
 */
private Activity activity;
private String TAG = "ResideMenu";
/**
 * The DecorView of current activity.
 */
private ViewGroup viewDecor;
private TouchDisableView viewActivity;
/**
 * The flag of menu opening status.
 */
private boolean isOpened;
private float shadowAdjustScaleX;
private float shadowAdjustScaleY;
/**
 * Views which need stop to intercept touch events.
 */
private List<View> ignoredViews;
private List<ResideMenuItem> leftMenuItems;
// private List<ResideMenuItem> rightMenuItems;
private DisplayMetrics displayMetrics = new DisplayMetrics();
private OnMenuListener menuListener;
private float lastRawX;
private boolean isInIgnoredView = false;
private int scaleDirection = DIRECTION_LEFT;
private int pressedState = PRESSED_DOWN;
private List<Integer> disabledSwipeDirection = new ArrayList<Integer>();
// Valid scale factor is between 0.0f and 1.0f.
private float mScaleValue = 0.5f;
private boolean mUse3D;
private static final int ROTATE_Y_ANGLE = 10;

public ResideMenu(Context context) {
    super(context);
    initViews(context, -1, -1);
}

private static final int REQUEST_PHONE_CALL = 1;

/**
 * This constructor provides you to create menus with your own custom
 * layouts, but if you use custom menu then do not call addMenuItem because
 * it will not be able to find default views
 */
public ResideMenu(Context context, int customLeftMenuId,
                  int customRightMenuId) {
    super(context);
    initViews(context, customLeftMenuId, customRightMenuId);
}

private void initViews(final Context context, int customLeftMenuId,
                       int customRightMenuId) {
    LayoutInflater inflater = (LayoutInflater) context
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.residemenu_custom, this);
    mresidemenu_cross_click = findViewById(R.id.residemenu_cross_click);
    mresidemenu_cross_click.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            closeMenu();
        }
    });


    if (customLeftMenuId >= 0) {
        scrollViewLeftMenu = inflater.inflate(customLeftMenuId, this, false);
    } else {
        scrollViewLeftMenu = inflater.inflate(
                R.layout.residemenu_custom_left_scrollview, this, false);
        layoutLeftMenu = scrollViewLeftMenu.findViewById(R.id.layout_left_menu);
    }
    
    imageViewShadow = findViewById(R.id.iv_shadow);
    imageViewBackground = findViewById(R.id.iv_background);

    FrameLayout menuHolder = findViewById(R.id.sv_menu_holder);
    menuHolder.addView(scrollViewLeftMenu);

}


/**
 * Returns left menu view so you can findViews and do whatever you want with
 */
public View getLeftMenuView() {
    return scrollViewLeftMenu;
}

@Override
protected boolean fitSystemWindows(Rect insets) {
    setMyPadding(insets);
    return true;
}


@Override
public WindowInsets onApplyWindowInsets(WindowInsets insets) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
        Rect rect = new Rect(
                insets.getSystemWindowInsetLeft(),
                insets.getSystemWindowInsetTop(),
                insets.getSystemWindowInsetRight(),
                insets.getSystemWindowInsetBottom()
        );
        setMyPadding(rect);

        return insets.consumeSystemWindowInsets();
    } else {
            }
    return super.onApplyWindowInsets(insets);
}

private void setMyPadding(Rect rect) {
    // setPadding(0, 70,0,70);
    int bottomPadding = rect.bottom;
    Log.d("RESIDE MENU ", "Padding " + rect.left + " " + rect.top + " " + rect.right + " " + rect.bottom);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT || isTablet(getContext())) {
        if (hasNavBar()) {
            WindowManager manager = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
            switch (manager.getDefaultDisplay().getRotation()) {
                case Surface.ROTATION_90:
                    rect.right += viewActivity.getPaddingRight() + getNavBarWidth();
                    break;
                case Surface.ROTATION_180:
                    rect.top += viewActivity.getPaddingTop() + getNavBarHeight();
                    break;
                case Surface.ROTATION_270:
                    rect.left += viewActivity.getPaddingLeft() + getNavBarWidth();
                    break;
                default:
                    rect.bottom += viewActivity.getPaddingBottom() + getNavBarWidth();
            }
        }
        if (isTablet(getContext())) {
            rect.bottom = 0;
        }
        setPadding(rect.left, rect.top, rect.right, rect.bottom);
        Log.d("RESIDE MENU2  ", "Padding " + rect.left + " " + rect.top + " " + rect.right + " " + rect.bottom);

    } else {

        // This is added to fix soft navigationBar's overlapping to content above LOLLIPOP
        bottomPadding = viewActivity.getPaddingBottom() + rect.bottom;
        boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
        boolean hasHomeKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_HOME);
        if (!hasBackKey || !hasHomeKey) {//there's a navigation bar
            bottomPadding += getNavigationBarHeight();
        }

        this.setPadding(viewActivity.getPaddingLeft() + rect.left,
                viewActivity.getPaddingTop() + rect.top,
                viewActivity.getPaddingRight() + rect.right,
                bottomPadding);
        rect.left = rect.top = rect.right = rect.bottom = 0;
        // setPadding(rect.left, rect.top, rect.right, rect.bottom);
        //  setPadding(20, 20,20,20);
        Log.d("RESIDE MENU3 ", "Padding " + rect.left + " " + rect.top + " " + rect.right + " " + rect.bottom);

    }
    // int navHeight = getNavBarHeight();
}

public boolean isTablet(Context context) {
    try {
        // Compute screen size
        // Context context = (put the class name of your Activity here eg MyActivity).this;
        DisplayMetrics dm = context.getResources().getDisplayMetrics();
        float screenWidth = dm.widthPixels / dm.xdpi;
        float screenHeight = dm.heightPixels / dm.ydpi;
        double size = Math.sqrt(Math.pow(screenWidth, 2) +
                Math.pow(screenHeight, 2));
        // Tablet devices have a screen size greater than 6 inches
        return size >= 6;
    } catch (Throwable t) {
        //  Log.e("sscreen size", t.toString());
        return false;
    }
}

private int getNavBarWidth() {
    return getNavBarDimen("navigation_bar_width");
}

private int getNavBarHeight() {
    return getNavBarDimen("navigation_bar_height");
}

private int getNavBarDimen(String resourceString) {
    Resources r = getResources();
    int id = r.getIdentifier(resourceString, "dimen", "android");
    if (id > 0) {
        return r.getDimensionPixelSize(id);
    } else {
        return 0;
    }
}

/**
 * check is system has navigation bar or not* http://stackoverflow.com/a/29120269/3758898
 *
 * @return true if navigation bar is present or false
 */
boolean hasNavBar() {
    try {
        // check for emulator
        Class<?> serviceManager = Class.forName("android.os.ServiceManager");
        IBinder serviceBinder = (IBinder) serviceManager.getMethod("getService", String.class).invoke(serviceManager, "window");
        Class<?> stub = Class.forName("android.view.IWindowManager$Stub");
        Object windowManagerService = stub.getMethod("asInterface", IBinder.class).invoke(stub, serviceBinder);
        Method hasNavigationBar = windowManagerService.getClass().getMethod("hasNavigationBar");
        return (boolean) hasNavigationBar.invoke(windowManagerService);
    } catch (ClassNotFoundException
            | ClassCastException
            | NoSuchMethodException
            | SecurityException
            | IllegalAccessException
            | IllegalArgumentException
            | InvocationTargetException e) {

        boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
        boolean hasHomeKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_HOME);
        return !hasHomeKey && !hasBackKey;
    }
}


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;
}


private int getNavigationBarHeight() {
    Resources resources = getResources();
    int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
    if (resourceId > 0) {
        return resources.getDimensionPixelSize(resourceId);
    }
    return 0;
}

/**
 * Set up the activity;
 *
 * @param activity
 */
public void attachToActivity(Activity activity) {
    initValue(activity);
    setShadowAdjustScaleXByOrientation();
    viewDecor.addView(this, 0);

    if (getNavigationBarSize(getContext()).x > 0 && getNavigationBarSize(getContext()).y > 0) {
        this.postDelayed(new Runnable() {
            @Override
            public void run() {
                setPadding(getPaddingLeft(),
                        getPaddingTop(), getPaddingRight(),
                        getPaddingBottom());
            }
        }, 100);
    }
}

private void initValue(Activity activity) {
    this.activity = activity;
    leftMenuItems = new ArrayList<>();
    //rightMenuItems = new ArrayList<ResideMenuItem>();
    ignoredViews = new ArrayList<>();
    viewDecor = (ViewGroup) activity.getWindow().getDecorView();
    viewActivity = new TouchDisableView(this.activity);

    View mContent = viewDecor.getChildAt(0);
    viewDecor.removeViewAt(0);
    viewActivity.setContent(mContent);
    addView(viewActivity);

    ViewGroup parent = (ViewGroup) scrollViewLeftMenu.getParent();
    parent.removeView(scrollViewLeftMenu);
    //  parent.removeView(scrollViewRightMenu);
}

private void setShadowAdjustScaleXByOrientation() {
    int orientation = getResources().getConfiguration().orientation;
    if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
        shadowAdjustScaleX = 0.034f;
        shadowAdjustScaleY = 0.12f;
    } else if (orientation == Configuration.ORIENTATION_PORTRAIT) {
        shadowAdjustScaleX = 0.06f;
        shadowAdjustScaleY = 0.07f;
    }
}

/**
 * 00
 * Set the background image of menu;
 *
 * @param imageResource
 */
public void setBackground(int imageResource) {
    imageViewBackground.setImageResource(imageResource);
}

/**
 * The visibility of the shadow under the activity;
 *
 * @param isVisible
 */
public void setShadowVisible(boolean isVisible) {
    if (isVisible)
        imageViewShadow.setBackgroundResource(R.drawable.shadow);
    else
        imageViewShadow.setBackgroundResource(0);
}

/**
 * Add a single item to the left menu;
 * <p/>
 * WARNING: It will be removed from v2.0.
 *
 * @param menuItem
 */
@Deprecated
public void addMenuItem(ResideMenuItem menuItem) {
    this.leftMenuItems.add(menuItem);
    layoutLeftMenu.addView(menuItem);
}

/**
 * Add a single items;
 *
 * @param menuItem
 * @param direction
 */
public void addMenuItem(ResideMenuItem menuItem, int direction) {
    if (direction == DIRECTION_LEFT) {
        this.leftMenuItems.add(menuItem);
        layoutLeftMenu.addView(menuItem);

    } else {
        //   this.rightMenuItems.add(menuItem);
        //   layoutRightMenu.addView(menuItem);
    }
}

/**
 * WARNING: It will be removed from v2.0.
 *
 * @param menuItems
 */
@Deprecated
public void setMenuItems(List<ResideMenuItem> menuItems) {
    this.leftMenuItems = menuItems;
    rebuildMenu();
}

/**
 * Set menu items by a array;
 *
 * @param menuItems
 * @param direction
 */
public void setMenuItems(List<ResideMenuItem> menuItems, int direction) {
    if (direction == DIRECTION_LEFT)
        this.leftMenuItems = menuItems;
    // else
    //   this.rightMenuItems = menuItems;
    rebuildMenu();
}

private void rebuildMenu() {
    if (layoutLeftMenu != null) {
        layoutLeftMenu.removeAllViews();
        for (ResideMenuItem leftMenuItem : leftMenuItems)
            layoutLeftMenu.addView(leftMenuItem);
    }

  
}

/**
 * WARNING: It will be removed from v2.0.
 *
 * @return
 */
@Deprecated
public List<ResideMenuItem> getMenuItems() {
    return leftMenuItems;
}


/**
 * If you need to do something on closing or opening menu,
 * set a listener here.
 *
 * @return
 */
public void setMenuListener(OnMenuListener menuListener) {
    this.menuListener = menuListener;
}


public OnMenuListener getMenuListener() {
    return menuListener;
}

/**
 * Show the menu;
 */
public void openMenu(int direction) {

    setScaleDirection(direction);

    isOpened = true;
    AnimatorSet scaleDown_activity = buildScaleDownAnimation(viewActivity, mScaleValue, mScaleValue);
    AnimatorSet scaleDown_shadow = buildScaleDownAnimation(imageViewShadow,
            mScaleValue + shadowAdjustScaleX, mScaleValue + shadowAdjustScaleY);
    AnimatorSet alpha_menu = buildMenuAnimation(scrollViewMenu, 1.0f);
    scaleDown_shadow.addListener(animationListener);
    scaleDown_activity.playTogether(scaleDown_shadow);
    scaleDown_activity.playTogether(alpha_menu);
    scaleDown_activity.start();
}

/**
 * Close the menu;
 */
public void closeMenu() {

    isOpened = false;
    AnimatorSet scaleUp_activity = buildScaleUpAnimation(viewActivity, 1.0f, 1.0f);
    AnimatorSet scaleUp_shadow = buildScaleUpAnimation(imageViewShadow, 1.0f, 1.0f);
    AnimatorSet alpha_menu = buildMenuAnimation(scrollViewMenu, 0.0f);
    scaleUp_activity.addListener(animationListener);
    scaleUp_activity.playTogether(scaleUp_shadow);
    scaleUp_activity.playTogether(alpha_menu);
    scaleUp_activity.start();
}

@Deprecated
public void setDirectionDisable(int direction) {
    disabledSwipeDirection.add(direction);
}

public void setSwipeDirectionDisable(int direction) {
    disabledSwipeDirection.add(direction);
}

private boolean isInDisableDirection(int direction) {
    return disabledSwipeDirection.contains(direction);
}

private void setScaleDirection(int direction) {

    int screenWidth = getScreenWidth();
    float pivotX;
    float pivotY = getScreenHeight() * 0.5f;

    if (direction == DIRECTION_LEFT) {
        scrollViewMenu = scrollViewLeftMenu;
        pivotX = screenWidth * 1.5f;
    } else {
        // scrollViewMenu = scrollViewRightMenu;
        pivotX = screenWidth * -0.5f;
    }

    ViewHelper.setPivotX(viewActivity, pivotX);
    ViewHelper.setPivotY(viewActivity, pivotY);
    ViewHelper.setPivotX(imageViewShadow, pivotX);
    ViewHelper.setPivotY(imageViewShadow, pivotY);
    scaleDirection = direction;
}

/**
 * return the flag of menu status;
 *
 * @return
 */
public boolean isOpened() {
    return isOpened;
}

private OnClickListener viewActivityOnClickListener = new OnClickListener() {
    @Override
    public void onClick(View view) {
        if (isOpened()) closeMenu();
    }
};

private Animator.AnimatorListener animationListener = new Animator.AnimatorListener() {
    @Override
    public void onAnimationStart(Animator animation) {
        if (isOpened()) {
            showScrollViewMenu(scrollViewMenu);
            if (menuListener != null)
                menuListener.openMenu();
        }
    }

    @Override
    public void onAnimationEnd(Animator animation) {
        // reset the view;
        if (isOpened()) {
            viewActivity.setTouchDisable(true);
            viewActivity.setOnClickListener(viewActivityOnClickListener);
        } else {
            viewActivity.setTouchDisable(false);
            viewActivity.setOnClickListener(null);
            hideScrollViewMenu(scrollViewLeftMenu);
            //  hideScrollViewMenu(scrollViewRightMenu);
            if (menuListener != null)
                menuListener.closeMenu();
        }
    }

    @Override
    public void onAnimationCancel(Animator animation) {
    }

    @Override
    public void onAnimationRepeat(Animator animation) {
    }
};

/**
 * A helper method to build scale down animation;
 *
 * @param target
 * @param targetScaleX
 * @param targetScaleY
 * @return
 */
private AnimatorSet buildScaleDownAnimation(View target, float targetScaleX, float targetScaleY) {

    AnimatorSet scaleDown = new AnimatorSet();
    scaleDown.playTogether(
            ObjectAnimator.ofFloat(target, "scaleX", targetScaleX),
            ObjectAnimator.ofFloat(target, "scaleY", targetScaleY)
    );

    if (mUse3D) {
        int angle = scaleDirection == DIRECTION_LEFT ? -ROTATE_Y_ANGLE : ROTATE_Y_ANGLE;
        scaleDown.playTogether(ObjectAnimator.ofFloat(target, "rotationY", angle));
    }

    scaleDown.setInterpolator(AnimationUtils.loadInterpolator(activity,
            android.R.anim.decelerate_interpolator));
    scaleDown.setDuration(250);
    return scaleDown;
}

/**
 * A helper method to build scale up animation;
 *
 * @param target
 * @param targetScaleX
 * @param targetScaleY
 * @return
 */
private AnimatorSet buildScaleUpAnimation(View target, float targetScaleX, float targetScaleY) {

    AnimatorSet scaleUp = new AnimatorSet();
    scaleUp.playTogether(
            ObjectAnimator.ofFloat(target, "scaleX", targetScaleX),
            ObjectAnimator.ofFloat(target, "scaleY", targetScaleY)
    );

    if (mUse3D) {
        scaleUp.playTogether(ObjectAnimator.ofFloat(target, "rotationY", 0));
    }

    scaleUp.setDuration(250);
    return scaleUp;
}

private AnimatorSet buildMenuAnimation(View target, float alpha) {

    AnimatorSet alphaAnimation = new AnimatorSet();
    alphaAnimation.playTogether(
            ObjectAnimator.ofFloat(target, "alpha", alpha)
    );

    alphaAnimation.setDuration(250);
    return alphaAnimation;
}

/**
 * If there were some view you don't want reside menu
 * to intercept their touch event, you could add it to
 * ignored views.
 *
 * @param v
 */
public void addIgnoredView(View v) {
    ignoredViews.add(v);
}

/**
 * Remove a view from ignored views;
 *
 * @param v
 */
public void removeIgnoredView(View v) {
    ignoredViews.remove(v);
}

/**
 * Clear the ignored view list;
 */
public void clearIgnoredViewList() {
    ignoredViews.clear();
}

/**
 * If the motion event was relative to the view
 * which in ignored view list,return true;
 *
 * @param ev
 * @return
 */
private boolean isInIgnoredView(MotionEvent ev) {
    Rect rect = new Rect();
    for (View v : ignoredViews) {
        v.getGlobalVisibleRect(rect);
        if (rect.contains((int) ev.getX(), (int) ev.getY()))
            return true;
    }
    return false;
}

private void setScaleDirectionByRawX(float currentRawX) {
  /*  if (currentRawX < lastRawX)
        setScaleDirection(DIRECTION_RIGHT);
    else*/
    setScaleDirection(DIRECTION_LEFT);
}

private float getTargetScale(float currentRawX) {
    float scaleFloatX = ((currentRawX - lastRawX) / getScreenWidth()) * 0.75f;
    // scaleFloatX = scaleDirection == DIRECTION_RIGHT ? -scaleFloatX : scaleFloatX;

    float targetScale = ViewHelper.getScaleX(viewActivity) - scaleFloatX;
    targetScale = targetScale > 1.0f ? 1.0f : targetScale;
    targetScale = targetScale < 0.5f ? 0.5f : targetScale;
    return targetScale;
}

private float lastActionDownX, lastActionDownY;

@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
    float currentActivityScaleX = ViewHelper.getScaleX(viewActivity);
    if (currentActivityScaleX == 1.0f)
        setScaleDirectionByRawX(ev.getRawX());

    switch (ev.getAction()) {
        case MotionEvent.ACTION_DOWN:
            lastActionDownX = ev.getX();
            lastActionDownY = ev.getY();
            isInIgnoredView = isInIgnoredView(ev) && !isOpened();
            pressedState = PRESSED_DOWN;
            break;

        case MotionEvent.ACTION_MOVE:
            if (isInIgnoredView || isInDisableDirection(scaleDirection))
                break;

            if (pressedState != PRESSED_DOWN &&
                    pressedState != PRESSED_MOVE_HORIZONTAL)
                break;

            int xOffset = (int) (ev.getX() - lastActionDownX);
            int yOffset = (int) (ev.getY() - lastActionDownY);

            if (pressedState == PRESSED_DOWN) {
                if (yOffset > 25 || yOffset < -25) {
                    pressedState = PRESSED_MOVE_VERTICAL;
                    break;
                }
                if (xOffset < -50 || xOffset > 50) {
                    pressedState = PRESSED_MOVE_HORIZONTAL;
                    ev.setAction(MotionEvent.ACTION_CANCEL);
                }
            } else if (pressedState == PRESSED_MOVE_HORIZONTAL) {
                if (currentActivityScaleX < 0.95)
                    showScrollViewMenu(scrollViewMenu);

                float targetScale = getTargetScale(ev.getRawX());
                if (mUse3D) {
                    int angle = scaleDirection == DIRECTION_LEFT ? -ROTATE_Y_ANGLE : ROTATE_Y_ANGLE;
                    angle *= (1 - targetScale) * 2;
                    ViewHelper.setRotationY(viewActivity, angle);

                    ViewHelper.setScaleX(imageViewShadow, targetScale - shadowAdjustScaleX);
                    ViewHelper.setScaleY(imageViewShadow, targetScale - shadowAdjustScaleY);
                } else {
                    ViewHelper.setScaleX(imageViewShadow, targetScale + shadowAdjustScaleX);
                    ViewHelper.setScaleY(imageViewShadow, targetScale + shadowAdjustScaleY);
                }
                ViewHelper.setScaleX(viewActivity, targetScale);
                ViewHelper.setScaleY(viewActivity, targetScale);
                ViewHelper.setAlpha(scrollViewMenu, (1 - targetScale) * 2.0f);

                lastRawX = ev.getRawX();
                return true;
            }
            break;

        case MotionEvent.ACTION_UP:

            if (isInIgnoredView) break;
            if (pressedState != PRESSED_MOVE_HORIZONTAL) break;

            pressedState = PRESSED_DONE;
            if (isOpened()) {
                if (currentActivityScaleX > 0.56f)
                    closeMenu();
                else
                    openMenu(scaleDirection);
            } else {
                if (currentActivityScaleX < 0.94f) {
                    openMenu(scaleDirection);
                } else {
                    closeMenu();
                }
            }

            break;

    }
    lastRawX = ev.getRawX();
    return super.dispatchTouchEvent(ev);
}

public int getScreenHeight() {
    activity.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    return displayMetrics.heightPixels;
}

public int getScreenWidth() {
    activity.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    return displayMetrics.widthPixels;
}

public void setScaleValue(float scaleValue) {
    this.mScaleValue = scaleValue;
}

public void setUse3D(boolean use3D) {
    mUse3D = use3D;
}

public interface OnMenuListener {

    /**
     * This method will be called at the finished time of opening menu animations.
     */
    public void openMenu();

    /**
     * This method will be called at the finished time of closing menu animations.
     */
    public void closeMenu();
}

private void showScrollViewMenu(View scrollViewMenu) {
    if (scrollViewMenu != null && scrollViewMenu.getParent() == null) {
        addView(scrollViewMenu);
    }
}

private void hideScrollViewMenu(View scrollViewMenu) {
    if (scrollViewMenu != null && scrollViewMenu.getParent() != null) {
        removeView(scrollViewMenu);
    }
}

public Point getNavigationBarSize(Context context) {

    Point appUsableSize = getAppUsableScreenSize(context);
    Point realScreenSize = getRealScreenSize(context);
    // navigation bar on the right
    if (appUsableSize.x < realScreenSize.x) {
        return new Point(realScreenSize.x - appUsableSize.x, appUsableSize.y);
    }

    // navigation bar at the bottom
    if (appUsableSize.y < realScreenSize.y) {
        return new Point(appUsableSize.x, realScreenSize.y - appUsableSize.y);
    }

    // navigation bar is not present
    return new Point();
}

}

Paridhi2502 avatar Oct 10 '18 08:10 Paridhi2502

I am also facing the white bar at the bottom in GlaxyS8 !!! any solution pls?

sbouiachref avatar Dec 05 '18 08:12 sbouiachref