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:
parent
33cd6fdb98
commit
5192fb08a5
215 changed files with 2813 additions and 1177 deletions
|
|
@ -53,6 +53,9 @@ import com.keylesspalace.tusky.entity.Status
|
|||
import com.keylesspalace.tusky.network.MastodonApi
|
||||
import com.keylesspalace.tusky.util.unsafeLazy
|
||||
import dagger.android.AndroidInjection
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import java.util.concurrent.TimeUnit
|
||||
import javax.inject.Inject
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
|
|
@ -61,9 +64,6 @@ import kotlinx.coroutines.delay
|
|||
import kotlinx.coroutines.launch
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import retrofit2.HttpException
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import java.util.concurrent.TimeUnit
|
||||
import javax.inject.Inject
|
||||
|
||||
class SendStatusService : Service(), Injectable {
|
||||
|
||||
|
|
@ -88,7 +88,9 @@ class SendStatusService : Service(), Injectable {
|
|||
private val statusesToSend = ConcurrentHashMap<Int, StatusToSend>()
|
||||
private val sendJobs = ConcurrentHashMap<Int, Job>()
|
||||
|
||||
private val notificationManager by unsafeLazy { getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager }
|
||||
private val notificationManager by unsafeLazy {
|
||||
getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
}
|
||||
|
||||
override fun onCreate() {
|
||||
AndroidInjection.inject(this)
|
||||
|
|
@ -103,7 +105,12 @@ class SendStatusService : Service(), Injectable {
|
|||
?: throw IllegalStateException("SendStatusService started without $KEY_STATUS extra")
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val channel = NotificationChannel(CHANNEL_ID, getString(R.string.send_post_notification_channel_name), NotificationManager.IMPORTANCE_LOW)
|
||||
val channel =
|
||||
NotificationChannel(
|
||||
CHANNEL_ID,
|
||||
getString(R.string.send_post_notification_channel_name),
|
||||
NotificationManager.IMPORTANCE_LOW
|
||||
)
|
||||
notificationManager.createNotificationChannel(channel)
|
||||
}
|
||||
|
||||
|
|
@ -119,7 +126,11 @@ class SendStatusService : Service(), Injectable {
|
|||
.setProgress(1, 0, true)
|
||||
.setOngoing(true)
|
||||
.setColor(getColor(R.color.notification_color))
|
||||
.addAction(0, getString(android.R.string.cancel), cancelSendingIntent(sendingNotificationId))
|
||||
.addAction(
|
||||
0,
|
||||
getString(android.R.string.cancel),
|
||||
cancelSendingIntent(sendingNotificationId)
|
||||
)
|
||||
|
||||
if (statusesToSend.size == 0 || Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
ServiceCompat.stopForeground(this, ServiceCompat.STOP_FOREGROUND_DETACH)
|
||||
|
|
@ -296,7 +307,9 @@ class SendStatusService : Service(), Injectable {
|
|||
// when statusToSend == null, sending has been canceled
|
||||
val statusToSend = statusesToSend[statusId] ?: return
|
||||
|
||||
val backoff = TimeUnit.SECONDS.toMillis(statusToSend.retries.toLong()).coerceAtMost(MAX_RETRY_INTERVAL)
|
||||
val backoff = TimeUnit.SECONDS.toMillis(
|
||||
statusToSend.retries.toLong()
|
||||
).coerceAtMost(MAX_RETRY_INTERVAL)
|
||||
|
||||
delay(backoff)
|
||||
sendStatus(statusId)
|
||||
|
|
@ -304,7 +317,10 @@ class SendStatusService : Service(), Injectable {
|
|||
|
||||
private fun stopSelfWhenDone() {
|
||||
if (statusesToSend.isEmpty()) {
|
||||
ServiceCompat.stopForeground(this@SendStatusService, ServiceCompat.STOP_FOREGROUND_REMOVE)
|
||||
ServiceCompat.stopForeground(
|
||||
this@SendStatusService,
|
||||
ServiceCompat.STOP_FOREGROUND_REMOVE
|
||||
)
|
||||
stopSelf()
|
||||
}
|
||||
}
|
||||
|
|
@ -431,10 +447,7 @@ class SendStatusService : Service(), Injectable {
|
|||
private var sendingNotificationId = -1 // use negative ids to not clash with other notis
|
||||
private var errorNotificationId = Int.MIN_VALUE // use even more negative ids to not clash with other notis
|
||||
|
||||
fun sendStatusIntent(
|
||||
context: Context,
|
||||
statusToSend: StatusToSend
|
||||
): Intent {
|
||||
fun sendStatusIntent(context: Context, statusToSend: StatusToSend): Intent {
|
||||
val intent = Intent(context, SendStatusService::class.java)
|
||||
intent.putExtra(KEY_STATUS, statusToSend)
|
||||
|
||||
|
|
@ -482,7 +495,8 @@ data class StatusToSend(
|
|||
@Parcelize
|
||||
data class MediaToSend(
|
||||
val localId: Int,
|
||||
val id: String?, // null if media is not yet completely uploaded
|
||||
// null if media is not yet completely uploaded
|
||||
val id: String?,
|
||||
val uri: String,
|
||||
val description: String?,
|
||||
val focus: Attachment.Focus?,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue