Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Behind navigation bar #126

Open
JWvanV opened this issue Dec 7, 2016 · 3 comments
Open

Behind navigation bar #126

JWvanV opened this issue Dec 7, 2016 · 3 comments

Comments

@JWvanV
Copy link

JWvanV commented Dec 7, 2016

Hey, nice library.
I do see something wierd with a transparent navigation bar.
On my Nexus7 the sheet does the correct thing and adds padding to the sheet bottom.
On my OneplusOne the sheet doesn't do the correct thing and make the sheet overlap with the navigation bar :(

My statusbar height implementation works on all my activities. Could you compare it with yours?

    private static boolean hasNavBar(Context context) {
        // Kitkat and less shows container above nav bar
        if (android.os.Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
            return false;
        }
        // Emulator
        if (Build.FINGERPRINT.startsWith("generic")) {
            return true;
        }
        boolean hasMenuKey = ViewConfiguration.get(context).hasPermanentMenuKey();
        boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
        boolean hasNoCapacitiveKeys = !hasMenuKey && !hasBackKey;
        Resources resources = context.getResources();
        int id = resources.getIdentifier("config_showNavigationBar", "bool", "android");
        boolean hasOnScreenNavBar = id > 0 && resources.getBoolean(id);
        return hasOnScreenNavBar || hasNoCapacitiveKeys || getNavigationBarHeight(context, true) > 0;
    }

    public static int getNavigationBarHeight(Context context, boolean skipRequirement) {
        int resourceId = context.getResources().getIdentifier("navigation_bar_height", "dimen", "android");
        if (resourceId > 0 && (skipRequirement || hasNavBar(context))) {
            return context.getResources().getDimensionPixelSize(resourceId);
        }
        return 0;
    }
@soarcn
Copy link
Owner

soarcn commented Dec 8, 2016

I believe there are some changes in android 7.0. The workaround would be if the current android version >=7 has NavBar return false, unfortunately I don't have android 7 device so I can't test it, would you mind testing it and sending a PR to me ? Thanks

@JWvanV
Copy link
Author

JWvanV commented Dec 8, 2016

I Checked it by changing
mDialogView.getChildAt(0).setPadding(0, 0, 0, helper.mNavBarAvailable ? helper.getNavigationBarHeight(getContext()) + mDialogView.getPaddingBottom() : 0);
to
mDialogView.getChildAt(0).setPadding(0, 0, 0, ActivityUtils.getNavigationBarHeight(getContext(), false));

at BottomSheet.java:198.

This fixed the issue for me :D

I've never done a PR before, so I'm not quite sure how to do it :p

@JWvanV
Copy link
Author

JWvanV commented Dec 8, 2016

Pull request filed :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants