|
5 | 5 | import android.content.Context; |
6 | 6 | import android.content.DialogInterface; |
7 | 7 | import android.graphics.Color; |
8 | | -import android.graphics.Insets; |
9 | 8 | import android.graphics.Point; |
10 | 9 | import android.graphics.Rect; |
11 | 10 | import android.graphics.drawable.ColorDrawable; |
|
32 | 31 | import androidx.annotation.NonNull; |
33 | 32 | import androidx.annotation.Nullable; |
34 | 33 | import androidx.core.graphics.ColorUtils; |
| 34 | +import androidx.core.graphics.Insets; |
35 | 35 | import androidx.core.view.ViewCompat; |
| 36 | +import androidx.core.view.WindowInsetsCompat; |
36 | 37 | import androidx.fragment.app.DialogFragment; |
37 | 38 |
|
38 | 39 | public class IterableInAppFragmentHTMLNotification extends DialogFragment implements IterableWebView.HTMLNotificationCallbacks { |
@@ -204,26 +205,10 @@ public void run() { |
204 | 205 | @Override |
205 | 206 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
206 | 207 | super.onViewCreated(view, savedInstanceState); |
207 | | - // Use ViewCompat to handle insets dynamically |
| 208 | + // Handle edge-to-edge insets with modern approach |
208 | 209 | 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 | | - } |
| 210 | + Insets sysBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()); |
| 211 | + v.setPadding(0, sysBars.top, 0, sysBars.bottom); |
227 | 212 | return insets; |
228 | 213 | }); |
229 | 214 | } |
|
0 commit comments