mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 04:13:53 +01:00
Merge release branch to master (#1932)
* Bugfix/upload via share (#1920) * Bug Fix #1878 * Added a java library to fetch the MIME type from input stream * Fetch MIME type using this and use the contribution tag only when this fails: * formatting changes, removed unused commented out line * Versioning and changelog for v2.8.5 (#1923) * Versioning for v2.8.5 * Update changelog.md
This commit is contained in:
parent
e36a71a584
commit
02fe0044a6
5 changed files with 40 additions and 10 deletions
|
|
@ -1,5 +1,11 @@
|
|||
# Wikimedia Commons for Android
|
||||
|
||||
## v2.8.5
|
||||
- Fixed issues with sporadic upload failures due to wrong mimeType
|
||||
|
||||
## v2.8.4
|
||||
- Hotfix for constant upload crashes for Oreo users
|
||||
|
||||
## 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
|
||||
|
|
|
|||
|
|
@ -64,7 +64,6 @@ dependencies {
|
|||
androidTestImplementation 'com.android.support.test:rules:1.0.2'
|
||||
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
||||
|
||||
debugImplementation "com.squareup.leakcanary:leakcanary-android:$LEAK_CANARY"
|
||||
releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$LEAK_CANARY"
|
||||
testImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$LEAK_CANARY"
|
||||
|
|
@ -72,6 +71,7 @@ dependencies {
|
|||
//For handling runtime permissions
|
||||
implementation 'com.karumi:dexter:5.0.0'
|
||||
|
||||
implementation files('libs/simplemagic-1.9.jar')
|
||||
}
|
||||
|
||||
android {
|
||||
|
|
@ -80,8 +80,8 @@ android {
|
|||
|
||||
defaultConfig {
|
||||
applicationId 'fr.free.nrw.commons'
|
||||
versionCode 90
|
||||
versionName '2.8.3'
|
||||
versionCode 92
|
||||
versionName '2.8.5'
|
||||
setProperty("archivesBaseName", "app-commons-v$versionName-" + getBranchName())
|
||||
|
||||
minSdkVersion 15
|
||||
|
|
|
|||
BIN
app/libs/simplemagic-1.9.jar
Normal file
BIN
app/libs/simplemagic-1.9.jar
Normal file
Binary file not shown.
|
|
@ -131,7 +131,6 @@ public class Utils {
|
|||
|
||||
// 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;
|
||||
|
|
|
|||
|
|
@ -13,9 +13,12 @@ import android.support.v4.app.NotificationCompat;
|
|||
import android.webkit.MimeTypeMap;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.j256.simplemagic.ContentInfo;
|
||||
import com.j256.simplemagic.ContentInfoUtil;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FilterInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashSet;
|
||||
|
|
@ -68,6 +71,7 @@ public class UploadService extends HandlerService<Contribution> {
|
|||
public static final int NOTIFICATION_UPLOAD_IN_PROGRESS = 1;
|
||||
public static final int NOTIFICATION_UPLOAD_COMPLETE = 2;
|
||||
public static final int NOTIFICATION_UPLOAD_FAILED = 3;
|
||||
private ContentInfoUtil contentInfoUtil;
|
||||
|
||||
public UploadService() {
|
||||
super("UploadService");
|
||||
|
|
@ -129,7 +133,6 @@ public class UploadService extends HandlerService<Contribution> {
|
|||
protected void handle(int what, Contribution contribution) {
|
||||
switch (what) {
|
||||
case ACTION_UPLOAD_FILE:
|
||||
//FIXME: Google Photos bug
|
||||
uploadContribution(contribution);
|
||||
break;
|
||||
default:
|
||||
|
|
@ -195,20 +198,34 @@ public class UploadService extends HandlerService<Contribution> {
|
|||
}
|
||||
|
||||
private void uploadContribution(Contribution contribution) {
|
||||
InputStream fileInputStream;
|
||||
|
||||
InputStream fileInputStream = null;
|
||||
InputStream tempFileInputStream = null;
|
||||
ContentInfo contentInfo = null;
|
||||
String notificationTag = contribution.getLocalUri().toString();
|
||||
|
||||
try {
|
||||
//FIXME: Google Photos bug
|
||||
File file1 = new File(contribution.getLocalUri().getPath());
|
||||
fileInputStream = new FileInputStream(file1);
|
||||
//fileInputStream = this.getContentResolver().openInputStream(contribution.getLocalUri());
|
||||
tempFileInputStream = new FileInputStream(file1);
|
||||
if (contentInfoUtil == null) {
|
||||
contentInfoUtil = new ContentInfoUtil();
|
||||
}
|
||||
contentInfo = contentInfoUtil.findMatch(tempFileInputStream);
|
||||
} catch (FileNotFoundException e) {
|
||||
Timber.d("File not found");
|
||||
Toast fileNotFound = Toast.makeText(this, R.string.upload_failed, Toast.LENGTH_LONG);
|
||||
fileNotFound.show();
|
||||
return;
|
||||
} catch (IOException e) {
|
||||
Timber.d("exception while fetching MIME type: "+e);
|
||||
} finally {
|
||||
try {
|
||||
if (null != tempFileInputStream) {
|
||||
tempFileInputStream.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Timber.d("File not found");
|
||||
}
|
||||
}
|
||||
|
||||
//As the fileInputStream is null there's no point in continuing the upload process
|
||||
|
|
@ -226,9 +243,17 @@ public class UploadService extends HandlerService<Contribution> {
|
|||
|
||||
String filename = null;
|
||||
try {
|
||||
//try to fetch the MIME type from contentInfo first and then use the tag to do it
|
||||
//Note : the tag has not proven trustworthy in the past
|
||||
String mimeType;
|
||||
if (contentInfo == null || contentInfo.getMimeType() == null) {
|
||||
mimeType = (String) contribution.getTag("mimeType");
|
||||
} else {
|
||||
mimeType = contentInfo.getMimeType();
|
||||
}
|
||||
filename = Utils.fixExtension(
|
||||
contribution.getFilename(),
|
||||
MimeTypeMap.getSingleton().getExtensionFromMimeType((String)contribution.getTag("mimeType")));
|
||||
MimeTypeMap.getSingleton().getExtensionFromMimeType(mimeType));
|
||||
|
||||
synchronized (unfinishedUploads) {
|
||||
Timber.d("making sure of uniqueness of name: %s", filename);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue