|
5 | 5 | import android.content.Context; |
6 | 6 | import android.content.DialogInterface; |
7 | 7 | import android.graphics.Color; |
| 8 | +import android.graphics.Insets; |
8 | 9 | import android.graphics.Point; |
9 | 10 | import android.graphics.Rect; |
10 | 11 | import android.graphics.drawable.ColorDrawable; |
|
31 | 32 | import androidx.annotation.NonNull; |
32 | 33 | import androidx.annotation.Nullable; |
33 | 34 | import androidx.core.graphics.ColorUtils; |
| 35 | +import androidx.core.view.ViewCompat; |
34 | 36 | import androidx.fragment.app.DialogFragment; |
35 | 37 |
|
36 | 38 | public class IterableInAppFragmentHTMLNotification extends DialogFragment implements IterableWebView.HTMLNotificationCallbacks { |
@@ -199,6 +201,33 @@ public void run() { |
199 | 201 | return relativeLayout; |
200 | 202 | } |
201 | 203 |
|
| 204 | + @Override |
| 205 | + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
| 206 | + super.onViewCreated(view, savedInstanceState); |
| 207 | + // Use ViewCompat to handle insets dynamically |
| 208 | + ViewCompat.setOnApplyWindowInsetsListener(view, (v, insets) -> { |
| 209 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { |
| 210 | + // For API 30 and above: Use WindowInsetsCompat to handle insets |
| 211 | + Insets systemBarsInsets = insets.getSystemGestureInsets().toPlatformInsets(); |
| 212 | + v.setPadding( |
| 213 | + 0, |
| 214 | + systemBarsInsets.top, // Padding for status bar and cutout |
| 215 | + 0, |
| 216 | + systemBarsInsets.bottom // Padding for navigation bar |
| 217 | + ); |
| 218 | + } else { |
| 219 | + // For older Android versions: Use legacy methods |
| 220 | + v.setPadding( |
| 221 | + 0, |
| 222 | + insets.getSystemWindowInsetTop(), // Padding for status bar and cutout |
| 223 | + 0, |
| 224 | + insets.getSystemWindowInsetBottom() // Padding for navigation bar |
| 225 | + ); |
| 226 | + } |
| 227 | + return insets; |
| 228 | + }); |
| 229 | + } |
| 230 | + |
202 | 231 | public void setLoaded(boolean loaded) { |
203 | 232 | this.loaded = loaded; |
204 | 233 | } |
|
0 commit comments