peachsim 0.1.1655 → 0.1.1659
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/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 +11251 -1123
- 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 -5
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +8960 -134
- 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 +9769 -731
- 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 +10651 -1418
- package/dist-lib/swift-compile.cjs +8802 -138
- package/dist-lib/swift-compile.mjs +8802 -138
- 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 +8960 -134
- 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 +1 -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 +25 -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/swift-compile.ts +12 -3
- package/src/swift-host.ts +2 -1
- package/src/swift-objc-compile.ts +117 -4
- package/src/swift-objc-sdk.ts +8792 -135
- package/src/swift-objc-standin.ts +1 -0
- 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,68 +0,0 @@
|
|
|
1
|
-
package androidx.compose.ui.platform
|
|
2
|
-
|
|
3
|
-
import android.content.Context
|
|
4
|
-
import android.view.ViewGroup
|
|
5
|
-
import androidx.compose.runtime.Composable
|
|
6
|
-
import androidx.compose.runtime.CompositionContext
|
|
7
|
-
import androidx.compose.runtime.mutableStateOf
|
|
8
|
-
|
|
9
|
-
// AbstractComposeView and ComposeView as compose-ui's Android source has them:
|
|
10
|
-
// setContent stores a state-backed lambda, composition starts when the view
|
|
11
|
-
// attaches to a window, a later setContent replaces the lambda inside the same
|
|
12
|
-
// composition, and detaching disposes it (the default view composition
|
|
13
|
-
// strategy).
|
|
14
|
-
class ComposeView(context: Context) : ViewGroup(context) {
|
|
15
|
-
private val content = mutableStateOf<(@Composable () -> Unit)?>(null)
|
|
16
|
-
private var shouldCreateCompositionOnAttachedToWindow = false
|
|
17
|
-
private var parentContext: CompositionContext? = null
|
|
18
|
-
private var composition: AutoCloseable? = null
|
|
19
|
-
|
|
20
|
-
val hasComposition: Boolean get() = composition != null
|
|
21
|
-
|
|
22
|
-
@Composable
|
|
23
|
-
internal fun Content() {
|
|
24
|
-
content.value?.invoke()
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
fun setParentCompositionContext(parent: CompositionContext?) {
|
|
28
|
-
parentContext = parent
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
fun setContent(content: @Composable () -> Unit) {
|
|
32
|
-
shouldCreateCompositionOnAttachedToWindow = true
|
|
33
|
-
this.content.value = content
|
|
34
|
-
if (isAttachedToWindow) createComposition()
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
fun createComposition() {
|
|
38
|
-
check(parentContext != null || isAttachedToWindow) {
|
|
39
|
-
"createComposition requires a previous call to createComposition(ComposeViewContext)," +
|
|
40
|
-
" a parent reference, or the View to be attached to a window. Attach the View or " +
|
|
41
|
-
"call setParentCompositionReference."
|
|
42
|
-
}
|
|
43
|
-
ensureCompositionCreated()
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
fun disposeComposition() {
|
|
47
|
-
composition?.close()
|
|
48
|
-
composition = null
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
private fun ensureCompositionCreated() {
|
|
52
|
-
if (composition != null) return
|
|
53
|
-
check(parentContext == null) { "a ComposeView composing into a parent composition is not supported in Peach yet" }
|
|
54
|
-
val window = attachedWindow
|
|
55
|
-
check(window is android.view.Window) { "ComposeView is not attached to an activity window" }
|
|
56
|
-
composition = window.host.compose(this)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
override fun onAttachedToWindow() {
|
|
60
|
-
super.onAttachedToWindow()
|
|
61
|
-
if (shouldCreateCompositionOnAttachedToWindow) ensureCompositionCreated()
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
override fun onDetachedFromWindow() {
|
|
65
|
-
super.onDetachedFromWindow()
|
|
66
|
-
disposeComposition()
|
|
67
|
-
}
|
|
68
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
package androidx.compose.ui.res
|
|
2
|
-
|
|
3
|
-
import androidx.compose.runtime.Composable
|
|
4
|
-
import androidx.compose.runtime.ReadOnlyComposable
|
|
5
|
-
import androidx.compose.ui.graphics.Color
|
|
6
|
-
import androidx.compose.ui.platform.LocalContext
|
|
7
|
-
import androidx.compose.ui.platform.LocalResources
|
|
8
|
-
|
|
9
|
-
// ColorResources.android.kt: ResourcesCompat.getColor on API 23 and up is
|
|
10
|
-
// Resources.getColor with the context's theme
|
|
11
|
-
@Composable
|
|
12
|
-
@ReadOnlyComposable
|
|
13
|
-
fun colorResource(id: Int): Color {
|
|
14
|
-
val context = LocalContext.current
|
|
15
|
-
return Color(LocalResources.current.getColor(id, context.theme))
|
|
16
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
package androidx.compose.ui.res
|
|
2
|
-
|
|
3
|
-
import android.content.res.Resources
|
|
4
|
-
import androidx.compose.runtime.Composable
|
|
5
|
-
import androidx.compose.runtime.remember
|
|
6
|
-
import androidx.compose.ui.graphics.ImageBitmap
|
|
7
|
-
import androidx.compose.ui.graphics.painter.BitmapPainter
|
|
8
|
-
import androidx.compose.ui.graphics.painter.Painter
|
|
9
|
-
import androidx.compose.ui.graphics.vector.ImageVector
|
|
10
|
-
import androidx.compose.ui.graphics.vector.rememberVectorPainter
|
|
11
|
-
import androidx.compose.ui.platform.LocalConfiguration
|
|
12
|
-
import androidx.compose.ui.platform.LocalResources
|
|
13
|
-
import dev.peach.app.PeachDrawable
|
|
14
|
-
import dev.peach.app.peachAppDrawables
|
|
15
|
-
import dev.peach.app.peachDecodeBitmap
|
|
16
|
-
import dev.peach.app.peachDrawable
|
|
17
|
-
|
|
18
|
-
// PainterResources.android.kt, VectorResources.android.kt and
|
|
19
|
-
// ImageResources.android.kt: the drawable file the display's density selects,
|
|
20
|
-
// a vector built for the configuration and cached per configuration as the
|
|
21
|
-
// image vector cache is pruned on a configuration change, or a bitmap
|
|
22
|
-
|
|
23
|
-
@Composable
|
|
24
|
-
fun painterResource(id: Int): Painter {
|
|
25
|
-
val res = LocalResources.current
|
|
26
|
-
val configuration = LocalConfiguration.current
|
|
27
|
-
return when (val drawable = res.drawable(id)) {
|
|
28
|
-
is PeachDrawable.Vector ->
|
|
29
|
-
rememberVectorPainter(remember(id, configuration) { drawable.build(res.configuration.isNight()) })
|
|
30
|
-
is PeachDrawable.Xml -> throw IllegalArgumentException(
|
|
31
|
-
"Only VectorDrawables and rasterized asset types are supported ex. PNG, JPG, WEBP",
|
|
32
|
-
)
|
|
33
|
-
is PeachDrawable.Bitmap ->
|
|
34
|
-
BitmapPainter(remember(drawable.path, id) { peachDecodeBitmap(drawable, res.displayMetrics.densityDpi) })
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
@Composable
|
|
39
|
-
fun ImageVector.Companion.vectorResource(id: Int): ImageVector {
|
|
40
|
-
val res = LocalResources.current
|
|
41
|
-
return remember(id, res, res.configuration) { vectorResource(res, id) }
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
fun ImageVector.Companion.vectorResource(res: Resources, resId: Int): ImageVector =
|
|
45
|
-
when (val drawable = res.drawable(resId)) {
|
|
46
|
-
is PeachDrawable.Vector -> drawable.build(res.configuration.isNight())
|
|
47
|
-
// the parser reads another root tag's missing viewport
|
|
48
|
-
else -> throw IllegalArgumentException("${drawable.path}: <VectorGraphic> tag requires viewportWidth > 0")
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
@Composable
|
|
52
|
-
fun ImageBitmap.Companion.imageResource(id: Int): ImageBitmap {
|
|
53
|
-
val res = LocalResources.current
|
|
54
|
-
val drawable = res.drawable(id)
|
|
55
|
-
return remember(drawable.path) { imageResource(res, id) }
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// the drawable must be a BitmapDrawable
|
|
59
|
-
fun ImageBitmap.Companion.imageResource(res: Resources, id: Int): ImageBitmap =
|
|
60
|
-
when (val drawable = res.drawable(id)) {
|
|
61
|
-
is PeachDrawable.Bitmap -> peachDecodeBitmap(drawable, res.displayMetrics.densityDpi)
|
|
62
|
-
else -> throw ClassCastException("${drawable.path} is not a BitmapDrawable")
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
private fun Resources.drawable(id: Int): PeachDrawable =
|
|
66
|
-
peachDrawable(
|
|
67
|
-
peachAppDrawables[id]?.takeUnless { it.isEmpty() }
|
|
68
|
-
?: throw Resources.NotFoundException("Resource ID #0x${id.toString(16)}"),
|
|
69
|
-
displayMetrics.densityDpi,
|
|
70
|
-
)
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
package androidx.compose.ui.res
|
|
2
|
-
|
|
3
|
-
import androidx.compose.runtime.Composable
|
|
4
|
-
import androidx.compose.runtime.ReadOnlyComposable
|
|
5
|
-
import androidx.compose.ui.platform.LocalResources
|
|
6
|
-
|
|
7
|
-
// StringResources.android.kt: string, string array and plural resources read
|
|
8
|
-
// through the composition's resources
|
|
9
|
-
|
|
10
|
-
@Composable
|
|
11
|
-
@ReadOnlyComposable
|
|
12
|
-
fun stringResource(id: Int): String {
|
|
13
|
-
return LocalResources.current.getString(id)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
@Composable
|
|
17
|
-
@ReadOnlyComposable
|
|
18
|
-
fun stringResource(id: Int, vararg formatArgs: Any): String {
|
|
19
|
-
return LocalResources.current.getString(id, *formatArgs)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
@Composable
|
|
23
|
-
@ReadOnlyComposable
|
|
24
|
-
fun stringArrayResource(id: Int): Array<String> {
|
|
25
|
-
return LocalResources.current.getStringArray(id)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
@Composable
|
|
29
|
-
@ReadOnlyComposable
|
|
30
|
-
fun pluralStringResource(id: Int, count: Int): String {
|
|
31
|
-
return LocalResources.current.getQuantityString(id, count)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
@Composable
|
|
35
|
-
@ReadOnlyComposable
|
|
36
|
-
fun pluralStringResource(id: Int, count: Int, vararg formatArgs: Any): String {
|
|
37
|
-
return LocalResources.current.getQuantityString(id, count, *formatArgs)
|
|
38
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
package androidx.core.view
|
|
2
|
-
|
|
3
|
-
import android.view.View
|
|
4
|
-
import android.view.Window
|
|
5
|
-
import android.view.WindowInsetsController
|
|
6
|
-
|
|
7
|
-
// androidx.core's window helpers as they run from API 30, on the platform
|
|
8
|
-
// window and its insets controller
|
|
9
|
-
object WindowCompat {
|
|
10
|
-
fun setDecorFitsSystemWindows(window: Window, decorFitsSystemWindows: Boolean) {
|
|
11
|
-
window.setDecorFitsSystemWindows(decorFitsSystemWindows)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
fun getInsetsController(window: Window, view: View): WindowInsetsControllerCompat =
|
|
15
|
-
WindowInsetsControllerCompat(window, view)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
class WindowInsetsControllerCompat(window: Window, @Suppress("UNUSED_PARAMETER") view: View) {
|
|
19
|
-
private val controller = window.insetsController
|
|
20
|
-
|
|
21
|
-
private fun appearance(flag: Int) = controller.systemBarsAppearance and flag != 0
|
|
22
|
-
private fun setAppearance(flag: Int, light: Boolean) =
|
|
23
|
-
controller.setSystemBarsAppearance(if (light) flag else 0, flag)
|
|
24
|
-
|
|
25
|
-
var isAppearanceLightStatusBars: Boolean
|
|
26
|
-
get() = appearance(WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS)
|
|
27
|
-
set(light) = setAppearance(WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS, light)
|
|
28
|
-
|
|
29
|
-
var isAppearanceLightNavigationBars: Boolean
|
|
30
|
-
get() = appearance(WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS)
|
|
31
|
-
set(light) = setAppearance(WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS, light)
|
|
32
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
package androidx.lifecycle
|
|
2
|
-
|
|
3
|
-
import android.app.Application
|
|
4
|
-
|
|
5
|
-
// androidx.lifecycle's AndroidViewModel: a view model that holds its
|
|
6
|
-
// application, which the default factory passes to its constructor
|
|
7
|
-
open class AndroidViewModel(private val application: Application) : ViewModel() {
|
|
8
|
-
@Suppress("UNCHECKED_CAST")
|
|
9
|
-
open fun <T : Application> getApplication(): T = application as T
|
|
10
|
-
}
|
|
@@ -1,388 +0,0 @@
|
|
|
1
|
-
@file:OptIn(androidx.compose.ui.InternalComposeUiApi::class)
|
|
2
|
-
|
|
3
|
-
package dev.peach.app
|
|
4
|
-
|
|
5
|
-
import android.os.Bundle
|
|
6
|
-
|
|
7
|
-
import android.app.Activity
|
|
8
|
-
import android.app.Application
|
|
9
|
-
import android.content.ComponentName
|
|
10
|
-
import android.content.Intent
|
|
11
|
-
import android.content.res.Configuration
|
|
12
|
-
import android.content.res.Resources
|
|
13
|
-
import android.content.res.processResources
|
|
14
|
-
import android.view.ViewGroup
|
|
15
|
-
import android.view.Window
|
|
16
|
-
import android.view.WindowTheme
|
|
17
|
-
import androidx.activity.ComponentActivity
|
|
18
|
-
import androidx.lifecycle.ViewModelProvider
|
|
19
|
-
import androidx.activity.compose.LocalOnBackPressedDispatcherOwner
|
|
20
|
-
import androidx.compose.runtime.Composable
|
|
21
|
-
import androidx.compose.runtime.CompositionLocalProvider
|
|
22
|
-
import androidx.compose.ui.platform.ComposeView
|
|
23
|
-
import androidx.compose.ui.platform.LocalConfiguration
|
|
24
|
-
import androidx.compose.ui.platform.LocalContext
|
|
25
|
-
import androidx.compose.ui.platform.PlatformArchitectureComponentsOwner
|
|
26
|
-
import androidx.compose.runtime.getValue
|
|
27
|
-
import androidx.compose.runtime.key
|
|
28
|
-
import androidx.compose.runtime.mutableIntStateOf
|
|
29
|
-
import androidx.compose.runtime.mutableStateOf
|
|
30
|
-
import androidx.compose.runtime.neverEqualPolicy
|
|
31
|
-
import androidx.compose.runtime.setValue
|
|
32
|
-
import androidx.compose.ui.text.font.FontFamily
|
|
33
|
-
import androidx.lifecycle.Lifecycle
|
|
34
|
-
import PeachComposeMount
|
|
35
|
-
import PeachWindowInsets
|
|
36
|
-
import readPeachWindowInsets
|
|
37
|
-
import addMount
|
|
38
|
-
import mounts
|
|
39
|
-
import preparePeachDevice
|
|
40
|
-
import robotoFamily
|
|
41
|
-
import org.json.JSONObject
|
|
42
|
-
import android.util.DisplayMetrics
|
|
43
|
-
import kotlin.math.roundToInt
|
|
44
|
-
|
|
45
|
-
// what the manifest, Gradle files and theme resolved: the launcher component
|
|
46
|
-
// the intent names (an alias stays the alias), the activity class it runs, what
|
|
47
|
-
// its window read from the theme, and constructors for the manifest's
|
|
48
|
-
// Application and that class (wasm has no reflection).
|
|
49
|
-
internal class PeachAppSpec(
|
|
50
|
-
val launcher: ComponentName,
|
|
51
|
-
val component: ComponentName,
|
|
52
|
-
// the launcher activity's window theme in a day and a night configuration,
|
|
53
|
-
// values-night over values
|
|
54
|
-
val dayWindow: WindowTheme,
|
|
55
|
-
val nightWindow: WindowTheme,
|
|
56
|
-
val createApplication: () -> Application,
|
|
57
|
-
val createActivity: () -> Activity,
|
|
58
|
-
// the activity's configChanges includes uiMode: it takes a night mode
|
|
59
|
-
// change in onConfigurationChanged rather than relaunching
|
|
60
|
-
val handlesUiMode: Boolean,
|
|
61
|
-
// how the activity's window meets the keyboard, pan, resize or nothing:
|
|
62
|
-
// adjustPan and an unspecified adjust on a compose window pan
|
|
63
|
-
val softInputAdjust: String,
|
|
64
|
-
// the app's view models, each built with the constructor the device's
|
|
65
|
-
// default factory finds for it
|
|
66
|
-
val viewModels: ViewModelProvider.Factory,
|
|
67
|
-
val predictiveBack: Boolean,
|
|
68
|
-
)
|
|
69
|
-
|
|
70
|
-
internal fun viewModelFactory(): ViewModelProvider.Factory = runningApp().spec.viewModels
|
|
71
|
-
|
|
72
|
-
internal fun peachApplication(): Application = runningApp().application
|
|
73
|
-
|
|
74
|
-
private class ActivityOwners(activity: ComponentActivity) : PlatformArchitectureComponentsOwner {
|
|
75
|
-
override val lifecycleOwner = activity
|
|
76
|
-
override val viewModelStoreOwner = activity
|
|
77
|
-
override val savedStateRegistryOwner = activity
|
|
78
|
-
override val navigationEventDispatcherOwner = activity
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// the device and the application one started app process keeps, and what
|
|
82
|
-
// ActivityThread's record holds for its one activity: whether it is paused or
|
|
83
|
-
// stopped, and the state it saved when it stopped, until it resumes
|
|
84
|
-
private class AppProcess(
|
|
85
|
-
val spec: PeachAppSpec,
|
|
86
|
-
val application: Application,
|
|
87
|
-
val density: Float, val fontScale: Float, val locale: String,
|
|
88
|
-
val fonts: FontFamily,
|
|
89
|
-
insets: String,
|
|
90
|
-
val invalidate: (Boolean) -> Unit,
|
|
91
|
-
) {
|
|
92
|
-
var insets by mutableStateOf(readPeachWindowInsets(insets))
|
|
93
|
-
var visibleSystemBars by mutableStateOf(3)
|
|
94
|
-
lateinit var activity: Activity
|
|
95
|
-
lateinit var mount: PeachComposeMount
|
|
96
|
-
// the window the device presents, once its scene is in place
|
|
97
|
-
var window: Window? = null
|
|
98
|
-
var mountId = 0
|
|
99
|
-
// the held view's place among its window's views; a relaunched window's
|
|
100
|
-
// first view takes the place the last window's view held, as it takes
|
|
101
|
-
// that view's saved state on the device
|
|
102
|
-
var view = 0
|
|
103
|
-
var paused = false
|
|
104
|
-
var stopped = false
|
|
105
|
-
var state: Bundle? = null
|
|
106
|
-
// the night mode last reported to the activity: ActivityRecord compares
|
|
107
|
-
// the configuration with it before a relaunch or onConfigurationChanged
|
|
108
|
-
var reportedNight = false
|
|
109
|
-
// the software keyboard's height above the screen's bottom edge, in pixels
|
|
110
|
-
var ime by mutableIntStateOf(0)
|
|
111
|
-
var imeVisible by mutableStateOf(false)
|
|
112
|
-
// the configuration the content view composes with: a copy the view's
|
|
113
|
-
// configuration change replaces, as AndroidComposeView's observer does
|
|
114
|
-
val configuration = mutableStateOf(Configuration(), neverEqualPolicy())
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
private var process: AppProcess? = null
|
|
118
|
-
|
|
119
|
-
private fun deviceConfiguration(night: Boolean, locale: String) = Configuration().apply {
|
|
120
|
-
uiMode = Configuration.UI_MODE_TYPE_NORMAL or
|
|
121
|
-
if (night) Configuration.UI_MODE_NIGHT_YES else Configuration.UI_MODE_NIGHT_NO
|
|
122
|
-
localeTag = locale
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// a cold start in ActivityThread's order: the Application and its onCreate,
|
|
126
|
-
// then the launcher activity attached to its window and launcher intent,
|
|
127
|
-
// onCreate, onStart, onPostCreate, onResume and onPostResume, and only then the
|
|
128
|
-
// window added, which attaches the content view and composes it.
|
|
129
|
-
internal fun peachStartApp(
|
|
130
|
-
spec: PeachAppSpec,
|
|
131
|
-
density: Float, fontScale: Float, locale: String,
|
|
132
|
-
font: String,
|
|
133
|
-
insets: String, night: Boolean,
|
|
134
|
-
invalidate: (Boolean) -> Unit,
|
|
135
|
-
): String {
|
|
136
|
-
try {
|
|
137
|
-
preparePeachDevice(locale)
|
|
138
|
-
val metrics = DisplayMetrics()
|
|
139
|
-
metrics.densityDpi = (density * DisplayMetrics.DENSITY_DEFAULT).roundToInt()
|
|
140
|
-
metrics.density = metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT.toFloat()
|
|
141
|
-
processResources = Resources(deviceConfiguration(night, locale), metrics, peachAppStrings, peachAppPlurals, peachAppArrays, peachAppColors)
|
|
142
|
-
val application = spec.createApplication()
|
|
143
|
-
application.onCreate()
|
|
144
|
-
val app = AppProcess(
|
|
145
|
-
spec, application, density, fontScale, locale,
|
|
146
|
-
robotoFamily(font), insets, invalidate,
|
|
147
|
-
)
|
|
148
|
-
process = app
|
|
149
|
-
val view = launchActivity(app, null)
|
|
150
|
-
val params = view.layoutParams
|
|
151
|
-
return app.activity.window.describe().put("dialogs", app.mount.dialogState()).put("ok", true).put("id", app.mountId)
|
|
152
|
-
.put("wrapWidth", params?.width == ViewGroup.LayoutParams.WRAP_CONTENT)
|
|
153
|
-
.put("wrapHeight", params?.height == ViewGroup.LayoutParams.WRAP_CONTENT)
|
|
154
|
-
.put("softInputAdjust", spec.softInputAdjust)
|
|
155
|
-
.toString()
|
|
156
|
-
} catch (error: Throwable) {
|
|
157
|
-
return JSONObject().put("ok", false).put("code", "E_KOTLIN_APP")
|
|
158
|
-
.put("error", "${error::class.simpleName}: ${error.message}").toString()
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// ActivityThread's handleLaunchActivity: a new instance of the launcher
|
|
163
|
-
// activity created from the state its last instance saved, if any, with what
|
|
164
|
-
// that instance retained, then started, restored, resumed and its window
|
|
165
|
-
// added. the window's scene takes the process's mount id, so the device keeps
|
|
166
|
-
// presenting it.
|
|
167
|
-
private fun launchActivity(app: AppProcess, lastNonConfigurationInstance: Any?): ComposeView {
|
|
168
|
-
val spec = app.spec
|
|
169
|
-
val activity = spec.createActivity()
|
|
170
|
-
val componentActivity = activity as? ComponentActivity
|
|
171
|
-
val state = app.state
|
|
172
|
-
lateinit var window: Window
|
|
173
|
-
lateinit var mount: PeachComposeMount
|
|
174
|
-
// the window's one scene composes the ComposeView it holds; a new
|
|
175
|
-
// view starts a new composition, as on the device. the key is the view's
|
|
176
|
-
// place, not the view, so a relaunched window's view lands on the keys its
|
|
177
|
-
// saved state was written under
|
|
178
|
-
var held by mutableStateOf<ComposeView?>(null)
|
|
179
|
-
var place by mutableIntStateOf((app.view - 1).coerceAtLeast(0))
|
|
180
|
-
val host = object : PeachWindowHost {
|
|
181
|
-
override fun compose(view: ComposeView): AutoCloseable {
|
|
182
|
-
held = view
|
|
183
|
-
place += 1
|
|
184
|
-
app.view = place
|
|
185
|
-
return AutoCloseable { if (held === view) held = null }
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// a change before the window is presented reaches the device with
|
|
189
|
-
// the window itself
|
|
190
|
-
override fun windowChanged() {
|
|
191
|
-
if (app.window === window)
|
|
192
|
-
mount.emitAtFrame("window") { window.describe().put("dialogs", mount.dialogState()).toString() }
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
// the theme the activity is created under: a relaunch after a night
|
|
196
|
-
// change takes the other one
|
|
197
|
-
val theme = if (processResources.configuration.isNight()) spec.nightWindow else spec.dayWindow
|
|
198
|
-
window = Window(activity, theme, host, spec.predictiveBack)
|
|
199
|
-
activity.attach(
|
|
200
|
-
app.application,
|
|
201
|
-
spec.component,
|
|
202
|
-
Intent(Intent.ACTION_MAIN, setOf(Intent.CATEGORY_LAUNCHER), spec.launcher),
|
|
203
|
-
window,
|
|
204
|
-
lastNonConfigurationInstance,
|
|
205
|
-
)
|
|
206
|
-
if (spec.predictiveBack) componentActivity?.onBackPressedDispatcher?.setOnBackInvokedDispatcher(window.onBackInvokedDispatcher)
|
|
207
|
-
activity.performCreate(state)
|
|
208
|
-
activity.performStart()
|
|
209
|
-
if (state != null) activity.performRestoreInstanceState(state)
|
|
210
|
-
activity.performPostCreate(state)
|
|
211
|
-
activity.performResume()
|
|
212
|
-
app.activity = activity
|
|
213
|
-
app.paused = false
|
|
214
|
-
app.stopped = false
|
|
215
|
-
app.state = null
|
|
216
|
-
app.reportedNight = activity.resources.configuration.isNight()
|
|
217
|
-
mount = PeachComposeMount(
|
|
218
|
-
app.density, app.fontScale, app.locale, app.fonts, app.invalidate,
|
|
219
|
-
night = activity.resources.configuration.isNight(),
|
|
220
|
-
owners = componentActivity?.let(::ActivityOwners),
|
|
221
|
-
insets = PeachWindowInsets({ app.insets }, { app.ime }, { window.fitsSystemWindows }),
|
|
222
|
-
clockRunning = { componentActivity == null || componentActivity.lifecycle.currentState.isAtLeast(Lifecycle.State.STARTED) },
|
|
223
|
-
)
|
|
224
|
-
app.configuration.value = Configuration().apply { setTo(activity.resources.configuration) }
|
|
225
|
-
mount.setContent {
|
|
226
|
-
val content = @Composable { held?.let { view -> key(place) { view.Content() } }; Unit }
|
|
227
|
-
// the content view's context is the activity, its configuration the
|
|
228
|
-
// copy above, and its tree resolves the activity as its back
|
|
229
|
-
// dispatcher owner
|
|
230
|
-
CompositionLocalProvider(
|
|
231
|
-
LocalContext provides activity,
|
|
232
|
-
LocalConfiguration provides app.configuration.value,
|
|
233
|
-
) {
|
|
234
|
-
if (componentActivity != null)
|
|
235
|
-
CompositionLocalProvider(LocalOnBackPressedDispatcherOwner provides componentActivity, content = content)
|
|
236
|
-
else content()
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
if (app.mountId == 0) app.mountId = addMount(mount)
|
|
240
|
-
else {
|
|
241
|
-
// the relaunched window takes the device's bounds and reports its
|
|
242
|
-
// window, which the new instance may have set differently
|
|
243
|
-
mount.constraints = app.mount.constraints
|
|
244
|
-
mounts[app.mountId] = mount
|
|
245
|
-
mount.emitAtFrame("window") { window.describe().put("dialogs", mount.dialogState()).toString() }
|
|
246
|
-
app.invalidate(true)
|
|
247
|
-
}
|
|
248
|
-
app.mount = mount
|
|
249
|
-
app.window = window
|
|
250
|
-
window.addToWindowManager()
|
|
251
|
-
return checkNotNull(held) {
|
|
252
|
-
"${spec.component.flattenToShortString()} set no ComposeView as its content; Peach composes only ComposeView content"
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
private fun runningApp() = checkNotNull(process) { "the app is not running" }
|
|
257
|
-
|
|
258
|
-
// the device's back: an activity with predictive back gets it through its
|
|
259
|
-
// window's back dispatch, where ComponentActivity's dispatcher takes it only
|
|
260
|
-
// while a callback is enabled and the activity's own default handles the
|
|
261
|
-
// rest; without predictive back the key reaches onBackPressed. false when the
|
|
262
|
-
// task moved to the back, which the device then shows as home.
|
|
263
|
-
internal fun peachAppBack(predictive: Boolean): Boolean {
|
|
264
|
-
val activity = runningApp().activity
|
|
265
|
-
activity.movedTaskToBack = false
|
|
266
|
-
if (runningApp().mount.dialogBack()) return true
|
|
267
|
-
if (!predictive) activity.onBackPressed()
|
|
268
|
-
else if (activity.window.invokeBack()) Unit
|
|
269
|
-
else activity.movedTaskToBack = true
|
|
270
|
-
return !activity.movedTaskToBack
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
internal fun peachAppBackPhase(
|
|
274
|
-
generation: Int, receiver: Int, registration: Int, phase: String,
|
|
275
|
-
touchX: Float, touchY: Float, progress: Float, edge: Int, frameTimeMillis: Double,
|
|
276
|
-
) {
|
|
277
|
-
val app = process ?: return
|
|
278
|
-
val window = app.window ?: return
|
|
279
|
-
if (!app.spec.predictiveBack || window.backGeneration != generation) return
|
|
280
|
-
val event = android.window.BackEvent(touchX, touchY, progress, edge, frameTimeMillis.toLong())
|
|
281
|
-
if (receiver == 0) window.backPhase(phase, registration, event)
|
|
282
|
-
else app.mount.dialogBackPhase(receiver, phase, registration, event)
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
// ActivityThread's pause and stop; from API 28 an activity that stops saves
|
|
286
|
-
// its state after onStop, kept for a relaunch until it resumes
|
|
287
|
-
private fun pauseAndStop(app: AppProcess) {
|
|
288
|
-
app.window?.cancelBackGesture()
|
|
289
|
-
app.mount.cancelDialogBackGestures()
|
|
290
|
-
if (!app.paused) {
|
|
291
|
-
app.activity.performPause()
|
|
292
|
-
app.paused = true
|
|
293
|
-
}
|
|
294
|
-
if (!app.stopped) {
|
|
295
|
-
app.activity.performStop()
|
|
296
|
-
app.stopped = true
|
|
297
|
-
app.state = Bundle().also(app.activity::performSaveInstanceState)
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
// the task left the foreground (onPause, onStop, onSaveInstanceState) or came
|
|
302
|
-
// back to it (onRestart, onStart, onResume, onPostResume). a configuration
|
|
303
|
-
// that changed while it was stopped reaches it first: a relaunch in place of
|
|
304
|
-
// the restart, or onConfigurationChanged.
|
|
305
|
-
internal fun peachAppTask(foreground: Boolean) {
|
|
306
|
-
val app = runningApp()
|
|
307
|
-
if (!foreground) return pauseAndStop(app)
|
|
308
|
-
if (reportConfiguration(app)) return
|
|
309
|
-
app.activity.performRestart()
|
|
310
|
-
app.activity.performResume()
|
|
311
|
-
app.paused = false
|
|
312
|
-
app.stopped = false
|
|
313
|
-
app.state = null
|
|
314
|
-
// the frame clock runs again once the activity is started
|
|
315
|
-
app.mount.invalidate(false)
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
// gives a visible activity the process configuration when it differs from the
|
|
319
|
-
// one last reported to it: a relaunch, or onConfigurationChanged under
|
|
320
|
-
// configChanges uiMode. true when it relaunched.
|
|
321
|
-
private fun reportConfiguration(app: AppProcess): Boolean {
|
|
322
|
-
val configuration = processResources.configuration
|
|
323
|
-
if (configuration.isNight() == app.reportedNight) return false
|
|
324
|
-
if (!app.spec.handlesUiMode) {
|
|
325
|
-
relaunch(app)
|
|
326
|
-
return true
|
|
327
|
-
}
|
|
328
|
-
app.reportedNight = configuration.isNight()
|
|
329
|
-
app.activity.performConfigurationChanged(Configuration().apply { setTo(configuration) })
|
|
330
|
-
app.configuration.value = Configuration().apply { setTo(configuration) }
|
|
331
|
-
app.mount.night = app.reportedNight
|
|
332
|
-
return false
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
internal fun peachImeVisible(): Boolean {
|
|
336
|
-
val app = runningApp()
|
|
337
|
-
return !app.activity.window.fitsSystemWindows && app.imeVisible
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
internal fun peachSystemBarVisible(type: Int): Boolean = runningApp().visibleSystemBars and type != 0
|
|
341
|
-
|
|
342
|
-
internal fun peachAppInsets(insets: String, visibleSystemBars: Int) {
|
|
343
|
-
require(visibleSystemBars in 0..3) { "unsupported visible system bar types: $visibleSystemBars" }
|
|
344
|
-
val app = runningApp()
|
|
345
|
-
val next = readPeachWindowInsets(insets)
|
|
346
|
-
if (next == app.insets && visibleSystemBars == app.visibleSystemBars) return
|
|
347
|
-
app.insets = next
|
|
348
|
-
app.visibleSystemBars = visibleSystemBars
|
|
349
|
-
app.invalidate(true)
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
// keep visibility independent of height, then apply the content window's decor
|
|
353
|
-
internal fun peachAppIme(bottom: Int, visible: Boolean) {
|
|
354
|
-
val app = runningApp()
|
|
355
|
-
if (app.ime == bottom && app.imeVisible == visible) return
|
|
356
|
-
app.ime = bottom
|
|
357
|
-
app.imeVisible = visible
|
|
358
|
-
app.invalidate(true)
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
// the device's night mode changed. the process's configuration changes in
|
|
362
|
-
// place and the Application hears it first; a visible activity then takes it.
|
|
363
|
-
// a stopped activity takes it once visible again, if it still differs.
|
|
364
|
-
internal fun peachAppNight(night: Boolean) {
|
|
365
|
-
val app = runningApp()
|
|
366
|
-
val configuration = processResources.configuration
|
|
367
|
-
if (configuration.isNight() == night) return
|
|
368
|
-
configuration.setTo(deviceConfiguration(night, app.locale))
|
|
369
|
-
app.application.onConfigurationChanged(Configuration().apply { setTo(configuration) })
|
|
370
|
-
if (!app.stopped) reportConfiguration(app)
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
// ActivityThread's handleRelaunchActivityInner: pause and stop with the state
|
|
374
|
-
// saved, collect what the next instance keeps, destroy, then launch anew
|
|
375
|
-
private fun relaunch(app: AppProcess) {
|
|
376
|
-
val old = app.activity
|
|
377
|
-
val oldMount = app.mount
|
|
378
|
-
old.isChangingConfigurations = true
|
|
379
|
-
pauseAndStop(app)
|
|
380
|
-
val retained = old.retainNonConfigurationInstances()
|
|
381
|
-
old.performDestroy()
|
|
382
|
-
old.window.removeFromWindowManager()
|
|
383
|
-
try {
|
|
384
|
-
launchActivity(app, retained)
|
|
385
|
-
} finally {
|
|
386
|
-
oldMount.close()
|
|
387
|
-
}
|
|
388
|
-
}
|