update Kotlin to 1.7.10 and fix some (new?) warnings (#2647)

* update Kotlin to 1.7.10 and fix some (new?) warnings

* remove unused import
This commit is contained in:
Konrad Pozniak 2022-08-07 19:36:09 +02:00 committed by GitHub
parent 12e42e9b2b
commit 4f0f9a7a12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 17 additions and 65 deletions

View File

@ -97,11 +97,11 @@ class ComposeTokenizer : MultiAutoCompleteTextView.Tokenizer {
return if (i > 0 && text[i - 1] == ' ') { return if (i > 0 && text[i - 1] == ' ') {
text text
} else if (text is Spanned) { } else if (text is Spanned) {
val s = SpannableString(text.toString() + " ") val s = SpannableString("$text ")
TextUtils.copySpansFrom(text, 0, text.length, Object::class.java, s, 0) TextUtils.copySpansFrom(text, 0, text.length, Object::class.java, s, 0)
s s
} else { } else {
text.toString() + " " "$text "
} }
} }
} }

View File

@ -77,7 +77,7 @@ fun showAddPollDialog(
} }
val pollDurationId = durations.indexOfLast { val pollDurationId = durations.indexOfLast {
it <= poll?.expiresIn ?: 0 it <= (poll?.expiresIn ?: 0)
} }
binding.pollDurationSpinner.setSelection(pollDurationId) binding.pollDurationSpinner.setSelection(pollDurationId)

View File

@ -191,10 +191,6 @@ class SearchViewModel @Inject constructor(
.autoDispose() .autoDispose()
} }
fun getAllAccountsOrderedByActive(): List<AccountEntity> {
return accountManager.getAllAccountsOrderedByActive()
}
fun muteAccount(accountId: String, notifications: Boolean, duration: Int?) { fun muteAccount(accountId: String, notifications: Boolean, duration: Int?) {
timelineCases.mute(accountId, notifications, duration) timelineCases.mute(accountId, notifications, duration)
} }

View File

@ -288,7 +288,7 @@ class SearchStatusesFragment : SearchFragment<StatusViewData.Concrete>(), Status
val stringToShare = statusToShare.account.username + val stringToShare = statusToShare.account.username +
" - " + " - " +
statusToShare.content.toString() statusToShare.content
sendIntent.putExtra(Intent.EXTRA_TEXT, stringToShare) sendIntent.putExtra(Intent.EXTRA_TEXT, stringToShare)
sendIntent.type = "text/plain" sendIntent.type = "text/plain"
startActivity(Intent.createChooser(sendIntent, resources.getText(R.string.send_post_content_to))) startActivity(Intent.createChooser(sendIntent, resources.getText(R.string.send_post_content_to)))

View File

@ -171,12 +171,11 @@ class ViewVideoFragment : ViewMediaFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
val attachment = arguments?.getParcelable<Attachment>(ARG_ATTACHMENT) val attachment = arguments?.getParcelable<Attachment>(ARG_ATTACHMENT)
val url: String
if (attachment == null) { if (attachment == null) {
throw IllegalArgumentException("attachment has to be set") throw IllegalArgumentException("attachment has to be set")
} }
url = attachment.url val url = attachment.url
isAudio = attachment.type == Attachment.Type.AUDIO isAudio = attachment.type == Attachment.Type.AUDIO
finalizeViewSetup(url, attachment.previewUrl, attachment.description) finalizeViewSetup(url, attachment.previewUrl, attachment.description)
} }

View File

@ -48,7 +48,7 @@ class ListStatusAccessibilityDelegate(
val pos = recyclerView.getChildAdapterPosition(host) val pos = recyclerView.getChildAdapterPosition(host)
val status = statusProvider.getStatus(pos) ?: return val status = statusProvider.getStatus(pos) ?: return
if (status is StatusViewData.Concrete) { if (status is StatusViewData.Concrete) {
if (!status.spoilerText.isNullOrEmpty()) { if (status.spoilerText.isNotEmpty()) {
info.addAction(if (status.isExpanded) collapseCwAction else expandCwAction) info.addAction(if (status.isExpanded) collapseCwAction else expandCwAction)
} }

View File

@ -52,7 +52,3 @@ inline fun <T> List<T>.replacedFirstWhich(replacement: T, predicate: (T) -> Bool
} }
return newList return newList
} }
inline fun <reified R> Iterable<*>.firstIsInstanceOrNull(): R? {
return firstOrNull { it is R }?.let { it as R }
}

