Skip to content

Commit

Permalink
Merge pull request #31 from usefulness/updates
Browse files Browse the repository at this point in the history
Build release app
  • Loading branch information
mateuszkwiecinski authored Nov 20, 2023
2 parents b9d7cc3 + 1cf576a commit 1dc3e68
Show file tree
Hide file tree
Showing 14 changed files with 139 additions and 111 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ jobs:
with:
build-root-directory: sample
gradle-version: ${{ matrix.gradle }}
arguments: check -PagpVersion=${{ matrix.agp }} --continue
arguments: build -PagpVersion=${{ matrix.agp }} --continue

- name: Upload reports
if: ${{ failure() }}
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ assertj-core = { module = "org.assertj:assertj-core", version.ref = "maven-asser
agp-gradle-api = { module = "com.android.tools.build:gradle-api", version.ref = "google-agp" }
kotlin-gradle-api = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin-api", version.ref = "maven-kotlin" }
com-squareup-kotlinpoet = "com.squareup:kotlinpoet:1.15.1"
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "maven-kotlin-serialization" }
kotlinx-serialization-json-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "maven-kotlin-serialization" }
kotlinx-serialization-json-okio = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json-okio", version.ref = "maven-kotlin-serialization" }
com-squareup-okio = "com.squareup.okio:okio:3.6.0"
jetbrains-dokka = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "maven-dokka" }
Expand Down
9 changes: 5 additions & 4 deletions licensee-for-android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

