From 31ddb8693adad46704a59adb7c4dad28b65260f2 Mon Sep 17 00:00:00 2001 From: Tobias Zwick Date: Thu, 23 May 2024 19:08:16 +0200 Subject: [PATCH 1/2] update kotlin + gradle + agp --- app/build.gradle.kts | 7 ++----- .../streetcomplete/quests/smoothness/SmoothnessItem.kt | 2 +- build.gradle.kts | 4 ++-- buildSrc/build.gradle.kts | 4 ++-- gradle/wrapper/gradle-wrapper.properties | 2 +- 5 files changed, 8 insertions(+), 11 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 10edc6bdd9..5ea291eba5 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -5,7 +5,8 @@ import java.util.Properties plugins { id("com.android.application") kotlin("android") - kotlin("plugin.serialization") version "1.9.23" + kotlin("plugin.serialization") version "2.0.0" + kotlin("plugin.compose") version "2.0.0" } android { @@ -69,10 +70,6 @@ android { compose = true } - composeOptions { - kotlinCompilerExtensionVersion = "1.5.12" - } - bundle { language { enableSplit = false // because language is selectable in-app diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/smoothness/SmoothnessItem.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/smoothness/SmoothnessItem.kt index 8a796bc298..858eecc82d 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/smoothness/SmoothnessItem.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/smoothness/SmoothnessItem.kt @@ -49,7 +49,7 @@ fun Smoothness.asItem(context: Context, surface: String): DisplayItem R.drawable.ic_smoothness_skateboard GOOD -> R.drawable.ic_smoothness_scooter INTERMEDIATE -> R.drawable.ic_smoothness_city_bike diff --git a/build.gradle.kts b/build.gradle.kts index d5fda83b3d..ac51a90f51 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,8 +4,8 @@ buildscript { mavenCentral() } dependencies { - val kotlinVersion = "1.9.23" - classpath("com.android.tools.build:gradle:8.3.2") + val kotlinVersion = "2.0.0" + classpath("com.android.tools.build:gradle:8.4.1") classpath(kotlin("gradle-plugin", version = kotlinVersion)) } } diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index bcdec54493..a0783bad8c 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -8,8 +8,8 @@ dependencies { implementation("de.westnordost:countryboundaries:2.1") implementation("com.esotericsoftware.yamlbeans:yamlbeans:1.15") implementation("org.jsoup:jsoup:1.15.3") - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2") - implementation("com.charleskorn.kaml:kaml:0.58.0") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3") + implementation("com.charleskorn.kaml:kaml:0.59.0") implementation("org.jetbrains:markdown:0.7.0") } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 36c9baf650..cbf1b3ea9f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip zipStoreBase=GRADLE_USER_HOME From 6896fef296d5ef65efe4b1d28d4f6b526d766730 Mon Sep 17 00:00:00 2001 From: Tobias Zwick Date: Thu, 23 May 2024 19:56:48 +0200 Subject: [PATCH 2/2] lint --- .../data/urlconfig/UrlConfig.kt | 2 +- .../data/user/oauth/OAuthService.kt | 4 +-- .../osm/street_parking/StreetParking.kt | 8 +++--- .../overlays/places/PlacesOverlayForm.kt | 4 +-- .../quests/smoothness/AddSmoothnessForm.kt | 2 -- .../screens/TwoPaneHeaderFragment.kt | 1 - .../main/edithistory/EditHistoryFragment.kt | 1 - .../streetcomplete/util/ktx/Context.kt | 13 --------- .../streetcomplete/util/ktx/LocalDate.kt | 2 -- .../view/GridLayoutSpacingItemDecoration.kt | 27 ------------------- .../res/layout/labeled_icon_button_cell.xml | 2 +- app/src/main/res/values-w720dp/dimens.xml | 6 ----- 12 files changed, 10 insertions(+), 62 deletions(-) delete mode 100644 app/src/main/java/de/westnordost/streetcomplete/view/GridLayoutSpacingItemDecoration.kt delete mode 100644 app/src/main/res/values-w720dp/dimens.xml diff --git a/app/src/main/java/de/westnordost/streetcomplete/data/urlconfig/UrlConfig.kt b/app/src/main/java/de/westnordost/streetcomplete/data/urlconfig/UrlConfig.kt index b90f7ada33..a39320d8f1 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/data/urlconfig/UrlConfig.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/data/urlconfig/UrlConfig.kt @@ -45,7 +45,7 @@ fun parseConfigUrl( keyValue[0].lowercase() to keyValue[1] } - val name = parameters[PARAM_NAME]?.let { it.decodeURLQueryComponent(plusIsSpace = true) } + val name = parameters[PARAM_NAME]?.decodeURLQueryComponent(plusIsSpace = true) val questTypesString = parameters[PARAM_QUESTS] ?: return null val questTypes = stringToQuestTypes(questTypesString, questTypeRegistry) ?: return null diff --git a/app/src/main/java/de/westnordost/streetcomplete/data/user/oauth/OAuthService.kt b/app/src/main/java/de/westnordost/streetcomplete/data/user/oauth/OAuthService.kt index 66c80f6d67..c19e1d7cb1 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/data/user/oauth/OAuthService.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/data/user/oauth/OAuthService.kt @@ -102,7 +102,7 @@ class OAuthService(private val httpClient: HttpClient) { * and required in the OAuth 2.1 draft * https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-09 */ - public val codeVerifier: String = createRandomAlphanumericString(128) + val codeVerifier: String = createRandomAlphanumericString(128) /** * Creates the URL to be opened in the browser or a web view in which the user agrees to @@ -144,7 +144,7 @@ class OAuthService(private val httpClient: HttpClient) { * the user did not accept the requested permissions * @throws OAuthConnectionException if the server reply is malformed */ -public fun extractAuthorizationCode(uri: String): String { +fun extractAuthorizationCode(uri: String): String { val parameters = Url(uri).parameters val authorizationCode = parameters["code"] if (authorizationCode != null) return authorizationCode diff --git a/app/src/main/java/de/westnordost/streetcomplete/osm/street_parking/StreetParking.kt b/app/src/main/java/de/westnordost/streetcomplete/osm/street_parking/StreetParking.kt index 236bf3e9dd..cfe5c0e4ca 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/osm/street_parking/StreetParking.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/osm/street_parking/StreetParking.kt @@ -8,13 +8,13 @@ data class LeftAndRightStreetParking(val left: StreetParking?, val right: Street @Serializable sealed class StreetParking -@Serializable object NoStreetParking : StreetParking() +@Serializable data object NoStreetParking : StreetParking() /** When an unknown/unsupported value has been used */ -@Serializable object UnknownStreetParking : StreetParking() +@Serializable data object UnknownStreetParking : StreetParking() /** When not both parking orientation and position have been specified*/ -@Serializable object IncompleteStreetParking : StreetParking() +@Serializable data object IncompleteStreetParking : StreetParking() /** There is street parking, but it is mapped as separate geometry */ -@Serializable object StreetParkingSeparate : StreetParking() +@Serializable data object StreetParkingSeparate : StreetParking() @Serializable data class StreetParkingPositionAndOrientation( val orientation: ParkingOrientation, diff --git a/app/src/main/java/de/westnordost/streetcomplete/overlays/places/PlacesOverlayForm.kt b/app/src/main/java/de/westnordost/streetcomplete/overlays/places/PlacesOverlayForm.kt index b7ec9402de..ac00e92a1d 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/overlays/places/PlacesOverlayForm.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/overlays/places/PlacesOverlayForm.kt @@ -195,7 +195,7 @@ class PlacesOverlayForm : AbstractOverlayForm() { and if that feature doesn't already set a name (i.e. is a brand) */ val isNameInputInvisible = selectedFeature == null || - selectedFeature.addTags?.get("name") != null || + selectedFeature.addTags["name"] != null || selectedFeature.id == "shop/vacant" binding.nameContainer.root.isGone = isNameInputInvisible @@ -261,7 +261,7 @@ private suspend fun createEditAction( val hasAddedNames = previousNames.isEmpty() && newNames.isNotEmpty() val hasChangedNames = previousNames != newNames val hasChangedFeature = newFeature != previousFeature - val isFeatureWithName = newFeature.addTags?.get("name") != null + val isFeatureWithName = newFeature.addTags.get("name") != null val wasFeatureWithName = previousFeature?.addTags?.get("name") != null val wasVacant = element != null && element.isDisusedPlace() val isVacant = newFeature.id == "shop/vacant" diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/smoothness/AddSmoothnessForm.kt b/app/src/main/java/de/westnordost/streetcomplete/quests/smoothness/AddSmoothnessForm.kt index 802c318f20..7e83ff4c50 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/smoothness/AddSmoothnessForm.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/smoothness/AddSmoothnessForm.kt @@ -20,8 +20,6 @@ import de.westnordost.streetcomplete.view.image_select.ItemViewHolder class AddSmoothnessForm : AImageListQuestForm() { - private val binding by contentViewBinding(QuestGenericListBinding::bind) - override val otherAnswers get() = listOfNotNull( AnswerItem(R.string.quest_smoothness_wrong_surface) { surfaceWrong() }, createConvertToStepsAnswer(), diff --git a/app/src/main/java/de/westnordost/streetcomplete/screens/TwoPaneHeaderFragment.kt b/app/src/main/java/de/westnordost/streetcomplete/screens/TwoPaneHeaderFragment.kt index 745a0329a7..a93f10bb07 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/screens/TwoPaneHeaderFragment.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/screens/TwoPaneHeaderFragment.kt @@ -8,7 +8,6 @@ import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager.FragmentLifecycleCallbacks import androidx.preference.PreferenceHeaderFragmentCompat -import de.westnordost.streetcomplete.R /** A two pane preferences fragment that dispatches updates of its pane state to its children. */ abstract class TwoPaneHeaderFragment : PreferenceHeaderFragmentCompat() { diff --git a/app/src/main/java/de/westnordost/streetcomplete/screens/main/edithistory/EditHistoryFragment.kt b/app/src/main/java/de/westnordost/streetcomplete/screens/main/edithistory/EditHistoryFragment.kt index 4adcce9b72..695896d32e 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/screens/main/edithistory/EditHistoryFragment.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/screens/main/edithistory/EditHistoryFragment.kt @@ -12,7 +12,6 @@ import de.westnordost.streetcomplete.util.ktx.toast import de.westnordost.streetcomplete.util.ktx.viewLifecycleScope import de.westnordost.streetcomplete.util.viewBinding import de.westnordost.streetcomplete.view.insets_animation.respectSystemInsets -import kotlinx.coroutines.flow.firstOrNull import kotlinx.coroutines.launch import org.koin.androidx.viewmodel.ext.android.viewModel diff --git a/app/src/main/java/de/westnordost/streetcomplete/util/ktx/Context.kt b/app/src/main/java/de/westnordost/streetcomplete/util/ktx/Context.kt index 134b5e1220..5f65972473 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/util/ktx/Context.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/util/ktx/Context.kt @@ -35,19 +35,6 @@ val Context.hasLocationPermission: Boolean get() = hasPermission(ACCESS_FINE_LOC private val Context.locationManager get() = getSystemService()!! -/** Await a call from a broadcast once and return it */ -suspend fun Context.awaitReceiverCall(intentFilter: IntentFilter): Intent = - suspendCancellableCoroutine { continuation -> - val receiver = object : BroadcastReceiver() { - override fun onReceive(context: Context, intent: Intent) { - unregisterReceiver(this) - continuation.resume(intent) - } - } - registerReceiver(receiver, intentFilter) - continuation.invokeOnCancellation { unregisterReceiver(receiver) } - } - fun Context.sendEmail(email: String, subject: String, text: String? = null) { val intent = Intent(Intent.ACTION_SENDTO).apply { data = "mailto:".toUri() diff --git a/app/src/main/java/de/westnordost/streetcomplete/util/ktx/LocalDate.kt b/app/src/main/java/de/westnordost/streetcomplete/util/ktx/LocalDate.kt index b3a48a43f6..2a8e2f54bc 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/util/ktx/LocalDate.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/util/ktx/LocalDate.kt @@ -1,5 +1,3 @@ -@file:Suppress("NOTHING_TO_INLINE") - package de.westnordost.streetcomplete.util.ktx import kotlinx.datetime.Clock diff --git a/app/src/main/java/de/westnordost/streetcomplete/view/GridLayoutSpacingItemDecoration.kt b/app/src/main/java/de/westnordost/streetcomplete/view/GridLayoutSpacingItemDecoration.kt deleted file mode 100644 index 8e81927d03..0000000000 --- a/app/src/main/java/de/westnordost/streetcomplete/view/GridLayoutSpacingItemDecoration.kt +++ /dev/null @@ -1,27 +0,0 @@ -package de.westnordost.streetcomplete.view - -import android.graphics.Rect -import android.view.View -import androidx.recyclerview.widget.GridLayoutManager -import androidx.recyclerview.widget.RecyclerView - -/** Item decoration that adds a spacing between the items for RecyclerView that uses a GridLayoutManager*/ -class GridLayoutSpacingItemDecoration(private val spacingInPx: Int) : RecyclerView.ItemDecoration() { - override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) { - val position = parent.getChildAdapterPosition(view) - val count = parent.adapter?.itemCount ?: 0 - val layoutManager = parent.layoutManager as GridLayoutManager - - val spanCount = layoutManager.spanCount - val spanSizeLookup = layoutManager.spanSizeLookup - - val row = spanSizeLookup.getSpanGroupIndex(position, spanCount) - val span = spanSizeLookup.getSpanIndex(position, spanCount) - val rowCount = spanSizeLookup.getSpanGroupIndex(count - 1, spanCount) + 1 - - outRect.left = if (span > 0) spacingInPx / 2 else 0 - outRect.right = if (span < spanCount - 1) spacingInPx / 2 else 0 - outRect.top = if (row > 0) spacingInPx / 2 else 0 - outRect.bottom = if (row < rowCount - 1) spacingInPx / 2 else 0 - } -} diff --git a/app/src/main/res/layout/labeled_icon_button_cell.xml b/app/src/main/res/layout/labeled_icon_button_cell.xml index e117d5ca76..3374ff8b71 100644 --- a/app/src/main/res/layout/labeled_icon_button_cell.xml +++ b/app/src/main/res/layout/labeled_icon_button_cell.xml @@ -17,7 +17,7 @@ android:scaleType="fitCenter" android:adjustViewBounds="true" android:background="#3666" - tools:src="@drawable/ic_cycleway_lane"/> + tools:src="@drawable/ic_cycleway_lane_white"/> - - 12dp - 24dp - -