Skip to content

Merge 2.8 release with master #1887

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Sep 7, 2018
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