Fix Codacy Issues + remove unused patch

This commit is contained in:
Adam Jones 2017-03-21 20:31:10 +00:00
parent 2e5fdf44ed
commit ea43e1a796
8 changed files with 18 additions and 46 deletions

View file

@ -85,8 +85,7 @@ public class CommonsApplication extends Application {
schemeRegistry.register(new Scheme("https", sslSocketFactory, 443));
ClientConnectionManager cm = new ThreadSafeClientConnManager(params, schemeRegistry);
params.setParameter(CoreProtocolPNames.USER_AGENT, "Commons/" + APPLICATION_VERSION + " (https://mediawiki.org/wiki/Apps/Commons) Android/" + Build.VERSION.RELEASE);
DefaultHttpClient httpclient = new DefaultHttpClient(cm, params);
return httpclient;
return new DefaultHttpClient(cm, params);
}
public static MWApi createMWApi() {
@ -95,8 +94,8 @@ public class CommonsApplication extends Application {
@Override
public void onCreate() {
ACRA.init(this);
super.onCreate();
ACRA.init(this);
// Fire progress callbacks for every 3% of uploaded content
System.setProperty("in.yuvi.http.fluent.PROGRESS_TRIGGER_THRESHOLD", "3.0");
api = createMWApi();
@ -130,15 +129,10 @@ public class CommonsApplication extends Application {
imageCache = new LruCache<String, Bitmap>(cacheSize) {
@Override
protected int sizeOf(String key, Bitmap bitmap) {
// bitmap.getByteCount() not available on older androids
int bitmapSize;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR1) {
bitmapSize = bitmap.getRowBytes() * bitmap.getHeight();
} else {
bitmapSize = bitmap.getByteCount();
}
// The cache size will be measured in kilobytes rather than
// number of items.
bitmapSize = bitmap.getByteCount();
// The cache size will be measured in kilobytes rather than number of items.
return bitmapSize / 1024;
}
};

View file

@ -29,8 +29,8 @@ public abstract class HandlerService<T> extends Service {
@Override
public void onDestroy() {
super.onDestroy();
threadLooper.quit();
super.onDestroy();
}
public class HandlerServiceLocalBinder extends Binder {

View file

@ -225,17 +225,15 @@ public class MediaDataExtractor {
NodeList childNodes = node.getChildNodes();
for (int j = 0, childNodesLength = childNodes.getLength(); j < childNodesLength; j++) {
Node childNode = childNodes.item(j);
if (childNode.getNodeName().equals("name")) {
if (comparator.match(childNode)) {
// yay! Now fetch the value node.
for (int k = j + 1; k < childNodesLength; k++) {
Node siblingNode = childNodes.item(k);
if (siblingNode.getNodeName().equals("value")) {
return siblingNode;
}
if (childNode.getNodeName().equals("name") && comparator.match(childNode)) {
// yay! Now fetch the value node.
for (int k = j + 1; k < childNodesLength; k++) {
Node siblingNode = childNodes.item(k);
if (siblingNode.getNodeName().equals("value")) {
return siblingNode;
}
throw new IOException("No value node found for matched template parameter.");
}
throw new IOException("No value node found for matched template parameter.");
}
}
}

View file

@ -12,6 +12,7 @@ public class ContributionsSyncService extends Service {
@Override
public void onCreate() {
super.onCreate();
synchronized (sSyncAdapterLock) {
if (sSyncAdapter == null) {
sSyncAdapter = new ContributionsSyncAdapter(getApplicationContext(), true);

View file

@ -12,6 +12,7 @@ public class ModificationsSyncService extends Service {
@Override
public void onCreate() {
super.onCreate();
synchronized (sSyncAdapterLock) {
if (sSyncAdapter == null) {
sSyncAdapter = new ModificationsSyncAdapter(getApplicationContext(), true);

View file

@ -109,10 +109,8 @@ public class MultipleShareActivity
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
if (requestCode == 1) {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
multipleUploadBegins();
}
if (requestCode == 1 && grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
multipleUploadBegins();
}
}

View file

@ -1,2 +1,3 @@
#!/bin/sh
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore /home/nico/d/d/wya/nr-commons.keystore commons/target/commons-1.0-SNAPSHOT.apk nrkeystorealias
zipalign -f -v 4 commons/target/commons-1.0-SNAPSHOT.apk commons/target/commons-1.0-SNAPSHOT_signed.apk

View file

@ -1,21 +0,0 @@
diff --git a/app/src/main/java/fr/free/nrw/commons/CommonsApplication.java b/app/src/main/java/fr/free/nrw/commons/CommonsApplication.java
index 3fe594d..8306000 100644
--- a/app/src/main/java/fr/free/nrw/commons/CommonsApplication.java
+++ b/app/src/main/java/fr/free/nrw/commons/CommonsApplication.java
@@ -45,11 +45,12 @@ public class CommonsApplication extends Application {
private MWApi api;
private Account currentAccount = null; // Unlike a savings account...
- public static final String API_URL = "https://test.wikipedia.org/w/api.php";
- public static final String IMAGE_URL_BASE = "https://upload.wikimedia.org/wikipedia/test";
- public static final String HOME_URL = "https://test.wikipedia.org/wiki/";
+ public static final String API_URL = "https://commons.wikimedia.org/w/api.php";
+ public static final String IMAGE_URL_BASE = "https://upload.wikimedia.org/wikipedia/commons";
+ public static final String HOME_URL = "https://commons.wikimedia.org/wiki/";
+
public static final String EVENTLOG_URL = "https://www.wikimedia.org/beacon/event";
- public static final String EVENTLOG_WIKI = "testwiki";
+ public static final String EVENTLOG_WIKI = "commonswiki";
public static final Object[] EVENT_UPLOAD_ATTEMPT = {"MobileAppUploadAttempts", 5334329L};
public static final Object[] EVENT_LOGIN_ATTEMPT = {"MobileAppLoginAttempts", 5257721L};