diff --git a/.github/workflows/check-pr.yaml b/.github/workflows/check-pr.yaml index 96985ec..664bba0 100644 --- a/.github/workflows/check-pr.yaml +++ b/.github/workflows/check-pr.yaml @@ -8,7 +8,7 @@ on: workflow_call: jobs: - assembleDebug: + assembleAndroidDebug: runs-on: macos-latest steps: @@ -21,10 +21,10 @@ jobs: distribution: 'zulu' java-version: '17' - - name: Assemble Debug + - name: Assemble Android Debug run: ./gradlew assembleDebug --stacktrace - assembleRelease: + assembleAndroidRelease: runs-on: macos-latest steps: @@ -37,7 +37,7 @@ jobs: distribution: 'zulu' java-version: '17' - - name: Assemble Release + - name: Assemble Android Release run: ./gradlew assembleRelease --stacktrace # UI tests on CI are flaky @@ -62,9 +62,9 @@ jobs: # arch: x86_64 # script: ./gradlew connectedCheck --stacktrace - check: + test: runs-on: macos-latest - needs: [assembleDebug, assembleRelease] + needs: [assembleAndroidDebug, assembleAndroidRelease] steps: - name: Checkout code @@ -76,12 +76,12 @@ jobs: distribution: 'zulu' java-version: '17' - - name: Run checks - run: ./gradlew check --stacktrace + - name: Run tests + run: ./gradlew :jsontree:jvmTest --tests com.sebastianneubauer.jsontree.JsonTreeParserTest --stacktrace detekt: runs-on: macos-latest - needs: [assembleDebug, assembleRelease] + needs: [assembleAndroidDebug, assembleAndroidRelease] steps: - name: Checkout code diff --git a/.gitignore b/.gitignore index 45c7f2d..a3c1abe 100644 --- a/.gitignore +++ b/.gitignore @@ -59,9 +59,28 @@ captures/ .idea/navEditor.xml .idea/other.xml .idea/studiobot.xml +.idea/artifacts .kotlin +# Xcode +*.xcodeproj/* +!*.xcodeproj/project.pbxproj +!*.xcodeproj/xcshareddata/ +!*.xcodeproj/project.xcworkspace/ +!*.xcworkspace/contents.xcworkspacedata +**/xcshareddata/WorkspaceSettings.xcsettings +xcuserdata +IDEWorkspaceChecks.plist + +# CocoaPods +Pods/ + +# iOS App packaging +*.ipa +*.dSYM.zip +*.dSYM + # Keystore files # Uncomment the following lines if you do not want to check your keystore files in. #*.jks diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d2f55a8..d65289a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,10 +5,9 @@ android-compileSdk = "34" java-toolchain = "17" compose = "1.6.11" -agp = "8.4.2" +agp = "8.3.2" kotlin = "2.0.0" publish = "0.29.0" -nexus-publish = "2.0.0" api-validator = "0.16.3" atomicfuGradlePlugin = "0.22.0" diff --git a/jsontree/build.gradle.kts b/jsontree/build.gradle.kts index 6e57616..addbb2d 100644 --- a/jsontree/build.gradle.kts +++ b/jsontree/build.gradle.kts @@ -17,10 +17,6 @@ kotlin { publishLibraryVariants("release") @OptIn(ExperimentalKotlinGradlePluginApi::class) instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) - @OptIn(ExperimentalKotlinGradlePluginApi::class) - compilerOptions { - jvmTarget.set(JvmTarget.JVM_1_8) - } @OptIn(ExperimentalKotlinGradlePluginApi::class) instrumentedTestVariant { @@ -90,7 +86,6 @@ kotlin { } } - android { namespace = "com.sebastianneubauer.jsontree" compileSdk = libs.versions.android.compileSdk.get().toInt() diff --git a/sample/build.gradle.kts b/sample/build.gradle.kts index a9b1c7d..7c46681 100644 --- a/sample/build.gradle.kts +++ b/sample/build.gradle.kts @@ -65,14 +65,13 @@ kotlin { } - - android { namespace = "com.sebastianneubauer.jsontreesample" compileSdk = 34 defaultConfig { - minSdk = 24 + minSdk = 21 + targetSdk = 34 } sourceSets["main"].apply { manifest.srcFile("src/androidMain/AndroidManifest.xml") @@ -82,6 +81,18 @@ android { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } + buildTypes { + getByName("release") { + isMinifyEnabled = true + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") + //for testing only, don't do this in your app + signingConfig = signingConfigs.getByName("debug") + } + getByName("debug") { + applicationIdSuffix = ".debug" + signingConfig = signingConfigs.getByName("debug") + } + } buildFeatures { compose = true } diff --git a/sample/src/commonMain/kotlin/App.kt b/sample/src/commonMain/kotlin/App.kt index 2ef6c25..f8789f7 100644 --- a/sample/src/commonMain/kotlin/App.kt +++ b/sample/src/commonMain/kotlin/App.kt @@ -22,6 +22,7 @@ import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Scaffold import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBarDefaults import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -39,22 +40,23 @@ import com.sebastianneubauer.jsontree.defaultLightColors import com.sebastianneubauer.jsontreesample.ui.theme.JsonTreeTheme import org.jetbrains.compose.ui.tooling.preview.Preview - @Composable internal fun App() = JsonTreeTheme { MainScreen() } @OptIn( - ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class, ExperimentalLayoutApi::class + ExperimentalMaterial3Api::class, + ExperimentalFoundationApi::class, + ExperimentalLayoutApi::class ) @Composable -fun MainScreen() { - +private fun MainScreen() { Scaffold( modifier = Modifier.safeDrawingPadding(), topBar = { CenterAlignedTopAppBar( + colors = TopAppBarDefaults.centerAlignedTopAppBarColors(containerColor = Color.White), title = { Text( modifier = Modifier.padding(horizontal = 16.dp), @@ -68,7 +70,9 @@ fun MainScreen() { contentWindowInsets = WindowInsets(top = 60.dp), ) { padding -> Column( - modifier = Modifier.fillMaxSize().padding(padding) + modifier = Modifier + .fillMaxSize() + .padding(padding) ) { var errorMessage: String? by remember { mutableStateOf(null) } var json: String by remember { mutableStateOf(simpleJson) } @@ -78,17 +82,24 @@ fun MainScreen() { var showItemCount: Boolean by remember { mutableStateOf(true) } var expandSingleChildren: Boolean by remember { mutableStateOf(true) } - FlowRow { - Button(modifier = Modifier.padding(horizontal = 8.dp), onClick = { - errorMessage = null - json = when (json) { - emptyJson -> simpleJson - simpleJson -> complexJson - complexJson -> invalidJson - invalidJson -> emptyJson - else -> throw IllegalStateException("No JSON selected!") + FlowRow( + modifier = Modifier + .fillMaxWidth() + .background(color = Color.White), + ) { + Button( + modifier = Modifier.padding(horizontal = 8.dp), + onClick = { + errorMessage = null + json = when (json) { + emptyJson -> simpleJson + simpleJson -> complexJson + complexJson -> invalidJson + invalidJson -> emptyJson + else -> throw IllegalStateException("No JSON selected!") + } } - }) { + ) { Text( text = when (json) { simpleJson -> "Simple Json" @@ -100,36 +111,47 @@ fun MainScreen() { ) } - Button(modifier = Modifier.padding(horizontal = 8.dp), onClick = { - val newState = when (initialState) { - TreeState.EXPANDED -> TreeState.COLLAPSED - TreeState.COLLAPSED -> TreeState.FIRST_ITEM_EXPANDED - TreeState.FIRST_ITEM_EXPANDED -> TreeState.EXPANDED + Button( + modifier = Modifier.padding(horizontal = 8.dp), + onClick = { + val newState = when (initialState) { + TreeState.EXPANDED -> TreeState.COLLAPSED + TreeState.COLLAPSED -> TreeState.FIRST_ITEM_EXPANDED + TreeState.FIRST_ITEM_EXPANDED -> TreeState.EXPANDED + } + initialState = newState } - initialState = newState - }) { + ) { Text(text = initialState.name) } - Button(modifier = Modifier.padding(horizontal = 8.dp), - onClick = { showIndices = !showIndices }) { + Button( + modifier = Modifier.padding(horizontal = 8.dp), + onClick = { showIndices = !showIndices } + ) { Text(text = if (showIndices) "Hide indices" else "Show indices") } - Button(modifier = Modifier.padding(horizontal = 8.dp), - onClick = { showItemCount = !showItemCount }) { + Button( + modifier = Modifier.padding(horizontal = 8.dp), + onClick = { showItemCount = !showItemCount } + ) { Text(text = if (showItemCount) "Hide item count" else "Show item count") } - Button(modifier = Modifier.padding(horizontal = 8.dp), onClick = { - colors = - if (colors == defaultLightColors) defaultDarkColors else defaultLightColors - }) { + Button( + modifier = Modifier.padding(horizontal = 8.dp), + onClick = { + colors = if (colors == defaultLightColors) defaultDarkColors else defaultLightColors + } + ) { Text(text = if (colors == defaultLightColors) "Light" else "Dark") } - Button(modifier = Modifier.padding(horizontal = 8.dp), - onClick = { expandSingleChildren = !expandSingleChildren }) { + Button( + modifier = Modifier.padding(horizontal = 8.dp), + onClick = { expandSingleChildren = !expandSingleChildren } + ) { Text(text = if (expandSingleChildren) "Expand children" else "Don't expand children") } } @@ -147,12 +169,20 @@ fun MainScreen() { val error = errorMessage if (error != null) { Text( - text = error, color = Color.Black + modifier = Modifier + .fillMaxSize() + .background( + color = if (colors == defaultLightColors) Color.White else Color.Black + ), + text = error, + color = if (colors == defaultLightColors) Color.Black else Color.White, ) } else { JsonTree( - modifier = Modifier.fillMaxSize() - .horizontalScroll(rememberScrollState()).background( + modifier = Modifier + .fillMaxSize() + .horizontalScroll(rememberScrollState()) + .background( if (colors == defaultLightColors) Color.White else Color.Black ), contentPadding = PaddingValues(16.dp), @@ -191,9 +221,8 @@ fun MainScreen() { } } - @Preview @Composable -fun PreviewMainScreen() = JsonTreeTheme { +private fun PreviewMainScreen() = JsonTreeTheme { MainScreen() } \ No newline at end of file