Skip to content

Bug in grid size calculation causes display clipping when targeting SDK >= 24 #22

@MachFour

Description

@MachFour

Hi, I know this repo is unmaintained but leaving this here for anyone in the future who comes across this.

The latest released version of this app targets Android SDK 17 and works fine when installed from F-Droid. For some reason though, it doesn't use all the vertical space on my phone, about 15% of the bottom part of the screen below the game display is blank. This also occurs if I recompile the app targeting SDK versions below 24 (Oreo).

When I changed the target SDK to 24 (Oreo), the app could use all the available screen space. However it caused the edges of the tetris grid and status display to get cut off on my screen. After some time debugging, I discovered the offending line of code:

app/src/main/java/org/blockinger/game/components/Display.java, in function doDraw()

int size2 = (int)(((c.getHeight()-1) - 2*columnOffset)/(columns + 4 + host.getResources().getInteger(R.integer.padding_columns)));

This line calculates the grid size necessary to fit within the available horizontal space. However, it incorrectly uses c.getHeight() instead of c.getWidth(). When I changed c.getHeight() to c.getWidth(), the problem was fixed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions