Skip to content

Commit

Permalink
Revert "Removes redundant parenthesis" (getodk#1544)
Browse files Browse the repository at this point in the history
Conflicted with getodk#1529 which includes changes made with IDE support.
  • Loading branch information
lognaturel authored Oct 19, 2017
1 parent 42adf2e commit cddd425
Show file tree
Hide file tree
Showing 38 changed files with 80 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public void onSensorChanged(SensorEvent event) {
double degrees = normalizeDegree(azimuth);
bearingDecimal = String.format(Locale.US, "%.3f", degrees);
String dir = "N";
if (degrees > 0 && degrees <= 22.5 || degrees > 337.5) {
if ((degrees > 0 && degrees <= 22.5) || degrees > 337.5) {
dir = "N";
} else if (degrees > 22.5 && degrees <= 67.5) {
dir = "NE";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void onCreate(Bundle savedInstanceState) {

if (savedInstanceState != null && savedInstanceState.containsKey(syncMsgKey)) {
TextView tv = (TextView) findViewById(R.id.status_text);
tv.setText(savedInstanceState.getString(syncMsgKey).trim());
tv.setText((savedInstanceState.getString(syncMsgKey)).trim());
}

// DiskSyncTask checks the disk for any forms not already in the content provider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ public static boolean isLocalFormSuperseded(String formId, String latestVersion)
int idxJrVersion = formCursor.getColumnIndex(FormsColumns.JR_VERSION);
if (formCursor.isNull(idxJrVersion)) {
// any non-null version on server is newer
return latestVersion != null;
return (latestVersion != null);
}
String jrVersion = formCursor.getString(idxJrVersion);
// apparently, the isNull() predicate above is not respected on all Android OSes???
Expand All @@ -596,7 +596,7 @@ public static boolean isLocalFormSuperseded(String formId, String latestVersion)
return false;
}
// if what we have is less, then the server is newer
return jrVersion.compareTo(latestVersion) < 0;
return (jrVersion.compareTo(latestVersion) < 0);
} finally {
if (formCursor != null) {
formCursor.close();
Expand Down Expand Up @@ -661,8 +661,8 @@ public void formListDownloadingComplete(HashMap<String, FormDetails> result) {
HashMap<String, String> item = new HashMap<String, String>();
item.put(FORMNAME, details.formName);
item.put(FORMID_DISPLAY,
(details.formVersion == null) ? "" : (getString(R.string.version) + " "
+ details.formVersion + " ") + "ID: " + details.formID);
((details.formVersion == null) ? "" : (getString(R.string.version) + " "
+ details.formVersion + " ")) + "ID: " + details.formID);
item.put(FORMDETAIL_KEY, formDetailsKey);
item.put(FORM_ID_KEY, details.formID);
item.put(FORM_VERSION_KEY, details.formVersion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ public boolean onPrepareOptionsMenu(Menu menu) {
.getFormController();

useability = (boolean) AdminSharedPreferences.getInstance().get(AdminKeys.KEY_CHANGE_LANGUAGE)
&& formController != null
&& (formController != null)
&& formController.getLanguages() != null
&& formController.getLanguages().length > 1;

Expand Down Expand Up @@ -1238,7 +1238,7 @@ private View createView(int event, boolean advancingPage) {
public CharSequence filter(CharSequence source, int start,
int end, Spanned dest, int dstart, int dend) {
for (int i = start; i < end; i++) {
if (Character.getType(source.charAt(i)) == Character.CONTROL) {
if (Character.getType((source.charAt(i))) == Character.CONTROL) {
return "";
}
}
Expand Down Expand Up @@ -2107,7 +2107,7 @@ private void removeTempInstance() {
try {
c = new InstancesDao().getInstancesCursorForFilePath(formController.getInstancePath()
.getAbsolutePath());
erase = c.getCount() < 1;
erase = (c.getCount() < 1);
} finally {
if (c != null) {
c.close();
Expand Down Expand Up @@ -2529,7 +2529,7 @@ private void afterAllAnimations() {
public void onAnimationEnd(Animation animation) {
Timber.i("onAnimationEnd %s",
((animation == inAnimation) ? "in"
: animation == outAnimation ? "out" : "other"));
: ((animation == outAnimation) ? "out" : "other")));
if (inAnimation == animation) {
animationCompletionSet |= 1;
} else if (outAnimation == animation) {
Expand All @@ -2548,15 +2548,15 @@ public void onAnimationRepeat(Animation animation) {
// Added by AnimationListener interface.
Timber.i("onAnimationRepeat %s",
((animation == inAnimation) ? "in"
: animation == outAnimation ? "out" : "other"));
: ((animation == outAnimation) ? "out" : "other")));
}

@Override
public void onAnimationStart(Animation animation) {
// Added by AnimationListener interface.
Timber.i("onAnimationStart %s",
((animation == inAnimation) ? "in"
: animation == outAnimation ? "out" : "other"));
: ((animation == outAnimation) ? "out" : "other")));
}

/**
Expand Down Expand Up @@ -2895,8 +2895,9 @@ public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
return false;
}

if (Math.abs(e1.getX() - e2.getX()) > xpixellimit && Math.abs(e1.getY() - e2.getY())
< ypixellimit || Math.abs(e1.getX() - e2.getX()) > xpixellimit * 2) {
if ((Math.abs(e1.getX() - e2.getX()) > xpixellimit && Math.abs(e1
.getY() - e2.getY()) < ypixellimit)
|| Math.abs(e1.getX() - e2.getX()) > xpixellimit * 2) {
beenSwiped = true;
if (velocityX > 0) {
if (e1.getX() > e2.getX()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ public void refreshView() {

FormEntryPrompt fp = formController.getQuestionPrompt();
String label = fp.getLongText();
if (!fp.isReadOnly() || label != null && label.length() > 0) {
if (!fp.isReadOnly() || (label != null && label.length() > 0)) {
// show the question if it is an editable field.
// or if it is read-only and the label is not blank.
String answerDisplay = FormEntryPromptUtils.getAnswerText(fp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ protected void onStop() {

public void returnLocation() {
Intent i = new Intent();
if (setClear || readOnly && latLng == null) {
if (setClear || (readOnly && latLng == null)) {
i.putExtra(FormEntryActivity.LOCATION_RESULT, "");
setResult(RESULT_OK, i);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ public void run() {
*/
public void returnLocation() {
Intent i = new Intent();
if (setClear || readOnly && latLng == null) {
if (setClear || (readOnly && latLng == null)) {
i.putExtra(FormEntryActivity.LOCATION_RESULT, "");
setResult(RESULT_OK, i);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ private boolean isDeviceOnline() {
ConnectivityManager connMgr =
(ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
return networkInfo != null && networkInfo.isConnected();
return (networkInfo != null && networkInfo.isConnected());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ private boolean isDeviceOnline() {
ConnectivityManager connMgr =
(ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
return networkInfo != null && networkInfo.isConnected();
return (networkInfo != null && networkInfo.isConnected());
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ private boolean upgradeToVersion4(SQLiteDatabase db, int oldVersion) {
+ FormsProviderAPI.FormsColumns.JR_VERSION
+ ", "
+ ((oldVersion != 3) ? ""
: FormsProviderAPI.FormsColumns.BASE64_RSA_PUBLIC_KEY + ", ")
: (FormsProviderAPI.FormsColumns.BASE64_RSA_PUBLIC_KEY + ", "))
+ FormsProviderAPI.FormsColumns.JRCACHE_FILE_PATH
+ ") SELECT "
+ FormsProviderAPI.FormsColumns._ID
Expand Down Expand Up @@ -174,7 +174,7 @@ private boolean upgradeToVersion4(SQLiteDatabase db, int oldVersion) {
+ MODEL_VERSION
+ " AS TEXT) ELSE NULL END, "
+ ((oldVersion != 3) ? ""
: FormsProviderAPI.FormsColumns.BASE64_RSA_PUBLIC_KEY + ", ")
: (FormsProviderAPI.FormsColumns.BASE64_RSA_PUBLIC_KEY + ", "))
+ FormsProviderAPI.FormsColumns.JRCACHE_FILE_PATH + " FROM "
+ FORMS_TABLE_NAME);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public boolean realTime() {

@Override
public Object eval(Object[] args, EvaluationContext ec) {
if (args == null || args.length != 1 && args.length != 4 && args.length != 6) {
if (args == null || (args.length != 1 && args.length != 4 && args.length != 6)) {
// we should never get here since it is already handled in ExternalDataUtil
// .getSearchXPathExpression(String appearance)
throw new ExternalDataException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,8 +477,8 @@ private void setUpCameraOutputs(int width, int height) {

int[] afAvailableModes = characteristics.get(CameraCharacteristics.CONTROL_AF_AVAILABLE_MODES);

autoFocusSupported = !(afAvailableModes.length == 0 || afAvailableModes.length == 1
&& afAvailableModes[0] == CameraMetadata.CONTROL_AF_MODE_OFF);
autoFocusSupported = !(afAvailableModes.length == 0 || (afAvailableModes.length == 1
&& afAvailableModes[0] == CameraMetadata.CONTROL_AF_MODE_OFF));

StreamConfigurationMap map = characteristics.get(
CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ private boolean groupIsFieldList(FormIndex index) {
}

GroupDef gd = (GroupDef) element; // exceptions?
return ODKView.FIELD_LIST.equalsIgnoreCase(gd.getAppearanceAttr());
return (ODKView.FIELD_LIST.equalsIgnoreCase(gd.getAppearanceAttr()));
}

private boolean repeatIsFieldList(FormIndex index) {
Expand All @@ -376,7 +376,7 @@ private boolean repeatIsFieldList(FormIndex index) {
}

GroupDef gd = (GroupDef) element; // exceptions?
return ODKView.FIELD_LIST.equalsIgnoreCase(gd.getAppearanceAttr());
return (ODKView.FIELD_LIST.equalsIgnoreCase(gd.getAppearanceAttr()));
}

/**
Expand Down Expand Up @@ -419,10 +419,10 @@ public boolean indexIsInFieldList() {
}

public boolean currentPromptIsQuestion() {
return getEvent() == FormEntryController.EVENT_QUESTION
|| (getEvent() == FormEntryController.EVENT_GROUP
return (getEvent() == FormEntryController.EVENT_QUESTION
|| ((getEvent() == FormEntryController.EVENT_GROUP
|| getEvent() == FormEntryController.EVENT_REPEAT)
&& indexIsInFieldList();
&& indexIsInFieldList()));
}

/**
Expand Down Expand Up @@ -538,10 +538,10 @@ public int stepToPreviousScreenEvent() throws JavaRosaException {

while (event == FormEntryController.EVENT_REPEAT_JUNCTURE
|| event == FormEntryController.EVENT_PROMPT_NEW_REPEAT
|| event == FormEntryController.EVENT_QUESTION && indexIsInFieldList()
|| (event == FormEntryController.EVENT_GROUP
|| (event == FormEntryController.EVENT_QUESTION && indexIsInFieldList())
|| ((event == FormEntryController.EVENT_GROUP
|| event == FormEntryController.EVENT_REPEAT)
&& !indexIsInFieldList()) {
&& !indexIsInFieldList())) {
event = stepToPreviousEvent();
}

Expand Down Expand Up @@ -1066,7 +1066,7 @@ private IDataReference getSubmissionDataReference() {
*/
public boolean isSubmissionEntireForm() {
IDataReference sub = getSubmissionDataReference();
return getInstance().resolveReference(sub) == null;
return (getInstance().resolveReference(sub) == null);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private IdAndPrefix findDeviceId(Context context, TelephonyManager telephonyMana
String scheme = null;

if (deviceId != null) {
if (deviceId.contains("*") || deviceId.contains("000000000000000")) {
if ((deviceId.contains("*") || deviceId.contains("000000000000000"))) {
deviceId = Settings.Secure.getString(context.getContentResolver(), androidIdName);
scheme = androidIdName;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class ControlCharacterFilter implements InputFilter {
public CharSequence filter(CharSequence source, int start, int end,
Spanned dest, int dstart, int dend) {
for (int i = start; i < end; i++) {
if (Character.getType(source.charAt(i)) == Character.CONTROL) {
if (Character.getType((source.charAt(i))) == Character.CONTROL) {
return "";
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public int delete(@NonNull Uri uri, String where, String[] whereArgs) {
del.getColumnIndex(InstanceColumns.INSTANCE_FILE_PATH));
Collect.getInstance().getActivityLogger().logAction(this, "delete",
instanceFile);
File instanceDir = new File(instanceFile).getParentFile();
File instanceDir = (new File(instanceFile)).getParentFile();
deleteAllFilesInDirectory(instanceDir);
} while (del.moveToNext());
}
Expand All @@ -261,7 +261,7 @@ public int delete(@NonNull Uri uri, String where, String[] whereArgs) {
c.getColumnIndex(InstanceColumns.INSTANCE_FILE_PATH));
Collect.getInstance().getActivityLogger().logAction(this, "delete",
instanceFile);
File instanceDir = new File(instanceFile).getParentFile();
File instanceDir = (new File(instanceFile)).getParentFile();
deleteAllFilesInDirectory(instanceDir);
} while (c.moveToNext());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ private boolean isFormAutoSendOptionEnabled(NetworkInfo currentNetworkInfo) {
sendnetwork = true;
}

return currentNetworkInfo.getType() == ConnectivityManager.TYPE_WIFI
return (currentNetworkInfo.getType() == ConnectivityManager.TYPE_WIFI
&& sendwifi || currentNetworkInfo.getType() == ConnectivityManager.TYPE_MOBILE
&& sendnetwork;
&& sendnetwork);
}

private void uploadForms(Context context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public LatLngBounds getBounds() {
}

public boolean isZoomLevelAvailable(int zoom) {
return zoom >= this.minimumZoom && zoom <= this.maximumZoom;
return (zoom >= this.minimumZoom) && (zoom <= this.maximumZoom);
}

// ------------------------------------------------------------------------
Expand Down Expand Up @@ -181,7 +181,7 @@ private void calculateBounds() {
}

private boolean isDatabaseAvailable() {
return this.database != null && this.database.isOpen();
return (this.database != null) && (this.database.isOpen());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ private File[] getFileFromSelectedItem(int item) {
return directory.listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String filename) {
return filename.toLowerCase(Locale.US).endsWith(".mbtiles");
return (filename.toLowerCase(Locale.US).endsWith(".mbtiles"));
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ private boolean isAlreadyDefined(File formDefFile) {
Cursor c = null;
try {
c = formsDao.getFormsCursorForFormFilePath(formDefFile.getAbsolutePath());
return c.getCount() > 0;
return (c.getCount() > 0);
} finally {
if (c != null) {
c.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ protected FECWrapper doInBackground(String... path) {
if (instancePath != null) {
File instance = new File(instancePath);
File shadowInstance = SaveToDiskTask.savepointFile(instance);
if (shadowInstance.exists() && shadowInstance.lastModified()
> instance.lastModified()) {
if (shadowInstance.exists() && (shadowInstance.lastModified()
> instance.lastModified())) {
// the savepoint is newer than the saved value of the instance.
// use it.
usedSavepoint = true;
Expand Down Expand Up @@ -550,7 +550,7 @@ public ExternalDataManager getExternalDataManager() {
}

public boolean hasUsedSavepoint() {
return data != null && data.hasUsedSavepoint();
return (data != null) && data.hasUsedSavepoint();
}

public void destroy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,8 @@ private boolean uploadOneSubmission(String urlString, String id, String instance

// we've added at least one attachment to the request...
if (j + 1 < files.size()) {
if (j - lastJ + 1 > 100 || byteCount + files.get(j + 1).length() > 10000000L) {
if ((j - lastJ + 1 > 100) || (byteCount + files.get(j + 1).length()
> 10000000L)) {
// the next file would exceed the 10MB threshold...
Timber.i("Extremely long post is being split into multiple posts");
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public static final class EncryptedFormInformation {
byte[] messageDigest = md.digest();
ivSeedArray = new byte[IV_BYTE_LENGTH];
for (int i = 0; i < IV_BYTE_LENGTH; ++i) {
ivSeedArray[i] = messageDigest[i % messageDigest.length];
ivSeedArray[i] = messageDigest[(i % messageDigest.length)];
}
} catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
Timber.e(e, "Unable to set md5 hash for instanceid and symmetric key.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ public static HashMap<String, String> parseXML(File xmlFile) {
String base64RsaPublicKey = submission.getAttributeValue(null,
"base64RsaPublicKey");
fields.put(BASE64_RSA_PUBLIC_KEY,
base64RsaPublicKey == null || base64RsaPublicKey.trim().length() == 0
(base64RsaPublicKey == null || base64RsaPublicKey.trim().length() == 0)
? null : base64RsaPublicKey.trim());
} catch (Exception e) {
Timber.i("XML file %s does not have a submission element", xmlFile.getAbsolutePath());
Expand Down
Loading

0 comments on commit cddd425

Please sign in to comment.