plugins {
id("java-gradle-plugin")
Expand All @@ -15,7 +16,7 @@ dependencies {
implementation(libs.com.squareup.kotlinpoet) {
exclude(module: "kotlin-reflect")
}
implementation(libs.kotlinx.serialization.json)
implementation(libs.kotlinx.serialization.json.core)
implementation(libs.kotlinx.serialization.json.okio)
implementation(libs.com.squareup.okio)

Expand All @@ -32,9 +33,9 @@ kotlin {
}

tasks.withType(KotlinCompile).configureEach {
kotlinOptions {
apiVersion = "1.8"
languageVersion = "1.8"
compilerOptions {
apiVersion = KotlinVersion.KOTLIN_1_8
languageVersion = KotlinVersion.KOTLIN_1_8
}
}
tasks.withType(Test).configureEach {
Expand Down
16 changes: 15 additions & 1 deletion sample/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
alias(libs.plugins.starter.application.android)
alias(libs.plugins.app.cash.licensee)
id("io.github.usefulness.licensee-for-android")
alias(libs.plugins.starter.easylauncher)
}

licensee {
Expand All @@ -20,10 +21,23 @@ android {

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

signingConfigs {
named("debug") {
storeFile rootProject.file("keys/debug.keystore")
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
buildTypes {
named("debug") {
signingConfig signingConfigs.getByName("debug")
applicationIdSuffix ".debug"
versionNameSuffix "-debug"
}
named("release") {
minifyEnabled = true
signingConfig signingConfigs.getByName("debug")
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
matchingFallbacks += ["debug"]
}
Expand Down
17 changes: 11 additions & 6 deletions sample/app/src/main/kotlin/se/premex/gross/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package io.githhub.usefulness.licensee.android.app
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
Expand All @@ -14,8 +15,10 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.NavigationBarItem
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import se.premex.gross.AssetsOssView
Expand All @@ -30,17 +33,19 @@ enum class Views {
class MainActivity : ComponentActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge()
super.onCreate(savedInstanceState)
setContent {
val selectedView = remember { mutableStateOf(Views.Programmatic) }
var selectedView by remember { mutableStateOf(Views.Programmatic) }

GrossTheme {
Scaffold(
bottomBar = {
BottomAppBar {
NavigationBarItem(
selected = false,
selected = selectedView == Views.Programmatic,
onClick = {
selectedView.value = Views.Programmatic
selectedView = Views.Programmatic
},
icon = {
Icon(
Expand All @@ -50,9 +55,9 @@ class MainActivity : ComponentActivity() {
},
)
NavigationBarItem(
selected = false,
selected = selectedView == Views.AssetBased,
onClick = {
selectedView.value = Views.AssetBased
selectedView = Views.AssetBased
},
icon = {
Icon(
Expand All @@ -70,7 +75,7 @@ class MainActivity : ComponentActivity() {
.padding(paddingValues),
color = MaterialTheme.colorScheme.background,
) {
when (selectedView.value) {
when (selectedView) {
Views.Programmatic -> ProgrammaticOssView()
Views.AssetBased -> AssetsOssView()
}
Expand Down
32 changes: 16 additions & 16 deletions sample/app/src/main/kotlin/se/premex/gross/OssArtifactView.kt
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
package se.premex.gross

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import io.githhub.usefulness.licensee.android.app.R
import se.premex.gross.ui.AssetLicenseeParser
import se.premex.gross.ui.ErrorView
import se.premex.gross.ui.LoadingView
import se.premex.gross.ui.OssView
import se.premex.gross.ui.OssViewState
import se.premex.gross.ui.State
import java.io.IOException

@Composable
fun AssetsOssView() {
val assetManager = LocalContext.current.assets

val licenseParser = remember { AssetLicenseeParser(assetManager) }

val uiState = remember { mutableStateOf(OssViewState()) }
val uiState = remember { mutableStateOf<OssViewState>(State.Loading) }

LaunchedEffect(key1 = assetManager) {
try {
uiState.value = OssViewState(viewState = State.Success(data = licenseParser.readFromAssets()))
} catch (ioException: IOException) {
uiState.value =
OssViewState(
viewState = State.Failed(
errorMessage = ioException.localizedMessage ?: "",
),
)
}
LaunchedEffect(assetManager) {
uiState.value = runCatching { licenseParser.readFromAssets() }.fold(
onSuccess = { State.Success(data = it) },
onFailure = { State.Failed(errorMessage = it.localizedMessage.orEmpty()) },
)
}

when (val state = uiState.value.viewState) {
when (val state = uiState.value) {
State.Loading -> LoadingView(stringResource(id = R.string.loading))
is State.Failed -> ErrorView(stringResource(id = R.string.error), state.errorMessage)
is State.Loading -> LoadingView(stringResource(id = R.string.loading))
is State.Success -> {
Column {
Text(text = stringResource(id = R.string.assetBased))
Text(
text = stringResource(id = R.string.assetBased),
modifier = Modifier
.padding(16.dp),
)

OssView(state.data)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
package se.premex.gross

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import io.githhub.usefulness.licensee.android.app.R
import io.github.usefulness.licensee.LicenseeForAndroid
import se.premex.gross.ui.OssView

@Composable
fun ProgrammaticOssView() {
Column {
Text(text = stringResource(id = R.string.programmatic))
Text(
text = stringResource(id = R.string.programmatic),
modifier = Modifier
.padding(16.dp),
)
OssView(LicenseeForAndroid.artifacts)
}
}
13 changes: 0 additions & 13 deletions sample/app/src/main/kotlin/se/premex/gross/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package se.premex.gross.ui.theme

import android.app.Activity
import android.os.Build
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
Expand All @@ -9,11 +8,7 @@ import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalView
import androidx.core.view.WindowCompat

private val DarkColorScheme = darkColorScheme(
primary = Purple80,
Expand Down Expand Up @@ -53,14 +48,6 @@ fun GrossTheme(
darkTheme -> DarkColorScheme
else -> LightColorScheme
}
val view = LocalView.current
if (!view.isInEditMode) {
SideEffect {
val window = (view.context as Activity).window
window.statusBarColor = colorScheme.primary.toArgb()
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme
}
}

MaterialTheme(
colorScheme = colorScheme,
Expand Down
1 change: 1 addition & 0 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
alias(libs.plugins.starter.application.android) apply false
alias(libs.plugins.starter.library.android) apply false
alias(libs.plugins.starter.library.kotlin) apply false
id("io.github.usefulness.licensee-for-android") apply false
}

commonConfig {
Expand Down
4 changes: 2 additions & 2 deletions sample/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ maven-kotlin = "1.9.20"
maven-junit = "5.10.1"
maven-junit4 = "4.13.2"
maven-assertj = "3.24.2"

activity-compose = "1.8.1"
androidx-compose-compiler = "1.5.4"
androidx-core = "1.12.0"
Expand All @@ -24,7 +23,7 @@ junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher
junit4 = { module = "junit:junit", version.ref = "maven-junit4" }
assertj-core = { module = "org.assertj:assertj-core", version.ref = "maven-assertj" }

kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "maven-kotlin-serialization" }
kotlinx-serialization-json-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "maven-kotlin-serialization" }
kotlinx-serialization-json-okio = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json-okio", version.ref = "maven-kotlin-serialization" }
com-squareup-okio = "com.squareup.okio:okio:3.6.0"

Expand Down Expand Up @@ -66,3 +65,4 @@ starter-library-kotlin = { id = "com.starter.library.kotlin", version.ref = "gra
starter-library-android = { id = "com.starter.library.android", version.ref = "gradle-starter" }
starter-application-android = { id = "com.starter.application.android", version.ref = "gradle-starter" }
app-cash-licensee = "app.cash.licensee:1.8.0"
starter-easylauncher = "com.starter.easylauncher:6.2.0"
Binary file added sample/keys/debug.keystore
Binary file not shown.
2 changes: 1 addition & 1 deletion sample/serialization/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ tasks.withType(Test).configureEach {
}

dependencies {
api(libs.kotlinx.serialization.json)
api(libs.kotlinx.serialization.json.core)
implementation(libs.kotlinx.serialization.json.okio)
api(libs.com.squareup.okio)

Expand Down
Loading

0 comments on commit 1dc3e68

Please sign in to comment.