[TIMOB-26246] Android: Handle Android P insetting/display-cutout
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-10-25T14:05:07.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 7.5.0 |
Components | Android |
Labels | android, inset |
Reporter | Joshua Quick |
Assignee | Joshua Quick |
Created | 2018-07-27T23:11:35.000+0000 |
Updated | 2018-12-10T23:20:35.000+0000 |
Description
*Summary:*
Android 9.0 (aka: Android P) will support devices with "iPhone X" style frame insetting where the top frame cuts into the top status bar.
!AndroidP_Inset.png|thumbnail!
We'll need to provide APIs to better support this device feature. Preferably re-use the existing APIs used by iPhone X such as our
Window.extendSafeArea
property.
*Note 1:*
Android 9.0 (API Level 28) provides new APIs to help with us. They're listed here...
https://developer.android.com/preview/features#cutout
Quick reference...
https://developer.android.com/reference/android/view/DisplayCutout
https://developer.android.com/reference/android/view/WindowManager.LayoutParams#LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
Also, the window won't render into the cutout unless we set additional window flags such as the following...
WindowManager.LayoutParams attributes = getWindow().getAttributes();
attributes.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
getWindow().setAttributes(attributes);
*Note 2:*
Huawei has their own custom notch support on Android 8 which they document in the link below. Note that these are not official Google Android APIs.
https://developer.huawei.com/consumer/en/devservice/doc/30210
Attachments
File | Date | Size |
---|---|---|
AndroidP_Inset.png | 2018-07-27T23:05:48.000+0000 | 215944 |
[~jquick] Quick PoC of the Android safe-area [here](https://github.com/hansemannn/titanium_mobile/commit/0d73f7b7ebc6ddbb1a798e536bd2902e934babe8). It currently does not build due to missing symbols, although 28 is installed. Not sure how to fix that so far!
[~hknoechel], we need to update all of the "build.properties" files to build with API Level 28 and link to the newest libraries. But before we do that, we've got to install API Level 28 on the Jenkins nodes first. I'll talk to the team here about it. I've already written up a ticket to build with API Level 28 here: [TIMOB-26261] We'll handle this part on our end. Once done/merged, you can update your branch and be able to build it. Thanks for digging into it anyways. We'll get there. _*Edit:* Also, we shouldn't modify the Jenkins nodes until after the 7.3.0 GA release. We don't want to risk breaking Jenkins right now._
I'm now thinking that on Android P, we should always set up the window layout to render under the notch (like iOS) and instead tie our
Ti.UI.Window.extendSafeArea
property to Android's JavaView.setFitSystemWindows()
method since this controls whether or not Titanium's views will be rendered within the safe area. https://developer.android.com/reference/android/view/View.html#setFitsSystemWindows(boolean) The reason is because before Android P, you already had the ability to set up a translucent top status bar and bottom navigation bar via a "theme", but Titanium has never offered the ability to render content under those bars before. We can use the newTi.UI.Window.extendSafeArea
on older Android OS versions to support this as well. Note that we currently support extending a toolbar's background under the top status bar in a similar fashion. The idea is we would leverage the same feature, but apply it to the root content view of the activity. https://github.com/appcelerator/titanium_mobile/pull/9524PR (master): https://github.com/appcelerator/titanium_mobile/pull/10383
*FR Passed* Waiting on Jenkins to merge
Verified the fix on SDK 7.5.0.v20181025085349. Closing
This change is causing a lot of crashes in Production:
@Joshua Quick, can you please let me know if the issue mentioned in the above comment has been fixed? This made me downgrade my SDK from 7.5.0 to 7.4.2 which made my our much more stable. The above issue is causing excessive crashes in 7.5.0.GA
[~fahad86], this issue is being fixed in Titanium 7.5.1. Please see: [TIMOB-26632] We've confirmed that this crash will happen if the app UI is backgrounded and you attempted to launch it via an intent such as URL scheme or notification.