Skip to content

Commit

Permalink
Merge pull request #16 from KoalaSat/notify-follows
Browse files Browse the repository at this point in the history
Notify Follows
  • Loading branch information
KoalaSat authored Oct 25, 2024
2 parents d8baf88 + c56ed84 commit 026c464
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 54 deletions.
50 changes: 0 additions & 50 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,6 @@ jobs:
distribution: 'temurin'
java-version: 17

# - name: Setup Dart SDK
# uses: dart-lang/setup-dart@v1.6.5

# - name: Setup Android SDK
# uses: android-actions/setup-android@v3
# with:
# packages: 'platforms;android-34 build-tools;34.0.0'

# - name: Verify apksigner
# run: $ANDROID_SDK_ROOT/build-tools/34.0.0/apksigner --version

# - name: Install Apktool
# run: |
# wget "https://raw.githubusercontent.com/iBotPeaches/Apktool/master/scripts/linux/apktool"
# wget "https://github.com/iBotPeaches/Apktool/releases/download/v2.10.0/apktool_2.10.0.jar"
# mv apktool_2.10.0.jar apktool.jar
# sudo cp apktool /usr/local/bin
# sudo cp apktool.jar /usr/local/bin
# sudo chmod +x /usr/local/bin/apktool
# sudo chmod +x /usr/local/bin/apktool.jar

# - name: Verify Apktool Installation
# run: apktool --version

- name: Cache gradle
uses: actions/cache@v4
with:
Expand Down Expand Up @@ -100,29 +76,3 @@ jobs:
asset_path: app/build/outputs/apk/release/app-release-unsigned-signed.apk
asset_name: pokey-universal-${{ steps.set_asset_name.outputs.asset_tag }}.apk
asset_content_type: application/zip

# - name: Get Zap.Store latest release
# id: get-zap-store-release
# run: |
# LATEST_RELEASE=$(curl -s https://api.github.com/repos/zapstore/zapstore-cli/releases/latest)
# TAG_NAME=$(echo $LATEST_RELEASE | jq -r .tag_name)
# echo "Latest release tag: $TAG_NAME"
# echo "::set-output name=zapstore_version::$TAG_NAME"

# - name: Publish to Zap.Store
# id: publish-zap-store
# env:
# NSEC: ${{ secrets.POKEY_NSEC }}
# run: |
# mkdir /home/runner/.zapstore
# git clone https://github.com/zapstore/zapstore-cli.git
# cd zapstore-cli
# git fetch --tags
# git checkout ${{ steps.get-zap-store-release.outputs.zapstore_version }}
# dart pub get
# dart compile exe lib/main.dart -o build
# cd $GITHUB_WORKSPACE
# APKSIGNER_PATH=$ANDROID_SDK_ROOT/build-tools/34.0.0/apksigner ./zapstore-cli/build publish pokey



