Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 4 additions & 6 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ android {
// Restrict shipped locales to those we actually translate.
resourceConfigurations += listOf("en", "ar")

// API Base URL - using BuildConfig for environment-specific values
buildConfigField("String", "API_BASE_URL", "\"https://ed.databayt.org/api/\"")
// API base URL lives in core/network/BuildConfig.API_BASE_URL (single
// source of truth). Socket URL stays here for now until E09 lifts it.
buildConfigField("String", "SOCKET_URL", "\"https://ed.databayt.org\"")
}

Expand All @@ -50,8 +50,7 @@ android {
applicationIdSuffix = ".debug"
versionNameSuffix = "-debug"

// Development API (can point to local or staging)
buildConfigField("String", "API_BASE_URL", "\"https://ed.databayt.org/api/\"")
// API_BASE_URL is owned by core/network; override there if needed per buildType.
}

release {
Expand All @@ -62,8 +61,7 @@ android {
"proguard-rules.pro"
)

// Production API
buildConfigField("String", "API_BASE_URL", "\"https://ed.databayt.org/api/\"")
// API_BASE_URL is owned by core/network; override there if needed per buildType.
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package org.hogwarts.android.config

import org.hogwarts.android.core.network.BuildConfig as NetworkBuildConfig

object BuildConfigHelper {
const val APPLICATION_ID = "org.hogwarts.android"
const val VERSION_NAME = "1.0.0"
const val VERSION_CODE = 1

val isDebug: Boolean get() = org.hogwarts.android.BuildConfig.DEBUG

val apiBaseUrl: String get() = if (isDebug) {
"https://staging-api.databayt.org"
} else {
"https://api.databayt.org"
}
// Reads through to core/network's BuildConfig.API_BASE_URL — the single
// source of truth for the API host. See core/network/build.gradle.kts.
val apiBaseUrl: String get() = NetworkBuildConfig.API_BASE_URL

val environment: String get() = if (isDebug) "staging" else "production"
}
9 changes: 9 additions & 0 deletions core/network/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ android {
defaultConfig {
minSdk = 26
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

// Single source of truth for the API host. Retrofit endpoints carry the
// `api/...` path prefix themselves, so this value intentionally has no
// `/api/` suffix. App-level BuildConfigHelper reads through to here.
buildConfigField("String", "API_BASE_URL", "\"https://ed.databayt.org/\"")
}

buildFeatures {
buildConfig = true
}

compileOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import javax.inject.Singleton
@InstallIn(SingletonComponent::class)
object NetworkModule {

private const val BASE_URL = "https://ed.databayt.org/"
private const val TIMEOUT_SECONDS = 30L

@Provides
Expand Down Expand Up @@ -84,7 +83,7 @@ object NetworkModule {
okHttpClient: OkHttpClient,
json: Json
): Retrofit = Retrofit.Builder()
.baseUrl(BASE_URL)
.baseUrl(BuildConfig.API_BASE_URL)
.client(okHttpClient)
.addConverterFactory(json.asConverterFactory("application/json".toMediaType()))
.build()
Expand Down