upgrade ktlint plugin to 12.0.3 (#4169)

There are some new rules, I think they mostly make sense, except for the
max line length which I had to disable because we are over it in a lot
of places.

---------

Co-authored-by: Goooler <wangzongler@gmail.com>
This commit is contained in:
Konrad Pozniak 2024-01-04 17:00:55 +01:00 committed by GitHub
commit 5192fb08a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
215 changed files with 2813 additions and 1177 deletions

View file

@ -26,10 +26,10 @@ import com.keylesspalace.tusky.components.notifications.updateUnifiedPushSubscri
import com.keylesspalace.tusky.db.AccountManager
import com.keylesspalace.tusky.network.MastodonApi
import dagger.android.AndroidInjection
import javax.inject.Inject
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import javax.inject.Inject
@DelicateCoroutinesApi
class NotificationBlockStateBroadcastReceiver : BroadcastReceiver() {
@ -60,7 +60,14 @@ class NotificationBlockStateBroadcastReceiver : BroadcastReceiver() {
accountManager.getAccountByIdentifier(gid)?.let { account ->
if (isUnifiedPushNotificationEnabledForAccount(account)) {
// Update UnifiedPush notification subscription
GlobalScope.launch { updateUnifiedPushSubscription(context, mastodonApi, accountManager, account) }
GlobalScope.launch {
updateUnifiedPushSubscription(
context,
mastodonApi,
accountManager,
account
)
}
}
}
}

View file

@ -47,10 +47,16 @@ class SendStatusBroadcastReceiver : BroadcastReceiver() {
if (intent.action == NotificationHelper.REPLY_ACTION) {
val notificationId = intent.getIntExtra(NotificationHelper.KEY_NOTIFICATION_ID, -1)
val senderId = intent.getLongExtra(NotificationHelper.KEY_SENDER_ACCOUNT_ID, -1)
val senderIdentifier = intent.getStringExtra(NotificationHelper.KEY_SENDER_ACCOUNT_IDENTIFIER)
val senderFullName = intent.getStringExtra(NotificationHelper.KEY_SENDER_ACCOUNT_FULL_NAME)
val senderIdentifier = intent.getStringExtra(
NotificationHelper.KEY_SENDER_ACCOUNT_IDENTIFIER
)
val senderFullName = intent.getStringExtra(
NotificationHelper.KEY_SENDER_ACCOUNT_FULL_NAME
)
val citedStatusId = intent.getStringExtra(NotificationHelper.KEY_CITED_STATUS_ID)
val visibility = intent.getSerializableExtra(NotificationHelper.KEY_VISIBILITY) as Status.Visibility
val visibility = intent.getSerializableExtra(
NotificationHelper.KEY_VISIBILITY
) as Status.Visibility
val spoiler = intent.getStringExtra(NotificationHelper.KEY_SPOILER).orEmpty()
val mentions = intent.getStringArrayExtra(NotificationHelper.KEY_MENTIONS).orEmpty()
@ -63,7 +69,10 @@ class SendStatusBroadcastReceiver : BroadcastReceiver() {
if (account == null) {
Log.w(TAG, "Account \"$senderId\" not found in database. Aborting quick reply!")
val builder = NotificationCompat.Builder(context, NotificationHelper.CHANNEL_MENTION + senderIdentifier)
val builder = NotificationCompat.Builder(
context,
NotificationHelper.CHANNEL_MENTION + senderIdentifier
)
.setSmallIcon(R.drawable.ic_notify)
.setColor(context.getColor(R.color.tusky_blue))
.setGroup(senderFullName)
@ -105,7 +114,10 @@ class SendStatusBroadcastReceiver : BroadcastReceiver() {
context.startService(sendIntent)
val builder = NotificationCompat.Builder(context, NotificationHelper.CHANNEL_MENTION + senderIdentifier)
val builder = NotificationCompat.Builder(
context,
NotificationHelper.CHANNEL_MENTION + senderIdentifier
)
.setSmallIcon(R.drawable.ic_notify)
.setColor(context.getColor(R.color.notification_color))
.setGroup(senderFullName)

View file

@ -26,11 +26,11 @@ import com.keylesspalace.tusky.db.AccountManager
import com.keylesspalace.tusky.network.MastodonApi
import com.keylesspalace.tusky.worker.NotificationWorker
import dagger.android.AndroidInjection
import javax.inject.Inject
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import org.unifiedpush.android.connector.MessagingReceiver
import javax.inject.Inject
@DelicateCoroutinesApi
class UnifiedPushBroadcastReceiver : MessagingReceiver() {
@ -63,7 +63,9 @@ class UnifiedPushBroadcastReceiver : MessagingReceiver() {
accountManager.getAccountById(instance.toLong())?.let {
// Launch the coroutine in global scope -- it is short and we don't want to lose the registration event
// and there is no saner way to use structured concurrency in a receiver
GlobalScope.launch { registerUnifiedPushEndpoint(context, mastodonApi, accountManager, it, endpoint) }
GlobalScope.launch {
registerUnifiedPushEndpoint(context, mastodonApi, accountManager, it, endpoint)
}
}
}