10 changes: 10 additions & 0 deletions app/src/main/java/com/koalasat/pokey/models/EncryptedStorage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ object PrefKeys {
const val NOTIFY_REACTIONS = "notify_reactions"
const val NOTIFY_MENTIONS = "notify_mentions"
const val NOTIFY_REPOSTS = "notify_reposts"
const val NOTIFY_FOLLOWS = "notify_follows"
}
object DefaultKeys {
const val NOTIFY_REPLIES = true
Expand All @@ -25,6 +26,7 @@ object DefaultKeys {
const val NOTIFY_QUOTES = true
const val NOTIFY_MENTIONS = true
const val NOTIFY_REPOSTS = true
const val NOTIFY_FOLLOWS = true
}

object EncryptedStorage {
Expand All @@ -49,6 +51,8 @@ object EncryptedStorage {
val notifyMentions: LiveData<Boolean> get() = _notifyMentions
private val _notifyResposts = MutableLiveData<Boolean>().apply { DefaultKeys.NOTIFY_REPOSTS }
val notifyResposts: LiveData<Boolean> get() = _notifyResposts
private val _notifyFollows = MutableLiveData<Boolean>().apply { DefaultKeys.NOTIFY_FOLLOWS }
val notifyFollows: LiveData<Boolean> get() = _notifyFollows

fun init(context: Context) {
val masterKey: MasterKey =
Expand All @@ -72,6 +76,7 @@ object EncryptedStorage {
_notifyQuotes.value = sharedPreferences.getBoolean(PrefKeys.NOTIFY_QUOTES, DefaultKeys.NOTIFY_QUOTES)
_notifyMentions.value = sharedPreferences.getBoolean(PrefKeys.NOTIFY_MENTIONS, DefaultKeys.NOTIFY_MENTIONS)
_notifyResposts.value = sharedPreferences.getBoolean(PrefKeys.NOTIFY_REPOSTS, DefaultKeys.NOTIFY_REPOSTS)
_notifyFollows.value = sharedPreferences.getBoolean(PrefKeys.NOTIFY_FOLLOWS, DefaultKeys.NOTIFY_FOLLOWS)
}

fun updatePubKey(newValue: String) {
Expand Down Expand Up @@ -113,4 +118,9 @@ object EncryptedStorage {
sharedPreferences.edit().putBoolean(PrefKeys.NOTIFY_REPOSTS, newValue).apply()
_notifyResposts.value = newValue
}

fun updateNotifyFollows(newValue: Boolean) {
sharedPreferences.edit().putBoolean(PrefKeys.NOTIFY_FOLLOWS, newValue).apply()
_notifyFollows.value = newValue
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,13 @@ class NotificationsService : Service() {
text = "$sats Sats"
}
}
3 -> {
if (!EncryptedStorage.notifyFollows.value!!) return@launch
if (event.taggedUsers().last() != EncryptedStorage.pubKey.value) return@launch

title = getString(R.string.new_follow)
nip32Bech32 = Hex.decode(event.pubKey).toNpub()
}
}

if (title.isEmpty()) return@launch
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.koalasat.pokey.ui.notifications

import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand Down Expand Up @@ -39,7 +38,6 @@ class NotificationsFragment : Fragment() {
viewModel.updateNotifyZaps(isChecked)
}
viewModel.newZaps.observe(viewLifecycleOwner) { value ->
Log.d("Pokey", "binding.newZaps.isChecked" + binding.newZaps.isChecked)
binding.newZaps.isChecked = value
}

Expand Down Expand Up @@ -83,6 +81,14 @@ class NotificationsFragment : Fragment() {
binding.newReposts.isChecked = value
}

viewModel.newFollows.value.apply { EncryptedStorage.notifyFollows.value }
binding.newFollows.setOnCheckedChangeListener { _, isChecked ->
viewModel.updateNotifyFollows(isChecked)
}
viewModel.newFollows.observe(viewLifecycleOwner) { value ->
binding.newFollows.isChecked = value.apply { EncryptedStorage.notifyFollows.value }
}

return root
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@ class NotificationsViewModel : ViewModel() {
private val _newReposts = MutableLiveData<Boolean>().apply { value = EncryptedStorage.notifyResposts.value }
val newReposts: LiveData<Boolean> = _newReposts

private val _newFollows = MutableLiveData<Boolean>().apply { value = EncryptedStorage.notifyFollows.value }
val newFollows: LiveData<Boolean> = _newFollows

init {
EncryptedStorage.notifyReplies.observeForever { value ->
_newReplies.value = value
}
Log.d("Pokey", "_newZaps.value" + _newZaps.value)
EncryptedStorage.notifyZaps.observeForever { value ->
_newZaps.value = value
Log.d("Pokey", "observeForever" + value)
}
EncryptedStorage.notifyQuotes.observeForever { value ->
_newQuotes.value = value
Expand All @@ -53,6 +55,9 @@ class NotificationsViewModel : ViewModel() {
EncryptedStorage.notifyResposts.observeForever { value ->
_newReposts.value = value
}
EncryptedStorage.notifyFollows.observeForever { value ->
_newFollows.value = value
}
}

fun updateNotifyReplies(value: Boolean) {
Expand All @@ -72,7 +77,6 @@ class NotificationsViewModel : ViewModel() {

fun updateNotifyZaps(value: Boolean) {
_newZaps.value = value
Log.d("Pokey", "updateNotifyZaps" + value)
EncryptedStorage.updateNotifyZaps(value)
}

Expand All @@ -90,4 +94,9 @@ class NotificationsViewModel : ViewModel() {
_newReposts.value = value
EncryptedStorage.updateNotifyReposts(value)
}

fun updateNotifyFollows(value: Boolean) {
_newFollows.value = value
EncryptedStorage.updateNotifyFollows(value)
}
}
7 changes: 7 additions & 0 deletions app/src/main/res/layout/fragment_notifications.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,12 @@
android:layout_height="wrap_content"
android:minHeight="48dp"
android:text="@string/active_private_messages" />

<Switch
android:id="@+id/newFollows"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="48dp"
android:text="@string/active_follows" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@
<string name="active_quotes">New quotes</string>
<string name="active_mentions">New mentions</string>
<string name="active_reposts">New reposts</string>
<string name="active_follows">New follows</string>
</resources>

0 comments on commit 026c464

Please sign in to comment.