Skip to content

Commit a63b9f8

Browse files
authored
Merge 2.8 release with master (#1887)
* Add Traceur for getting meaningful RxJava stack traces (#1832) * Hotfix for overwrite issue in 2.8.0 (#1838) * This solution is an hotfix for overrite issue came back on 2.8.0 version. What I did is checking the extension, and if it is null, adding .jpg suffix. Because commons files always have suffixes, and we should compare file names after adding suffixes. Othervise overrides are possible. * Check if file title includes an extension already, by checking if is there any dot in it. * Fix logic error * Add uncovered tests * Remove unecessary line breaks * Make Javadocs more explicit * Versioning and changelog for v2.8.2 (#1842) * Versioning for v2.8.2 * Changelog for v2.8.2 * Add logs in wiki data edit and session refresh flow (#1874) * Fix logout (#1875) * [WIP] Refactor feedback and quiz to reduce possibility of NPE (#1881) * Refactor feedback and quiz to reduce possibility of NPE * Handle throwables in quiz checker * Minor refactoring * Set Traceur to only work in DEBUG mode (#1884) * Bug fix for uploaded images count in achievements activity (#1885) * Versioning and changelog for v2.8.3 (#1886) * Update changelog.md * Versioning for v2.8.3
1 parent 13c377a commit a63b9f8

18 files changed

+284
-252
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Wikimedia Commons for Android
22

3+
## v2.8.3
4+
- Fixed issues with session tokens not being cleared in 2FA, which should reduce p18 edit failures as well
5+
- Fixed crash caused by bug in fetching revert count
6+
- Fixed crash potentially caused by Traceur library
7+
8+
## v2.8.2
9+
- Fixed bug with uploads sent via Share being given .jpeg extensions and overwriting files of the same name
10+
311
## v2.8.1
412
- Fixed bug with category edits not being sent to server
513

app/build.gradle

+4-2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ dependencies {
5959
testImplementation 'com.squareup.okhttp3:mockwebserver:3.8.1'
6060
implementation 'com.dinuscxj:circleprogressbar:1.1.1'
6161

62+
implementation 'com.tspoon.traceur:traceur:1.0.1'
63+
6264
androidTestImplementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
6365
androidTestImplementation 'com.squareup.okhttp3:mockwebserver:3.8.1'
6466
androidTestImplementation "com.android.support:support-annotations:$SUPPORT_LIB_VERSION"
@@ -83,8 +85,8 @@ android {
8385

8486
defaultConfig {
8587
applicationId 'fr.free.nrw.commons'
86-
versionCode 88
87-
versionName '2.8.1'
88+
versionCode 90
89+
versionName '2.8.3'
8890
setProperty("archivesBaseName", "app-commons-v$versionName-" + getBranchName())
8991

9092
minSdkVersion project.minSdkVersion

app/src/main/java/fr/free/nrw/commons/CommonsApplication.java

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

3+
import android.annotation.SuppressLint;
34
import android.app.Application;
45
import android.app.NotificationChannel;
56
import android.app.NotificationManager;
@@ -14,6 +15,8 @@
1415
import com.facebook.stetho.Stetho;
1516
import com.squareup.leakcanary.LeakCanary;
1617
import com.squareup.leakcanary.RefWatcher;
18+
import com.tspoon.traceur.Traceur;
19+
import com.tspoon.traceur.TraceurConfig;
1720

1821
import org.acra.ACRA;
1922
import org.acra.ReportingInteractionMode;
@@ -84,6 +87,12 @@ public class CommonsApplication extends Application {
8487
@Override
8588
public void onCreate() {
8689
super.onCreate();
90+
if (BuildConfig.DEBUG) {
91+
//FIXME: Traceur should be disabled for release builds until error fixed
92+
//See https://github.com/commons-app/apps-android-commons/issues/1877
93+
Traceur.enableLogging();
94+
}
95+
8796
ApplicationlessInjection
8897
.getInstance(this)
8998
.getCommonsApplicationComponent()
@@ -152,6 +161,7 @@ public static RefWatcher getRefWatcher(Context context) {
152161
* @param context Application context
153162
* @param logoutListener Implementation of interface LogoutListener
154163
*/
164+
@SuppressLint("CheckResult")
155165
public void clearApplicationData(Context context, LogoutListener logoutListener) {
156166
File cacheDirectory = context.getCacheDir();
157167
File applicationDirectory = new File(cacheDirectory.getParent());
@@ -164,7 +174,7 @@ public void clearApplicationData(Context context, LogoutListener logoutListener)
164174
}
165175
}
166176

167-
sessionManager.clearAllAccounts()
177+
sessionManager.logout()
168178
.subscribeOn(Schedulers.io())
169179
.observeOn(AndroidSchedulers.mainThread())
170180
.subscribe(() -> {
@@ -175,7 +185,6 @@ public void clearApplicationData(Context context, LogoutListener logoutListener)
175185
applicationPrefs.edit().putBoolean("firstrun", false).apply();
176186
otherPrefs.edit().clear().apply();
177187
updateAllDatabases();
178-
179188
logoutListener.onLogoutComplete();
180189
});
181190
}

app/src/main/java/fr/free/nrw/commons/Utils.java

+10-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public static int licenseNameFor(String license) {
111111
}
112112

113113
/**
114-
* Fixing incorrect extension
114+
* Adds extension to filename. Converts to .jpg if system provides .jpeg, adds .jpg if no extension detected
115115
* @param title File name
116116
* @param extension Correct extension
117117
* @return File with correct extension
@@ -128,6 +128,15 @@ public static String fixExtension(String title, String extension) {
128128
.endsWith("." + extension.toLowerCase(Locale.ENGLISH))) {
129129
title += "." + extension;
130130
}
131+
132+
// If extension is still null, make it jpg. (Hotfix for https://github.com/commons-app/apps-android-commons/issues/228)
133+
// If title has an extension in it, if won't be true
134+
// FIXME: .png uploads fail when uploaded via Share
135+
if (extension == null && title.lastIndexOf(".")<=0) {
136+
extension = "jpg";
137+
title += "." + extension;
138+
}
139+
131140
return title;
132141
}
133142

app/src/main/java/fr/free/nrw/commons/achievements/Achievements.java

+13-57
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package fr.free.nrw.commons.achievements;
22

3-
import android.util.Log;
4-
53
/**
64
* represnts Achievements class ans stores all the parameters
75
*/
@@ -45,62 +43,20 @@ public Achievements(int uniqueUsedImages,
4543
}
4644

4745
/**
48-
* Builder class for Achievements class
46+
* Get Achievements object from FeedbackResponse
47+
*
48+
* @param response
49+
* @return
4950
*/
50-
public class AchievementsBuilder {
51-
private int nestedUniqueUsedImages;
52-
private int nestedArticlesUsingImages;
53-
private int nestedThanksReceived;
54-
private int nestedImagesEditedBySomeoneElse;
55-
private int nestedFeaturedImages;
56-
private int nestedImagesUploaded;
57-
private int nestedRevertCount;
58-
59-
public AchievementsBuilder setUniqueUsedImages(int uniqueUsedImages) {
60-
this.nestedUniqueUsedImages = uniqueUsedImages;
61-
return this;
62-
}
63-
64-
public AchievementsBuilder setArticlesUsingImages(int articlesUsingImages) {
65-
this.nestedArticlesUsingImages = articlesUsingImages;
66-
return this;
67-
}
68-
69-
public AchievementsBuilder setThanksReceived(int thanksReceived) {
70-
this.nestedThanksReceived = thanksReceived;
71-
return this;
72-
}
73-
74-
public AchievementsBuilder setImagesEditedBySomeoneElse(int imagesEditedBySomeoneElse) {
75-
this.nestedImagesEditedBySomeoneElse = imagesEditedBySomeoneElse;
76-
return this;
77-
}
78-
79-
public AchievementsBuilder setFeaturedImages(int featuredImages) {
80-
this.nestedFeaturedImages = featuredImages;
81-
return this;
82-
}
83-
84-
public AchievementsBuilder setImagesUploaded(int imagesUploaded) {
85-
this.nestedImagesUploaded = imagesUploaded;
86-
return this;
87-
}
88-
89-
public AchievementsBuilder setRevertCount( int revertCount){
90-
this.nestedRevertCount = revertCount;
91-
return this;
92-
}
93-
94-
public Achievements createAchievements(){
95-
return new Achievements(nestedUniqueUsedImages,
96-
nestedArticlesUsingImages,
97-
nestedThanksReceived,
98-
nestedImagesEditedBySomeoneElse,
99-
nestedFeaturedImages,
100-
nestedImagesUploaded,
101-
nestedRevertCount);
102-
}
103-
51+
public static Achievements from(FeedbackResponse response) {
52+
return new Achievements(response.getUniqueUsedImages(),
53+
response.getArticlesUsingImages(),
54+
response.getThanksReceived(),
55+
response.getImagesEditedBySomeoneElse(),
56+
response.getFeaturedImages().getQualityImages()
57+
+ response.getFeaturedImages().getFeaturedPicturesOnWikimediaCommons(),
58+
0,
59+
response.getDeletedUploads());
10460
}
10561

10662
/**

0 commit comments

Comments
 (0)