Skip to content

Commit

Permalink
add AppPolicy for the default value of externalCameraIp app preference [
Browse files Browse the repository at this point in the history
  • Loading branch information
fetiu committed Oct 6, 2024
1 parent 71a649d commit df4226a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.foke.together.data.datasource.local.datastore
import androidx.datastore.core.Serializer
import com.foke.together.AppPreferences
import com.foke.together.util.AppLog
import com.foke.together.util.AppPolicy
import java.io.InputStream
import java.io.OutputStream
import javax.inject.Inject
Expand All @@ -14,6 +15,7 @@ class AppPreferencesSerializer @Inject constructor(): Serializer<AppPreferences>
// You need to check default value of each types from link below
// https://protobuf.dev/programming-guides/proto3/
// ex> isDebugMode = true
externalCameraIp = AppPolicy.DEFAULT_EXTERNAL_CAMERA_IP
build()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,7 @@ class AppPreferencesRepository @Inject constructor(

override fun getExternalCameraIP(): Flow<ExternalCameraIP> =
appPreferencesFlow.map {
val address = it.externalCameraIp
if (address.isNullOrEmpty()) {
ExternalCameraIP("0.0.0.0")
} else {
ExternalCameraIP(address)
}
ExternalCameraIP(it.externalCameraIp)
}

override suspend fun setExternalCameraIP(ip: ExternalCameraIP) {
Expand Down
5 changes: 5 additions & 0 deletions util/src/main/java/com/foke/together/util/Policy.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.foke.together.util

object AppPolicy {
const val DEFAULT_EXTERNAL_CAMERA_IP = "0.0.0.0"
}

0 comments on commit df4226a

Please sign in to comment.