Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-do UI of About screens and Settings screens in Compose #5719

Merged
merged 96 commits into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
9eb3d85
work in progress preferences class
westnordost Mar 27, 2024
75de46f
fix compilation
westnordost Mar 27, 2024
4bea262
fix compilation
westnordost Mar 27, 2024
69fe759
work in progress
westnordost May 23, 2024
5b28d90
clarify todo
westnordost May 23, 2024
94923aa
Merge branch 'master' into compose-about
westnordost May 23, 2024
643f06d
Merge branch 'master' into compose-about
westnordost May 23, 2024
7090d3a
prefix todo
westnordost May 23, 2024
7114296
fix setting filters didn't work
westnordost May 23, 2024
8ce79e7
scroll to bottom
westnordost May 26, 2024
fcf9f12
fix logs update
westnordost May 26, 2024
cd8f584
move StringWithCursor to util package and add a few functions
westnordost May 27, 2024
eba4f63
make cursor public
westnordost May 27, 2024
f16d5f6
add HtmlMarkupParser
westnordost May 27, 2024
a8882c1
add tests etc
westnordost May 28, 2024
d8dd9e0
move dp functions into ktx package
westnordost May 29, 2024
8f640b5
make parser more lenient (this is inside html spec)
westnordost May 29, 2024
cfe48a6
fix iso control stuff
westnordost May 29, 2024
50d817e
add List<HtmlNode>.toAnnotatedString()
westnordost May 29, 2024
9229faa
add HtmlText composable
westnordost May 30, 2024
6b21127
implement CreditsScreen
westnordost May 30, 2024
bae5a49
a bit more compact
westnordost May 30, 2024
0648a66
add PrivacyStatement screen
westnordost May 30, 2024
d18eaa1
fix html parser whitespace behavior
westnordost May 30, 2024
5a971e9
preview more
westnordost May 30, 2024
b170d92
hmm
westnordost May 30, 2024
84dfd71
more whitespace fixes
westnordost May 31, 2024
58e0c23
yet more html parser whitepace stuff (but simplified the code)
westnordost May 31, 2024
8d84293
Merge branch 'compose-about' into compose-about-in-tex
westnordost May 31, 2024
59cc012
finish basic html styling...
westnordost May 31, 2024
b1b659d
Merge branch 'compose-about-in-tex' into compose-about
westnordost May 31, 2024
48fd264
add changelog screen
westnordost May 31, 2024
4518e6b
Merge branch 'master' into compose-about
westnordost Jun 2, 2024
530a7ee
fix screen did not scroll
westnordost Jun 2, 2024
0a90bc0
implement whats-new dialog
westnordost Jun 2, 2024
b78fbe9
fix scrolling in dialog
westnordost Jun 2, 2024
0025768
Merge branch 'master' into compose-about
westnordost Jun 17, 2024
5fd0b57
don't crash on html parse error, instead just display the raw string
westnordost Jun 17, 2024
4faf20f
connect all the sub-screens in about screen with navigation component
westnordost Jun 17, 2024
c034692
move some files
westnordost Jun 17, 2024
2624457
gr
westnordost Jun 17, 2024
ff79886
wip quest selection screen
westnordost Jun 17, 2024
f02c1bb
more wip quest selection screen
westnordost Jun 18, 2024
8455e97
don't implement reordering (for now)
westnordost Jun 18, 2024
034cc93
add todo
westnordost Jun 18, 2024
1907aca
various tiny improvements
westnordost Jun 19, 2024
6c5c48d
no need for lambda
westnordost Jun 19, 2024
01ae238
implement quest selection
westnordost Jun 19, 2024
cefbf67
fix bug
westnordost Jun 20, 2024
ac91138
implement the non-fragment part of ShowQuestsFormsActivity in Compose
westnordost Jun 20, 2024
51c04d2
remove unused function
westnordost Jun 20, 2024
2345ff7
quest presets screen almost done...
westnordost Jun 21, 2024
32c227a
move ResurveyIntervalsUpdater to data directory
westnordost Jun 22, 2024
de50558
remove two pane settings fragment
westnordost Jun 22, 2024
22129ae
connect urlconfig dialog
westnordost Jun 22, 2024
2ea73a8
fix dark mode
westnordost Jun 22, 2024
c5d0c42
fix dark mode
westnordost Jun 22, 2024
ef611c2
add todo
westnordost Jun 22, 2024
2b75b6d
add infodialog, move into dialogs package
westnordost Jun 24, 2024
ac3622c
add some icons
westnordost Jun 24, 2024
def7a78
rename destination object
westnordost Jun 24, 2024
802322d
settings screen wip
westnordost Jun 24, 2024
e80097f
more wip on settings etc.
westnordost Jun 26, 2024
ae56964
remove cache size setting (dial up default to 200MB)
westnordost Jun 26, 2024
16780de
Add note about that one should write in local language (fixes #5710)
westnordost Jun 26, 2024
e0f1124
use listpicker that doesn't reserve the whole screen for itsel
westnordost Jun 28, 2024
0c63d3e
fix selection wasn't applied
westnordost Jun 28, 2024
a0f2aaa
sort languages by alphabet
westnordost Jun 28, 2024
c7d7b4a
Merge branch 'master' into compose-settings
westnordost Jun 28, 2024
e199944
some small things...
westnordost Jun 28, 2024
612841d
use multiplatform bignumber library
westnordost Jun 28, 2024
3c350d9
add comment that makes clear that ScrollableAlertDialog (and SimpleLi…
westnordost Jun 28, 2024
6724289
Merge branch 'compose-settings' into preferences-class
westnordost Jun 28, 2024
11e30e5
replace lastpickedvaluesstore
westnordost Jul 1, 2024
2a81c1a
remove unused imports
westnordost Jul 1, 2024
bb89e93
eliminate direct access of ObservableSettings - everything shall go t…
westnordost Jul 1, 2024
6daeaed
eliminate some unnecessary indirection
westnordost Jul 1, 2024
a28bba6
remove reference to deleted activity
westnordost Jul 3, 2024
80eeb5f
remove listener on clear
westnordost Jul 3, 2024
54a82ca
remove unused import
westnordost Jul 3, 2024
024bb04
typo
westnordost Jul 3, 2024
7f8d8cc
add comment
westnordost Jul 3, 2024
241d64b
rename function
westnordost Jul 4, 2024
e3d9301
add comment
westnordost Jul 4, 2024
bf70ee2
move default constants to Preferences class
westnordost Jul 4, 2024
8958a7c
fixes logs screen
westnordost Jul 4, 2024
d24fd02
add comment
westnordost Jul 4, 2024
8ae505b
revert change to a string
westnordost Jul 4, 2024
34bbb7e
typo
westnordost Jul 4, 2024
6dba07f
add doc comment
westnordost Jul 4, 2024
4c547c1
add note about performance issue
westnordost Jul 4, 2024
c843a4b
user and settings activity should not be restarted on rotate screen etc.
westnordost Jul 4, 2024
1a3c936
properly order the strings
westnordost Jul 4, 2024
fc4d52c
add filters-counter
westnordost Jul 4, 2024
3f57092
shorter log
westnordost Jul 4, 2024
d2398fb
rather use ok and cancel as button labels, no reset
westnordost Jul 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ dependencies {
implementation("io.insert-koin:koin-core")
implementation("io.insert-koin:koin-android")
implementation("io.insert-koin:koin-androidx-workmanager")
implementation("io.insert-koin:koin-androidx-compose")

// Android stuff
implementation("com.google.android.material:material:1.12.0")
Expand All @@ -138,7 +139,6 @@ dependencies {
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("androidx.annotation:annotation:1.8.0")
implementation("androidx.fragment:fragment-ktx:1.8.1")
implementation("androidx.preference:preference-ktx:1.2.1")
implementation("androidx.recyclerview:recyclerview:1.3.2")
implementation("androidx.viewpager:viewpager:1.0.0")
implementation("androidx.localbroadcastmanager:localbroadcastmanager:1.1.0")
Expand All @@ -148,10 +148,13 @@ dependencies {
implementation(composeBom)
androidTestImplementation(composeBom)
implementation("androidx.compose.material:material")
implementation("androidx.activity:activity-compose")
// Jetpack Compose Previews
implementation("androidx.compose.ui:ui-tooling-preview")
debugImplementation("androidx.compose.ui:ui-tooling")

implementation("androidx.navigation:navigation-compose:2.7.7")

implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.2")
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.8.2")
// photos
Expand Down Expand Up @@ -196,7 +199,9 @@ dependencies {
implementation("org.jbox2d:jbox2d-library:2.2.1.1")

// sharing presets/settings via QR Code
implementation("com.google.zxing:core:3.5.3")
implementation("io.github.alexzhirkevich:qrose:1.0.1")
// for encoding information for the URL configuration (QR code)
implementation("com.ionspin.kotlin:bignum:0.3.9")

// serialization
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.0")
Expand Down
9 changes: 5 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<activity
android:windowSoftInputMode="adjustResize"
android:name="de.westnordost.streetcomplete.screens.MainActivity"
android:configChanges="orientation|screenSize"
android:configChanges="orientation|screenSize|screenLayout"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down Expand Up @@ -78,17 +78,18 @@
android:name="de.westnordost.streetcomplete.screens.settings.SettingsActivity"
android:label="@string/action_settings"
android:parentActivityName="de.westnordost.streetcomplete.screens.MainActivity"
android:configChanges="density|fontScale|keyboard|keyboardHidden|layoutDirection|locale|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MANAGE_NETWORK_USAGE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name="de.westnordost.streetcomplete.screens.FragmentContainerActivity" />
<activity android:name="de.westnordost.streetcomplete.screens.about.AboutActivity" />
<activity
android:name="de.westnordost.streetcomplete.screens.settings.debug.ShowQuestFormsActivity"
android:configChanges="orientation|screenSize|uiMode" />
android:name="de.westnordost.streetcomplete.screens.about.AboutActivity"
android:configChanges="density|fontScale|keyboard|keyboardHidden|layoutDirection|locale|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode"
/>
<activity
android:name="de.westnordost.streetcomplete.screens.user.UserActivity"
android:screenOrientation="portrait"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ object ApplicationConstants {
const val MAX_DOWNLOADABLE_AREA_IN_SQKM = 12.0
const val MIN_DOWNLOADABLE_AREA_IN_SQKM = 0.1

const val COPYRIGHT_YEARS = "2016-2024"

const val DATABASE_NAME = "streetcomplete_v2.db"
const val OLD_DATABASE_NAME = "streetcomplete.db"

Expand Down Expand Up @@ -59,9 +57,7 @@ object ApplicationConstants {
const val NOTIFICATIONS_CHANNEL_SYNC = "downloading"
const val NOTIFICATIONS_ID_SYNC = 1

const val DEFAULT_MAP_CACHE_SIZE_IN_MB = 50
const val DEFAULT_AUTOSYNC = "ON"
const val DEFAULT_RESURVEY_INTERVALS = "DEFAULT"
const val DEFAULT_MAP_CACHE_SIZE_IN_MB = 200

const val STREETMEASURE = "de.westnordost.streetmeasure"

Expand Down
89 changes: 0 additions & 89 deletions app/src/main/java/de/westnordost/streetcomplete/Prefs.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import androidx.core.content.getSystemService
import androidx.work.ExistingPeriodicWorkPolicy
import androidx.work.PeriodicWorkRequest
import androidx.work.WorkManager
import com.russhwolf.settings.ObservableSettings
import com.russhwolf.settings.SettingsListener
import de.westnordost.streetcomplete.data.CacheTrimmer
import de.westnordost.streetcomplete.data.CleanerWorker
import de.westnordost.streetcomplete.data.Preloader
import de.westnordost.streetcomplete.data.allEditTypesModule
import de.westnordost.streetcomplete.data.changelog.changelogModule
import de.westnordost.streetcomplete.data.dbModule
import de.westnordost.streetcomplete.data.download.downloadModule
import de.westnordost.streetcomplete.data.download.tiles.DownloadedTilesController
Expand Down Expand Up @@ -50,17 +50,18 @@ import de.westnordost.streetcomplete.screens.about.aboutScreenModule
import de.westnordost.streetcomplete.screens.main.mainModule
import de.westnordost.streetcomplete.screens.main.map.mapModule
import de.westnordost.streetcomplete.screens.measure.arModule
import de.westnordost.streetcomplete.screens.settings.ResurveyIntervalsUpdater
import de.westnordost.streetcomplete.data.preferences.ResurveyIntervalsUpdater
import de.westnordost.streetcomplete.screens.settings.settingsModule
import de.westnordost.streetcomplete.screens.user.userScreenModule
import de.westnordost.streetcomplete.util.CrashReportExceptionHandler
import de.westnordost.streetcomplete.util.getDefaultTheme
import de.westnordost.streetcomplete.util.getSelectedLocales
import de.westnordost.streetcomplete.util.ktx.nowAsEpochMilliseconds
import de.westnordost.streetcomplete.util.logs.AndroidLogger
import de.westnordost.streetcomplete.util.logs.DatabaseLogger
import de.westnordost.streetcomplete.util.logs.Log
import de.westnordost.streetcomplete.util.prefs.preferencesModule
import de.westnordost.streetcomplete.data.preferences.Preferences
import de.westnordost.streetcomplete.data.preferences.Theme
import de.westnordost.streetcomplete.data.preferences.preferencesModule
import de.westnordost.streetcomplete.util.setDefaultLocales
import kotlinx.coroutines.CoroutineName
import kotlinx.coroutines.CoroutineScope
Expand All @@ -80,7 +81,7 @@ class StreetCompleteApplication : Application() {
private val crashReportExceptionHandler: CrashReportExceptionHandler by inject()
private val resurveyIntervalsUpdater: ResurveyIntervalsUpdater by inject()
private val downloadedTilesController: DownloadedTilesController by inject()
private val prefs: ObservableSettings by inject()
private val prefs: Preferences by inject()
private val editHistoryController: EditHistoryController by inject()
private val userLoginController: UserLoginController by inject()
private val cacheTrimmer: CacheTrimmer by inject()
Expand Down Expand Up @@ -115,6 +116,7 @@ class StreetCompleteApplication : Application() {
mainModule,
maptilesModule,
metadataModule,
changelogModule,
noteEditsModule,
notesModule,
messagesModule,
Expand Down Expand Up @@ -142,7 +144,7 @@ class StreetCompleteApplication : Application() {
setLoggerInstances()

// Force logout users who are logged in with OAuth 1.0a, they need to re-authenticate with OAuth 2
if (prefs.getStringOrNull(Prefs.OAUTH1_ACCESS_TOKEN) != null) {
if (prefs.hasOAuth1AccessToken) {
userLoginController.logOut()
}

Expand All @@ -159,24 +161,20 @@ class StreetCompleteApplication : Application() {

enqueuePeriodicCleanupWork()

updateDefaultTheme()
updateTheme(prefs.theme)

resurveyIntervalsUpdater.update()

val lastVersion = prefs.getStringOrNull(Prefs.LAST_VERSION_DATA)
val lastVersion = prefs.lastDataVersion
if (BuildConfig.VERSION_NAME != lastVersion) {
prefs.putString(Prefs.LAST_VERSION_DATA, BuildConfig.VERSION_NAME)
prefs.lastDataVersion = BuildConfig.VERSION_NAME
if (lastVersion != null) {
onNewVersion()
}
}

settingsListeners += prefs.addStringOrNullListener(Prefs.LANGUAGE_SELECT) {
updateDefaultLocales()
}
settingsListeners += prefs.addStringOrNullListener(Prefs.THEME_SELECT) {
updateDefaultTheme()
}
settingsListeners += prefs.onLanguageChanged { updateDefaultLocales() }
settingsListeners += prefs.onThemeChanged { updateTheme(it) }
}

private fun onNewVersion() {
Expand Down Expand Up @@ -207,8 +205,7 @@ class StreetCompleteApplication : Application() {
setDefaultLocales(getSelectedLocales(prefs))
}

private fun updateDefaultTheme() {
val theme = Prefs.Theme.valueOf(prefs.getStringOrNull(Prefs.THEME_SELECT) ?: getDefaultTheme())
private fun updateTheme(theme: Theme) {
AppCompatDelegate.setDefaultNightMode(theme.appCompatNightMode)
}

Expand All @@ -232,3 +229,9 @@ class StreetCompleteApplication : Application() {
private val isConnected: Boolean
get() = getSystemService<ConnectivityManager>()?.activeNetworkInfo?.isConnected == true
}

private val Theme.appCompatNightMode: Int get() = when (this) {
Theme.LIGHT -> AppCompatDelegate.MODE_NIGHT_NO
Theme.DARK -> AppCompatDelegate.MODE_NIGHT_YES
Theme.SYSTEM -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package de.westnordost.streetcomplete.data

import com.russhwolf.settings.ObservableSettings
import de.westnordost.osmapi.OsmConnection
import de.westnordost.osmapi.user.UserApi
import de.westnordost.streetcomplete.ApplicationConstants
import de.westnordost.streetcomplete.Prefs
import de.westnordost.streetcomplete.data.osm.mapdata.MapDataApi
import de.westnordost.streetcomplete.data.osm.mapdata.MapDataApiImpl
import de.westnordost.streetcomplete.data.osmnotes.NotesApi
import de.westnordost.streetcomplete.data.osmnotes.NotesApiImpl
import de.westnordost.streetcomplete.data.osmtracks.TracksApi
import de.westnordost.streetcomplete.data.osmtracks.TracksApiImpl
import de.westnordost.streetcomplete.data.preferences.Preferences
import org.koin.androidx.workmanager.dsl.worker
import org.koin.core.qualifier.named
import org.koin.dsl.module
Expand All @@ -29,7 +28,7 @@ val osmApiModule = module {
single { OsmConnection(
OSM_API_URL,
ApplicationConstants.USER_AGENT,
get<ObservableSettings>().getStringOrNull(Prefs.OAUTH2_ACCESS_TOKEN)
get<Preferences>().oAuth2AccessToken
) }
single { UnsyncedChangesCountSource(get(), get()) }

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package de.westnordost.streetcomplete.data.changelog

import android.content.res.Resources
import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.util.html.HtmlElementNode
import de.westnordost.streetcomplete.util.html.HtmlNode
import de.westnordost.streetcomplete.util.html.HtmlTextNode
import de.westnordost.streetcomplete.util.html.parseHtml
import de.westnordost.streetcomplete.util.ktx.getRawTextFile
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext

class Changelog(private val resources: Resources) {
/** Return the app's changelog, sorted descending by version.
*
* @param sinceVersion optionally only return the changes since the given version
* */
suspend fun getChangelog(sinceVersion: String? = null): Map<String, List<HtmlNode>> {
val text = withContext(Dispatchers.IO) { resources.getRawTextFile(R.raw.changelog) }
val html = withContext(Dispatchers.Default) { parseHtml(text) }
var currentVersion: String? = null
var versionHtml = ArrayList<HtmlNode>()
// LinkedHashMap so that order is preserved
val result = LinkedHashMap<String, List<HtmlNode>>()
for (node in html) {
if (node is HtmlElementNode && node.tag == "h2") {
if (currentVersion != null) {
result[currentVersion] = versionHtml
versionHtml = ArrayList()
}
currentVersion = (node.nodes.first() as HtmlTextNode).text.trim()
if (currentVersion == sinceVersion) return result
} else {
versionHtml.add(node)
}
}
return result
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package de.westnordost.streetcomplete.data.changelog

import org.koin.dsl.module

val changelogModule = module {
single { Changelog(get()) }
}
Loading