Skip to content

Commit

Permalink
Merge pull request #5799 from streetcomplete/compose-edithistory
Browse files Browse the repository at this point in the history
Migrate main screen to Compose
  • Loading branch information
westnordost authored Oct 30, 2024
2 parents fe52bc9 + 6fd8738 commit 2c2d8c5
Show file tree
Hide file tree
Showing 161 changed files with 4,811 additions and 3,909 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ dependencies {
implementation("androidx.localbroadcastmanager:localbroadcastmanager:1.1.0")

// Jetpack Compose
val composeBom = platform("androidx.compose:compose-bom:2024.09.02")
val composeBom = platform("androidx.compose:compose-bom:2024.10.00")
implementation(composeBom)
androidTestImplementation(composeBom)
implementation("androidx.compose.material:material")
Expand All @@ -145,7 +145,7 @@ dependencies {
implementation("androidx.compose.ui:ui-tooling-preview")
debugImplementation("androidx.compose.ui:ui-tooling")

implementation("androidx.navigation:navigation-compose:2.8.1")
implementation("androidx.navigation:navigation-compose:2.8.3")

implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.6")
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.8.6")
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@
android:supportsRtl="true">
<activity
android:windowSoftInputMode="adjustResize"
android:name="de.westnordost.streetcomplete.screens.MainActivity"
android:name="de.westnordost.streetcomplete.screens.main.MainActivity"
android:configChanges="orientation|screenSize|screenLayout"
android:launchMode="singleTop"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down Expand Up @@ -77,7 +78,7 @@
<activity
android:name="de.westnordost.streetcomplete.screens.settings.SettingsActivity"
android:label="@string/action_settings"
android:parentActivityName="de.westnordost.streetcomplete.screens.MainActivity"
android:parentActivityName="de.westnordost.streetcomplete.screens.main.MainActivity"
android:configChanges="density|fontScale|keyboard|keyboardHidden|layoutDirection|locale|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode"
android:exported="true">
<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ object ApplicationConstants {
const val NOTIFICATIONS_CHANNEL_SYNC = "downloading"
const val NOTIFICATIONS_ID_SYNC = 1

// where to send the error reports to
const val ERROR_REPORTS_EMAIL = "[email protected]"

const val STREETMEASURE = "de.westnordost.streetmeasure"

val IGNORED_RELATION_TYPES = setOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ val appModule = module {
factory<AssetManager> { androidContext().assets }
factory<Resources> { androidContext().resources }

single { CrashReportExceptionHandler(androidContext(), get(), "[email protected]", "crashreport.txt") }
single { CrashReportExceptionHandler(androidContext(), get(), "crashreport.txt") }
single { DatabaseLogger(get()) }
single { SoundFx(androidContext()) }
single { HttpClient {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ val downloadModule = module {
factory { MobileDataAutoDownloadStrategy(get(), get()) }
factory { WifiAutoDownloadStrategy(get(), get()) }

single { Downloader(get(), get(), get(), get(), get(named("SerializeSync"))) }
single { Downloader(get(), get(), get(), get(), get(), get(named("SerializeSync"))) }

single<DownloadProgressSource> { get<Downloader>() }
single { DownloadController(get()) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package de.westnordost.streetcomplete.data.download

import de.westnordost.streetcomplete.ApplicationConstants
import de.westnordost.streetcomplete.data.AuthorizationException
import de.westnordost.streetcomplete.data.download.tiles.DownloadedTilesController
import de.westnordost.streetcomplete.data.download.tiles.TilesRect
import de.westnordost.streetcomplete.data.download.tiles.enclosingTilesRect
import de.westnordost.streetcomplete.data.maptiles.MapTilesDownloader
import de.westnordost.streetcomplete.data.osm.mapdata.BoundingBox
import de.westnordost.streetcomplete.data.osm.mapdata.MapDataDownloader
import de.westnordost.streetcomplete.data.osmnotes.NotesDownloader
import de.westnordost.streetcomplete.data.user.UserLoginController
import de.westnordost.streetcomplete.util.Listeners
import de.westnordost.streetcomplete.util.ktx.format
import de.westnordost.streetcomplete.util.ktx.nowAsEpochMilliseconds
Expand All @@ -26,6 +28,7 @@ class Downloader(
private val mapDataDownloader: MapDataDownloader,
private val mapTilesDownloader: MapTilesDownloader,
private val downloadedTilesController: DownloadedTilesController,
private val userLoginController: UserLoginController,
private val mutex: Mutex
) : DownloadProgressSource {

Expand Down Expand Up @@ -80,6 +83,9 @@ class Downloader(
} catch (e: Exception) {
hasError = true
Log.e(TAG, "Unable to download", e)
if (e is AuthorizationException) {
userLoginController.logOut()
}
listeners.forEach { it.onError(e) }
throw e
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package de.westnordost.streetcomplete.data.edithistory
import de.westnordost.streetcomplete.data.osm.mapdata.LatLon
import de.westnordost.streetcomplete.data.quest.OsmNoteQuestKey
import de.westnordost.streetcomplete.data.quest.OsmQuestKey
import kotlinx.serialization.Serializable

interface Edit {
val key: EditKey
Expand All @@ -12,9 +13,14 @@ interface Edit {
val isSynced: Boolean?
}

@Serializable
sealed class EditKey

@Serializable
data class ElementEditKey(val id: Long) : EditKey()
@Serializable
data class NoteEditKey(val id: Long) : EditKey()
@Serializable
data class OsmQuestHiddenKey(val osmQuestKey: OsmQuestKey) : EditKey()
@Serializable
data class OsmNoteQuestHiddenKey(val osmNoteQuestKey: OsmNoteQuestKey) : EditKey()
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class MessagesSource(
private val changelog: Changelog,
) {
/* Must be a singleton because there is a listener that should respond to a change in the
* database table*/
* database table */

interface UpdateListener {
fun onNumberOfMessagesUpdated(messageCount: Int)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import androidx.core.app.PendingIntentCompat
import de.westnordost.streetcomplete.ApplicationConstants.NAME
import de.westnordost.streetcomplete.ApplicationConstants.NOTIFICATIONS_CHANNEL_SYNC
import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.screens.MainActivity
import de.westnordost.streetcomplete.screens.main.MainActivity

/** Creates the notification for syncing in the Android notifications area. Used both by the upload
* and by the download service. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import org.koin.dsl.module
val uploadModule = module {
factory { VersionIsBannedChecker(get(), "https://www.westnordost.de/streetcomplete/banned_versions.txt", ApplicationConstants.USER_AGENT) }

single { Uploader(get(), get(), get(), get(), get(), get(named("SerializeSync"))) }
single { Uploader(get(), get(), get(), get(), get(), get(), get(named("SerializeSync"))) }
/* uploading and downloading should be serialized, i.e. may not run in parallel, to avoid
* certain race-condition.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import de.westnordost.streetcomplete.data.download.tiles.enclosingTilePos
import de.westnordost.streetcomplete.data.osm.edits.upload.ElementEditsUploader
import de.westnordost.streetcomplete.data.osm.mapdata.LatLon
import de.westnordost.streetcomplete.data.osmnotes.edits.NoteEditsUploader
import de.westnordost.streetcomplete.data.user.UserLoginController
import de.westnordost.streetcomplete.data.user.UserLoginSource
import de.westnordost.streetcomplete.util.Listeners
import de.westnordost.streetcomplete.util.logs.Log
Expand All @@ -20,6 +21,7 @@ class Uploader(
private val downloadedTilesController: DownloadedTilesController,
private val userLoginSource: UserLoginSource,
private val versionIsBannedChecker: VersionIsBannedChecker,
private val userLoginController: UserLoginController,
private val mutex: Mutex
) : UploadProgressSource {

Expand Down Expand Up @@ -77,6 +79,9 @@ class Uploader(
Log.i(TAG, "Upload cancelled")
} catch (e: Exception) {
Log.e(TAG, "Unable to upload", e)
if (e is AuthorizationException) {
userLoginController.logOut()
}
listeners.forEach { it.onError(e) }
throw e
} finally {
Expand Down
Loading

0 comments on commit 2c2d8c5

Please sign in to comment.