peachsim 0.1.1655 → 0.1.1660
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/cli/app-config.ts +4 -0
- package/cli/app-stubs.ts +43 -6
- package/cli/commands/inspect/shared.ts +5 -2
- package/cli/commands/inspect/url.ts +2 -1
- package/cli/commands/screenshot.ts +5 -5
- package/cli/commands/state.ts +9 -6
- package/cli/outbound-endpoints.ts +9 -1
- package/cli/output-redaction.ts +49 -0
- package/detox/index.ts +0 -1
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/bundle-channel.cjs +12772 -1132
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +29 -5
- package/dist-lib/config.mjs +29 -5
- package/dist-lib/detox/index.cjs +19 -6
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +10411 -73
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +11220 -670
- package/dist-lib/host/fetch-proxy-handler.cjs +260 -197
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +653 -338
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +443 -312
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +548 -163
- package/dist-lib/native-app-identity-project.cjs +179 -33
- package/dist-lib/native-app-identity-project.mjs +179 -33
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +23 -23
- package/dist-lib/public-origins-lib.json +96 -63
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +2 -2
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +12193 -1448
- package/dist-lib/swift-compile.cjs +10348 -172
- package/dist-lib/swift-compile.mjs +10348 -172
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +10411 -73
- package/dist-lib/vite.cjs +149 -163
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-compat/src/stubs/native-seams/react-native-gesture-handler.d.ts +2 -0
- package/dist-types/packages/peach-engine/src/engine/app-font-registry.d.ts +14 -0
- package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +8 -0
- package/dist-types/packages/peach-engine/src/engine/node.d.ts +3 -0
- package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +21 -0
- package/dist-types/packages/peach-engine/src/render-worker/gesture-seam-protocol.d.ts +2 -1
- package/dist-types/packages/peach-engine/src/render-worker/test-bridge-protocol.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/rolldown-bundle-inventory.d.ts +1 -0
- package/dist-types/packages/peach-globals/src/index.d.ts +34 -0
- package/kotlin/README.md +38 -23
- package/kotlin/sdk.tar.gz +0 -0
- package/package.json +2 -12
- package/runtime-companion.json +1 -1
- package/src/bundleGlobalFooter.ts +0 -2
- package/src/config.ts +54 -2
- package/src/configured-bundle-producer.ts +7 -1
- package/src/host/fetch-proxy-handler.ts +14 -50
- package/src/host/rolldown-bundle-forward.ts +71 -0
- package/src/installed-package-versions.ts +54 -2
- package/src/kotlin-host.ts +138 -285
- package/src/kotlin-module.ts +4 -7
- package/src/kotlin-sdk.ts +81 -0
- package/src/kotlin-toolchain.ts +152 -0
- package/src/kotlin-view-models.ts +1 -1
- package/src/kotlinSdkContract.ts +113 -0
- package/src/nitro-adapter.lock.json +3 -3
- package/src/nitro-bundle.ts +18 -4
- package/src/nitro-compile.ts +5 -1
- package/src/nitro-source.ts +112 -28
- package/src/nitroContract.ts +16 -4
- package/src/stub-pattern-matcher.ts +4 -0
- package/src/swift-compile.ts +44 -14
- package/src/swift-host.ts +2 -1
- package/src/swift-objc-compile.ts +117 -4
- package/src/swift-objc-sdk.ts +10215 -59
- package/src/swift-objc-standin.ts +5 -2
- package/src/vite-plugin-one.ts +73 -134
- package/src/worker-system-chunks.ts +14 -4
- package/src/xcode-project.ts +261 -34
- package/kotlin/AndroidViewSources/android/content/Context.kt +0 -22
- package/kotlin/AndroidViewSources/android/content/res/Configuration.kt +0 -25
- package/kotlin/AndroidViewSources/android/content/res/Resources.kt +0 -72
- package/kotlin/AndroidViewSources/android/graphics/Canvas.kt +0 -22
- package/kotlin/AndroidViewSources/android/graphics/Color.kt +0 -13
- package/kotlin/AndroidViewSources/android/graphics/Paint.kt +0 -18
- package/kotlin/AndroidViewSources/android/util/DisplayMetrics.kt +0 -12
- package/kotlin/AndroidViewSources/android/view/View.kt +0 -211
- package/kotlin/AndroidViewSources/android/widget/FrameLayout.kt +0 -61
- package/kotlin/AndroidViewSources/android/widget/LinearLayout.kt +0 -49
- package/kotlin/AndroidViewSources/dev/peach/app/JavaFormat.kt +0 -272
- package/kotlin/AppSources/android/app/Activity.kt +0 -174
- package/kotlin/AppSources/android/app/Application.kt +0 -11
- package/kotlin/AppSources/android/app/UiModeManager.kt +0 -9
- package/kotlin/AppSources/android/content/Intent.kt +0 -16
- package/kotlin/AppSources/android/os/Bundle.kt +0 -11
- package/kotlin/AppSources/android/util/SuperNotCalledException.kt +0 -3
- package/kotlin/AppSources/android/view/Window.kt +0 -182
- package/kotlin/AppSources/android/view/WindowInsets.kt +0 -9
- package/kotlin/AppSources/android/view/WindowInsetsController.kt +0 -17
- package/kotlin/AppSources/android/view/WindowManager.kt +0 -16
- package/kotlin/AppSources/android/window/BackEvent.kt +0 -24
- package/kotlin/AppSources/android/window/OnBackAnimationCallback.kt +0 -7
- package/kotlin/AppSources/android/window/OnBackInvokedDispatcher.kt +0 -84
- package/kotlin/AppSources/androidx/activity/ActivityFlags.kt +0 -9
- package/kotlin/AppSources/androidx/activity/ActivityViewModelLazy.kt +0 -21
- package/kotlin/AppSources/androidx/activity/BackEventCompat.kt +0 -43
- package/kotlin/AppSources/androidx/activity/ComponentActivity.kt +0 -122
- package/kotlin/AppSources/androidx/activity/EdgeToEdge.kt +0 -75
- package/kotlin/AppSources/androidx/activity/ExperimentalActivityApi.kt +0 -6
- package/kotlin/AppSources/androidx/activity/OnBackPressedCallback.kt +0 -69
- package/kotlin/AppSources/androidx/activity/OnBackPressedDispatcher.kt +0 -144
- package/kotlin/AppSources/androidx/activity/OnBackPressedDispatcherOwner.kt +0 -7
- package/kotlin/AppSources/androidx/activity/compose/BackHandler.kt +0 -86
- package/kotlin/AppSources/androidx/activity/compose/ComponentActivity.kt +0 -29
- package/kotlin/AppSources/androidx/activity/compose/internal/BackHandlerCompat.kt +0 -38
- package/kotlin/AppSources/androidx/activity/compose/internal/BackHandlerDispatcherCompat.kt +0 -27
- package/kotlin/AppSources/androidx/compose/foundation/layout/WindowInsets.kt +0 -15
- package/kotlin/AppSources/androidx/compose/ui/platform/AndroidCompositionLocals.kt +0 -27
- package/kotlin/AppSources/androidx/compose/ui/platform/ComposeView.kt +0 -68
- package/kotlin/AppSources/androidx/compose/ui/res/ColorResources.kt +0 -16
- package/kotlin/AppSources/androidx/compose/ui/res/PainterResources.kt +0 -70
- package/kotlin/AppSources/androidx/compose/ui/res/StringResources.kt +0 -38
- package/kotlin/AppSources/androidx/core/view/WindowCompat.kt +0 -32
- package/kotlin/AppSources/androidx/lifecycle/AndroidViewModel.kt +0 -10
- package/kotlin/AppSources/dev/peach/app/PeachApp.kt +0 -388
- package/kotlin/AppSources/dev/peach/app/PeachDrawable.kt +0 -102
- package/kotlin/AppSources/dev/peach/app/PeachWindowHost.kt +0 -14
- package/kotlin/CompilerSources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar +0 -1
- package/kotlin/CompilerSources/PeachJniIncoming.kt +0 -243
- package/kotlin/CompilerSources/PeachJniPlugin.kt +0 -116
- package/kotlin/ComposeSources/PeachComposeHost.kt +0 -724
- package/kotlin/ComposeSources/PeachMagnifier.kt +0 -185
- package/kotlin/ComposeSources/PeachSemantics.kt +0 -127
- package/kotlin/ExpoComposeSources/PeachAndroidView.kt +0 -103
- package/kotlin/ExpoComposeSources/PeachExpoViewMount.kt +0 -24
- package/kotlin/ExpoComposeSources/dev/peach/expo/PeachExpoCompose.kt +0 -28
- package/kotlin/ExpoComposeSources/expo/modules/kotlin/views/ExpoComposeView.kt +0 -70
- package/kotlin/ExpoSources/dev/peach/expo/PeachExpoRuntime.kt +0 -516
- package/kotlin/ExpoSources/dev/peach/expo/PeachExpoTypes.kt +0 -173
- package/kotlin/ExpoSources/expo/modules/kotlin/AppContext.kt +0 -20
- package/kotlin/ExpoSources/expo/modules/kotlin/Promise.kt +0 -19
- package/kotlin/ExpoSources/expo/modules/kotlin/classcomponent/ClassComponentBuilder.kt +0 -198
- package/kotlin/ExpoSources/expo/modules/kotlin/exception/CodedException.kt +0 -126
- package/kotlin/ExpoSources/expo/modules/kotlin/functions/Functions.kt +0 -132
- package/kotlin/ExpoSources/expo/modules/kotlin/jni/JavaScriptTypedArray.kt +0 -81
- package/kotlin/ExpoSources/expo/modules/kotlin/modules/Module.kt +0 -98
- package/kotlin/ExpoSources/expo/modules/kotlin/objects/ObjectDefinitionBuilder.kt +0 -236
- package/kotlin/ExpoSources/expo/modules/kotlin/records/Record.kt +0 -12
- package/kotlin/ExpoSources/expo/modules/kotlin/runtime/Runtime.kt +0 -9
- package/kotlin/ExpoSources/expo/modules/kotlin/sharedobjects/SharedObject.kt +0 -50
- package/kotlin/ExpoSources/expo/modules/kotlin/sharedobjects/SharedObjectRegistry.kt +0 -57
- package/kotlin/ExpoSources/expo/modules/kotlin/sharedobjects/SharedRef.kt +0 -19
- package/kotlin/ExpoSources/expo/modules/kotlin/typedarray/ConcreteTypedArrays.kt +0 -158
- package/kotlin/ExpoSources/expo/modules/kotlin/typedarray/GenericTypedArray.kt +0 -8
- package/kotlin/ExpoSources/expo/modules/kotlin/typedarray/TypedArray.kt +0 -29
- package/kotlin/ExpoSources/expo/modules/kotlin/typedarray/TypedArrayIterator.kt +0 -9
- package/kotlin/ExpoSources/expo/modules/kotlin/types/AnyType.kt +0 -155
- package/kotlin/ExpoSources/expo/modules/kotlin/types/Either.kt +0 -91
- package/kotlin/ExpoSources/expo/modules/kotlin/types/Enumerable.kt +0 -6
- package/kotlin/ExpoSources/expo/modules/kotlin/viewevent/ViewEvent.kt +0 -68
- package/kotlin/ExpoSources/expo/modules/kotlin/views/ExpoView.kt +0 -20
- package/kotlin/ExpoSources/expo/modules/kotlin/views/ViewDefinitionBuilder.kt +0 -72
- package/kotlin/ExpoSources/expo/modules/kotlin/views/ViewProps.kt +0 -36
- package/kotlin/JniPlatformSources/androidx/annotation/CallSuper.kt +0 -5
- package/kotlin/JniPlatformSources/com/facebook/proguard/annotations/DoNotStrip.kt +0 -5
- package/kotlin/JniPlatformSources/dalvik/annotation/optimization/FastNative.kt +0 -5
- package/kotlin/JniPlatformSources/kotlin/Synchronized.kt +0 -6
- package/kotlin/JniPlatformSources/kotlin/jvm/JvmField.kt +0 -5
- package/kotlin/JniPlatformSources/kotlin/jvm/JvmStatic.kt +0 -5
- package/kotlin/JniSources/com/facebook/jni/HybridData.kt +0 -66
- package/kotlin/JniSources/dev/peach/jni/IncomingBindings.kt +0 -157
- package/kotlin/JniSources/dev/peach/jni/NativeBindings.kt +0 -77
- package/kotlin/JniTransportSources/dev/peach/jni/integration/JniTransport.kt +0 -89
- package/kotlin/Sources/android/os/Build.kt +0 -17
- package/kotlin/Sources/android/os/Handler.kt +0 -35
- package/kotlin/Sources/android/os/Looper.kt +0 -17
- package/kotlin/Sources/android/os/MessageQueue.kt +0 -56
- package/kotlin/Sources/android/os/SystemClock.kt +0 -14
- package/kotlin/Sources/android/util/Log.kt +0 -64
- package/kotlin/Sources/androidx/annotation/DrawableRes.kt +0 -14
- package/kotlin/Sources/androidx/annotation/Keep.kt +0 -4
- package/kotlin/Sources/dev/onejs/one/OneNativeSourceDispatch.kt +0 -7
- package/kotlin/Sources/dev/onejs/one/OneNativeSourceViewDispatch.kt +0 -13
- package/kotlin/Sources/dev/onejs/one/source/OneModule.kt +0 -4
- package/kotlin/Sources/java/lang/Runnable.kt +0 -6
- package/kotlin/Sources/java/security/MessageDigest.kt +0 -114
- package/kotlin/Sources/java/util/IllegalFormatCodePointException.kt +0 -10
- package/kotlin/Sources/java/util/IllegalFormatException.kt +0 -5
- package/kotlin/Sources/kotlin/text/StringFormat.kt +0 -9
- package/kotlin/Sources/org/json/JSON.kt +0 -307
- package/kotlin/tools/abi-classes.main.kts +0 -41
- package/kotlin/tools/expo-types.main.kts +0 -127
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
package androidx.activity
|
|
2
|
-
|
|
3
|
-
import android.app.Activity
|
|
4
|
-
import android.os.Bundle
|
|
5
|
-
import androidx.lifecycle.HasDefaultViewModelProviderFactory
|
|
6
|
-
import androidx.lifecycle.Lifecycle
|
|
7
|
-
import androidx.lifecycle.LifecycleEventObserver
|
|
8
|
-
import androidx.lifecycle.LifecycleOwner
|
|
9
|
-
import androidx.lifecycle.LifecycleRegistry
|
|
10
|
-
import androidx.lifecycle.SAVED_STATE_REGISTRY_OWNER_KEY
|
|
11
|
-
import androidx.lifecycle.VIEW_MODEL_STORE_OWNER_KEY
|
|
12
|
-
import androidx.lifecycle.ViewModelStore
|
|
13
|
-
import androidx.lifecycle.ViewModelStoreOwner
|
|
14
|
-
import androidx.lifecycle.enableSavedStateHandles
|
|
15
|
-
import androidx.lifecycle.viewmodel.CreationExtras
|
|
16
|
-
import androidx.lifecycle.viewmodel.MutableCreationExtras
|
|
17
|
-
import androidx.navigationevent.DirectNavigationEventInput
|
|
18
|
-
import androidx.navigationevent.NavigationEventDispatcher
|
|
19
|
-
import androidx.navigationevent.NavigationEventDispatcherOwner
|
|
20
|
-
import androidx.savedstate.SavedStateRegistry
|
|
21
|
-
import androidx.savedstate.SavedStateRegistryController
|
|
22
|
-
import androidx.savedstate.SavedStateRegistryOwner
|
|
23
|
-
|
|
24
|
-
// androidx.activity's ComponentActivity owners, on the multiplatform
|
|
25
|
-
// lifecycle, viewmodel and savedstate libraries: the registry attaches in the
|
|
26
|
-
// constructor and restores in onCreate before super, the lifecycle moves up on
|
|
27
|
-
// the post callbacks and down on the pre callbacks, as ReportFragment does from
|
|
28
|
-
// API 29, and destroy clears the view model store unless the activity is
|
|
29
|
-
// changing configurations.
|
|
30
|
-
open class ComponentActivity : Activity(), LifecycleOwner, ViewModelStoreOwner,
|
|
31
|
-
HasDefaultViewModelProviderFactory, SavedStateRegistryOwner, OnBackPressedDispatcherOwner,
|
|
32
|
-
NavigationEventDispatcherOwner {
|
|
33
|
-
private val lifecycleRegistry = LifecycleRegistry(this)
|
|
34
|
-
private val savedStateRegistryController = SavedStateRegistryController.create(this)
|
|
35
|
-
|
|
36
|
-
// the last instance's store after a configuration relaunch, else a new one
|
|
37
|
-
private var _viewModelStore: ViewModelStore? = null
|
|
38
|
-
|
|
39
|
-
private class NonConfigurationInstances(val custom: Any?, val viewModelStore: ViewModelStore?)
|
|
40
|
-
|
|
41
|
-
override val lifecycle: Lifecycle get() = lifecycleRegistry
|
|
42
|
-
override val viewModelStore: ViewModelStore
|
|
43
|
-
get() {
|
|
44
|
-
ensureViewModelStore()
|
|
45
|
-
return checkNotNull(_viewModelStore)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
private fun ensureViewModelStore() {
|
|
49
|
-
if (_viewModelStore == null) {
|
|
50
|
-
_viewModelStore = (lastNonConfigurationInstance as? NonConfigurationInstances)?.viewModelStore
|
|
51
|
-
?: ViewModelStore()
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
override val savedStateRegistry: SavedStateRegistry get() = savedStateRegistryController.savedStateRegistry
|
|
55
|
-
// SavedStateViewModelFactory's constructor choice, made at compile time
|
|
56
|
-
// for the app's view models since Kotlin/Wasm has no reflection
|
|
57
|
-
override val defaultViewModelProviderFactory get() = dev.peach.app.viewModelFactory()
|
|
58
|
-
override val defaultViewModelCreationExtras: CreationExtras
|
|
59
|
-
get() = MutableCreationExtras().also {
|
|
60
|
-
it[SAVED_STATE_REGISTRY_OWNER_KEY] = this
|
|
61
|
-
it[VIEW_MODEL_STORE_OWNER_KEY] = this
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
init {
|
|
65
|
-
lifecycleRegistry.addObserver(LifecycleEventObserver { _, event ->
|
|
66
|
-
if (event == Lifecycle.Event.ON_DESTROY && !isChangingConfigurations) viewModelStore.clear()
|
|
67
|
-
})
|
|
68
|
-
savedStateRegistryController.performAttach()
|
|
69
|
-
enableSavedStateHandles()
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
override fun onCreate(savedInstanceState: Bundle?) {
|
|
73
|
-
savedStateRegistryController.performRestore(savedInstanceState?.state)
|
|
74
|
-
super.onCreate(savedInstanceState)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
@Suppress("DEPRECATION")
|
|
78
|
-
final override fun onRetainNonConfigurationInstance(): Any? {
|
|
79
|
-
val custom = onRetainCustomNonConfigurationInstance()
|
|
80
|
-
val viewModelStore = _viewModelStore
|
|
81
|
-
?: (lastNonConfigurationInstance as? NonConfigurationInstances)?.viewModelStore
|
|
82
|
-
if (viewModelStore == null && custom == null) return null
|
|
83
|
-
return NonConfigurationInstances(custom, viewModelStore)
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
@Deprecated("Use a ViewModel to store non config state.")
|
|
87
|
-
open fun onRetainCustomNonConfigurationInstance(): Any? = null
|
|
88
|
-
|
|
89
|
-
@Deprecated("Use a ViewModel to store non config state.")
|
|
90
|
-
open val lastCustomNonConfigurationInstance: Any?
|
|
91
|
-
get() = (lastNonConfigurationInstance as? NonConfigurationInstances)?.custom
|
|
92
|
-
|
|
93
|
-
override fun onSaveInstanceState(outState: Bundle) {
|
|
94
|
-
lifecycleRegistry.currentState = Lifecycle.State.CREATED
|
|
95
|
-
super.onSaveInstanceState(outState)
|
|
96
|
-
savedStateRegistryController.performSave(outState.state)
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// onBackPressed's back, an input of the navigation event dispatcher: an
|
|
100
|
-
// enabled handler gets it first; without one it falls back to Activity's own
|
|
101
|
-
private val onBackPressedInput: DirectNavigationEventInput by lazy {
|
|
102
|
-
DirectNavigationEventInput().also(navigationEventDispatcher::addInput)
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
override fun onBackPressed() {
|
|
106
|
-
onBackPressedInput.backCompleted()
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
final override val onBackPressedDispatcher: OnBackPressedDispatcher by lazy {
|
|
110
|
-
OnBackPressedDispatcher { super@ComponentActivity.onBackPressed() }
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
override val navigationEventDispatcher: NavigationEventDispatcher
|
|
114
|
-
get() = onBackPressedDispatcher.eventDispatcher
|
|
115
|
-
|
|
116
|
-
override fun dispatchActivityPostCreated() = lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_CREATE)
|
|
117
|
-
override fun dispatchActivityPostStarted() = lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_START)
|
|
118
|
-
override fun dispatchActivityPostResumed() = lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_RESUME)
|
|
119
|
-
override fun dispatchActivityPrePaused() = lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_PAUSE)
|
|
120
|
-
override fun dispatchActivityPreStopped() = lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_STOP)
|
|
121
|
-
override fun dispatchActivityPreDestroyed() = lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_DESTROY)
|
|
122
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
package androidx.activity
|
|
2
|
-
|
|
3
|
-
import android.app.UiModeManager
|
|
4
|
-
import android.content.res.Configuration
|
|
5
|
-
import android.content.res.Resources
|
|
6
|
-
import android.graphics.Color
|
|
7
|
-
import android.view.WindowManager
|
|
8
|
-
import androidx.core.view.WindowCompat
|
|
9
|
-
import androidx.core.view.WindowInsetsControllerCompat
|
|
10
|
-
|
|
11
|
-
// androidx.activity 1.13.0's EdgeToEdge as it runs on Peach's API 37 device,
|
|
12
|
-
// where it takes EdgeToEdgeApi35: the decor stops fitting system windows, the
|
|
13
|
-
// bars turn transparent, navigation bar contrast follows an auto style, the
|
|
14
|
-
// bars' appearance follows dark mode and the window lays out into every
|
|
15
|
-
// cutout. a style's non-transparent scrim is an androidx.core ProtectionLayout
|
|
16
|
-
// view added to the decor, which Peach's ComposeView-only window cannot host.
|
|
17
|
-
|
|
18
|
-
// DecorView's light scrim and the platform's dark scrim
|
|
19
|
-
internal val DefaultLightScrim = Color.argb(0xe6, 0xFF, 0xFF, 0xFF)
|
|
20
|
-
internal val DefaultDarkScrim = Color.argb(0x80, 0x1b, 0x1b, 0x1b)
|
|
21
|
-
|
|
22
|
-
fun ComponentActivity.enableEdgeToEdge(
|
|
23
|
-
statusBarStyle: SystemBarStyle = SystemBarStyle.auto(Color.TRANSPARENT, Color.TRANSPARENT),
|
|
24
|
-
navigationBarStyle: SystemBarStyle = SystemBarStyle.auto(DefaultLightScrim, DefaultDarkScrim),
|
|
25
|
-
) {
|
|
26
|
-
val view = window.decorView
|
|
27
|
-
val statusBarIsDark = statusBarStyle.detectDarkMode(view.resources)
|
|
28
|
-
val navigationBarIsDark = navigationBarStyle.detectDarkMode(view.resources)
|
|
29
|
-
WindowCompat.setDecorFitsSystemWindows(window, false)
|
|
30
|
-
window.statusBarColor = Color.TRANSPARENT
|
|
31
|
-
window.navigationBarColor = Color.TRANSPARENT
|
|
32
|
-
check(
|
|
33
|
-
statusBarStyle.getScrimWithEnforcedContrast(statusBarIsDark) == Color.TRANSPARENT &&
|
|
34
|
-
navigationBarStyle.getScrimWithEnforcedContrast(navigationBarIsDark) == Color.TRANSPARENT
|
|
35
|
-
) { "enableEdgeToEdge with a non-transparent scrim adds a ProtectionLayout view; Peach composes only ComposeView content" }
|
|
36
|
-
window.isNavigationBarContrastEnforced = navigationBarStyle.nightMode == UiModeManager.MODE_NIGHT_AUTO
|
|
37
|
-
WindowInsetsControllerCompat(window, view).run {
|
|
38
|
-
isAppearanceLightStatusBars = !statusBarIsDark
|
|
39
|
-
isAppearanceLightNavigationBars = !navigationBarIsDark
|
|
40
|
-
}
|
|
41
|
-
window.attributes.layoutInDisplayCutoutMode =
|
|
42
|
-
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
class SystemBarStyle private constructor(
|
|
46
|
-
private val lightScrim: Int,
|
|
47
|
-
internal val darkScrim: Int,
|
|
48
|
-
internal val nightMode: Int,
|
|
49
|
-
internal val detectDarkMode: (Resources) -> Boolean,
|
|
50
|
-
) {
|
|
51
|
-
companion object {
|
|
52
|
-
fun auto(
|
|
53
|
-
lightScrim: Int,
|
|
54
|
-
darkScrim: Int,
|
|
55
|
-
detectDarkMode: (Resources) -> Boolean = { resources ->
|
|
56
|
-
(resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) ==
|
|
57
|
-
Configuration.UI_MODE_NIGHT_YES
|
|
58
|
-
},
|
|
59
|
-
): SystemBarStyle = SystemBarStyle(lightScrim, darkScrim, UiModeManager.MODE_NIGHT_AUTO, detectDarkMode)
|
|
60
|
-
|
|
61
|
-
fun dark(scrim: Int): SystemBarStyle =
|
|
62
|
-
SystemBarStyle(scrim, scrim, UiModeManager.MODE_NIGHT_YES) { true }
|
|
63
|
-
|
|
64
|
-
fun light(scrim: Int, darkScrim: Int): SystemBarStyle =
|
|
65
|
-
SystemBarStyle(scrim, darkScrim, UiModeManager.MODE_NIGHT_NO) { false }
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
internal fun getScrim(isDark: Boolean) = if (isDark) darkScrim else lightScrim
|
|
69
|
-
|
|
70
|
-
internal fun getScrimWithEnforcedContrast(isDark: Boolean): Int = when {
|
|
71
|
-
nightMode == UiModeManager.MODE_NIGHT_AUTO -> Color.TRANSPARENT
|
|
72
|
-
isDark -> darkScrim
|
|
73
|
-
else -> lightScrim
|
|
74
|
-
}
|
|
75
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
package androidx.activity
|
|
2
|
-
|
|
3
|
-
import androidx.navigationevent.NavigationEvent
|
|
4
|
-
import androidx.navigationevent.NavigationEventHandler
|
|
5
|
-
import androidx.navigationevent.NavigationEventInfo
|
|
6
|
-
|
|
7
|
-
// androidx.activity 1.13.0's OnBackPressedCallback: each registration is a
|
|
8
|
-
// NavigationEventHandler on the dispatcher's NavigationEventDispatcher
|
|
9
|
-
abstract class OnBackPressedCallback(enabled: Boolean) {
|
|
10
|
-
private val eventHandlers: MutableList<OnBackPressedEventHandler> = mutableListOf()
|
|
11
|
-
|
|
12
|
-
var isEnabled: Boolean = enabled
|
|
13
|
-
set(value) {
|
|
14
|
-
field = value
|
|
15
|
-
// a handler registered without a lifecycle is always lifecycle active
|
|
16
|
-
for (callback in eventHandlers) callback.isBackEnabled = callback.isLifecycleActive && value
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
private val closeables = mutableListOf<AutoCloseable>()
|
|
20
|
-
|
|
21
|
-
fun remove() {
|
|
22
|
-
for (closeable in closeables.toList()) closeable.close()
|
|
23
|
-
closeables.clear()
|
|
24
|
-
for (callback in eventHandlers) callback.remove()
|
|
25
|
-
eventHandlers.clear()
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
open fun handleOnBackStarted(backEvent: BackEventCompat) {}
|
|
29
|
-
open fun handleOnBackProgressed(backEvent: BackEventCompat) {}
|
|
30
|
-
abstract fun handleOnBackPressed()
|
|
31
|
-
open fun handleOnBackCancelled() {}
|
|
32
|
-
|
|
33
|
-
internal fun addCloseable(closeable: AutoCloseable) {
|
|
34
|
-
closeables += closeable
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
internal fun createNavigationEventHandler(info: NavigationEventInfo): OnBackPressedEventHandler {
|
|
38
|
-
val newHandler = OnBackPressedEventHandler(onBackPressedCallback = this, info)
|
|
39
|
-
eventHandlers += newHandler
|
|
40
|
-
return newHandler
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
internal class OnBackPressedEventHandler(
|
|
44
|
-
private val onBackPressedCallback: OnBackPressedCallback,
|
|
45
|
-
info: NavigationEventInfo,
|
|
46
|
-
) : NavigationEventHandler<NavigationEventInfo>(initialInfo = info, isBackEnabled = onBackPressedCallback.isEnabled) {
|
|
47
|
-
var isLifecycleActive: Boolean = true
|
|
48
|
-
set(value) {
|
|
49
|
-
field = value
|
|
50
|
-
isBackEnabled = value && onBackPressedCallback.isEnabled
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
override fun onBackStarted(event: NavigationEvent) {
|
|
54
|
-
onBackPressedCallback.handleOnBackStarted(BackEventCompat(event))
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
override fun onBackProgressed(event: NavigationEvent) {
|
|
58
|
-
onBackPressedCallback.handleOnBackProgressed(BackEventCompat(event))
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
override fun onBackCompleted() {
|
|
62
|
-
onBackPressedCallback.handleOnBackPressed()
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
override fun onBackCancelled() {
|
|
66
|
-
onBackPressedCallback.handleOnBackCancelled()
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
package androidx.activity
|
|
2
|
-
|
|
3
|
-
import androidx.lifecycle.Lifecycle
|
|
4
|
-
import androidx.lifecycle.LifecycleEventObserver
|
|
5
|
-
import androidx.lifecycle.LifecycleOwner
|
|
6
|
-
import androidx.navigationevent.NavigationEvent
|
|
7
|
-
import androidx.navigationevent.NavigationEventDispatcher
|
|
8
|
-
import androidx.navigationevent.NavigationEventInfo
|
|
9
|
-
import androidx.navigationevent.NavigationEventInput
|
|
10
|
-
import java.lang.Runnable
|
|
11
|
-
|
|
12
|
-
// activity 1.13.0 routes legacy back through its navigation event input;
|
|
13
|
-
// predictive back registers separate default and overlay inputs with the window.
|
|
14
|
-
class OnBackPressedDispatcher(
|
|
15
|
-
private val fallbackOnBackPressed: Runnable?,
|
|
16
|
-
private val onHasEnabledCallbacksChanged: ((Boolean) -> Unit)?,
|
|
17
|
-
) {
|
|
18
|
-
private var hasEnabledCallbacks = false
|
|
19
|
-
private val eventInput by lazy { OnBackPressedEventInput() }
|
|
20
|
-
|
|
21
|
-
internal val eventDispatcher
|
|
22
|
-
get() = eventInput.dispatcher
|
|
23
|
-
|
|
24
|
-
constructor(fallbackOnBackPressed: Runnable? = null) : this(fallbackOnBackPressed, null)
|
|
25
|
-
|
|
26
|
-
fun addCallback(onBackPressedCallback: OnBackPressedCallback) {
|
|
27
|
-
val info = OnBackPressedCallbackInfo(onBackPressedCallback)
|
|
28
|
-
val handler = onBackPressedCallback.createNavigationEventHandler(info)
|
|
29
|
-
eventDispatcher.addHandler(handler)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
@OptIn(ExperimentalActivityApi::class)
|
|
33
|
-
fun addCallback(owner: LifecycleOwner, onBackPressedCallback: OnBackPressedCallback) {
|
|
34
|
-
val lifecycle = owner.lifecycle
|
|
35
|
-
if (lifecycle.currentState === Lifecycle.State.DESTROYED) return
|
|
36
|
-
val info = OnBackPressedCallbackInfo(onBackPressedCallback, owner)
|
|
37
|
-
val eventHandler = onBackPressedCallback.createNavigationEventHandler(info)
|
|
38
|
-
// the order flag adds the handler once, so its place in the queue holds,
|
|
39
|
-
// and toggles it with the lifecycle; the legacy order re-adds it on each
|
|
40
|
-
// start, which moves it to the top
|
|
41
|
-
if (ActivityFlags.isOnBackPressedLifecycleOrderMaintained) {
|
|
42
|
-
eventHandler.isLifecycleActive = false
|
|
43
|
-
eventDispatcher.addHandler(eventHandler)
|
|
44
|
-
}
|
|
45
|
-
val observer = object : LifecycleEventObserver {
|
|
46
|
-
override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) {
|
|
47
|
-
when (event) {
|
|
48
|
-
Lifecycle.Event.ON_START ->
|
|
49
|
-
if (ActivityFlags.isOnBackPressedLifecycleOrderMaintained) eventHandler.isLifecycleActive = true
|
|
50
|
-
else eventDispatcher.addHandler(eventHandler)
|
|
51
|
-
Lifecycle.Event.ON_STOP ->
|
|
52
|
-
if (ActivityFlags.isOnBackPressedLifecycleOrderMaintained) eventHandler.isLifecycleActive = false
|
|
53
|
-
else eventHandler.remove()
|
|
54
|
-
Lifecycle.Event.ON_DESTROY -> {
|
|
55
|
-
eventHandler.remove()
|
|
56
|
-
lifecycle.removeObserver(this)
|
|
57
|
-
}
|
|
58
|
-
else -> Unit
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
lifecycle.addObserver(observer)
|
|
63
|
-
onBackPressedCallback.addCloseable(AutoCloseable { lifecycle.removeObserver(observer) })
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
fun hasEnabledCallbacks(): Boolean = hasEnabledCallbacks
|
|
67
|
-
|
|
68
|
-
// activity 1.13 registers separate default and overlay platform inputs.
|
|
69
|
-
fun setOnBackInvokedDispatcher(invoker: android.window.OnBackInvokedDispatcher) {
|
|
70
|
-
eventDispatcher.addInput(WindowBackInput(invoker, android.window.OnBackInvokedDispatcher.PRIORITY_DEFAULT), NavigationEventDispatcher.PRIORITY_DEFAULT)
|
|
71
|
-
eventDispatcher.addInput(WindowBackInput(invoker, android.window.OnBackInvokedDispatcher.PRIORITY_OVERLAY), NavigationEventDispatcher.PRIORITY_OVERLAY)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
fun dispatchOnBackStarted(backEvent: BackEventCompat) {
|
|
75
|
-
eventInput.backStarted(backEvent.toNavigationEvent())
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
fun dispatchOnBackProgressed(backEvent: BackEventCompat) {
|
|
79
|
-
eventInput.backProgressed(backEvent.toNavigationEvent())
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
fun onBackPressed() {
|
|
83
|
-
eventInput.backCompleted()
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
fun dispatchOnBackCancelled() {
|
|
87
|
-
eventInput.backCancelled()
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
private inner class OnBackPressedEventInput : NavigationEventInput() {
|
|
91
|
-
val dispatcher = NavigationEventDispatcher { fallbackOnBackPressed?.run() }.also { it.addInput(this) }
|
|
92
|
-
|
|
93
|
-
override fun onHasEnabledHandlersChanged(hasEnabledHandlers: Boolean) {
|
|
94
|
-
hasEnabledCallbacks = hasEnabledHandlers
|
|
95
|
-
onHasEnabledCallbacksChanged?.invoke(hasEnabledHandlers)
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
fun backStarted(event: NavigationEvent) = dispatchOnBackStarted(event)
|
|
99
|
-
fun backProgressed(event: NavigationEvent) = dispatchOnBackProgressed(event)
|
|
100
|
-
fun backCancelled() = dispatchOnBackCancelled()
|
|
101
|
-
fun backCompleted() = dispatchOnBackCompleted()
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
private class WindowBackInput(
|
|
106
|
-
private val invoker: android.window.OnBackInvokedDispatcher,
|
|
107
|
-
private val priority: Int,
|
|
108
|
-
) : NavigationEventInput() {
|
|
109
|
-
private val callback = object : android.window.OnBackAnimationCallback {
|
|
110
|
-
override fun onBackStarted(backEvent: android.window.BackEvent) =
|
|
111
|
-
dispatchOnBackStarted(BackEventCompat(backEvent).toNavigationEvent())
|
|
112
|
-
override fun onBackProgressed(backEvent: android.window.BackEvent) =
|
|
113
|
-
dispatchOnBackProgressed(BackEventCompat(backEvent).toNavigationEvent())
|
|
114
|
-
override fun onBackCancelled() = dispatchOnBackCancelled()
|
|
115
|
-
override fun onBackInvoked() = dispatchOnBackCompleted()
|
|
116
|
-
}
|
|
117
|
-
override fun onHasEnabledHandlersChanged(hasEnabledHandlers: Boolean) {
|
|
118
|
-
if (hasEnabledHandlers) invoker.registerOnBackInvokedCallback(priority, callback)
|
|
119
|
-
else invoker.unregisterOnBackInvokedCallback(callback)
|
|
120
|
-
}
|
|
121
|
-
override fun onRemoved() { invoker.unregisterOnBackInvokedCallback(callback) }
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// androidx.activity's Kotlin registration: a callback from a lambda, bound to
|
|
125
|
-
// owner's lifecycle when one is given
|
|
126
|
-
fun OnBackPressedDispatcher.addCallback(
|
|
127
|
-
owner: LifecycleOwner? = null,
|
|
128
|
-
enabled: Boolean = true,
|
|
129
|
-
onBackPressed: OnBackPressedCallback.() -> Unit,
|
|
130
|
-
): OnBackPressedCallback {
|
|
131
|
-
val callback = object : OnBackPressedCallback(enabled) {
|
|
132
|
-
override fun handleOnBackPressed() {
|
|
133
|
-
onBackPressed()
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
if (owner != null) addCallback(owner, callback)
|
|
137
|
-
else addCallback(callback)
|
|
138
|
-
return callback
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
private data class OnBackPressedCallbackInfo(
|
|
142
|
-
val callback: OnBackPressedCallback,
|
|
143
|
-
val owner: LifecycleOwner? = null,
|
|
144
|
-
) : NavigationEventInfo()
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
package androidx.activity.compose
|
|
2
|
-
|
|
3
|
-
import androidx.activity.ActivityFlags
|
|
4
|
-
import androidx.activity.ExperimentalActivityApi
|
|
5
|
-
import androidx.activity.OnBackPressedDispatcherOwner
|
|
6
|
-
import androidx.activity.compose.internal.BackHandlerCompat
|
|
7
|
-
import androidx.activity.compose.internal.BackHandlerDispatcherCompat
|
|
8
|
-
import androidx.compose.runtime.Composable
|
|
9
|
-
import androidx.compose.runtime.DisposableEffect
|
|
10
|
-
import androidx.compose.runtime.ProvidedValue
|
|
11
|
-
import androidx.compose.runtime.SideEffect
|
|
12
|
-
import androidx.compose.runtime.compositionLocalOf
|
|
13
|
-
import androidx.compose.runtime.currentCompositeKeyHashCode
|
|
14
|
-
import androidx.compose.runtime.remember
|
|
15
|
-
import androidx.lifecycle.compose.LifecycleStartEffect
|
|
16
|
-
import androidx.navigationevent.NavigationEventDispatcherOwner
|
|
17
|
-
import androidx.navigationevent.NavigationEventInfo
|
|
18
|
-
import androidx.navigationevent.compose.LocalNavigationEventDispatcherOwner
|
|
19
|
-
|
|
20
|
-
// activity-compose 1.13.0's LocalOnBackPressedDispatcherOwner. on the device
|
|
21
|
-
// an unprovided value resolves from the view tree or the context, both of
|
|
22
|
-
// which reach the activity that set the content; the window host provides that
|
|
23
|
-
// activity here.
|
|
24
|
-
object LocalOnBackPressedDispatcherOwner {
|
|
25
|
-
private val LocalOnBackPressedDispatcherOwner =
|
|
26
|
-
compositionLocalOf<OnBackPressedDispatcherOwner?> { null }
|
|
27
|
-
|
|
28
|
-
val current: OnBackPressedDispatcherOwner?
|
|
29
|
-
@Composable
|
|
30
|
-
get() = LocalOnBackPressedDispatcherOwner.current
|
|
31
|
-
|
|
32
|
-
infix fun provides(dispatcherOwner: OnBackPressedDispatcherOwner): ProvidedValue<OnBackPressedDispatcherOwner?> =
|
|
33
|
-
LocalOnBackPressedDispatcherOwner.provides(dispatcherOwner)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// activity-compose 1.13.0's BackHandler: a handler on the navigation event
|
|
37
|
-
// dispatcher when one is provided, else a callback on the back dispatcher
|
|
38
|
-
@OptIn(ExperimentalActivityApi::class)
|
|
39
|
-
@Composable
|
|
40
|
-
fun BackHandler(enabled: Boolean = true, onBack: () -> Unit) {
|
|
41
|
-
val owner = LocalNavigationEventDispatcherOwner.current
|
|
42
|
-
?: LocalOnBackPressedDispatcherOwner.current
|
|
43
|
-
?: error(
|
|
44
|
-
"No NavigationEventDispatcherOwner was provided via " +
|
|
45
|
-
"LocalNavigationEventDispatcherOwner and no OnBackPressedDispatcherOwner was " +
|
|
46
|
-
"provided via LocalOnBackPressedDispatcherOwner. Please provide one of the two."
|
|
47
|
-
)
|
|
48
|
-
val dispatcher = remember(owner) {
|
|
49
|
-
BackHandlerDispatcherCompat(
|
|
50
|
-
(owner as? NavigationEventDispatcherOwner)?.navigationEventDispatcher,
|
|
51
|
-
(owner as? OnBackPressedDispatcherOwner)?.onBackPressedDispatcher,
|
|
52
|
-
)
|
|
53
|
-
}
|
|
54
|
-
val compositeKey = currentCompositeKeyHashCode
|
|
55
|
-
val handler = remember(dispatcher, compositeKey) { ComposeBackHandler(BackHandlerInfo(owner, compositeKey)) }
|
|
56
|
-
if (ActivityFlags.isOnBackPressedLifecycleOrderMaintained) {
|
|
57
|
-
SideEffect { handler.currentOnBackCompleted = onBack }
|
|
58
|
-
LifecycleStartEffect(enabled, handler) {
|
|
59
|
-
handler.isBackEnabled = enabled
|
|
60
|
-
onStopOrDispose { handler.isBackEnabled = false }
|
|
61
|
-
}
|
|
62
|
-
DisposableEffect(dispatcher, handler) {
|
|
63
|
-
dispatcher.addHandler(handler)
|
|
64
|
-
onDispose { dispatcher.removeHandler(handler) }
|
|
65
|
-
}
|
|
66
|
-
} else {
|
|
67
|
-
SideEffect {
|
|
68
|
-
handler.isBackEnabled = enabled
|
|
69
|
-
handler.currentOnBackCompleted = onBack
|
|
70
|
-
}
|
|
71
|
-
LifecycleStartEffect(dispatcher, handler) {
|
|
72
|
-
dispatcher.addHandler(handler)
|
|
73
|
-
onStopOrDispose { dispatcher.removeHandler(handler) }
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
private class ComposeBackHandler(info: BackHandlerInfo) : BackHandlerCompat(info) {
|
|
79
|
-
var currentOnBackCompleted: () -> Unit = {}
|
|
80
|
-
|
|
81
|
-
override fun onBackCompleted() {
|
|
82
|
-
currentOnBackCompleted()
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
private data class BackHandlerInfo(val owner: Any, val compositeKey: Long) : NavigationEventInfo()
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
package androidx.activity.compose
|
|
2
|
-
|
|
3
|
-
import android.view.ViewGroup
|
|
4
|
-
import androidx.activity.ComponentActivity
|
|
5
|
-
import androidx.compose.runtime.Composable
|
|
6
|
-
import androidx.compose.runtime.CompositionContext
|
|
7
|
-
import androidx.compose.ui.platform.ComposeView
|
|
8
|
-
|
|
9
|
-
private val DefaultActivityContentLayoutParams =
|
|
10
|
-
ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
|
11
|
-
|
|
12
|
-
// activity-compose's setContent: reuse the ComposeView already in the content
|
|
13
|
-
// parent, otherwise create one and set it as the content view. the activity
|
|
14
|
-
// itself supplies the view tree owners.
|
|
15
|
-
fun ComponentActivity.setContent(
|
|
16
|
-
parent: CompositionContext? = null,
|
|
17
|
-
content: @Composable () -> Unit,
|
|
18
|
-
) {
|
|
19
|
-
val existingComposeView =
|
|
20
|
-
(window.decorView as ViewGroup).getChildAt(0) as? ComposeView
|
|
21
|
-
if (existingComposeView != null) with(existingComposeView) {
|
|
22
|
-
setParentCompositionContext(parent)
|
|
23
|
-
setContent(content)
|
|
24
|
-
} else ComposeView(this).apply {
|
|
25
|
-
setParentCompositionContext(parent)
|
|
26
|
-
setContent(content)
|
|
27
|
-
setContentView(this, DefaultActivityContentLayoutParams)
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
package androidx.activity.compose.internal
|
|
2
|
-
|
|
3
|
-
import androidx.activity.BackEventCompat
|
|
4
|
-
import androidx.activity.OnBackPressedCallback
|
|
5
|
-
import androidx.navigationevent.NavigationEvent
|
|
6
|
-
import androidx.navigationevent.NavigationEventHandler
|
|
7
|
-
import androidx.navigationevent.NavigationEventInfo
|
|
8
|
-
|
|
9
|
-
// activity-compose 1.13.0's BackHandlerCompat: one back handler as both a
|
|
10
|
-
// navigation event handler and a back callback, for whichever dispatcher the
|
|
11
|
-
// composition provides
|
|
12
|
-
internal abstract class BackHandlerCompat(val info: NavigationEventInfo) {
|
|
13
|
-
open fun onBackStarted(event: BackEventCompat) {}
|
|
14
|
-
open fun onBackProgressed(event: BackEventCompat) {}
|
|
15
|
-
abstract fun onBackCompleted()
|
|
16
|
-
open fun onBackCancelled() {}
|
|
17
|
-
|
|
18
|
-
open var isBackEnabled: Boolean
|
|
19
|
-
get() = onBackPressedCallback.isEnabled && navigationEventHandler.isBackEnabled
|
|
20
|
-
set(value) {
|
|
21
|
-
onBackPressedCallback.isEnabled = value
|
|
22
|
-
navigationEventHandler.isBackEnabled = value
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
val onBackPressedCallback = object : OnBackPressedCallback(enabled = false) {
|
|
26
|
-
override fun handleOnBackStarted(backEvent: BackEventCompat) = this@BackHandlerCompat.onBackStarted(backEvent)
|
|
27
|
-
override fun handleOnBackProgressed(backEvent: BackEventCompat) = this@BackHandlerCompat.onBackProgressed(backEvent)
|
|
28
|
-
override fun handleOnBackPressed() = this@BackHandlerCompat.onBackCompleted()
|
|
29
|
-
override fun handleOnBackCancelled() = this@BackHandlerCompat.onBackCancelled()
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
val navigationEventHandler = object : NavigationEventHandler<NavigationEventInfo>(info, isBackEnabled = false) {
|
|
33
|
-
override fun onBackStarted(event: NavigationEvent) = this@BackHandlerCompat.onBackStarted(BackEventCompat(event))
|
|
34
|
-
override fun onBackProgressed(event: NavigationEvent) = this@BackHandlerCompat.onBackProgressed(BackEventCompat(event))
|
|
35
|
-
override fun onBackCompleted() = this@BackHandlerCompat.onBackCompleted()
|
|
36
|
-
override fun onBackCancelled() = this@BackHandlerCompat.onBackCancelled()
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
package androidx.activity.compose.internal
|
|
2
|
-
|
|
3
|
-
import androidx.activity.OnBackPressedDispatcher
|
|
4
|
-
import androidx.navigationevent.NavigationEventDispatcher
|
|
5
|
-
|
|
6
|
-
// activity-compose 1.13.0's BackHandlerDispatcherCompat: the navigation event
|
|
7
|
-
// dispatcher when there is one, else the back dispatcher
|
|
8
|
-
internal class BackHandlerDispatcherCompat(
|
|
9
|
-
private val navigationEventDispatcher: NavigationEventDispatcher?,
|
|
10
|
-
private val onBackPressedDispatcher: OnBackPressedDispatcher?,
|
|
11
|
-
) {
|
|
12
|
-
init {
|
|
13
|
-
requireNotNull(navigationEventDispatcher ?: onBackPressedDispatcher) {
|
|
14
|
-
"At least one dispatcher (NavigationEventDispatcher or OnBackPressedDispatcher) must be non-null."
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
fun addHandler(handler: BackHandlerCompat) {
|
|
19
|
-
if (navigationEventDispatcher != null) navigationEventDispatcher.addHandler(handler.navigationEventHandler)
|
|
20
|
-
else checkNotNull(onBackPressedDispatcher).addCallback(handler.onBackPressedCallback)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
fun removeHandler(handler: BackHandlerCompat) {
|
|
24
|
-
if (navigationEventDispatcher != null) handler.navigationEventHandler.remove()
|
|
25
|
-
else handler.onBackPressedCallback.remove()
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
package androidx.compose.foundation.layout
|
|
2
|
-
|
|
3
|
-
import androidx.compose.runtime.Composable
|
|
4
|
-
import androidx.compose.runtime.NonRestartableComposable
|
|
5
|
-
|
|
6
|
-
// android reports visibility from the content's insets after decor consumption
|
|
7
|
-
val WindowInsets.Companion.isImeVisible: Boolean
|
|
8
|
-
@Composable @NonRestartableComposable get() = dev.peach.app.peachImeVisible()
|
|
9
|
-
|
|
10
|
-
// bar visibility survives fitting decor consuming the content's inset sizes
|
|
11
|
-
val WindowInsets.Companion.areStatusBarsVisible: Boolean
|
|
12
|
-
@Composable @NonRestartableComposable get() = dev.peach.app.peachSystemBarVisible(1)
|
|
13
|
-
|
|
14
|
-
val WindowInsets.Companion.areNavigationBarsVisible: Boolean
|
|
15
|
-
@Composable @NonRestartableComposable get() = dev.peach.app.peachSystemBarVisible(2)
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
package androidx.compose.ui.platform
|
|
2
|
-
|
|
3
|
-
import android.content.Context
|
|
4
|
-
import android.content.res.Configuration
|
|
5
|
-
import android.content.res.Resources
|
|
6
|
-
import androidx.compose.runtime.compositionLocalOf
|
|
7
|
-
import androidx.compose.runtime.compositionLocalWithComputedDefaultOf
|
|
8
|
-
import androidx.compose.runtime.neverEqualPolicy
|
|
9
|
-
import androidx.compose.runtime.staticCompositionLocalOf
|
|
10
|
-
|
|
11
|
-
// AndroidCompositionLocals.android.kt: the configuration, context and
|
|
12
|
-
// resources a ComposeView's content reads, provided where its composition starts
|
|
13
|
-
val LocalConfiguration = compositionLocalOf<Configuration>(neverEqualPolicy()) {
|
|
14
|
-
noLocalProvidedFor("LocalConfiguration")
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
val LocalContext = staticCompositionLocalOf<Context> { noLocalProvidedFor("LocalContext") }
|
|
18
|
-
|
|
19
|
-
// the context's resources, recomputed when the configuration changes
|
|
20
|
-
val LocalResources = compositionLocalWithComputedDefaultOf<Resources> {
|
|
21
|
-
LocalConfiguration.currentValue
|
|
22
|
-
LocalContext.currentValue.resources
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
private fun noLocalProvidedFor(name: String): Nothing {
|
|
26
|
-
error("CompositionLocal $name not present")
|
|
27
|
-
}
|