Fixed the migrations warning under Kotlin header #13282 (#6060)

* Fixed  Migration warnings under Kotlin header

* suppresses Lint

---------

Co-authored-by: Nicolas Raoul <nicolas.raoul@gmail.com>
This commit is contained in:
Sonal Yadav 2024-12-22 19:44:20 +05:30 committed by GitHub
parent f1e8e48769
commit b55c61ddb8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 28 additions and 20 deletions

View file

@ -146,7 +146,7 @@ class LoginActivity : AccountAuthenticatorActivity() {
loginTwoFactor.removeTextChangedListener(textWatcher)
}
delegate.onDestroy()
loginClient?.cancel()
loginClient.cancel()
binding = null
super.onDestroy()
}

View file

@ -250,7 +250,7 @@ class CustomSelectorActivity :
val selectedImages: ArrayList<Image> =
result.data!!
.getParcelableArrayListExtra(CustomSelectorConstants.NEW_SELECTED_IMAGES)!!
viewModel?.selectedImages?.value = selectedImages
viewModel.selectedImages?.value = selectedImages
}
}

View file

@ -240,7 +240,7 @@ class DescriptionEditActivity :
applicationContext,
media,
updatedWikiText,
)?.subscribeOn(Schedulers.io())
).subscribeOn(Schedulers.io())
?.observeOn(AndroidSchedulers.mainThread())
?.subscribe(Consumer<Boolean> { s: Boolean? -> Timber.d("Descriptions are added.") })
?.let {

View file

@ -175,7 +175,7 @@ class OkHttpJsonApiClient @Inject constructor(
.build()
val response: Response = okHttpClient.newCall(request).execute()
if (response.body != null && response.isSuccessful) {
val json: String = response.body!!.string() ?: return@fromCallable null
val json: String = response.body!!.string()
try {
return@fromCallable gson.fromJson<UpdateAvatarResponse>(
json,

View file

@ -86,7 +86,7 @@ class FileProcessor
*/
fun getExifTagsToRedact(): Set<String> {
val prefManageEXIFTags =
defaultKvStore.getStringSet(Prefs.MANAGED_EXIF_TAGS) ?: emptySet()
defaultKvStore.getStringSet(Prefs.MANAGED_EXIF_TAGS)
val redactTags: Set<String> =
context.resources.getStringArray(R.array.pref_exifTag_values).toSet()
return redactTags - prefManageEXIFTags

View file

@ -14,7 +14,7 @@ data class UploadResult(
constructor(parcel: Parcel) : this(
parcel.readString() ?: "",
parcel.readString() ?: "",
parcel.readInt() ?: 0,
parcel.readInt(),
parcel.readString() ?: "",
) {
}

View file

@ -121,6 +121,7 @@ class UploadWorker(
private var notificationFinishingTitle: String?,
var contribution: Contribution?,
) {
@SuppressLint("MissingPermission")
fun onProgress(
transferred: Long,
total: Long,
@ -175,6 +176,7 @@ class UploadWorker(
.setProgress(100, 0, true)
.setOngoing(true)
@SuppressLint("MissingPermission")
override suspend fun doWork(): Result {
try {
var totalUploadsStarted = 0
@ -298,7 +300,7 @@ class UploadWorker(
* Upload the contribution
* @param contribution
*/
@SuppressLint("StringFormatInvalid", "CheckResult")
@SuppressLint("StringFormatInvalid", "CheckResult", "MissingPermission")
private suspend fun uploadContribution(contribution: Contribution) {
if (contribution.localUri == null || contribution.localUri.path == null) {
Timber.e("""upload: ${contribution.media.filename} failed, file path is null""")
@ -439,7 +441,7 @@ class UploadWorker(
username,
)
CommonsApplication
.instance!!
.instance
.clearApplicationData(appContext, logoutListener)
}
}
@ -581,7 +583,7 @@ class UploadWorker(
* Notify that the current upload has succeeded
* @param contribution
*/
@SuppressLint("StringFormatInvalid")
@SuppressLint("StringFormatInvalid", "MissingPermission")
private fun showSuccessNotification(contribution: Contribution) {
val displayTitle = contribution.media.displayTitle
contribution.state = Contribution.STATE_COMPLETED
@ -606,7 +608,7 @@ class UploadWorker(
* Notify that the current upload has failed
* @param contribution
*/
@SuppressLint("StringFormatInvalid")
@SuppressLint("StringFormatInvalid", "MissingPermission")
private fun showFailedNotification(contribution: Contribution) {
val displayTitle = contribution.media.displayTitle
currentNotification.setContentIntent(getPendingIntent(UploadProgressActivity::class.java))
@ -626,7 +628,7 @@ class UploadWorker(
)
}
@SuppressLint("StringFormatInvalid")
@SuppressLint("StringFormatInvalid", "MissingPermission")
private fun showInvalidLoginNotification(contribution: Contribution) {
val displayTitle = contribution.media.displayTitle
currentNotification
@ -648,7 +650,7 @@ class UploadWorker(
/**
* Shows a notification for a failed contribution upload.
*/
@SuppressLint("StringFormatInvalid")
@SuppressLint("StringFormatInvalid", "MissingPermission")
private fun showErrorNotification(contribution: Contribution) {
val displayTitle = contribution.media.displayTitle
currentNotification
@ -671,6 +673,7 @@ class UploadWorker(
* Notify that the current upload is paused
* @param contribution
*/
@SuppressLint("MissingPermission")
private fun showPausedNotification(contribution: Contribution) {
val displayTitle = contribution.media.displayTitle
@ -695,6 +698,7 @@ class UploadWorker(
* Notify that the current upload is cancelled
* @param contribution
*/
@SuppressLint("MissingPermission")
private fun showCancelledNotification(contribution: Contribution) {
val displayTitle = contribution.media.displayTitle
currentNotification.setContentIntent(getPendingIntent(UploadProgressActivity::class.java))

View file

@ -55,7 +55,7 @@ class CustomSelectorUtils {
val uploadableFile = PickedFiles.pickedExistingPicture(context, image.uri)
val exifInterface: ExifInterface? =
try {
ExifInterface(uploadableFile.file!!)
ExifInterface(uploadableFile.file)
} catch (e: IOException) {
Timber.e(e)
null

View file

@ -62,6 +62,6 @@ object DownloadUtils {
) {
val systemService =
activity.getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
systemService?.enqueue(req)
systemService.enqueue(req)
}
}

View file

@ -2,6 +2,8 @@ package fr.free.nrw.commons.wikidata
import android.annotation.SuppressLint
import android.content.Context
import android.os.Build
import androidx.annotation.RequiresApi
import com.google.gson.Gson
import fr.free.nrw.commons.R
import fr.free.nrw.commons.contributions.Contribution
@ -111,12 +113,14 @@ class WikidataEditService @Inject constructor(
.blockingFirst()
}
@SuppressLint("StringFormatInvalid")
private fun showSuccessToast(wikiItemName: String) {
val successStringTemplate = context.getString(R.string.successful_wikidata_edit)
val successMessage = String.format(Locale.getDefault(), successStringTemplate, wikiItemName)
showLongToast(context, successMessage)
}
@RequiresApi(Build.VERSION_CODES.N)
@SuppressLint("CheckResult")
private fun addCaption(
fileEntityId: Long, languageCode: String,
@ -176,7 +180,7 @@ class WikidataEditService @Inject constructor(
SnakPartial(
"value",
MEDIA_LEGENDS.propertyName, MonoLingualText(
WikiBaseMonolingualTextValue(value!!, key!!)
WikiBaseMonolingualTextValue(value, key)
)
)
)

View file

@ -68,7 +68,7 @@ class BookmarkLocationControllerTest {
@Test
fun loadBookmarkedLocations() {
val bookmarkedLocations =
bookmarkLocationsController!!.loadFavoritesLocations()
bookmarkLocationsController.loadFavoritesLocations()
Assert.assertEquals(2, bookmarkedLocations.size.toLong())
}
}

View file

@ -50,7 +50,7 @@ class JsonKvStoreTest {
fun getJson() {
whenever(prefs.getString("key", null)).thenReturn(expected)
val result = store.getJson("key", Person::class.java)
val result = store.getJson<Person>("key")
Assert.assertEquals(testData, result)
}
@ -70,7 +70,7 @@ class JsonKvStoreTest {
fun getJsonHandlesMalformedJson() {
whenever(prefs.getString("key", null)).thenReturn("junk")
val result = store.getJson("key", Person::class.java)
val result = store.getJson<Person>("key")
Assert.assertNull(result)
}

View file

@ -305,7 +305,7 @@ class NearbyParentFragmentPresenterTest {
whenever(nearbyParentFragmentView.mapFocus).thenReturn(LatLng(2.0, 1.0, 0.0F))
// 111.19 km real distance, return false if 148306.444306 > currentLocationSearchRadius
NearbyController.currentLocationSearchRadius = 148306.0
val isClose = nearbyPresenter?.searchCloseToCurrentLocation()
val isClose = nearbyPresenter.searchCloseToCurrentLocation()
assertFalse(isClose!!.equals(false))
}
@ -317,7 +317,7 @@ class NearbyParentFragmentPresenterTest {
whenever(nearbyParentFragmentView.getCameraTarget()).thenReturn(LatLng(2.0, 1.0, 0.0F))
// 111.19 km real distance, return false if 148253.333 > currentLocationSearchRadius
NearbyController.currentLocationSearchRadius = 148307.0
val isClose = nearbyPresenter?.searchCloseToCurrentLocation()
val isClose = nearbyPresenter.searchCloseToCurrentLocation()
assertTrue(isClose!!)
}