vocollapse / Blockinger

Tetris clone for Android
Other
212 stars 143 forks source link

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

Open MachFour opened 1 year ago

MachFour commented 1 year ago

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.

calhix commented 1 year ago

Do you plan on making a release in your repo? I would like to try it out if you do. This is the only decent Tetris clone that exists and been using it for years.

MachFour commented 1 year ago

Hey! If you're worried about this bug, it only occurs when you rebuilt the source for a later SDK. There's no observable difference if you just use the f-droid version.

For now I've just built my repo locally and have sideloaded the apk onto my phone. Is there anything in particular you'd want in a release?

TheMask06 commented 3 months ago

Hello friends, you could make a project like this but for android 4.x+