From fb840eb9ce122e13f2e45e9705279d8ccebdc5cb Mon Sep 17 00:00:00 2001 From: Jay Ohms Date: Thu, 13 Jun 2024 10:01:51 -0400 Subject: [PATCH] Rename HotwireDestination annotation -> HotwireDestinationDeepLink --- .../demo/features/imageviewer/ImageViewerFragment.kt | 4 ++-- .../demo/features/numbers/NumberBottomSheetFragment.kt | 4 ++-- .../dev/hotwire/demo/features/numbers/NumbersFragment.kt | 4 ++-- .../hotwire/demo/features/web/WebBottomSheetFragment.kt | 4 ++-- .../kotlin/dev/hotwire/demo/features/web/WebFragment.kt | 4 ++-- .../dev/hotwire/demo/features/web/WebHomeFragment.kt | 4 ++-- .../dev/hotwire/demo/features/web/WebModalFragment.kt | 4 ++-- ...otwireDestination.kt => HotwireDestinationDeepLink.kt} | 8 ++++---- .../navigation/fragments/HotwireWebBottomSheetFragment.kt | 4 ++-- .../hotwire/navigation/fragments/HotwireWebFragment.kt | 4 ++-- .../hotwire/navigation/navigator/NavigatorGraphBuilder.kt | 6 +++--- .../dev/hotwire/navigation/navigator/NavigatorRule.kt | 4 ++-- 12 files changed, 27 insertions(+), 27 deletions(-) rename navigation-fragments/src/main/java/dev/hotwire/navigation/destinations/{HotwireDestination.kt => HotwireDestinationDeepLink.kt} (73%) diff --git a/demo/src/main/kotlin/dev/hotwire/demo/features/imageviewer/ImageViewerFragment.kt b/demo/src/main/kotlin/dev/hotwire/demo/features/imageviewer/ImageViewerFragment.kt index 9703e3c..a3a8dd1 100644 --- a/demo/src/main/kotlin/dev/hotwire/demo/features/imageviewer/ImageViewerFragment.kt +++ b/demo/src/main/kotlin/dev/hotwire/demo/features/imageviewer/ImageViewerFragment.kt @@ -7,11 +7,11 @@ import android.view.ViewGroup import android.widget.ImageView import coil.load import dev.hotwire.demo.R -import dev.hotwire.navigation.destinations.HotwireDestination +import dev.hotwire.navigation.destinations.HotwireDestinationDeepLink import dev.hotwire.navigation.fragments.HotwireFragment import dev.hotwire.navigation.util.displayBackButtonAsCloseIcon -@HotwireDestination(uri = "turbo://fragment/image_viewer") +@HotwireDestinationDeepLink(uri = "turbo://fragment/image_viewer") class ImageViewerFragment : HotwireFragment() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { return inflater.inflate(R.layout.fragment_image_viewer, container, false) diff --git a/demo/src/main/kotlin/dev/hotwire/demo/features/numbers/NumberBottomSheetFragment.kt b/demo/src/main/kotlin/dev/hotwire/demo/features/numbers/NumberBottomSheetFragment.kt index e3d06c6..02958a5 100644 --- a/demo/src/main/kotlin/dev/hotwire/demo/features/numbers/NumberBottomSheetFragment.kt +++ b/demo/src/main/kotlin/dev/hotwire/demo/features/numbers/NumberBottomSheetFragment.kt @@ -8,10 +8,10 @@ import android.view.ViewGroup import com.google.android.material.textview.MaterialTextView import dev.hotwire.core.turbo.config.PathConfigurationProperties import dev.hotwire.demo.R -import dev.hotwire.navigation.destinations.HotwireDestination +import dev.hotwire.navigation.destinations.HotwireDestinationDeepLink import dev.hotwire.navigation.fragments.HotwireBottomSheetFragment -@HotwireDestination(uri = "turbo://fragment/numbers/sheet") +@HotwireDestinationDeepLink(uri = "turbo://fragment/numbers/sheet") class NumberBottomSheetFragment : HotwireBottomSheetFragment() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { return inflater.inflate(R.layout.fragment_number_bottom_sheet, container, false) diff --git a/demo/src/main/kotlin/dev/hotwire/demo/features/numbers/NumbersFragment.kt b/demo/src/main/kotlin/dev/hotwire/demo/features/numbers/NumbersFragment.kt index d6892c3..256e57d 100644 --- a/demo/src/main/kotlin/dev/hotwire/demo/features/numbers/NumbersFragment.kt +++ b/demo/src/main/kotlin/dev/hotwire/demo/features/numbers/NumbersFragment.kt @@ -8,10 +8,10 @@ import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import dev.hotwire.demo.R import dev.hotwire.demo.Urls -import dev.hotwire.navigation.destinations.HotwireDestination +import dev.hotwire.navigation.destinations.HotwireDestinationDeepLink import dev.hotwire.navigation.fragments.HotwireFragment -@HotwireDestination(uri = "turbo://fragment/numbers") +@HotwireDestinationDeepLink(uri = "turbo://fragment/numbers") class NumbersFragment : HotwireFragment(), NumbersFragmentCallback { private val numbersAdapter = NumbersAdapter(this) diff --git a/demo/src/main/kotlin/dev/hotwire/demo/features/web/WebBottomSheetFragment.kt b/demo/src/main/kotlin/dev/hotwire/demo/features/web/WebBottomSheetFragment.kt index c0bdda8..334a5b1 100644 --- a/demo/src/main/kotlin/dev/hotwire/demo/features/web/WebBottomSheetFragment.kt +++ b/demo/src/main/kotlin/dev/hotwire/demo/features/web/WebBottomSheetFragment.kt @@ -4,10 +4,10 @@ import android.os.Bundle import android.view.MenuItem import android.view.View import dev.hotwire.demo.R -import dev.hotwire.navigation.destinations.HotwireDestination +import dev.hotwire.navigation.destinations.HotwireDestinationDeepLink import dev.hotwire.navigation.fragments.HotwireWebBottomSheetFragment -@HotwireDestination(uri = "turbo://fragment/web/modal/sheet") +@HotwireDestinationDeepLink(uri = "turbo://fragment/web/modal/sheet") class WebBottomSheetFragment : HotwireWebBottomSheetFragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) diff --git a/demo/src/main/kotlin/dev/hotwire/demo/features/web/WebFragment.kt b/demo/src/main/kotlin/dev/hotwire/demo/features/web/WebFragment.kt index aa11d10..e390151 100644 --- a/demo/src/main/kotlin/dev/hotwire/demo/features/web/WebFragment.kt +++ b/demo/src/main/kotlin/dev/hotwire/demo/features/web/WebFragment.kt @@ -9,10 +9,10 @@ import dev.hotwire.core.turbo.visit.VisitAction.REPLACE import dev.hotwire.core.turbo.visit.VisitOptions import dev.hotwire.demo.R import dev.hotwire.demo.Urls -import dev.hotwire.navigation.destinations.HotwireDestination +import dev.hotwire.navigation.destinations.HotwireDestinationDeepLink import dev.hotwire.navigation.fragments.HotwireWebFragment -@HotwireDestination(uri = "turbo://fragment/web") +@HotwireDestinationDeepLink(uri = "turbo://fragment/web") open class WebFragment : HotwireWebFragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) diff --git a/demo/src/main/kotlin/dev/hotwire/demo/features/web/WebHomeFragment.kt b/demo/src/main/kotlin/dev/hotwire/demo/features/web/WebHomeFragment.kt index be3919d..9752ea9 100644 --- a/demo/src/main/kotlin/dev/hotwire/demo/features/web/WebHomeFragment.kt +++ b/demo/src/main/kotlin/dev/hotwire/demo/features/web/WebHomeFragment.kt @@ -6,10 +6,10 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import dev.hotwire.core.turbo.errors.VisitError -import dev.hotwire.navigation.destinations.HotwireDestination +import dev.hotwire.navigation.destinations.HotwireDestinationDeepLink import dev.hotwire.demo.R -@HotwireDestination(uri = "turbo://fragment/web/home") +@HotwireDestinationDeepLink(uri = "turbo://fragment/web/home") class WebHomeFragment : WebFragment() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { return inflater.inflate(R.layout.fragment_web_home, container, false) diff --git a/demo/src/main/kotlin/dev/hotwire/demo/features/web/WebModalFragment.kt b/demo/src/main/kotlin/dev/hotwire/demo/features/web/WebModalFragment.kt index 85d98b3..2b3fedd 100644 --- a/demo/src/main/kotlin/dev/hotwire/demo/features/web/WebModalFragment.kt +++ b/demo/src/main/kotlin/dev/hotwire/demo/features/web/WebModalFragment.kt @@ -1,6 +1,6 @@ package dev.hotwire.demo.features.web -import dev.hotwire.navigation.destinations.HotwireDestination +import dev.hotwire.navigation.destinations.HotwireDestinationDeepLink -@HotwireDestination(uri = "turbo://fragment/web/modal") +@HotwireDestinationDeepLink(uri = "turbo://fragment/web/modal") class WebModalFragment : WebFragment() diff --git a/navigation-fragments/src/main/java/dev/hotwire/navigation/destinations/HotwireDestination.kt b/navigation-fragments/src/main/java/dev/hotwire/navigation/destinations/HotwireDestinationDeepLink.kt similarity index 73% rename from navigation-fragments/src/main/java/dev/hotwire/navigation/destinations/HotwireDestination.kt rename to navigation-fragments/src/main/java/dev/hotwire/navigation/destinations/HotwireDestinationDeepLink.kt index beee101..fc22ffa 100644 --- a/navigation-fragments/src/main/java/dev/hotwire/navigation/destinations/HotwireDestination.kt +++ b/navigation-fragments/src/main/java/dev/hotwire/navigation/destinations/HotwireDestinationDeepLink.kt @@ -7,7 +7,7 @@ import kotlin.reflect.full.findAnnotation * Annotation for each Fragment that will be registered as a navigation destination. * * For example: - * `@HotwireDestination(uri = "turbo://fragment/search")` + * `@HotwireDestinationDeepLink(uri = "turbo://fragment/search")` * `class SearchFragment : TurboWebFragment()` * * @property uri The URI to be registered with the Android Navigation component nav graph. @@ -15,13 +15,13 @@ import kotlin.reflect.full.findAnnotation @Target(AnnotationTarget.CLASS) @Retention(AnnotationRetention.RUNTIME) @MustBeDocumented -annotation class HotwireDestination( +annotation class HotwireDestinationDeepLink( val uri: String ) { companion object { - internal fun from(klass: KClass): HotwireDestination { + internal fun from(klass: KClass): HotwireDestinationDeepLink { return requireNotNull(klass.findAnnotation()) { - "A HotwireDestination annotation is required for the destination: ${klass.simpleName}" + "A HotwireDestinationDeepLink annotation is required for the destination: ${klass.simpleName}" } } } diff --git a/navigation-fragments/src/main/java/dev/hotwire/navigation/fragments/HotwireWebBottomSheetFragment.kt b/navigation-fragments/src/main/java/dev/hotwire/navigation/fragments/HotwireWebBottomSheetFragment.kt index a5f60ba..3ff5a1e 100644 --- a/navigation-fragments/src/main/java/dev/hotwire/navigation/fragments/HotwireWebBottomSheetFragment.kt +++ b/navigation-fragments/src/main/java/dev/hotwire/navigation/fragments/HotwireWebBottomSheetFragment.kt @@ -15,7 +15,7 @@ import dev.hotwire.core.turbo.views.TurboWebChromeClient import dev.hotwire.core.turbo.views.TurboWebView import dev.hotwire.navigation.R import dev.hotwire.navigation.config.HotwireNavigation -import dev.hotwire.navigation.destinations.HotwireDestination +import dev.hotwire.navigation.destinations.HotwireDestinationDeepLink import dev.hotwire.navigation.views.TurboView /** @@ -24,7 +24,7 @@ import dev.hotwire.navigation.views.TurboView * * For native bottom sheet fragments, refer to [HotwireBottomSheetFragment]. */ -@HotwireDestination(uri = "turbo://fragment/web/modal/sheet") +@HotwireDestinationDeepLink(uri = "turbo://fragment/web/modal/sheet") open class HotwireWebBottomSheetFragment : HotwireBottomSheetFragment(), HotwireWebFragmentCallback { private lateinit var webDelegate: HotwireWebFragmentDelegate diff --git a/navigation-fragments/src/main/java/dev/hotwire/navigation/fragments/HotwireWebFragment.kt b/navigation-fragments/src/main/java/dev/hotwire/navigation/fragments/HotwireWebFragment.kt index 1f69939..8267bba 100644 --- a/navigation-fragments/src/main/java/dev/hotwire/navigation/fragments/HotwireWebFragment.kt +++ b/navigation-fragments/src/main/java/dev/hotwire/navigation/fragments/HotwireWebFragment.kt @@ -14,7 +14,7 @@ import dev.hotwire.core.turbo.views.TurboWebChromeClient import dev.hotwire.core.turbo.views.TurboWebView import dev.hotwire.navigation.R import dev.hotwire.navigation.config.HotwireNavigation -import dev.hotwire.navigation.destinations.HotwireDestination +import dev.hotwire.navigation.destinations.HotwireDestinationDeepLink import dev.hotwire.navigation.session.SessionModalResult import dev.hotwire.navigation.views.TurboView @@ -24,7 +24,7 @@ import dev.hotwire.navigation.views.TurboView * * For native fragments, refer to [HotwireFragment]. */ -@HotwireDestination(uri = "turbo://fragment/web") +@HotwireDestinationDeepLink(uri = "turbo://fragment/web") open class HotwireWebFragment : HotwireFragment(), HotwireWebFragmentCallback { private lateinit var webDelegate: HotwireWebFragmentDelegate diff --git a/navigation-fragments/src/main/java/dev/hotwire/navigation/navigator/NavigatorGraphBuilder.kt b/navigation-fragments/src/main/java/dev/hotwire/navigation/navigator/NavigatorGraphBuilder.kt index e25d2a9..f505966 100644 --- a/navigation-fragments/src/main/java/dev/hotwire/navigation/navigator/NavigatorGraphBuilder.kt +++ b/navigation-fragments/src/main/java/dev/hotwire/navigation/navigator/NavigatorGraphBuilder.kt @@ -16,7 +16,7 @@ import androidx.navigation.get import dev.hotwire.core.turbo.config.PathConfiguration import dev.hotwire.core.turbo.config.uri import dev.hotwire.navigation.config.HotwireNavigation -import dev.hotwire.navigation.destinations.HotwireDestination +import dev.hotwire.navigation.destinations.HotwireDestinationDeepLink import java.util.UUID import kotlin.reflect.KClass import kotlin.reflect.full.isSubclassOf @@ -40,7 +40,7 @@ internal class NavigatorGraphBuilder( val fragmentDestinations = registeredFragments.map { FragmentDestination( route = currentRoute.also { currentRoute++ }.toString(), - uri = HotwireDestination.from(it).uri.toUri(), + uri = HotwireDestinationDeepLink.from(it).uri.toUri(), kClass = it ) } @@ -94,7 +94,7 @@ internal class NavigatorGraphBuilder( private fun List.startDestination(): FragmentDestination { val startDestinationUri = pathConfiguration.properties(startLocation).uri ?: - HotwireDestination.from(HotwireNavigation.defaultFragmentDestination).uri.toUri() + HotwireDestinationDeepLink.from(HotwireNavigation.defaultFragmentDestination).uri.toUri() return requireNotNull(firstOrNull { it.uri == startDestinationUri }) { "A start Fragment destination was not found for uri: $startDestinationUri" diff --git a/navigation-fragments/src/main/java/dev/hotwire/navigation/navigator/NavigatorRule.kt b/navigation-fragments/src/main/java/dev/hotwire/navigation/navigator/NavigatorRule.kt index 5c7c8d5..fadb999 100644 --- a/navigation-fragments/src/main/java/dev/hotwire/navigation/navigator/NavigatorRule.kt +++ b/navigation-fragments/src/main/java/dev/hotwire/navigation/navigator/NavigatorRule.kt @@ -21,7 +21,7 @@ import dev.hotwire.core.turbo.nav.TurboNavQueryStringPresentation import dev.hotwire.core.turbo.visit.VisitAction import dev.hotwire.core.turbo.visit.VisitOptions import dev.hotwire.navigation.config.HotwireNavigation -import dev.hotwire.navigation.destinations.HotwireDestination +import dev.hotwire.navigation.destinations.HotwireDestinationDeepLink import dev.hotwire.navigation.session.SessionModalResult import dev.hotwire.navigation.util.location @@ -35,7 +35,7 @@ internal class NavigatorRule( pathConfiguration: PathConfiguration, val controller: NavController ) { - val defaultUri = HotwireDestination.from(HotwireNavigation.defaultFragmentDestination).uri.toUri() + val defaultUri = HotwireDestinationDeepLink.from(HotwireNavigation.defaultFragmentDestination).uri.toUri() // Current destination val previousLocation = controller.previousBackStackEntry.location