Skip to content

Commit

Permalink
Merge branch 'v4.2.0-release'
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-raoul committed Oct 20, 2023
2 parents af58161 + d4917b5 commit 1490710
Show file tree
Hide file tree
Showing 137 changed files with 456 additions and 449 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: 11
distribution: 'temurin'
java-version: '17'

- name: Cache packages
id: cache-packages
Expand Down
15 changes: 6 additions & 9 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 29 additions & 23 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ dependencies {
// Utils
implementation 'in.yuvi:http.fluent:1.3'
implementation 'com.google.code.gson:gson:2.8.5'
implementation ("com.squareup.okhttp3:okhttp:$OKHTTP_VERSION"){
force = true //API 19 support
implementation ("com.squareup.okhttp3:okhttp:$OKHTTP_VERSION!!"){
// Forcing dependency versions using force = true on a first-level dependency has been deprecated.
// Ref: https://docs.gradle.org/7.5/userguide/upgrading_version_5.html#forced_dependencies
//force = true //API 19 support
}
implementation 'com.squareup.okio:okio:2.2.2'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
Expand Down Expand Up @@ -78,22 +80,22 @@ dependencies {

//Mocking
testImplementation 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0'
testImplementation 'org.mockito:mockito-inline:2.13.0'
testImplementation 'org.mockito:mockito-core:2.25.1'
testImplementation "org.powermock:powermock-module-junit4:2.0.2"
testImplementation "org.powermock:powermock-api-mockito2:2.0.2"
testImplementation 'org.mockito:mockito-inline:5.2.0'
testImplementation 'org.mockito:mockito-core:5.5.0'
testImplementation "org.powermock:powermock-module-junit4:2.0.9"
testImplementation "org.powermock:powermock-api-mockito2:2.0.9"

// Unit testing
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.robolectric:robolectric:4.6.1'
testImplementation 'androidx.test:core:1.4.0'
testImplementation 'org.robolectric:robolectric:4.10.3'
testImplementation 'androidx.test:core:1.5.0'
testImplementation "com.squareup.okhttp3:mockwebserver:$OKHTTP_VERSION"
testImplementation "com.jraska.livedata:testing-ktx:1.1.2"
testImplementation "androidx.arch.core:core-testing:2.1.0"
testImplementation "org.junit.jupiter:junit-jupiter-api:5.7.0"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.7.0"
testImplementation "androidx.arch.core:core-testing:2.2.0"
testImplementation "org.junit.jupiter:junit-jupiter-api:5.10.0"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.10.0"
testImplementation 'com.facebook.soloader:soloader:0.10.1'
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.5.0"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3"

// Android testing
androidTestImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$KOTLIN_VERSION"
Expand All @@ -119,8 +121,7 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation "androidx.exifinterface:exifinterface:1.3.2"
implementation "androidx.core:core-ktx:$CORE_KTX_VERSION"
implementation "androidx.multidex:multidex:2.0.1"
compile 'com.simplecityapps:recyclerview-fastscroll:2.0.1'
implementation 'com.simplecityapps:recyclerview-fastscroll:2.0.1'

//swipe_layout
implementation 'com.daimajia.swipelayout:library:1.2.0@aar'
Expand Down Expand Up @@ -151,6 +152,8 @@ dependencies {
//Glide
implementation 'com.github.bumptech.glide:glide:4.12.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
kaptTest "androidx.databinding:databinding-compiler:8.0.2"
kaptAndroidTest "androidx.databinding:databinding-compiler:8.0.2"

implementation("io.github.coordinates2country:coordinates2country-android:1.3") { exclude group: 'com.google.android', module: 'android' }
}
Expand Down Expand Up @@ -188,12 +191,16 @@ android {

vectorDrawables.useSupportLibrary = true
}

packagingOptions {
exclude 'META-INF/androidx.*'
exclude 'META-INF/proguard/androidx-annotations.pro'
jniLibs {
excludes += ['META-INF/androidx.*']
}
resources {
excludes += ['META-INF/androidx.*', 'META-INF/proguard/androidx-annotations.pro']
}
}


testOptions {
animationsDisabled true

Expand Down Expand Up @@ -326,11 +333,6 @@ android {
}
}

lintOptions {
disable 'MissingTranslation'
disable 'ExtraTranslation'
abortOnError false
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -342,7 +344,11 @@ android {
buildFeatures {
viewBinding true
}

namespace 'fr.free.nrw.commons'
lint {
abortOnError false
disable 'MissingTranslation', 'ExtraTranslation'
}
}

String getTestUserName() {
Expand Down
2 changes: 2 additions & 0 deletions app/proguard-rules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
-keepattributes Signature
# Retain declared checked exceptions for use by a Proxy instance.
-keepattributes Exceptions
# Classes used by retrofit to fetch API repsonse
-keepclasseswithmembers class org.wikipedia.** { *; }
# --- /Retrofit ---

# --- OkHttp + Okio ---
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="fr.free.nrw.commons">
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@
import fr.free.nrw.commons.Utils;
import fr.free.nrw.commons.auth.SessionManager;
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
import fr.free.nrw.commons.utils.DialogUtil;
import fr.free.nrw.commons.media.MediaClient;
import fr.free.nrw.commons.profile.ProfileActivity;
import fr.free.nrw.commons.utils.DialogUtil;
import fr.free.nrw.commons.utils.SystemThemeUtils;
import fr.free.nrw.commons.utils.ViewUtil;
import java.util.Locale;
Expand All @@ -52,7 +53,6 @@
import javax.inject.Named;
import org.apache.commons.lang3.StringUtils;
import org.wikipedia.dataclient.WikiSite;
import fr.free.nrw.commons.profile.ProfileActivity;


/**
Expand Down Expand Up @@ -112,7 +112,8 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment impl

private ContributionsListAdapter adapter;

@Nullable private Callback callback;
@Nullable
private Callback callback;

private final int SPAN_COUNT_LANDSCAPE = 3;
private final int SPAN_COUNT_PORTRAIT = 1;
Expand Down Expand Up @@ -142,7 +143,8 @@ public void onActivityResult(Map<String, Boolean> result) {


@Override
public void onCreate(@Nullable @org.jetbrains.annotations.Nullable final Bundle savedInstanceState) {
public void onCreate(
@Nullable @org.jetbrains.annotations.Nullable final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Now that we are allowing this fragment to be started for
// any userName- we expect it to be passed as an argument
Expand Down Expand Up @@ -336,7 +338,7 @@ private void setListeners() {
* Launch Custom Selector.
*/
@OnClick(R.id.fab_custom_gallery)
void launchCustomSelector(){
void launchCustomSelector() {
controller.initiateCustomGalleryPickWithPermission(getActivity());
animateFAB(isFabOpen);
}
Expand All @@ -348,24 +350,24 @@ public void scrollToTop() {
private void animateFAB(final boolean isFabOpen) {
this.isFabOpen = !isFabOpen;
if (fabPlus.isShown()) {
if (isFabOpen) {
fabPlus.startAnimation(rotate_backward);
fabCamera.startAnimation(fab_close);
fabGallery.startAnimation(fab_close);
fabCustomGallery.startAnimation(fab_close);
fabCamera.hide();
fabGallery.hide();
fabCustomGallery.hide();
} else {
fabPlus.startAnimation(rotate_forward);
fabCamera.startAnimation(fab_open);
fabGallery.startAnimation(fab_open);
fabCustomGallery.startAnimation(fab_open);
fabCamera.show();
fabGallery.show();
fabCustomGallery.show();
}
this.isFabOpen = !isFabOpen;
if (isFabOpen) {
fabPlus.startAnimation(rotate_backward);
fabCamera.startAnimation(fab_close);
fabGallery.startAnimation(fab_close);
fabCustomGallery.startAnimation(fab_close);
fabCamera.hide();
fabGallery.hide();
fabCustomGallery.hide();
} else {
fabPlus.startAnimation(rotate_forward);
fabCamera.startAnimation(fab_open);
fabGallery.startAnimation(fab_open);
fabCustomGallery.startAnimation(fab_open);
fabCamera.show();
fabGallery.show();
fabCustomGallery.show();
}
this.isFabOpen = !isFabOpen;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package fr.free.nrw.commons.filepicker;

import static fr.free.nrw.commons.filepicker.PickedFiles.singleFileList;

import android.app.Activity;
import android.content.ClipData;
import android.content.Context;
Expand All @@ -8,13 +10,11 @@
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import androidx.preference.PreferenceManager;
import android.provider.MediaStore;
import android.text.TextUtils;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import androidx.preference.PreferenceManager;
import fr.free.nrw.commons.customselector.model.Image;
import fr.free.nrw.commons.customselector.ui.selector.CustomSelectorActivity;
import java.io.File;
Expand All @@ -23,8 +23,6 @@
import java.util.ArrayList;
import java.util.List;

import static fr.free.nrw.commons.filepicker.PickedFiles.singleFileList;

public class FilePicker implements Constants {

private static final String KEY_PHOTO_URI = "photo_uri";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.content.Context;
import android.content.Intent;

import android.os.Build;
import androidx.core.app.NotificationCompat;

import javax.inject.Inject;
Expand Down Expand Up @@ -49,21 +50,29 @@ public NotificationHelper(Context context) {
* @param intent the intent to be fired when the notification is clicked
*/
public void showNotification(Context context,
String notificationTitle,
String notificationMessage,
int notificationId,
Intent intent) {
String notificationTitle,
String notificationMessage,
int notificationId,
Intent intent) {

notificationBuilder.setDefaults(DEFAULT_ALL)
.setContentTitle(notificationTitle)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(notificationMessage))
.setSmallIcon(R.drawable.ic_launcher)
.setProgress(0, 0, false)
.setOngoing(false)
.setPriority(PRIORITY_HIGH);
.setContentTitle(notificationTitle)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(notificationMessage))
.setSmallIcon(R.drawable.ic_launcher)
.setProgress(0, 0, false)
.setOngoing(false)
.setPriority(PRIORITY_HIGH);

PendingIntent pendingIntent = PendingIntent.getActivity(context, 1, intent, PendingIntent.FLAG_UPDATE_CURRENT);
int flags = PendingIntent.FLAG_UPDATE_CURRENT;

// Check if the API level is 31 or higher to modify the flag
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
// For API level 31 or above, PendingIntent requires either FLAG_IMMUTABLE or FLAG_MUTABLE to be set
flags |= PendingIntent.FLAG_IMMUTABLE;
}

PendingIntent pendingIntent = PendingIntent.getActivity(context, 1, intent, flags);
notificationBuilder.setContentIntent(pendingIntent);
notificationManager.notify(notificationId, notificationBuilder.build());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ class DepictsPresenter @Inject constructor(
)
}
)

}
} else {
repository.cleanup()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@
import android.net.Uri;
import android.os.Build;
import android.provider.Settings;

import androidx.annotation.StringRes;
import androidx.core.content.ContextCompat;

import com.karumi.dexter.Dexter;
import com.karumi.dexter.MultiplePermissionsReport;
import com.karumi.dexter.PermissionToken;
import com.karumi.dexter.listener.PermissionRequest;
import com.karumi.dexter.listener.multi.MultiplePermissionsListener;

import fr.free.nrw.commons.CommonsApplication;
import fr.free.nrw.commons.R;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AboutActivityUnitTests {

@Before
fun setUp() {
MockitoAnnotations.initMocks(this)
MockitoAnnotations.openMocks(this)

activity = Robolectric.buildActivity(AboutActivity::class.java).create().get()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CommonsAppAdapterUnitTest {

@Before
fun setUp() {
MockitoAnnotations.initMocks(this)
MockitoAnnotations.openMocks(this)
adapter = CommonsAppAdapter(sessionManager, preferences)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class FakeContextWrapper(base: Context?) : ContextWrapper(base) {
}

init {
MockitoAnnotations.initMocks(this)
MockitoAnnotations.openMocks(this)
Mockito.`when`(mMockAccountManager.accounts).thenReturn(ACCOUNTS)
Mockito.`when`(mMockAccountManager.getAccountsByType(BuildConfig.ACCOUNT_TYPE))
.thenReturn(ACCOUNTS)
Expand Down
Loading

0 comments on commit 1490710

Please sign in to comment.