diff --git a/enro-core/src/main/java/dev/enro/destination/activity/ActivityResultDestination.kt b/enro-core/src/main/java/dev/enro/android/ActivityResultDestination.kt similarity index 98% rename from enro-core/src/main/java/dev/enro/destination/activity/ActivityResultDestination.kt rename to enro-core/src/main/java/dev/enro/android/ActivityResultDestination.kt index c3f25444..86cf36db 100644 --- a/enro-core/src/main/java/dev/enro/destination/activity/ActivityResultDestination.kt +++ b/enro-core/src/main/java/dev/enro/android/ActivityResultDestination.kt @@ -1,4 +1,4 @@ -package dev.enro.destination.activity +package dev.enro.android import android.content.Context import android.content.Intent @@ -13,7 +13,6 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.saveable.rememberSaveable -import dev.enro.android.activity import dev.enro.core.* import dev.enro.destination.compose.OverrideNavigationAnimations import dev.enro.destination.compose.navigationHandle diff --git a/enro-core/src/main/java/dev/enro/core/controller/NavigationApplication.kt b/enro-core/src/main/java/dev/enro/android/NavigationApplication.kt similarity index 56% rename from enro-core/src/main/java/dev/enro/core/controller/NavigationApplication.kt rename to enro-core/src/main/java/dev/enro/android/NavigationApplication.kt index 5da61b61..3fbbcd23 100644 --- a/enro-core/src/main/java/dev/enro/core/controller/NavigationApplication.kt +++ b/enro-core/src/main/java/dev/enro/android/NavigationApplication.kt @@ -1,4 +1,6 @@ -package dev.enro.core.controller +package dev.enro.android + +import dev.enro.core.controller.NavigationController public interface NavigationApplication { public val navigationController: NavigationController diff --git a/enro-core/src/main/java/dev/enro/hilt/NavigationContext.kt b/enro-core/src/main/java/dev/enro/android/hilt/NavigationContext.kt similarity index 96% rename from enro-core/src/main/java/dev/enro/hilt/NavigationContext.kt rename to enro-core/src/main/java/dev/enro/android/hilt/NavigationContext.kt index f5f7ef05..a80ebcdb 100644 --- a/enro-core/src/main/java/dev/enro/hilt/NavigationContext.kt +++ b/enro-core/src/main/java/dev/enro/android/hilt/NavigationContext.kt @@ -1,4 +1,4 @@ -package dev.enro.hilt +package dev.enro.android.hilt import dagger.hilt.internal.GeneratedComponentManager import dagger.hilt.internal.GeneratedComponentManagerHolder diff --git a/enro-core/src/main/java/dev/enro/viewmodel/EnroViewModelExtensions.kt b/enro-core/src/main/java/dev/enro/android/viewmodel/EnroViewModelExtensions.kt similarity index 99% rename from enro-core/src/main/java/dev/enro/viewmodel/EnroViewModelExtensions.kt rename to enro-core/src/main/java/dev/enro/android/viewmodel/EnroViewModelExtensions.kt index 58b54da1..70a9d0f5 100644 --- a/enro-core/src/main/java/dev/enro/viewmodel/EnroViewModelExtensions.kt +++ b/enro-core/src/main/java/dev/enro/android/viewmodel/EnroViewModelExtensions.kt @@ -1,4 +1,4 @@ -package dev.enro.viewmodel +package dev.enro.android.viewmodel import androidx.activity.ComponentActivity import androidx.annotation.MainThread diff --git a/enro-core/src/main/java/dev/enro/viewmodel/EnroViewModelFactory.kt b/enro-core/src/main/java/dev/enro/android/viewmodel/EnroViewModelFactory.kt similarity index 97% rename from enro-core/src/main/java/dev/enro/viewmodel/EnroViewModelFactory.kt rename to enro-core/src/main/java/dev/enro/android/viewmodel/EnroViewModelFactory.kt index c8a51618..279d9641 100644 --- a/enro-core/src/main/java/dev/enro/viewmodel/EnroViewModelFactory.kt +++ b/enro-core/src/main/java/dev/enro/android/viewmodel/EnroViewModelFactory.kt @@ -1,4 +1,4 @@ -package dev.enro.viewmodel +package dev.enro.android.viewmodel import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModelProvider diff --git a/enro-core/src/main/java/dev/enro/viewmodel/EnroViewModelFactoryExtensions.kt b/enro-core/src/main/java/dev/enro/android/viewmodel/EnroViewModelFactoryExtensions.kt similarity index 96% rename from enro-core/src/main/java/dev/enro/viewmodel/EnroViewModelFactoryExtensions.kt rename to enro-core/src/main/java/dev/enro/android/viewmodel/EnroViewModelFactoryExtensions.kt index b59c087c..d39e85b3 100644 --- a/enro-core/src/main/java/dev/enro/viewmodel/EnroViewModelFactoryExtensions.kt +++ b/enro-core/src/main/java/dev/enro/android/viewmodel/EnroViewModelFactoryExtensions.kt @@ -1,4 +1,4 @@ -package dev.enro.viewmodel +package dev.enro.android.viewmodel import androidx.compose.runtime.Composable import androidx.compose.runtime.remember diff --git a/enro-core/src/main/java/dev/enro/viewmodel/EnroViewModelNavigationHandleProvider.kt b/enro-core/src/main/java/dev/enro/android/viewmodel/EnroViewModelNavigationHandleProvider.kt similarity index 96% rename from enro-core/src/main/java/dev/enro/viewmodel/EnroViewModelNavigationHandleProvider.kt rename to enro-core/src/main/java/dev/enro/android/viewmodel/EnroViewModelNavigationHandleProvider.kt index 3459e9bb..b4c76f70 100644 --- a/enro-core/src/main/java/dev/enro/viewmodel/EnroViewModelNavigationHandleProvider.kt +++ b/enro-core/src/main/java/dev/enro/android/viewmodel/EnroViewModelNavigationHandleProvider.kt @@ -1,4 +1,4 @@ -package dev.enro.viewmodel +package dev.enro.android.viewmodel import androidx.annotation.Keep import dev.enro.core.EnroException diff --git a/enro-core/src/main/java/dev/enro/core/controller/usecase/GetNavigationAnimations.kt b/enro-core/src/main/java/dev/enro/animation/internal/GetNavigationAnimations.kt similarity index 98% rename from enro-core/src/main/java/dev/enro/core/controller/usecase/GetNavigationAnimations.kt rename to enro-core/src/main/java/dev/enro/animation/internal/GetNavigationAnimations.kt index 7258cf5d..66385b61 100644 --- a/enro-core/src/main/java/dev/enro/core/controller/usecase/GetNavigationAnimations.kt +++ b/enro-core/src/main/java/dev/enro/animation/internal/GetNavigationAnimations.kt @@ -1,4 +1,4 @@ -package dev.enro.core.controller.usecase +package dev.enro.animation.internal import android.provider.Settings import dev.enro.animation.ClosingTransition diff --git a/enro-core/src/main/java/dev/enro/core/controller/repository/NavigationAnimationRepository.kt b/enro-core/src/main/java/dev/enro/animation/internal/NavigationAnimationRepository.kt similarity index 95% rename from enro-core/src/main/java/dev/enro/core/controller/repository/NavigationAnimationRepository.kt rename to enro-core/src/main/java/dev/enro/animation/internal/NavigationAnimationRepository.kt index 4f1f9176..b881d228 100644 --- a/enro-core/src/main/java/dev/enro/core/controller/repository/NavigationAnimationRepository.kt +++ b/enro-core/src/main/java/dev/enro/animation/internal/NavigationAnimationRepository.kt @@ -1,4 +1,4 @@ -package dev.enro.core.controller.repository +package dev.enro.animation.internal import dev.enro.animation.ClosingTransition import dev.enro.animation.NavigationAnimationOverride diff --git a/enro-core/src/main/java/dev/enro/core/NavigationExecutor.kt b/enro-core/src/main/java/dev/enro/core/NavigationExecutor.kt index 50999d03..44ad1c86 100644 --- a/enro-core/src/main/java/dev/enro/core/NavigationExecutor.kt +++ b/enro-core/src/main/java/dev/enro/core/NavigationExecutor.kt @@ -65,7 +65,7 @@ public class NavigationExecutorBuilder) { when (args.binding) { is ActivityNavigationBinding -> - DefaultContainerExecutor::open as ((ExecutorArgs) -> Unit) + DefaultContainerExecutor::open is FragmentNavigationBinding -> DefaultContainerExecutor::open @@ -83,7 +83,7 @@ public class NavigationExecutorBuilder) { when (context.contextReference) { - is Activity -> DefaultContainerExecutor::close as (NavigationContext) -> Unit + is Activity -> DefaultContainerExecutor::close is Fragment -> DefaultContainerExecutor::close is ComposableDestination -> DefaultContainerExecutor::close else -> throw IllegalArgumentException("No default close executor found for context ${context.contextReference::class.java.simpleName}") diff --git a/enro-core/src/main/java/dev/enro/core/NavigationHandle.kt b/enro-core/src/main/java/dev/enro/core/NavigationHandle.kt index 09e8d5ef..1c234774 100644 --- a/enro-core/src/main/java/dev/enro/core/NavigationHandle.kt +++ b/enro-core/src/main/java/dev/enro/core/NavigationHandle.kt @@ -18,12 +18,14 @@ public interface NavigationHandle : LifecycleOwner { public val instruction: NavigationInstruction.Open<*> public val dependencyScope: EnroDependencyScope public fun executeInstruction(navigationInstruction: NavigationInstruction) -} -public interface TypedNavigationHandle : NavigationHandle { - override val key: T + public interface Typed : NavigationHandle { + override val key: T + } } +public typealias TypedNavigationHandle = NavigationHandle.Typed + @PublishedApi internal class TypedNavigationHandleImpl( internal val navigationHandle: NavigationHandle, diff --git a/enro-core/src/main/java/dev/enro/core/container/NavigationContainer.kt b/enro-core/src/main/java/dev/enro/core/container/NavigationContainer.kt index 7ecda3ec..16ea1205 100644 --- a/enro-core/src/main/java/dev/enro/core/container/NavigationContainer.kt +++ b/enro-core/src/main/java/dev/enro/core/container/NavigationContainer.kt @@ -29,10 +29,9 @@ import dev.enro.compatability.Compatibility import dev.enro.core.controller.get import dev.enro.core.controller.interceptor.builder.NavigationInterceptorBuilder import dev.enro.core.controller.usecase.CanInstructionBeHostedAs -import dev.enro.core.controller.usecase.GetNavigationAnimations +import dev.enro.animation.internal.GetNavigationAnimations import dev.enro.core.getNavigationHandle import dev.enro.core.parentContainer -import dev.enro.destination.fragment.parentContainer import dev.enro.extensions.getParcelableListCompat import kotlinx.coroutines.Job import kotlinx.coroutines.delay diff --git a/enro-core/src/main/java/dev/enro/core/container/NavigationContainerScope.kt b/enro-core/src/main/java/dev/enro/core/container/NavigationContainerScope.kt index dc0558ff..3cc0d60d 100644 --- a/enro-core/src/main/java/dev/enro/core/container/NavigationContainerScope.kt +++ b/enro-core/src/main/java/dev/enro/core/container/NavigationContainerScope.kt @@ -5,9 +5,8 @@ import dev.enro.core.controller.EnroDependencyContainer import dev.enro.core.controller.EnroDependencyScope import dev.enro.core.controller.get import dev.enro.core.controller.register -import dev.enro.core.controller.usecase.GetNavigationAnimations +import dev.enro.animation.internal.GetNavigationAnimations import dev.enro.core.parentContainer -import dev.enro.destination.fragment.parentContainer internal class NavigationContainerScope( owner: NavigationContainer, diff --git a/enro-core/src/main/java/dev/enro/core/controller/NavigationController.kt b/enro-core/src/main/java/dev/enro/core/controller/NavigationController.kt index 0e6a707c..765906d4 100644 --- a/enro-core/src/main/java/dev/enro/core/controller/NavigationController.kt +++ b/enro-core/src/main/java/dev/enro/core/controller/NavigationController.kt @@ -2,7 +2,7 @@ package dev.enro.core.controller import android.app.Application import androidx.annotation.Keep -import androidx.fragment.app.FragmentManager.FragmentLifecycleCallbacks +import dev.enro.android.NavigationApplication import dev.enro.core.EnroException import dev.enro.core.NavigationBinding import dev.enro.core.NavigationExecutor diff --git a/enro-core/src/main/java/dev/enro/core/controller/NavigationControllerScope.kt b/enro-core/src/main/java/dev/enro/core/controller/NavigationControllerScope.kt index cebd9996..4d4f7492 100644 --- a/enro-core/src/main/java/dev/enro/core/controller/NavigationControllerScope.kt +++ b/enro-core/src/main/java/dev/enro/core/controller/NavigationControllerScope.kt @@ -1,7 +1,7 @@ package dev.enro.core.controller -import android.app.Application -import androidx.fragment.app.FragmentManager +import dev.enro.animation.internal.GetNavigationAnimations +import dev.enro.animation.internal.NavigationAnimationRepository import dev.enro.destination.activity.internal.ActivityLifecycleCallbacksForEnro import dev.enro.destination.fragment.internal.FragmentLifecycleCallbacksForEnro import dev.enro.core.controller.repository.* @@ -48,8 +48,8 @@ internal class NavigationControllerScope( register { GetNavigationAnimations(get(), get().controllerOverrides) } // Other - register { ActivityLifecycleCallbacksForEnro(get(), get()) } - register { FragmentLifecycleCallbacksForEnro(get(), get()) } + register { ActivityLifecycleCallbacksForEnro(get(), get()) } + register { FragmentLifecycleCallbacksForEnro(get(), get()) } } ) } \ No newline at end of file diff --git a/enro-core/src/main/java/dev/enro/core/controller/createNavigationController.kt b/enro-core/src/main/java/dev/enro/core/controller/createNavigationController.kt index 4f709e07..08fb40b3 100644 --- a/enro-core/src/main/java/dev/enro/core/controller/createNavigationController.kt +++ b/enro-core/src/main/java/dev/enro/core/controller/createNavigationController.kt @@ -2,6 +2,7 @@ package dev.enro.core.controller import android.app.Application import androidx.annotation.Keep +import dev.enro.android.NavigationApplication /** * Create a NavigationController from the NavigationControllerDefinition/DSL, and immediately attach it diff --git a/enro-core/src/main/java/dev/enro/core/controller/defaultNavigationModule.kt b/enro-core/src/main/java/dev/enro/core/controller/defaultNavigationModule.kt index 691de33d..8659f9da 100644 --- a/enro-core/src/main/java/dev/enro/core/controller/defaultNavigationModule.kt +++ b/enro-core/src/main/java/dev/enro/core/controller/defaultNavigationModule.kt @@ -1,7 +1,7 @@ package dev.enro.core.controller -import dev.enro.destination.activity.ActivityResultBridge -import dev.enro.destination.activity.ActivityResultDestination +import dev.enro.android.ActivityResultBridge +import dev.enro.android.ActivityResultDestination import dev.enro.destination.compose.composableDestination import dev.enro.core.controller.interceptor.HiltInstructionInterceptor import dev.enro.core.controller.interceptor.InstructionOpenedByInterceptor diff --git a/enro-core/src/main/java/dev/enro/core/controller/generatedNavigationModule.kt b/enro-core/src/main/java/dev/enro/core/controller/generatedNavigationModule.kt index fc652322..c372da2d 100644 --- a/enro-core/src/main/java/dev/enro/core/controller/generatedNavigationModule.kt +++ b/enro-core/src/main/java/dev/enro/core/controller/generatedNavigationModule.kt @@ -1,5 +1,7 @@ package dev.enro.core.controller +import dev.enro.android.NavigationApplication + @Suppress("UNCHECKED_CAST") internal fun NavigationApplication.loadGeneratedNavigationModule(): NavigationModule { diff --git a/enro-core/src/main/java/dev/enro/core/controller/usecase/AddModuleToController.kt b/enro-core/src/main/java/dev/enro/core/controller/usecase/AddModuleToController.kt index 77ae9570..3e690be4 100644 --- a/enro-core/src/main/java/dev/enro/core/controller/usecase/AddModuleToController.kt +++ b/enro-core/src/main/java/dev/enro/core/controller/usecase/AddModuleToController.kt @@ -1,5 +1,6 @@ package dev.enro.core.controller.usecase +import dev.enro.animation.internal.NavigationAnimationRepository import dev.enro.core.controller.NavigationModule import dev.enro.core.controller.repository.* diff --git a/enro-core/src/main/java/dev/enro/core/hosts/NavigationHostFactories.kt b/enro-core/src/main/java/dev/enro/core/hosts/NavigationHostFactories.kt index 6883b72c..71d7ca4f 100644 --- a/enro-core/src/main/java/dev/enro/core/hosts/NavigationHostFactories.kt +++ b/enro-core/src/main/java/dev/enro/core/hosts/NavigationHostFactories.kt @@ -9,8 +9,8 @@ import dev.enro.destination.activity.ActivityNavigationBinding import dev.enro.destination.compose.ComposableNavigationBinding import dev.enro.core.container.asPresentInstruction import dev.enro.destination.fragment.FragmentNavigationBinding -import dev.enro.hilt.isHiltApplication -import dev.enro.hilt.isHiltContext +import dev.enro.android.hilt.isHiltApplication +import dev.enro.android.hilt.isHiltContext internal class ActivityHost : NavigationHostFactory(Activity::class.java) { override fun supports( diff --git a/enro-core/src/main/java/dev/enro/core/result/NavigationResultExtensions.kt b/enro-core/src/main/java/dev/enro/core/result/NavigationResultExtensions.kt index e4c1d3da..51a149ac 100644 --- a/enro-core/src/main/java/dev/enro/core/result/NavigationResultExtensions.kt +++ b/enro-core/src/main/java/dev/enro/core/result/NavigationResultExtensions.kt @@ -11,7 +11,7 @@ import androidx.recyclerview.widget.RecyclerView import dev.enro.core.* import dev.enro.core.controller.usecase.createResultChannel import dev.enro.core.result.internal.LazyResultChannelProperty -import dev.enro.viewmodel.getNavigationHandle +import dev.enro.android.viewmodel.getNavigationHandle import kotlin.properties.ReadOnlyProperty import kotlin.reflect.KClass import dev.enro.core.closeWithResult as nonDeprecatedCloseWithResult diff --git a/enro-core/src/main/java/dev/enro/core/result/flows/FlowResultChannel.kt b/enro-core/src/main/java/dev/enro/core/result/flows/FlowResultChannel.kt index a8798431..da4b2289 100644 --- a/enro-core/src/main/java/dev/enro/core/result/flows/FlowResultChannel.kt +++ b/enro-core/src/main/java/dev/enro/core/result/flows/FlowResultChannel.kt @@ -10,7 +10,7 @@ import dev.enro.core.result.NavigationResultChannel import dev.enro.core.result.internal.ResultChannelImpl import dev.enro.core.result.registerForNavigationResultWithKey import dev.enro.extensions.getParcelableListCompat -import dev.enro.viewmodel.getNavigationHandle +import dev.enro.android.viewmodel.getNavigationHandle import kotlin.properties.PropertyDelegateProvider import kotlin.properties.ReadOnlyProperty diff --git a/enro-core/src/main/java/dev/enro/destination/compose/ProvideViewModelFactory.kt b/enro-core/src/main/java/dev/enro/destination/compose/ProvideViewModelFactory.kt index 66d153a5..e4f299e5 100644 --- a/enro-core/src/main/java/dev/enro/destination/compose/ProvideViewModelFactory.kt +++ b/enro-core/src/main/java/dev/enro/destination/compose/ProvideViewModelFactory.kt @@ -9,7 +9,7 @@ import androidx.lifecycle.ViewModelStore import androidx.lifecycle.ViewModelStoreOwner import androidx.lifecycle.viewmodel.CreationExtras import androidx.lifecycle.viewmodel.compose.LocalViewModelStoreOwner -import dev.enro.viewmodel.withNavigationHandle +import dev.enro.android.viewmodel.withNavigationHandle @Composable public fun ProvideViewModelFactory( diff --git a/enro-core/src/main/java/dev/enro/destination/compose/destination/ComposableDestinationOwner.kt b/enro-core/src/main/java/dev/enro/destination/compose/destination/ComposableDestinationOwner.kt index 30f09bee..67fe2cbe 100644 --- a/enro-core/src/main/java/dev/enro/destination/compose/destination/ComposableDestinationOwner.kt +++ b/enro-core/src/main/java/dev/enro/destination/compose/destination/ComposableDestinationOwner.kt @@ -21,8 +21,6 @@ import androidx.savedstate.SavedStateRegistry import androidx.savedstate.SavedStateRegistryOwner import dev.enro.animation.NavigationAnimation import dev.enro.core.* -import dev.enro.destination.compose.ComposableDestination -import dev.enro.destination.compose.LocalNavigationHandle import dev.enro.destination.compose.dialog.* import dev.enro.core.container.NavigationContainer import dev.enro.core.container.getAnimationsForEntering @@ -31,6 +29,8 @@ import dev.enro.core.controller.usecase.ComposeEnvironment import dev.enro.core.controller.usecase.OnNavigationContextCreated import dev.enro.core.controller.usecase.OnNavigationContextSaved import dev.enro.android.activity +import dev.enro.destination.compose.ComposableDestination +import dev.enro.destination.compose.LocalNavigationHandle import dev.enro.extensions.rememberLifecycleState internal class ComposableDestinationOwner( diff --git a/enro-core/src/main/java/dev/enro/destination/compose/destination/ComposableDestinationViewModelStoreOwner.kt b/enro-core/src/main/java/dev/enro/destination/compose/destination/ComposableDestinationViewModelStoreOwner.kt index 689822fc..8bd260fe 100644 --- a/enro-core/src/main/java/dev/enro/destination/compose/destination/ComposableDestinationViewModelStoreOwner.kt +++ b/enro-core/src/main/java/dev/enro/destination/compose/destination/ComposableDestinationViewModelStoreOwner.kt @@ -9,7 +9,7 @@ import dagger.hilt.internal.GeneratedComponentManagerHolder import dev.enro.core.addOpenInstruction import dev.enro.core.controller.application import dev.enro.core.getNavigationHandle -import dev.enro.viewmodel.withNavigationHandle +import dev.enro.android.viewmodel.withNavigationHandle internal class ComposableDestinationViewModelStoreOwner( private val owner: ComposableDestinationOwner, diff --git a/enro-core/src/test/java/dev/enro/ProjectArchitecture.kt b/enro-core/src/test/java/dev/enro/ProjectArchitecture.kt index 45a604d6..c7a1706c 100644 --- a/enro-core/src/test/java/dev/enro/ProjectArchitecture.kt +++ b/enro-core/src/test/java/dev/enro/ProjectArchitecture.kt @@ -37,7 +37,18 @@ internal class ProjectArchitecture { val allowedDependencies = listOf( "" to "dev.enro.core", "" to "dev.enro.annotation", + "" to "dev.enro.extensions", + + "dev.enro.compatability" to "", + "" to "dev.enro.compatability", + "dev.enro.destination" to "dev.enro.animation", + + // Should be removed + "dev.enro.core.hosts" to "", + + "dev.enro.core.container" to "dev.enro.animation", + // Destinations are allowed to access Android specific functionality, // and the Android specific functionality is allowed to access the destinations "dev.enro.destination" to "dev.enro.android", @@ -45,7 +56,7 @@ internal class ProjectArchitecture { ) ArchRuleDefinition.classes() .that() - .resideInAPackage("dev.enro.destination.activity") + .resideInAPackage("dev.enro..") .should(NotDependOnOtherPackageGroups(allowedDependencies)) .check(classes) } @@ -69,7 +80,7 @@ internal object NotDependOnInternalClasses : ArchCondition("not depen internal class NotDependOnOtherPackageGroups( private val allowedDependencies: List> -) : ArchCondition("not depend on internal classes") { +) : ArchCondition("not depend on other package groups") { override fun check(item: JavaClass, events: ConditionEvents) { item.directDependenciesFromSelf .forEach { dependency -> @@ -80,9 +91,12 @@ internal class NotDependOnOtherPackageGroups( val targetPackage = dependency.targetClass.packageName if (!targetPackage.startsWith("dev.enro")) return@forEach + if (originPackage.startsWith(targetPackage)) return@forEach + val commonPrefix = originPackage.commonPrefixWith(targetPackage) + if (commonPrefix.count { it == '.' } >= 3) return@forEach + val isAllowed = allowedDependencies.any { - originPackage.startsWith(it.first) && - targetPackage.startsWith(it.second) + (originPackage.startsWith(it.first) && targetPackage.startsWith(it.second)) } if (isAllowed) return@forEach diff --git a/enro-processor/src/main/java/dev/enro/processor/domain/DestinationReference.kt b/enro-processor/src/main/java/dev/enro/processor/domain/DestinationReference.kt index 9f50c89a..93b7d325 100644 --- a/enro-processor/src/main/java/dev/enro/processor/domain/DestinationReference.kt +++ b/enro-processor/src/main/java/dev/enro/processor/domain/DestinationReference.kt @@ -33,10 +33,10 @@ sealed class DestinationReference { .any { it.declaration.qualifiedName?.asString() == "androidx.fragment.app.Fragment" } val isSyntheticClass = declaration is KSClassDeclaration && declaration.getAllSuperTypes() - .any { it.declaration.qualifiedName?.asString() == "dev.enro.core.synthetic.SyntheticDestination" } + .any { it.declaration.qualifiedName?.asString() == "dev.enro.destination.synthetic.SyntheticDestination" } val isSyntheticProvider = declaration is KSPropertyDeclaration && - declaration.type.resolve().declaration.qualifiedName?.asString() == "dev.enro.core.synthetic.SyntheticDestinationProvider" + declaration.type.resolve().declaration.qualifiedName?.asString() == "dev.enro.destination.synthetic.SyntheticDestinationProvider" val isComposable = declaration is KSFunctionDeclaration && declaration.annotations .any { it.shortName.asString() == "Composable" } @@ -76,7 +76,7 @@ sealed class DestinationReference { .firstOrNull { actualName == it.simpleName.toString() && it != element } val syntheticProviderMirror = processingEnv.elementUtils - .getTypeElement("dev.enro.core.synthetic.SyntheticDestinationProvider") + .getTypeElement("dev.enro.destination.synthetic.SyntheticDestinationProvider") .asType() val erasedSyntheticProvider = processingEnv.typeUtils.erasure(syntheticProviderMirror) val erasedReturnType = processingEnv.typeUtils.erasure(syntheticElement!!.returnType) diff --git a/enro-processor/src/main/java/dev/enro/processor/generator/NavigationDestinationGenerator.kt b/enro-processor/src/main/java/dev/enro/processor/generator/NavigationDestinationGenerator.kt index a6e20398..89d5afec 100644 --- a/enro-processor/src/main/java/dev/enro/processor/generator/NavigationDestinationGenerator.kt +++ b/enro-processor/src/main/java/dev/enro/processor/generator/NavigationDestinationGenerator.kt @@ -306,19 +306,19 @@ fun JavaFile.Builder.addImportsForBinding(): JavaFile.Builder { fun FileSpec.Builder.addImportsForBinding(): FileSpec.Builder { return this .addImport( - "dev.enro.core.activity", + "dev.enro.destination.activity", "activityDestination" ) .addImport( - "dev.enro.core.fragment", + "dev.enro.destination.fragment", "fragmentDestination" ) .addImport( - "dev.enro.core.synthetic", + "dev.enro.destination.synthetic", "syntheticDestination" ) .addImport( - "dev.enro.core.compose", + "dev.enro.destination.compose", "composableDestination" ) } \ No newline at end of file diff --git a/enro-test/src/main/java/dev/enro/test/EnroTest.kt b/enro-test/src/main/java/dev/enro/test/EnroTest.kt index bd14af85..efd1ad52 100644 --- a/enro-test/src/main/java/dev/enro/test/EnroTest.kt +++ b/enro-test/src/main/java/dev/enro/test/EnroTest.kt @@ -4,10 +4,10 @@ package dev.enro.test import android.app.Application import androidx.test.core.app.ApplicationProvider import androidx.test.platform.app.InstrumentationRegistry -import dev.enro.core.controller.NavigationApplication +import dev.enro.android.NavigationApplication import dev.enro.core.controller.NavigationController import dev.enro.core.controller.createUnattachedNavigationController -import dev.enro.viewmodel.EnroViewModelNavigationHandleProvider +import dev.enro.android.viewmodel.EnroViewModelNavigationHandleProvider object EnroTest { diff --git a/enro/hilt-test/src/androidTest/java/dev/enro/TestApplication.kt b/enro/hilt-test/src/androidTest/java/dev/enro/TestApplication.kt index 50660160..b9c91851 100644 --- a/enro/hilt-test/src/androidTest/java/dev/enro/TestApplication.kt +++ b/enro/hilt-test/src/androidTest/java/dev/enro/TestApplication.kt @@ -2,7 +2,7 @@ package dev.enro import android.app.Application import dev.enro.annotations.NavigationComponent -import dev.enro.core.controller.NavigationApplication +import dev.enro.android.NavigationApplication import dev.enro.core.controller.createNavigationController import dev.enro.core.plugins.EnroLogger diff --git a/enro/hilt-test/src/androidTest/java/dev/enro/hilt/test/HiltViewModelCreationTests.kt b/enro/hilt-test/src/androidTest/java/dev/enro/hilt/test/HiltViewModelCreationTests.kt index b1b389ef..366f2e51 100644 --- a/enro/hilt-test/src/androidTest/java/dev/enro/hilt/test/HiltViewModelCreationTests.kt +++ b/enro/hilt-test/src/androidTest/java/dev/enro/hilt/test/HiltViewModelCreationTests.kt @@ -27,8 +27,8 @@ import dev.enro.core.* import dev.enro.destination.compose.EnroContainer import dev.enro.destination.fragment.containerManager import dev.enro.expectContext -import dev.enro.viewmodel.enroViewModels -import dev.enro.viewmodel.navigationHandle +import dev.enro.android.viewmodel.enroViewModels +import dev.enro.android.viewmodel.navigationHandle import dev.enro.waitOnMain import junit.framework.TestCase.assertTrue import kotlinx.parcelize.Parcelize diff --git a/enro/src/androidTest/java/dev/enro/TestApplication.kt b/enro/src/androidTest/java/dev/enro/TestApplication.kt index a7d1c2df..0007a819 100644 --- a/enro/src/androidTest/java/dev/enro/TestApplication.kt +++ b/enro/src/androidTest/java/dev/enro/TestApplication.kt @@ -3,7 +3,7 @@ package dev.enro import android.app.Application import dev.enro.annotations.NavigationComponent import dev.enro.destination.compose.composableDestination -import dev.enro.core.controller.NavigationApplication +import dev.enro.android.NavigationApplication import dev.enro.core.controller.createNavigationController import dev.enro.core.destinations.ComposableDestinations import dev.enro.core.destinations.ManuallyBoundComposableScreen diff --git a/enro/src/androidTest/java/dev/enro/core/destinations/ComposableDestinations.kt b/enro/src/androidTest/java/dev/enro/core/destinations/ComposableDestinations.kt index 1351ea03..9c78a8c5 100644 --- a/enro/src/androidTest/java/dev/enro/core/destinations/ComposableDestinations.kt +++ b/enro/src/androidTest/java/dev/enro/core/destinations/ComposableDestinations.kt @@ -17,7 +17,7 @@ import dev.enro.destination.compose.navigationHandle import dev.enro.core.requestClose import dev.enro.core.result.NavigationResultChannel import dev.enro.core.result.registerForNavigationResult -import dev.enro.viewmodel.navigationHandle +import dev.enro.android.viewmodel.navigationHandle import kotlinx.parcelize.Parcelize import java.util.* diff --git a/enro/src/androidTest/java/dev/enro/result/ResultDestinations.kt b/enro/src/androidTest/java/dev/enro/result/ResultDestinations.kt index eaf7e020..0e1b4c47 100644 --- a/enro/src/androidTest/java/dev/enro/result/ResultDestinations.kt +++ b/enro/src/androidTest/java/dev/enro/result/ResultDestinations.kt @@ -19,8 +19,8 @@ import dev.enro.core.result.forwardResult import dev.enro.core.result.registerForNavigationResult import dev.enro.core.result.sendResult import dev.enro.destination.synthetic.SyntheticDestination -import dev.enro.viewmodel.enroViewModels -import dev.enro.viewmodel.navigationHandle +import dev.enro.android.viewmodel.enroViewModels +import dev.enro.android.viewmodel.navigationHandle import kotlinx.parcelize.Parcelize @Parcelize diff --git a/enro/src/androidTest/java/dev/enro/result/ViewModelResultTests.kt b/enro/src/androidTest/java/dev/enro/result/ViewModelResultTests.kt index 3c3b78d6..e51d143b 100644 --- a/enro/src/androidTest/java/dev/enro/result/ViewModelResultTests.kt +++ b/enro/src/androidTest/java/dev/enro/result/ViewModelResultTests.kt @@ -11,8 +11,8 @@ import dev.enro.core.NavigationKey import dev.enro.core.closeWithResult import dev.enro.core.forward import dev.enro.core.result.registerForNavigationResult -import dev.enro.viewmodel.enroViewModels -import dev.enro.viewmodel.navigationHandle +import dev.enro.android.viewmodel.enroViewModels +import dev.enro.android.viewmodel.navigationHandle import kotlinx.parcelize.Parcelize import leakcanary.DetectLeaksAfterTestSuccess import org.junit.Rule diff --git a/enro/src/androidTest/java/dev/enro/test/EnroTestTestDestinations.kt b/enro/src/androidTest/java/dev/enro/test/EnroTestTestDestinations.kt index 70c1c5d1..5967f994 100644 --- a/enro/src/androidTest/java/dev/enro/test/EnroTestTestDestinations.kt +++ b/enro/src/androidTest/java/dev/enro/test/EnroTestTestDestinations.kt @@ -7,8 +7,8 @@ import dev.enro.annotations.NavigationDestination import dev.enro.core.NavigationKey import dev.enro.core.navigationHandle import dev.enro.core.result.registerForNavigationResult -import dev.enro.viewmodel.enroViewModels -import dev.enro.viewmodel.navigationHandle +import dev.enro.android.viewmodel.enroViewModels +import dev.enro.android.viewmodel.navigationHandle import kotlinx.parcelize.Parcelize interface EnroTestTestKey : NavigationKey { diff --git a/enro/src/test/java/dev/enro/test/TestData.kt b/enro/src/test/java/dev/enro/test/TestData.kt index b0da1970..78237cfd 100644 --- a/enro/src/test/java/dev/enro/test/TestData.kt +++ b/enro/src/test/java/dev/enro/test/TestData.kt @@ -8,7 +8,7 @@ import dev.enro.core.container.push import dev.enro.core.container.setBackstack import dev.enro.core.result.flows.registerForFlowResult import dev.enro.core.result.registerForNavigationResult -import dev.enro.viewmodel.navigationHandle +import dev.enro.android.viewmodel.navigationHandle import kotlinx.parcelize.Parcelize import java.util.* diff --git a/example/src/main/java/dev/enro/example/Backstacks.kt b/example/src/main/java/dev/enro/example/Backstacks.kt index 34a657ff..8be35c83 100644 --- a/example/src/main/java/dev/enro/example/Backstacks.kt +++ b/example/src/main/java/dev/enro/example/Backstacks.kt @@ -17,14 +17,14 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp -import dev.enro.annotations.NavigationDestination import dev.enro.annotations.AdvancedEnroApi +import dev.enro.annotations.NavigationDestination import dev.enro.core.NavigationContext import dev.enro.core.NavigationHost import dev.enro.core.NavigationKey import dev.enro.core.getNavigationHandle -import dev.enro.destination.fragment.navigationContext import dev.enro.core.rootContext +import dev.enro.destination.compose.navigationContext import kotlinx.coroutines.delay import kotlinx.coroutines.isActive import kotlinx.parcelize.Parcelize diff --git a/example/src/main/java/dev/enro/example/ExampleApplication.kt b/example/src/main/java/dev/enro/example/ExampleApplication.kt index 664fac7c..0520f0f3 100644 --- a/example/src/main/java/dev/enro/example/ExampleApplication.kt +++ b/example/src/main/java/dev/enro/example/ExampleApplication.kt @@ -7,7 +7,7 @@ import androidx.compose.material.contentColorFor import androidx.compose.runtime.CompositionLocalProvider import dagger.hilt.android.HiltAndroidApp import dev.enro.annotations.NavigationComponent -import dev.enro.core.controller.NavigationApplication +import dev.enro.android.NavigationApplication import dev.enro.core.controller.createNavigationController import dev.enro.core.plugins.EnroLogger @@ -27,4 +27,8 @@ class ExampleApplication : Application(), NavigationApplication { } } } + + override fun onCreate() { + super.onCreate() + } } diff --git a/example/src/main/java/dev/enro/example/RootFragment.kt b/example/src/main/java/dev/enro/example/RootFragment.kt index 06197ffe..7b346b8d 100644 --- a/example/src/main/java/dev/enro/example/RootFragment.kt +++ b/example/src/main/java/dev/enro/example/RootFragment.kt @@ -15,6 +15,7 @@ import dev.enro.destination.activity.containerManager import dev.enro.destination.fragment.container.FragmentNavigationContainer import dev.enro.destination.fragment.container.navigationContainer import dev.enro.destination.fragment.container.setVisibilityAnimated +import dev.enro.destination.fragment.containerManager import dev.enro.example.databinding.FragmentRootBinding import dev.enro.example.destinations.compose.ExampleComposable import dev.enro.example.destinations.fragment.ExampleFragment diff --git a/example/src/main/java/dev/enro/example/core/ui/ExampleScreenTemplate.kt b/example/src/main/java/dev/enro/example/core/ui/ExampleScreenTemplate.kt index 653e0e2a..c20ea006 100644 --- a/example/src/main/java/dev/enro/example/core/ui/ExampleScreenTemplate.kt +++ b/example/src/main/java/dev/enro/example/core/ui/ExampleScreenTemplate.kt @@ -42,8 +42,9 @@ import dev.enro.example.destinations.compose.ExampleComposable import dev.enro.example.destinations.fragment.DialogFragmentKey import dev.enro.example.destinations.fragment.ExampleFragment import dev.enro.example.destinations.restoration.SaveRootState -import dev.enro.viewmodel.navigationHandle -import dev.enro.viewmodel.withNavigationHandle +import dev.enro.android.viewmodel.navigationHandle +import dev.enro.android.viewmodel.withNavigationHandle +import dev.enro.destination.compose.parentContainer import kotlinx.coroutines.delay import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow diff --git a/example/src/main/java/dev/enro/example/destinations/activity/ActivityResults.kt b/example/src/main/java/dev/enro/example/destinations/activity/ActivityResults.kt index 73765bf3..5ca750fe 100644 --- a/example/src/main/java/dev/enro/example/destinations/activity/ActivityResults.kt +++ b/example/src/main/java/dev/enro/example/destinations/activity/ActivityResults.kt @@ -17,9 +17,9 @@ import androidx.compose.ui.Modifier import dev.enro.annotations.NavigationDestination import dev.enro.annotations.ExperimentalEnroApi import dev.enro.core.NavigationKey -import dev.enro.destination.activity.activityResultDestination -import dev.enro.destination.activity.withInput -import dev.enro.destination.activity.withMappedResult +import dev.enro.android.activityResultDestination +import dev.enro.android.withInput +import dev.enro.android.withMappedResult import dev.enro.destination.compose.navigationHandle import dev.enro.destination.compose.registerForNavigationResult import dev.enro.core.present diff --git a/example/src/main/java/dev/enro/example/destinations/result/ResultExample.kt b/example/src/main/java/dev/enro/example/destinations/result/ResultExample.kt index b0055305..e40cd960 100644 --- a/example/src/main/java/dev/enro/example/destinations/result/ResultExample.kt +++ b/example/src/main/java/dev/enro/example/destinations/result/ResultExample.kt @@ -1,6 +1,7 @@ package dev.enro.example.destinations.result import android.annotation.SuppressLint +import android.content.Context import android.os.Bundle import android.view.LayoutInflater import android.view.View @@ -9,6 +10,8 @@ import androidx.fragment.app.Fragment import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel +import dev.enro.android.viewmodel.enroViewModels +import dev.enro.android.viewmodel.navigationHandle import dev.enro.annotations.NavigationDestination import dev.enro.core.NavigationKey import dev.enro.core.result.registerForNavigationResult @@ -18,9 +21,14 @@ import dev.enro.example.databinding.FragmentResultExampleBinding import dev.enro.example.destinations.result.compose.GetString import dev.enro.example.destinations.result.flow.embedded.CreateSentenceEmbeddedFlow import dev.enro.example.destinations.result.flow.managed.CreateSentenceManagedFlow -import dev.enro.viewmodel.enroViewModels -import dev.enro.viewmodel.navigationHandle import kotlinx.parcelize.Parcelize +import net.bytebuddy.ByteBuddy +import net.bytebuddy.android.AndroidClassLoadingStrategy.Wrapping +import net.bytebuddy.dynamic.loading.ClassLoadingStrategy +import net.bytebuddy.implementation.InvocationHandlerAdapter +import net.bytebuddy.matcher.ElementMatcher +import kotlin.coroutines.coroutineContext + @Parcelize class ResultExampleKey : NavigationKey.SupportsPush @@ -29,7 +37,9 @@ class ResultExampleKey : NavigationKey.SupportsPush @NavigationDestination(ResultExampleKey::class) class RequestExampleFragment : Fragment() { - private val viewModel by enroViewModels() + private val viewModel by lazy { + enroViewModels().value.instrumented(requireActivity()) + } override fun onCreateView( inflater: LayoutInflater, @@ -64,7 +74,7 @@ class RequestExampleFragment : Fragment() { } } -class RequestExampleViewModel() : ViewModel() { +open class RequestExampleViewModel() : ViewModel() { private val navigation by navigationHandle() @@ -98,4 +108,25 @@ class RequestExampleViewModel() : ViewModel() { fun onRequestSentenceEmbeddedFlow() { requestSentence.push(CreateSentenceEmbeddedFlow()) } +} + +inline fun T.instrumented(context : Context) : T { + val strategy = Wrapping( + context.getDir( + "generated", + Context.MODE_PRIVATE + ) + ) + val wrapped = this + return ByteBuddy() + .subclass(T::class.java) + .method { true } + .intercept(InvocationHandlerAdapter.of { proxy, method, args -> + method.invoke(wrapped, *args) + }) +// . + .make() + .load(T::class.java.classLoader, strategy) + .loaded + .newInstance() } \ No newline at end of file diff --git a/example/src/main/java/dev/enro/example/destinations/result/flow/managed/CreateSentenceManagedFlow.kt b/example/src/main/java/dev/enro/example/destinations/result/flow/managed/CreateSentenceManagedFlow.kt index 468e0603..bdbfbe73 100644 --- a/example/src/main/java/dev/enro/example/destinations/result/flow/managed/CreateSentenceManagedFlow.kt +++ b/example/src/main/java/dev/enro/example/destinations/result/flow/managed/CreateSentenceManagedFlow.kt @@ -19,8 +19,8 @@ import dev.enro.example.core.data.Sentence import dev.enro.example.destinations.result.compose.SelectAdjective import dev.enro.example.destinations.result.compose.SelectAdverb import dev.enro.example.destinations.result.compose.SelectNoun -import dev.enro.viewmodel.enroViewModels -import dev.enro.viewmodel.navigationHandle +import dev.enro.android.viewmodel.enroViewModels +import dev.enro.android.viewmodel.navigationHandle import kotlinx.parcelize.Parcelize @Parcelize diff --git a/tests/application/src/main/java/dev/enro/tests/application/TestApplication.kt b/tests/application/src/main/java/dev/enro/tests/application/TestApplication.kt index 8cd79caa..2084270d 100644 --- a/tests/application/src/main/java/dev/enro/tests/application/TestApplication.kt +++ b/tests/application/src/main/java/dev/enro/tests/application/TestApplication.kt @@ -2,7 +2,7 @@ package dev.enro.tests.application import android.app.Application import dev.enro.annotations.NavigationComponent -import dev.enro.core.controller.NavigationApplication +import dev.enro.android.NavigationApplication import dev.enro.core.controller.createNavigationController @NavigationComponent