Skip to content

Commit ea43e1a

Browse files
committed
Fix Codacy Issues + remove unused patch
1 parent 2e5fdf4 commit ea43e1a

File tree

8 files changed

+18
-46
lines changed

8 files changed

+18
-46
lines changed

app/src/main/java/fr/free/nrw/commons/CommonsApplication.java

+5-11
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ public static AbstractHttpClient createHttpClient() {
8585
schemeRegistry.register(new Scheme("https", sslSocketFactory, 443));
8686
ClientConnectionManager cm = new ThreadSafeClientConnManager(params, schemeRegistry);
8787
params.setParameter(CoreProtocolPNames.USER_AGENT, "Commons/" + APPLICATION_VERSION + " (https://mediawiki.org/wiki/Apps/Commons) Android/" + Build.VERSION.RELEASE);
88-
DefaultHttpClient httpclient = new DefaultHttpClient(cm, params);
89-
return httpclient;
88+
return new DefaultHttpClient(cm, params);
9089
}
9190

9291
public static MWApi createMWApi() {
@@ -95,8 +94,8 @@ public static MWApi createMWApi() {
9594

9695
@Override
9796
public void onCreate() {
98-
ACRA.init(this);
9997
super.onCreate();
98+
ACRA.init(this);
10099
// Fire progress callbacks for every 3% of uploaded content
101100
System.setProperty("in.yuvi.http.fluent.PROGRESS_TRIGGER_THRESHOLD", "3.0");
102101
api = createMWApi();
@@ -130,15 +129,10 @@ public void onCreate() {
130129
imageCache = new LruCache<String, Bitmap>(cacheSize) {
131130
@Override
132131
protected int sizeOf(String key, Bitmap bitmap) {
133-
// bitmap.getByteCount() not available on older androids
134132
int bitmapSize;
135-
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR1) {
136-
bitmapSize = bitmap.getRowBytes() * bitmap.getHeight();
137-
} else {
138-
bitmapSize = bitmap.getByteCount();
139-
}
140-
// The cache size will be measured in kilobytes rather than
141-
// number of items.
133+
bitmapSize = bitmap.getByteCount();
134+
135+
// The cache size will be measured in kilobytes rather than number of items.
142136
return bitmapSize / 1024;
143137
}
144138
};

app/src/main/java/fr/free/nrw/commons/HandlerService.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ public void handleMessage(Message msg) {
2929

3030
@Override
3131
public void onDestroy() {
32-
super.onDestroy();
3332
threadLooper.quit();
33+
super.onDestroy();
3434
}
3535

3636
public class HandlerServiceLocalBinder extends Binder {

app/src/main/java/fr/free/nrw/commons/MediaDataExtractor.java

+7-9
Original file line numberDiff line numberDiff line change
@@ -225,17 +225,15 @@ private Node findTemplateParameter(Node templateNode, TemplateChildNodeComparato
225225
NodeList childNodes = node.getChildNodes();
226226
for (int j = 0, childNodesLength = childNodes.getLength(); j < childNodesLength; j++) {
227227
Node childNode = childNodes.item(j);
228-
if (childNode.getNodeName().equals("name")) {
229-
if (comparator.match(childNode)) {
230-
// yay! Now fetch the value node.
231-
for (int k = j + 1; k < childNodesLength; k++) {
232-
Node siblingNode = childNodes.item(k);
233-
if (siblingNode.getNodeName().equals("value")) {
234-
return siblingNode;
235-
}
228+
if (childNode.getNodeName().equals("name") && comparator.match(childNode)) {
229+
// yay! Now fetch the value node.
230+
for (int k = j + 1; k < childNodesLength; k++) {
231+
Node siblingNode = childNodes.item(k);
232+
if (siblingNode.getNodeName().equals("value")) {
233+
return siblingNode;
236234
}
237-
throw new IOException("No value node found for matched template parameter.");
238235
}
236+
throw new IOException("No value node found for matched template parameter.");
239237
}
240238
}
241239
}

app/src/main/java/fr/free/nrw/commons/contributions/ContributionsSyncService.java

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class ContributionsSyncService extends Service {
1212

1313
@Override
1414
public void onCreate() {
15+
super.onCreate();
1516
synchronized (sSyncAdapterLock) {
1617
if (sSyncAdapter == null) {
1718
sSyncAdapter = new ContributionsSyncAdapter(getApplicationContext(), true);

app/src/main/java/fr/free/nrw/commons/modifications/ModificationsSyncService.java

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class ModificationsSyncService extends Service {
1212

1313
@Override
1414
public void onCreate() {
15+
super.onCreate();
1516
synchronized (sSyncAdapterLock) {
1617
if (sSyncAdapter == null) {
1718
sSyncAdapter = new ModificationsSyncAdapter(getApplicationContext(), true);

app/src/main/java/fr/free/nrw/commons/upload/MultipleShareActivity.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,8 @@ public void OnMultipleUploadInitiated() {
109109

110110
@Override
111111
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
112-
if (requestCode == 1) {
113-
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
114-
multipleUploadBegins();
115-
}
112+
if (requestCode == 1 && grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
113+
multipleUploadBegins();
116114
}
117115
}
118116

sign.sh

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

upload-to-commons.patch

-21
This file was deleted.

0 commit comments

Comments
 (0)