Skip to content

Commit

Permalink
Merge 2.8 release with master (#1887)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
maskaravivek authored Sep 7, 2018
1 parent 13c377a commit a63b9f8
Show file tree
Hide file tree
Showing 18 changed files with 284 additions and 252 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Wikimedia Commons for Android

## v2.8.3
- Fixed issues with session tokens not being cleared in 2FA, which should reduce p18 edit failures as well
- Fixed crash caused by bug in fetching revert count
- Fixed crash potentially caused by Traceur library

## v2.8.2
- Fixed bug with uploads sent via Share being given .jpeg extensions and overwriting files of the same name

## v2.8.1
- Fixed bug with category edits not being sent to server

Expand Down
6 changes: 4 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ dependencies {
testImplementation 'com.squareup.okhttp3:mockwebserver:3.8.1'
implementation 'com.dinuscxj:circleprogressbar:1.1.1'

implementation 'com.tspoon.traceur:traceur:1.0.1'

androidTestImplementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
androidTestImplementation 'com.squareup.okhttp3:mockwebserver:3.8.1'
androidTestImplementation "com.android.support:support-annotations:$SUPPORT_LIB_VERSION"
Expand All @@ -83,8 +85,8 @@ android {

defaultConfig {
applicationId 'fr.free.nrw.commons'
versionCode 88
versionName '2.8.1'
versionCode 90
versionName '2.8.3'
setProperty("archivesBaseName", "app-commons-v$versionName-" + getBranchName())

minSdkVersion project.minSdkVersion
Expand Down
13 changes: 11 additions & 2 deletions app/src/main/java/fr/free/nrw/commons/CommonsApplication.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.free.nrw.commons;

import android.annotation.SuppressLint;
import android.app.Application;
import android.app.NotificationChannel;
import android.app.NotificationManager;
Expand All @@ -14,6 +15,8 @@
import com.facebook.stetho.Stetho;
import com.squareup.leakcanary.LeakCanary;
import com.squareup.leakcanary.RefWatcher;
import com.tspoon.traceur.Traceur;
import com.tspoon.traceur.TraceurConfig;

import org.acra.ACRA;
import org.acra.ReportingInteractionMode;
Expand Down Expand Up @@ -84,6 +87,12 @@ public class CommonsApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
if (BuildConfig.DEBUG) {
//FIXME: Traceur should be disabled for release builds until error fixed
//See https://github.com/commons-app/apps-android-commons/issues/1877
Traceur.enableLogging();
}

ApplicationlessInjection
.getInstance(this)
.getCommonsApplicationComponent()
Expand Down Expand Up @@ -152,6 +161,7 @@ public static RefWatcher getRefWatcher(Context context) {
* @param context Application context
* @param logoutListener Implementation of interface LogoutListener
*/
@SuppressLint("CheckResult")
public void clearApplicationData(Context context, LogoutListener logoutListener) {
File cacheDirectory = context.getCacheDir();
File applicationDirectory = new File(cacheDirectory.getParent());
Expand All @@ -164,7 +174,7 @@ public void clearApplicationData(Context context, LogoutListener logoutListener)
}
}

sessionManager.clearAllAccounts()
sessionManager.logout()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(() -> {
Expand All @@ -175,7 +185,6 @@ public void clearApplicationData(Context context, LogoutListener logoutListener)
applicationPrefs.edit().putBoolean("firstrun", false).apply();
otherPrefs.edit().clear().apply();
updateAllDatabases();

logoutListener.onLogoutComplete();
});
}
Expand Down
11 changes: 10 additions & 1 deletion app/src/main/java/fr/free/nrw/commons/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public static int licenseNameFor(String license) {
}

/**
* Fixing incorrect extension
* Adds extension to filename. Converts to .jpg if system provides .jpeg, adds .jpg if no extension detected
* @param title File name
* @param extension Correct extension
* @return File with correct extension
Expand All @@ -128,6 +128,15 @@ public static String fixExtension(String title, String extension) {
.endsWith("." + extension.toLowerCase(Locale.ENGLISH))) {
title += "." + extension;
}

// If extension is still null, make it jpg. (Hotfix for https://github.com/commons-app/apps-android-commons/issues/228)
// If title has an extension in it, if won't be true
// FIXME: .png uploads fail when uploaded via Share
if (extension == null && title.lastIndexOf(".")<=0) {
extension = "jpg";
title += "." + extension;
}

return title;
}

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

import android.util.Log;

/**
* represnts Achievements class ans stores all the parameters
*/
Expand Down Expand Up @@ -45,62 +43,20 @@ public Achievements(int uniqueUsedImages,
}

/**
* Builder class for Achievements class
* Get Achievements object from FeedbackResponse
*
* @param response
* @return
*/
public class AchievementsBuilder {
private int nestedUniqueUsedImages;
private int nestedArticlesUsingImages;
private int nestedThanksReceived;
private int nestedImagesEditedBySomeoneElse;
private int nestedFeaturedImages;
private int nestedImagesUploaded;
private int nestedRevertCount;

public AchievementsBuilder setUniqueUsedImages(int uniqueUsedImages) {
this.nestedUniqueUsedImages = uniqueUsedImages;
return this;
}

public AchievementsBuilder setArticlesUsingImages(int articlesUsingImages) {
this.nestedArticlesUsingImages = articlesUsingImages;
return this;
}

public AchievementsBuilder setThanksReceived(int thanksReceived) {
this.nestedThanksReceived = thanksReceived;
return this;
}

public AchievementsBuilder setImagesEditedBySomeoneElse(int imagesEditedBySomeoneElse) {
this.nestedImagesEditedBySomeoneElse = imagesEditedBySomeoneElse;
return this;
}

public AchievementsBuilder setFeaturedImages(int featuredImages) {
this.nestedFeaturedImages = featuredImages;
return this;
}

public AchievementsBuilder setImagesUploaded(int imagesUploaded) {
this.nestedImagesUploaded = imagesUploaded;
return this;
}

public AchievementsBuilder setRevertCount( int revertCount){
this.nestedRevertCount = revertCount;
return this;
}

public Achievements createAchievements(){
return new Achievements(nestedUniqueUsedImages,
nestedArticlesUsingImages,
nestedThanksReceived,
nestedImagesEditedBySomeoneElse,
nestedFeaturedImages,
nestedImagesUploaded,
nestedRevertCount);
}

public static Achievements from(FeedbackResponse response) {
return new Achievements(response.getUniqueUsedImages(),
response.getArticlesUsingImages(),
response.getThanksReceived(),
response.getImagesEditedBySomeoneElse(),
response.getFeaturedImages().getQualityImages()
+ response.getFeaturedImages().getFeaturedPicturesOnWikimediaCommons(),
0,
response.getDeletedUploads());
}

/**
Expand Down
Loading

0 comments on commit a63b9f8

Please sign in to comment.