diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
index 5bec54801..d906e2642 100644
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -2,14 +2,22 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/scopes/Astrid.xml b/.idea/scopes/Astrid.xml
index d6058e323..cf1e37295 100644
--- a/.idea/scopes/Astrid.xml
+++ b/.idea/scopes/Astrid.xml
@@ -1,3 +1,3 @@
-
+
\ No newline at end of file
diff --git a/api/src/com/todoroo/andlib/data/AbstractDatabase.java b/api/src/com/todoroo/andlib/data/AbstractDatabase.java
index 2ff93f9d7..d20f7a799 100644
--- a/api/src/com/todoroo/andlib/data/AbstractDatabase.java
+++ b/api/src/com/todoroo/andlib/data/AbstractDatabase.java
@@ -127,8 +127,9 @@ abstract public class AbstractDatabase {
*/
public final Table getTable(Class extends AbstractModel> modelType) {
for (Table table : getTables()) {
- if (table.modelClass.equals(modelType))
+ if (table.modelClass.equals(modelType)) {
return table;
+ }
}
throw new UnsupportedOperationException("Unknown model class " + modelType); //$NON-NLS-1$
}
@@ -151,8 +152,9 @@ abstract public class AbstractDatabase {
protected synchronized final void initializeHelper() {
if (helper == null) {
- if (ContextManager.getContext() == null)
+ if (ContextManager.getContext() == null) {
throw new NullPointerException("Null context creating database helper");
+ }
helper = new DatabaseHelper(ContextManager.getContext(),
getName(), null, getVersion());
}
@@ -165,8 +167,9 @@ abstract public class AbstractDatabase {
public synchronized final void openForWriting() {
initializeHelper();
- if (database != null && !database.isReadOnly() && database.isOpen())
+ if (database != null && !database.isReadOnly() && database.isOpen()) {
return;
+ }
try {
database = helper.getWritableDatabase();
@@ -193,8 +196,9 @@ abstract public class AbstractDatabase {
*/
public synchronized final void openForReading() {
initializeHelper();
- if (database != null && database.isOpen())
+ if (database != null && database.isOpen()) {
return;
+ }
database = helper.getReadableDatabase();
}
@@ -305,8 +309,9 @@ abstract public class AbstractDatabase {
sql.append("CREATE TABLE IF NOT EXISTS ").append(table.name).append('(').
append(AbstractModel.ID_PROPERTY).append(" INTEGER PRIMARY KEY AUTOINCREMENT");
for (Property> property : table.getProperties()) {
- if (AbstractModel.ID_PROPERTY.name.equals(property.name))
+ if (AbstractModel.ID_PROPERTY.name.equals(property.name)) {
continue;
+ }
sql.append(',').append(property.accept(sqlVisitor, null));
}
sql.append(')');
diff --git a/api/src/com/todoroo/andlib/data/AbstractModel.java b/api/src/com/todoroo/andlib/data/AbstractModel.java
index 1bfa6bccc..8775e7551 100644
--- a/api/src/com/todoroo/andlib/data/AbstractModel.java
+++ b/api/src/com/todoroo/andlib/data/AbstractModel.java
@@ -113,12 +113,15 @@ public abstract class AbstractModel implements Parcelable, Cloneable {
ContentValues mergedValues = new ContentValues();
ContentValues defaultValues = getDefaultValues();
- if (defaultValues != null)
+ if (defaultValues != null) {
mergedValues.putAll(defaultValues);
- if (values != null)
+ }
+ if (values != null) {
mergedValues.putAll(values);
- if (setValues != null)
+ }
+ if (setValues != null) {
mergedValues.putAll(setValues);
+ }
return mergedValues;
}
@@ -136,10 +139,11 @@ public abstract class AbstractModel implements Parcelable, Cloneable {
* saved - future saves will not need to write all the data as before.
*/
public void markSaved() {
- if (values == null)
+ if (values == null) {
values = setValues;
- else if (setValues != null)
+ } else if (setValues != null) {
values.putAll(setValues);
+ }
setValues = null;
}
@@ -149,8 +153,9 @@ public abstract class AbstractModel implements Parcelable, Cloneable {
*/
@Override
public boolean equals(Object other) {
- if (other == null || other.getClass() != getClass())
+ if (other == null || other.getClass() != getClass()) {
return false;
+ }
return getMergedValues().equals(((AbstractModel) other).getMergedValues());
}
@@ -180,10 +185,12 @@ public abstract class AbstractModel implements Parcelable, Cloneable {
} catch (CloneNotSupportedException e) {
throw new RuntimeException(e);
}
- if (setValues != null)
+ if (setValues != null) {
clone.setValues = new ContentValues(setValues);
- if (values != null)
+ }
+ if (values != null) {
clone.values = new ContentValues(values);
+ }
return clone;
}
@@ -200,8 +207,9 @@ public abstract class AbstractModel implements Parcelable, Cloneable {
* Reads all properties from the supplied cursor and store
*/
public synchronized void readPropertiesFromCursor(TodorooCursor extends AbstractModel> cursor) {
- if (values == null)
+ if (values == null) {
values = new ContentValues();
+ }
// clears user-set values
setValues = null;
@@ -221,29 +229,28 @@ public abstract class AbstractModel implements Parcelable, Cloneable {
*/
public synchronized TYPE getValue(Property property) {
Object value;
- if (setValues != null && setValues.containsKey(property.getColumnName()))
+ if (setValues != null && setValues.containsKey(property.getColumnName())) {
value = setValues.get(property.getColumnName());
-
- else if (values != null && values.containsKey(property.getColumnName()))
+ } else if (values != null && values.containsKey(property.getColumnName())) {
value = values.get(property.getColumnName());
-
- else if (getDefaultValues().containsKey(property.getColumnName()))
+ } else if (getDefaultValues().containsKey(property.getColumnName())) {
value = getDefaultValues().get(property.getColumnName());
-
- else
+ } else {
throw new UnsupportedOperationException(
"Model Error: Did not read property " + property.name); //$NON-NLS-1$
+ }
// resolve properties that were retrieved with a different type than accessed
try {
- if (value instanceof String && property instanceof LongProperty)
+ if (value instanceof String && property instanceof LongProperty) {
return (TYPE) Long.valueOf((String) value);
- else if (value instanceof String && property instanceof IntegerProperty)
+ } else if (value instanceof String && property instanceof IntegerProperty) {
return (TYPE) Integer.valueOf((String) value);
- else if (value instanceof String && property instanceof DoubleProperty)
+ } else if (value instanceof String && property instanceof DoubleProperty) {
return (TYPE) Double.valueOf((String) value);
- else if (value instanceof Integer && property instanceof LongProperty)
+ } else if (value instanceof Integer && property instanceof LongProperty) {
return (TYPE) Long.valueOf(((Number) value).longValue());
+ }
return (TYPE) value;
} catch (NumberFormatException e) {
return (TYPE) getDefaultValues().get(property.name);
@@ -258,22 +265,25 @@ public abstract class AbstractModel implements Parcelable, Cloneable {
abstract public long getId();
protected long getIdHelper(LongProperty id) {
- if (setValues != null && setValues.containsKey(id.name))
+ if (setValues != null && setValues.containsKey(id.name)) {
return setValues.getAsLong(id.name);
- else if (values != null && values.containsKey(id.name))
+ } else if (values != null && values.containsKey(id.name)) {
return values.getAsLong(id.name);
- else
+ } else {
return NO_ID;
+ }
}
public void setId(long id) {
- if (setValues == null)
+ if (setValues == null) {
setValues = new ContentValues();
+ }
- if (id == NO_ID)
+ if (id == NO_ID) {
clearValue(ID_PROPERTY);
- else
+ } else {
setValues.put(ID_PROPERTY_NAME, id);
+ }
}
/**
@@ -288,10 +298,12 @@ public abstract class AbstractModel implements Parcelable, Cloneable {
* @return true if setValues or values contains this property
*/
public boolean containsValue(Property> property) {
- if (setValues != null && setValues.containsKey(property.getColumnName()))
+ if (setValues != null && setValues.containsKey(property.getColumnName())) {
return true;
- if (values != null && values.containsKey(property.getColumnName()))
+ }
+ if (values != null && values.containsKey(property.getColumnName())) {
return true;
+ }
return false;
}
@@ -301,10 +313,12 @@ public abstract class AbstractModel implements Parcelable, Cloneable {
* stored is not null
*/
public boolean containsNonNullValue(Property> property) {
- if (setValues != null && setValues.containsKey(property.getColumnName()))
+ if (setValues != null && setValues.containsKey(property.getColumnName())) {
return setValues.get(property.getColumnName()) != null;
- if (values != null && values.containsKey(property.getColumnName()))
+ }
+ if (values != null && values.containsKey(property.getColumnName())) {
return values.get(property.getColumnName()) != null;
+ }
return false;
}
@@ -318,17 +332,20 @@ public abstract class AbstractModel implements Parcelable, Cloneable {
Property property, TYPE newValue) {
// we've already decided to save it, so overwrite old value
- if (setValues.containsKey(property.getColumnName()))
+ if (setValues.containsKey(property.getColumnName())) {
return true;
+ }
// values contains this key, we should check it out
if (values != null && values.containsKey(property.getColumnName())) {
TYPE value = getValue(property);
if (value == null) {
- if (newValue == null)
+ if (newValue == null) {
return false;
- } else if (value.equals(newValue))
+ }
+ } else if (value.equals(newValue)) {
return false;
+ }
}
// otherwise, good to save
@@ -340,10 +357,12 @@ public abstract class AbstractModel implements Parcelable, Cloneable {
*/
public synchronized void setValue(Property property,
TYPE value) {
- if (setValues == null)
+ if (setValues == null) {
setValues = new ContentValues();
- if (!shouldSaveValue(property, value))
+ }
+ if (!shouldSaveValue(property, value)) {
return;
+ }
saver.save(property, setValues, value);
}
@@ -352,8 +371,9 @@ public abstract class AbstractModel implements Parcelable, Cloneable {
* Merges content values with those coming from another source
*/
public synchronized void mergeWith(ContentValues other) {
- if (setValues == null)
+ if (setValues == null) {
setValues = new ContentValues();
+ }
setValues.putAll(other);
}
@@ -362,11 +382,13 @@ public abstract class AbstractModel implements Parcelable, Cloneable {
* keeping the existing value if one already exists
*/
public synchronized void mergeWithoutReplacement(ContentValues other) {
- if (setValues == null)
+ if (setValues == null) {
setValues = new ContentValues();
+ }
for (Entry item : other.valueSet()) {
- if (setValues.containsKey(item.getKey()))
+ if (setValues.containsKey(item.getKey())) {
continue;
+ }
AndroidUtilities.putInto(setValues, item.getKey(), item.getValue(), true);
}
}
@@ -377,10 +399,12 @@ public abstract class AbstractModel implements Parcelable, Cloneable {
* @param property
*/
public synchronized void clearValue(Property> property) {
- if (setValues != null && setValues.containsKey(property.getColumnName()))
+ if (setValues != null && setValues.containsKey(property.getColumnName())) {
setValues.remove(property.getColumnName());
- if (values != null && values.containsKey(property.getColumnName()))
+ }
+ if (values != null && values.containsKey(property.getColumnName())) {
values.remove(property.getColumnName());
+ }
}
/**
@@ -391,10 +415,11 @@ public abstract class AbstractModel implements Parcelable, Cloneable {
* @param value
*/
public void setFlag(IntegerProperty property, int flag, boolean value) {
- if (value)
+ if (value) {
setValue(property, getValue(property) | flag);
- else
+ } else {
setValue(property, getValue(property) & ~flag);
+ }
}
/**
@@ -412,26 +437,30 @@ public abstract class AbstractModel implements Parcelable, Cloneable {
// --- setting and retrieving flags
public synchronized void putTransitory(String key, Object value) {
- if (transitoryData == null)
+ if (transitoryData == null) {
transitoryData = new HashMap();
+ }
transitoryData.put(key, value);
}
public Object getTransitory(String key) {
- if (transitoryData == null)
+ if (transitoryData == null) {
return null;
+ }
return transitoryData.get(key);
}
public Object clearTransitory(String key) {
- if (transitoryData == null)
+ if (transitoryData == null) {
return null;
+ }
return transitoryData.remove(key);
}
public Set getAllTransitoryKeys() {
- if (transitoryData == null)
+ if (transitoryData == null) {
return null;
+ }
return transitoryData.keySet();
}
@@ -453,19 +482,23 @@ public abstract class AbstractModel implements Parcelable, Cloneable {
*/
protected static Property>[] generateProperties(Class extends AbstractModel> cls) {
ArrayList> properties = new ArrayList>();
- if (cls.getSuperclass() != AbstractModel.class)
+ if (cls.getSuperclass() != AbstractModel.class) {
properties.addAll(Arrays.asList(generateProperties(
(Class extends AbstractModel>) cls.getSuperclass())));
+ }
// a property is public, static & extends Property
for (Field field : cls.getFields()) {
- if ((field.getModifiers() & Modifier.STATIC) == 0)
+ if ((field.getModifiers() & Modifier.STATIC) == 0) {
continue;
- if (!Property.class.isAssignableFrom(field.getType()))
+ }
+ if (!Property.class.isAssignableFrom(field.getType())) {
continue;
+ }
try {
- if (((Property>) field.get(null)).table == null)
+ if (((Property>) field.get(null)).table == null) {
continue;
+ }
properties.add((Property>) field.get(null));
} catch (IllegalArgumentException e) {
throw new RuntimeException(e);
@@ -492,8 +525,9 @@ public abstract class AbstractModel implements Parcelable, Cloneable {
// we don't allow null values, as they indicate unset properties
// when the database was written
- if (value != null)
+ if (value != null) {
property.accept(this, value);
+ }
}
public Void visitDouble(Property property, Object value) {
diff --git a/api/src/com/todoroo/andlib/data/ContentResolverDao.java b/api/src/com/todoroo/andlib/data/ContentResolverDao.java
index df804bc2a..bbc4bbde8 100644
--- a/api/src/com/todoroo/andlib/data/ContentResolverDao.java
+++ b/api/src/com/todoroo/andlib/data/ContentResolverDao.java
@@ -52,8 +52,9 @@ public class ContentResolverDao {
public ContentResolverDao(Class modelClass, Context context, Uri baseUri) {
DependencyInjectionService.getInstance().inject(this);
this.modelClass = modelClass;
- if (debug == null)
+ if (debug == null) {
debug = false;
+ }
this.baseUri = baseUri;
cr = context.getContentResolver();
@@ -96,8 +97,9 @@ public class ContentResolverDao {
* @return
*/
public TodorooCursor query(Query query) {
- if (debug)
+ if (debug) {
Log.i("SQL-" + modelClass.getSimpleName(), query.toString()); //$NON-NLS-1$
+ }
Cursor cursor = query.queryContentResolver(cr, baseUri);
return new TodorooCursor(cursor, query.getFields());
}
@@ -111,10 +113,12 @@ public class ContentResolverDao {
public boolean save(TYPE model) {
writeTransitoriesToModelContentValues(model);
if (model.isSaved()) {
- if (model.getSetValues() == null)
+ if (model.getSetValues() == null) {
return false;
- if (cr.update(uriWithId(model.getId()), model.getSetValues(), null, null) != 0)
+ }
+ if (cr.update(uriWithId(model.getId()), model.getSetValues(), null, null) != 0) {
return true;
+ }
}
Uri uri = cr.insert(baseUri, model.getMergedValues());
long id = Long.parseLong(uri.getLastPathSegment());
@@ -149,8 +153,9 @@ public class ContentResolverDao {
TodorooCursor cursor = query(
Query.select(properties).where(AbstractModel.ID_PROPERTY.eq(id)));
try {
- if (cursor.getCount() == 0)
+ if (cursor.getCount() == 0) {
return null;
+ }
cursor.moveToFirst();
Constructor constructor = modelClass.getConstructor(TodorooCursor.class);
return constructor.newInstance(cursor);
diff --git a/api/src/com/todoroo/andlib/data/DatabaseDao.java b/api/src/com/todoroo/andlib/data/DatabaseDao.java
index 49a6d93a5..25b252ac3 100644
--- a/api/src/com/todoroo/andlib/data/DatabaseDao.java
+++ b/api/src/com/todoroo/andlib/data/DatabaseDao.java
@@ -52,8 +52,9 @@ public class DatabaseDao {
public DatabaseDao(Class modelClass) {
DependencyInjectionService.getInstance().inject(this);
this.modelClass = modelClass;
- if (debug == null)
+ if (debug == null) {
debug = false;
+ }
}
public DatabaseDao(Class modelClass, AbstractDatabase database) {
@@ -79,8 +80,9 @@ public class DatabaseDao {
* @param database
*/
public void setDatabase(AbstractDatabase database) {
- if (database == this.database)
+ if (database == this.database) {
return;
+ }
this.database = database;
table = database.getTable(modelClass);
outstandingTable = database.getOutstandingTable(modelClass);
@@ -116,8 +118,9 @@ public class DatabaseDao {
*/
public TodorooCursor query(Query query) {
query.from(table);
- if (debug)
+ if (debug) {
Log.i("SQL-" + modelClass.getSimpleName(), query.toString()); //$NON-NLS-1$
+ }
Cursor cursor = database.rawQuery(query.toString(), null);
return new TodorooCursor(cursor, query.getFields());
}
@@ -132,8 +135,9 @@ public class DatabaseDao {
*/
public TodorooCursor rawQuery(String selection, String[] selectionArgs, Property>... properties) {
String[] fields = new String[properties.length];
- for (int i = 0; i < properties.length; i++)
+ for (int i = 0; i < properties.length; i++) {
fields[i] = properties[i].name;
+ }
return new TodorooCursor(database.getDatabase().query(table.name,
fields, selection, selectionArgs, null, null, null),
properties);
@@ -155,8 +159,9 @@ public class DatabaseDao {
protected TYPE returnFetchResult(TodorooCursor cursor) {
try {
- if (cursor.getCount() == 0)
+ if (cursor.getCount() == 0) {
return null;
+ }
Constructor constructor = modelClass.getConstructor(TodorooCursor.class);
return constructor.newInstance(cursor);
} catch (SecurityException e) {
@@ -230,8 +235,9 @@ public class DatabaseDao {
toUpdate.close();
}
- if (toUpdate.getCount() == 0)
+ if (toUpdate.getCount() == 0) {
return 0;
+ }
synchronized (database) {
database.getDatabase().beginTransactionWithListener(new SQLiteTransactionListener() {
@@ -281,7 +287,9 @@ public class DatabaseDao {
ContentValues values = item.getSetValues();
if (values.size() == 0) // nothing changed
+ {
return true;
+ }
return saveExisting(item);
}
@@ -321,11 +329,15 @@ public class DatabaseDao {
result.set(op.makeChange());
if (result.get()) {
if (recordOutstanding && ((numOutstanding = createOutstandingEntries(item.getId(), values)) != -1)) // Create entries for setValues in outstanding table
+ {
database.getDatabase().setTransactionSuccessful();
+ }
}
} finally {
if (recordOutstanding) // commit transaction
+ {
database.getDatabase().endTransaction();
+ }
}
if (result.get()) {
onModelUpdated(item, recordOutstanding && numOutstanding > 0);
@@ -352,8 +364,9 @@ public class DatabaseDao {
long newRow = database.insert(table.name,
AbstractModel.ID_PROPERTY.name, item.getMergedValues());
boolean result = newRow >= 0;
- if (result)
+ if (result) {
item.setId(newRow);
+ }
return result;
}
};
@@ -371,7 +384,9 @@ public class DatabaseDao {
public boolean saveExisting(final TYPE item) {
final ContentValues values = item.getSetValues();
if (values == null || values.size() == 0) // nothing changed
+ {
return true;
+ }
DatabaseChangeOp update = new DatabaseChangeOp() {
@Override
public boolean makeChange() {
diff --git a/api/src/com/todoroo/andlib/data/Property.java b/api/src/com/todoroo/andlib/data/Property.java
index b773b5893..3163b382f 100644
--- a/api/src/com/todoroo/andlib/data/Property.java
+++ b/api/src/com/todoroo/andlib/data/Property.java
@@ -119,13 +119,15 @@ public abstract class Property extends Field implements Cloneable {
*/
public Property cloneAs(String tableAlias, String columnAlias) {
Table aliasedTable = this.table;
- if (!TextUtils.isEmpty(tableAlias))
+ if (!TextUtils.isEmpty(tableAlias)) {
aliasedTable = table.as(tableAlias);
+ }
try {
Property newInstance = this.getClass().getConstructor(Table.class, String.class).newInstance(aliasedTable, this.name);
- if (!TextUtils.isEmpty(columnAlias))
+ if (!TextUtils.isEmpty(columnAlias)) {
return (Property) newInstance.as(columnAlias);
+ }
return newInstance;
} catch (Exception e) {
throw new RuntimeException(e);
@@ -311,8 +313,9 @@ public abstract class Property extends Field implements Cloneable {
}
public String getColumnName() {
- if (hasAlias())
+ if (hasAlias()) {
return alias;
+ }
return name;
}
diff --git a/api/src/com/todoroo/andlib/data/Table.java b/api/src/com/todoroo/andlib/data/Table.java
index 26b9462f5..4defca0bf 100644
--- a/api/src/com/todoroo/andlib/data/Table.java
+++ b/api/src/com/todoroo/andlib/data/Table.java
@@ -67,21 +67,24 @@ public final class Table extends SqlTable {
*/
@SuppressWarnings("nls")
public Field field(Property> property) {
- if (alias != null)
+ if (alias != null) {
return Field.field(alias + "." + property.name);
+ }
return Field.field(name + "." + property.name);
}
@Override
public String toString() {
- if (hasAlias())
+ if (hasAlias()) {
return expression + " AS " + alias; //$NON-NLS-1$
+ }
return expression;
}
public String name() {
- if (hasAlias())
+ if (hasAlias()) {
return alias;
+ }
return name;
}
}
\ No newline at end of file
diff --git a/api/src/com/todoroo/andlib/data/TodorooCursor.java b/api/src/com/todoroo/andlib/data/TodorooCursor.java
index fc720a82e..5edd2159e 100644
--- a/api/src/com/todoroo/andlib/data/TodorooCursor.java
+++ b/api/src/com/todoroo/andlib/data/TodorooCursor.java
@@ -108,31 +108,35 @@ public class TodorooCursor extends CursorWrapper {
public Object visitDouble(Property property,
TodorooCursor> cursor) {
int column = columnIndex(property, cursor);
- if (property.checkFlag(Property.PROP_FLAG_NULLABLE) && cursor.isNull(column))
+ if (property.checkFlag(Property.PROP_FLAG_NULLABLE) && cursor.isNull(column)) {
return null;
+ }
return cursor.getDouble(column);
}
public Object visitInteger(Property property,
TodorooCursor> cursor) {
int column = columnIndex(property, cursor);
- if (property.checkFlag(Property.PROP_FLAG_NULLABLE) && cursor.isNull(column))
+ if (property.checkFlag(Property.PROP_FLAG_NULLABLE) && cursor.isNull(column)) {
return null;
+ }
return cursor.getInt(column);
}
public Object visitLong(Property property, TodorooCursor> cursor) {
int column = columnIndex(property, cursor);
- if (property.checkFlag(Property.PROP_FLAG_NULLABLE) && cursor.isNull(column))
+ if (property.checkFlag(Property.PROP_FLAG_NULLABLE) && cursor.isNull(column)) {
return null;
+ }
return cursor.getLong(column);
}
public Object visitString(Property property,
TodorooCursor> cursor) {
int column = columnIndex(property, cursor);
- if (property.checkFlag(Property.PROP_FLAG_NULLABLE) && cursor.isNull(column))
+ if (property.checkFlag(Property.PROP_FLAG_NULLABLE) && cursor.isNull(column)) {
return null;
+ }
return cursor.getString(column);
}
diff --git a/api/src/com/todoroo/andlib/service/ContextManager.java b/api/src/com/todoroo/andlib/service/ContextManager.java
index f3714157b..49cec9f01 100644
--- a/api/src/com/todoroo/andlib/service/ContextManager.java
+++ b/api/src/com/todoroo/andlib/service/ContextManager.java
@@ -28,10 +28,12 @@ public final class ContextManager {
* @param context
*/
public static void setContext(Context context) {
- if (context == null || context.getApplicationContext() == null)
+ if (context == null || context.getApplicationContext() == null) {
return;
- if (ContextManager.context != null && !(context instanceof Activity))
+ }
+ if (ContextManager.context != null && !(context instanceof Activity)) {
return;
+ }
ContextManager.context = context;
}
diff --git a/api/src/com/todoroo/andlib/service/DependencyInjectionService.java b/api/src/com/todoroo/andlib/service/DependencyInjectionService.java
index 2d726d1b6..6a1747937 100644
--- a/api/src/com/todoroo/andlib/service/DependencyInjectionService.java
+++ b/api/src/com/todoroo/andlib/service/DependencyInjectionService.java
@@ -44,8 +44,9 @@ public class DependencyInjectionService {
Class> cls = caller.getClass();
while (cls != null) {
String packageName = cls.getPackage().getName();
- if (!isQualifiedPackage(packageName))
+ if (!isQualifiedPackage(packageName)) {
break;
+ }
for (Field field : cls.getDeclaredFields()) {
if (field.getAnnotation(Autowired.class) != null) {
@@ -71,12 +72,15 @@ public class DependencyInjectionService {
@SuppressWarnings("nls")
private boolean isQualifiedPackage(String packageName) {
- if (packageName.startsWith("com.todoroo"))
+ if (packageName.startsWith("com.todoroo")) {
return true;
- if (packageName.startsWith("com.timsu"))
+ }
+ if (packageName.startsWith("com.timsu")) {
return true;
- if (packageName.startsWith("org.weloveastrid"))
+ }
+ if (packageName.startsWith("org.weloveastrid")) {
return true;
+ }
return false;
}
@@ -92,10 +96,11 @@ public class DependencyInjectionService {
throws IllegalStateException, IllegalArgumentException,
IllegalAccessException {
- if (field.getType().isPrimitive())
+ if (field.getType().isPrimitive()) {
throw new IllegalStateException(String.format(
"Tried to dependency-inject primative field '%s' of type '%s'",
field.getName(), field.getType()));
+ }
// field has already been processed, ignore
if (field.get(caller) != null) {
@@ -146,8 +151,9 @@ public class DependencyInjectionService {
* @return
*/
public synchronized static DependencyInjectionService getInstance() {
- if (instance == null)
+ if (instance == null) {
instance = new DependencyInjectionService();
+ }
return instance;
}
diff --git a/api/src/com/todoroo/andlib/service/ExceptionService.java b/api/src/com/todoroo/andlib/service/ExceptionService.java
index b022f2f23..e5aa065e0 100644
--- a/api/src/com/todoroo/andlib/service/ExceptionService.java
+++ b/api/src/com/todoroo/andlib/service/ExceptionService.java
@@ -42,8 +42,9 @@ public class ExceptionService {
* @param error Exception encountered. Message will be displayed to user
*/
public void reportError(String name, Throwable error) {
- if (errorReporters == null)
+ if (errorReporters == null) {
return;
+ }
for (ErrorReporter reporter : errorReporters) {
try {
@@ -66,10 +67,11 @@ public class ExceptionService {
final String messageToDisplay;
// pretty up the message when displaying to user
- if (error == null)
+ if (error == null) {
messageToDisplay = context.getString(R.string.DLG_error_generic);
- else
+ } else {
messageToDisplay = context.getString(R.string.DLG_error, error);
+ }
((Activity) context).runOnUiThread(new Runnable() {
public void run() {
@@ -125,13 +127,15 @@ public class ExceptionService {
}
}
- if (tag == null)
+ if (tag == null) {
tag = "unknown-" + name; //$NON-NLS-1$
+ }
- if (error == null)
+ if (error == null) {
Log.e(tag, "Exception: " + name); //$NON-NLS-1$
- else
+ } else {
Log.e(tag, error.toString(), error);
+ }
}
}
@@ -153,8 +157,9 @@ public class ExceptionService {
}
public void uncaughtException(Thread thread, Throwable ex) {
- if (exceptionService != null)
+ if (exceptionService != null) {
exceptionService.reportError("uncaught", ex); //$NON-NLS-1$
+ }
defaultUEH.uncaughtException(thread, ex);
}
}
diff --git a/api/src/com/todoroo/andlib/service/HttpRestClient.java b/api/src/com/todoroo/andlib/service/HttpRestClient.java
index bcdf25584..3fde17306 100644
--- a/api/src/com/todoroo/andlib/service/HttpRestClient.java
+++ b/api/src/com/todoroo/andlib/service/HttpRestClient.java
@@ -106,8 +106,9 @@ public class HttpRestClient implements RestClient {
public void process(
final HttpRequest request,
final HttpContext context) throws HttpException, IOException {
- if (!request.containsHeader("Accept-Encoding"))
+ if (!request.containsHeader("Accept-Encoding")) {
request.addHeader("Accept-Encoding", "gzip");
+ }
}
});
@@ -191,8 +192,9 @@ public class HttpRestClient implements RestClient {
* @throws IOException
*/
public synchronized String get(String url) throws IOException {
- if (debug)
+ if (debug) {
Log.d("http-rest-client-get", url); //$NON-NLS-1$
+ }
try {
HttpGet httpGet = new HttpGet(url);
@@ -216,14 +218,16 @@ public class HttpRestClient implements RestClient {
* @throws IOException
*/
public synchronized String post(String url, HttpEntity data, Header... headers) throws IOException {
- if (debug)
+ if (debug) {
Log.d("http-rest-client-post", url + " | " + data); //$NON-NLS-1$ //$NON-NLS-2$
+ }
try {
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(data);
- for (Header header : headers)
+ for (Header header : headers) {
httpPost.addHeader(header);
+ }
HttpResponse response = getClient().execute(httpPost);
return processHttpResponse(response);
diff --git a/api/src/com/todoroo/andlib/sql/DBObject.java b/api/src/com/todoroo/andlib/sql/DBObject.java
index f95851003..99b0cefd8 100644
--- a/api/src/com/todoroo/andlib/sql/DBObject.java
+++ b/api/src/com/todoroo/andlib/sql/DBObject.java
@@ -32,14 +32,21 @@ public abstract class DBObject> implements Cloneable {
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
DBObject> dbObject = (DBObject>) o;
- if (alias != null ? !alias.equals(dbObject.alias) : dbObject.alias != null) return false;
- if (expression != null ? !expression.equals(dbObject.expression) : dbObject.expression != null)
+ if (alias != null ? !alias.equals(dbObject.alias) : dbObject.alias != null) {
return false;
+ }
+ if (expression != null ? !expression.equals(dbObject.expression) : dbObject.expression != null) {
+ return false;
+ }
return true;
}
@@ -65,8 +72,9 @@ public abstract class DBObject> implements Cloneable {
sb.append(SPACE).append(AS).append(SPACE).append(alias);
} else {
int pos = expression.indexOf('.');
- if (pos > 0)
+ if (pos > 0) {
sb.append(SPACE).append(AS).append(SPACE).append(expression.substring(pos + 1));
+ }
}
return sb.toString();
}
diff --git a/api/src/com/todoroo/andlib/sql/Field.java b/api/src/com/todoroo/andlib/sql/Field.java
index 6cfe2048e..4b722ff37 100644
--- a/api/src/com/todoroo/andlib/sql/Field.java
+++ b/api/src/com/todoroo/andlib/sql/Field.java
@@ -23,8 +23,9 @@ public class Field extends DBObject {
}
public Criterion eq(Object value) {
- if (value == null)
+ if (value == null) {
return UnaryCriterion.isNull(this);
+ }
return UnaryCriterion.eq(this, value);
}
@@ -38,15 +39,17 @@ public class Field extends DBObject {
*/
@SuppressWarnings("nls")
public Criterion eqCaseInsensitive(String value) {
- if (value == null)
+ if (value == null) {
return UnaryCriterion.isNull(this);
+ }
String escaped = value.replace("\\", "\\\\").replace("%", "\\%").replace("_", "\\_");
return UnaryCriterion.like(this, escaped, "\\");
}
public Criterion neq(Object value) {
- if (value == null)
+ if (value == null) {
return UnaryCriterion.isNotNull(this);
+ }
return UnaryCriterion.neq(this, value);
}
diff --git a/api/src/com/todoroo/andlib/sql/Join.java b/api/src/com/todoroo/andlib/sql/Join.java
index d532b8c43..b318bb005 100644
--- a/api/src/com/todoroo/andlib/sql/Join.java
+++ b/api/src/com/todoroo/andlib/sql/Join.java
@@ -44,8 +44,9 @@ public class Join {
sb.append(joinType).append(SPACE).append(JOIN).append(SPACE).append(joinTable).append(SPACE).append(ON).append(SPACE).append("(");
for (int i = 0; i < criterions.length; i++) {
sb.append(criterions[i]);
- if (i < criterions.length - 1)
+ if (i < criterions.length - 1) {
sb.append(SPACE).append(AND).append(SPACE);
+ }
}
sb.append(")");
return sb.toString();
diff --git a/api/src/com/todoroo/andlib/sql/Order.java b/api/src/com/todoroo/andlib/sql/Order.java
index 9630ac8a1..b441f29b6 100644
--- a/api/src/com/todoroo/andlib/sql/Order.java
+++ b/api/src/com/todoroo/andlib/sql/Order.java
@@ -56,9 +56,10 @@ public class Order {
}
public Order reverse() {
- if (orderType == OrderType.ASC)
+ if (orderType == OrderType.ASC) {
return new Order(expression, OrderType.DESC);
- else
+ } else {
return new Order(expression, OrderType.ASC);
+ }
}
}
diff --git a/api/src/com/todoroo/andlib/sql/Query.java b/api/src/com/todoroo/andlib/sql/Query.java
index 77694d297..555ff7e20 100644
--- a/api/src/com/todoroo/andlib/sql/Query.java
+++ b/api/src/com/todoroo/andlib/sql/Query.java
@@ -125,8 +125,9 @@ public final class Query {
visitLimitClause(sql);
} else {
if (groupBies.size() > 0 || orders.size() > 0 ||
- havings.size() > 0)
+ havings.size() > 0) {
throw new IllegalStateException("Can't have extras AND query template"); //$NON-NLS-1$
+ }
sql.append(queryTemplate);
}
@@ -198,8 +199,9 @@ public final class Query {
private void visitSelectClause(StringBuilder sql) {
sql.append(SELECT).append(SPACE);
- if (distinct)
+ if (distinct) {
sql.append(DISTINCT).append(SPACE);
+ }
if (fields.isEmpty()) {
sql.append(ALL).append(SPACE);
return;
@@ -211,8 +213,9 @@ public final class Query {
}
private void visitLimitClause(StringBuilder sql) {
- if (limits > -1)
+ if (limits > -1) {
sql.append(LIMIT).append(SPACE).append(limits).append(SPACE);
+ }
}
public SqlTable as(String alias) {
@@ -254,12 +257,14 @@ public final class Query {
public Cursor queryContentResolver(ContentResolver cr, Uri baseUri) {
Uri uri = baseUri;
- if (joins.size() != 0)
+ if (joins.size() != 0) {
throw new UnsupportedOperationException("can't perform join in content resolver query"); //$NON-NLS-1$
+ }
String[] projection = new String[fields.size()];
- for (int i = 0; i < projection.length; i++)
+ for (int i = 0; i < projection.length; i++) {
projection[i] = fields.get(i).toString();
+ }
StringBuilder groupByClause = new StringBuilder();
StringBuilder selectionClause = new StringBuilder();
@@ -269,24 +274,30 @@ public final class Query {
selectionClause, orderClause, groupByClause);
} else {
if (groupBies.size() > 0) {
- for (Field groupBy : groupBies)
+ for (Field groupBy : groupBies) {
groupByClause.append(SPACE).append(groupBy).append(COMMA);
- if (groupByClause.length() > 0)
+ }
+ if (groupByClause.length() > 0) {
groupByClause.deleteCharAt(groupByClause.length() - 1);
+ }
}
- for (Criterion criterion : criterions)
+ for (Criterion criterion : criterions) {
selectionClause.append(criterion).append(SPACE);
+ }
- for (Order order : orders)
+ for (Order order : orders) {
orderClause.append(SPACE).append(order).append(COMMA);
- if (orderClause.length() > 0)
+ }
+ if (orderClause.length() > 0) {
orderClause.deleteCharAt(orderClause.length() - 1);
+ }
}
- if (groupByClause.length() > 0)
+ if (groupByClause.length() > 0) {
uri = Uri.withAppendedPath(baseUri, AstridApiConstants.GROUP_BY_URI +
groupByClause.toString().trim());
+ }
return cr.query(uri, projection, selectionClause.toString(), null,
orderClause.toString());
}
@@ -306,18 +317,21 @@ public final class Query {
Pattern where = Pattern.compile("WHERE (.*?)(LIMIT|HAVING|GROUP|ORDER|\\Z)");
Matcher whereMatcher = where.matcher(queryTemplate);
- if (whereMatcher.find())
+ if (whereMatcher.find()) {
selectionClause.append(whereMatcher.group(1).trim());
+ }
Pattern group = Pattern.compile("GROUP BY (.*?)(LIMIT|HAVING|ORDER|\\Z)");
Matcher groupMatcher = group.matcher(queryTemplate);
- if (groupMatcher.find())
+ if (groupMatcher.find()) {
groupByClause.append(groupMatcher.group(1).trim());
+ }
Pattern order = Pattern.compile("ORDER BY (.*?)(LIMIT|HAVING|\\Z)");
Matcher orderMatcher = order.matcher(queryTemplate);
- if (orderMatcher.find())
+ if (orderMatcher.find()) {
orderClause.append(orderMatcher.group(1).trim());
+ }
}
}
diff --git a/api/src/com/todoroo/andlib/sql/QueryTemplate.java b/api/src/com/todoroo/andlib/sql/QueryTemplate.java
index 7abd50e42..cd34a2cb6 100644
--- a/api/src/com/todoroo/andlib/sql/QueryTemplate.java
+++ b/api/src/com/todoroo/andlib/sql/QueryTemplate.java
@@ -57,8 +57,9 @@ public final class QueryTemplate {
visitWhereClause(sql);
visitGroupByClause(sql);
visitOrderByClause(sql);
- if (limit != null)
+ if (limit != null) {
sql.append(LIMIT).append(SPACE).append(limit);
+ }
return sql.toString();
}
diff --git a/api/src/com/todoroo/andlib/sql/UnaryCriterion.java b/api/src/com/todoroo/andlib/sql/UnaryCriterion.java
index ff48d58c2..d0b6b5a9f 100644
--- a/api/src/com/todoroo/andlib/sql/UnaryCriterion.java
+++ b/api/src/com/todoroo/andlib/sql/UnaryCriterion.java
@@ -38,12 +38,13 @@ public class UnaryCriterion extends Criterion {
@SuppressWarnings("nls")
protected void afterPopulateOperator(StringBuilder sb) {
- if (value == null)
+ if (value == null) {
return;
- else if (value instanceof String)
+ } else if (value instanceof String) {
sb.append("'").append(sanitize((String) value)).append("'");
- else
+ } else {
sb.append(value);
+ }
}
/**
diff --git a/api/src/com/todoroo/andlib/utility/AndroidUtilities.java b/api/src/com/todoroo/andlib/utility/AndroidUtilities.java
index 9274c0626..f18c58f99 100644
--- a/api/src/com/todoroo/andlib/utility/AndroidUtilities.java
+++ b/api/src/com/todoroo/andlib/utility/AndroidUtilities.java
@@ -94,10 +94,12 @@ public class AndroidUtilities {
ConnectivityManager manager = (ConnectivityManager)
context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = manager.getActiveNetworkInfo();
- if (info == null)
+ if (info == null) {
return false;
- if (info.getState() != State.CONNECTED)
+ }
+ if (info.getState() != State.CONNECTED) {
return false;
+ }
return true;
}
@@ -118,8 +120,9 @@ public class AndroidUtilities {
bis.close();
}
} finally {
- if (is != null)
+ if (is != null) {
is.close();
+ }
}
}
@@ -157,10 +160,11 @@ public class AndroidUtilities {
*/
public static void startExternalIntent(Context context, Intent intent, int request) {
try {
- if (request > -1 && context instanceof Activity)
+ if (request > -1 && context instanceof Activity) {
((Activity) context).startActivityForResult(intent, request);
- else
+ } else {
context.startActivity(intent);
+ }
} catch (Exception e) {
getExceptionService().displayAndReportError(context,
"start-external-intent-" + intent.toString(), //$NON-NLS-1$
@@ -194,25 +198,26 @@ public class AndroidUtilities {
* @param value
*/
public static void putInto(ContentValues target, String key, Object value, boolean errorOnFail) {
- if (value instanceof Boolean)
+ if (value instanceof Boolean) {
target.put(key, (Boolean) value);
- else if (value instanceof Byte)
+ } else if (value instanceof Byte) {
target.put(key, (Byte) value);
- else if (value instanceof Double)
+ } else if (value instanceof Double) {
target.put(key, (Double) value);
- else if (value instanceof Float)
+ } else if (value instanceof Float) {
target.put(key, (Float) value);
- else if (value instanceof Integer)
+ } else if (value instanceof Integer) {
target.put(key, (Integer) value);
- else if (value instanceof Long)
+ } else if (value instanceof Long) {
target.put(key, (Long) value);
- else if (value instanceof Short)
+ } else if (value instanceof Short) {
target.put(key, (Short) value);
- else if (value instanceof String)
+ } else if (value instanceof String) {
target.put(key, (String) value);
- else if (errorOnFail)
+ } else if (errorOnFail) {
throw new UnsupportedOperationException("Could not handle type " + //$NON-NLS-1$
value.getClass());
+ }
}
/**
@@ -223,25 +228,26 @@ public class AndroidUtilities {
* @param value
*/
public static void putInto(Bundle target, String key, Object value, boolean errorOnFail) {
- if (value instanceof Boolean)
+ if (value instanceof Boolean) {
target.putBoolean(key, (Boolean) value);
- else if (value instanceof Byte)
+ } else if (value instanceof Byte) {
target.putByte(key, (Byte) value);
- else if (value instanceof Double)
+ } else if (value instanceof Double) {
target.putDouble(key, (Double) value);
- else if (value instanceof Float)
+ } else if (value instanceof Float) {
target.putFloat(key, (Float) value);
- else if (value instanceof Integer)
+ } else if (value instanceof Integer) {
target.putInt(key, (Integer) value);
- else if (value instanceof Long)
+ } else if (value instanceof Long) {
target.putLong(key, (Long) value);
- else if (value instanceof Short)
+ } else if (value instanceof Short) {
target.putShort(key, (Short) value);
- else if (value instanceof String)
+ } else if (value instanceof String) {
target.putString(key, (String) value);
- else if (errorOnFail)
+ } else if (errorOnFail) {
throw new UnsupportedOperationException("Could not handle type " + //$NON-NLS-1$
value.getClass());
+ }
}
// --- serialization
@@ -267,9 +273,11 @@ public class AndroidUtilities {
* @return
*/
public static int indexOf(TYPE[] array, TYPE value) {
- for (int i = 0; i < array.length; i++)
- if (array[i].equals(value))
+ for (int i = 0; i < array.length; i++) {
+ if (array[i].equals(value)) {
return i;
+ }
+ }
return -1;
}
@@ -281,9 +289,11 @@ public class AndroidUtilities {
* @return
*/
public static int indexOf(int[] array, int value) {
- for (int i = 0; i < array.length; i++)
- if (array[i] == value)
+ for (int i = 0; i < array.length; i++) {
+ if (array[i] == value) {
return i;
+ }
+ }
return -1;
}
@@ -305,18 +315,19 @@ public class AndroidUtilities {
String key, Object value) {
result.append(key.replace(SERIALIZATION_SEPARATOR, SEPARATOR_ESCAPE)).append(
SERIALIZATION_SEPARATOR);
- if (value instanceof Integer)
+ if (value instanceof Integer) {
result.append('i').append(value);
- else if (value instanceof Double)
+ } else if (value instanceof Double) {
result.append('d').append(value);
- else if (value instanceof Long)
+ } else if (value instanceof Long) {
result.append('l').append(value);
- else if (value instanceof String)
+ } else if (value instanceof String) {
result.append('s').append(value.toString().replace(SERIALIZATION_SEPARATOR, SEPARATOR_ESCAPE));
- else if (value instanceof Boolean)
+ } else if (value instanceof Boolean) {
result.append('b').append(value);
- else
+ } else {
throw new UnsupportedOperationException(value.getClass().toString());
+ }
result.append(SERIALIZATION_SEPARATOR);
}
@@ -325,8 +336,9 @@ public class AndroidUtilities {
*/
public static String bundleToSerializedString(Bundle source) {
StringBuilder result = new StringBuilder();
- if (source == null)
+ if (source == null) {
return null;
+ }
for (String key : source.keySet()) {
addSerialized(result, key, source.get(key));
@@ -341,8 +353,9 @@ public class AndroidUtilities {
* @return
*/
public static ContentValues contentValuesFromSerializedString(String string) {
- if (string == null)
+ if (string == null) {
return new ContentValues();
+ }
ContentValues result = new ContentValues();
fromSerialized(string, result, new SerializedPut() {
@@ -376,8 +389,9 @@ public class AndroidUtilities {
* @return
*/
public static Bundle bundleFromSerializedString(String string) {
- if (string == null)
+ if (string == null) {
return new Bundle();
+ }
Bundle result = new Bundle();
fromSerialized(string, result, new SerializedPut() {
@@ -436,8 +450,9 @@ public class AndroidUtilities {
*/
@SuppressWarnings("nls")
public static ContentValues contentValuesFromString(String string) {
- if (string == null)
+ if (string == null) {
return null;
+ }
String[] pairs = string.split("=");
ContentValues result = new ContentValues();
@@ -451,8 +466,9 @@ public class AndroidUtilities {
} else {
newKey = pairs[i];
}
- if (key != null)
+ if (key != null) {
result.put(key.trim(), pairs[i].trim());
+ }
key = newKey;
}
return result;
@@ -466,10 +482,12 @@ public class AndroidUtilities {
* @return
*/
public static boolean equals(Object a, Object b) {
- if (a == null && b == null)
+ if (a == null && b == null) {
return true;
- if (a == null)
+ }
+ if (a == null) {
return false;
+ }
return a.equals(b);
}
@@ -508,8 +526,9 @@ public class AndroidUtilities {
while ((bytes = source.read(buffer)) != -1) {
if (bytes == 0) {
bytes = source.read();
- if (bytes < 0)
+ if (bytes < 0) {
break;
+ }
dest.write(bytes);
dest.flush();
continue;
@@ -528,16 +547,19 @@ public class AndroidUtilities {
* @return first view (by DFS) if found, or null if none
*/
public static TYPE findViewByType(View view, Class type) {
- if (view == null)
+ if (view == null) {
return null;
- if (type.isInstance(view))
+ }
+ if (type.isInstance(view)) {
return (TYPE) view;
+ }
if (view instanceof ViewGroup) {
ViewGroup group = (ViewGroup) view;
for (int i = 0; i < group.getChildCount(); i++) {
TYPE v = findViewByType(group.getChildAt(i), type);
- if (v != null)
+ if (v != null) {
return v;
+ }
}
}
return null;
@@ -557,8 +579,9 @@ public class AndroidUtilities {
*/
public static void copyDatabases(Context context, String folder) {
File folderFile = new File(folder);
- if (!folderFile.exists())
+ if (!folderFile.exists()) {
folderFile.mkdir();
+ }
for (String db : context.databaseList()) {
File dbFile = context.getDatabasePath(db);
try {
@@ -592,8 +615,9 @@ public class AndroidUtilities {
*/
public static KEY findKeyInMap(Map map, VALUE value) {
for (Entry entry : map.entrySet()) {
- if (entry.getValue().equals(value))
+ if (entry.getValue().equals(value)) {
return entry.getKey();
+ }
}
return null;
}
@@ -640,8 +664,9 @@ public class AndroidUtilities {
*/
public static Object callApiMethod(int minSdk, Object receiver,
String methodName, Class>[] params, Object... args) {
- if (getSdkVersion() < minSdk)
+ if (getSdkVersion() < minSdk) {
return null;
+ }
return AndroidUtilities.callMethod(receiver.getClass(),
receiver, methodName, params, args);
@@ -660,8 +685,9 @@ public class AndroidUtilities {
@SuppressWarnings("nls")
public static Object callApiStaticMethod(int minSdk, String className,
String methodName, Class>[] params, Object... args) {
- if (getSdkVersion() < minSdk)
+ if (getSdkVersion() < minSdk) {
return null;
+ }
try {
return AndroidUtilities.callMethod(Class.forName(className),
@@ -826,17 +852,20 @@ public class AndroidUtilities {
originalListLength = list.length;
length += list.length;
}
- if (newItems != null)
+ if (newItems != null) {
length += newItems.length;
+ }
T[] newList = (T[]) Array.newInstance(type, length);
if (list != null) {
- for (int i = 0; i < list.length; i++)
+ for (int i = 0; i < list.length; i++) {
newList[i] = list[i];
+ }
}
if (newItems != null) {
- for (int i = 0; i < newItems.length; i++)
+ for (int i = 0; i < newItems.length; i++) {
newList[originalListLength + i] = newItems[i];
+ }
}
return newList;
}
@@ -846,11 +875,13 @@ public class AndroidUtilities {
private static ExceptionService exceptionService = null;
private static ExceptionService getExceptionService() {
- if (exceptionService == null)
+ if (exceptionService == null) {
synchronized (AndroidUtilities.class) {
- if (exceptionService == null)
+ if (exceptionService == null) {
exceptionService = new ExceptionService();
+ }
}
+ }
return exceptionService;
}
@@ -863,11 +894,13 @@ public class AndroidUtilities {
*/
public static TYPE[] concat(TYPE[] dest, TYPE[] source, TYPE... additional) {
int i = 0;
- for (; i < Math.min(dest.length, source.length); i++)
+ for (; i < Math.min(dest.length, source.length); i++) {
dest[i] = source[i];
+ }
int base = i;
- for (; i < dest.length; i++)
+ for (; i < dest.length; i++) {
dest[i] = additional[i - base];
+ }
return dest;
}
@@ -920,7 +953,9 @@ public class AndroidUtilities {
*/
public static boolean isTabletSized(Context context) {
if (context.getPackageManager().hasSystemFeature("com.google.android.tv")) //$NON-NLS-1$
+ {
return true;
+ }
int size = context.getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK;
@@ -965,8 +1000,9 @@ public class AndroidUtilities {
* @param popup
*/
public static void tryDismissPopup(Activity activity, final PopupWindow popup) {
- if (popup == null)
+ if (popup == null) {
return;
+ }
try {
popup.dismiss();
} catch (Exception e) {
@@ -1008,8 +1044,9 @@ public class AndroidUtilities {
String extension = "";
if (index > 0) {
extension = file.substring(index + 1);
- if (!extension.matches("\\w+"))
+ if (!extension.matches("\\w+")) {
extension = "";
+ }
}
return extension;
}
diff --git a/api/src/com/todoroo/andlib/utility/DateUtilities.java b/api/src/com/todoroo/andlib/utility/DateUtilities.java
index 285bf5b2f..f2b712eac 100644
--- a/api/src/com/todoroo/andlib/utility/DateUtilities.java
+++ b/api/src/com/todoroo/andlib/utility/DateUtilities.java
@@ -29,8 +29,9 @@ public class DateUtilities {
* Convert unixtime into date
*/
public static final Date unixtimeToDate(long millis) {
- if (millis == 0)
+ if (millis == 0) {
return null;
+ }
return new Date(millis);
}
@@ -38,8 +39,9 @@ public class DateUtilities {
* Convert date into unixtime
*/
public static final long dateToUnixtime(Date date) {
- if (date == null)
+ if (date == null) {
return 0;
+ }
return date.getTime();
}
@@ -101,8 +103,9 @@ public class DateUtilities {
static Boolean is24HourOverride = null;
public static boolean is24HourFormat(Context context) {
- if (is24HourOverride != null)
+ if (is24HourOverride != null) {
return is24HourOverride;
+ }
return DateFormat.is24HourFormat(context);
}
@@ -149,12 +152,14 @@ public class DateUtilities {
// united states, you are special
Locale locale = Locale.getDefault();
if (arrayBinaryContains(locale.getLanguage(), "ja", "ko", "zh")
- || arrayBinaryContains(locale.getCountry(), "BZ", "CA", "KE", "MN", "US"))
+ || arrayBinaryContains(locale.getCountry(), "BZ", "CA", "KE", "MN", "US")) {
value = "'#' d'$'";
- else
+ } else {
value = "d'$' '#'";
- if (includeYear)
+ }
+ if (includeYear) {
value += ", yyyy";
+ }
if (arrayBinaryContains(locale.getLanguage(), "ja", "zh")) {
standardDate = new SimpleDateFormat(value).format(date).replace("#", month).replace("$", "\u65E5"); //$NON-NLS-1$
} else if ("ko".equals(Locale.getDefault().getLanguage())) {
@@ -182,20 +187,24 @@ public class DateUtilities {
Locale locale = Locale.getDefault();
// united states, you are special
if (arrayBinaryContains(locale.getLanguage(), "ja", "ko", "zh")
- || arrayBinaryContains(locale.getCountry(), "BZ", "CA", "KE", "MN", "US"))
+ || arrayBinaryContains(locale.getCountry(), "BZ", "CA", "KE", "MN", "US")) {
value = "'#' d";
- else
+ } else {
value = "d '#'";
+ }
if (date.getYear() != (new Date()).getYear()) {
value = value + "\nyyyy";
}
if (arrayBinaryContains(locale.getLanguage(), "ja", "zh")) //$NON-NLS-1$
+ {
return new SimpleDateFormat(value).format(date).replace("#", month) + "\u65E5"; //$NON-NLS-1$
- else if ("ko".equals(Locale.getDefault().getLanguage())) //$NON-NLS-1$
+ } else if ("ko".equals(Locale.getDefault().getLanguage())) //$NON-NLS-1$
+ {
return new SimpleDateFormat(value).format(date).replace("#", month) + "\uC77C"; //$NON-NLS-1$
- else
+ } else {
return new SimpleDateFormat(value).format(date).replace("#", month);
+ }
}
/**
@@ -247,33 +256,40 @@ public class DateUtilities {
long today = clearTime(new Date());
long input = clearTime(new Date(date));
- if (today == input)
+ if (today == input) {
return context.getString(R.string.today).toLowerCase();
+ }
- if (today + ONE_DAY == input)
+ if (today + ONE_DAY == input) {
return context.getString(abbreviated ? R.string.tmrw : R.string.tomorrow).toLowerCase();
+ }
- if (today == input + ONE_DAY)
+ if (today == input + ONE_DAY) {
return context.getString(abbreviated ? R.string.yest : R.string.yesterday).toLowerCase();
+ }
if (today + DateUtilities.ONE_WEEK >= input &&
- today - DateUtilities.ONE_WEEK <= input)
+ today - DateUtilities.ONE_WEEK <= input) {
return abbreviated ? DateUtilities.getWeekdayShort(new Date(date)) : DateUtilities.getWeekday(new Date(date));
+ }
return DateUtilities.getDateStringHideYear(context, new Date(date));
}
public static boolean isEndOfMonth(Date d) {
int date = d.getDate();
- if (date < 28)
+ if (date < 28) {
return false;
+ }
int month = d.getMonth();
- if (month == Calendar.FEBRUARY)
+ if (month == Calendar.FEBRUARY) {
return date >= 28;
+ }
- if (month == Calendar.APRIL || month == Calendar.JUNE || month == Calendar.SEPTEMBER || month == Calendar.NOVEMBER)
+ if (month == Calendar.APRIL || month == Calendar.JUNE || month == Calendar.SEPTEMBER || month == Calendar.NOVEMBER) {
return date >= 30;
+ }
return date >= 31;
}
@@ -309,8 +325,9 @@ public class DateUtilities {
}
public static long parseIso8601(String iso8601String) throws ParseException {
- if (iso8601String == null)
+ if (iso8601String == null) {
return 0;
+ }
String formatString;
if (isoStringHasTime(iso8601String)) { // Time exists
iso8601String = iso8601String.replace("Z", "+00:00"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -330,12 +347,14 @@ public class DateUtilities {
}
public static String timeToIso8601(long time, boolean includeTime) {
- if (time == 0)
+ if (time == 0) {
return null;
+ }
Date date = new Date(time);
String formatString = "yyyy-MM-dd'T'HH:mm:ssZ"; //$NON-NLS-1$
- if (!includeTime)
+ if (!includeTime) {
formatString = "yyyy-MM-dd"; //$NON-NLS-1$
+ }
return new SimpleDateFormat(formatString).format(date);
}
diff --git a/api/src/com/todoroo/andlib/utility/DialogUtilities.java b/api/src/com/todoroo/andlib/utility/DialogUtilities.java
index 328124eea..6ef09ba03 100644
--- a/api/src/com/todoroo/andlib/utility/DialogUtilities.java
+++ b/api/src/com/todoroo/andlib/utility/DialogUtilities.java
@@ -29,8 +29,9 @@ public class DialogUtilities {
public static void viewDialog(final Activity activity, final String text,
final View view, final DialogInterface.OnClickListener okListener,
final DialogInterface.OnClickListener cancelListener) {
- if (activity.isFinishing())
+ if (activity.isFinishing()) {
return;
+ }
tryOnUiThread(activity, new Runnable() {
public void run() {
@@ -76,8 +77,9 @@ public class DialogUtilities {
*/
public static void okDialog(final Activity activity, final String text,
final DialogInterface.OnClickListener okListener) {
- if (activity.isFinishing())
+ if (activity.isFinishing()) {
return;
+ }
tryOnUiThread(activity, new Runnable() {
public void run() {
@@ -101,8 +103,9 @@ public class DialogUtilities {
public static void okDialog(final Activity activity, final String title,
final int icon, final CharSequence text,
final DialogInterface.OnClickListener okListener) {
- if (activity.isFinishing())
+ if (activity.isFinishing()) {
return;
+ }
tryOnUiThread(activity, new Runnable() {
public void run() {
@@ -157,8 +160,9 @@ public class DialogUtilities {
final int icon,
final DialogInterface.OnClickListener okListener,
final DialogInterface.OnClickListener cancelListener) {
- if (activity.isFinishing())
+ if (activity.isFinishing()) {
return;
+ }
tryOnUiThread(activity, new Runnable() {
public void run() {
@@ -220,8 +224,9 @@ public class DialogUtilities {
* @param dialog
*/
public static void dismissDialog(Activity activity, final Dialog dialog) {
- if (dialog == null)
+ if (dialog == null) {
return;
+ }
tryOnUiThread(activity, new Runnable() {
public void run() {
try {
diff --git a/api/src/com/todoroo/andlib/utility/Pair.java b/api/src/com/todoroo/andlib/utility/Pair.java
index a44618ec1..d933c9eb6 100644
--- a/api/src/com/todoroo/andlib/utility/Pair.java
+++ b/api/src/com/todoroo/andlib/utility/Pair.java
@@ -36,8 +36,9 @@ public class Pair {
@Override
public final boolean equals(Object o) {
- if (!(o instanceof Pair, ?>))
+ if (!(o instanceof Pair, ?>)) {
return false;
+ }
final Pair, ?> other = (Pair, ?>) o;
return equal(getLeft(), other.getLeft()) && equal(getRight(), other.getRight());
diff --git a/api/src/com/todoroo/andlib/utility/Preferences.java b/api/src/com/todoroo/andlib/utility/Preferences.java
index e5fa865da..2d3b2e42b 100644
--- a/api/src/com/todoroo/andlib/utility/Preferences.java
+++ b/api/src/com/todoroo/andlib/utility/Preferences.java
@@ -32,8 +32,9 @@ public class Preferences {
*/
public static void setIfUnset(SharedPreferences prefs, Editor editor, Resources r, int keyResource, int value) {
String key = r.getString(keyResource);
- if (!prefs.contains(key))
+ if (!prefs.contains(key)) {
editor.putString(key, Integer.toString(value));
+ }
}
/**
@@ -47,8 +48,9 @@ public class Preferences {
*/
public static void setIfUnset(SharedPreferences prefs, Editor editor, Resources r, int keyResource, boolean value) {
String key = r.getString(keyResource);
- if (!prefs.contains(key) || !(prefs.getAll().get(key) instanceof Boolean))
+ if (!prefs.contains(key) || !(prefs.getAll().get(key) instanceof Boolean)) {
editor.putBoolean(key, value);
+ }
}
/**
@@ -62,8 +64,9 @@ public class Preferences {
*/
public static void setIfUnset(SharedPreferences prefs, Editor editor, Resources r, int keyResource, String value) {
String key = r.getString(keyResource);
- if (!prefs.contains(key) || !(prefs.getAll().get(key) instanceof String))
+ if (!prefs.contains(key) || !(prefs.getAll().get(key) instanceof String)) {
editor.putString(key, value);
+ }
}
/* ======================================================================
@@ -76,8 +79,9 @@ public class Preferences {
* Get preferences object from the context
*/
public static SharedPreferences getPrefs(Context context) {
- if (preferences != null)
+ if (preferences != null) {
return preferences;
+ }
context = context.getApplicationContext();
try {
@@ -141,8 +145,9 @@ public class Preferences {
Context context = ContextManager.getContext();
Resources r = context.getResources();
String value = getPrefs(context).getString(r.getString(keyResource), null);
- if (value == null)
+ if (value == null) {
return defaultValue;
+ }
try {
return Integer.parseInt(value);
diff --git a/api/src/com/todoroo/andlib/utility/TodorooPreferenceActivity.java b/api/src/com/todoroo/andlib/utility/TodorooPreferenceActivity.java
index 2f95518f9..fe99cb8bc 100644
--- a/api/src/com/todoroo/andlib/utility/TodorooPreferenceActivity.java
+++ b/api/src/com/todoroo/andlib/utility/TodorooPreferenceActivity.java
@@ -68,14 +68,15 @@ abstract public class TodorooPreferenceActivity extends PreferenceActivity {
updatePreferences(group, null);
} else {
Object value = null;
- if (preference instanceof ListPreference)
+ if (preference instanceof ListPreference) {
value = ((ListPreference) preference).getValue();
- else if (preference instanceof CheckBoxPreference)
+ } else if (preference instanceof CheckBoxPreference) {
value = ((CheckBoxPreference) preference).isChecked();
- else if (preference instanceof EditTextPreference)
+ } else if (preference instanceof EditTextPreference) {
value = ((EditTextPreference) preference).getText();
- else if (preference instanceof RingtonePreference)
+ } else if (preference instanceof RingtonePreference) {
value = getPreferenceManager().getSharedPreferences().getString(preference.getKey(), null);
+ }
updatePreferences(preference, value);
diff --git a/api/src/com/todoroo/astrid/api/Filter.java b/api/src/com/todoroo/astrid/api/Filter.java
index 5a7637b3e..b20cd4d69 100644
--- a/api/src/com/todoroo/astrid/api/Filter.java
+++ b/api/src/com/todoroo/astrid/api/Filter.java
@@ -107,8 +107,9 @@ public class Filter extends FilterListItem {
}
public String getSqlQuery() {
- if (filterOverride != null)
+ if (filterOverride != null) {
return filterOverride;
+ }
return sqlQuery;
}
@@ -150,23 +151,30 @@ public class Filter extends FilterListItem {
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
Filter other = (Filter) obj;
if (sqlQuery == null) {
- if (other.sqlQuery != null)
+ if (other.sqlQuery != null) {
return false;
- } else if (!sqlQuery.equals(other.sqlQuery))
+ }
+ } else if (!sqlQuery.equals(other.sqlQuery)) {
return false;
+ }
if (title == null) {
- if (other.title != null)
+ if (other.title != null) {
return false;
- } else if (!title.equals(other.title))
+ }
+ } else if (!title.equals(other.title)) {
return false;
+ }
return true;
}
diff --git a/api/src/com/todoroo/astrid/api/FilterCategory.java b/api/src/com/todoroo/astrid/api/FilterCategory.java
index 3de203890..899766694 100644
--- a/api/src/com/todoroo/astrid/api/FilterCategory.java
+++ b/api/src/com/todoroo/astrid/api/FilterCategory.java
@@ -75,10 +75,11 @@ public class FilterCategory extends FilterListItem {
FilterCategory.class.getClassLoader());
item.children = new Filter[parcelableChildren.length];
for (int i = 0; i < item.children.length; i++) {
- if (parcelableChildren[i] instanceof FilterListItem)
+ if (parcelableChildren[i] instanceof FilterListItem) {
item.children[i] = (Filter) parcelableChildren[i];
- else
+ } else {
item.children[i] = null;
+ }
}
return item;
diff --git a/api/src/com/todoroo/astrid/api/FilterCategoryWithNewButton.java b/api/src/com/todoroo/astrid/api/FilterCategoryWithNewButton.java
index 31a4acf2b..ecf2f8f9c 100644
--- a/api/src/com/todoroo/astrid/api/FilterCategoryWithNewButton.java
+++ b/api/src/com/todoroo/astrid/api/FilterCategoryWithNewButton.java
@@ -83,10 +83,11 @@ public class FilterCategoryWithNewButton extends FilterCategory {
FilterCategoryWithNewButton.class.getClassLoader());
item.children = new Filter[parcelableChildren.length];
for (int i = 0; i < item.children.length; i++) {
- if (parcelableChildren[i] instanceof FilterListItem)
+ if (parcelableChildren[i] instanceof FilterListItem) {
item.children[i] = (Filter) parcelableChildren[i];
- else
+ } else {
item.children[i] = null;
+ }
}
item.intent = source.readParcelable(PendingIntent.class.getClassLoader());
diff --git a/api/src/com/todoroo/astrid/api/FilterWithCustomIntent.java b/api/src/com/todoroo/astrid/api/FilterWithCustomIntent.java
index b3dbd6b48..3a43fb185 100644
--- a/api/src/com/todoroo/astrid/api/FilterWithCustomIntent.java
+++ b/api/src/com/todoroo/astrid/api/FilterWithCustomIntent.java
@@ -46,8 +46,9 @@ public class FilterWithCustomIntent extends Filter {
Intent intent = new Intent();
intent.putExtra("filter", this); //$NON-NLS-1$
intent.setComponent(new ComponentName(AstridApiConstants.ASTRID_PACKAGE, "com.todoroo.astrid.activity.TaskListActivity")); //$NON-NLS-1$
- if (customExtras != null)
+ if (customExtras != null) {
intent.putExtras(customExtras);
+ }
return intent;
}
diff --git a/api/src/com/todoroo/astrid/api/PermaSql.java b/api/src/com/todoroo/astrid/api/PermaSql.java
index 8bf52c6aa..7f6a6fd56 100644
--- a/api/src/com/todoroo/astrid/api/PermaSql.java
+++ b/api/src/com/todoroo/astrid/api/PermaSql.java
@@ -89,8 +89,9 @@ public final class PermaSql {
* Replace placeholder strings with actual
*/
public static String replacePlaceholders(String value) {
- if (value.contains(VALUE_NOW))
+ if (value.contains(VALUE_NOW)) {
value = value.replace(VALUE_NOW, Long.toString(DateUtilities.now()));
+ }
if (value.contains(VALUE_EOD) || value.contains(VALUE_EOD_DAY_AFTER) ||
value.contains(VALUE_EOD_NEXT_WEEK) || value.contains(VALUE_EOD_TOMORROW) ||
value.contains(VALUE_EOD_YESTERDAY) || value.contains(VALUE_EOD_NEXT_MONTH)) {
diff --git a/api/src/com/todoroo/astrid/api/SyncAction.java b/api/src/com/todoroo/astrid/api/SyncAction.java
index 13ac0d382..1e237ad29 100644
--- a/api/src/com/todoroo/astrid/api/SyncAction.java
+++ b/api/src/com/todoroo/astrid/api/SyncAction.java
@@ -58,8 +58,9 @@ public class SyncAction implements Parcelable {
*/
@Override
public boolean equals(Object o) {
- if (!(o instanceof SyncAction))
+ if (!(o instanceof SyncAction)) {
return false;
+ }
SyncAction other = (SyncAction) o;
return label.equals(other.label) && intent.getTargetPackage().equals(other.intent.getTargetPackage());
}
diff --git a/api/src/com/todoroo/astrid/core/SortHelper.java b/api/src/com/todoroo/astrid/core/SortHelper.java
index 6bdf5b9f8..50881cfd5 100644
--- a/api/src/com/todoroo/astrid/core/SortHelper.java
+++ b/api/src/com/todoroo/astrid/core/SortHelper.java
@@ -52,26 +52,31 @@ public class SortHelper {
@SuppressWarnings("nls")
public static String adjustQueryForFlagsAndSort(String originalSql, int flags, int sort) {
// sort
- if (originalSql == null)
+ if (originalSql == null) {
originalSql = "";
+ }
if (!originalSql.toUpperCase().contains("ORDER BY")) {
Order order = orderForSortType(sort);
- if ((flags & FLAG_REVERSE_SORT) > 0)
+ if ((flags & FLAG_REVERSE_SORT) > 0) {
order = order.reverse();
+ }
originalSql += " ORDER BY " + order;
}
// flags
- if ((flags & FLAG_SHOW_COMPLETED) > 0)
+ if ((flags & FLAG_SHOW_COMPLETED) > 0) {
originalSql = originalSql.replace(Task.COMPLETION_DATE.eq(0).toString(),
Criterion.all.toString());
- if ((flags & FLAG_SHOW_HIDDEN) > 0)
+ }
+ if ((flags & FLAG_SHOW_HIDDEN) > 0) {
originalSql = originalSql.replace(TaskCriteria.isVisible().toString(),
Criterion.all.toString());
- if ((flags & FLAG_SHOW_DELETED) > 0)
+ }
+ if ((flags & FLAG_SHOW_DELETED) > 0) {
originalSql = originalSql.replace(Task.DELETION_DATE.eq(0).toString(),
Criterion.all.toString());
+ }
return originalSql;
}
@@ -82,8 +87,9 @@ public class SortHelper {
public static int setManualSort(int flags, boolean status) {
flags = (flags & ~FLAG_DRAG_DROP);
- if (status)
+ if (status) {
flags |= FLAG_DRAG_DROP;
+ }
return flags;
}
@@ -111,8 +117,9 @@ public class SortHelper {
default:
order = defaultTaskOrder();
}
- if (sortType != SORT_ALPHA)
+ if (sortType != SORT_ALPHA) {
order.addSecondaryExpression(Order.asc(Task.TITLE));
+ }
return order;
}
diff --git a/api/src/com/todoroo/astrid/data/RemoteModel.java b/api/src/com/todoroo/astrid/data/RemoteModel.java
index c22de89cd..a3f58d7bc 100644
--- a/api/src/com/todoroo/astrid/data/RemoteModel.java
+++ b/api/src/com/todoroo/astrid/data/RemoteModel.java
@@ -96,22 +96,25 @@ abstract public class RemoteModel extends AbstractModel {
abstract public String getUuid();
protected String getUuidHelper(StringProperty uuid) {
- if (setValues != null && setValues.containsKey(uuid.name))
+ if (setValues != null && setValues.containsKey(uuid.name)) {
return setValues.getAsString(uuid.name);
- else if (values != null && values.containsKey(uuid.name))
+ } else if (values != null && values.containsKey(uuid.name)) {
return values.getAsString(uuid.name);
- else
+ } else {
return NO_UUID;
+ }
}
public void setUuid(String uuid) {
- if (setValues == null)
+ if (setValues == null) {
setValues = new ContentValues();
+ }
- if (NO_UUID.equals(uuid))
+ if (NO_UUID.equals(uuid)) {
clearValue(UUID_PROPERTY);
- else
+ } else {
setValues.put(UUID_PROPERTY_NAME, uuid);
+ }
}
public static boolean isUuidEmpty(String uuid) {
@@ -163,8 +166,9 @@ abstract public class RemoteModel extends AbstractModel {
File dir = context.getExternalFilesDir(PICTURES_DIRECTORY);
if (dir != null) {
File file = new File(dir + File.separator + DateUtilities.now() + ".jpg");
- if (file.exists())
+ if (file.exists()) {
return null;
+ }
try {
FileOutputStream fos = new FileOutputStream(file);
@@ -189,11 +193,14 @@ abstract public class RemoteModel extends AbstractModel {
public static String getPictureUrl(String value, String size) {
try {
- if (value == null)
+ if (value == null) {
return null;
+ }
JSONObject pictureJson = new JSONObject(value);
if (pictureJson.has("path")) // Unpushed encoded bitmap //$NON-NLS-1$
+ {
return null;
+ }
return pictureJson.optString(size);
} catch (JSONException e) {
return value;
@@ -203,8 +210,9 @@ abstract public class RemoteModel extends AbstractModel {
@SuppressWarnings("nls")
public static Bitmap getPictureBitmap(String value) {
try {
- if (value == null)
+ if (value == null) {
return null;
+ }
if (value.contains("path")) {
JSONObject pictureJson = new JSONObject(value);
if (pictureJson.has("path")) {
diff --git a/api/src/com/todoroo/astrid/data/TagData.java b/api/src/com/todoroo/astrid/data/TagData.java
index 3eea53ac6..1ff621420 100644
--- a/api/src/com/todoroo/astrid/data/TagData.java
+++ b/api/src/com/todoroo/astrid/data/TagData.java
@@ -329,10 +329,11 @@ public final class TagData extends RemoteModel {
*/
public boolean isDeleted() {
// assume false if we didn't load deletion date
- if (!containsValue(DELETION_DATE))
+ if (!containsValue(DELETION_DATE)) {
return false;
- else
+ } else {
return getValue(DELETION_DATE) > 0;
+ }
}
}
diff --git a/api/src/com/todoroo/astrid/data/Task.java b/api/src/com/todoroo/astrid/data/Task.java
index 5ef683e85..10d4397f0 100644
--- a/api/src/com/todoroo/astrid/data/Task.java
+++ b/api/src/com/todoroo/astrid/data/Task.java
@@ -301,8 +301,9 @@ public final class Task extends RemoteModel {
public static final String USER_ID_SELF = "0";
public static boolean isRealUserId(String userId) {
- if (userId == null)
+ if (userId == null) {
return false;
+ }
return !(Task.USER_ID_SELF.equals(userId) ||
Task.USER_ID_UNASSIGNED.equals(userId) ||
Task.USER_ID_EMAIL.equals(userId) ||
@@ -310,8 +311,9 @@ public final class Task extends RemoteModel {
}
public static boolean userIdIsEmail(String userId) {
- if (userId == null)
+ if (userId == null) {
return false;
+ }
return userId.indexOf('@') >= 0;
}
@@ -469,10 +471,11 @@ public final class Task extends RemoteModel {
*/
public boolean isDeleted() {
// assume false if we didn't load deletion date
- if (!containsValue(DELETION_DATE))
+ if (!containsValue(DELETION_DATE)) {
return false;
- else
+ } else {
return getValue(DELETION_DATE) > 0;
+ }
}
/**
@@ -555,8 +558,9 @@ public final class Task extends RemoteModel {
throw new IllegalArgumentException("Unknown setting " + setting);
}
- if (date <= 0)
+ if (date <= 0) {
return date;
+ }
Date dueDate = new Date(date / 1000L * 1000L); // get rid of millis
if (setting != URGENCY_SPECIFIC_DAY_TIME) {
@@ -600,8 +604,9 @@ public final class Task extends RemoteModel {
throw new IllegalArgumentException("Unknown setting " + setting);
}
- if (date <= 0)
+ if (date <= 0) {
return date;
+ }
Date hideUntil = new Date(date / 1000L * 1000L); // get rid of millis
if (setting != HIDE_UNTIL_SPECIFIC_DAY_TIME && setting != HIDE_UNTIL_DUE_TIME) {
@@ -618,8 +623,9 @@ public final class Task extends RemoteModel {
* Checks whether this due date has a due time or only a date
*/
public boolean hasDueTime() {
- if (!hasDueDate())
+ if (!hasDueDate()) {
return false;
+ }
return hasDueTime(getValue(Task.DUE_DATE));
}
diff --git a/api/src/com/todoroo/astrid/data/TaskApiDao.java b/api/src/com/todoroo/astrid/data/TaskApiDao.java
index 74f082ad8..6b50b98f1 100644
--- a/api/src/com/todoroo/astrid/data/TaskApiDao.java
+++ b/api/src/com/todoroo/astrid/data/TaskApiDao.java
@@ -188,24 +188,29 @@ public class TaskApiDao extends ContentResolverDao {
* @return true if task change shouldn't be broadcast
*/
public static boolean insignificantChange(ContentValues values) {
- if (values == null || values.size() == 0)
+ if (values == null || values.size() == 0) {
return true;
+ }
if (values.containsKey(Task.DETAILS_DATE.name) &&
- values.size() <= 3)
+ values.size() <= 3) {
return true;
+ }
if (values.containsKey(Task.REMINDER_LAST.name) &&
- values.size() <= 2)
+ values.size() <= 2) {
return true;
+ }
if (values.containsKey(Task.REMINDER_SNOOZE.name) &&
- values.size() <= 2)
+ values.size() <= 2) {
return true;
+ }
if (values.containsKey(Task.TIMER_START.name) &&
- values.size() <= 2)
+ values.size() <= 2) {
return true;
+ }
return false;
}
diff --git a/api/src/com/todoroo/astrid/data/User.java b/api/src/com/todoroo/astrid/data/User.java
index c910c5240..876943e36 100644
--- a/api/src/com/todoroo/astrid/data/User.java
+++ b/api/src/com/todoroo/astrid/data/User.java
@@ -182,19 +182,23 @@ public final class User extends RemoteModel {
public String getDisplayName(StringProperty nameProperty, StringProperty firstNameProperty, StringProperty lastNameProperty) {
String name = getCheckedString(nameProperty);
- if (!(TextUtils.isEmpty(name) || "null".equals(name)))
+ if (!(TextUtils.isEmpty(name) || "null".equals(name))) {
return name;
+ }
String firstName = getCheckedString(firstNameProperty);
boolean firstNameEmpty = TextUtils.isEmpty(firstName) || "null".equals(firstName);
String lastName = getCheckedString(lastNameProperty);
boolean lastNameEmpty = TextUtils.isEmpty(lastName) || "null".equals(lastName);
- if (firstNameEmpty && lastNameEmpty)
+ if (firstNameEmpty && lastNameEmpty) {
return getCheckedString(EMAIL);
+ }
StringBuilder nameBuilder = new StringBuilder();
- if (!firstNameEmpty)
+ if (!firstNameEmpty) {
nameBuilder.append(firstName).append(" ");
- if (!lastNameEmpty)
+ }
+ if (!lastNameEmpty) {
nameBuilder.append(lastName);
+ }
return nameBuilder.toString().trim();
}
diff --git a/api/src/com/todoroo/astrid/sync/SyncBackgroundService.java b/api/src/com/todoroo/astrid/sync/SyncBackgroundService.java
index 0319362d3..32ac0af12 100644
--- a/api/src/com/todoroo/astrid/sync/SyncBackgroundService.java
+++ b/api/src/com/todoroo/astrid/sync/SyncBackgroundService.java
@@ -74,13 +74,15 @@ abstract public class SyncBackgroundService extends Service {
* Start the actual synchronization
*/
private void startSynchronization(Context context) {
- if (context == null || context.getResources() == null)
+ if (context == null || context.getResources() == null) {
return;
+ }
ContextManager.setContext(context);
- if (!getSyncUtilities().isLoggedIn())
+ if (!getSyncUtilities().isLoggedIn()) {
return;
+ }
getSyncProvider().synchronize(context);
}
@@ -162,10 +164,11 @@ abstract public class SyncBackgroundService extends Service {
long lastSyncDate = getSyncUtilities().getLastSyncDate();
// if user never synchronized, give them a full offset period before bg sync
- if (lastSyncDate != 0)
+ if (lastSyncDate != 0) {
return Math.max(0, lastSyncDate + interval - DateUtilities.now());
- else
+ } else {
return interval;
+ }
}
diff --git a/api/src/com/todoroo/astrid/sync/SyncContainer.java b/api/src/com/todoroo/astrid/sync/SyncContainer.java
index c742df94c..e24532006 100644
--- a/api/src/com/todoroo/astrid/sync/SyncContainer.java
+++ b/api/src/com/todoroo/astrid/sync/SyncContainer.java
@@ -30,8 +30,9 @@ public class SyncContainer {
*/
public Metadata findMetadata(String key) {
for (Metadata item : metadata) {
- if (AndroidUtilities.equals(key, item.getValue(Metadata.KEY)))
+ if (AndroidUtilities.equals(key, item.getValue(Metadata.KEY))) {
return item;
+ }
}
return null;
}
diff --git a/api/src/com/todoroo/astrid/sync/SyncProvider.java b/api/src/com/todoroo/astrid/sync/SyncProvider.java
index a82933418..0a6993caa 100644
--- a/api/src/com/todoroo/astrid/sync/SyncProvider.java
+++ b/api/src/com/todoroo/astrid/sync/SyncProvider.java
@@ -168,8 +168,9 @@ public abstract class SyncProvider {
((Activity) context).runOnUiThread(new Runnable() {
@Override
public void run() {
- if (showSyncToast)
+ if (showSyncToast) {
makeSyncToast(context);
+ }
}
});
}
@@ -221,8 +222,9 @@ public abstract class SyncProvider {
length = data.remoteUpdated.size();
for (int i = 0; i < length; i++) {
TYPE remote = data.remoteUpdated.get(i);
- if (remote.task.getId() != Task.NO_ID)
+ if (remote.task.getId() != Task.NO_ID) {
continue;
+ }
remoteNewTaskNameMap.put(remote.task.getValue(Task.TITLE), i);
}
@@ -239,10 +241,11 @@ public abstract class SyncProvider {
@SuppressWarnings("nls")
protected String getFinalSyncStatus() {
if (getUtilities().getLastError() != null || getUtilities().getLastAttemptedSyncDate() != 0) {
- if (getUtilities().getLastAttemptedSyncDate() == 0)
+ if (getUtilities().getLastAttemptedSyncDate() == 0) {
return "errors";
- else
+ } else {
return "failed";
+ }
} else {
return "success";
}
@@ -261,22 +264,25 @@ public abstract class SyncProvider {
private final int check(TYPE o1, TYPE o2, LongProperty property) {
long o1Property = o1.task.getValue(property);
long o2Property = o2.task.getValue(property);
- if (o1Property != 0 && o2Property != 0)
+ if (o1Property != 0 && o2Property != 0) {
return 0;
- else if (o1Property != 0)
+ } else if (o1Property != 0) {
return -1;
- else if (o2Property != 0)
+ } else if (o2Property != 0) {
return 1;
+ }
return SENTINEL;
}
public int compare(TYPE o1, TYPE o2) {
int comparison = check(o1, o2, Task.DELETION_DATE);
- if (comparison != SENTINEL)
+ if (comparison != SENTINEL) {
return comparison;
+ }
comparison = check(o1, o2, Task.COMPLETION_DATE);
- if (comparison != SENTINEL)
+ if (comparison != SENTINEL) {
return comparison;
+ }
return 0;
}
});
@@ -286,8 +292,9 @@ public abstract class SyncProvider {
TYPE remote = data.remoteUpdated.get(i);
// don't synchronize new & deleted tasks
- if (!remote.task.isSaved() && (remote.task.isDeleted()))
+ if (!remote.task.isSaved() && (remote.task.isDeleted())) {
continue;
+ }
try {
write(remote);
@@ -304,8 +311,9 @@ public abstract class SyncProvider {
data.localUpdated.moveToNext();
TYPE local = read(data.localUpdated);
try {
- if (local.task == null)
+ if (local.task == null) {
continue;
+ }
// if there is a conflict, merge
int remoteIndex = matchTask((ArrayList) data.remoteUpdated, local);
diff --git a/api/src/com/todoroo/astrid/sync/SyncProviderPreferences.java b/api/src/com/todoroo/astrid/sync/SyncProviderPreferences.java
index 700261524..2191b8b0c 100644
--- a/api/src/com/todoroo/astrid/sync/SyncProviderPreferences.java
+++ b/api/src/com/todoroo/astrid/sync/SyncProviderPreferences.java
@@ -86,8 +86,9 @@ abstract public class SyncProviderPreferences extends TodorooPreferenceActivity
@Override
public void onChildViewAdded(View parent, View child) {
View view = findViewById(R.id.status);
- if (view != null)
+ if (view != null) {
view.setBackgroundColor(statusColor);
+ }
}
});
}
@@ -105,12 +106,13 @@ abstract public class SyncProviderPreferences extends TodorooPreferenceActivity
int index = AndroidUtilities.indexOf(
r.getStringArray(R.array.sync_SPr_interval_values),
(String) value);
- if (index <= 0)
+ if (index <= 0) {
preference.setSummary(R.string.sync_SPr_interval_desc_disabled);
- else
+ } else {
preference.setSummary(r.getString(
R.string.sync_SPr_interval_desc,
r.getStringArray(R.array.sync_SPr_interval_entries)[index]));
+ }
}
// status
@@ -171,8 +173,9 @@ abstract public class SyncProviderPreferences extends TodorooPreferenceActivity
});
View view = findViewById(R.id.status);
- if (view != null)
+ if (view != null) {
view.setBackgroundColor(statusColor);
+ }
} else if (r.getString(R.string.sync_SPr_key_last_error).equals(preference.getKey())) {
if (getUtilities().getLastError() != null) {
// Display error
@@ -266,8 +269,9 @@ abstract public class SyncProviderPreferences extends TodorooPreferenceActivity
break;
}
}
- if (resource == null)
+ if (resource == null) {
return lastError;
+ }
return r.getString(resource.intValue(), service);
}
diff --git a/api/src/com/todoroo/astrid/sync/SyncProviderUtilities.java b/api/src/com/todoroo/astrid/sync/SyncProviderUtilities.java
index 6c8332265..83d009e8f 100644
--- a/api/src/com/todoroo/astrid/sync/SyncProviderUtilities.java
+++ b/api/src/com/todoroo/astrid/sync/SyncProviderUtilities.java
@@ -194,8 +194,9 @@ abstract public class SyncProviderUtilities {
String value = getPrefs().getString(
ContextManager.getContext().getString(
getSyncIntervalKey()), null);
- if (value == null)
+ if (value == null) {
return 0;
+ }
try {
return Integer.parseInt(value);
} catch (Exception e) {
diff --git a/api/src/com/todoroo/astrid/sync/SyncV2BackgroundService.java b/api/src/com/todoroo/astrid/sync/SyncV2BackgroundService.java
index d46c9c1f6..13b86585d 100644
--- a/api/src/com/todoroo/astrid/sync/SyncV2BackgroundService.java
+++ b/api/src/com/todoroo/astrid/sync/SyncV2BackgroundService.java
@@ -75,16 +75,18 @@ abstract public class SyncV2BackgroundService extends Service {
* Start the actual synchronization
*/
private void startSynchronization(final Context context) {
- if (context == null || context.getResources() == null)
+ if (context == null || context.getResources() == null) {
return;
+ }
ContextManager.setContext(context);
- if (!getSyncUtilities().isLoggedIn())
+ if (!getSyncUtilities().isLoggedIn()) {
return;
+ }
SyncV2Provider provider = getSyncProvider();
- if (provider.isActive())
+ if (provider.isActive()) {
provider.synchronizeActiveTasks(false, new SyncResultCallbackAdapter() {
@Override
public void finished() {
@@ -92,6 +94,7 @@ abstract public class SyncV2BackgroundService extends Service {
context.sendBroadcast(new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH));
}
});
+ }
}
@Override
@@ -171,10 +174,11 @@ abstract public class SyncV2BackgroundService extends Service {
long lastSyncDate = getSyncUtilities().getLastSyncDate();
// if user never synchronized, give them a full offset period before bg sync
- if (lastSyncDate != 0)
+ if (lastSyncDate != 0) {
return Math.max(0, lastSyncDate + interval - DateUtilities.now());
- else
+ } else {
return interval;
+ }
}
diff --git a/api/src/com/todoroo/astrid/sync/SyncV2Provider.java b/api/src/com/todoroo/astrid/sync/SyncV2Provider.java
index 45f0632a2..d35b53ffe 100644
--- a/api/src/com/todoroo/astrid/sync/SyncV2Provider.java
+++ b/api/src/com/todoroo/astrid/sync/SyncV2Provider.java
@@ -90,8 +90,9 @@ abstract public class SyncV2Provider {
utilities.recordSuccessfulSync();
utilities.reportLastError();
utilities.stopOngoing();
- if (callback != null)
+ if (callback != null) {
callback.finished();
+ }
}
@Override
diff --git a/astrid/common-src/com/commonsware/cwac/tlv/TouchListView.java b/astrid/common-src/com/commonsware/cwac/tlv/TouchListView.java
index 8b30a41e5..3ba2532cf 100644
--- a/astrid/common-src/com/commonsware/cwac/tlv/TouchListView.java
+++ b/astrid/common-src/com/commonsware/cwac/tlv/TouchListView.java
@@ -419,8 +419,9 @@ public class TouchListView extends ErrorCatchingListView {
private final Runnable longPressRunnable = new Runnable() {
public void run() {
AndroidUtilities.sleepDeep(1000L);
- if (Thread.currentThread().isInterrupted())
+ if (Thread.currentThread().isInterrupted()) {
return;
+ }
if (mDragView != null && mDragPos == mFirstDragPos &&
Math.abs(mDragCurrentX - mDragStartX) < 10) {
@@ -473,10 +474,11 @@ public class TouchListView extends ErrorCatchingListView {
if (mDragPos == mFirstDragPos &&
Math.abs(mDragCurrentX - mDragStartX) < 10) {
long pressTime = System.currentTimeMillis() - mDragStartTime;
- if (pressTime < 1000)
+ if (pressTime < 1000) {
mClickListener.onClick(mOriginalView);
- else
+ } else {
mClickListener.onLongClick(mOriginalView);
+ }
}
}
}
diff --git a/astrid/plugin-src/com/timsu/astrid/GCMIntentService.java b/astrid/plugin-src/com/timsu/astrid/GCMIntentService.java
index dd562e226..93f31559e 100644
--- a/astrid/plugin-src/com/timsu/astrid/GCMIntentService.java
+++ b/astrid/plugin-src/com/timsu/astrid/GCMIntentService.java
@@ -67,8 +67,9 @@ public class GCMIntentService extends GCMBaseIntentService {
if (AndroidUtilities.getSdkVersion() > 8) { //Gingerbread and above
//the following uses relection to get android.os.Build.SERIAL to avoid having to build with Gingerbread
try {
- if (!Build.UNKNOWN.equals(Build.SERIAL))
+ if (!Build.UNKNOWN.equals(Build.SERIAL)) {
id = Build.SERIAL;
+ }
} catch (Exception e) {
// Ah well
}
@@ -120,13 +121,15 @@ public class GCMIntentService extends GCMBaseIntentService {
@Override
protected void onMessage(Context context, Intent intent) {
if (actFmPreferenceService.isLoggedIn()) {
- if (intent.hasExtra("web_update"))
- if (DateUtilities.now() - actFmPreferenceService.getLastSyncDate() > MIN_MILLIS_BETWEEN_FULL_SYNCS && !actFmPreferenceService.isOngoing())
+ if (intent.hasExtra("web_update")) {
+ if (DateUtilities.now() - actFmPreferenceService.getLastSyncDate() > MIN_MILLIS_BETWEEN_FULL_SYNCS && !actFmPreferenceService.isOngoing()) {
new ActFmSyncV2Provider().synchronizeActiveTasks(false, refreshOnlyCallback);
- else
+ } else {
handleWebUpdate(intent);
- else
+ }
+ } else {
handleMessage(intent);
+ }
}
}
@@ -179,12 +182,14 @@ public class GCMIntentService extends GCMBaseIntentService {
private void handleMessage(Intent intent) {
String message = intent.getStringExtra("alert");
Context context = ContextManager.getContext();
- if (TextUtils.isEmpty(message))
+ if (TextUtils.isEmpty(message)) {
return;
+ }
long lastNotification = Preferences.getLong(PREF_LAST_GCM, 0);
- if (DateUtilities.now() - lastNotification < 5000L)
+ if (DateUtilities.now() - lastNotification < 5000L) {
return;
+ }
Preferences.setLong(PREF_LAST_GCM, DateUtilities.now());
Intent notifyIntent = null;
int notifId;
@@ -218,8 +223,9 @@ public class GCMIntentService extends GCMBaseIntentService {
return;
}
- if (notifyIntent == null)
+ if (notifyIntent == null) {
return;
+ }
notifyIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
notifyIntent.putExtra(TaskListActivity.TOKEN_SOURCE, Constants.SOURCE_C2DM);
@@ -233,10 +239,11 @@ public class GCMIntentService extends GCMBaseIntentService {
Notification notification = new Notification(icon,
message, System.currentTimeMillis());
String title;
- if (intent.hasExtra("title"))
+ if (intent.hasExtra("title")) {
title = "Astrid: " + intent.getStringExtra("title");
- else
+ } else {
title = ContextManager.getString(R.string.app_name);
+ }
notification.setLatestEventInfo(ContextManager.getContext(), title,
message, pendingIntent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
@@ -259,20 +266,26 @@ public class GCMIntentService extends GCMBaseIntentService {
private int calculateIcon(Intent intent) {
if (intent.hasExtra("type")) {
String type = intent.getStringExtra("type");
- if ("f".equals(type))
+ if ("f".equals(type)) {
return R.drawable.notif_c2dm_done;
- if ("s".equals(type))
+ }
+ if ("s".equals(type)) {
return R.drawable.notif_c2dm_assign;
- if ("l".equals(type))
+ }
+ if ("l".equals(type)) {
return R.drawable.notif_c2dm_assign;
+ }
} else {
String message = intent.getStringExtra("alert");
- if (message.contains(" finished "))
+ if (message.contains(" finished ")) {
return R.drawable.notif_c2dm_done;
- if (message.contains(" invited you to "))
+ }
+ if (message.contains(" invited you to ")) {
return R.drawable.notif_c2dm_assign;
- if (message.contains(" sent you "))
+ }
+ if (message.contains(" sent you ")) {
return R.drawable.notif_c2dm_assign;
+ }
}
return R.drawable.notif_c2dm_msg;
}
@@ -339,8 +352,9 @@ public class GCMIntentService extends GCMBaseIntentService {
update.setValue(UserActivity.ACTION, "tag_comment");
update.setValue(UserActivity.TARGET_NAME, intent.getStringExtra("title"));
String message = intent.getStringExtra("alert");
- if (message.contains(":"))
+ if (message.contains(":")) {
message = message.substring(message.indexOf(':') + 2);
+ }
update.setValue(UserActivity.MESSAGE, message);
update.setValue(UserActivity.CREATED_AT, DateUtilities.now());
update.setValue(UserActivity.TARGET_ID, intent.getStringExtra("tag_id"));
@@ -366,14 +380,26 @@ public class GCMIntentService extends GCMBaseIntentService {
private boolean shouldLaunchActivity(Intent intent) {
if (intent.hasExtra("type")) {
String type = intent.getStringExtra("type");
- if ("f".equals(type)) return true;
- if ("s".equals(type)) return false;
- if ("l".equals(type)) return false;
+ if ("f".equals(type)) {
+ return true;
+ }
+ if ("s".equals(type)) {
+ return false;
+ }
+ if ("l".equals(type)) {
+ return false;
+ }
} else {
String message = intent.getStringExtra("alert");
- if (message.contains(" finished ")) return true;
- if (message.contains(" invited you to ")) return false;
- if (message.contains(" sent you ")) return false;
+ if (message.contains(" finished ")) {
+ return true;
+ }
+ if (message.contains(" invited you to ")) {
+ return false;
+ }
+ if (message.contains(" sent you ")) {
+ return false;
+ }
}
return true;
}
diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmCameraModule.java b/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmCameraModule.java
index cb4416b7b..646bf65f6 100644
--- a/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmCameraModule.java
+++ b/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmCameraModule.java
@@ -44,12 +44,14 @@ public class ActFmCameraModule {
PackageManager pm = activity.getPackageManager();
final boolean cameraAvailable = pm.queryIntentActivities(cameraIntent, 0).size() > 0;
- if (cameraAvailable)
+ if (cameraAvailable) {
options.add(activity.getString(R.string.actfm_picture_camera));
+ }
options.add(activity.getString(R.string.actfm_picture_gallery));
- if (clearImageOption != null)
+ if (clearImageOption != null) {
options.add(activity.getString(R.string.actfm_picture_clear));
+ }
ArrayAdapter adapter = new ArrayAdapter(activity,
android.R.layout.simple_spinner_dropdown_item, options.toArray(new String[options.size()]));
@@ -71,8 +73,9 @@ public class ActFmCameraModule {
activity.startActivityForResult(Intent.createChooser(intent,
activity.getString(R.string.actfm_TVA_tag_picture)), REQUEST_CODE_PICTURE);
} else {
- if (clearImageOption != null)
+ if (clearImageOption != null) {
clearImageOption.clearImage();
+ }
}
}
};
@@ -90,13 +93,15 @@ public class ActFmCameraModule {
final Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
PackageManager pm = fragment.getActivity().getPackageManager();
final boolean cameraAvailable = pm.queryIntentActivities(cameraIntent, 0).size() > 0;
- if (cameraAvailable)
+ if (cameraAvailable) {
options.add(fragment.getString(R.string.actfm_picture_camera));
+ }
options.add(fragment.getString(R.string.actfm_picture_gallery));
- if (clearImageOption != null)
+ if (clearImageOption != null) {
options.add(fragment.getString(R.string.actfm_picture_clear));
+ }
ArrayAdapter adapter = new ArrayAdapter(fragment.getActivity(),
android.R.layout.simple_spinner_dropdown_item, options.toArray(new String[options.size()]));
@@ -107,8 +112,9 @@ public class ActFmCameraModule {
public void onClick(DialogInterface d, int which) {
if (which == 0 && cameraAvailable) {
lastTempFile = getTempFile(fragment.getActivity());
- if (lastTempFile != null)
+ if (lastTempFile != null) {
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(lastTempFile));
+ }
fragment.startActivityForResult(cameraIntent, REQUEST_CODE_CAMERA);
} else if ((which == 1 && cameraAvailable) || (which == 0 && !cameraAvailable)) {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
@@ -116,8 +122,9 @@ public class ActFmCameraModule {
fragment.startActivityForResult(Intent.createChooser(intent,
fragment.getString(R.string.actfm_TVA_tag_picture)), REQUEST_CODE_PICTURE);
} else {
- if (clearImageOption != null)
+ if (clearImageOption != null) {
clearImageOption.clearImage();
+ }
}
}
};
@@ -173,10 +180,12 @@ public class ActFmCameraModule {
bitmap = bitmapFromUri(activity, Uri.fromFile(lastTempFile));
lastTempFile.deleteOnExit();
lastTempFile = null;
- } else
+ } else {
bitmap = null;
- } else
+ }
+ } else {
bitmap = data.getParcelableExtra("data"); //$NON-NLS-1$
+ }
if (bitmap != null) {
activity.setResult(Activity.RESULT_OK);
cameraResult.handleCameraResult(bitmap);
diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmGoogleAuthActivity.java b/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmGoogleAuthActivity.java
index 427f4f4f3..38db535ac 100644
--- a/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmGoogleAuthActivity.java
+++ b/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmGoogleAuthActivity.java
@@ -72,8 +72,9 @@ public class ActFmGoogleAuthActivity extends ListActivity {
accountManager = new GoogleAccountManager(this);
Account[] accounts = accountManager.getAccounts();
ArrayList accountNames = new ArrayList();
- for (Account a : accounts)
+ for (Account a : accounts) {
accountNames.add(a.name);
+ }
nameArray = accountNames.toArray(new String[accountNames.size()]);
setListAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, nameArray));
@@ -132,8 +133,9 @@ public class ActFmGoogleAuthActivity extends ListActivity {
}
});
} finally {
- if (dismissDialog)
+ if (dismissDialog) {
DialogUtilities.dismissDialog(ActFmGoogleAuthActivity.this, pd);
+ }
}
}
}.start();
diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmLoginActivity.java b/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmLoginActivity.java
index 3ea766d00..b43950bdb 100644
--- a/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmLoginActivity.java
+++ b/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmLoginActivity.java
@@ -196,11 +196,13 @@ public class ActFmLoginActivity extends SherlockFragmentActivity {
ContextManager.setContext(this);
setContentView(getContentViewResource());
- if (getTitleResource() != 0)
+ if (getTitleResource() != 0) {
setTitle(getTitleResource());
+ }
- if (getSupportActionBar() != null)
+ if (getSupportActionBar() != null) {
getSupportActionBar().hide();
+ }
rand = new Random(DateUtilities.now());
@@ -298,14 +300,16 @@ public class ActFmLoginActivity extends SherlockFragmentActivity {
protected void initializeUI() {
errors = (TextView) findViewById(R.id.error);
LoginButton loginButton = (LoginButton) findViewById(R.id.fb_login);
- if (loginButton == null)
+ if (loginButton == null) {
return;
+ }
loginButton.setReadPermissions(Arrays.asList("email", "offline_access"));
View googleLogin = findViewById(R.id.gg_login);
- if (AmazonMarketStrategy.isKindleFire())
+ if (AmazonMarketStrategy.isKindleFire()) {
googleLogin.setVisibility(View.GONE);
+ }
googleLogin.setOnClickListener(googleListener);
View fbLogin = findViewById(R.id.fb_login_dummy);
@@ -371,8 +375,9 @@ public class ActFmLoginActivity extends SherlockFragmentActivity {
getCredentials(new OnGetCredentials() {
@Override
public void getCredentials(String[] accounts) {
- if (accounts != null && accounts.length > 0)
+ if (accounts != null && accounts.length > 0) {
email.setText(accounts[0]);
+ }
}
});
@@ -415,8 +420,9 @@ public class ActFmLoginActivity extends SherlockFragmentActivity {
getCredentials(new OnGetCredentials() {
@Override
public void getCredentials(String[] accounts) {
- if (accounts != null && accounts.length > 0)
+ if (accounts != null && accounts.length > 0) {
email.setText(accounts[0]);
+ }
}
});
@@ -494,8 +500,9 @@ public class ActFmLoginActivity extends SherlockFragmentActivity {
char last = 'a';
for (int i = 0; i < chars.length; i++) {
char r = acceptable.charAt(rand.nextInt(acceptable.length()));
- while (!checkSimilar(last, r))
+ while (!checkSimilar(last, r)) {
r = acceptable.charAt(rand.nextInt(acceptable.length()));
+ }
last = r;
chars[i] = r;
}
@@ -512,8 +519,9 @@ public class ActFmLoginActivity extends SherlockFragmentActivity {
|| (oSimilar.indexOf(last) > 0 && oSimilar.indexOf(check) > 0)
|| (puncSimilar.indexOf(last) > 0 && puncSimilar.indexOf(check) > 0);
- if (match)
+ if (match) {
return false;
+ }
return true;
}
@@ -572,9 +580,10 @@ public class ActFmLoginActivity extends SherlockFragmentActivity {
@SuppressWarnings("nls")
public void authenticate(final String email, final String firstName, final String lastName, final String provider,
final String secret) {
- if (progressDialog == null)
+ if (progressDialog == null) {
progressDialog = DialogUtilities.progressDialog(this,
getString(R.string.DLG_please_wait));
+ }
new Thread() {
@Override
@@ -851,8 +860,9 @@ public class ActFmLoginActivity extends SherlockFragmentActivity {
Preferences.setString(ActFmPreferenceService.PREF_PICTURE,
result.optString("picture"));
- if (!result.optBoolean("new"))
+ if (!result.optBoolean("new")) {
Toast.makeText(this, R.string.actfm_ALA_user_exists_sync_alert, Toast.LENGTH_LONG).show();
+ }
ActFmPreferenceService.reloadThisUser();
@@ -887,12 +897,13 @@ public class ActFmLoginActivity extends SherlockFragmentActivity {
JSONObject result = ae.result;
if (result != null && result.has("code")) {
String code = result.optString("code");
- if ("user_exists".equals(code))
+ if ("user_exists".equals(code)) {
message = getString(R.string.actfm_ALA_error_user_exists);
- else if ("incorrect_password".equals(code))
+ } else if ("incorrect_password".equals(code)) {
message = getString(R.string.actfm_ALA_error_wrong_password);
- else if ("user_not_found".equals(code) || "missing_param".equals(code))
+ } else if ("user_not_found".equals(code) || "missing_param".equals(code)) {
message = getString(R.string.actfm_ALA_error_user_not_found);
+ }
}
}
errors.setText(message);
@@ -909,8 +920,9 @@ public class ActFmLoginActivity extends SherlockFragmentActivity {
super.onActivityResult(requestCode, resultCode, data);
uiHelper.onActivityResult(requestCode, resultCode, data);
- if (resultCode == RESULT_CANCELED)
+ if (resultCode == RESULT_CANCELED) {
return;
+ }
if (requestCode == REQUEST_CODE_GOOGLE_ACCOUNTS && data != null && credentialsListener != null) {
String accounts[] = data.getStringArrayExtra(
@@ -937,8 +949,9 @@ public class ActFmLoginActivity extends SherlockFragmentActivity {
// errors.setVisibility(View.GONE);
// }
else if (requestCode == REQUEST_CODE_GOOGLE) {
- if (data == null)
+ if (data == null) {
return;
+ }
String email = data.getStringExtra(ActFmGoogleAuthActivity.RESULT_EMAIL);
String token = data.getStringExtra(ActFmGoogleAuthActivity.RESULT_TOKEN);
authenticate(email, email, "", "google", token);
@@ -953,11 +966,12 @@ public class ActFmLoginActivity extends SherlockFragmentActivity {
public void getCredentials(OnGetCredentials onGetCredentials) {
credentialsListener = onGetCredentials;
- if (Integer.parseInt(Build.VERSION.SDK) >= 7)
+ if (Integer.parseInt(Build.VERSION.SDK) >= 7) {
credentialsListener.getCredentials(ModernAuthManager.getAccounts(this));
- else
+ } else {
GoogleLoginServiceHelper.getAccount(this,
REQUEST_CODE_GOOGLE_ACCOUNTS, false);
+ }
}
}
diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmPreferences.java b/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmPreferences.java
index f9afeeb6b..afa969cba 100644
--- a/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmPreferences.java
+++ b/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmPreferences.java
@@ -78,9 +78,9 @@ public class ActFmPreferences extends SyncProviderPreferences {
PreferenceScreen screen = getPreferenceScreen();
Preference inAppBilling = findPreference(getString(R.string.actfm_inapp_billing));
- if (Constants.ASTRID_LITE || Preferences.getBoolean(PremiumUnlockService.PREF_KILL_SWITCH, false))
+ if (Constants.ASTRID_LITE || Preferences.getBoolean(PremiumUnlockService.PREF_KILL_SWITCH, false)) {
screen.removePreference(inAppBilling);
- else
+ } else {
inAppBilling.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
@@ -88,6 +88,7 @@ public class ActFmPreferences extends SyncProviderPreferences {
return true;
}
});
+ }
findPreference(getString(R.string.actfm_account_type)).setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
@@ -141,19 +142,22 @@ public class ActFmPreferences extends SyncProviderPreferences {
String title = actFmPreferenceService.getLoggedInUserName();
String email = Preferences.getStringValue(ActFmPreferenceService.PREF_EMAIL);
if (!TextUtils.isEmpty(email)) {
- if (!TextUtils.isEmpty(title))
+ if (!TextUtils.isEmpty(title)) {
title += "\n"; //$NON-NLS-1$
+ }
title += email;
}
status.setTitle(getString(R.string.actfm_status_title_logged_in, title));
- } else
+ } else {
status.setTitle(R.string.sync_SPr_group_status);
+ }
if (r.getString(R.string.actfm_https_key).equals(preference.getKey())) {
- if ((Boolean) value)
+ if ((Boolean) value) {
preference.setSummary(R.string.actfm_https_enabled);
- else
+ } else {
preference.setSummary(R.string.actfm_https_disabled);
+ }
} else if (r.getString(R.string.actfm_account_type).equals(preference.getKey())) {
if (ActFmPreferenceService.isPremiumUser()) {
// Premium user
diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmSyncActionExposer.java b/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmSyncActionExposer.java
index bcbe524f8..fc9207d1f 100644
--- a/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmSyncActionExposer.java
+++ b/astrid/plugin-src/com/todoroo/astrid/actfm/ActFmSyncActionExposer.java
@@ -36,8 +36,9 @@ public class ActFmSyncActionExposer extends BroadcastReceiver {
DependencyInjectionService.getInstance().inject(this);
// if we aren't logged in, don't expose sync action
- if (!actFmPreferenceService.isLoggedIn())
+ if (!actFmPreferenceService.isLoggedIn()) {
return;
+ }
SyncAction syncAction = new SyncAction(context.getString(R.string.actfm_APr_header),
null);
diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/CommentsFragment.java b/astrid/plugin-src/com/todoroo/astrid/actfm/CommentsFragment.java
index 939fc9200..5f53927de 100644
--- a/astrid/plugin-src/com/todoroo/astrid/actfm/CommentsFragment.java
+++ b/astrid/plugin-src/com/todoroo/astrid/actfm/CommentsFragment.java
@@ -217,10 +217,11 @@ public abstract class CommentsFragment extends SherlockListFragment {
pictureButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- if (picture != null)
+ if (picture != null) {
ActFmCameraModule.showPictureLauncher(CommentsFragment.this, clearImage);
- else
+ } else {
ActFmCameraModule.showPictureLauncher(CommentsFragment.this, null);
+ }
}
});
@@ -235,8 +236,9 @@ public abstract class CommentsFragment extends SherlockListFragment {
protected void refreshUpdatesList() {
Activity activity = getActivity();
View view = getView();
- if (activity == null || view == null)
+ if (activity == null || view == null) {
return;
+ }
Cursor cursor = null;
ListView listView = ((ListView) view.findViewById(android.R.id.list));
@@ -287,8 +289,9 @@ public abstract class CommentsFragment extends SherlockListFragment {
listView.setVisibility(View.VISIBLE);
}
- if (activity instanceof CommentsActivity)
+ if (activity instanceof CommentsActivity) {
setLastViewed();
+ }
}
@@ -305,8 +308,9 @@ public abstract class CommentsFragment extends SherlockListFragment {
int historyCount = 0;
Cursor c = updateAdapter.getCursor();
for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) {
- if (NameMaps.TABLE_ID_HISTORY.equals(c.getString(UpdateAdapter.TYPE_PROPERTY_INDEX)))
+ if (NameMaps.TABLE_ID_HISTORY.equals(c.getString(UpdateAdapter.TYPE_PROPERTY_INDEX))) {
historyCount++;
+ }
}
loadMoreHistory(historyCount, doneRunnable);
}
@@ -327,7 +331,7 @@ public abstract class CommentsFragment extends SherlockListFragment {
public void runOnSuccess() {
synchronized (this) {
Activity activity = getActivity();
- if (activity != null)
+ if (activity != null) {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
@@ -335,6 +339,7 @@ public abstract class CommentsFragment extends SherlockListFragment {
refreshUpdatesList();
}
});
+ }
}
}
@@ -354,8 +359,9 @@ public abstract class CommentsFragment extends SherlockListFragment {
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- if (menu.size() > 0)
+ if (menu.size() > 0) {
return;
+ }
MenuItem item;
boolean showCommentsRefresh = actFmPreferenceService.isLoggedIn();
diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/EditPeopleControlSet.java b/astrid/plugin-src/com/todoroo/astrid/actfm/EditPeopleControlSet.java
index d4bf272d7..9c873f9a1 100644
--- a/astrid/plugin-src/com/todoroo/astrid/actfm/EditPeopleControlSet.java
+++ b/astrid/plugin-src/com/todoroo/astrid/actfm/EditPeopleControlSet.java
@@ -164,8 +164,9 @@ public class EditPeopleControlSet extends PopupControlSet {
@Override
public void readFromTask(Task sourceTask) {
setTask(sourceTask);
- if (!dontClearAssignedCustom)
+ if (!dontClearAssignedCustom) {
assignedCustom.setText(""); //$NON-NLS-1$
+ }
dontClearAssignedCustom = false;
setUpData(task, null);
}
@@ -303,8 +304,9 @@ public class EditPeopleControlSet extends PopupControlSet {
.put(CONTACT_CHOOSER_USER, true));
int contactsIndex = addUnassigned ? 2 : 1;
boolean addContactPicker = Preferences.getBoolean(R.string.p_use_contact_picker, true) && contactPickerAvailable();
- if (addContactPicker)
+ if (addContactPicker) {
coreUsers.add(contactsIndex, contactPickerUser);
+ }
if (assignedIndex == 0) {
assignedIndex = findAssignedIndex(t, coreUsers, listUsers, astridUsers);
@@ -354,8 +356,9 @@ public class EditPeopleControlSet extends PopupControlSet {
return Long.toString(value);
} catch (JSONException e) {
String value = obj.optString("id"); //$NON-NLS-1$
- if (TextUtils.isEmpty(value))
+ if (TextUtils.isEmpty(value)) {
value = defaultValue;
+ }
return value;
}
}
@@ -366,23 +369,28 @@ public class EditPeopleControlSet extends PopupControlSet {
ArrayList users = new ArrayList();
for (int i = 0; i < jsonUsers.size(); i++) {
JSONObject person = jsonUsers.get(i);
- if (person == null)
+ if (person == null) {
continue;
+ }
String id = getLongOrStringId(person, Task.USER_ID_EMAIL);
- if (ActFmPreferenceService.userId().equals(id) || ((Task.USER_ID_UNASSIGNED.equals(id) || Task.isRealUserId(id)) && userIds.contains(id)))
+ if (ActFmPreferenceService.userId().equals(id) || ((Task.USER_ID_UNASSIGNED.equals(id) || Task.isRealUserId(id)) && userIds.contains(id))) {
continue;
+ }
userIds.add(id);
String email = person.optString("email");
- if (!TextUtils.isEmpty(email) && emails.contains(email))
+ if (!TextUtils.isEmpty(email) && emails.contains(email)) {
continue;
+ }
emails.add(email);
String name = person.optString("name");
- if (Task.USER_ID_SELF.equals(id))
+ if (Task.USER_ID_SELF.equals(id)) {
name = activity.getString(R.string.actfm_EPA_assign_me);
- if (Task.USER_ID_UNASSIGNED.equals(id))
+ }
+ if (Task.USER_ID_UNASSIGNED.equals(id)) {
name = activity.getString(R.string.actfm_EPA_unassigned);
+ }
AssignedToUser atu = new AssignedToUser(name, person);
users.add(atu);
@@ -392,15 +400,18 @@ public class EditPeopleControlSet extends PopupControlSet {
user.label += " (" + user.user.optString("email") + ")";
names.put(name, null);
}
- if (!TextUtils.isEmpty(email))
+ if (!TextUtils.isEmpty(email)) {
atu.label += " (" + email + ")";
+ }
} else if (TextUtils.isEmpty(name) || "null".equals(name)) {
- if (!TextUtils.isEmpty(email))
+ if (!TextUtils.isEmpty(email)) {
atu.label = email;
- else
+ } else {
users.remove(atu);
- } else
+ }
+ } else {
names.put(name, atu);
+ }
}
return users;
}
@@ -445,8 +456,9 @@ public class EditPeopleControlSet extends PopupControlSet {
}
if (getLongOrStringId(user, Task.USER_ID_EMAIL).equals(assignedId) ||
(user.optString("email").equals(assignedEmail) &&
- !(TextUtils.isEmpty(assignedEmail))))
+ !(TextUtils.isEmpty(assignedEmail)))) {
return index;
+ }
}
index++;
}
@@ -490,8 +502,9 @@ public class EditPeopleControlSet extends PopupControlSet {
@SuppressWarnings("nls")
@Override
public View getView(int position, View convertView, ViewGroup parent) {
- if (convertView == null)
+ if (convertView == null) {
convertView = activity.getLayoutInflater().inflate(R.layout.assigned_adapter_row, parent, false);
+ }
CheckedTextView ctv = (CheckedTextView) convertView.findViewById(android.R.id.text1);
super.getView(position, ctv, parent);
if (assignedList.getCheckedItemPosition() == position + positionOffset) {
@@ -581,8 +594,9 @@ public class EditPeopleControlSet extends PopupControlSet {
@Override
public String writeToModel(Task t) {
- if (initialized && dialog != null)
+ if (initialized && dialog != null) {
dialog.dismiss();
+ }
// do nothing else, we use a separate method
return null;
}
@@ -610,8 +624,9 @@ public class EditPeopleControlSet extends PopupControlSet {
*/
@SuppressWarnings("nls")
public boolean saveSharingSettings(String toast) {
- if (task == null)
+ if (task == null) {
return false;
+ }
boolean dirty = false;
try {
@@ -621,8 +636,9 @@ public class EditPeopleControlSet extends PopupControlSet {
userJson = PeopleContainer.createUserJson(assignedCustom);
assignedView = assignedCustom;
} else {
- if (!loadedUI || assignedList.getCheckedItemPosition() == ListView.INVALID_POSITION)
+ if (!loadedUI || assignedList.getCheckedItemPosition() == ListView.INVALID_POSITION) {
return true;
+ }
AssignedToUser item = (AssignedToUser) assignedList.getAdapter().getItem(assignedList.getCheckedItemPosition());
if (item != null) {
if (item.equals(contactPickerUser)) { //don't want to ever set the user as the fake contact picker user
@@ -634,9 +650,10 @@ public class EditPeopleControlSet extends PopupControlSet {
if (userJson != null) {
String email = userJson.optString("email");
- if (!TextUtils.isEmpty(email) && email.indexOf('@') == -1)
+ if (!TextUtils.isEmpty(email) && email.indexOf('@') == -1) {
throw new ParseSharedException(assignedView,
activity.getString(R.string.actfm_EPA_invalid_email, userJson.optString("email")));
+ }
}
if (userJson == null || Task.USER_ID_SELF.equals(getLongOrStringId(userJson, Task.USER_ID_EMAIL))) {
@@ -659,8 +676,9 @@ public class EditPeopleControlSet extends PopupControlSet {
} catch (JSONException e) {
// sad times
taskUserId = task.getValue(Task.USER_ID);
- if (Task.userIdIsEmail(taskUserId))
+ if (Task.userIdIsEmail(taskUserId)) {
taskUserEmail = taskUserId;
+ }
}
String userId = getLongOrStringId(userJson, Task.USER_ID_EMAIL);
String userEmail = userJson.optString("email");
@@ -671,8 +689,9 @@ public class EditPeopleControlSet extends PopupControlSet {
dirty = match ? dirty : true;
String willAssignToId = getLongOrStringId(userJson, Task.USER_ID_EMAIL);
task.setValue(Task.USER_ID, willAssignToId);
- if (Task.USER_ID_EMAIL.equals(task.getValue(Task.USER_ID)))
+ if (Task.USER_ID_EMAIL.equals(task.getValue(Task.USER_ID))) {
task.setValue(Task.USER_ID, userEmail);
+ }
task.setValue(Task.USER, "");
}
@@ -702,10 +721,11 @@ public class EditPeopleControlSet extends PopupControlSet {
task.putTransitory(TaskService.TRANS_ASSIGNED, true);
- if (assignedView == assignedCustom)
+ if (assignedView == assignedCustom) {
StatisticsService.reportEvent(StatisticsConstants.TASK_ASSIGNED_EMAIL);
- else if (task.getValue(Task.USER_ID) != Task.USER_ID_SELF)
+ } else if (task.getValue(Task.USER_ID) != Task.USER_ID_SELF) {
StatisticsService.reportEvent(StatisticsConstants.TASK_ASSIGNED_PICKER);
+ }
return true;
} catch (ParseSharedException e) {
@@ -740,14 +760,16 @@ public class EditPeopleControlSet extends PopupControlSet {
userJson = PeopleContainer.createUserJson(assignedCustom);
} else {
if (!hasLoadedUI() || assignedList.getCheckedItemPosition() == ListView.INVALID_POSITION) {
- if (task != null)
+ if (task != null) {
return task.getValue(Task.USER_ID) == Task.USER_ID_SELF;
- else
+ } else {
return true;
+ }
}
AssignedToUser item = (AssignedToUser) assignedList.getAdapter().getItem(assignedList.getCheckedItemPosition());
- if (item != null)
+ if (item != null) {
userJson = item.user;
+ }
}
if (userJson == null || Task.USER_ID_SELF.equals(getLongOrStringId(userJson, Task.USER_ID_EMAIL))) {
@@ -800,8 +822,9 @@ public class EditPeopleControlSet extends PopupControlSet {
assignedCustom.setText(email);
dontClearAssignedCustom = true;
refreshDisplayView();
- if (dialog != null)
+ if (dialog != null) {
dialog.dismiss();
+ }
} else {
DialogUtilities.okDialog(activity, activity.getString(R.string.TEA_contact_error), null);
}
@@ -819,8 +842,9 @@ public class EditPeopleControlSet extends PopupControlSet {
displayString = activity.getString(R.string.TEA_assigned_to, assignedCustom.getText());
} else {
AssignedToUser user = (AssignedToUser) assignedList.getAdapter().getItem(assignedList.getCheckedItemPosition());
- if (user == null)
+ if (user == null) {
user = (AssignedToUser) assignedList.getAdapter().getItem(0);
+ }
String id = getLongOrStringId(user.user, Task.USER_ID_IGNORE);
if (Task.USER_ID_UNASSIGNED.equals(id)) {
@@ -828,8 +852,9 @@ public class EditPeopleControlSet extends PopupControlSet {
displayString = activity.getString(R.string.actfm_EPA_unassigned);
} else {
String userString = user.toString();
- if (Task.USER_ID_SELF.equals(id))
+ if (Task.USER_ID_SELF.equals(id)) {
userString = userString.toLowerCase();
+ }
displayString = activity.getString(R.string.TEA_assigned_to, userString);
}
@@ -838,10 +863,11 @@ public class EditPeopleControlSet extends PopupControlSet {
assignedDisplay.setTextColor(unassigned ? unsetColor : themeColor);
assignedDisplay.setText(displayString);
- if (unassigned)
+ if (unassigned) {
image.setImageResource(R.drawable.tea_icn_assign_gray);
- else
+ } else {
image.setImageResource(ThemeService.getTaskEditDrawable(R.drawable.tea_icn_assign, R.drawable.tea_icn_assign_lightblue));
+ }
}
@Override
diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/TagCommentsFragment.java b/astrid/plugin-src/com/todoroo/astrid/actfm/TagCommentsFragment.java
index 5ed009453..8987bf146 100644
--- a/astrid/plugin-src/com/todoroo/astrid/actfm/TagCommentsFragment.java
+++ b/astrid/plugin-src/com/todoroo/astrid/actfm/TagCommentsFragment.java
@@ -66,8 +66,9 @@ public class TagCommentsFragment extends CommentsFragment {
protected void loadModelFromIntent(Intent intent) {
if (tagData == null) {
long id = intent.getLongExtra(TagViewFragment.EXTRA_TAG_DATA, 0);
- if (id > 0)
+ if (id > 0) {
tagData = tagDataService.fetchById(id, TagData.PROPERTIES);
+ }
}
}
@@ -120,7 +121,9 @@ public class TagCommentsFragment extends CommentsFragment {
@Override
protected void populateListHeader(ViewGroup header) {
- if (header == null) return;
+ if (header == null) {
+ return;
+ }
TextView tagTitle = (TextView) header.findViewById(R.id.tag_title);
String tagName = tagData.getValue(TagData.NAME);
tagTitle.setText(tagName);
@@ -138,12 +141,14 @@ public class TagCommentsFragment extends CommentsFragment {
imageView.setDefaultImageDrawable(ResourceDrawableCache.getImageDrawableFromId(getResources(), TagService.getDefaultImageIDForTag(tagData.getUuid())));
String imageUrl = tagData.getPictureUrl(TagData.PICTURE, RemoteModel.PICTURE_MEDIUM);
Bitmap imageBitmap = null;
- if (TextUtils.isEmpty(imageUrl))
+ if (TextUtils.isEmpty(imageUrl)) {
imageBitmap = tagData.getPictureBitmap(TagData.PICTURE);
- if (imageBitmap != null)
+ }
+ if (imageBitmap != null) {
imageView.setImageBitmap(imageBitmap);
- else
+ } else {
imageView.setUrl(imageUrl);
+ }
}
@Override
@@ -177,8 +182,9 @@ public class TagCommentsFragment extends CommentsFragment {
if (tagData != null && RemoteModel.isValidUuid(tagData.getValue(TagData.UUID))) {
Preferences.setLong(UPDATES_LAST_VIEWED + tagData.getValue(TagData.UUID), DateUtilities.now());
Activity activity = getActivity();
- if (activity instanceof TaskListActivity)
+ if (activity instanceof TaskListActivity) {
((TaskListActivity) activity).setCommentsCount(0);
+ }
}
}
diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/TagSettingsActivity.java b/astrid/plugin-src/com/todoroo/astrid/actfm/TagSettingsActivity.java
index cc9ffe0e4..8ce570ae2 100644
--- a/astrid/plugin-src/com/todoroo/astrid/actfm/TagSettingsActivity.java
+++ b/astrid/plugin-src/com/todoroo/astrid/actfm/TagSettingsActivity.java
@@ -141,10 +141,11 @@ public class TagSettingsActivity extends SherlockFragmentActivity {
params.height = LayoutParams.WRAP_CONTENT;
DisplayMetrics metrics = getResources().getDisplayMetrics();
- if ((metrics.widthPixels / metrics.density) >= AndroidUtilities.MIN_TABLET_HEIGHT)
+ if ((metrics.widthPixels / metrics.density) >= AndroidUtilities.MIN_TABLET_HEIGHT) {
params.width = (3 * metrics.widthPixels) / 5;
- else if ((metrics.widthPixels / metrics.density) >= AndroidUtilities.MIN_TABLET_WIDTH)
+ } else if ((metrics.widthPixels / metrics.density) >= AndroidUtilities.MIN_TABLET_WIDTH) {
params.width = (4 * metrics.widthPixels) / 5;
+ }
getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);
}
@@ -188,16 +189,18 @@ public class TagSettingsActivity extends SherlockFragmentActivity {
isDialog = AstridPreferences.useTabletLayout(this);
if (isDialog) {
setTheme(ThemeService.getDialogTheme());
- if (AndroidUtilities.getSdkVersion() < 14)
+ if (AndroidUtilities.getSdkVersion() < 14) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
+ }
} else {
ThemeService.applyTheme(this);
ActionBar actionBar = getSupportActionBar();
if (Preferences.getBoolean(R.string.p_save_and_cancel, false)) {
- if (ThemeService.getTheme() == R.style.Theme_White_Alt)
+ if (ThemeService.getTheme() == R.style.Theme_White_Alt) {
actionBar.setLogo(R.drawable.ic_menu_save_blue_alt);
- else
+ } else {
actionBar.setLogo(R.drawable.ic_menu_save);
+ }
} else {
actionBar.setLogo(null);
}
@@ -324,8 +327,9 @@ public class TagSettingsActivity extends SherlockFragmentActivity {
if (setBitmap != null) {
JSONObject pictureJson = RemoteModel.PictureHelper.savePictureJson(this, setBitmap);
- if (pictureJson != null)
+ if (pictureJson != null) {
tagData.setValue(TagData.PICTURE, pictureJson.toString());
+ }
}
JSONArray members;
@@ -342,8 +346,9 @@ public class TagSettingsActivity extends SherlockFragmentActivity {
DialogUtilities.okDialog(this, e.message, null);
return;
}
- if (members == null)
+ if (members == null) {
members = new JSONArray();
+ }
if (members.length() > 0 && !actFmPreferenceService.isLoggedIn()) {
if (newName.length() > 0 && oldName.length() == 0) {
@@ -400,7 +405,9 @@ public class TagSettingsActivity extends SherlockFragmentActivity {
}
private void saveTagPictureLocally(Bitmap bitmap) {
- if (bitmap == null) return;
+ if (bitmap == null) {
+ return;
+ }
try {
String tagPicture = RemoteModel.PictureHelper.getPictureHash(tagData);
imageCache.put(tagPicture, bitmap);
@@ -443,13 +450,15 @@ public class TagSettingsActivity extends SherlockFragmentActivity {
String imageUrl = tagData.getPictureUrl(TagData.PICTURE, RemoteModel.PICTURE_MEDIUM);
Bitmap imageBitmap = null;
- if (TextUtils.isEmpty(imageUrl))
+ if (TextUtils.isEmpty(imageUrl)) {
imageBitmap = tagData.getPictureBitmap(TagData.PICTURE);
+ }
- if (imageBitmap != null)
+ if (imageBitmap != null) {
picture.setImageBitmap(imageBitmap);
- else
+ } else {
picture.setUrl(imageUrl);
+ }
if (!isNewTag) {
ImageView shortcut = (ImageView) findViewById(R.id.create_shortcut);
shortcut.setImageBitmap(FilterListFragment.superImposeListIcon(this, picture.getImageBitmap(), tagData.getUuid()));
@@ -604,22 +613,25 @@ public class TagSettingsActivity extends SherlockFragmentActivity {
break;
case android.R.id.home:
saveSettings();
- if (!isFinishing())
+ if (!isFinishing()) {
finish();
+ }
break;
}
return super.onOptionsItemSelected(item);
}
protected void showDeleteDialog(TagData td) {
- if (td == null)
+ if (td == null) {
return;
+ }
int string;
- if (td.getValue(TagData.MEMBER_COUNT) > 0)
+ if (td.getValue(TagData.MEMBER_COUNT) > 0) {
string = R.string.DLG_leave_this_shared_tag_question;
- else
+ } else {
string = R.string.DLG_delete_this_tag_question;
+ }
DialogUtilities.okCancelDialog(this, getString(string, td.getValue(TagData.NAME)),
diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/TagViewFragment.java b/astrid/plugin-src/com/todoroo/astrid/actfm/TagViewFragment.java
index 25e3157d2..21969bed5 100644
--- a/astrid/plugin-src/com/todoroo/astrid/actfm/TagViewFragment.java
+++ b/astrid/plugin-src/com/todoroo/astrid/actfm/TagViewFragment.java
@@ -174,8 +174,9 @@ public class TagViewFragment extends TaskListFragment {
((EditText) getView().findViewById(R.id.quickAddText)).setOnTouchListener(onTouch);
View membersEdit = getView().findViewById(R.id.members_edit);
- if (membersEdit != null)
+ if (membersEdit != null) {
membersEdit.setOnClickListener(settingsListener);
+ }
originalFilter = filter;
}
@@ -213,14 +214,16 @@ public class TagViewFragment extends TaskListFragment {
}
private void showListSettingsPopover() {
- if (!AstridPreferences.canShowPopover())
+ if (!AstridPreferences.canShowPopover()) {
return;
+ }
if (!Preferences.getBoolean(R.string.p_showed_list_settings_help, false)) {
Preferences.setBoolean(R.string.p_showed_list_settings_help, true);
View tabView = getView().findViewById(R.id.members_edit);
- if (tabView != null)
+ if (tabView != null) {
HelpInfoPopover.showPopover(getActivity(), tabView,
R.string.help_popover_list_settings, null);
+ }
}
}
@@ -249,22 +252,26 @@ public class TagViewFragment extends TaskListFragment {
@Override
protected void initializeData() {
synchronized (this) {
- if (dataLoaded)
+ if (dataLoaded) {
return;
+ }
dataLoaded = true;
}
TaskListActivity activity = (TaskListActivity) getActivity();
String tag = extras.getString(EXTRA_TAG_NAME);
String uuid = RemoteModel.NO_UUID;
- if (extras.containsKey(EXTRA_TAG_UUID))
+ if (extras.containsKey(EXTRA_TAG_UUID)) {
uuid = extras.getString(EXTRA_TAG_UUID);
- else if (extras.containsKey(EXTRA_TAG_REMOTE_ID)) // For legacy support with shortcuts, widgets, etc.
+ } else if (extras.containsKey(EXTRA_TAG_REMOTE_ID)) // For legacy support with shortcuts, widgets, etc.
+ {
uuid = Long.toString(extras.getLong(EXTRA_TAG_REMOTE_ID));
+ }
- if (tag == null && RemoteModel.NO_UUID.equals(uuid))
+ if (tag == null && RemoteModel.NO_UUID.equals(uuid)) {
return;
+ }
TodorooCursor cursor;
if (!RemoteModel.isUuidEmpty(uuid)) {
@@ -305,8 +312,9 @@ public class TagViewFragment extends TaskListFragment {
@Override
public void loadTaskListContent(boolean requery) {
super.loadTaskListContent(requery);
- if (taskAdapter == null || taskAdapter.getCursor() == null)
+ if (taskAdapter == null || taskAdapter.getCursor() == null) {
return;
+ }
int count = taskAdapter.getCursor().getCount();
@@ -336,8 +344,9 @@ public class TagViewFragment extends TaskListFragment {
}
TaskListActivity tla = (TaskListActivity) getActivity();
- if (tla != null)
+ if (tla != null) {
tla.setCommentsCount(unreadCount);
+ }
}
}
@@ -346,8 +355,9 @@ public class TagViewFragment extends TaskListFragment {
@Override
protected void initiateAutomaticSyncImpl() {
- if (!isCurrentTaskListFragment())
+ if (!isCurrentTaskListFragment()) {
return;
+ }
if (tagData != null) {
long lastAutosync = tagData.getValue(TagData.LAST_AUTOSYNC);
if (DateUtilities.now() - lastAutosync > AUTOSYNC_INTERVAL) {
@@ -478,8 +488,9 @@ public class TagViewFragment extends TaskListFragment {
getView().findViewById(R.id.members_header).setVisibility(View.GONE);
return;
}
- if (tagData == null)
+ if (tagData == null) {
return;
+ }
LinearLayout membersView = (LinearLayout) getView().findViewById(R.id.shared_with);
membersView.setOnClickListener(settingsListener);
boolean addedMembers = false;
@@ -567,8 +578,9 @@ public class TagViewFragment extends TaskListFragment {
} else {
owner = ActFmPreferenceService.thisUser();
}
- if (owner != null)
+ if (owner != null) {
addImageForMember(membersView, owner);
+ }
JSONObject unassigned = new JSONObject();
unassigned.put("id", Task.USER_ID_UNASSIGNED); //$NON-NLS-1$
@@ -585,13 +597,14 @@ public class TagViewFragment extends TaskListFragment {
}
View filterAssigned = getView().findViewById(R.id.filter_assigned);
- if (filterAssigned != null)
+ if (filterAssigned != null) {
filterAssigned.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
resetAssignedFilter();
}
});
+ }
}
@SuppressWarnings("nls")
@@ -604,14 +617,16 @@ public class TagViewFragment extends TaskListFragment {
image.setDefaultImageDrawable(ResourceDrawableCache.getImageDrawableFromId(resources, R.drawable.icn_default_person_image));
- if (Task.USER_ID_UNASSIGNED.equals(Long.toString(member.optLong("id", 0))))
+ if (Task.USER_ID_UNASSIGNED.equals(Long.toString(member.optLong("id", 0)))) {
image.setDefaultImageDrawable(ResourceDrawableCache.getImageDrawableFromId(resources, R.drawable.icn_anyone));
+ }
image.setScaleType(ImageView.ScaleType.FIT_CENTER);
try {
final String id = Long.toString(member.optLong("id", -2));
- if (ActFmPreferenceService.userId().equals(id))
+ if (ActFmPreferenceService.userId().equals(id)) {
member = ActFmPreferenceService.thisUser();
+ }
final JSONObject memberToUse = member;
final String memberName = displayName(memberToUse);
@@ -641,21 +656,23 @@ public class TagViewFragment extends TaskListFragment {
// New filter
currentId = id;
Criterion assignedCriterion;
- if (ActFmPreferenceService.userId().equals(currentId))
+ if (ActFmPreferenceService.userId().equals(currentId)) {
assignedCriterion = Criterion.or(Task.USER_ID.eq(0), Task.USER_ID.eq(id));
- else if (Task.userIdIsEmail(currentId) && !TextUtils.isEmpty(email))
+ } else if (Task.userIdIsEmail(currentId) && !TextUtils.isEmpty(email)) {
assignedCriterion = Criterion.or(Task.USER_ID.eq(email), Task.USER.like("%" + email + "%")); //$NON-NLS-1$ //$NON-NLS-2$ // Deprecated field OK for backwards compatibility
- else
+ } else {
assignedCriterion = Task.USER_ID.eq(id);
+ }
Criterion assigned = Criterion.and(TaskCriteria.activeAndVisible(), assignedCriterion);
filter = TagFilterExposer.filterFromTag(getActivity(), new Tag(tagData), assigned);
TextView filterByAssigned = (TextView) getView().findViewById(R.id.filter_assigned);
if (filterByAssigned != null) {
filterByAssigned.setVisibility(View.VISIBLE);
- if (id == Task.USER_ID_UNASSIGNED)
+ if (id == Task.USER_ID_UNASSIGNED) {
filterByAssigned.setText(getString(R.string.actfm_TVA_filter_by_unassigned));
- else
+ } else {
filterByAssigned.setText(getString(R.string.actfm_TVA_filtered_by_assign, displayName));
+ }
}
isBeingFiltered.set(true);
setUpTaskList();
@@ -669,8 +686,9 @@ public class TagViewFragment extends TaskListFragment {
isBeingFiltered.set(false);
filter = originalFilter;
View filterAssigned = getView().findViewById(R.id.filter_assigned);
- if (filterAssigned != null)
+ if (filterAssigned != null) {
filterAssigned.setVisibility(View.GONE);
+ }
setUpTaskList();
}
@@ -703,10 +721,12 @@ public class TagViewFragment extends TaskListFragment {
@SuppressWarnings("nls")
@Override
public void onReceive(Context context, Intent intent) {
- if (!intent.hasExtra("tag_id"))
+ if (!intent.hasExtra("tag_id")) {
return;
- if (tagData == null || !tagData.getValue(TagData.UUID).toString().equals(intent.getStringExtra("tag_id")))
+ }
+ if (tagData == null || !tagData.getValue(TagData.UUID).toString().equals(intent.getStringExtra("tag_id"))) {
return;
+ }
getActivity().runOnUiThread(new Runnable() {
@Override
@@ -775,10 +795,11 @@ public class TagViewFragment extends TaskListFragment {
((TaskListActivity) activity).setListsTitle(filter.title);
FilterListFragment flf = ((TaskListActivity) activity).getFilterListFragment();
if (flf != null) {
- if (!onActivityResult)
+ if (!onActivityResult) {
flf.refresh();
- else
+ } else {
flf.clear();
+ }
}
}
taskAdapter = null;
@@ -818,9 +839,9 @@ public class TagViewFragment extends TaskListFragment {
protected void toggleDragDrop(boolean newState) {
Class> customComponent;
- if (newState)
+ if (newState) {
customComponent = SubtasksTagListFragment.class;
- else {
+ } else {
filter.setFilterQueryOverride(null);
customComponent = TagViewFragment.class;
}
diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/WaitingOnMeFragment.java b/astrid/plugin-src/com/todoroo/astrid/actfm/WaitingOnMeFragment.java
index 3ea74d394..e82257030 100644
--- a/astrid/plugin-src/com/todoroo/astrid/actfm/WaitingOnMeFragment.java
+++ b/astrid/plugin-src/com/todoroo/astrid/actfm/WaitingOnMeFragment.java
@@ -42,8 +42,9 @@ public class WaitingOnMeFragment extends TaskListFragment {
new OnCompletedTaskListener() {
@Override
public void onCompletedTask(Task item, boolean newState) {
- if (newState == true)
+ if (newState == true) {
onTaskCompleted(item);
+ }
}
});
}
@@ -61,10 +62,11 @@ public class WaitingOnMeFragment extends TaskListFragment {
super.setTaskAppearance(viewHolder, task);
TextView nameView = viewHolder.nameView;
- if (task.getValue(WaitingOnMe.READ_AT) == 0 && task.getValue(WaitingOnMe.ACKNOWLEDGED) == 0)
+ if (task.getValue(WaitingOnMe.READ_AT) == 0 && task.getValue(WaitingOnMe.ACKNOWLEDGED) == 0) {
nameView.setTypeface(null, Typeface.BOLD);
- else
+ } else {
nameView.setTypeface(null, 0);
+ }
}
}
diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmInvoker.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmInvoker.java
index 95804a0e7..196329a0f 100644
--- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmInvoker.java
+++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmInvoker.java
@@ -132,16 +132,19 @@ public class ActFmInvoker {
try {
String request = createFetchUrl(api, method, getParameters);
- if (SYNC_DEBUG)
+ if (SYNC_DEBUG) {
Log.e("act-fm-invoke", request);
+ }
String response = restClient.get(request);
JSONObject object = new JSONObject(response);
- if (SYNC_DEBUG)
+ if (SYNC_DEBUG) {
AndroidUtilities.logJSONObject("act-fm-invoke-response", object);
- if (object.getString("status").equals("error"))
+ }
+ if (object.getString("status").equals("error")) {
throw new ActFmServiceException(object.getString("message"), object);
+ }
return object;
} catch (JSONException e) {
throw new IOException(e.getMessage());
@@ -163,17 +166,20 @@ public class ActFmInvoker {
try {
String request = createFetchUrl(null, method, getParameters);
- if (SYNC_DEBUG)
+ if (SYNC_DEBUG) {
Log.e("act-fm-post", request);
+ }
String response = restClient.post(request, data);
JSONObject object = new JSONObject(response);
- if (SYNC_DEBUG)
+ if (SYNC_DEBUG) {
AndroidUtilities.logJSONObject("act-fm-post-response", object);
+ }
- if (object.getString("status").equals("error"))
+ if (object.getString("status").equals("error")) {
throw new ActFmServiceException(object.getString("message"), object);
+ }
return object;
} catch (JSONException e) {
throw new IOException(e.getMessage());
@@ -199,8 +205,9 @@ public class ActFmInvoker {
}
String request = createFetchUrl("api/" + API_VERSION, "synchronize", params);
- if (SYNC_DEBUG)
+ if (SYNC_DEBUG) {
Log.e("act-fm-post", request);
+ }
Charset chars;
try {
chars = Charset.forName("UTF-8");
@@ -215,11 +222,13 @@ public class ActFmInvoker {
String response = restClient.post(request, entity);
JSONObject object = new JSONObject(response);
- if (SYNC_DEBUG)
+ if (SYNC_DEBUG) {
AndroidUtilities.logJSONObject("act-fm-post-response", object);
+ }
- if (object.getString("status").equals("error"))
+ if (object.getString("status").equals("error")) {
throw new ActFmServiceException(object.getString("message"), object);
+ }
return object;
} catch (JSONException e) {
throw new IOException(e.getMessage());
@@ -242,17 +251,20 @@ public class ActFmInvoker {
for (int i = 0; i < getParameters.length; i += 2) {
if (getParameters[i + 1] instanceof ArrayList) {
ArrayList> list = (ArrayList>) getParameters[i + 1];
- for (int j = 0; j < list.size(); j++)
+ for (int j = 0; j < list.size(); j++) {
params.add(new Pair(getParameters[i].toString() + "[]",
list.get(j)));
- } else
+ }
+ } else {
params.add(new Pair(getParameters[i].toString(), getParameters[i + 1]));
+ }
}
params.add(new Pair("app_id", APP_ID));
boolean syncMethod = "synchronize".equals(method);
- if (!syncMethod)
+ if (!syncMethod) {
params.add(new Pair("time", System.currentTimeMillis() / 1000L));
+ }
if (token != null) {
boolean foundTokenKey = false;
for (Pair curr : params) {
@@ -261,8 +273,9 @@ public class ActFmInvoker {
break;
}
}
- if (!foundTokenKey)
+ if (!foundTokenKey) {
params.add(new Pair("token", token));
+ }
}
Collections.sort(params, new Comparator>() {
@@ -270,8 +283,9 @@ public class ActFmInvoker {
public int compare(Pair object1,
Pair object2) {
int result = object1.getLeft().compareTo(object2.getLeft());
- if (result == 0)
+ if (result == 0) {
return object1.getRight().toString().compareTo(object2.getRight().toString());
+ }
return result;
}
});
@@ -282,26 +296,30 @@ public class ActFmInvoker {
customApi = true;
url = url.replace("api", api);
}
- if (Preferences.getBoolean(R.string.actfm_https_key, false))
+ if (Preferences.getBoolean(R.string.actfm_https_key, false)) {
url = "https:" + url;
- else
+ } else {
url = "http:" + url;
+ }
StringBuilder requestBuilder = new StringBuilder(url);
- if (!customApi)
+ if (!customApi) {
requestBuilder.append(API_VERSION).append("/");
+ }
requestBuilder.append(method).append('?');
StringBuilder sigBuilder = new StringBuilder(method);
for (Pair entry : params) {
- if (entry.getRight() == null)
+ if (entry.getRight() == null) {
continue;
+ }
String key = entry.getLeft();
String value = entry.getRight().toString();
String encoded = URLEncoder.encode(value, "UTF-8");
- if (!syncMethod || "app_id".equals(key))
+ if (!syncMethod || "app_id".equals(key)) {
requestBuilder.append(key).append('=').append(encoded).append('&');
+ }
sigBuilder.append(key).append(value);
}
diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmPreferenceService.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmPreferenceService.java
index 1b8c581ff..1dcfdd377 100644
--- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmPreferenceService.java
+++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmPreferenceService.java
@@ -51,8 +51,9 @@ public class ActFmPreferenceService extends SyncProviderUtilities {
@Override
public boolean shouldShowToast() {
- if (Preferences.getBoolean(AstridPreferences.P_FIRST_TASK, true))
+ if (Preferences.getBoolean(AstridPreferences.P_FIRST_TASK, true)) {
return false;
+ }
return super.shouldShowToast();
}
@@ -61,10 +62,11 @@ public class ActFmPreferenceService extends SyncProviderUtilities {
@Override
public void setToken(String setting) {
super.setToken(setting);
- if (TextUtils.isEmpty(setting))
+ if (TextUtils.isEmpty(setting)) {
RemoteModelDao.setOutstandingEntryFlags(RemoteModelDao.OUTSTANDING_FLAG_UNINITIALIZED);
- else
+ } else {
RemoteModelDao.setOutstandingEntryFlags(RemoteModelDao.OUTSTANDING_ENTRY_FLAG_ENQUEUE_MESSAGES | RemoteModelDao.OUTSTANDING_ENTRY_FLAG_RECORD_OUTSTANDING);
+ }
}
/**
@@ -80,8 +82,9 @@ public class ActFmPreferenceService extends SyncProviderUtilities {
public static String userId() {
try {
String value = Preferences.getStringValue(PREF_USER_ID);
- if (value == null)
+ if (value == null) {
return Long.toString(Preferences.getLong(PREF_USER_ID, -2L));
+ }
return value;
} catch (Exception e) {
return Long.toString(Preferences.getLong(PREF_USER_ID, -2L));
@@ -149,8 +152,9 @@ public class ActFmPreferenceService extends SyncProviderUtilities {
}
public synchronized static void reloadThisUser() {
- if (user == null)
+ if (user == null) {
return;
+ }
populateUser();
}
@@ -170,8 +174,9 @@ public class ActFmPreferenceService extends SyncProviderUtilities {
}
public static boolean isPremiumUser() {
- if (Preferences.getBoolean(PremiumUnlockService.PREF_KILL_SWITCH, false))
+ if (Preferences.getBoolean(PremiumUnlockService.PREF_KILL_SWITCH, false)) {
return true;
+ }
if (Preferences.getBoolean(BillingConstants.PREF_NEEDS_SERVER_UPDATE, false)) {
return Preferences.getBoolean(PREF_LOCAL_PREMIUM, false);
@@ -190,18 +195,21 @@ public class ActFmPreferenceService extends SyncProviderUtilities {
String name = Preferences.getStringValue(PREF_NAME);
if (TextUtils.isEmpty(name)) {
String firstName = Preferences.getStringValue(PREF_FIRST_NAME);
- if (!TextUtils.isEmpty(firstName))
+ if (!TextUtils.isEmpty(firstName)) {
name = firstName;
+ }
String lastName = Preferences.getStringValue(PREF_FIRST_NAME);
if (!TextUtils.isEmpty(lastName)) {
- if (!TextUtils.isEmpty(name))
+ if (!TextUtils.isEmpty(name)) {
name += " "; //$NON-NLS-1$
+ }
name += lastName;
}
- if (name == null)
+ if (name == null) {
name = ""; //$NON-NLS-1$
+ }
}
return name;
}
@@ -211,19 +219,23 @@ public class ActFmPreferenceService extends SyncProviderUtilities {
JSONObject thisUser = thisUser();
String name = thisUser.optString("name");
- if (!(TextUtils.isEmpty(name) || "null".equals(name)))
+ if (!(TextUtils.isEmpty(name) || "null".equals(name))) {
return name;
+ }
String firstName = thisUser.optString("first_name");
boolean firstNameEmpty = TextUtils.isEmpty(firstName) || "null".equals(firstName);
String lastName = thisUser.optString("last_name");
boolean lastNameEmpty = TextUtils.isEmpty(lastName) || "null".equals(lastName);
- if (firstNameEmpty && lastNameEmpty)
+ if (firstNameEmpty && lastNameEmpty) {
return thisUser.optString("email");
+ }
StringBuilder nameBuilder = new StringBuilder();
- if (!firstNameEmpty)
+ if (!firstNameEmpty) {
nameBuilder.append(firstName).append(" ");
- if (!lastNameEmpty)
+ }
+ if (!lastNameEmpty) {
nameBuilder.append(lastName);
+ }
return nameBuilder.toString().trim();
}
diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncService.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncService.java
index 8a77726d0..9882e1059 100644
--- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncService.java
+++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncService.java
@@ -67,13 +67,15 @@ public final class ActFmSyncService {
// --- data fetch methods
public int fetchFeaturedLists(int serverTime) throws JSONException, IOException {
- if (!checkForToken())
+ if (!checkForToken()) {
return 0;
+ }
JSONObject result = actFmInvoker.invoke("featured_lists",
"token", token, "modified_after", serverTime);
JSONArray featuredLists = result.getJSONArray("list");
- if (featuredLists.length() > 0)
+ if (featuredLists.length() > 0) {
Preferences.setBoolean(FeaturedListFilterExposer.PREF_SHOULD_SHOW_FEATURED_LISTS, true);
+ }
for (int i = 0; i < featuredLists.length(); i++) {
JSONObject featObject = featuredLists.getJSONObject(i);
@@ -87,8 +89,9 @@ public final class ActFmSyncService {
String purchaseToken = Preferences.getStringValue(BillingConstants.PREF_PURCHASE_TOKEN);
String productId = Preferences.getStringValue(BillingConstants.PREF_PRODUCT_ID);
try {
- if (!checkForToken())
+ if (!checkForToken()) {
throw new ActFmServiceException("Not logged in", null);
+ }
ArrayList