Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
9085838
Migrate SettingsActivity to compose
shobhitagarwal1612 Feb 20, 2026
c90424e
Migrate SettingsFragment.kt to compose
shobhitagarwal1612 Feb 20, 2026
8a0963c
Annotate the view model with HiltViewModel
shobhitagarwal1612 Feb 20, 2026
1d66506
Move toolbar UI to compose screen
shobhitagarwal1612 Feb 20, 2026
1c3d82e
Handle opening webpage in settings activity
shobhitagarwal1612 Feb 20, 2026
80f5749
* Loading State: Added CircularProgressIndicator when uiState is null.
shobhitagarwal1612 Feb 20, 2026
d919a1b
Handle locale changed calls
shobhitagarwal1612 Feb 20, 2026
60e63d5
Using Flows in LocalValueStore and UserRepository for automatic updates.
shobhitagarwal1612 Feb 20, 2026
1e02ca2
SettingsViewModel now observes userRepository.userSettingsFlow instea…
shobhitagarwal1612 Feb 20, 2026
e8dd223
Extracted SingleSelectionDialog and SettingsCategory, added Material …
shobhitagarwal1612 Feb 20, 2026
e858e61
Suggested improvements
shobhitagarwal1612 Feb 20, 2026
aea62d1
Remove unused fragment-compose library
shobhitagarwal1612 Feb 20, 2026
b14dc76
Add tests
shobhitagarwal1612 Feb 23, 2026
e2f4df9
Break compose elements into separate components
shobhitagarwal1612 Feb 23, 2026
008df46
Fix icon
shobhitagarwal1612 Feb 23, 2026
79fc2b3
Remove icons
shobhitagarwal1612 Feb 23, 2026
5a24b30
Refactor code
shobhitagarwal1612 Feb 23, 2026
7dc2a71
Inline Option data class
shobhitagarwal1612 Feb 23, 2026
df9ab06
Inline localValueStore helper methods to SettingsViewModel
shobhitagarwal1612 Feb 23, 2026
533bf5f
Refactor code
shobhitagarwal1612 Feb 23, 2026
31a7e9a
Pull SettingsSelectItem to a new file
shobhitagarwal1612 Feb 23, 2026
4f083b9
Add previews
shobhitagarwal1612 Feb 26, 2026
8c16222
Use defaults
shobhitagarwal1612 Feb 26, 2026
3746bc1
simplify the code
shobhitagarwal1612 Feb 26, 2026
dd066fe
Add missing previews
shobhitagarwal1612 Feb 26, 2026
dfdbc0c
Add missing license header
shobhitagarwal1612 Feb 26, 2026
1c06599
Update unit tests
shobhitagarwal1612 Feb 26, 2026
e84c353
Simplify tests
shobhitagarwal1612 Feb 26, 2026
43257e7
Simplify tests 2
shobhitagarwal1612 Feb 26, 2026
b958f20
Remove unused string
shobhitagarwal1612 Feb 26, 2026
739ea1c
Merge branch 'master' into compose-settings
shobhitagarwal1612 Feb 26, 2026
ec88031
Remove unused string
shobhitagarwal1612 Feb 26, 2026
f2d0735
Decouple data layer from SettingsViewModel
shobhitagarwal1612 Feb 27, 2026
2677b85
Use getString() from TestResourcesHelper
shobhitagarwal1612 Feb 27, 2026
30f13a8
Fix imports
shobhitagarwal1612 Feb 27, 2026
55891c5
Add @ExcludeFromJacocoGeneratedReport and improve variable name
shobhitagarwal1612 Feb 27, 2026
7fa4072
Replace SelectionDialog with Dropdown list
shobhitagarwal1612 Feb 27, 2026
830a9a1
Merge branch 'master' into compose-settings
shobhitagarwal1612 Feb 27, 2026
afd766c
Update app/src/main/java/org/groundplatform/android/ui/settings/Setti…
shobhitagarwal1612 Feb 27, 2026
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
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,15 @@ constructor(private val preferences: SharedPreferences, private val locale: Loca
preferences.edit { putString(PrefKeys.MEASUREMENT_UNITS, value) }
}

var shouldUploadMediaOverUnmeteredConnectionOnly: Boolean
get() = allowThreadDiskReads { preferences.getBoolean(PrefKeys.UPLOAD_MEDIA, false) }
set(value) = allowThreadDiskWrites {
preferences.edit { putBoolean(PrefKeys.UPLOAD_MEDIA, value) }
}