View File

@ -23,7 +23,6 @@ import android.graphics.Matrix
import android.net.Uri import android.net.Uri
import android.provider.OpenableColumns import android.provider.OpenableColumns
import android.util.Log import android.util.Log
import androidx.annotation.Px
import androidx.exifinterface.media.ExifInterface import androidx.exifinterface.media.ExifInterface
import java.io.File import java.io.File
import java.io.FileNotFoundException import java.io.FileNotFoundException
@ -68,43 +67,6 @@ fun getMediaSize(contentResolver: ContentResolver, uri: Uri?): Long {
return mediaSize return mediaSize
} }
fun getSampledBitmap(contentResolver: ContentResolver, uri: Uri, @Px reqWidth: Int, @Px reqHeight: Int): Bitmap? {
// First decode with inJustDecodeBounds=true to check dimensions
val options = BitmapFactory.Options()
options.inJustDecodeBounds = true
var stream: InputStream?
try {
stream = contentResolver.openInputStream(uri)
} catch (e: FileNotFoundException) {
Log.w(TAG, e)
return null
}
BitmapFactory.decodeStream(stream, null, options)
IOUtils.closeQuietly(stream)
// Calculate inSampleSize
options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight)
// Decode bitmap with inSampleSize set
options.inJustDecodeBounds = false
return try {
stream = contentResolver.openInputStream(uri)
val bitmap = BitmapFactory.decodeStream(stream, null, options)
val orientation = getImageOrientation(uri, contentResolver)
reorientBitmap(bitmap, orientation)
} catch (e: FileNotFoundException) {
Log.w(TAG, e)
null
} catch (e: OutOfMemoryError) {
Log.e(TAG, "OutOfMemoryError while trying to get sampled Bitmap", e)
null
} finally {
IOUtils.closeQuietly(stream)
}
}
@Throws(FileNotFoundException::class) @Throws(FileNotFoundException::class)
fun getImageSquarePixels(contentResolver: ContentResolver, uri: Uri): Long { fun getImageSquarePixels(contentResolver: ContentResolver, uri: Uri): Long {
val input = contentResolver.openInputStream(uri) val input = contentResolver.openInputStream(uri)

View File

@ -166,7 +166,7 @@ class StatusViewHelper(private val itemView: View) {
mediaPreviews[3].layoutParams.height = mediaPreviewHeight mediaPreviews[3].layoutParams.height = mediaPreviewHeight
} }
} }
if (attachments.isNullOrEmpty()) { if (attachments.isEmpty()) {
sensitiveMediaWarning.visibility = View.GONE sensitiveMediaWarning.visibility = View.GONE
sensitiveMediaShow.visibility = View.GONE sensitiveMediaShow.visibility = View.GONE
} else { } else {

View File

@ -32,17 +32,16 @@ class FragmentViewBindingDelegate<T : ViewBinding>(
object : DefaultLifecycleObserver { object : DefaultLifecycleObserver {
override fun onCreate(owner: LifecycleOwner) { override fun onCreate(owner: LifecycleOwner) {
fragment.viewLifecycleOwnerLiveData.observe( fragment.viewLifecycleOwnerLiveData.observe(
fragment, fragment
{ t -> ) { t ->
t?.lifecycle?.addObserver( t?.lifecycle?.addObserver(
object : DefaultLifecycleObserver { object : DefaultLifecycleObserver {
override fun onDestroy(owner: LifecycleOwner) { override fun onDestroy(owner: LifecycleOwner) {
binding = null binding = null
}
} }
) }
} )
) }
} }
} }
) )

View File

@ -6,7 +6,7 @@ buildscript {
} }
dependencies { dependencies {
classpath "com.android.tools.build:gradle:7.2.2" classpath "com.android.tools.build:gradle:7.2.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10"
classpath "org.jlleitschuh.gradle:ktlint-gradle:10.3.0" classpath "org.jlleitschuh.gradle:ktlint-gradle:10.3.0"
} }
} }