Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Flisar authored and Michael Flisar committed Nov 12, 2024
1 parent 7656589 commit 2765a3a
Show file tree
Hide file tree
Showing 47 changed files with 673 additions and 170 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ plugins {
alias(libs.plugins.kotlin.multiplatform) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.parcelize) apply false
alias(libs.plugins.compose) apply false
alias(libs.plugins.gradle.maven.publish.plugin) apply false
alias(libs.plugins.kotlin.jvm) apply false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ import com.michaelflisar.composechangelog.Changelog
import com.michaelflisar.composechangelog.ChangelogDefaults
import com.michaelflisar.composechangelog.ChangelogUtil
import com.michaelflisar.composechangelog.demo.classes.DemoPrefs
import com.michaelflisar.composechangelog.getAppVersionCode
import com.michaelflisar.composechangelog.getAppVersionName
import com.michaelflisar.composechangelog.setup
import com.michaelflisar.composechangelog.statesaver.kotpreferences.ChangelogStateSaverKotPreferences
import com.michaelflisar.composechangelog.statesaver.preferences.ChangelogStateSaverPreferences
import com.michaelflisar.composechangelog.statesaver.preferences.create
import com.michaelflisar.composethemer.ComposeTheme
import com.michaelflisar.toolbox.androiddemoapp.DemoActivity
import com.michaelflisar.toolbox.androiddemoapp.composables.DemoAppThemeRegion
Expand All @@ -50,12 +54,13 @@ class MainActivity : DemoActivity() {
override fun ColumnScope.Content(
themeState: ComposeTheme.State
) {
val context = LocalContext.current

val regionState = rememberDemoExpandedRegions(listOf(1, 2))

// needed - you can also provide your own implementation instead of this simple one
// (which simply saves the last shown version inside a preference file)
val changelogStateSaver = ChangelogStateSaverPreferences(LocalContext.current)
val changelogStateSaver = ChangelogStateSaverPreferences.create(LocalContext.current)

// ALTERNATIVE: if you use my kotpreference library like this demo you can do following:
val changelogStateSaverKotPrefs =
Expand All @@ -67,7 +72,8 @@ class MainActivity : DemoActivity() {
)

// Changelog - this will show the changelog once only if the changelog was not shown for the current app version yet
Changelog.CheckedShowChangelog(changelogStateSaver, setup)
val versionName = ChangelogUtil.getAppVersionName(context)
Changelog.CheckedShowChangelog(changelogStateSaver, versionName, setup)


val showChangelog = remember { mutableStateOf(false) }
Expand Down Expand Up @@ -161,7 +167,7 @@ class MainActivity : DemoActivity() {
Column {
Text("App Version", fontWeight = FontWeight.Bold)
Text(
"Code: ${ChangelogUtil.getAppVersionCode(context)}",
"Code: ${ChangelogUtil.getAppVersionCode(context, Constants.CHANGELOG_FORMATTER)}",
style = MaterialTheme.typography.bodySmall
)
Text(
Expand Down Expand Up @@ -220,10 +226,12 @@ class MainActivity : DemoActivity() {
OutlinedButton(
onClick = {
scope.launch(Dispatchers.IO) {
val versionName = ChangelogUtil.getAppVersionName(context)
val showChangelog =
ChangelogUtil.shouldShowChangelogOnStart(
context,
changelogStateSaver
changelogStateSaver,
versionName,
Constants.CHANGELOG_FORMATTER
)
infos.add("shouldShow = ${showChangelog.shouldShow} ($showChangelog)")
}
Expand Down
50 changes: 50 additions & 0 deletions demo/desktop/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import com.michaelflisar.composechangelog.gradle.plugin.Changelog
import com.michaelflisar.composechangelog.DefaultVersionFormatter

plugins {
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.compose)
id("compose-changelog")
}

val version = "1.0.6"
val code = Changelog.buildVersionCode(version, DefaultVersionFormatter(DefaultVersionFormatter.Format.MajorMinorPatchCandidate))

kotlin {

jvm {
withJava()
}

sourceSets {
val jvmMain by getting {
dependencies {

implementation(compose.desktop.currentOs)

implementation(project(":ComposeChangelog:Core"))
implementation(project(":ComposeChangelog:Modules:StateSaverPreferences"))
implementation(project(":ComposeChangelog:Modules:StateSaverKotPreferences"))

// KotPreferences
//implementation(libs.kotpreferences.core)
//implementation(libs.kotpreferences.datastore)
//implementation(libs.kotpreferences.compose)
}
}
}
}

compose.desktop {
application {
mainClass = "com.michaelflisar.composechangelog.demo.MainKt"

nativeDistributions {
targetFormats(TargetFormat.Exe)
packageName = "Changelog JVM Demo"
packageVersion = version
}
}
}
3 changes: 3 additions & 0 deletions demo/desktop/changelog.preferences_pb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@


changelogVersion ��=
52 changes: 52 additions & 0 deletions demo/desktop/changelog.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<changelog>

<release versionName="1.0.6" date="2018-03-04">
<new type="summary">This version has a summary item only - no show more button will be shown even if show more buttons are enabled</new>
</release>

<release versionName="1.0.5" date="2018-03-04">
<info>Some info 1 - apostrophe test: it's weird, but apostrophes do not work in precompiled xml files placed in xml resources!</info>
<new type="summary">Some improvement 1</new>
<bugfix>Some bugfix 1</bugfix>
<info>Some info 2</info>
<new type="summary">Some improvement 2</new>
<bugfix>Some bugfix 2</bugfix>
<info>Some info 3</info>
<new>Some improvement 3</new>
<bugfix>Some bugfix 3</bugfix>
<customTag>My custom tag text...</customTag>
</release>
<release versionName="1.0.4" date="2018-03-04">
<new type="summary">This version has a summary item only - no show more button will be shown even if show more buttons are enabled</new>
</release>
<release versionName="1.0.3" date="2018-03-04">
<info>Some info</info>
<new type="summary">Some improvement</new>
<bugfix>Some bugfix</bugfix>
</release>
<release versionName="1.0.2" date="2018-03-03" filter="dogs">
<info>Some dogs info - filter only set in release tag</info>
<new type="summary">Some dogs improvement - filter only set in release tag</new>
<bugfix>Some dogs bugfix - filter only set in release tag</bugfix>
</release>
<release versionName="1.0.1" date="2018-03-02" filter="cats">
<info type="summary">single summary of version 1.05</info>
<info>Some cats info - filter only set in release tag</info>
<new>Some cats improvement - filter only set in release tag</new>
<bugfix>Some cats bugfix - filter only set in release tag</bugfix>
</release>
<release versionName="1.0.0" date="2018-03-01">
<info filter="cats" type="summary">single cats summary of version 1.00</info>
<info filter="dogs" type="summary">single dogs summary of version 1.00</info>
<info filter="cats">New cats added - this info has filter text 'cats'</info>
<info filter="dogs">New dogs added - this info has filter text 'dogs'</info>
<new filter="cats">Some cats improvement - this info has filter text 'cats'</new>
<new filter="dogs">Some dogs improvement - this info has filter text 'dogs'</new>
<bugfix filter="cats">Some cats bugfix - this info has filter text 'cats'</bugfix>
<bugfix filter="dogs">Some dogs bugfix - this info has filter text 'dogs'</bugfix>
</release>
<release versionName="0.0.1" date="2018-02-01">
<info>this release does not have any summary item and will be shown expanded even if summary is enabled - this behaviour can be adjusted by the second parameter in the builder with which you enable summaries</info>
</release>

</changelog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.michaelflisar.composechangelog.demo

import com.michaelflisar.composechangelog.DefaultVersionFormatter

object Constants {
val CHANGELOG_FORMATTER =
DefaultVersionFormatter(DefaultVersionFormatter.Format.MajorMinorPatchCandidate)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package com.michaelflisar.composechangelog.demo

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Button
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.WindowPosition
import androidx.compose.ui.window.application
import androidx.compose.ui.window.rememberWindowState
import com.michaelflisar.composechangelog.Changelog
import com.michaelflisar.composechangelog.ChangelogDefaults
import com.michaelflisar.composechangelog.setup
import com.michaelflisar.composechangelog.statesaver.preferences.ChangelogStateSaverPreferences
import com.michaelflisar.composechangelog.statesaver.preferences.create

fun main() {

application {

// TODO: get it from the exe in a real jvm application
val versionName = "1.0.6"

val setup = ChangelogDefaults.setup(
versionFormatter = Constants.CHANGELOG_FORMATTER
)

Window(
title = "Changelog Demo",
onCloseRequest = ::exitApplication,
state = rememberWindowState(
position = WindowPosition(Alignment.Center),
width = 800.dp,
height = 600.dp
)
) {
val showChangelog = remember { mutableStateOf(false) }

Column(
modifier = Modifier.padding(16.dp),
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
Column {
Text("App Version", fontWeight = FontWeight.Bold)
Text(
"Code: ${Constants.CHANGELOG_FORMATTER.parseVersion(versionName)}",
style = MaterialTheme.typography.body1
)
Text(
"Name: $versionName",
style = MaterialTheme.typography.body1
)
}
Button(onClick = {
showChangelog.value = true
}) {
Text("Show Changelog")
}
}

// manual changelog dialog
if (showChangelog.value) {
Changelog.ShowChangelogDialog(setup) {
showChangelog.value = false
}
}

// automatic changelog dialog
val changelogStateSaver = ChangelogStateSaverPreferences.create()
Changelog.CheckedShowChangelog(changelogStateSaver, versionName, setup)
}
}
}
9 changes: 3 additions & 6 deletions gradle-plugin/plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import com.vanniktech.maven.publish.JavaLibrary
import com.vanniktech.maven.publish.GradlePlugin
import com.vanniktech.maven.publish.JavadocJar
import com.vanniktech.maven.publish.SonatypeHost

Expand Down Expand Up @@ -40,17 +40,14 @@ gradlePlugin {
id = "compose-changelog"
implementationClass = "com.michaelflisar.composechangelog.gradle.plugin.ClassLoaderPlugin"
}
isAutomatedPublishing = false
//isAutomatedPublishing = false
}
}

// should be published automatically
group = "ComposeChangelog"

mavenPublishing {

configure(
JavaLibrary(
GradlePlugin(
javadocJar = JavadocJar.Dokka("dokkaHtml"),
sourcesJar = true
)
Expand Down
10 changes: 8 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[versions]

gradle = "8.7.2"
gradle = "8.5.2"
kotlin = "2.0.21"
compose = "1.7.0"
dokka = "1.9.20"
Expand All @@ -11,7 +11,10 @@ kotlinx-coroutines = "1.9.0"
kotlinx-io-core = "0.5.3"
androidx-activity = "1.9.3"

accompanist = "0.32.0"
accompanist = "0.36.0"
moko-parcelize = "0.9.0"

datastoreprefs = "1.1.1"

# mflisar
kotpreferences = "0.7.0"
Expand Down Expand Up @@ -49,9 +52,12 @@ compose-material-icons-extended = { module = "org.jetbrains.compose.material:ma
compose-material3 = { module = "org.jetbrains.compose.material3:material3", version.ref = "compose" }

androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity" }
datastore-preferences = { module = "androidx.datastore:datastore-preferences", version.ref = "datastoreprefs" }

drawablepainter = { module = "com.google.accompanist:accompanist-drawablepainter", version.ref = "accompanist" }

moko-parcelize = { module = "dev.icerock.moko:parcelize", version.ref = "moko-parcelize" }

kotpreferences-core = { module = "io.github.mflisar.kotpreferences:core", version.ref = "kotpreferences" }
kotpreferences-datastore = { module = "io.github.mflisar.kotpreferences:storage-datastore", version.ref = "kotpreferences" }
kotpreferences-compose = { module = "io.github.mflisar.kotpreferences:extension-compose", version.ref = "kotpreferences" }
Expand Down
8 changes: 7 additions & 1 deletion library/core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.parcelize)
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.compose)
alias(libs.plugins.dokka)
alias(libs.plugins.gradle.maven.publish.plugin)
}
Expand Down Expand Up @@ -37,7 +38,7 @@ val licenseUrl = "$github/blob/main/LICENSE"
kotlin {

// Java
//jvm()
jvm()

// Android
androidTarget {
Expand All @@ -63,14 +64,19 @@ kotlin {

commonMain.dependencies {

implementation(compose.components.resources)

// Kotlin
implementation(libs.kotlin)
implementation(libs.kotlinx.coroutines)

implementation(libs.compose.material3)

api(libs.moko.parcelize)

api(project(":ComposeChangelog:Shared"))
}

}
}

Expand Down
2 changes: 0 additions & 2 deletions library/core/src/androidMain/AndroidManifest.xml

This file was deleted.

Loading

0 comments on commit 2765a3a

Please sign in to comment.