diff --git a/.gitignore b/.gitignore index 93569d6683a..44d33b8262c 100644 --- a/.gitignore +++ b/.gitignore @@ -110,3 +110,6 @@ local-builds.gradle # gitignore for retrocompatibility, so that it won't appear as a new file and # be accidentally checked in the repository. google-upload-credentials.json + +# Kotlin +.kotlin/ diff --git a/WooCommerce-Wear/build.gradle b/WooCommerce-Wear/build.gradle index b82c097ea5a..b7b4296340b 100644 --- a/WooCommerce-Wear/build.gradle +++ b/WooCommerce-Wear/build.gradle @@ -3,6 +3,7 @@ import io.sentry.android.gradle.extensions.InstrumentationFeature plugins { alias(libs.plugins.android.application) alias(libs.plugins.kotlin.android) + alias(libs.plugins.kotlin.compose) alias(libs.plugins.kotlin.parcelize) alias(libs.plugins.google.dagger.hilt) alias(libs.plugins.ksp) @@ -77,19 +78,13 @@ android { } } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - kotlinOptions { - jvmTarget = '1.8' + sourceCompatibility libs.versions.java.get() + targetCompatibility libs.versions.java.get() } buildFeatures { buildConfig true compose true } - composeOptions { - kotlinCompilerExtensionVersion libs.versions.androidx.compose.compiler.get() - } packaging { resources { excludes += '/META-INF/{AL2.0,LGPL2.1}' diff --git a/WooCommerce/build.gradle b/WooCommerce/build.gradle index e0d799593dc..418c353d77d 100644 --- a/WooCommerce/build.gradle +++ b/WooCommerce/build.gradle @@ -3,6 +3,7 @@ import io.sentry.android.gradle.extensions.InstrumentationFeature plugins { alias(libs.plugins.android.application) alias(libs.plugins.kotlin.android) + alias(libs.plugins.kotlin.compose) alias(libs.plugins.kotlin.parcelize) alias(libs.plugins.google.dagger.hilt) alias(libs.plugins.sentry) @@ -145,15 +146,11 @@ android { } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility libs.versions.java.get() + targetCompatibility libs.versions.java.get() coreLibraryDesugaringEnabled true } - composeOptions { - kotlinCompilerExtensionVersion libs.versions.androidx.compose.compiler.get() - } - flavorDimensions "buildType" productFlavors { diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/login/LoginWhatIsJetpackDialogFragment.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/login/LoginWhatIsJetpackDialogFragment.kt index 34919503985..4a04d3fedea 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/login/LoginWhatIsJetpackDialogFragment.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/login/LoginWhatIsJetpackDialogFragment.kt @@ -18,6 +18,7 @@ class LoginWhatIsJetpackDialogFragment : DialogFragment() { const val TAG = "LoginWhatIsJetpackDialogFragment" } + @Deprecated("Deprecated in Java") @Suppress("DEPRECATION") override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/main/MainActivity.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/main/MainActivity.kt index 02d388da570..8b5f17d864e 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/main/MainActivity.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/main/MainActivity.kt @@ -435,6 +435,7 @@ class MainActivity : } } + @Deprecated("Deprecated in Java") override fun onBackPressed() { AnalyticsTracker.trackBackPressed(this) @@ -1231,6 +1232,7 @@ class MainActivity : ) } + @Deprecated("Deprecated in Java") override fun onAttachFragment(fragment: Fragment) { super.onAttachFragment(fragment) updateAppBarVisibility(fragment) diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/shippinglabels/PrintShippingLabelFragment.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/shippinglabels/PrintShippingLabelFragment.kt index a1bbfb248c4..1a5bd6b8f8c 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/shippinglabels/PrintShippingLabelFragment.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/shippinglabels/PrintShippingLabelFragment.kt @@ -67,6 +67,7 @@ class PrintShippingLabelFragment : BaseFragment(R.layout.fragment_print_shipping private fun setupToolbar(binding: FragmentPrintShippingLabelBinding) { binding.toolbar.title = getString(viewModel.screenTitle) binding.toolbar.setNavigationOnClickListener { + @Suppress("DEPRECATION") when { requireContext().windowSizeClass != WindowSizeClass.Compact && onRequestAllowBackPress() -> { findNavController().navigateUp() diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/categories/ParentCategoryListFragment.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/categories/ParentCategoryListFragment.kt index c01e06af72b..6f694586c45 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/categories/ParentCategoryListFragment.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/categories/ParentCategoryListFragment.kt @@ -60,6 +60,7 @@ class ParentCategoryListFragment : viewModel.fetchParentCategories() } + @Deprecated("Deprecated in Java") @Suppress("DEPRECATION") override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/categories/ProductCategoriesFragment.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/categories/ProductCategoriesFragment.kt index 64ecb836636..1e905fa83d6 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/categories/ProductCategoriesFragment.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/categories/ProductCategoriesFragment.kt @@ -133,6 +133,7 @@ class ProductCategoriesFragment : }) } + @Deprecated("Deprecated in Java") @Suppress("DEPRECATION") override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/list/ProductListAdapter.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/list/ProductListAdapter.kt index b751601dc43..c5dc6591fb5 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/list/ProductListAdapter.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/list/ProductListAdapter.kt @@ -15,7 +15,7 @@ import com.woocommerce.android.util.CurrencyFormatter typealias OnProductClickListener = (remoteProductId: Long, sharedView: View?) -> Unit class ProductListAdapter( - private inline val clickListener: OnProductClickListener? = null, + private val clickListener: OnProductClickListener? = null, private val loadMoreListener: OnLoadMoreListener, private val currencyFormatter: CurrencyFormatter, private val isProductHighlighted: (Long) -> Boolean, diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/variations/attributes/AttributeBaseAdapter.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/variations/attributes/AttributeBaseAdapter.kt index 559d5517f8c..e51e70044c7 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/variations/attributes/AttributeBaseAdapter.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/variations/attributes/AttributeBaseAdapter.kt @@ -7,7 +7,7 @@ import com.woocommerce.android.databinding.AttributeItemBinding import com.woocommerce.android.model.ProductAttribute abstract class AttributeBaseAdapter( - private inline val onItemClick: (attributeId: Long, attributeName: String) -> Unit + private val onItemClick: (attributeId: Long, attributeName: String) -> Unit ) : RecyclerView.Adapter() { private var attributeList = listOf() diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/reviews/ReviewDetailFragment.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/reviews/ReviewDetailFragment.kt index 73a41e2aa61..b8fe7ed95d5 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/reviews/ReviewDetailFragment.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/reviews/ReviewDetailFragment.kt @@ -81,6 +81,7 @@ class ReviewDetailFragment : return inflater.inflate(R.layout.fragment_review_detail, container, false) } + @Deprecated("Deprecated in Java") @Suppress("DEPRECATION") override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/reviews/ReviewModeration.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/reviews/ReviewModeration.kt index 980d0f52b84..d974e9bfce0 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/reviews/ReviewModeration.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/reviews/ReviewModeration.kt @@ -4,17 +4,11 @@ import com.woocommerce.android.model.ActionStatus import com.woocommerce.android.model.ActionStatus.PENDING import com.woocommerce.android.model.ProductReview -@Suppress("DataClassPrivateConstructor") -data class ReviewModerationRequest private constructor( +data class ReviewModerationRequest( val review: ProductReview, val newStatus: ProductReviewStatus, - private val timeOfRequest: Long ) : Comparable { - constructor(review: ProductReview, newStatus: ProductReviewStatus) : this( - review, - newStatus, - System.currentTimeMillis() - ) + private val timeOfRequest = System.currentTimeMillis() override fun compareTo(other: ReviewModerationRequest): Int { return timeOfRequest.compareTo(other.timeOfRequest) diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/widgets/ItemDecorators.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/widgets/ItemDecorators.kt index 72ee2e68d1f..a963cc4ae84 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/widgets/ItemDecorators.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/widgets/ItemDecorators.kt @@ -23,6 +23,7 @@ class GridItemDecoration( } class HorizontalItemDecoration(private val spacing: Int) : ItemDecoration() { + @Deprecated("Deprecated in Java") override fun getItemOffsets(outRect: Rect, itemPosition: Int, parent: RecyclerView) { outRect.left = spacing outRect.right = spacing diff --git a/WooCommerce/src/test/kotlin/com/woocommerce/android/ui/analytics/UpdateAnalyticsHubStatsTest.kt b/WooCommerce/src/test/kotlin/com/woocommerce/android/ui/analytics/UpdateAnalyticsHubStatsTest.kt index 44a98a58550..273c6eace45 100644 --- a/WooCommerce/src/test/kotlin/com/woocommerce/android/ui/analytics/UpdateAnalyticsHubStatsTest.kt +++ b/WooCommerce/src/test/kotlin/com/woocommerce/android/ui/analytics/UpdateAnalyticsHubStatsTest.kt @@ -383,6 +383,10 @@ internal class UpdateAnalyticsHubStatsTest : BaseUnitTest() { @Test fun `when data store allows new stats fetch, then request data with ForceNew strategy`() = testBlocking { + // Given + whenever(repository.fetchVisitorsData(testRangeSelection, ForceNew)) + .doReturn(testVisitorsResult) + // When sut(testRangeSelection, this) @@ -409,6 +413,8 @@ internal class UpdateAnalyticsHubStatsTest : BaseUnitTest() { analyticsUpdateDataStore = analyticsDataStore, analyticsRepository = repository ) + whenever(repository.fetchVisitorsData(testRangeSelection, Saved)) + .doReturn(testVisitorsResult) // When sut(testRangeSelection, this) @@ -437,6 +443,8 @@ internal class UpdateAnalyticsHubStatsTest : BaseUnitTest() { analyticsUpdateDataStore = analyticsDataStore, analyticsRepository = repository ) + whenever(repository.fetchVisitorsData(testCustomRangeSelection, Saved)) + .doReturn(testVisitorsResult) // When sut(testCustomRangeSelection, this) @@ -457,6 +465,8 @@ internal class UpdateAnalyticsHubStatsTest : BaseUnitTest() { analyticsUpdateDataStore = analyticsDataStore, analyticsRepository = repository ) + whenever(repository.fetchVisitorsData(testRangeSelection, ForceNew)) + .doReturn(testVisitorsResult) // When sut(testRangeSelection, this, true) @@ -490,6 +500,8 @@ internal class UpdateAnalyticsHubStatsTest : BaseUnitTest() { analyticsUpdateDataStore = analyticsDataStore, analyticsRepository = repository ) + whenever(repository.fetchVisitorsData(testRangeSelection, Saved)) + .doReturn(testVisitorsResult) // When sut(testRangeSelection, this, false) @@ -539,6 +551,8 @@ internal class UpdateAnalyticsHubStatsTest : BaseUnitTest() { analyticsUpdateDataStore = analyticsDataStore, analyticsRepository = repository ) + whenever(repository.fetchVisitorsData(eq(testRangeSelection), any())) + .doReturn(testVisitorsResult) // When sut(testRangeSelection, this) diff --git a/build.gradle b/build.gradle index b5df01ef33e..8a338fb7a89 100644 --- a/build.gradle +++ b/build.gradle @@ -10,6 +10,7 @@ plugins { alias(libs.plugins.android.library) apply false alias(libs.plugins.android.test) apply false alias(libs.plugins.kotlin.android) apply false + alias(libs.plugins.kotlin.compose).apply(false) alias(libs.plugins.kotlin.parcelize) apply false alias(libs.plugins.google.dagger.hilt) apply false alias(libs.plugins.androidx.navigation.safeargs) apply false @@ -34,7 +35,7 @@ allprojects { tasks.withType(KotlinCompile).all { kotlinOptions { - jvmTarget = JavaVersion.VERSION_1_8 + jvmTarget = libs.versions.java.get() allWarningsAsErrors = true freeCompilerArgs += [ "-opt-in=kotlin.RequiresOptIn", diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 80c219995b4..6cb4df8f5fa 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -10,7 +10,6 @@ androidx-browser = '1.5.0' androidx-camera = '1.2.3' androidx-cardview = '1.0.0' androidx-compose-bom = '2024.04.00' -androidx-compose-compiler = '1.5.9' androidx-constraintlayout-compose = '1.0.1' androidx-constraintlayout-main = '2.1.4' androidx-core-main = '1.13.1' @@ -70,12 +69,13 @@ google-services = '4.4.0' google-zxing = '3.5.3' gravatar = '0.2.0' jackson-databind = '2.12.7.1' +java = '11' jetty-webapp = '9.4.51.v20230217' json-path = '2.9.0' junit = '4.13.2' -kotlin = '1.9.22' +kotlin = '2.0.21' kotlinx-coroutines = '1.8.1' -ksp = '1.9.22-1.0.17' +ksp = '2.0.21-1.0.27' mockito-inline = '4.6.1' mockito-kotlin = '4.0.0' mpandroidchart = 'v3.1.0' @@ -246,6 +246,7 @@ google-dagger-hilt = { id = "com.google.dagger.hilt.android", version.ref = "goo google-protobuf = { id = "com.google.protobuf", version.ref = "google-protobuf-plugin" } google-services = { id = "com.google.gms.google-services", version.ref = "google-services" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } +kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" } ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } sentry = { id = "io.sentry.android.gradle", version.ref = "sentry" } diff --git a/libs/cardreader/build.gradle b/libs/cardreader/build.gradle index 6a1203bf7e9..4a082ede46f 100644 --- a/libs/cardreader/build.gradle +++ b/libs/cardreader/build.gradle @@ -21,8 +21,8 @@ android { } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility libs.versions.java.get() + targetCompatibility libs.versions.java.get() } } diff --git a/libs/commons/build.gradle b/libs/commons/build.gradle index a0d38063d6a..90a85c52ca1 100644 --- a/libs/commons/build.gradle +++ b/libs/commons/build.gradle @@ -13,10 +13,7 @@ android { } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - kotlinOptions { - jvmTarget = '1.8' + sourceCompatibility libs.versions.java.get() + targetCompatibility libs.versions.java.get() } } diff --git a/libs/iap/build.gradle b/libs/iap/build.gradle index 0fcddd4cc9c..e116e9b8001 100644 --- a/libs/iap/build.gradle +++ b/libs/iap/build.gradle @@ -20,8 +20,8 @@ android { } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility libs.versions.java.get() + targetCompatibility libs.versions.java.get() } } diff --git a/quicklogin/build.gradle b/quicklogin/build.gradle index c2d921eba06..777990b5d42 100644 --- a/quicklogin/build.gradle +++ b/quicklogin/build.gradle @@ -66,8 +66,8 @@ android { } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility libs.versions.java.get() + targetCompatibility libs.versions.java.get() } buildFeatures {