Skip to content

Commit

Permalink
Yolo, part4
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszkwiecinski committed Nov 10, 2023
1 parent 87a3f13 commit 9a26655
Show file tree
Hide file tree
Showing 15 changed files with 92 additions and 161 deletions.
43 changes: 8 additions & 35 deletions sample/app/build.gradle.kts → sample/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
plugins {
alias(libs.plugins.com.android.application)
alias(libs.plugins.org.jetbrains.kotlin.android)
alias(libs.plugins.starter.application.android)
alias(libs.plugins.app.cash.licensee)
id("se.premex.gross")
id("io.github.usefulness.licensee-for-android")
}

licensee {
Expand All @@ -14,38 +13,24 @@ gross {
enableAndroidAssetGeneration.set(true)
}
android {
namespace = "se.premex.gross"
compileSdk = 33
namespace "io.githhub.usefulness.licensee.android.app"

defaultConfig {
applicationId = "se.premex.gross"
minSdk = 24
targetSdk = 33
versionCode = 1
versionName = "1.0"
applicationId = "io.githhub.usefulness.licensee.android.app"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}
}

buildTypes {
release {
isMinifyEnabled = false
minifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}

buildFeatures {
compose = true
}
Expand All @@ -59,15 +44,7 @@ android {
}
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
vendor.set(JvmVendorSpec.AZUL)
}
}

dependencies {

implementation(libs.core.ktx)
implementation(libs.lifecycle.runtime.ktx)
implementation(libs.activity.compose)
Expand All @@ -77,11 +54,7 @@ dependencies {
implementation(libs.ui.tooling.preview)
implementation(libs.material3)

// In theory we should be able to refer to "se.premex.gross:ui-oss" here and set a mapping up
// in the includeBuild like this
// dependencySubstitution { substitute(module("se.premex.gross:ui-oss")).using(project(":oss")) }
// Unfortunately this does not work - maybe same issue as https://youtrack.jetbrains.com/issue/KTIJ-13435
implementation("se.premex.gross:ui:1.0")
implementation(project(":ui"))

testImplementation(libs.junit)
androidTestImplementation(libs.androidx.test.ext.junit)
Expand All @@ -90,4 +63,4 @@ dependencies {
androidTestImplementation(libs.ui.test.junit4)
debugImplementation(libs.ui.tooling)
debugImplementation(libs.ui.test.manifest)
}
}
10 changes: 10 additions & 0 deletions sample/app/config/baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" ?>
<SmellBaseline>
<ManuallySuppressedIssues></ManuallySuppressedIssues>
<CurrentIssues>
<ID>FunctionNaming:OssArtifactView.kt$@Composable fun AssetsOssView()</ID>
<ID>FunctionNaming:OssKotlinCodeView.kt$@Composable fun ProgrammaticOssView()</ID>
<ID>FunctionNaming:Theme.kt$@Composable fun GrossTheme( darkTheme: Boolean = isSystemInDarkTheme(), // Dynamic color is available on Android 12+ dynamicColor: Boolean = true, content: @Composable () -&gt; Unit, )</ID>
<ID>WildcardImport:ExampleUnitTest.kt$import org.junit.Assert.*</ID>
</CurrentIssues>
</SmellBaseline>
21 changes: 0 additions & 21 deletions sample/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,21 +0,0 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

This file was deleted.

39 changes: 0 additions & 39 deletions sample/app/src/main/java/se/premex/gross/OssKotlinCodeView.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import androidx.compose.ui.res.stringResource
import se.premex.gross.ui.theme.GrossTheme

enum class Views {
Programmatic, AssetBased
Programmatic,
AssetBased,
}

class MainActivity : ComponentActivity() {
Expand All @@ -43,9 +44,10 @@ class MainActivity : ComponentActivity() {
icon = {
Icon(
imageVector = Icons.Rounded.Create,
contentDescription = stringResource(id = R.string.programmatic)
contentDescription = stringResource(id = R.string.programmatic),
)
})
},
)
NavigationBarItem(
selected = false,
onClick = {
Expand All @@ -54,17 +56,18 @@ class MainActivity : ComponentActivity() {
icon = {
Icon(
imageVector = Icons.Rounded.AddCircle,
contentDescription = stringResource(id = R.string.assetBased)
contentDescription = stringResource(id = R.string.assetBased),
)
})
},
)
}
}
},
) { paddingValues ->
Surface(
modifier = Modifier
.fillMaxSize()
.padding(paddingValues),
color = MaterialTheme.colorScheme.background
color = MaterialTheme.colorScheme.background,
) {
when (selectedView.value) {
Views.Programmatic -> ProgrammaticOssView()
Expand All @@ -75,4 +78,4 @@ class MainActivity : ComponentActivity() {
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import se.premex.gross.oss.R
import io.githhub.usefulness.licensee.android.app.R
import se.premex.gross.ui.AssetLicenseParser
import se.premex.gross.ui.ErrorView
import se.premex.gross.ui.LoadingView
Expand All @@ -33,8 +33,8 @@ fun AssetsOssView() {
uiState.value =
OssViewState(
viewState = State.Failed(
errorMessage = ioException.localizedMessage ?: ""
)
errorMessage = ioException.localizedMessage ?: "",
),
)
}
}
Expand All @@ -44,10 +44,10 @@ fun AssetsOssView() {
is State.Loading -> LoadingView(stringResource(id = R.string.loading))
is State.Success -> {
Column {
Text(text = stringResource(id = se.premex.gross.R.string.assetBased))
Text(text = stringResource(id = R.string.assetBased))

OssView(state.data)
}
}
}
}
}
43 changes: 43 additions & 0 deletions sample/app/src/main/kotlin/se/premex/gross/OssKotlinCodeView.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package se.premex.gross

