[Android] 2.0.1 - Refactoring & Minor Optimizations

This commit is contained in:
2025-10-14 23:59:27 -06:00
parent ef1cf3583a
commit 01d85a4add
4 changed files with 5 additions and 17 deletions

View File

@@ -40,7 +40,6 @@ class HealthConnectManager(private val context: Context) {
val isEnabled: Flow<Boolean> = _isEnabled.asStateFlow()
val hasPermissions: Flow<Boolean> = _hasPermissions.asStateFlow()
val autoSyncEnabled: Flow<Boolean> = _autoSync.asStateFlow()
val isCompatible: Flow<Boolean> = _isCompatible.asStateFlow()
companion object {
@@ -112,12 +111,6 @@ class HealthConnectManager(private val context: Context) {
_hasPermissions.value = granted
}
/** Enable or disable auto-sync */
fun setAutoSyncEnabled(enabled: Boolean) {
preferences.edit().putBoolean("auto_sync", enabled).apply()
_autoSync.value = enabled
}
/** Check if all required permissions are granted */
suspend fun hasAllPermissions(): Boolean {
return try {
@@ -163,7 +156,7 @@ class HealthConnectManager(private val context: Context) {
/** Get required permissions as strings */
fun getRequiredPermissions(): Set<String> {
return try {
REQUIRED_PERMISSIONS.map { it.toString() }.toSet()
REQUIRED_PERMISSIONS.map { it }.toSet()
} catch (e: Exception) {
Log.e(TAG, "Error getting required permissions", e)
emptySet()
@@ -359,8 +352,4 @@ class HealthConnectManager(private val context: Context) {
return _isEnabled.value && _hasPermissions.value
}
/** Get last successful sync timestamp */
fun getLastSyncSuccess(): String? {
return preferences.getString("last_sync_success", null)
}
}

View File

@@ -33,7 +33,6 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import kotlinx.coroutines.withContext
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient

View File

@@ -88,7 +88,7 @@ fun AddEditGymScreen(gymId: String?, viewModel: ClimbViewModel, onNavigateBack:
notes = notes
)
if (isEditing && gymId != null) {
if (isEditing) {
viewModel.updateGym(gym.copy(id = gymId))
} else {
viewModel.addGym(gym)
@@ -386,7 +386,7 @@ fun AddEditProblemScreen(
)
if (isEditing) {
problemId?.let { id ->
problemId.let { id ->
viewModel.updateProblem(problem.copy(id = id))
}
} else {
@@ -762,7 +762,7 @@ fun AddEditSessionScreen(
null
}
)
sessionId?.let { id ->
sessionId.let { id ->
viewModel.updateSession(session.copy(id = id))
}
} else {

View File

@@ -114,7 +114,7 @@ class ClimbViewModel(
}
}
private suspend fun renameTemporaryImages(problem: Problem): Problem {
private fun renameTemporaryImages(problem: Problem): Problem {
if (problem.imagePaths.isEmpty()) {
return problem
}