Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Build APK

on:
push:
branches: [ "**" ]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Get short SHA
id: sha
run: echo "short=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT

- uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- uses: gradle/actions/setup-gradle@v4

- name: Build F-Droid release APK (unsigned)
run: ./gradlew assembleFdroidRelease

- name: Sign APK
run: |
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 -d > /tmp/ntfy-release.keystore
$ANDROID_SDK_ROOT/build-tools/$(ls $ANDROID_SDK_ROOT/build-tools | sort -V | tail -1)/apksigner sign \
--ks /tmp/ntfy-release.keystore \
--ks-key-alias "${{ secrets.KEY_ALIAS }}" \
--ks-pass "pass:${{ secrets.KEYSTORE_PASSWORD }}" \
--key-pass "pass:${{ secrets.KEY_PASSWORD }}" \
--out app/build/outputs/apk/fdroid/release/app-fdroid-release-signed.apk \
app/build/outputs/apk/fdroid/release/app-fdroid-release-unsigned.apk
rm /tmp/ntfy-release.keystore

- uses: actions/upload-artifact@v4
with:
name: ntfy-fdroid-release
path: app/build/outputs/apk/fdroid/release/app-fdroid-release-signed.apk
retention-days: 7

- name: Send success email
if: success()
continue-on-error: true
uses: dawidd6/action-send-mail@v3
with:
server_address: smtp.gmail.com
server_port: 587
username: ${{ secrets.NOTIFY_EMAIL }}
password: ${{ secrets.GMAIL_APP_PASSWORD }}
subject: "[EugeneShtoka/ntfy-android] Build succeeded: ${{ github.ref_name }} (${{ steps.sha.outputs.short }})"
to: ${{ secrets.NOTIFY_EMAIL }}
from: ${{ secrets.NOTIFY_FROM }}
body: |
Branch: ${{ github.ref_name }}
Commit: ${{ github.sha }}
Message: ${{ github.event.head_commit.message }}

Download APK:
https://github.com/EugeneShtoka/ntfy-android/actions/runs/${{ github.run_id }}
44 changes: 44 additions & 0 deletions .github/workflows/rebase.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Rebase on upstream main

on:
schedule:
- cron: '0 6 * * *' # daily at 6am UTC
workflow_dispatch: # allow manual trigger

jobs:
rebase:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: x-persist-header
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Add upstream remote
run: git remote add upstream https://github.com/binwiederhier/ntfy-android.git

- name: Fetch upstream main
run: git fetch upstream main

- name: Check for new upstream commits
id: check
run: |
UPSTREAM=$(git rev-parse upstream/main)
BASE=$(git merge-base HEAD upstream/main)
if [ "$UPSTREAM" = "$BASE" ]; then
echo "changed=false" >> $GITHUB_OUTPUT
else
echo "changed=true" >> $GITHUB_OUTPUT
fi

- name: Rebase on upstream main
if: steps.check.outputs.changed == 'true'
run: |
git config user.email "action@github.com"
git config user.name "GitHub Actions"
git rebase upstream/main

- name: Push rebased branch
if: steps.check.outputs.changed == 'true'
run: git push origin x-persist-header --force
1 change: 1 addition & 0 deletions app/src/main/java/io/heckel/ntfy/db/Database.kt
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ data class Notification(
@Embedded(prefix = "attachment_") val attachment: Attachment?,
@ColumnInfo(name = "deleted") val deleted: Boolean,
@Ignore val event: String = ApiService.EVENT_MESSAGE, // In-memory event type (message, message_delete, message_clear)
@Ignore val persist: Boolean = true, // If false, notification should not be saved to local history
) {
constructor(
id: String,
Expand Down
12 changes: 7 additions & 5 deletions app/src/main/java/io/heckel/ntfy/db/Repository.kt
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,14 @@ class Repository(private val sharedPrefs: SharedPreferences, database: Database)
if (maybeExistingNotification != null || notification.event != ApiService.EVENT_MESSAGE) {
return false
}
// Mark old notifications with the same sequence ID as deleted (this is an update to an existing sequence)
if (notification.sequenceId.isNotEmpty()) {
notificationDao.markAsDeletedBySequenceId(notification.subscriptionId, notification.sequenceId)
}
subscriptionDao.updateLastNotificationId(notification.subscriptionId, notification.id)
notificationDao.add(notification)
if (notification.persist) {
// Mark old notifications with the same sequence ID as deleted (this is an update to an existing sequence)
if (notification.sequenceId.isNotEmpty()) {
notificationDao.markAsDeletedBySequenceId(notification.subscriptionId, notification.sequenceId)
}
notificationDao.add(notification)
}
return true
}

Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/io/heckel/ntfy/msg/Message.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ data class Message(
@SerializedName("content_type") val contentType: String?,
val encoding: String?,
val attachment: MessageAttachment?,
val persist: Boolean?,
)

@Keep
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/io/heckel/ntfy/msg/NotificationParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ class NotificationParser {
attachment = attachment,
notificationId = deriveNotificationId(baseUrl, topic, sequenceId),
deleted = false,
event = message.event
event = message.event,
persist = message.persist ?: true,
)
return NotificationWithTopic(topic, notification)
}
Expand Down