Skip to content

Commit 3b728ca

Browse files
committed
Coding style fixes
1 parent ee409a9 commit 3b728ca

File tree

11 files changed

+90
-86
lines changed

11 files changed

+90
-86
lines changed

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void onCreate(Bundle savedInstanceState) {
6161
usernameEdit.addTextChangedListener(textWatcher);
6262
passwordEdit.addTextChangedListener(textWatcher);
6363
twoFactorEdit.addTextChangedListener(textWatcher);
64-
passwordEdit.setOnEditorActionListener( newLoginInputActionListener() );
64+
passwordEdit.setOnEditorActionListener(newLoginInputActionListener());
6565

6666
loginButton.setOnClickListener(new View.OnClickListener() {
6767
@Override
@@ -151,7 +151,7 @@ private void performLogin() {
151151
private LoginTask getLoginTask() {
152152
return new LoginTask(
153153
this,
154-
canonicializeUsername( usernameEdit.getText().toString() ),
154+
canonicializeUsername(usernameEdit.getText().toString()),
155155
passwordEdit.getText().toString(),
156156
twoFactorEdit.getText().toString()
157157
);
@@ -162,16 +162,16 @@ private LoginTask getLoginTask() {
162162
* @param username String
163163
* @return String canonicial username
164164
*/
165-
private String canonicializeUsername( String username ) {
165+
private String canonicializeUsername(String username) {
166166
return new PageTitle(username).getText();
167167
}
168168

169169
@Override
170170
public boolean onOptionsItemSelected(MenuItem item) {
171171
switch (item.getItemId()) {
172-
case android.R.id.home:
173-
NavUtils.navigateUpFromSameTask(this);
174-
return true;
172+
case android.R.id.home:
173+
NavUtils.navigateUpFromSameTask(this);
174+
return true;
175175
}
176176
return super.onOptionsItemSelected(item);
177177
}
@@ -186,20 +186,20 @@ public void signUp(View view) {
186186
}
187187

188188
public void askUserForTwoFactorAuth() {
189-
if(BuildConfig.DEBUG) {
189+
if (BuildConfig.DEBUG) {
190190
twoFactorEdit.setVisibility(View.VISIBLE);
191-
showUserToastAndCancelDialog( R.string.login_failed_2fa_needed );
192-
}else{
193-
showUserToastAndCancelDialog( R.string.login_failed_2fa_not_supported );
191+
showUserToastAndCancelDialog(R.string.login_failed_2fa_needed);
192+
} else {
193+
showUserToastAndCancelDialog(R.string.login_failed_2fa_not_supported);
194194
}
195195
}
196196

197-
public void showUserToastAndCancelDialog( int resId ) {
198-
showUserToast( resId );
197+
public void showUserToastAndCancelDialog(int resId) {
198+
showUserToast(resId);
199199
progressDialog.cancel();
200200
}
201201

202-
private void showUserToast( int resId ) {
202+
private void showUserToast(int resId) {
203203
Toast.makeText(this, resId, Toast.LENGTH_LONG).show();
204204
}
205205

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ protected void onPostExecute(String result) {
6767
if (result.equals("PASS")) {
6868
handlePassResult();
6969
} else {
70-
handleOtherResults( result );
70+
handleOtherResults(result);
7171
}
7272
}
7373

@@ -88,38 +88,38 @@ private void handlePassResult() {
8888
}
8989
}
9090

91-
AccountUtil.createAccount( response, username, password );
91+
AccountUtil.createAccount(response, username, password);
9292
loginActivity.startMainActivity();
9393
}
9494

9595
/**
96-
* Match known failure message codes and provide messages
96+
* Match known failure message codes and provide messages.
9797
* @param result String
9898
*/
99-
private void handleOtherResults( String result ) {
99+
private void handleOtherResults(String result) {
100100
if (result.equals("NetworkFailure")) {
101101
// Matches NetworkFailure which is created by the doInBackground method
102-
loginActivity.showUserToastAndCancelDialog( R.string.login_failed_network );
102+
loginActivity.showUserToastAndCancelDialog(R.string.login_failed_network);
103103
} else if (result.toLowerCase().contains("nosuchuser".toLowerCase()) || result.toLowerCase().contains("noname".toLowerCase())) {
104104
// Matches nosuchuser, nosuchusershort, noname
105-
loginActivity.showUserToastAndCancelDialog( R.string.login_failed_username );
105+
loginActivity.showUserToastAndCancelDialog(R.string.login_failed_username);
106106
loginActivity.emptySensitiveEditFields();
107107
} else if (result.toLowerCase().contains("wrongpassword".toLowerCase())) {
108108
// Matches wrongpassword, wrongpasswordempty
109-
loginActivity.showUserToastAndCancelDialog( R.string.login_failed_password );
109+
loginActivity.showUserToastAndCancelDialog(R.string.login_failed_password);
110110
loginActivity.emptySensitiveEditFields();
111111
} else if (result.toLowerCase().contains("throttle".toLowerCase())) {
112112
// Matches unknown throttle error codes
113-
loginActivity.showUserToastAndCancelDialog( R.string.login_failed_throttled );
113+
loginActivity.showUserToastAndCancelDialog(R.string.login_failed_throttled);
114114
} else if (result.toLowerCase().contains("userblocked".toLowerCase())) {
115115
// Matches login-userblocked
116-
loginActivity.showUserToastAndCancelDialog( R.string.login_failed_blocked );
116+
loginActivity.showUserToastAndCancelDialog(R.string.login_failed_blocked);
117117
} else if (result.equals("2FA")) {
118118
loginActivity.askUserForTwoFactorAuth();
119119
} else {
120120
// Occurs with unhandled login failure codes
121121
Timber.d("Login failed with reason: %s", result);
122-
loginActivity.showUserToastAndCancelDialog( R.string.login_failed_generic );
122+
loginActivity.showUserToastAndCancelDialog(R.string.login_failed_generic);
123123
}
124124
}
125125
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
import android.content.Intent;
66
import android.os.IBinder;
77

8-
public class WikiAccountAuthenticatorService extends Service{
8+
public class WikiAccountAuthenticatorService extends Service {
99

1010
private static WikiAccountAuthenticator wikiAccountAuthenticator = null;
1111

1212
@Override
1313
public IBinder onBind(Intent intent) {
1414
if (!intent.getAction().equals(AccountManager.ACTION_AUTHENTICATOR_INTENT)) {
15-
return null;
15+
return null;
1616
}
1717

18-
if(wikiAccountAuthenticator == null) {
18+
if (wikiAccountAuthenticator == null) {
1919
wikiAccountAuthenticator = new WikiAccountAuthenticator(this);
2020
}
2121
return wikiAccountAuthenticator.getIBinder();

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ public void convertCoordRange() {
7474
double offset = 100;
7575

7676
//Coordinate offsets in radians
77-
double dLat = offset/EARTH_RADIUS;
78-
double dLon = offset/(EARTH_RADIUS*Math.cos(Math.PI*lat/180));
77+
double dLat = offset / EARTH_RADIUS;
78+
double dLon = offset / (EARTH_RADIUS * Math.cos(Math.PI * lat / 180));
7979

8080
//OffsetPosition, decimal degrees
81-
yPlus = lat + dLat * 180/Math.PI;
82-
yMinus = lat - dLat * 180/Math.PI;
83-
xPlus = lon + dLon * 180/Math.PI;
84-
xMinus = lon - dLon * 180/Math.PI;
81+
yPlus = lat + dLat * 180 / Math.PI;
82+
yMinus = lat - dLat * 180 / Math.PI;
83+
xPlus = lon + dLon * 180 / Math.PI;
84+
xMinus = lon - dLon * 180 / Math.PI;
8585
Timber.d("Search within: xMinus=%s, yMinus=%s, xPlus=%s, yPlus=%s",
8686
xMinus, yMinus, xPlus, yPlus);
8787
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ public void setContentProviderClient(ContentProviderClient client) {
6060

6161
public void save() {
6262
try {
63-
if(contentUri == null) {
63+
if (contentUri == null) {
6464
contentUri = client.insert(CategoryContentProvider.BASE_URI, this.toContentValues());
6565
} else {
6666
client.update(contentUri, toContentValues(), null, null);
6767
}
68-
} catch(RemoteException e) {
68+
} catch (RemoteException e) {
6969
throw new RuntimeException(e);
7070
}
7171
}
@@ -121,23 +121,23 @@ public static void onDelete(SQLiteDatabase db) {
121121
}
122122

123123
public static void onUpdate(SQLiteDatabase db, int from, int to) {
124-
if(from == to) {
124+
if (from == to) {
125125
return;
126126
}
127-
if(from < 4) {
127+
if (from < 4) {
128128
// doesn't exist yet
129129
from++;
130130
onUpdate(db, from, to);
131131
return;
132132
}
133-
if(from == 4) {
133+
if (from == 4) {
134134
// table added in version 5
135135
onCreate(db);
136136
from++;
137137
onUpdate(db, from, to);
138138
return;
139139
}
140-
if(from == 5) {
140+
if (from == 5) {
141141
from++;
142142
onUpdate(db, from, to);
143143
return;

app/src/main/java/fr/free/nrw/commons/media/MediaDetailPagerFragment.java

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@
3535
import fr.free.nrw.commons.mwapi.EventLog;
3636

3737
public class MediaDetailPagerFragment extends Fragment implements ViewPager.OnPageChangeListener {
38+
39+
public interface MediaDetailProvider {
40+
Media getMediaAtPosition(int i);
41+
42+
int getTotalMediaCount();
43+
44+
void notifyDatasetChanged();
45+
46+
void registerDataSetObserver(DataSetObserver observer);
47+
48+
void unregisterDataSetObserver(DataSetObserver observer);
49+
}
50+
3851
private ViewPager pager;
3952
private Boolean editable;
4053
private CommonsApplication app;
@@ -48,14 +61,6 @@ public MediaDetailPagerFragment(Boolean editable) {
4861
this.editable = editable;
4962
}
5063

51-
public interface MediaDetailProvider {
52-
Media getMediaAtPosition(int i);
53-
int getTotalMediaCount();
54-
void notifyDatasetChanged();
55-
void registerDataSetObserver(DataSetObserver observer);
56-
void unregisterDataSetObserver(DataSetObserver observer);
57-
}
58-
5964
//FragmentStatePagerAdapter allows user to swipe across collection of images (no. of images undetermined)
6065
private class MediaDetailAdapter extends FragmentStatePagerAdapter {
6166

@@ -65,7 +70,7 @@ public MediaDetailAdapter(FragmentManager fm) {
6570

6671
@Override
6772
public Fragment getItem(int i) {
68-
if(i == 0) {
73+
if (i == 0) {
6974
// See bug https://code.google.com/p/android/issues/detail?id=27526
7075
pager.postDelayed(new Runnable() {
7176
@Override
@@ -120,7 +125,7 @@ public void onSaveInstanceState(Bundle outState) {
120125
@Override
121126
public void onCreate(Bundle savedInstanceState) {
122127
super.onCreate(savedInstanceState);
123-
if(savedInstanceState != null) {
128+
if (savedInstanceState != null) {
124129
editable = savedInstanceState.getBoolean("editable");
125130
}
126131
app = CommonsApplication.getInstance();
@@ -206,13 +211,13 @@ public void onClick(View view) {
206211

207212
@Override
208213
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
209-
if(!editable) { // Disable menu options for editable views
214+
if (!editable) { // Disable menu options for editable views
210215
menu.clear(); // see http://stackoverflow.com/a/8495697/17865
211216
inflater.inflate(R.menu.fragment_image_detail, menu);
212-
if(pager != null) {
217+
if (pager != null) {
213218
MediaDetailProvider provider = (MediaDetailProvider)getActivity();
214219
Media m = provider.getMediaAtPosition(pager.getCurrentItem());
215-
if(m != null) {
220+
if (m != null) {
216221
// Enable default set of actions, then re-enable different set of actions only if it is a failed contrib
217222
menu.findItem(R.id.menu_retry_current_image).setEnabled(false).setVisible(false);
218223
menu.findItem(R.id.menu_cancel_current_image).setEnabled(false).setVisible(false);

app/src/main/java/fr/free/nrw/commons/nearby/NearbyBaseMarker.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@
1616
import fr.free.nrw.commons.utils.UriSerializer;
1717

1818
public class NearbyBaseMarker extends BaseMarkerOptions<NearbyMarker, NearbyBaseMarker> {
19+
20+
public static final Parcelable.Creator<NearbyBaseMarker> CREATOR = new Parcelable.Creator<NearbyBaseMarker>() {
21+
public NearbyBaseMarker createFromParcel(Parcel in) {
22+
return new NearbyBaseMarker(in);
23+
}
24+
25+
public NearbyBaseMarker[] newArray(int size) {
26+
return new NearbyBaseMarker[size];
27+
}
28+
};
29+
1930
private Place place;
2031

2132
NearbyBaseMarker() {
@@ -74,15 +85,4 @@ public void writeToParcel(Parcel dest, int flags) {
7485
dest.writeString(title);
7586
dest.writeString(gson.toJson(place));
7687
}
77-
78-
public static final Parcelable.Creator<NearbyBaseMarker> CREATOR
79-
= new Parcelable.Creator<NearbyBaseMarker>() {
80-
public NearbyBaseMarker createFromParcel(Parcel in) {
81-
return new NearbyBaseMarker(in);
82-
}
83-
84-
public NearbyBaseMarker[] newArray(int size) {
85-
return new NearbyBaseMarker[size];
86-
}
87-
};
8888
}

0 commit comments

Comments
 (0)