import androidx.compose.foundation.layout.Column
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
import se.premex.gross.core.Artifact
import se.premex.gross.core.Scm
import se.premex.gross.core.SpdxLicenses
import se.premex.gross.core.UnknownLicenses
import se.premex.gross.ui.OssView

@Composable
fun ProgrammaticOssView() {
Column {
Text(text = stringResource(id = R.string.programmatic))
OssView(
Gross.artifacts.map { artifact ->
Artifact(
name = artifact.name,
groupId = artifact.groupId,
artifactId = artifact.artifactId,
version = artifact.version,
scm = if (artifact.scm?.url != null) {
Scm(artifact.scm.url)
} else {
null
},
spdxLicenses = artifact.spdxLicenses.map {
SpdxLicenses(
identifier = it.identifier,
name = it.name,
url = it.url,
)
},
unknownLicenses = artifact.unknownLicenses.map {
UnknownLicenses(name = it.name, url = it.url)
},
)
},
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ val Pink80 = Color(0xFFEFB8C8)

val Purple40 = Color(0xFF6650a4)
val PurpleGrey40 = Color(0xFF625b71)
val Pink40 = Color(0xFF7D5260)
val Pink40 = Color(0xFF7D5260)
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import androidx.core.view.WindowCompat
private val DarkColorScheme = darkColorScheme(
primary = Purple80,
secondary = PurpleGrey80,
tertiary = Pink80
tertiary = Pink80,
)

private val LightColorScheme = lightColorScheme(
primary = Purple40,
secondary = PurpleGrey40,
tertiary = Pink40
tertiary = Pink40,

/* Other default colors to override
background = Color(0xFFFFFBFE),
Expand All @@ -34,15 +34,15 @@ private val LightColorScheme = lightColorScheme(
onTertiary = Color.White,
onBackground = Color(0xFF1C1B1F),
onSurface = Color(0xFF1C1B1F),
*/
*/
)

@Composable
fun GrossTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
// Dynamic color is available on Android 12+
dynamicColor: Boolean = true,
content: @Composable () -> Unit
content: @Composable () -> Unit,
) {
val colorScheme = when {
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
Expand All @@ -65,6 +65,6 @@ fun GrossTheme(
MaterialTheme(
colorScheme = colorScheme,
typography = Typography,
content = content
content = content,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ val Typography = Typography(
fontWeight = FontWeight.Normal,
fontSize = 16.sp,
lineHeight = 24.sp,
letterSpacing = 0.5.sp
)
letterSpacing = 0.5.sp,
),
/* Other default text styles to override
titleLarge = TextStyle(
fontFamily = FontFamily.Default,
Expand All @@ -30,5 +30,5 @@ val Typography = Typography(
lineHeight = 16.sp,
letterSpacing = 0.5.sp
)
*/
)
*/
)
Loading

0 comments on commit 9a26655

Please sign in to comment.