Skip to content

Commit

Permalink
[Fix] Fix display cutout theming.
Browse files Browse the repository at this point in the history
Display cutout value shortEdges is actually potentially available on API 27,
and display cutout value always is available on API 30.

See also
https://android-developers.googleblog.com/2018/07/supporting-display-cutouts-on-edge-to.html
about the potential backport to API 27.
  • Loading branch information
zhanghai committed Oct 3, 2023
1 parent 02edc07 commit 3a97531
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 42 deletions.
6 changes: 6 additions & 0 deletions app/src/main/res/values-v27/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@

<style name="Platform.V27.Theme.MaterialFiles" parent="Platform.V23.Theme.MaterialFiles">
<item name="android:navigationBarColor">?colorPrimaryDark</item>
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
<item name="android:windowLightNavigationBar">?isLightTheme</item>
</style>
<style name="Platform.Theme.MaterialFiles" parent="Platform.V27.Theme.MaterialFiles" />

<style name="Platform.V27.Theme.MaterialFiles.Immersive" parent="Platform.V21.Theme.MaterialFiles.Immersive">
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
</style>
<style name="Platform.Theme.MaterialFiles.Immersive" parent="Platform.V27.Theme.MaterialFiles.Immersive" />
</resources>
6 changes: 6 additions & 0 deletions app/src/main/res/values-v27/themes_material3.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@

<style name="Platform.V27.Theme.MaterialFiles.Material3" parent="Platform.V23.Theme.MaterialFiles.Material3">
<item name="android:navigationBarColor">?colorPrimaryDark</item>
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
<item name="android:windowLightNavigationBar">?isLightTheme</item>
</style>
<style name="Platform.Theme.MaterialFiles.Material3" parent="Platform.V27.Theme.MaterialFiles.Material3" />

<style name="Platform.V27.Theme.MaterialFiles.Material3.Immersive" parent="Platform.V21.Theme.MaterialFiles.Material3.Immersive">
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
</style>
<style name="Platform.Theme.MaterialFiles.Material3.Immersive" parent="Platform.V27.Theme.MaterialFiles.Material3.Immersive" />
</resources>
19 changes: 0 additions & 19 deletions app/src/main/res/values-v28/themes.xml

This file was deleted.

19 changes: 0 additions & 19 deletions app/src/main/res/values-v28/themes_material3.xml

This file was deleted.

4 changes: 2 additions & 2 deletions app/src/main/res/values-v29/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

<resources>

<style name="Platform.V29.Theme.MaterialFiles" parent="Platform.V28.Theme.MaterialFiles">
<style name="Platform.V29.Theme.MaterialFiles" parent="Platform.V27.Theme.MaterialFiles">
<item name="android:forceDarkAllowed">false</item>

<item name="colorPrimaryDark">@android:color/transparent</item>
</style>
<style name="Platform.Theme.MaterialFiles" parent="Platform.V29.Theme.MaterialFiles" />

<style name="Platform.V29.Theme.MaterialFiles.Immersive" parent="Platform.V28.Theme.MaterialFiles.Immersive">
<style name="Platform.V29.Theme.MaterialFiles.Immersive" parent="Platform.V27.Theme.MaterialFiles.Immersive">
<item name="android:forceDarkAllowed">false</item>

<item name="colorPrimaryDark">@android:color/transparent</item>
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values-v29/themes_material3.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

<resources>

<style name="Platform.V29.Theme.MaterialFiles.Material3" parent="Platform.V28.Theme.MaterialFiles.Material3">
<style name="Platform.V29.Theme.MaterialFiles.Material3" parent="Platform.V27.Theme.MaterialFiles.Material3">
<item name="android:forceDarkAllowed">false</item>

<item name="colorPrimaryDark">@android:color/transparent</item>
</style>
<style name="Platform.Theme.MaterialFiles.Material3" parent="Platform.V29.Theme.MaterialFiles.Material3" />

<style name="Platform.V29.Theme.MaterialFiles.Material3.Immersive" parent="Platform.V28.Theme.MaterialFiles.Material3.Immersive">
<style name="Platform.V29.Theme.MaterialFiles.Material3.Immersive" parent="Platform.V27.Theme.MaterialFiles.Material3.Immersive">
<item name="android:forceDarkAllowed">false</item>

<item name="colorPrimaryDark">@android:color/transparent</item>
Expand Down
19 changes: 19 additions & 0 deletions app/src/main/res/values-v30/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>

<!--
~ Copyright (c) 2019 Hai Zhang <dreaming.in.code.zh@gmail.com>
~ All Rights Reserved.
-->

<resources>

<style name="Platform.V30.Theme.MaterialFiles" parent="Platform.V29.Theme.MaterialFiles">
<item name="android:windowLayoutInDisplayCutoutMode">always</item>
</style>
<style name="Platform.Theme.MaterialFiles" parent="Platform.V30.Theme.MaterialFiles" />

<style name="Platform.V30.Theme.MaterialFiles.Immersive" parent="Platform.V29.Theme.MaterialFiles.Immersive">
<item name="android:windowLayoutInDisplayCutoutMode">always</item>
</style>
<style name="Platform.Theme.MaterialFiles.Immersive" parent="Platform.V30.Theme.MaterialFiles.Immersive" />
</resources>
19 changes: 19 additions & 0 deletions app/src/main/res/values-v30/themes_material3.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>

<!--
~ Copyright (c) 2023 Hai Zhang <dreaming.in.code.zh@gmail.com>
~ All Rights Reserved.
-->

<resources>

<style name="Platform.V30.Theme.MaterialFiles.Material3" parent="Platform.V29.Theme.MaterialFiles.Material3">
<item name="android:windowLayoutInDisplayCutoutMode">always</item>
</style>
<style name="Platform.Theme.MaterialFiles.Material3" parent="Platform.V30.Theme.MaterialFiles.Material3" />

<style name="Platform.V30.Theme.MaterialFiles.Material3.Immersive" parent="Platform.V29.Theme.MaterialFiles.Material3.Immersive">
<item name="android:windowLayoutInDisplayCutoutMode">always</item>
</style>
<style name="Platform.Theme.MaterialFiles.Material3.Immersive" parent="Platform.V30.Theme.MaterialFiles.Material3.Immersive" />
</resources>

0 comments on commit 3a97531

Please sign in to comment.