Skip to content

Commit

Permalink
Update internal visibility modifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
RyosukeCla committed Feb 20, 2024
1 parent 5be81ce commit ecab168
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import java.io.InputStreamReader
import java.net.HttpURLConnection
import java.net.URL

const val CONNECT_TIMEOUT = 10 * 1000
const val READ_TIMEOUT = 5 * 1000
internal const val CONNECT_TIMEOUT = 10 * 1000
internal const val READ_TIMEOUT = 5 * 1000

internal fun getRequest(endpoint: String): Result<String> {
var connection: HttpURLConnection? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import java.util.UUID
import kotlin.random.Random


fun getNativebrikUserSharedPreferences(context: Context): SharedPreferences? {
internal fun getNativebrikUserSharedPreferences(context: Context): SharedPreferences? {
return context.getSharedPreferences(
context.packageName + ".nativebrik.com.user",
Context.MODE_PRIVATE
Expand All @@ -29,32 +29,31 @@ internal fun formatISO8601(time: ZonedDateTime): String {
return time.format(DateTimeFormatter.ISO_INSTANT)
}

enum class UserPropertyType {
internal enum class UserPropertyType {
INTEGER,
DOUBLE,
STRING,
TIMESTAMPZ,
SEMVER,
UNKNOWN,;
}

data class UserProperty(
internal data class UserProperty(
val name: String,
val value: String,
val type: UserPropertyType,
) {}
)

class NativebrikUser {
private var properties: MutableMap<String, String> = mutableMapOf()
private var preferences: SharedPreferences? = null
private var lastBootTime: ZonedDateTime = getCurrentDate()

var id: String = ""
val id: String
get() {
return this.properties[BuiltinUserProperty.userId.toString()] ?: ""
}

constructor(context: Context) {
internal constructor(context: Context) {
this.preferences = getNativebrikUserSharedPreferences(context)

// userId := uuid by default
Expand Down Expand Up @@ -144,13 +143,13 @@ class NativebrikUser {
}

// n in [0,1)
fun getNormalizedUserRnd(seed: Int?): Double {
internal fun getNormalizedUserRnd(seed: Int?): Double {
val userSeedStr: String = this.properties[USER_SEED_KEY] ?: "0"
val userSeed: Int = userSeedStr.toIntOrNull() ?: 0
return Random((seed ?: 0 + userSeed)).nextDouble()
return Random((seed ?: 0) + userSeed).nextDouble()
}

fun toUserProperties(seed: Int? = 0): List<UserProperty> {
internal fun toUserProperties(seed: Int? = 0): List<UserProperty> {
val now = getCurrentDate()
val props: MutableList<UserProperty> = mutableListOf()

Expand Down

0 comments on commit ecab168

Please sign in to comment.