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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -184,7 +184,7 @@ public class Repo extends ValueObject {
} }
if (values.containsKey(RepoProvider.DataColumns.IS_SWAP)) { 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 static final String TAG = "RepoProvider.Helper";
private Helper() {} private Helper() { }
public static Repo findByUri(Context context, Uri uri) { public static Repo findByUri(Context context, Uri uri) {
ContentResolver resolver = context.getContentResolver(); 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, @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}) STEP_CONNECTING, STEP_SUCCESS, STEP_CONFIRM_SWAP, STEP_INITIAL_LOADING})
@Retention(RetentionPolicy.SOURCE) @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) { private void onDeviceFound(BluetoothDevice device) {
if (device != null && device.getName() != null && if (device != null && device.getName() != null &&
(device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.COMPUTER_HANDHELD_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.COMPUTER_PALM_SIZE_PC_PDA ||
device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.PHONE_SMART)) { device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.PHONE_SMART)) {
foundPeer(new BluetoothPeer(device)); foundPeer(new BluetoothPeer(device));
} }

View File

@ -170,10 +170,10 @@ public final class BluetoothSwap extends SwapType {
} }
@Override @Override
public void start() {} public void start() { }
@Override @Override
public void stop() {} public void stop() { }
@Override @Override
protected String getBroadcastAction() { 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}, * 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 { public void downloadUninterrupted() throws IOException {
try { try {
download(); download();
} catch (InterruptedException ignored) {} } catch (InterruptedException ignored) { }
} }
public abstract void download() throws IOException, InterruptedException; public abstract void download() throws IOException, InterruptedException;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -315,7 +315,7 @@ public class SwapAppsView extends ListView implements
return; return;
} }
switch(intent.getStringExtra(ApkDownloader.EXTRA_TYPE)) { switch (intent.getStringExtra(ApkDownloader.EXTRA_TYPE)) {
// Fallthrough for each of these "downloader no longer going" events... // Fallthrough for each of these "downloader no longer going" events...
case ApkDownloader.EVENT_APK_DOWNLOAD_COMPLETE: case ApkDownloader.EVENT_APK_DOWNLOAD_COMPLETE:
case ApkDownloader.EVENT_APK_DOWNLOAD_CANCELLED: 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: case SwapService.STEP_INTRO:
showIntro(); showIntro();
break; break;
@ -426,7 +426,7 @@ public class SwapWorkflowActivity extends AppCompatActivity {
R.string.cancel, R.string.cancel,
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) {} public void onClick(DialogInterface dialog, int which) { }
} }
).create().show(); ).create().show();
} }

View File

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