Skip to content

Commit

Permalink
Updates to Prod 1.0.4 version (#505)
Browse files Browse the repository at this point in the history
  • Loading branch information
ksharma-xyz authored Dec 29, 2024
1 parent 5bc8799 commit 7794532
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 32 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ jobs:
- uses: actions/checkout@v4
- name: Setup environment variables
run: |
echo "NSW_TRANSPORT_API_KEY=${{ secrets.NSW_TRANSPORT_API_KEY }}" >> $GITHUB_ENV
echo "ANDROID_NSW_TRANSPORT_API_KEY=${{ secrets.ANDROID_NSW_TRANSPORT_API_KEY }}" >> $GITHUB_ENV
echo "IOS_NSW_TRANSPORT_API_KEY=${{ secrets.IOS_NSW_TRANSPORT_API_KEY }}" >> $GITHUB_ENV
- name: set up JDK
uses: actions/setup-java@v4
Expand Down Expand Up @@ -58,12 +59,12 @@ jobs:

- name: Build Debug
env:
NSW_TRANSPORT_API_KEY: ${{ secrets.NSW_TRANSPORT_API_KEY }}
ANDROID_NSW_TRANSPORT_API_KEY: ${{ secrets.ANDROID_NSW_TRANSPORT_API_KEY }}
run: ./gradlew :composeApp:assembleDebug test

- name: Build Release
env:
NSW_TRANSPORT_API_KEY: ${{ secrets.NSW_TRANSPORT_API_KEY }}
ANDROID_NSW_TRANSPORT_API_KEY: ${{ secrets.ANDROID_NSW_TRANSPORT_API_KEY }}
run: ./gradlew :composeApp:assembleRelease test

iOS:
Expand All @@ -76,7 +77,8 @@ jobs:
- uses: actions/checkout@v4
- name: Setup environment variables
run: |
echo "NSW_TRANSPORT_API_KEY=${{ secrets.NSW_TRANSPORT_API_KEY }}" >> $GITHUB_ENV
echo "IOS_NSW_TRANSPORT_API_KEY=${{ secrets.IOS_NSW_TRANSPORT_API_KEY }}" >> $GITHUB_ENV
echo "ANDROID_NSW_TRANSPORT_API_KEY=${{ secrets.ANDROID_NSW_TRANSPORT_API_KEY }}" >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v4
Expand Down Expand Up @@ -104,7 +106,7 @@ jobs:

- name: Build iOS App - Debug (Without Code Signing)
env:
NSW_TRANSPORT_API_KEY: ${{ secrets.NSW_TRANSPORT_API_KEY }}
IOS_NSW_TRANSPORT_API_KEY: ${{ secrets.IOS_NSW_TRANSPORT_API_KEY }}
run: |
xcodebuild -project iosApp/iosApp.xcodeproj \
-scheme iosApp \
Expand Down
2 changes: 1 addition & 1 deletion composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ android {

defaultConfig {
applicationId = "xyz.ksharma.krail"
versionCode = 33
versionCode = 34
versionName = "1.0.4"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down
22 changes: 15 additions & 7 deletions feature/trip-planner/network/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ kotlin {

commonMain {
dependencies {
implementation(projects.core.appInfo)

implementation(libs.kotlinx.serialization.json)
implementation(libs.ktor.client.core)
Expand Down Expand Up @@ -75,19 +76,26 @@ kotlin {

// READ API KEY
val localProperties = gradleLocalProperties(rootProject.rootDir, providers)
val nswTransportApiKey: String = localProperties.getProperty("NSW_TRANSPORT_API_KEY")
?: System.getenv("NSW_TRANSPORT_API_KEY")
require(nswTransportApiKey.isNotEmpty()) {
"Register API key and put in local.properties as `NSW_TRANSPORT_API_KEY`"
val androidNswTransportApiKey: String = localProperties.getProperty("ANDROID_NSW_TRANSPORT_API_KEY")
?: System.getenv("ANDROID_NSW_TRANSPORT_API_KEY")
require(androidNswTransportApiKey.isNotEmpty()) {
"Register API key and put in local.properties as `ANDROID_NSW_TRANSPORT_API_KEY`"
}

val iosNswTransportApiKey: String = localProperties.getProperty("IOS_NSW_TRANSPORT_API_KEY")
?: System.getenv("IOS_NSW_TRANSPORT_API_KEY")
require(iosNswTransportApiKey.isNotEmpty()) {
"Register API key and put in local.properties as `IOS_NSW_TRANSPORT_API_KEY`"
}
buildkonfig {
packageName = "xyz.ksharma.krail.trip.planner.network"

require(nswTransportApiKey.isNotEmpty()) {
"Register API key and put in local.properties as `NSW_TRANSPORT_API_KEY`"
require(androidNswTransportApiKey.isNotEmpty() && iosNswTransportApiKey.isNotEmpty()) {
"Register API key and put in local.properties"
}

defaultConfigs {
buildConfigField(FieldSpec.Type.STRING, "NSW_TRANSPORT_API_KEY", nswTransportApiKey)
buildConfigField(FieldSpec.Type.STRING, "ANDROID_NSW_TRANSPORT_API_KEY", androidNswTransportApiKey)
buildConfigField(FieldSpec.Type.STRING, "IOS_NSW_TRANSPORT_API_KEY", iosNswTransportApiKey)
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import io.ktor.client.HttpClient
import io.ktor.client.engine.okhttp.OkHttp
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
import io.ktor.client.plugins.defaultRequest
import io.ktor.client.plugins.logging.LogLevel
import io.ktor.client.plugins.logging.Logger
import io.ktor.client.plugins.logging.Logging
import io.ktor.http.HttpHeaders
import io.ktor.serialization.kotlinx.json.json
import kotlinx.serialization.json.Json
import xyz.ksharma.krail.core.appinfo.AppInfoProvider
import xyz.ksharma.krail.trip.planner.network.BuildKonfig

actual fun httpClient(): HttpClient {
actual fun httpClient(appInfoProvider: AppInfoProvider): HttpClient {
return HttpClient(OkHttp) {
expectSuccess = true
install(ContentNegotiation) {
Expand All @@ -21,12 +24,24 @@ actual fun httpClient(): HttpClient {
})
}
install(Logging) {
// if(debug) - TODO
// level = LogLevel.BODY
if (appInfoProvider.getAppInfo().isDebug) {
level = LogLevel.BODY
logger = object : Logger {
override fun log(message: String) {
println(message)
}
}
sanitizeHeader { header -> header == HttpHeaders.Authorization }
} else {
level = LogLevel.NONE
}
}

defaultRequest {
headers.append(HttpHeaders.Authorization, "apikey ${BuildKonfig.NSW_TRANSPORT_API_KEY}")
headers.append(
HttpHeaders.Authorization,
"apikey ${BuildKonfig.ANDROID_NSW_TRANSPORT_API_KEY}"
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ import xyz.ksharma.krail.trip.planner.network.api.service.httpClient

val networkModule = module {
singleOf(::NetworkRateLimiter) { bind<RateLimiter>() }
single<HttpClient> { httpClient() }
single<HttpClient> { httpClient(appInfoProvider = get()) }
singleOf(::RealTripPlanningService) { bind<TripPlanningService>() }
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package xyz.ksharma.krail.trip.planner.network.api.service

import io.ktor.client.HttpClient
import xyz.ksharma.krail.core.appinfo.AppInfoProvider

expect fun httpClient(): HttpClient
expect fun httpClient(appInfoProvider: AppInfoProvider): HttpClient

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import io.ktor.client.HttpClient
import io.ktor.client.engine.darwin.Darwin
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
import io.ktor.client.plugins.defaultRequest
import io.ktor.client.plugins.logging.LogLevel
import io.ktor.client.plugins.logging.Logger
import io.ktor.client.plugins.logging.Logging
import io.ktor.http.HttpHeaders
import io.ktor.serialization.kotlinx.json.json
import kotlinx.serialization.json.Json
import xyz.ksharma.krail.core.appinfo.AppInfoProvider
import xyz.ksharma.krail.trip.planner.network.BuildKonfig

actual fun httpClient(): HttpClient {
actual fun httpClient(appInfoProvider: AppInfoProvider): HttpClient {
return HttpClient(Darwin) {
expectSuccess = true
install(ContentNegotiation) {
Expand All @@ -21,12 +24,24 @@ actual fun httpClient(): HttpClient {
})
}
install(Logging) {
// if(debug) - TODO
// level = LogLevel.BODY
if (appInfoProvider.getAppInfo().isDebug) {
level = LogLevel.BODY
logger = object : Logger {
override fun log(message: String) {
println(message)
}
}
sanitizeHeader { header -> header == HttpHeaders.Authorization }
} else {
level = LogLevel.NONE
}
}

defaultRequest {
headers.append(HttpHeaders.Authorization, "apikey ${BuildKonfig.NSW_TRANSPORT_API_KEY}")
headers.append(
HttpHeaders.Authorization,
"apikey ${BuildKonfig.IOS_NSW_TRANSPORT_API_KEY}"
)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package xyz.ksharma.krail.trip.planner.ui.components

import androidx.compose.animation.ExperimentalSharedTransitionApi
import androidx.compose.animation.animateContentSize
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.foundation.Image
Expand Down Expand Up @@ -49,8 +50,6 @@ import krail.feature.trip_planner.ui.generated.resources.ic_a11y
import krail.feature.trip_planner.ui.generated.resources.ic_clock
import krail.feature.trip_planner.ui.generated.resources.ic_walk
import org.jetbrains.compose.resources.painterResource
import xyz.ksharma.krail.core.appinfo.DevicePlatformType
import xyz.ksharma.krail.core.appinfo.LocalAppPlatformProvider
import xyz.ksharma.krail.taj.LocalContentAlpha
import xyz.ksharma.krail.taj.components.SeparatorIcon
import xyz.ksharma.krail.taj.components.Text
Expand Down Expand Up @@ -144,6 +143,7 @@ fun JourneyCard(
)
.animateContentSize(),
) {

when (cardState) {
JourneyCardState.DEFAULT -> DefaultJourneyCardContent(
timeToDeparture = timeToDeparture,
Expand Down Expand Up @@ -219,6 +219,7 @@ fun ExpandedJourneyCardContent(
text = text,
style = KrailTheme.typography.titleLarge,
color = themeColor,
modifier = Modifier,
)
}
}
Expand Down Expand Up @@ -345,7 +346,7 @@ fun getPaddingValue(lastLeg: TimeTableState.JourneyCardInfo.Leg): Dp {
) 16.dp else 0.dp
}

@OptIn(ExperimentalLayoutApi::class)
@OptIn(ExperimentalLayoutApi::class, ExperimentalSharedTransitionApi::class)
@Composable
fun DefaultJourneyCardContent(
timeToDeparture: String,
Expand Down Expand Up @@ -413,6 +414,7 @@ fun DefaultJourneyCardContent(
text = platform,
textAlign = TextAlign.Center,
style = KrailTheme.typography.labelLarge,
modifier = Modifier,
)
}
}
Expand Down

0 comments on commit 7794532

Please sign in to comment.