Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: add a null check for WindowInsets used in isKeyboardUp()
  • Loading branch information
jinliu9508 committed May 22, 2025
commit 09ed4e227df9ace36f5ad18e59da37dc847b5df3
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
val window = activityWeakReference.get()!!.window
view = window.decorView
view.getWindowVisibleDisplayFrame(visibleBounds)
window.windowManager.defaultDisplay.getMetrics(metrics)

Check warning on line 29 in OneSignalSDK/onesignal/core/src/main/java/com/onesignal/common/DeviceUtils.kt

View workflow job for this annotation

GitHub Actions / build

'getter for defaultDisplay: Display!' is deprecated. Deprecated in Java

Check warning on line 29 in OneSignalSDK/onesignal/core/src/main/java/com/onesignal/common/DeviceUtils.kt

View workflow job for this annotation

GitHub Actions / build

'getMetrics(DisplayMetrics!): Unit' is deprecated. Deprecated in Java
}
if (view != null) {
isOpen =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
val imeInsets = view.rootWindowInsets
imeInsets.isVisible(WindowInsetsCompat.Type.ime())
imeInsets?.isVisible(WindowInsetsCompat.Type.ime()) ?: false
} else {
// Does not work for cases when keyboard is full screen for Android 9 and below
val heightDiff = metrics.heightPixels - visibleBounds.bottom
Expand All @@ -45,7 +45,7 @@
fun getNetType(appContext: Context): Int? {
val cm =
appContext.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
val netInfo = cm.activeNetworkInfo

Check warning on line 48 in OneSignalSDK/onesignal/core/src/main/java/com/onesignal/common/DeviceUtils.kt

View workflow job for this annotation

GitHub Actions / build

'getter for activeNetworkInfo: NetworkInfo?' is deprecated. Deprecated in Java
if (netInfo != null) {
val networkType = netInfo.type
return if (networkType == ConnectivityManager.TYPE_WIFI || networkType == ConnectivityManager.TYPE_ETHERNET) 0 else 1
Expand Down
Loading