update ktlint plugin to 11.3.1, format code (#3442)

This commit is contained in:
Konrad Pozniak 2023-03-13 13:16:39 +01:00 committed by GitHub
commit d839f18267
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
141 changed files with 589 additions and 428 deletions

View file

@ -14,6 +14,7 @@
* see <http://www.gnu.org/licenses>. */
@file:JvmName("CustomEmojiHelper")
package com.keylesspalace.tusky.util
import android.graphics.Canvas
@ -39,8 +40,9 @@ import java.util.regex.Pattern
* @return the text with the shortcodes replaced by EmojiSpans
*/
fun CharSequence.emojify(emojis: List<Emoji>?, view: View, animate: Boolean): CharSequence {
if (emojis.isNullOrEmpty())
if (emojis.isNullOrEmpty()) {
return this
}
val builder = SpannableStringBuilder.valueOf(this)

View file

@ -24,7 +24,9 @@ import androidx.core.net.toUri
*
* @see [RFC5988](https://tools.ietf.org/html/rfc5988)
*/
class HttpHeaderLink @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) constructor(
class HttpHeaderLink
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
constructor(
uri: String
) {
data class Parameter(val name: String, val value: String?)

View file

@ -36,7 +36,7 @@ fun Closeable?.closeQuietly() {
fun Uri.copyToFile(
contentResolver: ContentResolver,
file: File,
file: File
): Boolean {
val from: InputStream?
val to: FileOutputStream

View file

@ -14,7 +14,6 @@ import com.keylesspalace.tusky.R
private val centerCropTransformation = CenterCrop()
fun loadAvatar(url: String?, imageView: ImageView, @Px radius: Int, animate: Boolean) {
if (url.isNullOrBlank()) {
Glide.with(imageView)
.load(R.drawable.avatar_default)

View file

@ -196,7 +196,8 @@ class ListStatusAccessibilityDelegate(
.setAdapter(
ArrayAdapter<CharSequence>(
host.context,
android.R.layout.simple_list_item_1, stringMentions
android.R.layout.simple_list_item_1,
stringMentions
)
) { _, which ->
statusActionListener.onViewAccount(mentions[which].id)
@ -213,7 +214,8 @@ class ListStatusAccessibilityDelegate(
.setAdapter(
ArrayAdapter(
host.context,
android.R.layout.simple_list_item_1, tags
android.R.layout.simple_list_item_1,
tags
)
) { _, which ->
statusActionListener.onViewTag(tags[which].toString())

View file

@ -54,7 +54,6 @@ class LocaleManager @Inject constructor(
}
override fun putString(key: String?, value: String?) {
// if we are on Android < 13 we have to save the selected language so we can apply it at appstart
// on Android 13+ the system handles it for us
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {

View file

@ -87,7 +87,6 @@ fun calculateInSampleSize(options: BitmapFactory.Options, reqWidth: Int, reqHeig
var inSampleSize = 1
if (height > reqHeight || width > reqWidth) {
val halfHeight = height / 2
val halfWidth = width / 2
@ -130,8 +129,13 @@ fun reorientBitmap(bitmap: Bitmap?, orientation: Int): Bitmap? {
return try {
val result = Bitmap.createBitmap(
bitmap, 0, 0, bitmap.width,
bitmap.height, matrix, true
bitmap,
0,
0,
bitmap.width,
bitmap.height,
matrix,
true
)
if (!bitmap.sameAs(result)) {
bitmap.recycle()

View file

@ -37,8 +37,9 @@ fun deserialize(data: String?): Set<Notification.Type> {
for (i in 0 until array.length()) {
val item = array.getString(i)
val type = Notification.Type.byString(item)
if (type != Notification.Type.UNKNOWN)
if (type != Notification.Type.UNKNOWN) {
ret.add(type)
}
}
}
return ret

View file

@ -35,9 +35,7 @@ import io.reactivex.rxjava3.core.Single
import io.reactivex.rxjava3.schedulers.Schedulers
fun updateShortcut(context: Context, account: AccountEntity) {
Single.fromCallable {
val innerSize = context.resources.getDimensionPixelSize(R.dimen.adaptive_bitmap_inner_size)
val outerSize = context.resources.getDimensionPixelSize(R.dimen.adaptive_bitmap_outer_size)
@ -94,6 +92,5 @@ fun updateShortcut(context: Context, account: AccountEntity) {
}
fun removeShortcut(context: Context, account: AccountEntity) {
ShortcutManagerCompat.removeDynamicShortcuts(context, listOf(account.id.toString()))
}

View file

@ -89,7 +89,6 @@ object SmartLengthInputFilter : InputFilter {
keep = boundary
} else {
// If no runway is allowed simply remove whitespace if present
while (source[keep - 1].isWhitespace()) {
--keep

View file

@ -43,7 +43,7 @@ private enum class FoundMatchType {
HTTP_URL,
HTTPS_URL,
TAG,
MENTION,
MENTION
}
private class FindCharsResult {

View file

@ -14,6 +14,7 @@
* see <http://www.gnu.org/licenses>. */
@file:JvmName("StatusParsingHelper")
package com.keylesspalace.tusky.util
import android.text.Html.TagHandler

View file

@ -53,7 +53,6 @@ class StatusViewHelper(private val itemView: View) {
showingContent: Boolean,
mediaPreviewHeight: Int
) {
val context = itemView.context
val mediaPreviews = arrayOf<MediaPreviewImageView>(
itemView.findViewById(R.id.status_media_preview_0),
@ -110,9 +109,11 @@ class StatusViewHelper(private val itemView: View) {
.centerInside()
.into(mediaPreviews[i])
} else {
val placeholder = if (attachment.blurhash != null)
val placeholder = if (attachment.blurhash != null) {
decodeBlurHash(context, attachment.blurhash)
else mediaPreviewUnloaded
} else {
mediaPreviewUnloaded
}
val meta = attachment.meta
val focus = meta?.focus
if (showingContent) {
@ -185,8 +186,12 @@ class StatusViewHelper(private val itemView: View) {
v.visibility = View.GONE
sensitiveMediaWarning.visibility = View.VISIBLE
setMediasPreview(
statusDisplayOptions, attachments, sensitive, previewListener,
false, mediaPreviewHeight
statusDisplayOptions,
attachments,
sensitive,
previewListener,
false,
mediaPreviewHeight
)
}
sensitiveMediaWarning.setOnClickListener { v ->
@ -194,8 +199,12 @@ class StatusViewHelper(private val itemView: View) {
v.visibility = View.GONE
sensitiveMediaShow.visibility = View.VISIBLE
setMediasPreview(
statusDisplayOptions, attachments, sensitive, previewListener,
true, mediaPreviewHeight
statusDisplayOptions,
attachments,
sensitive,
previewListener,
true,
mediaPreviewHeight
)
}
}

View file

@ -67,13 +67,13 @@ fun Notification.toViewData(
this.id,
this.account,
this.status?.toViewData(isShowingContent, isExpanded, isCollapsed),
this.report,
this.report
)
}
@JvmName("tagToViewData")
fun TrendingTag.toViewData(): TrendingViewData.Tag {
return TrendingViewData.Tag(
tag = this,
tag = this
)
}