mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33: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
|
# 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
|
## v2.8.3
|
||||||
- Fixed issues with session tokens not being cleared in 2FA, which should reduce p18 edit failures as well
|
- 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 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:rules:1.0.2'
|
||||||
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
||||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
||||||
|
|
||||||
debugImplementation "com.squareup.leakcanary:leakcanary-android:$LEAK_CANARY"
|
debugImplementation "com.squareup.leakcanary:leakcanary-android:$LEAK_CANARY"
|
||||||
releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$LEAK_CANARY"
|
releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$LEAK_CANARY"
|
||||||
testImplementation "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
|
//For handling runtime permissions
|
||||||
implementation 'com.karumi:dexter:5.0.0'
|
implementation 'com.karumi:dexter:5.0.0'
|
||||||
|
|
||||||
|
implementation files('libs/simplemagic-1.9.jar')
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
|
|
@ -80,8 +80,8 @@ android {
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId 'fr.free.nrw.commons'
|
applicationId 'fr.free.nrw.commons'
|
||||||
versionCode 90
|
versionCode 92
|
||||||
versionName '2.8.3'
|
versionName '2.8.5'
|
||||||
setProperty("archivesBaseName", "app-commons-v$versionName-" + getBranchName())
|
setProperty("archivesBaseName", "app-commons-v$versionName-" + getBranchName())
|
||||||
|
|
||||||
minSdkVersion 15
|
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 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
|
// 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) {
|
if (extension == null && title.lastIndexOf(".")<=0) {
|
||||||
extension = "jpg";
|
extension = "jpg";
|
||||||
title += "." + extension;
|
title += "." + extension;
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,12 @@ import android.support.v4.app.NotificationCompat;
|
||||||
import android.webkit.MimeTypeMap;
|
import android.webkit.MimeTypeMap;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.j256.simplemagic.ContentInfo;
|
||||||
|
import com.j256.simplemagic.ContentInfoUtil;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FilterInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.HashSet;
|
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_IN_PROGRESS = 1;
|
||||||
public static final int NOTIFICATION_UPLOAD_COMPLETE = 2;
|
public static final int NOTIFICATION_UPLOAD_COMPLETE = 2;
|
||||||
public static final int NOTIFICATION_UPLOAD_FAILED = 3;
|
public static final int NOTIFICATION_UPLOAD_FAILED = 3;
|
||||||
|
private ContentInfoUtil contentInfoUtil;
|
||||||
|
|
||||||
public UploadService() {
|
public UploadService() {
|
||||||
super("UploadService");
|
super("UploadService");
|
||||||
|
|
@ -129,7 +133,6 @@ public class UploadService extends HandlerService<Contribution> {
|
||||||
protected void handle(int what, Contribution contribution) {
|
protected void handle(int what, Contribution contribution) {
|
||||||
switch (what) {
|
switch (what) {
|
||||||
case ACTION_UPLOAD_FILE:
|
case ACTION_UPLOAD_FILE:
|
||||||
//FIXME: Google Photos bug
|
|
||||||
uploadContribution(contribution);
|
uploadContribution(contribution);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
@ -195,20 +198,34 @@ public class UploadService extends HandlerService<Contribution> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void uploadContribution(Contribution contribution) {
|
private void uploadContribution(Contribution contribution) {
|
||||||
InputStream fileInputStream;
|
InputStream fileInputStream = null;
|
||||||
|
InputStream tempFileInputStream = null;
|
||||||
|
ContentInfo contentInfo = null;
|
||||||
String notificationTag = contribution.getLocalUri().toString();
|
String notificationTag = contribution.getLocalUri().toString();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//FIXME: Google Photos bug
|
|
||||||
File file1 = new File(contribution.getLocalUri().getPath());
|
File file1 = new File(contribution.getLocalUri().getPath());
|
||||||
fileInputStream = new FileInputStream(file1);
|
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) {
|
} catch (FileNotFoundException e) {
|
||||||
Timber.d("File not found");
|
Timber.d("File not found");
|
||||||
Toast fileNotFound = Toast.makeText(this, R.string.upload_failed, Toast.LENGTH_LONG);
|
Toast fileNotFound = Toast.makeText(this, R.string.upload_failed, Toast.LENGTH_LONG);
|
||||||
fileNotFound.show();
|
fileNotFound.show();
|
||||||
return;
|
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
|
//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;
|
String filename = null;
|
||||||
try {
|
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(
|
filename = Utils.fixExtension(
|
||||||
contribution.getFilename(),
|
contribution.getFilename(),
|
||||||
MimeTypeMap.getSingleton().getExtensionFromMimeType((String)contribution.getTag("mimeType")));
|
MimeTypeMap.getSingleton().getExtensionFromMimeType(mimeType));
|
||||||
|
|
||||||
synchronized (unfinishedUploads) {
|
synchronized (unfinishedUploads) {
|
||||||
Timber.d("making sure of uniqueness of name: %s", filename);
|
Timber.d("making sure of uniqueness of name: %s", filename);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue