Skip to content

Commit accd7ed

Browse files
committed
Merge branch 'master' into login-screen-improvement
2 parents bcf6511 + 7e5d8c4 commit accd7ed

21 files changed

+161
-67
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ public void onCreate() {
147147
* @return Account|null
148148
*/
149149
public Account getCurrentAccount() {
150-
if(currentAccount == null) {
150+
if (currentAccount == null) {
151151
AccountManager accountManager = AccountManager.get(this);
152152
Account[] allAccounts = accountManager.getAccountsByType(AccountUtil.accountType());
153-
if(allAccounts.length != 0) {
153+
if (allAccounts.length != 0) {
154154
currentAccount = allAccounts[0];
155155
}
156156
}
@@ -161,7 +161,7 @@ public Boolean revalidateAuthToken() {
161161
AccountManager accountManager = AccountManager.get(this);
162162
Account curAccount = getCurrentAccount();
163163

164-
if(curAccount == null) {
164+
if (curAccount == null) {
165165
return false; // This should never happen
166166
}
167167

@@ -224,11 +224,13 @@ public void run(AccountManagerFuture<Boolean> accountManagerFuture) {
224224
if (getIndex() == allAccounts.length) {
225225
Timber.d("All accounts have been removed");
226226
//TODO: fix preference manager
227-
PreferenceManager.getDefaultSharedPreferences(getInstance()).edit().clear().commit();
227+
PreferenceManager.getDefaultSharedPreferences(getInstance())
228+
.edit().clear().commit();
228229
SharedPreferences preferences = context
229230
.getSharedPreferences("fr.free.nrw.commons", MODE_PRIVATE);
230231
preferences.edit().clear().commit();
231-
context.getSharedPreferences("prefs", Context.MODE_PRIVATE).edit().clear().commit();
232+
context.getSharedPreferences("prefs", Context.MODE_PRIVATE)
233+
.edit().clear().commit();
232234
preferences.edit().putBoolean("firstrun", false).apply();
233235
updateAllDatabases();
234236
currentAccount = null;

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import android.support.annotation.Nullable;
44

55
public class License {
6-
String key;
7-
String template;
8-
String url;
9-
String name;
6+
private String key;
7+
private String template;
8+
private String url;
9+
private String name;
1010

1111
public License(String key, String template, String url, String name) {
1212
if (key == null) {

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,9 @@ public static String licenseUrlFor(String license) {
242242
public static boolean xmlFastForward(XmlPullParser parser, String namespace, String element) {
243243
try {
244244
while (parser.next() != XmlPullParser.END_DOCUMENT) {
245-
if (parser.getEventType() == XmlPullParser.START_TAG &&
246-
parser.getNamespace().equals(namespace) &&
247-
parser.getName().equals(element)) {
245+
if (parser.getEventType() == XmlPullParser.START_TAG
246+
&& parser.getNamespace().equals(namespace)
247+
&& parser.getName().equals(element)) {
248248
// We found it!
249249
return true;
250250
}
@@ -267,7 +267,8 @@ public static String fixExtension(String title, String extension) {
267267
extension = "jpg";
268268
}
269269
title = jpegPattern.matcher(title).replaceFirst(".jpg");
270-
if (extension != null && !title.toLowerCase(Locale.getDefault()).endsWith("." + extension.toLowerCase(Locale.ENGLISH))) {
270+
if (extension != null && !title.toLowerCase(Locale.getDefault())
271+
.endsWith("." + extension.toLowerCase(Locale.ENGLISH))) {
271272
title += "." + extension;
272273
}
273274
return title;

app/src/main/java/fr/free/nrw/commons/auth/AuthenticatedActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
public abstract class AuthenticatedActivity extends NavigationBaseActivity {
1616

17-
String accountType;
17+
private String accountType;
1818
CommonsApplication app;
1919

2020
private String authCookie;

app/src/main/java/fr/free/nrw/commons/auth/SignupActivity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ protected void onCreate(Bundle savedInstanceState) {
2525

2626
webView.setWebViewClient(new MyWebViewClient());
2727
WebSettings webSettings = webView.getSettings();
28-
//Needed to refresh Captcha. Might introduce XSS vulnerabilities, but we can trust Wikimedia's site... right?
28+
/*Needed to refresh Captcha. Might introduce XSS vulnerabilities, but we can
29+
trust Wikimedia's site... right?*/
2930
webSettings.setJavaScriptEnabled(true);
3031

3132
webView.loadUrl(BuildConfig.SIGNUP_LANDING_URL);

app/src/main/java/fr/free/nrw/commons/caching/CacheController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void setQtPoint(double decLongitude, double decLatitude) {
3232
public void cacheCategory() {
3333
List<String> pointCatList = new ArrayList<>();
3434
if (MwVolleyApi.GpsCatExists.getGpsCatExists()) {
35-
pointCatList.addAll(MwVolleyApi.getGpsCat());
35+
pointCatList.addAll(MwVolleyApi.getGpsCat());
3636
Timber.d("Categories being cached: %s", pointCatList);
3737
} else {
3838
Timber.d("No categories found, so no categories cached");

app/src/main/java/fr/free/nrw/commons/category/CategorizationFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ private void updateCategoryList(String filter) {
197197
.concatWith(
198198
searchAll(filter)
199199
.mergeWith(searchCategories(filter))
200-
.concatWith( TextUtils.isEmpty(filter)
200+
.concatWith(TextUtils.isEmpty(filter)
201201
? defaultCategories() : Observable.empty())
202202
)
203203
.filter(categoryItem -> !containsYear(categoryItem.getName()))

app/src/main/java/fr/free/nrw/commons/category/CategoryContentProvider.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,13 @@ public int bulkInsert(@NonNull Uri uri, @NonNull ContentValues[] values) {
142142
public int update(@NonNull Uri uri, ContentValues contentValues, String selection,
143143
String[] selectionArgs) {
144144
/*
145-
SQL Injection warnings: First, note that we're not exposing this to the outside world (exported="false")
146-
Even then, we should make sure to sanitize all user input appropriately. Input that passes through ContentValues
145+
SQL Injection warnings: First, note that we're not exposing this to the
146+
outside world (exported="false"). Even then, we should make sure to sanitize
147+
all user input appropriately. Input that passes through ContentValues
147148
should be fine. So only issues are those that pass in via concating.
148149
149-
In here, the only concat created argument is for id. It is cast to an int, and will error out otherwise.
150+
In here, the only concat created argument is for id. It is cast to an int,
151+
and will error out otherwise.
150152
*/
151153
int uriType = uriMatcher.match(uri);
152154
SQLiteDatabase sqlDB = dbOpenHelper.getWritableDatabase();

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,12 @@ public int bulkInsert(@NonNull Uri uri, @NonNull ContentValues[] values) {
154154
public int update(@NonNull Uri uri, ContentValues contentValues, String selection, String[] selectionArgs) {
155155
/*
156156
SQL Injection warnings: First, note that we're not exposing this to the outside world (exported="false")
157-
Even then, we should make sure to sanitize all user input appropriately. Input that passes through ContentValues
158-
should be fine. So only issues are those that pass in via concating.
157+
Even then, we should make sure to sanitize all user input appropriately.
158+
Input that passes through ContentValuesshould be fine. So only issues are those that pass
159+
in via concating.
159160
160-
In here, the only concat created argument is for id. It is cast to an int, and will error out otherwise.
161+
In here, the only concat created argument is for id. It is cast to an int, and will
162+
error out otherwise.
161163
*/
162164
int uriType = uriMatcher.match(uri);
163165
CommonsApplication app = (CommonsApplication) getContext().getApplicationContext();

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public ModifierSequence(Uri mediaUri) {
2727
public ModifierSequence(Uri mediaUri, JSONObject data) {
2828
this(mediaUri);
2929
JSONArray modifiersJSON = data.optJSONArray("modifiers");
30-
for(int i=0; i< modifiersJSON.length(); i++) {
30+
for (int i=0; i< modifiersJSON.length(); i++) {
3131
modifiers.add(PageModifier.fromJSON(modifiersJSON.optJSONObject(i)));
3232
}
3333
}
@@ -41,7 +41,7 @@ public void queueModifier(PageModifier modifier) {
4141
}
4242

4343
public String executeModifications(String pageName, String pageContents) {
44-
for(PageModifier modifier: modifiers) {
44+
for (PageModifier modifier: modifiers) {
4545
pageContents = modifier.doModification(pageName, pageContents);
4646
}
4747
return pageContents;
@@ -60,7 +60,7 @@ public JSONObject toJSON() {
6060
JSONObject data = new JSONObject();
6161
try {
6262
JSONArray modifiersJSON = new JSONArray();
63-
for(PageModifier modifier: modifiers) {
63+
for (PageModifier modifier: modifiers) {
6464
modifiersJSON.put(modifier.toJSON());
6565
}
6666
data.put("modifiers", modifiersJSON);
@@ -81,7 +81,8 @@ public static ModifierSequence fromCursor(Cursor cursor) {
8181
// Hardcoding column positions!
8282
ModifierSequence ms = null;
8383
try {
84-
ms = new ModifierSequence(Uri.parse(cursor.getString(1)), new JSONObject(cursor.getString(2)));
84+
ms = new ModifierSequence(Uri.parse(cursor.getString(1)),
85+
new JSONObject(cursor.getString(2)));
8586
} catch (JSONException e) {
8687
throw new RuntimeException(e);
8788
}

0 commit comments

Comments
 (0)