mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Fix:5175 Upgraded Minimum SDK Version, Compile and Target SDK Version (#5177)
* Kotlin Version Upgraded to 1.6.10 * Kotlin Version Upgraded to 1.6.20 * Kotlin Version Upgraded to 1.7.20 * Fix:5175 Upgraded Minimum SDK Version, Compile and Target SDK Version
This commit is contained in:
parent
66e15a17ef
commit
9b0b936c62
13 changed files with 110 additions and 63 deletions
|
|
@ -85,7 +85,7 @@ dependencies {
|
|||
|
||||
// Unit testing
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
testImplementation 'org.robolectric:robolectric:4.6-alpha-1'
|
||||
testImplementation 'org.robolectric:robolectric:4.6.1'
|
||||
testImplementation 'androidx.test:core:1.4.0'
|
||||
testImplementation "com.squareup.okhttp3:mockwebserver:$OKHTTP_VERSION"
|
||||
testImplementation "com.jraska.livedata:testing-ktx:1.1.2"
|
||||
|
|
@ -111,8 +111,6 @@ dependencies {
|
|||
|
||||
// Debugging
|
||||
debugImplementation "com.squareup.leakcanary:leakcanary-android:$LEAK_CANARY_VERSION"
|
||||
releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$LEAK_CANARY_VERSION"
|
||||
testImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$LEAK_CANARY_VERSION"
|
||||
|
||||
// Support libraries
|
||||
implementation "com.google.android.material:material:1.1.0-alpha04"
|
||||
|
|
@ -144,9 +142,10 @@ dependencies {
|
|||
|
||||
implementation "androidx.multidex:multidex:$MULTIDEX_VERSION"
|
||||
|
||||
def work_version = "2.6.0"
|
||||
def work_version = "2.8.0"
|
||||
// Kotlin + coroutines
|
||||
implementation "androidx.work:work-runtime-ktx:$work_version"
|
||||
implementation("androidx.work:work-runtime:$work_version")
|
||||
testImplementation "androidx.work:work-testing:$work_version"
|
||||
|
||||
//Glide
|
||||
|
|
@ -169,7 +168,7 @@ project.gradle.taskGraph.whenReady {
|
|||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
compileSdkVersion 31
|
||||
|
||||
defaultConfig {
|
||||
//applicationId 'fr.free.nrw.commons'
|
||||
|
|
@ -178,8 +177,8 @@ android {
|
|||
versionName '4.0.3'
|
||||
setProperty("archivesBaseName", "app-commons-v$versionName-" + getBranchName())
|
||||
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 30
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 31
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
testInstrumentationRunnerArguments clearPackageData: 'true'
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,8 @@
|
|||
android:configChanges="screenSize|keyboard|orientation"
|
||||
android:parentActivityName=".customselector.ui.selector.CustomSelectorActivity" />
|
||||
|
||||
<activity android:name=".auth.LoginActivity">
|
||||
<activity android:name=".auth.LoginActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
|
||||
|
|
@ -77,6 +78,7 @@
|
|||
<activity
|
||||
android:hardwareAccelerated="false"
|
||||
android:name=".upload.UploadActivity"
|
||||
android:exported="true"
|
||||
android:configChanges="orientation|screenSize|keyboard"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
|
|
@ -235,7 +237,8 @@
|
|||
android:label="@string/provider_bookmarks_location"
|
||||
android:syncable="false" />
|
||||
|
||||
<receiver android:name=".widget.PicOfDayAppWidget">
|
||||
<receiver android:name=".widget.PicOfDayAppWidget"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
||||
</intent-filter>
|
||||
|
|
|
|||
|
|
@ -24,8 +24,6 @@ import com.facebook.drawee.backends.pipeline.Fresco;
|
|||
import com.facebook.imagepipeline.core.ImagePipeline;
|
||||
import com.facebook.imagepipeline.core.ImagePipelineConfig;
|
||||
import com.mapbox.mapboxsdk.Mapbox;
|
||||
import com.squareup.leakcanary.LeakCanary;
|
||||
import com.squareup.leakcanary.RefWatcher;
|
||||
import fr.free.nrw.commons.auth.SessionManager;
|
||||
import fr.free.nrw.commons.bookmarks.items.BookmarkItemsDao.Table;
|
||||
import fr.free.nrw.commons.bookmarks.locations.BookmarkLocationsDao;
|
||||
|
|
@ -55,6 +53,7 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import leakcanary.ObjectWatcher;
|
||||
import org.acra.ACRA;
|
||||
import org.acra.annotation.AcraCore;
|
||||
import org.acra.annotation.AcraDialog;
|
||||
|
|
@ -122,7 +121,7 @@ public class CommonsApplication extends MultiDexApplication {
|
|||
* Constants End
|
||||
*/
|
||||
|
||||
private RefWatcher refWatcher;
|
||||
private ObjectWatcher objectWatcher;
|
||||
|
||||
private static CommonsApplication INSTANCE;
|
||||
|
||||
|
|
@ -193,9 +192,6 @@ public class CommonsApplication extends MultiDexApplication {
|
|||
// or from Observables that are (deliberately or not) missing an onError handler.
|
||||
RxJavaPlugins.setErrorHandler(Functions.emptyConsumer());
|
||||
|
||||
if (setupLeakCanary() == RefWatcher.DISABLED) {
|
||||
return;
|
||||
}
|
||||
// Fire progress callbacks for every 3% of uploaded content
|
||||
System.setProperty("in.yuvi.http.fluent.PROGRESS_TRIGGER_THRESHOLD", "3.0");
|
||||
}
|
||||
|
|
@ -273,26 +269,14 @@ public class CommonsApplication extends MultiDexApplication {
|
|||
}
|
||||
|
||||
/**
|
||||
* Helps in setting up LeakCanary library
|
||||
*
|
||||
* @return instance of LeakCanary
|
||||
*/
|
||||
protected RefWatcher setupLeakCanary() {
|
||||
if (LeakCanary.isInAnalyzerProcess(this)) {
|
||||
return RefWatcher.DISABLED;
|
||||
}
|
||||
return LeakCanary.install(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a way to get member refWatcher
|
||||
* Provides a way to get member objectWatcher
|
||||
*
|
||||
* @param context Application context
|
||||
* @return application member refWatcher
|
||||
* @return application member objectWatcher
|
||||
*/
|
||||
public static RefWatcher getRefWatcher(Context context) {
|
||||
public static ObjectWatcher getObjectWatcher(Context context) {
|
||||
CommonsApplication application = (CommonsApplication) context.getApplicationContext();
|
||||
return application.refWatcher;
|
||||
return application.objectWatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -138,6 +138,18 @@ class ImageLoader @Inject constructor(
|
|||
is Result.TRUE -> {
|
||||
mapResult[imageSHA1] = Result.TRUE
|
||||
}
|
||||
is Result.ERROR -> {
|
||||
mapResult[imageSHA1] = Result.ERROR
|
||||
}
|
||||
is Result.FALSE -> {
|
||||
mapResult[imageSHA1] = Result.FALSE
|
||||
}
|
||||
is Result.INVALID -> {
|
||||
mapResult[imageSHA1] = Result.INVALID
|
||||
}
|
||||
is Result.NOTFOUND -> {
|
||||
mapResult[imageSHA1] = Result.NOTFOUND
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
|
|
@ -160,6 +172,18 @@ class ImageLoader @Inject constructor(
|
|||
is Result.TRUE -> {
|
||||
mapResult[sha1] = Result.TRUE
|
||||
}
|
||||
is Result.ERROR -> {
|
||||
mapResult[sha1] = Result.ERROR
|
||||
}
|
||||
is Result.FALSE -> {
|
||||
mapResult[sha1] = Result.FALSE
|
||||
}
|
||||
is Result.INVALID -> {
|
||||
mapResult[sha1] = Result.INVALID
|
||||
}
|
||||
is Result.NOTFOUND -> {
|
||||
mapResult[sha1] = Result.NOTFOUND
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ class LanguagesAdapter constructor(
|
|||
}
|
||||
|
||||
fun getIndexOfUserDefaultLocale(context: Context): Int {
|
||||
return language.codes.indexOf(context.locale.language)
|
||||
return language.codes.indexOf(context.locale!!.language)
|
||||
}
|
||||
|
||||
fun getIndexOfLanguageCode(languageCode: String): Int {
|
||||
|
|
@ -138,5 +138,5 @@ class LanguagesAdapter constructor(
|
|||
|
||||
}
|
||||
|
||||
private val Context.locale: Locale
|
||||
private val Context.locale: Locale?
|
||||
get() = ConfigurationCompat.getLocales(resources.configuration)[0]
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ class OkHttpJsonApiClientTests {
|
|||
|
||||
@Test
|
||||
fun testGetNearbyPlacesCustomQuery() {
|
||||
Mockito.`when`(response.message()).thenReturn("test")
|
||||
Mockito.`when`(response.message).thenReturn("test")
|
||||
try {
|
||||
okHttpJsonApiClient.getNearbyPlaces(latLng, "test", 10.0, true, "test")
|
||||
} catch (e: Exception) {
|
||||
|
|
@ -76,7 +76,7 @@ class OkHttpJsonApiClientTests {
|
|||
|
||||
@Test
|
||||
fun testGetNearbyPlaces() {
|
||||
Mockito.`when`(response.message()).thenReturn("test")
|
||||
Mockito.`when`(response.message).thenReturn("test")
|
||||
try {
|
||||
okHttpJsonApiClient.getNearbyPlaces(latLng, "test", 10.0, true)
|
||||
} catch (e: Exception) {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import android.content.Context
|
|||
import androidx.collection.LruCache
|
||||
import com.google.gson.Gson
|
||||
import com.nhaarman.mockitokotlin2.mock
|
||||
import com.squareup.leakcanary.RefWatcher
|
||||
import fr.free.nrw.commons.auth.AccountUtil
|
||||
import fr.free.nrw.commons.data.DBOpenHelper
|
||||
import fr.free.nrw.commons.di.CommonsApplicationComponent
|
||||
|
|
|
|||
|
|
@ -149,9 +149,9 @@ class CustomOkHttpNetworkFetcherUnitTest {
|
|||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testOnFetchResponseCaseReturn() {
|
||||
whenever(response.body()).thenReturn(body)
|
||||
whenever(response.body).thenReturn(body)
|
||||
whenever(response.isSuccessful).thenReturn(false)
|
||||
whenever(call.isCanceled).thenReturn(true)
|
||||
whenever(call.isCanceled()).thenReturn(true)
|
||||
val method: Method = CustomOkHttpNetworkFetcher::class.java.getDeclaredMethod(
|
||||
"onFetchResponse",
|
||||
CustomOkHttpNetworkFetcher.OkHttpNetworkFetchState::class.java,
|
||||
|
|
@ -167,11 +167,22 @@ class CustomOkHttpNetworkFetcherUnitTest {
|
|||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testOnFetchResponse() {
|
||||
whenever(response.body()).thenReturn(body)
|
||||
whenever(response.body).thenReturn(body)
|
||||
whenever(response.isSuccessful).thenReturn(true)
|
||||
whenever(response.header("Content-Range")).thenReturn("bytes 200-1000/67589")
|
||||
whenever(call.isCanceled).thenReturn(true)
|
||||
|
||||
whenever(call.isCanceled()).thenReturn(true)
|
||||
whenever(body.contentLength()).thenReturn(-1)
|
||||
|
||||
// Build Response object with Content-Range header
|
||||
val responseBuilder = Response.Builder()
|
||||
.request(Request.Builder().url("http://example.com").build())
|
||||
.protocol(Protocol.HTTP_1_1)
|
||||
.code(200)
|
||||
.message("OK")
|
||||
.header("Content-Range", "bytes 200-1000/67589")
|
||||
.body(body)
|
||||
whenever(call.execute()).thenReturn(responseBuilder.build())
|
||||
|
||||
val method: Method = CustomOkHttpNetworkFetcher::class.java.getDeclaredMethod(
|
||||
"onFetchResponse",
|
||||
CustomOkHttpNetworkFetcher.OkHttpNetworkFetchState::class.java,
|
||||
|
|
@ -180,18 +191,29 @@ class CustomOkHttpNetworkFetcherUnitTest {
|
|||
NetworkFetcher.Callback::class.java,
|
||||
)
|
||||
method.isAccessible = true
|
||||
method.invoke(fetcher, state, call, response, callback)
|
||||
method.invoke(fetcher, state, call, responseBuilder.build(), callback)
|
||||
verify(callback).onResponse(null, 0)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testOnFetchResponseCaseException() {
|
||||
whenever(response.body()).thenReturn(body)
|
||||
whenever(response.body).thenReturn(body)
|
||||
whenever(response.isSuccessful).thenReturn(true)
|
||||
whenever(response.header("Content-Range")).thenReturn("test")
|
||||
whenever(call.isCanceled).thenReturn(false)
|
||||
|
||||
whenever(call.isCanceled()).thenReturn(false)
|
||||
whenever(body.contentLength()).thenReturn(-1)
|
||||
|
||||
// Build Response object with Content-Range header
|
||||
val responseBuilder = Response.Builder()
|
||||
.request(Request.Builder().url("http://example.com").build())
|
||||
.protocol(Protocol.HTTP_1_1)
|
||||
.code(200)
|
||||
.message("OK")
|
||||
.header("Content-Range", "Test")
|
||||
.body(body)
|
||||
whenever(call.execute()).thenReturn(responseBuilder.build())
|
||||
|
||||
val method: Method = CustomOkHttpNetworkFetcher::class.java.getDeclaredMethod(
|
||||
"onFetchResponse",
|
||||
CustomOkHttpNetworkFetcher.OkHttpNetworkFetchState::class.java,
|
||||
|
|
@ -200,7 +222,7 @@ class CustomOkHttpNetworkFetcherUnitTest {
|
|||
NetworkFetcher.Callback::class.java,
|
||||
)
|
||||
method.isAccessible = true
|
||||
method.invoke(fetcher, state, call, response, callback)
|
||||
method.invoke(fetcher, state, call, responseBuilder.build(), callback)
|
||||
verify(callback).onFailure(any())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,10 @@ class LanguagesAdapterTest {
|
|||
@Test
|
||||
fun testGetIndexOfUserDefaultLocale() {
|
||||
languagesAdapter = LanguagesAdapter(context, selectedLanguages)
|
||||
Assertions.assertEquals(languageCodesList.indexOf(ConfigurationCompat.getLocales(context.resources.configuration)[0].language), languagesAdapter.getIndexOfUserDefaultLocale(context))
|
||||
Assertions.assertEquals(ConfigurationCompat.getLocales(context.resources.configuration)[0]?.let {
|
||||
languageCodesList.indexOf(
|
||||
it.language)
|
||||
}, languagesAdapter.getIndexOfUserDefaultLocale(context))
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -105,14 +108,17 @@ class LanguagesAdapterTest {
|
|||
val constraint = "spa"
|
||||
languagesAdapter.filter.filter(constraint)
|
||||
val length: Int = languageNamesList.size
|
||||
val defaultlanguagecode = languageCodesList.indexOf(ConfigurationCompat.getLocales(context.resources.configuration)[0].language)
|
||||
val defaultlanguagecode = ConfigurationCompat.getLocales(context.resources.configuration)[0]?.let {
|
||||
languageCodesList.indexOf(
|
||||
it.language)
|
||||
}
|
||||
var i = 0
|
||||
var s = 0
|
||||
while (i < length) {
|
||||
val key: String = language.codes[i]
|
||||
val value: String = language.localizedNames[i]
|
||||
if(value.contains(constraint, true) || Locale(key).getDisplayName(
|
||||
Locale(language.codes[defaultlanguagecode])).contains(constraint, true))
|
||||
Locale(language.codes[defaultlanguagecode!!])).contains(constraint, true))
|
||||
s++
|
||||
i++
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue