TrianguloY / LightningLauncher

More than a simple Android launcher, Lightning is a fast, light and extremely customizable tool to build the perfect home screen. To build your home screen.
https://www.lightninglauncher.com/
MIT License
32 stars 3 forks source link

Review screen padding configuration #20

Open SnowVolf opened 7 months ago

SnowVolf commented 7 months ago

I'm noticed that on new versions of Android, where the 3-button navigation bar is enabled, an additional indent is added equal to exactly the height of these buttons. This is a dead zone that cannot be used. Unfortunately, attempts to increase the number of rows on the page do not produce results.

Insets are set in Dashboard.java void configureSystemBarsPadding(PageConfig c)

private void configureSystemBarsPadding(PageConfig c) {
        {
            SystemBarTintManager.SystemBarConfig config = mScreen.getSystemBarTintManager().getConfig();
            int sbh = c.statusBarHide ? 0 : config.getStatusBarHeight();
            int abh = getActionBarHeight();
            int padding_top = c.statusBarOverlap ? 0 : sbh + abh;
            int padding_right = 0;
            int padding_bottom = 0;
            // Maybe cause of issue
            int nbh = config.getNavigationBarHeight();
            boolean navigationAtBottom = config.isNavigationAtBottom();
            if (!c.navigationBarOverlap) {
                if (navigationAtBottom) {
                    padding_bottom = nbh;
                } else {
                    padding_right = nbh;
                }
            }
            if (mIsAndroidActionBarDisplayed) {
                try {
                    View v = getWindow().getDecorView();
                    int resId = getResources().getIdentifier("action_bar_container", "id", "android");
                    ViewGroup v1 = v.findViewById(resId);
                    ((View) v1.getParent()).setPadding(0, sbh, 0, 0);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                padding_top = 0;
                sbh = 0;
            }
            findViewById(R.id.sb_padding).setPadding(0, padding_top, padding_right, padding_bottom);
            mEditControlsView.setPadding(0, sbh + abh, navigationAtBottom ? 0 : nbh, navigationAtBottom ? nbh : 0);
        }
    }

For the sake of experimentation, I removed bottom insets in this method, and the bug disappeared. But there were problems with indentations from the status bar, but this is the lesser of 2 evils. Most likely this was a consequence of using the AppCompat theme, and it is necessary to rewrite the calculation of paddings through WindowInsetsCompat to work correctly.