Skip to content
This repository was archived by the owner on May 23, 2025. It is now read-only.
Draft
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
3 changes: 1 addition & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ dependencies {

implementation libs.bundles.filemojicompat

implementation libs.bouncycastle
implementation libs.unified.push
implementation libs.bundles.unifiedpush

implementation libs.bundles.xmldiff

Expand Down
4 changes: 0 additions & 4 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
-keepattributes SourceFile,LineNumberTable
-renamesourcefileattribute SourceFile

# Bouncy Castle -- Keep EC
-keep class org.bouncycastle.jcajce.provider.asymmetric.EC$* { *; }
-keep class org.bouncycastle.jcajce.provider.asymmetric.ec.KeyPairGeneratorSpi$EC

# Preference fragments can be referenced by name, ensure they remain
# https://github.com/tuskyapp/Tusky/issues/3161
-keep class * extends androidx.preference.PreferenceFragmentCompat
Expand Down
15 changes: 4 additions & 11 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -159,19 +159,12 @@
android:name=".receiver.SendStatusBroadcastReceiver"
android:enabled="true"
android:exported="false" />
<receiver
android:exported="true"
android:enabled="true"
android:name=".receiver.UnifiedPushBroadcastReceiver"
tools:ignore="ExportedReceiver">
<service android:name=".receiver.UnifiedPushService"
android:exported="false">
<intent-filter>
<action android:name="org.unifiedpush.android.connector.MESSAGE"/>
<action android:name="org.unifiedpush.android.connector.UNREGISTERED"/>
<action android:name="org.unifiedpush.android.connector.NEW_ENDPOINT"/>
<action android:name="org.unifiedpush.android.connector.REGISTRATION_FAILED"/>
<action android:name="org.unifiedpush.android.connector.REGISTRATION_REFUSED"/>
<action android:name="org.unifiedpush.android.connector.PUSH_EVENT"/>
</intent-filter>
</receiver>
</service>
<receiver
android:exported="true"
android:enabled="true"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/keylesspalace/tusky/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ import com.keylesspalace.tusky.components.login.LoginActivity
import com.keylesspalace.tusky.components.preference.PreferencesActivity
import com.keylesspalace.tusky.components.scheduled.ScheduledStatusActivity
import com.keylesspalace.tusky.components.search.SearchActivity
import com.keylesspalace.tusky.components.systemnotifications.NotificationService
import com.keylesspalace.tusky.components.systemnotifications.NotificationHelper
import com.keylesspalace.tusky.components.trending.TrendingActivity
import com.keylesspalace.tusky.databinding.ActivityMainBinding
import com.keylesspalace.tusky.db.DraftsAlert
Expand Down Expand Up @@ -137,7 +137,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvider {
lateinit var eventHub: EventHub

@Inject
lateinit var notificationService: NotificationService
lateinit var notificationHelper: NotificationHelper

@Inject
lateinit var cacheUpdater: CacheUpdater
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/java/com/keylesspalace/tusky/MainViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import com.keylesspalace.tusky.appstore.ConversationsLoadingEvent
import com.keylesspalace.tusky.appstore.EventHub
import com.keylesspalace.tusky.appstore.NewNotificationsEvent
import com.keylesspalace.tusky.appstore.NotificationsLoadingEvent
import com.keylesspalace.tusky.components.systemnotifications.NotificationService
import com.keylesspalace.tusky.components.systemnotifications.NotificationHelper
import com.keylesspalace.tusky.db.AccountManager
import com.keylesspalace.tusky.entity.Emoji
import com.keylesspalace.tusky.entity.Notification
Expand All @@ -48,7 +48,7 @@ class MainViewModel @Inject constructor(
private val eventHub: EventHub,
private val accountManager: AccountManager,
private val shareShortcutHelper: ShareShortcutHelper,
private val notificationService: NotificationService,
private val notificationHelper: NotificationHelper,
) : ViewModel() {

private val activeAccount = accountManager.activeAccount!!
Expand Down Expand Up @@ -160,15 +160,15 @@ class MainViewModel @Inject constructor(
// notifications fully disabled) will get unnoticed; and also an app restart cannot be easily triggered by the user.

// TODO it's quite odd to separate channel creation (for an account) from the "is enabled by channels" question below
notificationService.createNotificationChannelsForAccount(activeAccount)
notificationHelper.createNotificationChannelsForAccount(activeAccount)

if (notificationService.areNotificationsEnabledBySystem()) {
if (notificationHelper.areNotificationsEnabledBySystem()) {
viewModelScope.launch {
notificationService.setupNotifications(activity)
notificationHelper.setupNotifications(activity)
}
} else {
viewModelScope.launch {
notificationService.disableAllNotifications()
notificationHelper.disableAllNotifications()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ data class InstanceInfo(
val version: String?,
val translationEnabled: Boolean?,
val mastodonApiVersion: Int?,
val vapidKey: String?
)
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ class InstanceInfoRepository @Inject constructor(
version = this?.version,
translationEnabled = this?.translationEnabled,
mastodonApiVersion = this?.mastodonApiVersion,
vapidKey = this?.vapidKey
)

private fun Instance.toEntity() = InstanceInfoEntity(
Expand Down Expand Up @@ -176,6 +177,7 @@ class InstanceInfoRepository @Inject constructor(
maxFieldValueLength = this.pleroma?.metadata?.fieldLimits?.valueLength,
translationEnabled = this.configuration?.translation?.enabled,
mastodonApiVersion = this.apiVersions?.mastodon,
vapidKey = this.configuration?.vapid?.publicKey
)

private fun InstanceV1.toEntity(instanceName: String) =
Expand Down Expand Up @@ -205,6 +207,7 @@ class InstanceInfoRepository @Inject constructor(
maxFieldValueLength = this.pleroma?.metadata?.fieldLimits?.valueLength,
translationEnabled = null,
mastodonApiVersion = null,
vapidKey = null
)

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import com.keylesspalace.tusky.appstore.PreferenceChangedEvent
import com.keylesspalace.tusky.components.notifications.requests.NotificationRequestsActivity
import com.keylesspalace.tusky.components.preference.PreferencesFragment.ReadingOrder
import com.keylesspalace.tusky.components.systemnotifications.NotificationChannelData
import com.keylesspalace.tusky.components.systemnotifications.NotificationService
import com.keylesspalace.tusky.components.systemnotifications.NotificationHelper
import com.keylesspalace.tusky.databinding.FragmentTimelineNotificationsBinding
import com.keylesspalace.tusky.databinding.NotificationsFilterBinding
import com.keylesspalace.tusky.entity.Status
Expand Down Expand Up @@ -100,7 +100,7 @@ class NotificationsFragment :
lateinit var eventHub: EventHub

@Inject
lateinit var notificationService: NotificationService
lateinit var notificationHelper: NotificationHelper

private val binding by viewBinding(FragmentTimelineNotificationsBinding::bind)

Expand Down Expand Up @@ -269,7 +269,7 @@ class NotificationsFragment :
viewLifecycleOwner.lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.RESUMED) {
accountManager.activeAccount?.let { account ->
notificationService.clearNotificationsForAccount(account)
notificationHelper.clearNotificationsForAccount(account)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package com.keylesspalace.tusky.components.notifications

import androidx.recyclerview.widget.RecyclerView
import com.keylesspalace.tusky.components.systemnotifications.NotificationService
import com.keylesspalace.tusky.components.systemnotifications.NotificationHelper
import com.keylesspalace.tusky.databinding.ItemSeveredRelationshipNotificationBinding
import com.keylesspalace.tusky.util.StatusDisplayOptions
import com.keylesspalace.tusky.viewdata.NotificationViewData
Expand All @@ -37,7 +37,7 @@ class SeveredRelationshipNotificationViewHolder(
val event = viewData.event!!
val context = binding.root.context

binding.severedRelationshipText.text = NotificationService.severedRelationShipText(
binding.severedRelationshipText.text = NotificationHelper.severedRelationShipText(
context,
event,
instanceName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package com.keylesspalace.tusky.components.preference
import android.os.Bundle
import androidx.lifecycle.lifecycleScope
import com.keylesspalace.tusky.R
import com.keylesspalace.tusky.components.systemnotifications.NotificationService
import com.keylesspalace.tusky.components.systemnotifications.NotificationHelper
import com.keylesspalace.tusky.db.AccountManager
import com.keylesspalace.tusky.db.entity.AccountEntity
import com.keylesspalace.tusky.settings.PrefKeys
Expand All @@ -36,7 +36,7 @@ class NotificationPreferencesFragment : BasePreferencesFragment() {
lateinit var accountManager: AccountManager

@Inject
lateinit var notificationService: NotificationService
lateinit var notificationHelper: NotificationHelper

override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
val activeAccount = accountManager.activeAccount ?: return
Expand All @@ -48,10 +48,10 @@ class NotificationPreferencesFragment : BasePreferencesFragment() {
isChecked = activeAccount.notificationsEnabled
setOnPreferenceChangeListener { _, newValue ->
updateAccount { copy(notificationsEnabled = newValue as Boolean) }
if (notificationService.areNotificationsEnabledBySystem()) {
notificationService.enablePullNotifications()
if (notificationHelper.areNotificationsEnabledBySystem()) {
notificationHelper.enablePullNotifications()
} else {
notificationService.disablePullNotifications()
notificationHelper.disablePullNotifications()
}
true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class NotificationFetcher @Inject constructor(
private val mastodonApi: MastodonApi,
private val accountManager: AccountManager,
private val eventHub: EventHub,
private val notificationService: NotificationService,
private val notificationHelper: NotificationHelper,
) {
suspend fun fetchAndShow(accountId: Long?) {
for (account in accountManager.accounts) {
Expand All @@ -54,14 +54,14 @@ class NotificationFetcher @Inject constructor(
if (account.notificationsEnabled) {
try {
val notifications = fetchNewNotifications(account)
.filter { notificationService.filterNotification(account, it.type) }
.filter { notificationHelper.filterNotification(account, it.type) }
.sortedWith(
compareBy({ it.id.length }, { it.id })
) // oldest notifications first

eventHub.dispatch(NewNotificationsEvent(account.accountId, notifications))

notificationService.show(account, notifications)
notificationHelper.show(account, notifications)
} catch (e: Exception) {
Log.e(TAG, "Error while fetching notifications", e)
}
Expand Down
Loading
Loading