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
[Android 13]: device with cutout shifting content below bottom of screen #9446
[Android 13]: device with cutout shifting content below bottom of screen #9446
Comments
Could you attach a picture? Hopefully it is an android 13 bug and it gets fixed automagically. It could be the case of a platform change affecting all targetSdk but I don't remember google/android breaking backwards compatibility without a very big warning on dev documentation. Anyhow, I'm self-assigning for the long run (a year or so), because emulators now don't support the x86 ABI (what a shit movement!) adb install koreader-android-x86-v2022.07.apk
Performing Streamed Install
adb: failed to install koreader-android-x86-v2022.07.apk: Failure [INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries, res=-113] In the mean time both repro steps for supported platforms other than android 13 (from 9 onwards) and links to relevant documentation about API changes are very welcome. |
I'm on Android 13 and it's under the cutout but definitely not below the bottom of the screen. That's all as it should be, isn't it? Edit: d'oh, it's 12. |
I tried reproducing it on Android 12 on a Pixel 3a and couldn't, even with the simulated punch hole cutout. Log here: sargo-log.txt. On the 6a, if I use the "Hide" or "Render apps below cutout area" setting, it will work fine, but it won't detect any other cutout setting. Log here: bluejay-log.txt. I wonder if WindowInsetsCompat would work any better? Wanted to include my pictures below tags so it wouldn't take forever to scroll past them. |
It's a bit hacky but here on GH I like to use |
It shouldn't. We're doing exactly the same in https://github.com/koreader/android-luajit-launcher/blob/master/app/src/main/java/org/koreader/launcher/MainActivity.kt#L173-L183 What If you enable verbose logs in KO FM -> tools -> more tools -> developer options you should see a message: "top x pixels are not available, reason: window inset" If you don't see the message then |
Took a look at the verbose logs and found A couple things that stuck out to me:
|
Thanks for the feedback! That's the issue. Until now all android devices reported the cutout pixels when the activity is attached to a window. The rest of the code relies on that premise being true.
Yup. Both the initial size and further resizes are expecting proper cutout pixels because
I'm afraid there's no workaround available. There was one a few years ago (hardcoding While a solution shouldn't be too hard to implement relying on remote feedback for testing changes makes everything messier. I'm going to flash an A13 GSI image on my old tablet and see if I can reproduce the issue there. |
Nah. Google GSI doesn't even boot on my samsung A7 :( |
Same issue (unsurprisingly) on a Pixel 6 Pro having updated to Android 13. |
As a small comment, if you are okay with only reading books on the front page of KOReader, it is possible to increase the bottom margin of your books until this is fixed. You could also play with hiding the display cutout in developer settings,, which solves the problem completely, but that applies to all of your apps. If I have time this weekend, I'll also see if I can build |
@awbooze cheers! "hiding" the display cutout in developer settings didn't help, but changing it to "render apps below cutout area" does, and restores functionality to KOReader (i. e. makes it useable ). |
"render apps below cutout area" is also works to me. thx! |
Thanks for the workaround, @emacsomancer. Here is a patch against luajit-launcher master, if somebody wants to try diff --git a/app/src/main/java/org/koreader/launcher/MainActivity.kt b/app/src/main/java/org/koreader/launcher/MainActivity.kt
index d5b24bb..97b006b 100644
--- a/app/src/main/java/org/koreader/launcher/MainActivity.kt
+++ b/app/src/main/java/org/koreader/launcher/MainActivity.kt
@@ -44,7 +44,7 @@ class MainActivity : NativeActivity(), LuaInterface,
// Path of last file imported
private var lastImportedPath: String? = null
- // Device cutout - only used on API 28+
+ // Device cutout - It might be > 0 on API28+
private var topInsetHeight: Int = 0
// Fullscreen - only used on API levels 16-18
@@ -159,9 +159,10 @@ class MainActivity : NativeActivity(), LuaInterface,
}
override fun surfaceChanged(holder: SurfaceHolder, format: Int, width: Int, height: Int) {
+ topInsetHeight = cutoutPixels
Log.v(TAG_SURFACE, String.format(Locale.US,
- "surface changed {\n width: %d\n height: %d\n format: %s\n}",
- width, height, pixelFormatName(format))
+ "surface changed {\n width: %d\n height: %d\n format: %s\n cutout: %dpx}",
+ width, height, pixelFormatName(format), topInsetHeight)
)
super.surfaceChanged(holder, format, width, height)
drawSplashScreen(holder)
@@ -170,17 +171,7 @@ class MainActivity : NativeActivity(), LuaInterface,
override fun onAttachedToWindow() {
Log.d(TAG_SURFACE, "onAttachedToWindow()")
super.onAttachedToWindow()
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
- val cut: DisplayCutout? = window.decorView.rootWindowInsets.displayCutout
- if (cut != null) {
- val cutPixels = cut.safeInsetTop
- if (topInsetHeight != cutPixels) {
- Log.v(TAG_SURFACE,
- "top $cutPixels pixels are not available, reason: window inset")
- topInsetHeight = cutPixels
- }
- }
- }
+ topInsetHeight = cutoutPixels
}
/* Called just before the activity is resumed by an intent */
@@ -436,15 +427,11 @@ class MainActivity : NativeActivity(), LuaInterface,
}
override fun getScreenHeight(): Int {
- return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
- // We need to handle the notch in Portrait
- // NOTE: getScreenAvailableHeight does it automatically, but it also excludes the nav bar, when there's one :/
- if (getOrientationCompat(screenIsLandscape).and(1) == 0) {
- // getScreenOrientation returns LinuxFB rotation constants, Portrait rotations are always even
- getHeight() - topInsetHeight
- } else {
- getHeight()
- }
+ // We need to handle the notch in Portrait
+ // NOTE: getScreenAvailableHeight does it automatically, but it also excludes the nav bar, when there's one :/
+ return if (getOrientationCompat(screenIsLandscape).and(1) == 0) {
+ // getScreenOrientation returns LinuxFB rotation constants, Portrait rotations are always even
+ getHeight() - topInsetHeight
} else {
getHeight()
}
@@ -475,15 +462,11 @@ class MainActivity : NativeActivity(), LuaInterface,
}
override fun getScreenWidth(): Int {
- return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
- // We need to handle the notch in Landscape
- // NOTE: getScreenAvailableWidth does it automatically, but it also excludes the nav bar, when there's one :/
- if (getOrientationCompat(screenIsLandscape).and(1) == 1) {
- // getScreenOrientation returns LinuxFB rotation constants, Landscape rotations are always odd
- getWidth() - topInsetHeight
- } else {
- getWidth()
- }
+ // We need to handle the notch in Landscape
+ // NOTE: getScreenAvailableWidth does it automatically, but it also excludes the nav bar, when there's one :/
+ return if (getOrientationCompat(screenIsLandscape).and(1) == 1) {
+ // getScreenOrientation returns LinuxFB rotation constants, Landscape rotations are always odd
+ getWidth() - topInsetHeight
} else {
getWidth()
}
diff --git a/app/src/main/java/org/koreader/launcher/extensions/ActivityExtensions.kt b/app/src/main/java/org/koreader/launcher/extensions/ActivityExtensions.kt
index f651c5d..19db075 100644
--- a/app/src/main/java/org/koreader/launcher/extensions/ActivityExtensions.kt
+++ b/app/src/main/java/org/koreader/launcher/extensions/ActivityExtensions.kt
@@ -14,6 +14,7 @@ import android.os.Build
import android.os.Environment
import android.provider.Settings
import android.util.DisplayMetrics
+import android.view.DisplayCutout
import android.view.Surface
import android.view.View
import android.view.WindowManager
@@ -31,6 +32,14 @@ val Activity.platform: String
} else {
"android"
}
+
+val Activity.cutoutPixels: Int
+ get() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
+ window.decorView.rootWindowInsets.displayCutout?.let {
+ it.safeInsetTop
+ } ?: 0
+ } else 0
+
/* Haptic feedback */
fun Activity.hapticFeedback(constant: Int, force: Boolean, view: View) {
runOnUiThread { |
Pixel 6a, Android 13, same issue. As a workaround I'm using GitHub release version with the following patch: /storage/emulated/0/koreader/patches/10-screen-offset.lua
|
Can someone please upload an apk of the patched koreader for android 13? I was going to myself, but I have ncurses installed but it fails to build because Creating a file |
Yes, the fdroid version doesn't allow changing the runtime behaviour of the app.
I don't think so. Is better to keep your APK with a signature that comes from a reputable source and a little lua file that you can remove yourself when a proper fix arrives. |
@Nfanja Thanks! This works very well with
|
UPDATE: This doesn't seem to work for long. After using the 2022.10 version for some time, the top menu returns in the notch area. Tried 2022.08 (github and fdroid version) but it doesn't work. Hopefully the devs will look into it. |
I have the Pixel 5a and the patch doesn't seem to work, even with the Github version. I am using GrapheneOS rom if this matters. |
Can also confirm |
Can confirm this works for now. And as stated in the 3rd comment before mine if i change orientation it messes this up and i need to restart koreader for it to appear properly again But i only use koreader in vertical orientation so its good for me for now Edit: using the latest 2022.11 version |
For Android 13 on Galaxy S21+, forcing show camera cutout with KOReader through Android display settings (mostly) fixed the issue. The bottom corners of books and book display settings are cut off slightly but not unusable. |
Can confirm tweak provided by @tinkerpunktheprol works on S21+ running 13.x. |
Patch is not working on Pixel 6a: GrapheneOS: android 13
|
Thanks for testing, @yparitcher! I'm afraid I'm going to need a device myself to see what happens and fix it. Probably the best way is to get rid of static window height + width and just return the last one picked by Let me know if you're available for more tests in the future! |
Now that i finally built for android, 6hrs and 15GB of my drive later, after failing, arm64 debug, then arm64 release signing, then finally arm7 debug, for sure :) Don't worry i used a separate tree so i can nuke the build and TC's when this is done. :) Btw even with decent internet speed (300mbit) a majority of a clean build time is spent being stuck waiting to download sources |
The easiest way now is if you push patches to git and i can just checkout your branch |
Thank you! This worked for me |
LineageOS 20 is out, so I might be able to join the fray soon (-ish). |
Yep. Not available for my phone/tablet yet. Hopefully soon. But I wouldn't mind if you take care of it entirely ;) |
If you have a few pointers for me to look into, it'll help once I finally make the jump ;). (I have a compatible device, just waiting for the dust to settle a bit, and to have a bit of free time reserved for it, in case shit happens during the upgrade ;p). |
Sure. We can make both width and height nullable integers and their getters to return current If they're not null then just return the value they hold, which should be updated on each new |
The cutoff also affect the page content (the last few lines of the pages). The "render apps below cutout area" settings is a system-wide settings, so it will affect other apps. If you're like me and don't need to change the bottom settings and just want to see the whole page content, it's possible to shift the content of the page up by changing the |
I'm using a Pixel 7 and I'm affected by this bug - I tried the workaround Developer options > Display cutout > Render apps below cutout area. However this causes another issue with the under screen fingerprint reader. The on screen symbol for where to put your finger will be slightly off from the sensor in the phone. You then need to hit your finger slightly above it which is annoying and confusing. If I instead set Display Cutout > Hide it fixes the UI cutoff in KOReader and shows the on screen fingerprint correctly, but it shrinks my screen size by the height of the cutout. I'll use this for now but a fix on KOReader end would be appreciated! |
I also encountered the same problem, using Samsung S20+, running OneUI 5.1 (Android 13). |
Is this setting special to the Galaxy or it's available in stock Android? Trying to find the name of the setting. |
Fix cutout on android 13 Closes: koreader#9446
Fix cutout on android 13 Closes: #9446
Issue
The Pixel 6a has a hole-punch camera, while my previous phone did not. After I upgraded to the 6a, I noticed that KOReader was not laying out content beneath the hole punch, but seemed to be laying content out below the bottom of the screen. This does also occur when the screen is rotated - if the camera is on the left, the text is cut off on the right.
After searching the issues, it looks like the problem is similar to #4769 and should have been fixed by koreader/android-luajit-launcher#150. The type of log you had nvvslm do is here.
After looking at the log and doing some digging in the code, it looks like getScreenHeight in android-luajit-launcher would probably correctly detect the notch, while screen:getRawSize() in device.lua is still returning the full screen height. I'd think this would move some content below the screen, although I'm not experienced with Lua.
Steps to reproduce
Thanks for the great reader app!
The text was updated successfully, but these errors were encountered: