File tree Expand file tree Collapse file tree 2 files changed +63
-0
lines changed
ui/src/main/java/com/nextcloud/android/common/ui/util/extensions Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ * Nextcloud Android Common Library
3+ *
4+ * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
5+ * SPDX-License-Identifier: MIT
6+ */
7+
8+ package com.nextcloud.android.common.ui.util.extensions
9+
10+ import android.graphics.Color
11+ import android.os.Build
12+ import androidx.activity.SystemBarStyle
13+ import androidx.activity.enableEdgeToEdge
14+ import androidx.appcompat.app.AppCompatActivity
15+
16+ @JvmOverloads
17+ @Suppress(" MagicNumber" )
18+ fun AppCompatActivity.adjustUIForAPILevel35 (
19+ statusBarStyle : SystemBarStyle = SystemBarStyle .auto(Color .TRANSPARENT , Color .TRANSPARENT ),
20+ navigationBarStyle : SystemBarStyle = SystemBarStyle .auto(Color .TRANSPARENT , Color .TRANSPARENT )
21+ ) {
22+ val isApiLevel35OrHigher = (Build .VERSION .SDK_INT >= 35 )
23+ if (! isApiLevel35OrHigher) {
24+ return
25+ }
26+
27+ enableEdgeToEdge(statusBarStyle, navigationBarStyle)
28+
29+ window.addSystemBarPaddings()
30+ }
Original file line number Diff line number Diff line change 1+ /*
2+ * Nextcloud Android Common Library
3+ *
4+ * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
5+ * SPDX-License-Identifier: MIT
6+ */
7+
8+ package com.nextcloud.android.common.ui.util.extensions
9+
10+ import android.view.View
11+ import android.view.Window
12+ import androidx.core.view.ViewCompat
13+ import androidx.core.view.WindowInsetsCompat
14+ import androidx.core.view.updatePadding
15+
16+ fun Window?.addSystemBarPaddings () {
17+ if (this == null ) {
18+ return
19+ }
20+
21+ ViewCompat .setOnApplyWindowInsetsListener(decorView) { v: View , insets: WindowInsetsCompat ->
22+ val bars = insets.getInsets(WindowInsetsCompat .Type .systemBars())
23+
24+ v.updatePadding(
25+ left = bars.left,
26+ top = bars.top,
27+ right = bars.right,
28+ bottom = bars.bottom
29+ )
30+
31+ WindowInsetsCompat .CONSUMED
32+ }
33+ }
You can’t perform that action at this time.
0 commit comments