|
1 | 1 | package com.iterable.iterableapi.ui.inbox;
|
2 | 2 |
|
3 | 3 | import android.content.Intent;
|
| 4 | +import android.graphics.Insets; |
| 5 | +import android.os.Build; |
4 | 6 | import android.os.Bundle;
|
5 | 7 | import androidx.annotation.LayoutRes;
|
6 | 8 | import androidx.annotation.NonNull;
|
7 | 9 | import androidx.annotation.Nullable;
|
| 10 | +import androidx.core.view.ViewCompat; |
8 | 11 | import androidx.fragment.app.Fragment;
|
9 | 12 | import androidx.recyclerview.widget.LinearLayoutManager;
|
10 | 13 | import androidx.recyclerview.widget.RecyclerView;
|
@@ -184,6 +187,33 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
|
184 | 187 | return relativeLayout;
|
185 | 188 | }
|
186 | 189 |
|
| 190 | + @Override |
| 191 | + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
| 192 | + super.onViewCreated(view, savedInstanceState); |
| 193 | + // Use ViewCompat to handle insets dynamically |
| 194 | + ViewCompat.setOnApplyWindowInsetsListener(view, (v, insets) -> { |
| 195 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { |
| 196 | + // For API 30 and above: Use WindowInsetsCompat to handle insets |
| 197 | + Insets systemBarsInsets = insets.getSystemGestureInsets().toPlatformInsets(); |
| 198 | + v.setPadding( |
| 199 | + 0, |
| 200 | + systemBarsInsets.top, // Padding for status bar and cutout |
| 201 | + 0, |
| 202 | + systemBarsInsets.bottom // Padding for navigation bar |
| 203 | + ); |
| 204 | + } else { |
| 205 | + // For older Android versions: Use legacy methods |
| 206 | + v.setPadding( |
| 207 | + 0, |
| 208 | + insets.getSystemWindowInsetTop(), // Padding for status bar and cutout |
| 209 | + 0, |
| 210 | + insets.getSystemWindowInsetBottom() // Padding for navigation bar |
| 211 | + ); |
| 212 | + } |
| 213 | + return insets; |
| 214 | + }); |
| 215 | + } |
| 216 | + |
187 | 217 | @Override
|
188 | 218 | public void onResume() {
|
189 | 219 | super.onResume();
|
|
0 commit comments