Skip to content

Commit

Permalink
Provide secrets to ci (#21)
Browse files Browse the repository at this point in the history
* Take secrets from env on CI

* update ci.yml
  • Loading branch information
efguydan authored May 21, 2023
1 parent 6e48baf commit 8e175e5
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ jobs:

- name: Build with Gradle
run: ./gradlew build
env:
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ build/

# Local configuration file (sdk path, etc)
local.properties
secret.properties

# Log/OS Files
*.log
Expand Down
26 changes: 20 additions & 6 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties
import java.io.FileInputStream
import java.util.Properties

plugins {
id("com.android.application")
Expand Down Expand Up @@ -26,12 +27,12 @@ android {

buildTypes {
debug {
buildConfigField("String", "CLIENT_ID", gradleLocalProperties(rootDir).getProperty("clientId"))
buildConfigField("String", "CLIENT_SECRET", gradleLocalProperties(rootDir).getProperty("clientSecret"))
buildConfigField("String", "CLIENT_ID", getSecret("CLIENT_ID"))
buildConfigField("String", "CLIENT_SECRET", getSecret("CLIENT_SECRET"))
}
release {
buildConfigField("String", "CLIENT_ID", gradleLocalProperties(rootDir).getProperty("clientId"))
buildConfigField("String", "CLIENT_SECRET", gradleLocalProperties(rootDir).getProperty("clientSecret"))
buildConfigField("String", "CLIENT_ID", getSecret("CLIENT_ID"))
buildConfigField("String", "CLIENT_SECRET", getSecret("CLIENT_SECRET"))
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
Expand Down Expand Up @@ -95,4 +96,17 @@ dependencies {
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
androidTestImplementation(platform("androidx.compose:compose-bom:2023.05.01"))
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
}
}

// Fixme: Move to different file
fun getSecret(key: String): String {
val isCi = System.getenv("CI") == "true"

return if (isCi) {
System.getenv(key)
} else {
val properties = Properties()
properties.load(FileInputStream(rootProject.file("secret.properties")))
properties.getProperty(key)
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
package com.efedaniel.spotifystats.ui.proton.components.button

import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.background
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.requiredSize
import androidx.compose.foundation.layout.width
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonColors
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.ButtonElevation
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.LocalContentColor
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import com.efedaniel.spotifystats.ui.proton.components.text.ProtonText
import com.efedaniel.spotifystats.ui.proton.theme.ProtonTheme
import com.efedaniel.spotifystats.ui.proton.theme.ProtonTheme.colors
import com.efedaniel.spotifystats.ui.proton.tokens.dimension.ProtonDimension
import com.efedaniel.spotifystats.ui.proton.tokens.icon.ProtonIcon
import com.efedaniel.spotifystats.ui.proton.tokens.icon.ProtonIconAsset
import com.efedaniel.spotifystats.utility.extensions.conditional

@Composable
Expand All @@ -25,9 +39,11 @@ fun ProtonButton(
size: ProtonButtonSize,
onClick: () -> Unit,
modifier: Modifier = Modifier,
icon: (@Composable () -> Unit)? = null,
icon: ProtonIconAsset? = null,
iconTint: Color = LocalContentColor.current,
fillMaxWidth: Boolean = false,
enabled: Boolean = true,
isLoading: Boolean = false,
colors: ButtonColors = ButtonDefaults.buttonColors(),
elevation: ButtonElevation? = ButtonDefaults.buttonElevation(),
border: BorderStroke? = null,
Expand All @@ -47,8 +63,28 @@ fun ProtonButton(
contentPadding = contentPadding,
interactionSource = interactionSource,
) {
icon?.let { lambda ->
lambda.invoke()
icon?.let {
Box {
this@Button.AnimatedVisibility(
visible = isLoading,
enter = fadeIn(),
exit = fadeOut(),
) {
CircularProgressIndicator(
modifier = Modifier.requiredSize(
ProtonDimension.ComponentSize28,
),
color = ProtonTheme.colors.white,
strokeWidth = ProtonDimension.Stroke2
)
}

ProtonIcon(
asset = icon,
tint = iconTint,
modifier = Modifier.align(Alignment.Center)
)
}
Spacer(modifier = Modifier.width(ProtonDimension.Spacing4))
}
ProtonText(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,23 @@ object ProtonDimension {

// region Component Size

@Stable
val ComponentSize24 = 24.dp

@Stable
val ComponentSize28 = 28.dp

@Stable
val ComponentSize36 = 36.dp

@Stable
val ComponentSize48 = 48.dp

// endregion

// region Icon Size

@Stable
val IconSize24 = 24.dp

// endregion
Expand All @@ -40,4 +47,14 @@ object ProtonDimension {
val Spacing48 = 48.dp

// endregion

// region Stroke

@Stable
val Stroke1 = 1.dp

@Stable
val Stroke2 = 2.dp

// endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,11 @@ fun LoginScreen(
text = stringResource(R.string.connect_with_spotify),
size = ProtonButtonSize.LARGE,
type = ProtonButtonType.ROUNDED,
isLoading = viewModel.state.isConnecting,
onClick = onConnectWithSpotify,
fillMaxWidth = true,
icon = {
ProtonIcon(
asset = ProtonIconAsset.Spotify,
tint = ProtonTheme.colors.green
)
},
icon = ProtonIconAsset.Spotify,
iconTint = ProtonTheme.colors.green,
modifier = Modifier
.align(Alignment.BottomCenter)
.padding(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
import com.efedaniel.spotifystats.ui.scene.auth.state.LoginUiState
import dagger.hilt.android.lifecycle.HiltViewModel
import timber.log.Timber
import javax.inject.Inject

@HiltViewModel
Expand All @@ -18,7 +17,6 @@ class LoginViewModel @Inject constructor(
private set

fun onConnectSpotifyResult(code: String?, error: String?) {
Timber.e(code.toString())
Timber.e(error.toString())
state = state.copy(isConnecting = true)
}
}

0 comments on commit 8e175e5

Please sign in to comment.