Skip to content

Commit

Permalink
Merge pull request #4 from KoalaSat/add-new-note-kinds
Browse files Browse the repository at this point in the history
Add new note kinds
  • Loading branch information
KoalaSat authored Oct 24, 2024
2 parents 092dab8 + b6a7fa2 commit 5c3cd58
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 43 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ jobs:
draft: false
prerelease: ${{ steps.regex-match.outputs.match != '' }}

- name: Upload Free APK Universal Asset
id: upload-free-release-asset-universal-apk
- name: Upload APK Universal Asset
id: upload-release-asset-universal-apk
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: app/build/outputs/apk/release/app-release-unsigned-signed.apk
asset_name: amber-fdroid-universal-${{ github.ref_name }}.apk
asset_name: pokey-universal-${{ github.ref_name }}.apk
asset_content_type: application/zip
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ abstract class AppDatabase : RoomDatabase() {
Room.databaseBuilder(
context,
AppDatabase::class.java,
"amber_db_$pubKey",
"pokey_db_$pubKey",
)
.build()
instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class NotificationsService : Service() {
private var subscriptionNotificationId = "subscriptionNotificationId"
private var subscriptionInboxId = "inboxRelays"

private var receivedEventsCache = mutableSetOf<String>()
private var defaultRelayUrls = listOf(
"wss://relay.damus.io",
"wss://offchain.pub",
Expand Down Expand Up @@ -84,11 +85,11 @@ class NotificationsService : Service() {
relay: Relay,
afterEOSE: Boolean,
) {
if (receivedEventsCache.contains(event.id)) return
Log.d("Pokey", "Relay Event: ${relay.url} - $subscriptionId - ${event.toJson()}")
receivedEventsCache.add(event.id)
if (subscriptionId == subscriptionNotificationId) {
createNoteNotification(event)
} else if (subscriptionId == subscriptionInboxId) {
manageInboxRelays(event)
}
}

Expand Down Expand Up @@ -213,24 +214,38 @@ class NotificationsService : Service() {
TypedFilter(
types = COMMON_FEED_TYPES,
filter = SincePerRelayFilter(
kinds = listOf(1),
kinds = listOf(1, 4, 13, 9735),
tags = mapOf("p" to listOf(hexKey)),
since = RelayPool.getAll().associate { it.url to EOSETime(latestNotification) },
),
),
),
)
Client.sendFilter(
Client.sendFilterAndStopOnFirstResponse(
subscriptionInboxId,
listOf(
TypedFilter(
types = EVENT_FINDER_TYPES,
filter = SincePerRelayFilter(
kinds = listOf(10002),
authors = listOf(hexKey),
),
),
),
onResponse = { manageInboxRelays(it) },
)
Client.sendFilterAndStopOnFirstResponse(
subscriptionInboxId,
listOf(
TypedFilter(
types = EVENT_FINDER_TYPES,
filter = SincePerRelayFilter(
kinds = listOf(10050, 10002),
kinds = listOf(10050),
authors = listOf(hexKey),
),
),
),
onResponse = { manageInboxRelays(it) },
)
}
}
Expand All @@ -243,6 +258,7 @@ class NotificationsService : Service() {
timer.schedule(
object : TimerTask() {
override fun run() {
receivedEventsCache.clear()
RelayPool.getAll().forEach {
if (!it.isConnected()) {
Log.d(
Expand Down Expand Up @@ -331,8 +347,6 @@ class NotificationsService : Service() {
title = getString(R.string.new_private)
} else if (event.kind == 9735) {
title = getString(R.string.new_zap)
} else if (event.kind == 3) {
title = getString(R.string.new_follow)
}

if (title.isEmpty()) return@launch
Expand Down
10 changes: 3 additions & 7 deletions app/src/main/java/com/koalasat/pokey/ui/relays/RelaysFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,11 @@ class RelaysFragment : Fragment() {
val root: View = binding.root

val textView: TextView = binding.titleRelays
relaysViewModel.text.observe(viewLifecycleOwner) {
textView.text = it
}

Pokey.isEnabled.observe(viewLifecycleOwner) {
textView.text = if (it) {
getString(R.string.relays)
if (it) {
textView.visibility = View.GONE
} else {
getString(R.string.not_started)
textView.visibility = View.VISIBLE
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
package com.koalasat.pokey.ui.relays

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.koalasat.pokey.Pokey
import com.koalasat.pokey.R

class RelaysViewModel() : ViewModel() {
private val _text = MutableLiveData<String>().apply {
value = Pokey.getInstance().getString(R.string.not_started)
}
val text: LiveData<String> = _text
}
class RelaysViewModel() : ViewModel()
22 changes: 11 additions & 11 deletions app/src/main/res/layout/fragment_relays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@
<TextView
android:id="@+id/title_relays"
android:layout_width="412dp"
android:layout_height="69dp"
android:layout_height="39dp"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:textAlignment="center"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
android:hint="@string/not_started"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@+id/relays"
/>
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/relays"
android:layout_width="405dp"
android:layout_height="638dp"
android:layout_width="404dp"
android:layout_height="wrap_content"
android:padding="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.4"
app:layout_constraintHorizontal_bias="0.428"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.741" />
</androidx.constraintlayout.widget.ConstraintLayout>
app:layout_constraintTop_toBottomOf="@+id/title_relays" />
</androidx.constraintlayout.widget.ConstraintLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/menu/bottom_nav_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
android:icon="@drawable/ic_notifications_black_24dp"
android:title="@string/title_notifications" />

</menu>
</menu>
11 changes: 9 additions & 2 deletions app/src/main/res/navigation/mobile_navigation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@
android:id="@+id/navigation_home"
android:name="com.koalasat.pokey.ui.home.HomeFragment"
android:label="@string/title_home"
tools:layout="@layout/fragment_home" />
tools:layout="@layout/fragment_home" >
<action
android:id="@+id/action_navigation_home_to_navigation_relays"
app:destination="@id/navigation_relays" />
<action
android:id="@+id/action_navigation_home_to_navigation_notifications"
app:destination="@id/navigation_notifications" />
</fragment>

<fragment
android:id="@+id/navigation_relays"
Expand All @@ -22,4 +29,4 @@
android:name="com.koalasat.pokey.ui.notifications.NotificationsFragment"
android:label="@string/title_notifications"
tools:layout="@layout/fragment_notifications" />
</navigation>
</navigation>
2 changes: 1 addition & 1 deletion zapstore.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
amber:
pokey:
android:
identifier: com.kolasat.pokey
name: Pokey
Expand Down

0 comments on commit 5c3cd58

Please sign in to comment.