/** Removes all values stored in the local store. */
fun clear() = allowThreadDiskWrites { preferences.edit { clear() } }

fun shouldUploadMediaOverUnmeteredConnectionOnly(): Boolean = allowThreadDiskReads {
preferences.getBoolean(PrefKeys.UPLOAD_MEDIA, false)
}

fun clearLastCameraPosition(surveyId: String) = allowThreadDiskReads {
preferences.edit { remove(PrefKeys.LAST_VIEWPORT_PREFIX + surveyId) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class MediaUploadWorkManager
constructor(private val workManager: WorkManager, private val localValueStore: LocalValueStore) {

private fun preferredNetworkType(): NetworkType =
if (localValueStore.shouldUploadMediaOverUnmeteredConnectionOnly()) NetworkType.UNMETERED
if (localValueStore.shouldUploadMediaOverUnmeteredConnectionOnly) NetworkType.UNMETERED
else NetworkType.CONNECTED

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import org.groundplatform.android.ui.main.MainViewModel
import org.groundplatform.android.ui.offlineareas.OfflineAreasViewModel
import org.groundplatform.android.ui.offlineareas.selector.OfflineAreaSelectorViewModel
import org.groundplatform.android.ui.offlineareas.viewer.OfflineAreaViewerViewModel
import org.groundplatform.android.ui.settings.SettingsViewModel
import org.groundplatform.android.ui.syncstatus.SyncStatusViewModel
import org.groundplatform.android.ui.tos.TermsOfServiceViewModel

Expand Down Expand Up @@ -143,10 +142,5 @@ abstract class ViewModelModule {
@ViewModelKey(BaseMapViewModel::class)
abstract fun bindBaseMapViewModel(viewModel: BaseMapViewModel): ViewModel

@Binds
@IntoMap
@ViewModelKey(SettingsViewModel::class)
abstract fun bindSettingsViewModel(viewModel: SettingsViewModel): ViewModel

@Binds abstract fun bindViewModelFactory(factory: ViewModelFactory): ViewModelProvider.Factory
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,15 @@ constructor(
UserSettings(
language = selectedLanguage,
measurementUnits = MeasurementUnits.valueOf(selectedLengthUnit),
shouldUploadPhotosOnWifiOnly = shouldUploadMediaOverUnmeteredConnectionOnly(),
shouldUploadPhotosOnWifiOnly = shouldUploadMediaOverUnmeteredConnectionOnly,
)
}

fun setUserSettings(userSettings: UserSettings) {
with(localValueStore) {
selectedLanguage = userSettings.language
selectedLengthUnit = userSettings.measurementUnits.name
shouldUploadMediaOverUnmeteredConnectionOnly = userSettings.shouldUploadPhotosOnWifiOnly
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,45 @@
*/
package org.groundplatform.android.ui.settings

import android.content.Intent
import android.net.Uri
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.os.LocaleListCompat
import dagger.hilt.android.AndroidEntryPoint
import org.groundplatform.android.databinding.SettingsActivityBinding
import org.groundplatform.android.ui.common.AbstractActivity
import org.groundplatform.android.ui.main.MainActivity
import org.groundplatform.android.ui.theme.AppTheme

@AndroidEntryPoint
class SettingsActivity : AbstractActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
AppTheme {
SettingsScreen(
onBack = { finish() },
onLocaleChanged = { locale -> applyLocaleAndRestart(locale) },
onVisitWebsiteClick = { uri: Uri -> openWebsite(uri) },
)
}
}
}

val binding = SettingsActivityBinding.inflate(layoutInflater)
setContentView(binding.root)
private fun applyLocaleAndRestart(languageCode: String) {
val appLocale = LocaleListCompat.forLanguageTags(languageCode)
AppCompatDelegate.setApplicationLocales(appLocale)

with(binding.settingsToolbar) {
setSupportActionBar(this)
setNavigationOnClickListener { finish() }
}
val intent =
Intent(this, MainActivity::class.java).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
}
startActivity(intent)
}

private fun openWebsite(uri: Uri) {
val intent = Intent(Intent.ACTION_VIEW, uri)
startActivity(intent)
}
}

This file was deleted.

Loading
Loading