Skip to content

Fix: IAM now showing after switching to 3-button-navigation mode #2284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 25, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@
import android.content.Context
import android.graphics.Rect
import android.net.ConnectivityManager
import android.os.Build
import android.telephony.TelephonyManager
import android.util.DisplayMetrics
import android.view.View
import androidx.core.view.WindowInsetsCompat
import java.lang.ref.WeakReference

object DeviceUtils {
private val MARGIN_ERROR_PX_SIZE = ViewUtils.dpToPx(24)

/**
* Check if the keyboard is currently being shown.
* Does not work for cases when keyboard is full screen.
*/
fun isKeyboardUp(activityWeakReference: WeakReference<Activity?>): Boolean {
val metrics = DisplayMetrics()
Expand All @@ -25,11 +26,18 @@
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) {
val heightDiff = metrics.heightPixels - visibleBounds.bottom
isOpen = heightDiff > MARGIN_ERROR_PX_SIZE
isOpen =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
val imeInsets = view.rootWindowInsets
imeInsets.isVisible(WindowInsetsCompat.Type.ime())
} else {
// Does not work for cases when keyboard is full screen for Android 9 and below
val heightDiff = metrics.heightPixels - visibleBounds.bottom
heightDiff > MARGIN_ERROR_PX_SIZE
}
}
return isOpen
}
Expand All @@ -37,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