Skip to content

Commit 1d479f0

Browse files
Merge branch 'main' into Languages-order-preference-commons-app#5826-
2 parents 5b778af + b55c61d commit 1d479f0

File tree

17 files changed

+37
-29
lines changed

17 files changed

+37
-29
lines changed

app/src/main/java/fr/free/nrw/commons/auth/LoginActivity.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class LoginActivity : AccountAuthenticatorActivity() {
146146
loginTwoFactor.removeTextChangedListener(textWatcher)
147147
}
148148
delegate.onDestroy()
149-
loginClient?.cancel()
149+
loginClient.cancel()
150150
binding = null
151151
super.onDestroy()
152152
}

app/src/main/java/fr/free/nrw/commons/bookmarks/BookmarkListRootFragment.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import android.content.Context;
44
import android.os.Bundle;
5-
import android.util.Log;
65
import android.view.LayoutInflater;
76
import android.view.View;
87
import android.view.ViewGroup;
@@ -26,6 +25,7 @@
2625
import fr.free.nrw.commons.navtab.NavTab;
2726
import java.util.ArrayList;
2827
import java.util.Iterator;
28+
import timber.log.Timber;
2929

3030
public class BookmarkListRootFragment extends CommonsDaggerSupportFragment implements
3131
FragmentManager.OnBackStackChangedListener,
@@ -136,7 +136,7 @@ public void onAttach(final Context context) {
136136

137137
@Override
138138
public void onMediaClicked(int position) {
139-
Log.d("deneme8", "on media clicked");
139+
Timber.d("on media clicked");
140140
/*container.setVisibility(View.VISIBLE);
141141
((BookmarkFragment)getParentFragment()).tabLayout.setVisibility(View.GONE);
142142
mediaDetails = new MediaDetailPagerFragment(false, true, position);
@@ -244,7 +244,7 @@ void moveToContributionsFragment() {
244244

245245
@Override
246246
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
247-
Log.d("deneme8", "on media clicked");
247+
Timber.d("on media clicked");
248248
binding.exploreContainer.setVisibility(View.VISIBLE);
249249
((BookmarkFragment) getParentFragment()).binding.tabLayout.setVisibility(View.GONE);
250250
mediaDetails = MediaDetailPagerFragment.newInstance(false, true);

app/src/main/java/fr/free/nrw/commons/contributions/SetWallpaperWorker.java

-4
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,11 @@
55
import android.app.WallpaperManager;
66
import android.content.Context;
77
import android.graphics.Bitmap;
8-
import android.graphics.BitmapFactory;
98
import android.net.Uri;
109
import android.os.Build;
11-
import android.util.Log;
1210
import androidx.annotation.NonNull;
1311
import androidx.annotation.Nullable;
1412
import androidx.core.app.NotificationCompat;
15-
import androidx.work.Data;
1613
import androidx.work.Worker;
1714
import androidx.work.WorkerParameters;
1815
import com.facebook.common.executors.CallerThreadExecutor;
@@ -25,7 +22,6 @@
2522
import com.facebook.imagepipeline.request.ImageRequest;
2623
import com.facebook.imagepipeline.request.ImageRequestBuilder;
2724
import fr.free.nrw.commons.R;
28-
import java.io.IOException;
2925
import timber.log.Timber;
3026

3127
public class SetWallpaperWorker extends Worker {

app/src/main/java/fr/free/nrw/commons/customselector/ui/selector/CustomSelectorActivity.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ class CustomSelectorActivity :
250250
val selectedImages: ArrayList<Image> =
251251
result.data!!
252252
.getParcelableArrayListExtra(CustomSelectorConstants.NEW_SELECTED_IMAGES)!!
253-
viewModel?.selectedImages?.value = selectedImages
253+
viewModel.selectedImages?.value = selectedImages
254254
}
255255
}
256256

app/src/main/java/fr/free/nrw/commons/description/DescriptionEditActivity.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ class DescriptionEditActivity :
240240
applicationContext,
241241
media,
242242
updatedWikiText,
243-
)?.subscribeOn(Schedulers.io())
243+
).subscribeOn(Schedulers.io())
244244
?.observeOn(AndroidSchedulers.mainThread())
245245
?.subscribe(Consumer<Boolean> { s: Boolean? -> Timber.d("Descriptions are added.") })
246246
?.let {

app/src/main/java/fr/free/nrw/commons/logging/FileLoggingTree.kt

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import android.util.Log
55
import org.slf4j.Logger
66
import org.slf4j.LoggerFactory
77

8-
import java.util.Locale
98
import java.util.concurrent.Executor
109

1110
import ch.qos.logback.classic.LoggerContext

app/src/main/java/fr/free/nrw/commons/mwapi/OkHttpJsonApiClient.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ class OkHttpJsonApiClient @Inject constructor(
175175
.build()
176176
val response: Response = okHttpClient.newCall(request).execute()
177177
if (response.body != null && response.isSuccessful) {
178-
val json: String = response.body!!.string() ?: return@fromCallable null
178+
val json: String = response.body!!.string()
179179
try {
180180
return@fromCallable gson.fromJson<UpdateAvatarResponse>(
181181
json,

app/src/main/java/fr/free/nrw/commons/nearby/PlaceAdapterDelegate.kt

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import android.view.View
55
import android.view.View.GONE
66
import android.view.View.INVISIBLE
77
import android.view.View.VISIBLE
8+
import android.widget.RelativeLayout
89
import androidx.activity.result.ActivityResultLauncher
910
import androidx.recyclerview.widget.LinearLayoutManager
1011
import androidx.recyclerview.widget.RecyclerView
1112
import androidx.transition.TransitionManager
13+
import com.google.android.material.bottomsheet.BottomSheetBehavior
1214
import com.hannesdorfmann.adapterdelegates4.dsl.AdapterDelegateViewBindingViewHolder
1315
import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateViewBinding
1416
import fr.free.nrw.commons.R
@@ -42,7 +44,10 @@ fun placeAdapterDelegate(
4244
root.setOnFocusChangeListener { view1: View?, hasFocus: Boolean ->
4345
if (!hasFocus && nearbyButtonLayout.buttonLayout.isShown) {
4446
nearbyButtonLayout.buttonLayout.visibility = GONE
45-
} else if (hasFocus && !nearbyButtonLayout.buttonLayout.isShown) {
47+
} else if (hasFocus && !nearbyButtonLayout.buttonLayout.isShown &&
48+
BottomSheetBehavior.from(root.parent.parent.parent as RelativeLayout).state !=
49+
BottomSheetBehavior.STATE_HIDDEN
50+
) {
4651
showOrHideAndScrollToIfLast()
4752
onItemClick?.invoke(item)
4853
}

app/src/main/java/fr/free/nrw/commons/upload/FileProcessor.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class FileProcessor
8686
*/
8787
fun getExifTagsToRedact(): Set<String> {
8888
val prefManageEXIFTags =
89-
defaultKvStore.getStringSet(Prefs.MANAGED_EXIF_TAGS) ?: emptySet()
89+
defaultKvStore.getStringSet(Prefs.MANAGED_EXIF_TAGS)
9090
val redactTags: Set<String> =
9191
context.resources.getStringArray(R.array.pref_exifTag_values).toSet()
9292
return redactTags - prefManageEXIFTags

app/src/main/java/fr/free/nrw/commons/upload/UploadResult.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ data class UploadResult(
1414
constructor(parcel: Parcel) : this(
1515
parcel.readString() ?: "",
1616
parcel.readString() ?: "",
17-
parcel.readInt() ?: 0,
17+
parcel.readInt(),
1818
parcel.readString() ?: "",
1919
) {
2020
}

app/src/main/java/fr/free/nrw/commons/upload/worker/UploadWorker.kt

+10-6
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ class UploadWorker(
121121
private var notificationFinishingTitle: String?,
122122
var contribution: Contribution?,
123123
) {
124+
@SuppressLint("MissingPermission")
124125
fun onProgress(
125126
transferred: Long,
126127
total: Long,
@@ -175,6 +176,7 @@ class UploadWorker(
175176
.setProgress(100, 0, true)
176177
.setOngoing(true)
177178

179+
@SuppressLint("MissingPermission")
178180
override suspend fun doWork(): Result {
179181
try {
180182
var totalUploadsStarted = 0
@@ -298,7 +300,7 @@ class UploadWorker(
298300
* Upload the contribution
299301
* @param contribution
300302
*/
301-
@SuppressLint("StringFormatInvalid", "CheckResult")
303+
@SuppressLint("StringFormatInvalid", "CheckResult", "MissingPermission")
302304
private suspend fun uploadContribution(contribution: Contribution) {
303305
if (contribution.localUri == null || contribution.localUri.path == null) {
304306
Timber.e("""upload: ${contribution.media.filename} failed, file path is null""")
@@ -439,7 +441,7 @@ class UploadWorker(
439441
username,
440442
)
441443
CommonsApplication
442-
.instance!!
444+
.instance
443445
.clearApplicationData(appContext, logoutListener)
444446
}
445447
}
@@ -581,7 +583,7 @@ class UploadWorker(
581583
* Notify that the current upload has succeeded
582584
* @param contribution
583585
*/
584-
@SuppressLint("StringFormatInvalid")
586+
@SuppressLint("StringFormatInvalid", "MissingPermission")
585587
private fun showSuccessNotification(contribution: Contribution) {
586588
val displayTitle = contribution.media.displayTitle
587589
contribution.state = Contribution.STATE_COMPLETED
@@ -606,7 +608,7 @@ class UploadWorker(
606608
* Notify that the current upload has failed
607609
* @param contribution
608610
*/
609-
@SuppressLint("StringFormatInvalid")
611+
@SuppressLint("StringFormatInvalid", "MissingPermission")
610612
private fun showFailedNotification(contribution: Contribution) {
611613
val displayTitle = contribution.media.displayTitle
612614
currentNotification.setContentIntent(getPendingIntent(UploadProgressActivity::class.java))
@@ -626,7 +628,7 @@ class UploadWorker(
626628
)
627629
}
628630

629-
@SuppressLint("StringFormatInvalid")
631+
@SuppressLint("StringFormatInvalid", "MissingPermission")
630632
private fun showInvalidLoginNotification(contribution: Contribution) {
631633
val displayTitle = contribution.media.displayTitle
632634
currentNotification
@@ -648,7 +650,7 @@ class UploadWorker(
648650
/**
649651
* Shows a notification for a failed contribution upload.
650652
*/
651-
@SuppressLint("StringFormatInvalid")
653+
@SuppressLint("StringFormatInvalid", "MissingPermission")
652654
private fun showErrorNotification(contribution: Contribution) {
653655
val displayTitle = contribution.media.displayTitle
654656
currentNotification
@@ -671,6 +673,7 @@ class UploadWorker(
671673
* Notify that the current upload is paused
672674
* @param contribution
673675
*/
676+
@SuppressLint("MissingPermission")
674677
private fun showPausedNotification(contribution: Contribution) {
675678
val displayTitle = contribution.media.displayTitle
676679

@@ -695,6 +698,7 @@ class UploadWorker(
695698
* Notify that the current upload is cancelled
696699
* @param contribution
697700
*/
701+
@SuppressLint("MissingPermission")
698702
private fun showCancelledNotification(contribution: Contribution) {
699703
val displayTitle = contribution.media.displayTitle
700704
currentNotification.setContentIntent(getPendingIntent(UploadProgressActivity::class.java))

app/src/main/java/fr/free/nrw/commons/utils/CustomSelectorUtils.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class CustomSelectorUtils {
5555
val uploadableFile = PickedFiles.pickedExistingPicture(context, image.uri)
5656
val exifInterface: ExifInterface? =
5757
try {
58-
ExifInterface(uploadableFile.file!!)
58+
ExifInterface(uploadableFile.file)
5959
} catch (e: IOException) {
6060
Timber.e(e)
6161
null

app/src/main/java/fr/free/nrw/commons/utils/DownloadUtils.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@ object DownloadUtils {
6262
) {
6363
val systemService =
6464
activity.getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
65-
systemService?.enqueue(req)
65+
systemService.enqueue(req)
6666
}
6767
}

app/src/main/java/fr/free/nrw/commons/wikidata/WikidataEditService.kt

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package fr.free.nrw.commons.wikidata
22

33
import android.annotation.SuppressLint
44
import android.content.Context
5+
import android.os.Build
6+
import androidx.annotation.RequiresApi
57
import com.google.gson.Gson
68
import fr.free.nrw.commons.R
79
import fr.free.nrw.commons.contributions.Contribution
@@ -111,12 +113,14 @@ class WikidataEditService @Inject constructor(
111113
.blockingFirst()
112114
}
113115

116+
@SuppressLint("StringFormatInvalid")
114117
private fun showSuccessToast(wikiItemName: String) {
115118
val successStringTemplate = context.getString(R.string.successful_wikidata_edit)
116119
val successMessage = String.format(Locale.getDefault(), successStringTemplate, wikiItemName)
117120
showLongToast(context, successMessage)
118121
}
119122

123+
@RequiresApi(Build.VERSION_CODES.N)
120124
@SuppressLint("CheckResult")
121125
private fun addCaption(
122126
fileEntityId: Long, languageCode: String,
@@ -176,7 +180,7 @@ class WikidataEditService @Inject constructor(
176180
SnakPartial(
177181
"value",
178182
MEDIA_LEGENDS.propertyName, MonoLingualText(
179-
WikiBaseMonolingualTextValue(value!!, key!!)
183+
WikiBaseMonolingualTextValue(value, key)
180184
)
181185
)
182186
)

app/src/test/kotlin/fr/free/nrw/commons/bookmarks/locations/BookmarkLocationControllerTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class BookmarkLocationControllerTest {
6868
@Test
6969
fun loadBookmarkedLocations() {
7070
val bookmarkedLocations =
71-
bookmarkLocationsController!!.loadFavoritesLocations()
71+
bookmarkLocationsController.loadFavoritesLocations()
7272
Assert.assertEquals(2, bookmarkedLocations.size.toLong())
7373
}
7474
}

app/src/test/kotlin/fr/free/nrw/commons/kvstore/JsonKvStoreTest.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class JsonKvStoreTest {
5050
fun getJson() {
5151
whenever(prefs.getString("key", null)).thenReturn(expected)
5252

53-
val result = store.getJson("key", Person::class.java)
53+
val result = store.getJson<Person>("key")
5454

5555
Assert.assertEquals(testData, result)
5656
}
@@ -70,7 +70,7 @@ class JsonKvStoreTest {
7070
fun getJsonHandlesMalformedJson() {
7171
whenever(prefs.getString("key", null)).thenReturn("junk")
7272

73-
val result = store.getJson("key", Person::class.java)
73+
val result = store.getJson<Person>("key")
7474

7575
Assert.assertNull(result)
7676
}

app/src/test/kotlin/fr/free/nrw/commons/nearby/NearbyParentFragmentPresenterTest.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ class NearbyParentFragmentPresenterTest {
305305
whenever(nearbyParentFragmentView.mapFocus).thenReturn(LatLng(2.0, 1.0, 0.0F))
306306
// 111.19 km real distance, return false if 148306.444306 > currentLocationSearchRadius
307307
NearbyController.currentLocationSearchRadius = 148306.0
308-
val isClose = nearbyPresenter?.searchCloseToCurrentLocation()
308+
val isClose = nearbyPresenter.searchCloseToCurrentLocation()
309309
assertFalse(isClose!!.equals(false))
310310
}
311311

@@ -317,7 +317,7 @@ class NearbyParentFragmentPresenterTest {
317317
whenever(nearbyParentFragmentView.getCameraTarget()).thenReturn(LatLng(2.0, 1.0, 0.0F))
318318
// 111.19 km real distance, return false if 148253.333 > currentLocationSearchRadius
319319
NearbyController.currentLocationSearchRadius = 148307.0
320-
val isClose = nearbyPresenter?.searchCloseToCurrentLocation()
320+
val isClose = nearbyPresenter.searchCloseToCurrentLocation()
321321
assertTrue(isClose!!)
322322
}
323323

0 commit comments

Comments
 (0)