@craft-native/android 0.0.222 → 0.0.224

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@craft-native/android",
3
- "version": "0.0.222",
3
+ "version": "0.0.224",
4
4
  "homepage": "https://github.com/craft-native/craft/tree/main/packages/android#readme",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1093,7 +1093,10 @@ internal object CraftNativeMedia {
1093
1093
  connection.disconnect()
1094
1094
  }
1095
1095
  }.getOrElse { error ->
1096
- CraftNativeCapabilityResult(code = if (error is java.net.SocketTimeoutException) "TIMEOUT" else "NETWORK_ERROR", message = error.message ?: "media.keep failed")
1096
+ val full = generateSequence(error) { it.cause }.take(16).any {
1097
+ it is android.system.ErrnoException && it.errno == android.system.OsConstants.ENOSPC
1098
+ }
1099
+ CraftNativeCapabilityResult(code = if (full) "NO_SPACE" else if (error is java.net.SocketTimeoutException) "TIMEOUT" else "NETWORK_ERROR", message = error.message ?: "media.keep failed")
1097
1100
  }
1098
1101
  val waiting = synchronized(inFlight) { inFlight.remove(address) ?: mutableListOf() }
1099
1102
  main.post { waiting.forEach { it(result) } }
@@ -92,6 +92,7 @@ import android.widget.Switch
92
92
  import android.widget.TextView
93
93
  import android.widget.MediaController
94
94
  import android.widget.VideoView
95
+ import androidx.activity.OnBackPressedCallback
95
96
  import androidx.appcompat.app.AppCompatActivity
96
97
  import androidx.appcompat.app.AppCompatDelegate
97
98
  import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
@@ -3826,6 +3827,9 @@ class MainActivity : AppCompatActivity() {
3826
3827
  override fun onCreate(savedInstanceState: Bundle?) {
3827
3828
  applyConfiguredAppearance()
3828
3829
  super.onCreate(savedInstanceState)
3830
+ onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
3831
+ override fun handleOnBackPressed() = handleNativeBack()
3832
+ })
3829
3833
  initialDeepLink = savedInstanceState?.getString("craft.initialDeepLink")?.let(Uri::parse) ?: intent?.data
3830
3834
  initialDeepLinkClaimed = savedInstanceState?.getBoolean("craft.initialDeepLinkClaimed", false) ?: false
3831
3835
  deliveredInitialDeepLink = savedInstanceState?.getBoolean("craft.deliveredInitialDeepLink", false) ?: false
@@ -3987,8 +3991,7 @@ class MainActivity : AppCompatActivity() {
3987
3991
  }
3988
3992
 
3989
3993
  private fun onBackPressedDispatcherCompat() {
3990
- @Suppress("DEPRECATION")
3991
- onBackPressed()
3994
+ onBackPressedDispatcher.onBackPressed()
3992
3995
  }
3993
3996
 
3994
3997
  private fun haptic() {
@@ -7286,7 +7289,9 @@ class MainActivity : AppCompatActivity() {
7286
7289
  }
7287
7290
 
7288
7291
  @Deprecated("Uses the activity back callback for native route navigation")
7289
- override fun onBackPressed() {
7292
+ override fun onBackPressed() = handleNativeBack()
7293
+
7294
+ private fun handleNativeBack() {
7290
7295
  val screen = screens.lastOrNull() ?: return back()
7291
7296
  val modal = screen.modalVisibility.entries.lastOrNull { (view, visible) -> visible && view.visibility == View.VISIBLE }
7292
7297
  if (modal != null) {