diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index cd2f7f0..ce3b430 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -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: @@ -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 - - - diff --git a/app/src/main/java/com/koalasat/pokey/models/EncryptedStorage.kt b/app/src/main/java/com/koalasat/pokey/models/EncryptedStorage.kt index ff24ab8..6ce6ee3 100644 --- a/app/src/main/java/com/koalasat/pokey/models/EncryptedStorage.kt +++ b/app/src/main/java/com/koalasat/pokey/models/EncryptedStorage.kt @@ -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 @@ -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 { @@ -49,6 +51,8 @@ object EncryptedStorage { val notifyMentions: LiveData get() = _notifyMentions private val _notifyResposts = MutableLiveData().apply { DefaultKeys.NOTIFY_REPOSTS } val notifyResposts: LiveData get() = _notifyResposts + private val _notifyFollows = MutableLiveData().apply { DefaultKeys.NOTIFY_FOLLOWS } + val notifyFollows: LiveData get() = _notifyFollows fun init(context: Context) { val masterKey: MasterKey = @@ -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) { @@ -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 + } } diff --git a/app/src/main/java/com/koalasat/pokey/service/NotificationsService.kt b/app/src/main/java/com/koalasat/pokey/service/NotificationsService.kt index 7b4ecbb..8d5ab78 100644 --- a/app/src/main/java/com/koalasat/pokey/service/NotificationsService.kt +++ b/app/src/main/java/com/koalasat/pokey/service/NotificationsService.kt @@ -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 diff --git a/app/src/main/java/com/koalasat/pokey/ui/notifications/NotificationsFragment.kt b/app/src/main/java/com/koalasat/pokey/ui/notifications/NotificationsFragment.kt index 453a587..93e3479 100644 --- a/app/src/main/java/com/koalasat/pokey/ui/notifications/NotificationsFragment.kt +++ b/app/src/main/java/com/koalasat/pokey/ui/notifications/NotificationsFragment.kt @@ -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 @@ -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 } @@ -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 } diff --git a/app/src/main/java/com/koalasat/pokey/ui/notifications/NotificationsViewModel.kt b/app/src/main/java/com/koalasat/pokey/ui/notifications/NotificationsViewModel.kt index 5d7e7d0..416daec 100644 --- a/app/src/main/java/com/koalasat/pokey/ui/notifications/NotificationsViewModel.kt +++ b/app/src/main/java/com/koalasat/pokey/ui/notifications/NotificationsViewModel.kt @@ -29,6 +29,9 @@ class NotificationsViewModel : ViewModel() { private val _newReposts = MutableLiveData().apply { value = EncryptedStorage.notifyResposts.value } val newReposts: LiveData = _newReposts + private val _newFollows = MutableLiveData().apply { value = EncryptedStorage.notifyFollows.value } + val newFollows: LiveData = _newFollows + init { EncryptedStorage.notifyReplies.observeForever { value -> _newReplies.value = value @@ -36,7 +39,6 @@ class NotificationsViewModel : ViewModel() { 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 @@ -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) { @@ -72,7 +77,6 @@ class NotificationsViewModel : ViewModel() { fun updateNotifyZaps(value: Boolean) { _newZaps.value = value - Log.d("Pokey", "updateNotifyZaps" + value) EncryptedStorage.updateNotifyZaps(value) } @@ -90,4 +94,9 @@ class NotificationsViewModel : ViewModel() { _newReposts.value = value EncryptedStorage.updateNotifyReposts(value) } + + fun updateNotifyFollows(value: Boolean) { + _newFollows.value = value + EncryptedStorage.updateNotifyFollows(value) + } } diff --git a/app/src/main/res/layout/fragment_notifications.xml b/app/src/main/res/layout/fragment_notifications.xml index 259a575..62dfd7a 100644 --- a/app/src/main/res/layout/fragment_notifications.xml +++ b/app/src/main/res/layout/fragment_notifications.xml @@ -68,5 +68,12 @@ android:layout_height="wrap_content" android:minHeight="48dp" android:text="@string/active_private_messages" /> + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f8de70f..cbb21ef 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -33,4 +33,5 @@ New quotes New mentions New reposts + New follows