Skip to content

Commit fc9cc42

Browse files
committed
Multiple fixes to edge-to-edge display (API 35)
1 parent e7165d9 commit fc9cc42

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

uhabits-android/src/main/java/org/isoron/uhabits/activities/habits/show/ShowHabitView.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@ import android.widget.FrameLayout
2525
import org.isoron.uhabits.core.ui.screens.habits.show.ShowHabitPresenter
2626
import org.isoron.uhabits.core.ui.screens.habits.show.ShowHabitState
2727
import org.isoron.uhabits.databinding.ShowHabitBinding
28+
import org.isoron.uhabits.utils.applyToolbarInsets
2829
import org.isoron.uhabits.utils.setupToolbar
2930

3031
class ShowHabitView(context: Context) : FrameLayout(context) {
3132
private val binding = ShowHabitBinding.inflate(LayoutInflater.from(context))
3233

3334
init {
35+
binding.toolbar.applyToolbarInsets()
3436
addView(binding.root)
3537
}
3638

uhabits-android/src/main/java/org/isoron/uhabits/utils/ViewExtensions.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,15 +251,21 @@ fun View.getCenter(): PointF {
251251
fun View.applyRootViewInsets() {
252252
ViewCompat.setOnApplyWindowInsetsListener(this) { view, insets ->
253253
val systemBarsInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars())
254-
view.setPadding(systemBarsInsets.left, 0, systemBarsInsets.right, systemBarsInsets.bottom)
254+
val displayCutoutInsets = insets.getInsets(WindowInsetsCompat.Type.displayCutout())
255+
val left = maxOf(systemBarsInsets.left, displayCutoutInsets.left)
256+
val right = maxOf(systemBarsInsets.right, displayCutoutInsets.right)
257+
view.setPadding(left, 0, right, 0)
258+
view.background = ColorDrawable(Color.BLACK)
255259
insets
256260
}
257261
}
258262

259263
fun View.applyToolbarInsets() {
260264
ViewCompat.setOnApplyWindowInsetsListener(this) { view, insets ->
261265
val systemBarsInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars())
262-
view.setPadding(0, systemBarsInsets.top, 0, 0)
266+
val displayCutoutInsets = insets.getInsets(WindowInsetsCompat.Type.displayCutout())
267+
val top = maxOf(systemBarsInsets.top, displayCutoutInsets.top)
268+
view.setPadding(0, top, 0, 0)
263269
insets
264270
}
265271
}

uhabits-android/src/main/res/layout/activity_edit_habit.xml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
~ with this program. If not, see <http://www.gnu.org/licenses/>.
1919
-->
2020

21-
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
21+
<LinearLayout
22+
xmlns:android="http://schemas.android.com/apk/res/android"
2223
xmlns:app="http://schemas.android.com/apk/res-auto"
2324
xmlns:tools="http://schemas.android.com/tools"
2425
android:layout_width="match_parent"
@@ -61,8 +62,10 @@
6162

6263
<ScrollView
6364
android:layout_width="match_parent"
64-
android:layout_height="wrap_content"
65-
app:layout_behavior="@string/appbar_scrolling_view_behavior">
65+
android:layout_height="0dp"
66+
android:layout_weight="1"
67+
app:layout_behavior="@string/appbar_scrolling_view_behavior"
68+
android:background="?attr/contrast0">
6669

6770
<LinearLayout
6871
android:layout_width="match_parent"
@@ -265,4 +268,4 @@
265268
</LinearLayout>
266269
</ScrollView>
267270

268-
</androidx.coordinatorlayout.widget.CoordinatorLayout>
271+
</LinearLayout>

uhabits-android/src/main/res/layout/automation.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@
5858

5959
<LinearLayout
6060
android:id="@+id/formPanel"
61-
style="@style/dialogFormPanel">
61+
style="@style/dialogFormPanel"
62+
android:layout_height="0dp"
63+
android:layout_weight="1"
64+
android:background="?attr/contrast0">
6265

6366
<FrameLayout style="@style/FormOuterBox">
6467
<LinearLayout style="@style/FormInnerBox">

0 commit comments

Comments
 (0)