diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c9100ba..8fb90d9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,7 +34,7 @@ jobs: distribution: 'temurin' - name: Setup gradle - uses: gradle/gradle-build-action@v2.4.2 + uses: gradle/gradle-build-action@ac2d340dc04d9e1113182899e983b5400c17cda1 - name: Check api run: ./gradlew apiCheck @@ -59,7 +59,7 @@ jobs: distribution: 'temurin' - name: Setup gradle - uses: gradle/gradle-build-action@v2.4.2 + uses: gradle/gradle-build-action@ac2d340dc04d9e1113182899e983b5400c17cda1 - name: Test ${{ matrix.config.target }} targets continue-on-error: ${{ matrix.config.continueOnError }} @@ -84,7 +84,7 @@ jobs: distribution: 'temurin' - name: Setup gradle - uses: gradle/gradle-build-action@v2.4.2 + uses: gradle/gradle-build-action@ac2d340dc04d9e1113182899e983b5400c17cda1 - name: Setup Pages uses: actions/configure-pages@v3 @@ -101,47 +101,6 @@ jobs: id: deployment uses: actions/deploy-pages@v1 - - name: Create new release from tag - env: - github_token: ${{ secrets.GITHUB_TOKEN }} - uses: softprops/action-gh-release@v1 - with: - generate_release_notes: true - token: ${{ env.github_token }} - - - create-staging-repository: - runs-on: ubuntu-latest - name: Create staging repository - needs: release - outputs: - repository_id: ${{ steps.create.outputs.repository_id }} - steps: - - id: create - uses: nexus-actions/create-nexus-staging-repo@v1.3.0 - with: - username: ${{ secrets.SONATYPE_USERNAME }} - password: ${{ secrets.SONATYPE_PASSWORD }} - staging_profile_id: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} - description: Created by GitHub Actions - base_url: https://s01.oss.sonatype.org/service/local/ - - publish: - name: Publish to Maven - runs-on: macos-latest - needs: create-staging-repository - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup JDK 17 - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - - - name: Setup gradle - uses: gradle/gradle-build-action@v2.4.2 - - name: Write secrets to local.properties run: | echo sonatypeUsername="${SONATYPE_USERNAME}" >> "local.properties" @@ -149,25 +108,25 @@ jobs: echo gpgKeyPassword="${GPG_KEY_PASSWORD}" >> "local.properties" echo gpgKeySecret="${GPG_KEY_SECRET}" >> "local.properties" env: - SONATYPE_REPOSITORY_ID: ${{ needs.create-staging-repository.outputs.repository_id }} - SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + SONATYPE_USERNAME: mirzemehdi SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} GPG_KEY_PASSWORD: ${{ secrets.GPG_KEY_PASSWORD }} GPG_KEY_SECRET: ${{ secrets.GPG_KEY_SECRET }} - - name: Release to sonatype - run: ./gradlew publishAllPublicationsToMavenRepository - close-staging-repository: - name: Close staging repository - runs-on: ubuntu-latest - needs: [ create-staging-repository, publish ] - if: ${{ always() && needs.create-staging-repository.result == 'success' }} - steps: - - name: Close staging repository - uses: nexus-actions/release-nexus-staging-repo@6632a81bfab63557b2717e8423b0a620ae5aa414 + - name: Publish to sonatype + uses: gradle/gradle-build-action@ac2d340dc04d9e1113182899e983b5400c17cda1 with: - username: ${{ secrets.SONATYPE_USERNAME }} - password: ${{ secrets.SONATYPE_PASSWORD }} - staging_repository_id: ${{ needs.create-staging-repository.outputs.repository_id }} - base_url: https://s01.oss.sonatype.org/service/local/ \ No newline at end of file + arguments: | + publishToSonatype + closeAndReleaseSonatypeStagingRepository + + - name: Create new release from tag + env: + github_token: ${{ secrets.GITHUB_TOKEN }} + uses: softprops/action-gh-release@v1 + with: + generate_release_notes: true + token: ${{ env.github_token }} + + diff --git a/build.gradle.kts b/build.gradle.kts index a2d7247..fd157ab 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -12,7 +12,7 @@ plugins { alias(libs.plugins.kotlinNativeCocoaPods) apply false alias(libs.plugins.dokka) apply false alias(libs.plugins.kotlinx.binary.validator) - + alias(libs.plugins.nexusPublish) id("com.google.gms.google-services") version "4.4.0" apply false } @@ -21,9 +21,8 @@ plugins { allprojects { group = "io.github.mirzemehdi" - version = "1.2.0-alpha02" - val sonatypeUsername = gradleLocalProperties(rootDir).getProperty("sonatypeUsername") - val sonatypePassword = gradleLocalProperties(rootDir).getProperty("sonatypePassword") + version = project.properties["kmpNotifierVersion"] as String + val gpgKeySecret = gradleLocalProperties(rootDir).getProperty("gpgKeySecret") val gpgKeyPassword = gradleLocalProperties(rootDir).getProperty("gpgKeyPassword") @@ -36,24 +35,6 @@ allprojects { extensions.configure { - repositories { - maven { - val isSnapshot = version.toString().endsWith("SNAPSHOT") - val repositoryId = System.getenv("SONATYPE_REPOSITORY_ID") ?: "" - url = uri( - when{ - isSnapshot.not() && repositoryId.isNotEmpty() -> "https://s01.oss.sonatype.org/service/local/staging/deployByRepositoryId/${repositoryId}/" - isSnapshot.not() -> "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2" - else -> "https://s01.oss.sonatype.org/content/repositories/snapshots" - } - ) - credentials { - username = sonatypeUsername - password = sonatypePassword - } - } - } - val javadocJar = tasks.register("javadocJar") { dependsOn(tasks.getByName("dokkaHtml")) archiveClassifier.set("javadoc") @@ -104,5 +85,17 @@ allprojects { dependsOn(project.tasks.withType(Sign::class.java)) } } +nexusPublishing { + repositories { + sonatype { //only for users registered in Sonatype after 24 Feb 2021 + nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) + snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) + val sonatypeUsername = gradleLocalProperties(rootDir).getProperty("sonatypeUsername") + val sonatypePassword = gradleLocalProperties(rootDir).getProperty("sonatypePassword") + username = sonatypeUsername + password = sonatypePassword + } + } +} diff --git a/gradle.properties b/gradle.properties index 23232d9..2c463e7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,4 +18,6 @@ kotlin.mpp.androidSourceSetLayoutVersion=2 kotlin.mpp.enableCInteropCommonization=true #Development -development=true \ No newline at end of file +development=true + +kmpNotifierVersion=1.2.0-alpha02 \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 1125b19..3cbfb93 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,25 +1,27 @@ [versions] -compose = "1.6.7" -compose-plugin = "1.6.10" -agp = "8.2.0" +compose = "1.6.8" +compose-plugin = "1.6.11" +agp = "8.2.2" android-minSdk = "21" android-compileSdk = "34" android-targetSdk = "34" -androidx-activityCompose = "1.9.0" +androidx-activityCompose = "1.9.1" androidx-core-ktx = "1.13.1" androidx-appcompat = "1.7.0" androidx-material = "1.12.0" androidx-constraintlayout = "2.1.4" -androidx-test-junit = "1.1.5" -androidx-espresso-core = "3.5.1" +androidx-test-junit = "1.2.1" +androidx-espresso-core = "3.6.1" androidx-startup-runtime = "1.1.1" kotlin = "2.0.0" junit = "4.13.2" -koin = "3.6.0-Beta5" +koin = "4.0.0-RC1" kotlinx-binary-validator = "0.13.2" dokka = "1.9.10" firebase-messaging = "24.0.0" kotlinx-coroutine = "1.9.0-RC" +nexusPublish = "2.0.0" + [libraries] @@ -55,4 +57,5 @@ androidLibrary = { id = "com.android.library", version.ref = "agp" } kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } kotlinNativeCocoaPods = { id = "org.jetbrains.kotlin.native.cocoapods", version.ref = "kotlin" } kotlinx-binary-validator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "kotlinx-binary-validator" } -dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } \ No newline at end of file +dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } +nexusPublish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "nexusPublish" } diff --git a/kmpnotifier/src/androidMain/kotlin/com/mmk/kmpnotifier/notification/AndroidNotifier.kt b/kmpnotifier/src/androidMain/kotlin/com/mmk/kmpnotifier/notification/AndroidNotifier.kt index a51cb67..9520932 100644 --- a/kmpnotifier/src/androidMain/kotlin/com/mmk/kmpnotifier/notification/AndroidNotifier.kt +++ b/kmpnotifier/src/androidMain/kotlin/com/mmk/kmpnotifier/notification/AndroidNotifier.kt @@ -67,9 +67,13 @@ internal class AndroidNotifier( } private fun getPendingIntent(payloadData: Map): PendingIntent? { + + val intent = getLauncherActivityIntent()?.apply { putExtra(ACTION_NOTIFICATION_CLICK, ACTION_NOTIFICATION_CLICK) payloadData.forEach { putExtra(it.key, it.value) } + val urlData = payloadData.getOrDefault(Notifier.KEY_URL, null) + urlData?.let { setData(Uri.parse(urlData)) } } intent?.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) @@ -84,5 +88,4 @@ internal class AndroidNotifier( return packageManager.getLaunchIntentForPackage(context.applicationContext.packageName) } - } \ No newline at end of file diff --git a/kmpnotifier/src/commonMain/kotlin/com/mmk/kmpnotifier/notification/Notifier.kt b/kmpnotifier/src/commonMain/kotlin/com/mmk/kmpnotifier/notification/Notifier.kt index 018a3a0..d8084de 100644 --- a/kmpnotifier/src/commonMain/kotlin/com/mmk/kmpnotifier/notification/Notifier.kt +++ b/kmpnotifier/src/commonMain/kotlin/com/mmk/kmpnotifier/notification/Notifier.kt @@ -1,10 +1,16 @@ package com.mmk.kmpnotifier.notification +import org.koin.core.scope.Scope + /** * Class that represent local notification */ public interface Notifier { + public companion object { + public const val KEY_URL: String = "URL" + } + /** * Sends local notification to device * @param title Title part diff --git a/sample/src/commonMain/kotlin/com/mmk/kmpnotifier/sample/App.kt b/sample/src/commonMain/kotlin/com/mmk/kmpnotifier/sample/App.kt index c85a110..5e2746b 100644 --- a/sample/src/commonMain/kotlin/com/mmk/kmpnotifier/sample/App.kt +++ b/sample/src/commonMain/kotlin/com/mmk/kmpnotifier/sample/App.kt @@ -17,6 +17,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp +import com.mmk.kmpnotifier.notification.Notifier import com.mmk.kmpnotifier.notification.NotifierManager @Composable @@ -45,7 +46,14 @@ fun App() { val permissionUtil = remember { NotifierManager.getPermissionUtil() } var notificationId by remember { mutableStateOf(0) } Button(onClick = { - notificationId = notifier.notify("Title", "bodyMessage") + notificationId = notifier.notify( + title = "Title", + body = "bodyMessage", + payloadData = mapOf( + Notifier.KEY_URL to "https://github.com/mirzemehdi/KMPNotifier/", + "extraKey" to "randomValue" + ) + ) }) { Text("Send Local Notification") }