Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
MFlisarWork committed Nov 12, 2024
1 parent 2765a3a commit 4626b8e
Show file tree
Hide file tree
Showing 14 changed files with 379 additions and 295 deletions.
5 changes: 5 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ tasks.register("publishToMavenLocal") {
tasks.register("publishToMaven") {
dependsOn(gradle.includedBuild("gradle-plugin").task(":gradle-plugin:publishToMaven"))
//dependsOn(gradle.includedBuild("gradle-plugin").task(":gradle-plugin-shared:publishToMavenLocal"))
}

tasks.register("publish") {
dependsOn(gradle.includedBuild("gradle-plugin").task(":gradle-plugin:publish"))
//dependsOn(gradle.includedBuild("gradle-plugin").task(":gradle-plugin-shared:publishToMavenLocal"))
}
2 changes: 1 addition & 1 deletion demo/android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
id("compose-changelog")
}

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

android {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import com.michaelflisar.composechangelog.Changelog
import com.michaelflisar.composechangelog.ChangelogDefaults
import com.michaelflisar.composechangelog.ChangelogUtil
import com.michaelflisar.composechangelog.ShowChangelogDialog
import com.michaelflisar.composechangelog.ShowChangelogDialogIfNecessary
import com.michaelflisar.composechangelog.demo.classes.DemoPrefs
import com.michaelflisar.composechangelog.getAppVersionCode
import com.michaelflisar.composechangelog.getAppVersionName
Expand Down Expand Up @@ -60,11 +61,14 @@ class MainActivity : DemoActivity() {

// 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.create(LocalContext.current)
val changelogStateSaver = remember {
ChangelogStateSaverPreferences.create(context)
}

// ALTERNATIVE: if you use my kotpreference library like this demo you can do following:
val changelogStateSaverKotPrefs =
val changelogStateSaverKotPrefs = remember {
ChangelogStateSaverKotPreferences(DemoPrefs.lastShownVersionForChangelog)
}

// optional - here you can apply some customisations like changelog resource id, localized texts, styles, filter, sorter, ...
val setup = ChangelogDefaults.setup(
Expand All @@ -73,8 +77,7 @@ class MainActivity : DemoActivity() {

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

ShowChangelogDialogIfNecessary(changelogStateSaver, versionName, setup)

val showChangelog = remember { mutableStateOf(false) }
val infos = remember { mutableStateListOf<String>() }
Expand Down Expand Up @@ -140,7 +143,7 @@ class MainActivity : DemoActivity() {
} else ChangelogDefaults.renderer(),
versionFormatter = Constants.CHANGELOG_FORMATTER
)
Changelog.ShowChangelogDialog(setup) {
ShowChangelogDialog(setup) {
showChangelog.value = false
}
}
Expand Down
10 changes: 5 additions & 5 deletions demo/android/src/main/res/raw/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<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 versionCode="10005" date="2018-03-04">
<release versionCode="1000500" 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>
Expand All @@ -16,20 +16,20 @@
<bugfix>Some bugfix 3</bugfix>
<customTag>My custom tag text...</customTag>
</release>
<release versionCode="10004" date="2018-03-04">
<release versionCode="1000400" 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 versionCode="10003" date="2018-03-04">
<release versionCode="1000300" date="2018-03-04">
<info>Some info</info>
<new type="summary">Some improvement</new>
<bugfix>Some bugfix</bugfix>
</release>
<release versionCode="10002" date="2018-03-03" filter="dogs">
<release versionCode="1000200" 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 versionCode="10001" date="2018-03-02" filter="cats">
<release versionCode="1000100" 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>
Expand Down
8 changes: 5 additions & 3 deletions demo/desktop/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import com.michaelflisar.composechangelog.gradle.plugin.Changelog
import com.michaelflisar.composechangelog.DefaultVersionFormatter

Expand Down Expand Up @@ -42,9 +41,12 @@ compose.desktop {
mainClass = "com.michaelflisar.composechangelog.demo.MainKt"

nativeDistributions {
targetFormats(TargetFormat.Exe)
packageName = "Changelog JVM Demo"
//targetFormats(TargetFormat.Exe)

packageName = "com.michaelflisar.composechangelog"
packageVersion = version

modules("java.instrument", "jdk.unsupported")
}
}
}
2 changes: 1 addition & 1 deletion demo/desktop/changelog.preferences_pb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@


changelogVersion ��=
changelogVersion ��=
2 changes: 1 addition & 1 deletion demo/desktop/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<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">
<release versionCode="1000500" 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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ 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.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.font.FontWeight
Expand All @@ -16,8 +19,11 @@ 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.ChangelogUtil
import com.michaelflisar.composechangelog.ShowChangelogDialog
import com.michaelflisar.composechangelog.ShowChangelogDialogIfNecessary
import com.michaelflisar.composechangelog.getAppVersionName
import com.michaelflisar.composechangelog.setup
import com.michaelflisar.composechangelog.statesaver.preferences.ChangelogStateSaverPreferences
import com.michaelflisar.composechangelog.statesaver.preferences.create
Expand All @@ -26,15 +32,28 @@ fun main() {

application {

// TODO: get it from the exe in a real jvm application
val versionName = "1.0.6"
// does only work if you build an exe file!!! not when you run the debug config...
// test it with createDistributable for the demo => then you can remove the "if (versionName == "<UNKNOWN>")"!
var versionName = ChangelogUtil.getAppVersionName()
println("versionName = $versionName")
if (versionName == "<UNKNOWN>") {
versionName = "1.0.5"
}

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

// saver for the automatic changelog showing
val changelogStateSaver = ChangelogStateSaverPreferences.create()

var lastChangelog by remember { mutableStateOf(-1L) }
LaunchedEffect(Unit) {
lastChangelog = changelogStateSaver.lastShownVersion()
}

Window(
title = "Changelog Demo",
title = "Changelog Demo ($versionName)",
onCloseRequest = ::exitApplication,
state = rememberWindowState(
position = WindowPosition(Alignment.Center),
Expand All @@ -58,6 +77,10 @@ fun main() {
"Name: $versionName",
style = MaterialTheme.typography.body1
)
Text(
"Last Changelog: $lastChangelog",
style = MaterialTheme.typography.body1
)
}
Button(onClick = {
showChangelog.value = true
Expand All @@ -68,14 +91,14 @@ fun main() {

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

// automatic changelog dialog
val changelogStateSaver = ChangelogStateSaverPreferences.create()
Changelog.CheckedShowChangelog(changelogStateSaver, versionName, setup)

ShowChangelogDialogIfNecessary(changelogStateSaver, versionName, setup)
}
}
}
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ datastoreprefs = "1.1.1"

# mflisar
kotpreferences = "0.7.0"
toolbox = "2.2.0"
toolbox = "2.2.2"

[plugins]

Expand Down
Loading

0 comments on commit 4626b8e

Please sign in to comment.