checkstyle: Add WhitespaceAround

This commit is contained in:
Daniel Martí 2015-10-08 20:01:37 +02:00
parent 95b53706f9
commit 3eb758f1b2
24 changed files with 60 additions and 61 deletions

View File

@ -114,17 +114,17 @@ public class BoundedInputStream extends InputStream {
*/
@Override
public int read(byte[] b, int off, int len) throws IOException {
if (max>=0 && pos>=max) {
if (max >= 0 && pos >= max) {
return -1;
}
long maxRead = max>=0 ? Math.min(len, max-pos) : len;
long maxRead = max >= 0 ? Math.min(len, max - pos) : len;
int bytesRead = in.read(b, off, (int) maxRead);
if (bytesRead==-1) {
if (bytesRead == -1) {
return -1;
}
pos+=bytesRead;
pos += bytesRead;
return bytesRead;
}
@ -136,9 +136,9 @@ public class BoundedInputStream extends InputStream {
*/
@Override
public long skip(long n) throws IOException {
long toSkip = max>=0 ? Math.min(n, max-pos) : n;
long toSkip = max >= 0 ? Math.min(n, max - pos) : n;
long skippedBytes = in.skip(toSkip);
pos+=skippedBytes;
pos += skippedBytes;
return skippedBytes;
}
@ -147,7 +147,7 @@ public class BoundedInputStream extends InputStream {
*/
@Override
public int available() throws IOException {
if (max>=0 && pos>=max) {
if (max >= 0 && pos >= max) {
return 0;
}
return in.available();

View File

@ -1118,15 +1118,15 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
return s;
}
int i;
for (i = s.length()-1; i >= 0; i--) {
for (i = s.length() - 1; i >= 0; i--) {
if (s.charAt(i) != '\n') {
break;
}
}
if (i == s.length()-1) {
if (i == s.length() - 1) {
return s;
}
return s.subSequence(0, i+1);
return s.subSequence(0, i + 1);
}
private ViewGroup layout_links_content;
@ -1586,7 +1586,7 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
btMain.setText(R.string.menu_upgrade);
} else {
updateWanted = false;
if (activity.mPm.getLaunchIntentForPackage(getApp().id) != null){
if (activity.mPm.getLaunchIntentForPackage(getApp().id) != null) {
btMain.setText(R.string.menu_launch);
} else {
btMain.setText(R.string.menu_uninstall);

View File

@ -119,7 +119,7 @@ public class Hasher {
public static byte[] unhex(String data) {
byte[] rawdata = new byte[data.length() / 2];
for (int i=0; i < data.length(); i++) {
for (int i = 0; i < data.length(); i++) {
char halfbyte = data.charAt(i);
int value;
if ('0' <= halfbyte && halfbyte <= '9')
@ -130,7 +130,7 @@ public class Hasher {
value = halfbyte - 'A' + 10;
else
throw new IllegalArgumentException("Bad hex digit");
rawdata[i/2] += (byte) (i % 2 == 0 ? value << 4 : value);
rawdata[i / 2] += (byte) (i % 2 == 0 ? value << 4 : value);
}
return rawdata;
}

View File

@ -44,7 +44,7 @@ public final class PRNGFixes extends Compatibility {
getBuildFingerprintAndDeviceSerial();
/** Hidden constructor to prevent instantiation. */
private PRNGFixes() {}
private PRNGFixes() { }
/**
* Applies all fixes.

View File

@ -30,7 +30,7 @@ public class ApkProvider extends FDroidProvider {
public static final class Helper {
private Helper() {}
private Helper() { }
public static void update(Context context, Apk apk) {
ContentResolver resolver = context.getContentResolver();

View File

@ -28,7 +28,7 @@ public class AppProvider extends FDroidProvider {
public static final class Helper {
private Helper() {}
private Helper() { }
public static int count(Context context, Uri uri) {
final String[] projection = {AppProvider.DataColumns._COUNT};

View File

@ -167,7 +167,7 @@ public class InstalledAppCacheUpdater {
protected Boolean doInBackground(Void... params) {
try {
Thread.sleep(10000);
} catch (InterruptedException ignored) {}
} catch (InterruptedException ignored) { }
return update();
}

View File

@ -184,7 +184,7 @@ public class Repo extends ValueObject {
}
if (values.containsKey(RepoProvider.DataColumns.IS_SWAP)) {
isSwap= toInt(values.getAsInteger(RepoProvider.DataColumns.IS_SWAP)) == 1;
isSwap = toInt(values.getAsInteger(RepoProvider.DataColumns.IS_SWAP)) == 1;
}
}
}

View File

@ -25,7 +25,7 @@ public class RepoProvider extends FDroidProvider {
private static final String TAG = "RepoProvider.Helper";
private Helper() {}
private Helper() { }
public static Repo findByUri(Context context, Uri uri) {
ContentResolver resolver = context.getContentResolver();

View File

@ -285,7 +285,7 @@ public class SwapService extends Service {
@IntDef({STEP_INTRO, STEP_SELECT_APPS, STEP_JOIN_WIFI, STEP_SHOW_NFC, STEP_WIFI_QR,
STEP_CONNECTING, STEP_SUCCESS, STEP_CONFIRM_SWAP, STEP_INITIAL_LOADING})
@Retention(RetentionPolicy.SOURCE)
public @interface SwapStep {}
public @interface SwapStep { }
// =================================================

View File

@ -97,8 +97,8 @@ public class BluetoothFinder extends PeerFinder<BluetoothPeer> {
private void onDeviceFound(BluetoothDevice device) {
if (device != null && device.getName() != null &&
(device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.COMPUTER_HANDHELD_PC_PDA||
device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.COMPUTER_PALM_SIZE_PC_PDA||
(device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.COMPUTER_HANDHELD_PC_PDA ||
device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.COMPUTER_PALM_SIZE_PC_PDA ||
device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.PHONE_SMART)) {
foundPeer(new BluetoothPeer(device));
}

View File

@ -170,10 +170,10 @@ public final class BluetoothSwap extends SwapType {
}
@Override
public void start() {}
public void start() { }
@Override
public void stop() {}
public void stop() { }
@Override
protected String getBroadcastAction() {

View File

@ -49,7 +49,7 @@ public abstract class SwapType {
}
}
protected void onStopped() {}
protected void onStopped() { }
/**
* Sends either a {@link org.fdroid.fdroid.localrepo.SwapService#EXTRA_STARTING},

View File

@ -91,7 +91,7 @@ public abstract class Downloader {
public void downloadUninterrupted() throws IOException {
try {
download();
} catch (InterruptedException ignored) {}
} catch (InterruptedException ignored) { }
}
public abstract void download() throws IOException, InterruptedException;

View File

@ -169,7 +169,7 @@ public class HttpDownloader extends Downloader {
if (stream != null)
stream.close();
}
catch (IOException e) {}
catch (IOException e) { }
connection.disconnect();
}

View File

@ -40,7 +40,7 @@ public class IconDownloader extends BaseImageDownloader {
InputStream is = downloader.getInputStream();
int b;
while ((b = is.read())!=-1)
while ((b = is.read()) != -1)
baos.write(b);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());

View File

@ -140,7 +140,7 @@ public final class Request {
while (line == null) {
while (input.available()>0) {
while (input.available() > 0) {
int b = input.read();
@ -152,11 +152,10 @@ public final class Request {
}
baos.write(b);
}
try { Thread.sleep(100); }
catch (Exception e){}
catch (Exception e) { }
}
return line;
@ -180,7 +179,7 @@ public final class Request {
headers.put(header, value);
}
if (input.available()>0)
if (input.available() > 0)
responseLine = readLine();
else
break;

View File

@ -154,7 +154,7 @@ public class Response {
private int fileSize = -1;
private String etag = null;
public Builder() {}
public Builder() { }
public Builder(InputStream contentStream) {
this.contentStream = contentStream;

View File

@ -68,7 +68,7 @@ public class AppDiff {
// data we still want to count it as "installed".
mInstalledAppInfo = mPm.getApplicationInfo(pkgName,
PackageManager.GET_UNINSTALLED_PACKAGES);
if ((mInstalledAppInfo.flags&ApplicationInfo.FLAG_INSTALLED) == 0) {
if ((mInstalledAppInfo.flags & ApplicationInfo.FLAG_INSTALLED) == 0) {
mInstalledAppInfo = null;
}
} catch (PackageManager.NameNotFoundException e) {

View File

@ -65,9 +65,9 @@ public class AppSecurityPermissions {
private static final String TAG = "AppSecurityPermissions";
public static final int WHICH_PERSONAL = 1<<0;
public static final int WHICH_DEVICE = 1<<1;
public static final int WHICH_NEW = 1<<2;
public static final int WHICH_PERSONAL = 1 << 0;
public static final int WHICH_DEVICE = 1 << 1;
public static final int WHICH_NEW = 1 << 2;
private final Context mContext;
private final LayoutInflater mInflater;
@ -276,12 +276,12 @@ public class AppSecurityPermissions {
}
final int[] flagsList = getRequestedPermissionFlags(info);
for (int i=0; i<strList.length; i++) {
for (int i = 0; i < strList.length; i++) {
String permName = strList[i];
// If we are only looking at an existing app, then we only
// care about permissions that have actually been granted to it.
if (installedPkgInfo != null && info == installedPkgInfo) {
if ((flagsList[i]&PackageInfo.REQUESTED_PERMISSION_GRANTED) == 0) {
if ((flagsList[i] & PackageInfo.REQUESTED_PERMISSION_GRANTED) == 0) {
continue;
}
}
@ -292,7 +292,7 @@ public class AppSecurityPermissions {
}
int existingIndex = -1;
if (installedPkgInfo != null && installedPkgInfo.requestedPermissions != null) {
for (int j=0; j<installedPkgInfo.requestedPermissions.length; j++) {
for (int j = 0; j < installedPkgInfo.requestedPermissions.length; j++) {
if (permName.equals(installedPkgInfo.requestedPermissions[j])) {
existingIndex = j;
break;
@ -337,7 +337,7 @@ public class AppSecurityPermissions {
mPermGroups.put(tmpPermInfo.group, group);
}
final boolean newPerm = installedPkgInfo != null
&& (existingFlags&PackageInfo.REQUESTED_PERMISSION_GRANTED) == 0;
&& (existingFlags & PackageInfo.REQUESTED_PERMISSION_GRANTED) == 0;
MyPermissionInfo myPerm = new MyPermissionInfo(tmpPermInfo);
myPerm.mNewReqFlags = flagsList[i];
myPerm.mExistingReqFlags = existingFlags;
@ -366,7 +366,7 @@ public class AppSecurityPermissions {
public int getPermissionCount(int which) {
int N = 0;
for (int i=0; i<mPermGroupsList.size(); i++) {
for (int i = 0; i < mPermGroupsList.size(); i++) {
N += getPermissionList(mPermGroupsList.get(i), which).size();
}
return N;
@ -393,12 +393,12 @@ public class AppSecurityPermissions {
LinearLayout permListView, int which) {
permListView.removeAllViews();
int spacing = (int) (8*mContext.getResources().getDisplayMetrics().density);
int spacing = (int) (8 * mContext.getResources().getDisplayMetrics().density);
for (int i=0; i<groups.size(); i++) {
for (int i = 0; i < groups.size(); i++) {
MyPermissionGroupInfo grp = groups.get(i);
final List<MyPermissionInfo> perms = getPermissionList(grp, which);
for (int j=0; j<perms.size(); j++) {
for (int j = 0; j < perms.size(); j++) {
MyPermissionInfo perm = perms.get(j);
View view = getPermissionItemView(grp, perm, j == 0,
which != WHICH_NEW ? mNewPermPrefix : null);
@ -408,7 +408,7 @@ public class AppSecurityPermissions {
if (j == 0) {
lp.topMargin = spacing;
}
if (j == grp.mAllPermissions.size()-1) {
if (j == grp.mAllPermissions.size() - 1) {
lp.bottomMargin = spacing;
}
if (permListView.getChildCount() == 0) {
@ -432,15 +432,15 @@ public class AppSecurityPermissions {
private boolean isDisplayablePermission(PermissionInfo pInfo, int newReqFlags,
int existingReqFlags) {
final int base = pInfo.protectionLevel&PermissionInfo.PROTECTION_MASK_BASE;
final int base = pInfo.protectionLevel & PermissionInfo.PROTECTION_MASK_BASE;
final boolean isNormal = (base == PermissionInfo.PROTECTION_NORMAL);
final boolean isDangerous = (base == PermissionInfo.PROTECTION_DANGEROUS);
final boolean isRequired =
((newReqFlags&PackageInfo.REQUESTED_PERMISSION_REQUIRED) != 0);
((newReqFlags & PackageInfo.REQUESTED_PERMISSION_REQUIRED) != 0);
final boolean wasGranted =
((existingReqFlags&PackageInfo.REQUESTED_PERMISSION_GRANTED) != 0);
((existingReqFlags & PackageInfo.REQUESTED_PERMISSION_GRANTED) != 0);
final boolean isGranted =
((newReqFlags&PackageInfo.REQUESTED_PERMISSION_GRANTED) != 0);
((newReqFlags & PackageInfo.REQUESTED_PERMISSION_GRANTED) != 0);
// Dangerous and normal permissions are always shown to the user if the permission
// is required, or it was previously granted
@ -450,7 +450,7 @@ public class AppSecurityPermissions {
}
final boolean isDevelopment =
((pInfo.protectionLevel&PermissionInfo.PROTECTION_FLAG_DEVELOPMENT) != 0);
((pInfo.protectionLevel & PermissionInfo.PROTECTION_FLAG_DEVELOPMENT) != 0);
// Development permissions are only shown to the user if they are already
// granted to the app -- if we are installing an app and they are not
@ -463,8 +463,8 @@ public class AppSecurityPermissions {
PermissionGroupInfoComparator() {
}
public final int compare(MyPermissionGroupInfo a, MyPermissionGroupInfo b) {
if (((a.flags()^b.flags())&PermissionGroupInfo.FLAG_PERSONAL_INFO) != 0) {
return ((a.flags()&PermissionGroupInfo.FLAG_PERSONAL_INFO) != 0) ? -1 : 1;
if (((a.flags() ^ b.flags()) & PermissionGroupInfo.FLAG_PERSONAL_INFO) != 0) {
return ((a.flags() & PermissionGroupInfo.FLAG_PERSONAL_INFO) != 0) ? -1 : 1;
}
if (a.priority() != b.priority()) {
return a.priority() > b.priority() ? -1 : 1;
@ -489,7 +489,7 @@ public class AppSecurityPermissions {
}
int idx = Collections.binarySearch(permList, pInfo, mPermComparator);
if (idx < 0) {
idx = -idx-1;
idx = -idx - 1;
permList.add(idx, pInfo);
}
}
@ -508,7 +508,7 @@ public class AppSecurityPermissions {
if (pInfo.mNew) {
addPermToList(group.mNewPermissions, pInfo);
}
if ((group.flags()&PermissionGroupInfo.FLAG_PERSONAL_INFO) != 0) {
if ((group.flags() & PermissionGroupInfo.FLAG_PERSONAL_INFO) != 0) {
addPermToList(group.mPersonalPermissions, pInfo);
} else {
addPermToList(group.mDevicePermissions, pInfo);

View File

@ -327,10 +327,10 @@ public class ManageReposActivity extends ActionBarActivity {
final TextWatcher textChangedListener = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
public void beforeTextChanged(CharSequence s, int start, int count, int after) { }
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {}
public void onTextChanged(CharSequence s, int start, int before, int count) { }
@Override
public void afterTextChanged(Editable s) {

View File

@ -315,7 +315,7 @@ public class SwapAppsView extends ListView implements
return;
}
switch(intent.getStringExtra(ApkDownloader.EXTRA_TYPE)) {
switch (intent.getStringExtra(ApkDownloader.EXTRA_TYPE)) {
// Fallthrough for each of these "downloader no longer going" events...
case ApkDownloader.EVENT_APK_DOWNLOAD_COMPLETE:
case ApkDownloader.EVENT_APK_DOWNLOAD_CANCELLED:

View File

@ -294,7 +294,7 @@ public class SwapWorkflowActivity extends AppCompatActivity {
}
}
switch(service.getStep()) {
switch (service.getStep()) {
case SwapService.STEP_INTRO:
showIntro();
break;
@ -426,7 +426,7 @@ public class SwapWorkflowActivity extends AppCompatActivity {
R.string.cancel,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {}
public void onClick(DialogInterface dialog, int which) { }
}
).create().show();
}

View File

@ -43,7 +43,7 @@
<module name="ParenPad" />
<module name="TypecastParenPad" />
<module name="WhitespaceAfter" />
<!--<module name="WhitespaceAround" />-->
<module name="WhitespaceAround" />
<module name="ModifierOrder" />
<module name="RedundantModifier" />