Remove unused code

Alex Baker 13 years ago
parent f2d770f03f
commit ef4b044faa

@ -194,13 +194,6 @@ public abstract class AbstractModel implements Parcelable, Cloneable {
return clone;
}
/**
* Check if this model has values that have been changed
*/
public boolean isModified() {
return setValues.size() > 0;
}
// --- data retrieval
/**

@ -14,8 +14,6 @@ import android.util.Log;
import com.todoroo.astrid.api.R;
import java.lang.Thread.UncaughtExceptionHandler;
/**
* Exception handling utility class - reports and logs errors
*
@ -140,32 +138,5 @@ public class ExceptionService {
}
}
}
/**
* Uncaught exception handler uses the exception utilities class to
* report errors
*
* @author Tim Su <tim@todoroo.com>
*/
public static class TodorooUncaughtExceptionHandler implements UncaughtExceptionHandler {
private final UncaughtExceptionHandler defaultUEH;
@Autowired
protected ExceptionService exceptionService;
public TodorooUncaughtExceptionHandler() {
defaultUEH = Thread.getDefaultUncaughtExceptionHandler();
DependencyInjectionService.getInstance().inject(this);
}
@Override
public void uncaughtException(Thread thread, Throwable ex) {
if (exceptionService != null) {
exceptionService.reportError("uncaught", ex); //$NON-NLS-1$
}
defaultUEH.uncaughtException(thread, ex);
}
}
}

@ -1,12 +0,0 @@
/**
* Copyright (c) 2012 Todoroo Inc
*
* See the file "LICENSE" for the full license governing this code.
*/
package com.todoroo.andlib.sql;
public class EqCriterion extends UnaryCriterion {
EqCriterion(Field field, Object value) {
super(field, Operator.eq, value);
}
}

@ -1,19 +0,0 @@
/**
* Copyright (c) 2012 Todoroo Inc
*
* See the file "LICENSE" for the full license governing this code.
*/
package com.todoroo.andlib.sql;
import java.util.ArrayList;
import java.util.List;
public class GroupBy {
private List<Field> fields = new ArrayList<Field>();
public static GroupBy groupBy(Field field) {
GroupBy groupBy = new GroupBy();
groupBy.fields.add(field);
return groupBy;
}
}

@ -8,8 +8,6 @@ package com.todoroo.andlib.sql;
import java.util.HashMap;
import java.util.Map;
import static com.todoroo.andlib.sql.SqlConstants.SPACE;
public final class Operator {
@ -46,15 +44,6 @@ public final class Operator {
this.operator = operator;
}
public Operator getContrary() {
if (!contraryRegistry.containsKey(this)) {
Operator opposite = new Operator(not.toString() + SPACE + this.toString());
contraryRegistry.put(this, opposite);
contraryRegistry.put(opposite, this);
}
return contraryRegistry.get(this);
}
@Override
public String toString() {
return this.operator;

@ -37,10 +37,6 @@ public class Order {
secondaryExpressions.add(secondary);
}
public void removeSecondaryExpression(Order secondary) {
secondaryExpressions.remove(secondary);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();

@ -95,11 +95,6 @@ public final class Query {
return this;
}
public Query appendSelectFields(Property<?>... selectFields) {
this.fields.addAll(asList(selectFields));
return this;
}
@Override
public boolean equals(Object o) {
return this == o || !(o == null || getClass() != o.getClass()) && this.toString().equals(o.toString());

@ -14,12 +14,4 @@ public class SqlTable extends DBObject<SqlTable> {
public static SqlTable table(String table) {
return new SqlTable(table);
}
protected String fieldExpression(String fieldName) {
if (hasAlias()) {
return alias + "." + fieldName;
}
return expression + "." + fieldName;
}
}

@ -10,14 +10,9 @@ import android.content.BroadcastReceiver;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.NetworkInfo.State;
import android.os.Bundle;
import android.text.InputType;
import android.util.DisplayMetrics;
@ -25,7 +20,6 @@ import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.PopupWindow;
import android.widget.TextView;
@ -36,7 +30,6 @@ import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
@ -49,8 +42,6 @@ import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.math.BigInteger;
import java.net.URL;
import java.net.URLConnection;
import java.security.MessageDigest;
import java.util.Arrays;
import java.util.Comparator;
@ -88,44 +79,6 @@ public class AndroidUtilities {
});
}
/**
* @return true if we're connected to the internet
*/
public static boolean isConnected(Context context) {
ConnectivityManager manager = (ConnectivityManager)
context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = manager.getActiveNetworkInfo();
if (info == null) {
return false;
}
if (info.getState() != State.CONNECTED) {
return false;
}
return true;
}
/**
* Fetch the image specified by the given url
*/
public static Bitmap fetchImage(URL url) throws IOException {
InputStream is = null;
try {
URLConnection conn = url.openConnection();
conn.connect();
is = conn.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is, 16384);
try {
return BitmapFactory.decodeStream(bis);
} finally {
bis.close();
}
} finally {
if (is != null) {
is.close();
}
}
}
/**
* Read a bitmap from the specified file, scaling if necessary
* Returns null if scaling failed after several tries
@ -172,24 +125,6 @@ public class AndroidUtilities {
}
}
/**
* Start the given intent, handling security exceptions if they arise
*
* @param activity
* @param intent
* @param requestCode
*/
public static void startExternalIntentForResult(
Activity activity, Intent intent, int requestCode) {
try {
activity.startActivityForResult(intent, requestCode);
} catch (SecurityException e) {
getExceptionService().displayAndReportError(activity,
"start-external-intent-" + intent.toString(), //$NON-NLS-1$
e);
}
}
/**
* Put an arbitrary object into a {@link ContentValues}
*
@ -252,19 +187,6 @@ public class AndroidUtilities {
// --- serialization
/**
* Rips apart a content value into two string arrays, keys and value
*/
public static String[][] contentValuesToStringArrays(ContentValues source) {
String[][] result = new String[2][source.size()];
int i = 0;
for (Entry<String, Object> entry : source.valueSet()) {
result[0][i] = entry.getKey();
result[1][i++] = entry.getValue().toString();
}
return result;
}
/**
* Return index of value in array
*
@ -541,32 +463,6 @@ public class AndroidUtilities {
}
}
/**
* Find a child view of a certain type
*
* @param view
* @param type
* @return first view (by DFS) if found, or null if none
*/
public static <TYPE> TYPE findViewByType(View view, Class<TYPE> type) {
if (view == null) {
return null;
}
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) {
return v;
}
}
}
return null;
}
/**
* @return Android SDK version as an integer. Works on all versions
*/
@ -574,27 +470,6 @@ public class AndroidUtilities {
return Integer.parseInt(android.os.Build.VERSION.SDK);
}
/**
* Copy databases to a given folder. Useful for debugging
*
* @param folder
*/
public static void copyDatabases(Context context, String folder) {
File folderFile = new File(folder);
if (!folderFile.exists()) {
folderFile.mkdir();
}
for (String db : context.databaseList()) {
File dbFile = context.getDatabasePath(db);
try {
copyFile(dbFile, new File(folderFile.getAbsolutePath() +
File.separator + db));
} catch (Exception e) {
Log.e("ERROR", "ERROR COPYING DB " + db, e); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}
/**
* Sort files by date so the newest file is on top
*
@ -609,22 +484,6 @@ public class AndroidUtilities {
});
}
/**
* Search for the given value in the map, returning key if found
*
* @param map
* @param value
* @return null if not found, otherwise key
*/
public static <KEY, VALUE> KEY findKeyInMap(Map<KEY, VALUE> map, VALUE value) {
for (Entry<KEY, VALUE> entry : map.entrySet()) {
if (entry.getValue().equals(value)) {
return entry.getKey();
}
}
return null;
}
/**
* Sleep, ignoring interruption. Before using this method, think carefully
* about why you are ignoring interruptions.
@ -674,32 +533,6 @@ public class AndroidUtilities {
AndroidUtilities.callMethod(receiver.getClass(), receiver, methodName, params, args);
}
/**
* Call a static method via reflection if API level is at least minSdk
*
* @param minSdk minimum sdk number (i.e. 8)
* @param className fully qualified class to call method on
* @param methodName method name to call
* @param params method parameter types
* @param args arguments
* @return method return value, or null if nothing was called or exception
*/
public static Object callApiStaticMethod(int minSdk, String className,
String methodName, Class<?>[] params, Object... args) {
if (getSdkVersion() < minSdk) {
return null;
}
try {
return AndroidUtilities.callMethod(Class.forName(className),
null, methodName, params, args);
} catch (ClassNotFoundException e) {
getExceptionService().reportError("call-method", e);
return null;
}
}
/**
* Call a method via reflection
*
@ -809,35 +642,6 @@ public class AndroidUtilities {
}
}
/**
* Create an intent to a remote activity
*
* @param appPackage
* @param activityClass
* @return
*/
public static Intent remoteIntent(String appPackage, String activityClass) {
Intent intent = new Intent();
intent.setClassName(appPackage, activityClass);
return intent;
}
/**
* Gets application signature
*
* @return application signature, or null if an error was encountered
*/
public static String getSignature(Context context, String packageName) {
try {
PackageInfo packageInfo = context.getPackageManager().getPackageInfo(packageName,
PackageManager.GET_SIGNATURES);
return packageInfo.signatures[0].toCharsString();
} catch (Exception e) {
Log.e("AndroidUtilities", packageName + " is not installed");
return null;
}
}
/**
* Join items to a list
*
@ -1023,17 +827,6 @@ public class AndroidUtilities {
}
}
/**
* Tries to parse an int from a string, returning the default value on failure
*/
public static long tryParseLong(String str, long defaultValue) {
try {
return Long.parseLong(str);
} catch (NumberFormatException e) {
return defaultValue;
}
}
/**
* Returns the final word characters after the last '.'
*

@ -25,16 +25,6 @@ public class DateUtilities {
* ============================================================ long time
* ====================================================================== */
/**
* Convert unixtime into date
*/
public static Date unixtimeToDate(long millis) {
if (millis == 0) {
return null;
}
return new Date(millis);
}
/**
* Convert date into unixtime
*/
@ -233,14 +223,6 @@ public class DateUtilities {
DateUtils.LENGTH_MEDIUM);
}
/**
* @return date format as getDateFormat with weekday
*/
public static String getDateStringWithTimeAndWeekday(Context context, Date date) {
return getDateStringWithWeekday(date) + " " + getTimeString(context, date);
}
/**
* @return date with time at the end
*/

@ -156,25 +156,6 @@ public class Preferences {
}
}
/**
* Gets an float value from a string preference. Returns null
* if the value is not set or not an flat.
*
* @param keyResource resource from string.xml
* @return
*/
public static Float getFloatFromString(int keyResource) {
Context context = ContextManager.getContext();
Resources r = context.getResources();
String value = getPrefs(context).getString(r.getString(keyResource), ""); //$NON-NLS-1$
try {
return Float.parseFloat(value);
} catch (Exception e) {
return null;
}
}
/**
* Sets string preference
*/

@ -9,7 +9,6 @@ import android.content.ContentValues;
import android.os.Parcel;
import android.os.Parcelable;
import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.QueryTemplate;
/**
@ -222,13 +221,4 @@ public class Filter extends FilterListItem {
}
};
/**
* @param title
* @return a filter that matches nothing
*/
public static Filter emptyFilter(String title) {
return new Filter(title, title,
new QueryTemplate().where(Criterion.none), null);
}
}

@ -1,48 +0,0 @@
/**
* Copyright (c) 2012 Todoroo Inc
*
* See the file "LICENSE" for the full license governing this code.
*/
package com.todoroo.astrid.data;
import android.content.Context;
import com.todoroo.andlib.data.ContentResolverDao;
import com.todoroo.andlib.sql.Criterion;
/**
* Data access object for accessing Astrid's {@link StoreObject} table. A
* StoreObject is an arbitrary piece of data stored inside of Astrid.
*
* @author Tim Su <tim@todoroo.com>
*/
public class StoreObjectApiDao extends ContentResolverDao<StoreObject> {
public StoreObjectApiDao(Context context) {
super(StoreObject.class, context, StoreObject.CONTENT_URI);
}
// --- SQL clause generators
/**
* Generates SQL clauses
*/
public static class StoreObjectCriteria {
/**
* Returns all store objects with given type
*/
public static Criterion byType(String type) {
return StoreObject.TYPE.eq(type);
}
/**
* Returns store object with type and key
*/
public static Criterion byTypeAndItem(String type, String item) {
return Criterion.and(byType(type), StoreObject.ITEM.eq(item));
}
}
}

@ -300,23 +300,6 @@ public final class Task extends RemoteModel {
*/
public static final String USER_ID_SELF = "0";
public static boolean isRealUserId(String userId) {
if (userId == null) {
return false;
}
return !(Task.USER_ID_SELF.equals(userId) ||
Task.USER_ID_UNASSIGNED.equals(userId) ||
Task.USER_ID_EMAIL.equals(userId) ||
Task.USER_ID_IGNORE.equals(userId));
}
public static boolean userIdIsEmail(String userId) {
if (userId == null) {
return false;
}
return userId.indexOf('@') >= 0;
}
// --- notification flags
/**

@ -5,7 +5,6 @@
*/
package com.todoroo.astrid.sync;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.Task;
@ -22,21 +21,6 @@ public class SyncContainer {
public Task task;
public ArrayList<Metadata> metadata;
/**
* Check if the metadata contains anything with the given key
*
* @param key
* @return first match. or null
*/
public Metadata findMetadata(String key) {
for (Metadata item : metadata) {
if (AndroidUtilities.equals(key, item.getValue(Metadata.KEY))) {
return item;
}
}
return null;
}
/**
* Method called when sync container is about to be saved into the database.
*/

@ -184,23 +184,4 @@ abstract public class SyncProviderUtilities {
editor.putBoolean(getIdentifier() + PREF_ONGOING, true);
editor.commit();
}
/**
* Reads the frequency, in seconds, auto-sync should occur.
*
* @return seconds duration, or 0 if not desired
*/
public int getSyncAutoSyncFrequency() {
String value = getPrefs().getString(
ContextManager.getContext().getString(
getSyncIntervalKey()), null);
if (value == null) {
return 0;
}
try {
return Integer.parseInt(value);
} catch (Exception e) {
return 0;
}
}
}

@ -6,7 +6,6 @@
package com.mdimension.jchronic;
import com.mdimension.jchronic.handlers.Handler;
import com.mdimension.jchronic.numerizer.Numerizer;
import com.mdimension.jchronic.repeaters.Repeater;
import com.mdimension.jchronic.tags.Grabber;
import com.mdimension.jchronic.tags.Ordinal;
@ -147,13 +146,6 @@ public class AstridChronic {
return normalizedText;
}
/**
* Convert number words to numbers (three => 3)
*/
protected static String numericizeNumbers(String text) {
return Numerizer.numerize(text);
}
/**
* Convert ordinal words to numeric ordinals (third => 3rd)
*/

@ -1,52 +0,0 @@
/**
* Copyright (c) 2012 Todoroo Inc
*
* See the file "LICENSE" for the full license governing this code.
*/
package com.todoroo.astrid.actfm;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.timsu.astrid.R;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.api.SyncAction;
import com.todoroo.astrid.service.AstridDependencyInjector;
/**
* Exposes sync action
*/
public class ActFmSyncActionExposer extends BroadcastReceiver {
@Autowired
ActFmPreferenceService actFmPreferenceService;
static {
AstridDependencyInjector.initialize();
}
@Override
public void onReceive(Context context, Intent intent) {
ContextManager.setContext(context);
DependencyInjectionService.getInstance().inject(this);
// if we aren't logged in, don't expose sync action
if (!actFmPreferenceService.isLoggedIn()) {
return;
}
SyncAction syncAction = new SyncAction(context.getString(R.string.actfm_APr_header),
null);
Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_SEND_SYNC_ACTIONS);
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_ADDON, ActFmPreferenceService.IDENTIFIER);
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_RESPONSE, syncAction);
context.sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ);
}
}

@ -160,8 +160,7 @@ public class ActFmInvoker {
* @param getParameters Name/Value pairs. Values will be URL encoded.
* @return response object
*/
public JSONObject post(String method, HttpEntity data, Object... getParameters) throws IOException,
ActFmServiceException {
public JSONObject post(String method, HttpEntity data, Object... getParameters) throws IOException {
try {
String request = createFetchUrl(null, method, getParameters);

@ -196,29 +196,4 @@ public class ActFmPreferenceService extends SyncProviderUtilities {
}
return name;
}
public static String thisUserName() {
JSONObject thisUser = thisUser();
String name = thisUser.optString("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) {
return thisUser.optString("email");
}
StringBuilder nameBuilder = new StringBuilder();
if (!firstNameEmpty) {
nameBuilder.append(firstName).append(" ");
}
if (!lastNameEmpty) {
nameBuilder.append(lastName);
}
return nameBuilder.toString().trim();
}
}

@ -16,7 +16,6 @@ import com.todoroo.astrid.data.RemoteModel;
import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.User;
import com.todoroo.astrid.service.TagDataService;
import com.todoroo.astrid.tags.reusable.FeaturedListFilterExposer;
import org.json.JSONArray;
import org.json.JSONException;
@ -49,25 +48,6 @@ public final class ActFmSyncService {
}
// --- data fetch methods
public int fetchFeaturedLists(int serverTime) throws JSONException, IOException {
if (!checkForToken()) {
return 0;
}
JSONObject result = actFmInvoker.invoke("featured_lists",
"token", token, "modified_after", serverTime);
JSONArray featuredLists = result.getJSONArray("list");
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);
tagDataService.saveFeaturedList(featObject);
}
return result.optInt("time", 0);
}
public void setGCMRegistration(String regId) {
try {
String deviceId = GCMIntentService.getDeviceID();

@ -61,10 +61,6 @@ public abstract class ClientToServerMessage<TYPE extends RemoteModel> {
return uuid;
}
public final long getPushedAt() {
return pushedAt;
}
public final JSONObject serializeToJSON(MultipartEntity entity) {
JSONObject json = new JSONObject();
try {

@ -60,11 +60,6 @@ public class NameMaps {
return TABLE_LOCAL_TO_SERVER.get(table);
}
public static Table getLocalTableForServerName(String serverName) {
return TABLE_SERVER_TO_LOCAL.get(serverName);
}
// --------------------------------
// ---- Column name mappings -------
// --------------------------------

@ -1,26 +0,0 @@
package com.todoroo.astrid.actfm.sync.messages;
import com.todoroo.astrid.dao.RemoteModelDao;
import com.todoroo.astrid.data.RemoteModel;
import org.apache.http.entity.mime.MultipartEntity;
import org.json.JSONException;
import org.json.JSONObject;
public class RequestDoubleCheck<TYPE extends RemoteModel> extends ClientToServerMessage<TYPE> {
public RequestDoubleCheck(long id, Class<TYPE> modelClass, RemoteModelDao<TYPE> modelDao) {
super(id, modelClass, modelDao);
}
@Override
protected boolean serializeExtrasToJSON(JSONObject serializeTo, MultipartEntity entity) throws JSONException {
// No extras
return true;
}
@Override
protected String getTypeString() {
return "RequestDoubleCheck"; //$NON-NLS-1$
}
}

@ -5,15 +5,12 @@
*/
package com.todoroo.astrid.core;
import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.service.ExceptionService;
import com.todoroo.andlib.sql.Query;
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
import com.todoroo.astrid.dao.Database;
import com.todoroo.astrid.dao.HistoryDao;
import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria;
import com.todoroo.astrid.dao.StoreObjectDao;
import com.todoroo.astrid.dao.TagDataDao;
import com.todoroo.astrid.dao.TagMetadataDao;
@ -27,7 +24,6 @@ import com.todoroo.astrid.dao.TaskOutstandingDao;
import com.todoroo.astrid.dao.UserActivityDao;
import com.todoroo.astrid.dao.UserActivityOutstandingDao;
import com.todoroo.astrid.dao.UserDao;
import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.gtasks.GtasksPreferenceService;
import com.todoroo.astrid.service.AstridDependencyInjector;
import com.todoroo.astrid.service.MetadataService;
@ -207,29 +203,4 @@ public final class PluginServices {
public static ActFmPreferenceService getActFmPreferenceService() {
return getInstance().actFmPreferenceService;
}
public static GtasksPreferenceService getGtasksPreferenceService() {
return getInstance().gtasksPreferenceService;
}
// -- helpers
/**
* Find the corresponding metadata for this task
*/
public static Metadata getMetadataByTaskAndWithKey(long taskId, String metadataKey) {
TodorooCursor<Metadata> cursor = PluginServices.getMetadataService().query(Query.select(
Metadata.PROPERTIES).where(MetadataCriteria.byTaskAndwithKey(taskId, metadataKey)));
try {
if (cursor.getCount() > 0) {
cursor.moveToNext();
return new Metadata(cursor);
} else {
return null;
}
} finally {
cursor.close();
}
}
}

@ -83,17 +83,6 @@ public class Calendars {
return null;
}
/**
* Return calendar package name
*/
public static String getCalendarPackage() {
if (AndroidUtilities.getSdkVersion() >= 8) {
return "com.google.android.calendar";
} else {
return "com.android.calendar";
}
}
// --- helper data structure
/**
@ -241,15 +230,6 @@ public class Calendars {
listPreference.setEnabled(true);
}
/**
* sets the default calendar for future use
*
* @param defaultCalendar default calendar id
*/
public static void setDefaultCalendar(String defaultCalendar) {
Preferences.setString(R.string.gcal_p_default, defaultCalendar);
}
/**
* gets the default calendar for future use
*

@ -70,21 +70,6 @@ public class GtasksListService {
return LIST_NOT_FOUND;
}
public void migrateListIds(TaskLists remoteLists) {
readLists();
List<TaskList> items = remoteLists.getItems();
for (TaskList remote : items) {
for (StoreObject list : lists) {
if (list.getValue(GtasksList.NAME).equals(remote.getTitle())) {
list.setValue(GtasksList.REMOTE_ID, remote.getId());
storeObjectDao.persist(list);
break;
}
}
}
}
/**
* Reads in remote list information and updates local list objects.
*

@ -31,10 +31,6 @@ public class GtasksPreferenceService extends SyncProviderUtilities {
return R.string.gtasks_GPr_interval_key;
}
public boolean migrationHasOccurred() {
return Preferences.getBoolean(PREF_MIGRATION_HAS_OCCURRED, false);
}
/**
* GTasks user's default list id
*/

@ -1,55 +0,0 @@
/**
* Copyright (c) 2012 Todoroo Inc
*
* See the file "LICENSE" for the full license governing this code.
*/
package com.todoroo.astrid.gtasks;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.timsu.astrid.R;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.api.SyncAction;
import com.todoroo.astrid.service.AstridDependencyInjector;
/**
* Exposes sync action
*/
public class GtasksSyncActionExposer extends BroadcastReceiver {
@Autowired
private GtasksPreferenceService gtasksPreferenceService;
static {
AstridDependencyInjector.initialize();
}
@Override
public void onReceive(Context context, Intent intent) {
ContextManager.setContext(context);
DependencyInjectionService.getInstance().inject(this);
// if we aren't logged in, don't expose sync action
if (!gtasksPreferenceService.isLoggedIn()) {
return;
}
Intent syncIntent = new Intent(null, null,
context, GtasksBackgroundService.class);
PendingIntent pendingIntent = PendingIntent.getService(context, 0, syncIntent, PendingIntent.FLAG_UPDATE_CURRENT);
SyncAction syncAction = new SyncAction(context.getString(R.string.gtasks_GPr_header),
pendingIntent);
Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_SEND_SYNC_ACTIONS);
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_ADDON, GtasksPreferenceService.IDENTIFIER);
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_RESPONSE, syncAction);
context.sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ);
}
}

@ -35,7 +35,6 @@ public class GtasksInvoker {
private Tasks service;
private GoogleAccessProtectedResource accessProtectedResource;
private String token;
private JsonFactory jsonFactory;
@Autowired
ExceptionService exceptionService;
@ -53,7 +52,7 @@ public class GtasksInvoker {
this.token = authToken;
accessProtectedResource = new GoogleAccessProtectedResource(authToken);
jsonFactory = new GsonFactory();
JsonFactory jsonFactory = new GsonFactory();
service = new Tasks(AndroidHttp.newCompatibleTransport(), accessProtectedResource, jsonFactory);
service.setKey(API_KEY);
service.setApplicationName("Astrid");
@ -164,10 +163,6 @@ public class GtasksInvoker {
}
}
public com.google.api.services.tasks.model.Tasks getAllGtasksFromTaskList(TaskList list, boolean includeDeleted, boolean includeHidden, long lastSyncDate) throws IOException {
return getAllGtasksFromListId(list.getId(), includeDeleted, includeHidden, lastSyncDate);
}
public com.google.api.services.tasks.model.Tasks getAllGtasksFromListId(String listId, boolean includeDeleted, boolean includeHidden, long lastSyncDate) throws IOException {
com.google.api.services.tasks.model.Tasks toReturn = null;
List request = service.tasks().list(listId);
@ -279,8 +274,4 @@ public class GtasksInvoker {
log("Clear completed tasks, list id: " + listId, null);
}
}
public JsonFactory getJsonFactory() {
return jsonFactory;
}
}

@ -52,22 +52,4 @@ public class MoveListRequest extends PushRequest {
toPush.setParent(newParent);
}
public String getIdTaskToMove() {
return idTaskToMove;
}
public void setIdTaskToMove(String idTaskToMove) {
this.idTaskToMove = idTaskToMove;
}
public String getDstList() {
return dstList;
}
public void setDstList(String dstList) {
this.dstList = dstList;
}
}

@ -29,26 +29,10 @@ public abstract class PushRequest {
return listId;
}
public void setListId(String listId) {
this.listId = listId;
}
public Task getToPush() {
return toPush;
}
public void setToPush(Task toPush) {
this.toPush = toPush;
}
public GtasksInvoker getService() {
return service;
}
public void setService(GtasksInvoker service) {
this.service = service;
}
public Task push() throws IOException {
try {
return executePush();

@ -1,33 +0,0 @@
/**
* Copyright (c) 2012 Todoroo Inc
*
* See the file "LICENSE" for the full license governing this code.
*/
package com.todoroo.astrid.gtasks.api;
import com.google.api.services.tasks.model.Task;
import java.io.IOException;
/**
* Encapsulates a request to the api to update a task on the remote server
*
* @author Sam Bosley
*/
public class UpdateRequest extends PushRequest {
public UpdateRequest(GtasksInvoker service, String listId, Task toUpdate) {
super(service, listId, toUpdate);
}
@Override
public Task executePush() throws IOException {
return service.updateGtask(listId, toPush);
}
@Override
protected void recover() {
//Figure out a good way to recover!
}
}

@ -562,10 +562,6 @@ public class EditNoteActivity extends LinearLayout implements TimerActionListene
}
}
public int numberOfComments() {
return items.size();
}
private static class NoteOrUpdate {
private final String type;
private final String picture;

@ -94,10 +94,6 @@ public class OpencrxControlSet extends PopupControlSet {
return name;
}
public String getCrxId() {
return crxId;
}
@Override
public String toString() {
return name;
@ -158,22 +154,6 @@ public class OpencrxControlSet extends PopupControlSet {
this(userData.getValue(REMOTE_ID), "", userData.getValue(FIRST_NAME), userData.getValue(LAST_NAME), userData.getValue(CRX_ID)); //$NON-NLS-1$
}
public String getEmail() {
return email;
}
public String getFirstname() {
return firstname;
}
public String getLastname() {
return lastname;
}
public String getCrxId() {
return crxId;
}
public long getId() {
return id;
}

@ -9,7 +9,6 @@ import android.app.Activity;
import android.app.Dialog;
import android.app.TimePickerDialog.OnTimeSetListener;
import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
@ -17,35 +16,19 @@ import android.widget.TimePicker;
import android.widget.Toast;
import com.timsu.astrid.R;
import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Query;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
import com.todoroo.astrid.actfm.sync.ActFmSyncService;
import com.todoroo.astrid.activity.AstridActivity;
import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.core.PluginServices;
import com.todoroo.astrid.dao.UserDao;
import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.TagMetadata;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.User;
import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.tags.TagMemberMetadata;
import com.todoroo.astrid.tags.TagService;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.Date;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* A dialog that shows your task reminder
@ -155,77 +138,4 @@ public class ReminderDialog extends Dialog {
((TextView) findViewById(R.id.reminder_message)).setText(
Notifications.getRandomReminder(activity.getResources().getStringArray(R.array.reminder_responses)));
}
private void addPicturesFromJSONArray(JSONArray array, LinkedHashSet<String> pictureUrls, List<String> names, AtomicBoolean isSharedTask) throws JSONException {
for (int i = 0; i < array.length(); i++) {
JSONObject person = array.getJSONObject(i);
if (person.has("picture")) { //$NON-NLS-1$
if (ActFmPreferenceService.userId().equals(Long.toString(person.optLong("id")))) //$NON-NLS-1$
{
continue;
}
isSharedTask.set(true);
String pictureUrl = person.getString("picture"); //$NON-NLS-1$
if (!TextUtils.isEmpty(pictureUrl)) {
pictureUrls.add(pictureUrl);
}
String name = person.optString("first_name"); //$NON-NLS-1$
if (!TextUtils.isEmpty(name)) {
names.add(name);
} else {
name = person.optString("name"); //$NON-NLS-1$
if (!TextUtils.isEmpty(name)) {
names.add(name);
}
}
}
}
}
private void addTagFaces(long taskId, LinkedHashSet<String> pictureUrls, List<String> names, AtomicBoolean isSharedTask) {
TodorooCursor<TagData> tags = tagService.getTagDataForTask(taskId, Criterion.all, TagData.UUID, TagData.MEMBERS);
try {
TagData td = new TagData();
for (tags.moveToFirst(); !tags.isAfterLast() && pictureUrls.size() < MAX_FACES; tags.moveToNext()) {
td.readFromCursor(tags);
try {
JSONArray people = new JSONArray(td.getValue(TagData.MEMBERS));
addPicturesFromJSONArray(people, pictureUrls, names, isSharedTask);
} catch (JSONException e) {
JSONArray people = new JSONArray();
TodorooCursor<User> users = userDao.query(Query.select(User.PROPERTIES)
.where(User.UUID.in(
Query.select(TagMemberMetadata.USER_UUID)
.from(TagMetadata.TABLE)
.where(TagMetadata.TAG_UUID.eq(td.getUuid())))));
try {
User user = new User();
for (users.moveToFirst(); !users.isAfterLast(); users.moveToNext()) {
user.clear();
user.readFromCursor(users);
try {
JSONObject userJson = new JSONObject();
ActFmSyncService.JsonHelper.jsonFromUser(userJson, user);
people.put(userJson);
} catch (JSONException e2) {
//
}
}
try {
addPicturesFromJSONArray(people, pictureUrls, names, isSharedTask);
} catch (JSONException e2) {
//
}
} finally {
users.close();
}
}
}
} finally {
tags.close();
}
}
}

@ -1,26 +0,0 @@
/**
* Copyright (c) 2012 Todoroo Inc
*
* See the file "LICENSE" for the full license governing this code.
*/
package com.todoroo.astrid.reminders;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class ReminderPlugin extends BroadcastReceiver {
static final String IDENTIFIER = "reminders"; //$NON-NLS-1$
@Override
public void onReceive(Context context, Intent intent) {
/*Plugin plugin = new Plugin(IDENTIFIER, "Reminders", "Todoroo",
"Provides notification reminders for tasks");
Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_SEND_PLUGINS);
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_PLUGIN, plugin);
context.sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ);*/
}
}

@ -176,10 +176,6 @@ public final class ReminderService {
scheduler.createAlarm(task, NO_ALARM, TYPE_OVERDUE);
}
public void clearAlarm(Task task, int type) {
scheduler.createAlarm(task, NO_ALARM, type);
}
/**
* Schedules alarms for a single task
*

@ -128,9 +128,4 @@ public class RepeatDetailExposer extends BroadcastReceiver {
return r.getQuantityString(plural, rrule.getInterval(), rrule.getInterval());
}
public String getPluginIdentifier() {
return RepeatsPlugin.IDENTIFIER;
}
}

@ -190,10 +190,6 @@ public abstract class AstridOrderedListUpdater<LIST> {
}
}
public void iterateOverList(OrderedListNodeVisitor visitor) {
applyToDescendantsHelper(treeRoot, visitor);
}
public void indent(LIST list, Filter filter, String targetTaskId, int delta) {
Node node = idToNode.get(targetTaskId);
indentHelper(list, filter, node, delta);

@ -77,10 +77,6 @@ public class OrderedMetadataListFragmentHelper<LIST> implements OrderedListFragm
return fragment.getListView();
}
private Filter getFilter() {
return fragment.getFilter();
}
public DraggableListView getTouchListView() {
return (DraggableListView) fragment.getListView();
}

@ -332,23 +332,6 @@ public final class TagService {
return metadataDao.query(query);
}
public TodorooCursor<TagData> getTagDataForTask(long taskId, Property<?>... properties) {
Criterion criterion = TagData.UUID.in(Query.select(TaskToTagMetadata.TAG_UUID)
.from(Metadata.TABLE)
.where(Criterion.and(MetadataCriteria.withKey(TaskToTagMetadata.KEY),
Metadata.DELETION_DATE.eq(0),
Metadata.TASK.eq(taskId))));
return tagDataService.query(Query.select(properties).where(criterion));
}
public TodorooCursor<TagData> getTagDataForTask(long taskId, Criterion additionalCriterion, Property<?>... properties) {
Criterion criterion = TagData.UUID.in(Query.select(TaskToTagMetadata.TAG_UUID).from(Metadata.TABLE).where(
Criterion.and(Metadata.DELETION_DATE.eq(0),
MetadataCriteria.byTaskAndwithKey(taskId, TaskToTagMetadata.KEY))));
return tagDataService.query(Query.select(properties).where(Criterion.and(criterion, additionalCriterion)));
}
/**
* Return tags as a comma-separated list of strings
*

@ -332,10 +332,4 @@ public final class TagsControlSet extends PopupControlSet {
image.setImageResource(R.drawable.tea_icn_lists_gray);
}
}
public boolean hasLists() {
LinkedHashSet<String> tags = getTagSet();
return !tags.isEmpty();
}
}

@ -6,15 +6,10 @@
package com.timsu.astrid.data;
import android.content.Context;
import android.database.Cursor;
import android.util.Log;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService;
import java.lang.reflect.InvocationTargetException;
import java.util.Iterator;
/**
* Abstract controller class. Mostly contains some static fields
*/
@ -53,53 +48,4 @@ abstract public class LegacyAbstractController {
abstract public void open();
abstract public void close();
// cursor iterator
public static class CursorIterator<TYPE extends LegacyAbstractModel> implements Iterator<TYPE> {
Cursor cursor;
Class<TYPE> cls;
public CursorIterator(Cursor cursor, Class<TYPE> cls) {
this.cursor = cursor;
this.cls = cls;
}
@Override
public boolean hasNext() {
return !cursor.isLast();
}
@Override
public TYPE next() {
try {
TYPE model = cls.getConstructor(Cursor.class).newInstance(cursor);
cursor.moveToNext();
return model;
// ugh...
} catch (IllegalArgumentException e) {
Log.e("CursorIterator", e.toString());
} catch (SecurityException e) {
Log.e("CursorIterator", e.toString());
} catch (InstantiationException e) {
Log.e("CursorIterator", e.toString());
} catch (IllegalAccessException e) {
Log.e("CursorIterator", e.toString());
} catch (InvocationTargetException e) {
Log.e("CursorIterator", e.toString());
} catch (NoSuchMethodException e) {
Log.e("CursorIterator", e.toString());
}
return null;
}
@Override
public void remove() {
throw new UnsupportedOperationException("Can't remove this way");
}
}
}

@ -249,31 +249,6 @@ public abstract class LegacyAbstractModel {
throw new UnsupportedOperationException("Could not read field " + field);
}
protected Double retrieveDouble(String field) {
if (setValues.containsKey(field)) {
return setValues.getAsDouble(field);
}
if (values.containsKey(field)) {
return values.getAsDouble(field);
}
// if we have a database to hit, do that now
if (cursor != null) {
Double value = cursor.getDouble(getColumnIndex(field));
values.put(field, value);
return value;
}
// do we have defaults?
ContentValues defaults = getDefaultValues();
if (defaults != null && defaults.containsKey(field)) {
return defaults.getAsDouble(field);
}
throw new UnsupportedOperationException("Could not read field " + field);
}
// --- retrieving composite objects
protected Date retrieveDate(String field) {

@ -16,10 +16,8 @@ import com.timsu.astrid.data.alerts.Alert.AlertDatabaseHelper;
import com.timsu.astrid.data.task.TaskIdentifier;
import java.util.Date;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
/**
* Controller for Tag-related operations
@ -29,15 +27,6 @@ public class AlertController extends LegacyAbstractController {
private SQLiteDatabase alertDatabase;
/**
* Get a cursor to tag identifiers
*/
public Cursor getTaskAlertsCursor(TaskIdentifier taskId) throws SQLException {
return alertDatabase.query(alertsTable,
Alert.FIELD_LIST, Alert.TASK + " = ?",
new String[]{taskId.idAsString()}, null, null, null);
}
/**
* Get a list of alerts for the given task
*/
@ -63,31 +52,6 @@ public class AlertController extends LegacyAbstractController {
}
}
/**
* Get a list of alerts that are set for the future
*/
public Set<TaskIdentifier> getTasksWithActiveAlerts() throws SQLException {
Set<TaskIdentifier> list = new HashSet<TaskIdentifier>();
Cursor cursor = alertDatabase.query(alertsTable,
Alert.FIELD_LIST, Alert.DATE + " > ?",
new String[]{Long.toString(System.currentTimeMillis())}, null, null, null);
try {
if (cursor.getCount() == 0) {
return list;
}
do {
cursor.moveToNext();
list.add(new Alert(cursor).getTask());
} while (!cursor.isLast());
return list;
} finally {
cursor.close();
}
}
/**
* Remove all alerts from the task
*/

@ -40,13 +40,4 @@ public enum Importance {
public int getLabelResource() {
return label;
}
public int getColorResource() {
return color;
}
public int getTaskListColor() {
return taskListColor;
}
}

@ -5,8 +5,6 @@
*/
package com.timsu.astrid.data.enums;
import android.content.res.Resources;
import java.util.Date;
public enum RepeatInterval {
@ -47,14 +45,4 @@ public enum RepeatInterval {
}
abstract public void offsetDateBy(Date input, int number);
public static String[] getLabels(Resources r) {
int intervalCount = RepeatInterval.values().length;
String[] result = new String[intervalCount];
for (int i = 0; i < intervalCount; i++) {
result[i] = r.getString(RepeatInterval.values()[i].getLabelResource());
}
return result;
}
}

@ -1,25 +0,0 @@
/**
* Copyright (c) 2012 Todoroo Inc
*
* See the file "LICENSE" for the full license governing this code.
*/
package com.timsu.astrid.data.location;
public class GeoPoint {
private int latitude, longitude;
public GeoPoint(int latitude, int longitude) {
this.latitude = latitude;
this.longitude = longitude;
}
public int getLatitudeE6() {
return latitude;
}
public int getLongitudeE6() {
return longitude;
}
}

@ -31,16 +31,6 @@ public class SyncDataController extends LegacyAbstractController {
// --- updated tasks list
/**
* Mark all updated tasks as finished synchronizing
*/
public boolean clearUpdatedTaskList(int syncServiceId) throws SQLException {
ContentValues values = new ContentValues();
values.put(SyncMapping.UPDATED, 0);
return syncDatabase.update(syncTable, values,
SyncMapping.SYNC_SERVICE + " = " + syncServiceId, null) > 0;
}
/**
* Indicate that this task's properties were updated
*/
@ -136,39 +126,6 @@ public class SyncDataController extends LegacyAbstractController {
}
}
/**
* Saves the given task to the database. Returns true on success.
*/
public boolean saveSyncMapping(SyncMapping mapping) {
long newRow = syncDatabase.insert(syncTable, SyncMapping.TASK,
mapping.getMergedValues());
mapping.setId(newRow);
return newRow >= 0;
}
/**
* Deletes the given mapping. Returns true on success
*/
public boolean deleteSyncMapping(SyncMapping mapping) {
// was never saved
if (mapping.getId() == 0) {
return false;
}
return syncDatabase.delete(syncTable, KEY_ROWID + "=" +
mapping.getId(), null) > 0;
}
/**
* Deletes the given mapping. Returns true on success
*/
public boolean deleteAllMappings(int syncServiceId) {
return syncDatabase.delete(syncTable, SyncMapping.SYNC_SERVICE +
"=" + syncServiceId, null) > 0;
}
// --- boilerplate
/**

@ -14,12 +14,10 @@ import android.database.sqlite.SQLiteDatabase;
import com.timsu.astrid.data.LegacyAbstractController;
import com.timsu.astrid.data.tag.AbstractTagModel.TagModelDatabaseHelper;
import com.timsu.astrid.data.tag.TagToTaskMapping.TagToTaskMappingDatabaseHelper;
import com.timsu.astrid.data.task.AbstractTaskModel.TaskModelDatabaseHelper;
import com.timsu.astrid.data.task.TaskIdentifier;
import com.todoroo.astrid.provider.Astrid2TaskProvider;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
/**
@ -95,86 +93,6 @@ public class TagController extends LegacyAbstractController {
return list;
}
/**
* Get a list of task identifiers for the given tag.
* This searches for TAGGED tasks only.
* Use getUntaggedTasks() to get a list of UNTAGGED tasks *
*/
public LinkedList<TaskIdentifier> getTaggedTasks(TagIdentifier tagId)
throws SQLException {
LinkedList<TaskIdentifier> list = new LinkedList<TaskIdentifier>();
Cursor cursor = tagToTaskMapDatabase.query(tagTaskTable,
TagToTaskMapping.FIELD_LIST, TagToTaskMapping.TAG + " = ?",
new String[]{tagId.idAsString()}, null, null, null);
try {
if (cursor.getCount() == 0) {
return list;
}
do {
cursor.moveToNext();
list.add(new TagToTaskMapping(cursor).getTask());
} while (!cursor.isLast());
} finally {
cursor.close();
}
return list;
}
/**
* Returns a list of task identifiers in the provided set that are UNtagged.
* <p/>
* The calling SubActivity must provide the set of tasks, since
* TagController cannot access the appropriate instance of TaskController.
* <p/>
* The current implementation is not very efficient, because queries
* the TagToTask map once for each active task.
*/
public LinkedList<TaskIdentifier> getUntaggedTasks() throws SQLException {
HashSet<Long> ids = new HashSet<Long>();
String[] tagMapColumns = new String[]{TagToTaskMapping.TASK};
Cursor tagMapCursor = tagToTaskMapDatabase.query(tagTaskTable,
tagMapColumns, null, null, TagToTaskMapping.TASK, null,
TagToTaskMapping.TASK + " ASC");
SQLiteDatabase taskDatabase = new TaskModelDatabaseHelper(context,
tasksTable, tasksTable).getReadableDatabase();
String[] taskColumns = new String[]{KEY_ROWID};
Cursor taskCursor = taskDatabase.query(tasksTable, taskColumns,
null, null, null, null, KEY_ROWID + " ASC");
LinkedList<TaskIdentifier> list = new LinkedList<TaskIdentifier>();
try {
if (taskCursor.getCount() == 0) {
return list;
}
do {
taskCursor.moveToNext();
ids.add(taskCursor.getLong(0));
} while (!taskCursor.isLast());
if (tagMapCursor.getCount() > 0) {
do {
tagMapCursor.moveToNext();
ids.remove(tagMapCursor.getLong(0));
} while (!tagMapCursor.isLast());
}
} finally {
taskCursor.close();
tagMapCursor.close();
taskDatabase.close();
}
for (Long id : ids) {
list.add(new TaskIdentifier(id));
}
return list;
}
// --- single tag operations
public TagIdentifier createTag(String name) throws SQLException {
@ -209,50 +127,6 @@ public class TagController extends LegacyAbstractController {
return saveSucessful;
}
/**
* Returns a TaskModelForView corresponding to the given Tag Name
*/
public TagModelForView fetchTagFromName(String name) throws SQLException {
Cursor cursor = tagDatabase.query(true, tagsTable,
TagModelForView.FIELD_LIST,
AbstractTagModel.NAME + " = ?", new String[]{name}, null, null, null, null);
try {
if (cursor != null && cursor.getCount() > 0) {
cursor.moveToFirst();
return new TagModelForView(cursor);
}
return null;
} finally {
if (cursor != null) {
cursor.close();
}
}
}
/**
* Returns a TaskModelForView corresponding to the given TagIdentifier
*/
public TagModelForView fetchTagForView(TagIdentifier tagId) throws SQLException {
long id = tagId.getId();
Cursor cursor = tagDatabase.query(true, tagsTable,
TagModelForView.FIELD_LIST,
KEY_ROWID + "=" + id, null, null, null, null, null);
try {
if (cursor != null) {
cursor.moveToFirst();
return new TagModelForView(cursor);
}
throw new SQLException("Returned empty set!");
} finally {
if (cursor != null) {
cursor.close();
}
}
}
/**
* Deletes the tag and removes tag/task mappings
*/

@ -28,31 +28,6 @@ public class TagModelForView extends AbstractTagModel {
public static final String HIDDEN_FROM_MAIN_LIST_PREFIX = "_";
/**
* Returns a TagModelForView object to represent "Untagged" tasks,
* whose Identifier is defined by the static final UNTAGGED_IDENTIFIER.
* <p/>
* Pass in a string to show the "Untagged" name in the desired language.
*
* @param untaggedLabel
* @return
*/
public static TagModelForView getUntaggedModel(String untaggedLabel) {
UNTAGGED_TASKS = new TagModelForView(untaggedLabel);
UNTAGGED_TASKS.setTagIdentifier(UNTAGGED_IDENTIFIER);
return UNTAGGED_TASKS;
}
/**
* Returns the default/last-used TagModelForView representing "Untagged"
* tasks. Set the localized name using getUntaggedModel(String...)
*/
public static TagModelForView getUntaggedModel() {
UNTAGGED_TASKS.setTagIdentifier(UNTAGGED_IDENTIFIER);
return UNTAGGED_TASKS;
}
// --- constructors
/**
@ -81,16 +56,4 @@ public class TagModelForView extends AbstractTagModel {
public String toString() {
return getName();
}
public boolean shouldHideFromMainList() {
return getName().startsWith(HIDDEN_FROM_MAIN_LIST_PREFIX);
}
public void toggleHideFromMainList() {
if (shouldHideFromMainList()) {
setName(getName().substring(HIDDEN_FROM_MAIN_LIST_PREFIX.length()));
} else {
setName(HIDDEN_FROM_MAIN_LIST_PREFIX + getName());
}
}
}

@ -362,17 +362,6 @@ public abstract class AbstractTaskModel extends LegacyAbstractModel {
return value;
}
public static int toSingleField(RepeatInfo repeatInfo) {
int repeat;
if (repeatInfo == null) {
repeat = 0;
} else {
repeat = (repeatInfo.value << REPEAT_VALUE_OFFSET) +
repeatInfo.interval.ordinal();
}
return repeat;
}
public static RepeatInfo fromSingleField(int repeat) {
if (repeat == 0) {
return null;

@ -5,7 +5,6 @@
*/
package com.timsu.astrid.data.task;
import android.app.Activity;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
@ -18,17 +17,13 @@ import android.net.Uri;
import android.util.Log;
import com.timsu.astrid.data.LegacyAbstractController;
import com.timsu.astrid.data.alerts.AlertController;
import com.timsu.astrid.data.sync.SyncDataController;
import com.timsu.astrid.data.task.AbstractTaskModel.RepeatInfo;
import com.timsu.astrid.data.task.AbstractTaskModel.TaskModelDatabaseHelper;
import com.todoroo.astrid.provider.Astrid2TaskProvider;
import com.todoroo.astrid.widget.TasksWidget.WidgetUpdateService;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
/**
* Controller for task-related operations
@ -43,89 +38,6 @@ public class TaskController extends LegacyAbstractController {
// --- task list operations
/**
* Return a list of all active tasks with notifications
*/
public HashSet<TaskModelForNotify> getTasksWithNotifications() {
HashSet<TaskModelForNotify> list = new HashSet<TaskModelForNotify>();
Cursor cursor = database.query(tasksTable, TaskModelForNotify.FIELD_LIST,
String.format("%s < %d AND (%s != 0 OR %s != 0)",
AbstractTaskModel.PROGRESS_PERCENTAGE,
AbstractTaskModel.COMPLETE_PERCENTAGE,
AbstractTaskModel.NOTIFICATIONS,
AbstractTaskModel.NOTIFICATION_FLAGS), null, null, null, null, null);
try {
if (cursor.getCount() == 0) {
return list;
}
do {
cursor.moveToNext();
list.add(new TaskModelForNotify(cursor));
} while (!cursor.isLast());
return list;
} finally {
cursor.close();
}
}
/**
* Return a list of all active tasks with deadlines
*/
public ArrayList<TaskModelForNotify> getTasksWithDeadlines() {
ArrayList<TaskModelForNotify> list = new ArrayList<TaskModelForNotify>();
Cursor cursor = database.query(tasksTable, TaskModelForNotify.FIELD_LIST,
String.format("%s < %d AND (%s != 0 OR %s != 0)",
AbstractTaskModel.PROGRESS_PERCENTAGE,
AbstractTaskModel.COMPLETE_PERCENTAGE,
AbstractTaskModel.DEFINITE_DUE_DATE,
AbstractTaskModel.PREFERRED_DUE_DATE), null, null, null, null, null);
try {
if (cursor.getCount() == 0) {
return list;
}
do {
cursor.moveToNext();
list.add(new TaskModelForNotify(cursor));
} while (!cursor.isLast());
return list;
} finally {
cursor.close();
}
}
/**
* Return a list of all of the tasks with progress < COMPLETE_PERCENTAGE
*/
public Cursor getActiveTaskListCursor() {
return database.query(tasksTable, TaskModelForList.FIELD_LIST,
AbstractTaskModel.PROGRESS_PERCENTAGE + " < " +
AbstractTaskModel.COMPLETE_PERCENTAGE, null, null, null,
null, null);
}
/**
* Return a list of all of the tasks matching selection
*/
public Cursor getMatchingTasksForProvider(String selection,
String[] selectionArgs) {
return database.query(tasksTable, TaskModelForProvider.FIELD_LIST,
selection, selectionArgs, null, null,
null, null);
}
/**
* Return a list of all tasks
*/
public Cursor getAllTaskListCursor() {
return database.query(tasksTable, TaskModelForList.FIELD_LIST,
null, null, null, null, null, null);
}
/**
* Return a list of all tasks
*/
@ -135,113 +47,6 @@ public class TaskController extends LegacyAbstractController {
null, null);
}
/**
* Delete all completed tasks with date < older than date
*/
public int deleteCompletedTasksOlderThan(Date olderThanDate) {
return database.delete(tasksTable, String.format("`%s` >= '%d' AND `%s` <= '%d'",
AbstractTaskModel.PROGRESS_PERCENTAGE, AbstractTaskModel.COMPLETE_PERCENTAGE,
AbstractTaskModel.COMPLETION_DATE, olderThanDate.getTime()), null);
}
/**
* Create a list of tasks from the db cursor given
*/
public ArrayList<TaskModelForList> createTaskListFromCursor(Cursor cursor) {
ArrayList<TaskModelForList> list = new ArrayList<TaskModelForList>();
if (cursor.getCount() == 0) {
return list;
}
do {
cursor.moveToNext();
list.add(new TaskModelForList(cursor));
} while (!cursor.isLast());
return list;
}
/**
* Helper method to take a cursor pointing to a list of id's and generate
* a hashset
*/
private HashSet<TaskIdentifier> createTaskIdentifierSet(Cursor cursor) {
HashSet<TaskIdentifier> list = new HashSet<TaskIdentifier>();
try {
if (cursor.getCount() == 0) {
return list;
}
do {
cursor.moveToNext();
list.add(new TaskIdentifier(cursor.getInt(
cursor.getColumnIndexOrThrow(KEY_ROWID))));
} while (!cursor.isLast());
return list;
} finally {
cursor.close();
}
}
/**
* Get identifiers for all tasks
*/
public HashSet<TaskIdentifier> getAllTaskIdentifiers() {
Cursor cursor = database.query(tasksTable, new String[]{KEY_ROWID},
null, null, null, null, null, null);
return createTaskIdentifierSet(cursor);
}
/**
* Get identifiers for all non-completed tasks
*/
public HashSet<TaskIdentifier> getActiveTaskIdentifiers() {
Cursor cursor = database.query(tasksTable, new String[]{KEY_ROWID},
AbstractTaskModel.PROGRESS_PERCENTAGE + " < " +
AbstractTaskModel.COMPLETE_PERCENTAGE, null, null, null, null, null);
return createTaskIdentifierSet(cursor);
}
/**
* Get identifiers for all non-completed, non-hidden tasks
*/
public HashSet<TaskIdentifier> getActiveVisibleTaskIdentifiers() {
Cursor cursor = database.query(tasksTable, new String[]{KEY_ROWID},
AbstractTaskModel.PROGRESS_PERCENTAGE + " < " +
AbstractTaskModel.COMPLETE_PERCENTAGE + " AND (" +
AbstractTaskModel.HIDDEN_UNTIL + " ISNULL OR " + AbstractTaskModel.HIDDEN_UNTIL + " < " +
System.currentTimeMillis() + ")", null, null, null, null, null);
return createTaskIdentifierSet(cursor);
}
/**
* Create a weighted list of tasks from the db cursor given
*/
public Cursor getTaskListCursorById(List<TaskIdentifier> idList) {
StringBuilder where = new StringBuilder();
for (int i = 0; i < idList.size(); i++) {
where.append(KEY_ROWID);
where.append("=");
where.append(idList.get(i).idAsString());
if (i < idList.size() - 1) {
where.append(" OR ");
}
}
// hack for empty arrays
if (idList.size() == 0) {
where.append("0");
}
return database.query(true, tasksTable,
TaskModelForList.FIELD_LIST, where.toString(), null, null,
null, null, null);
}
// --- single task operations
/**
@ -327,13 +132,6 @@ public class TaskController extends LegacyAbstractController {
// task timer was updated, update notification bar
if (values.containsKey(AbstractTaskModel.TIMER_START)) {
// show notification bar if timer was started
// if(values.getAsLong(AbstractTaskModel.TIMER_START) != 0) {
// ReminderService.showTimingNotification(context,
// task.getTaskIdentifier(), task.getName());
// } else {
// ReminderService.clearAllNotifications(context, task.getTaskIdentifier());
// }
}
// due date was updated, update calendar event
@ -350,20 +148,8 @@ public class TaskController extends LegacyAbstractController {
ContentResolver cr = context.getContentResolver();
Uri uri = Uri.parse(uriAsString);
// Integer estimated = null;
// if(values.containsKey(AbstractTaskModel.ESTIMATED_SECONDS))
//// estimated = values.getAsInteger(AbstractTaskModel.ESTIMATED_SECONDS);
// else { // read from event
// Cursor event = cr.query(uri, new String[] {"dtstart", "dtend"},
// null, null, null);
// event.moveToFirst();
//// estimated = (event.getInt(1) - event.getInt(0))/1000;
// }
// create new start and end date for this event
ContentValues newValues = new ContentValues();
/*TaskEditActivity.createCalendarStartEndTimes(task.getPreferredDueDate(),
task.getDefiniteDueDate(), estimated, newValues); TODO */
cr.update(uri, newValues, null, null);
}
} catch (Exception e) {
@ -396,12 +182,6 @@ public class TaskController extends LegacyAbstractController {
// handle sync-on-complete
if ((model.getFlags() & TaskModelForHandlers.FLAG_SYNC_ON_COMPLETE) > 0 &&
!duringSync) {
// Synchronizer synchronizer = new Synchronizer(model.getTaskIdentifier());
// synchronizer.synchronize(context, new SynchronizerListener() {
// public void onSynchronizerFinished(int numServicesSynced) {
//// TaskListSubActivity.shouldRefreshTaskList = true;
// }
// });
}
cursor.close();
@ -412,9 +192,6 @@ public class TaskController extends LegacyAbstractController {
* Clean up state from a task. Called when deleting or completing it
*/
private void cleanupTask(TaskIdentifier taskId, boolean isRepeating) {
// delete notifications & alarms
// ReminderService.deleteAlarm(context, null, taskId.getId());
// delete calendar event if not repeating
if (!isRepeating) {
try {
@ -449,124 +226,6 @@ public class TaskController extends LegacyAbstractController {
// --- fetching different models
/**
* Creates a new task and returns the task identifier
*/
public TaskModelForEdit createNewTaskForEdit() {
TaskModelForEdit task = new TaskModelForEdit();
task.setTaskIdentifier(null);
return task;
}
/**
* Returns a TaskModelForEdit corresponding to the given TaskIdentifier
*/
public TaskModelForEdit fetchTaskForEdit(Activity activity, TaskIdentifier
taskId) throws SQLException {
Cursor cursor = fetchTaskCursor(taskId, TaskModelForEdit.FIELD_LIST);
if (cursor == null) {
return null;
}
activity.startManagingCursor(cursor);
return new TaskModelForEdit(taskId, cursor);
}
/**
* Returns a TaskModelForList corresponding to the given TaskIdentifier
*/
public TaskModelForList fetchTaskForList(TaskIdentifier taskId) throws SQLException {
Cursor cursor = fetchTaskCursor(taskId, TaskModelForList.FIELD_LIST);
if (cursor == null) {
return null;
}
TaskModelForList model = new TaskModelForList(cursor);
cursor.close();
return model;
}
/**
* Returns a TaskModelForXml corresponding to the given TaskIdentifier
*/
public TaskModelForXml fetchTaskForXml(TaskIdentifier taskId) throws SQLException {
Cursor cursor = fetchTaskCursor(taskId, TaskModelForXml.FIELD_LIST);
if (cursor == null) {
return null;
}
TaskModelForXml model = new TaskModelForXml(cursor);
cursor.close();
return model;
}
/* Attempts to return a TaskModelForXml for the given name and creation date */
public TaskModelForXml fetchTaskForXml(String name, Date creationDate) {
Cursor cursor;
try {
cursor = fetchTaskCursor(name, creationDate.getTime(),
TaskModelForXml.FIELD_LIST);
} catch (SQLException e) {
return null;
}
if (cursor == null || cursor.getCount() == 0) {
return null;
}
TaskModelForXml model = new TaskModelForXml(cursor);
cursor.close();
return model;
}
/**
* Returns a TaskModelForReminder corresponding to the given TaskIdentifier
*/
public TaskModelForReminder fetchTaskForReminder(TaskIdentifier taskId) throws SQLException {
Cursor cursor = fetchTaskCursor(taskId, TaskModelForReminder.FIELD_LIST);
TaskModelForReminder model = new TaskModelForReminder(cursor);
cursor.close();
return model;
}
/**
* Returns a TaskModelForSync corresponding to the given TaskIdentifier
*/
public TaskModelForSync fetchTaskForSync(TaskIdentifier taskId) throws SQLException {
Cursor cursor = fetchTaskCursor(taskId, TaskModelForSync.FIELD_LIST);
TaskModelForSync model = new TaskModelForSync(cursor);
cursor.close();
return model;
}
/**
* Returns a TaskModelForView by name
*/
public TaskModelForSync searchForTaskForSync(String name) throws SQLException {
Cursor cursor = database.query(true, tasksTable, TaskModelForSync.FIELD_LIST,
AbstractTaskModel.NAME + " = ? AND " +
AbstractTaskModel.PROGRESS_PERCENTAGE + " < " +
AbstractTaskModel.COMPLETE_PERCENTAGE,
new String[]{name}, null, null, null, null);
try {
if (cursor == null || cursor.getCount() == 0) {
return null;
}
cursor.moveToFirst();
return new TaskModelForSync(cursor);
} finally {
if (cursor != null) {
cursor.close();
}
}
}
/**
* Returns a TaskModelForView corresponding to the given TaskIdentifier
*/
public TaskModelForNotify fetchTaskForNotify(TaskIdentifier taskId) throws SQLException {
Cursor cursor = fetchTaskCursor(taskId, TaskModelForNotify.FIELD_LIST);
TaskModelForNotify model = new TaskModelForNotify(cursor);
cursor.close();
return model;
}
/**
* Moves cursor to the task.
* Don't forget to close the cursor when you're done.
@ -583,104 +242,6 @@ public class TaskController extends LegacyAbstractController {
return cursor;
}
/**
* Returns null if unsuccessful, otherwise moves cursor to the task.
* Don't forget to close the cursor when you're done.
*/
private Cursor fetchTaskCursor(String name, long creationDate, String[] fieldList) {
// truncate millis
final String where = AbstractTaskModel.NAME + " = ? AND "
+ AbstractTaskModel.CREATION_DATE + " LIKE ?";
String approximateCreationDate = creationDate / 1000 + "%";
Cursor cursor = database.query(true, tasksTable, fieldList,
where, new String[]{name, approximateCreationDate}, null, null, null, null);
if (cursor == null) {
throw new SQLException("Returned empty set!");
}
if (cursor.moveToFirst()) {
return cursor;
}
cursor.close();
return null;
}
// --- methods supporting individual features
/**
* Returns a TaskModelForView corresponding to the given TaskIdentifier
*/
public int fetchTaskPostponeCount(TaskIdentifier taskId) throws SQLException {
Cursor cursor = fetchTaskCursor(taskId, new String[]{AbstractTaskModel.POSTPONE_COUNT});
try {
if (cursor == null || cursor.getCount() == 0) {
return 0;
}
cursor.moveToFirst();
return cursor.getInt(0);
} catch (Exception e) {
return 0;
} finally {
if (cursor != null) {
cursor.close();
}
}
}
public void updateAlarmForTask() throws SQLException {
// TaskModelForNotify task = fetchTaskForNotify(taskId);
AlertController alertController = new AlertController(context);
alertController.open();
// ReminderService.updateAlarm(context, this, alertController, task);
alertController.close();
}
public ArrayList<TaskModelForWidget> getTasksForWidget(String limit) {
Cursor cursor = database.query(tasksTable, TaskModelForWidget.FIELD_LIST,
AbstractTaskModel.PROGRESS_PERCENTAGE + " < " +
AbstractTaskModel.COMPLETE_PERCENTAGE + " AND (" +
AbstractTaskModel.HIDDEN_UNTIL + " ISNULL OR " + AbstractTaskModel.HIDDEN_UNTIL + " < " +
System.currentTimeMillis() + ")", null, null, null,
AbstractTaskModel.IMPORTANCE + " * " + 5 * 24 * 3600 * 1000L +
" + CASE WHEN MAX(pdd, ddd) = 0 THEN " +
(System.currentTimeMillis() + 7 * 24 * 3600 * 1000L) +
" ELSE (CASE WHEN pdd = 0 THEN ddd ELSE pdd END) END ASC", limit);
try {
ArrayList<TaskModelForWidget> list = new ArrayList<TaskModelForWidget>();
for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
list.add(new TaskModelForWidget(cursor));
}
return list;
} finally {
cursor.close();
}
}
public ArrayList<TaskModelForProvider> getTasksForProvider(String limit) {
Cursor cursor = database.query(tasksTable, TaskModelForProvider.FIELD_LIST,
AbstractTaskModel.PROGRESS_PERCENTAGE + " < " +
AbstractTaskModel.COMPLETE_PERCENTAGE + " AND (" +
AbstractTaskModel.HIDDEN_UNTIL + " ISNULL OR " + AbstractTaskModel.HIDDEN_UNTIL + " < " +
System.currentTimeMillis() + ")", null, null, null,
AbstractTaskModel.IMPORTANCE + " * " + 5 * 24 * 3600 * 1000L +
" + CASE WHEN MAX(pdd, ddd) = 0 THEN " +
(System.currentTimeMillis() + 7 * 24 * 3600 * 1000L) +
" ELSE (CASE WHEN pdd = 0 THEN ddd ELSE pdd END) END ASC", limit);
try {
ArrayList<TaskModelForProvider> list = new ArrayList<TaskModelForProvider>();
for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
list.add(new TaskModelForProvider(cursor));
}
return list;
} finally {
cursor.close();
}
}
// --- boilerplate
/**

@ -143,10 +143,6 @@ public class TaskModelForList extends AbstractTaskModel {
return super.getElapsedSeconds();
}
public static int getCompletedPercentage() {
return COMPLETE_PERCENTAGE;
}
@Override
public Date getDefiniteDueDate() {
return super.getDefiniteDueDate();
@ -234,10 +230,6 @@ public class TaskModelForList extends AbstractTaskModel {
super.stopTimerAndUpdateElapsedTime();
}
public static String getNameField() {
return NAME;
}
@Override
public void setPreferredDueDate(Date preferredDueDate) {
super.setPreferredDueDate(preferredDueDate);

@ -1,387 +0,0 @@
/***
Copyright (c) 2008-2009 CommonsWare, LLC
Portions (c) 2009 Google, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may
not use this file except in compliance with the License. You may obtain
a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.commonsware.cwac.merge;
import android.database.DataSetObserver;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListAdapter;
import android.widget.SectionIndexer;
import com.commonsware.cwac.sacklist.SackOfViewsAdapter;
import java.util.ArrayList;
import java.util.List;
/**
* Adapter that merges multiple child adapters and views
* into a single contiguous whole.
* <p/>
* Adapters used as pieces within MergeAdapter must
* have view type IDs monotonically increasing from 0. Ideally,
* adapters also have distinct ranges for their row ids, as
* returned by getItemId().
*/
public class MergeAdapter extends BaseAdapter implements SectionIndexer {
protected ArrayList<ListAdapter> pieces = new ArrayList<ListAdapter>();
/**
* Stock constructor, simply chaining to the superclass.
*/
public MergeAdapter() {
}
/**
* Adds a new adapter to the roster of things to appear
* in the aggregate list.
*
* @param adapter Source for row views for this section
*/
public void addAdapter(ListAdapter adapter) {
pieces.add(adapter);
adapter.registerDataSetObserver(new CascadeDataSetObserver());
}
/**
* Adds a new View to the roster of things to appear
* in the aggregate list.
*
* @param view Single view to add
*/
public void addView(View view) {
addView(view, false);
}
/**
* Adds a new View to the roster of things to appear
* in the aggregate list.
*
* @param view Single view to add
* @param enabled false if views are disabled, true if enabled
*/
public void addView(View view, boolean enabled) {
ArrayList<View> list = new ArrayList<View>(1);
list.add(view);
addViews(list, enabled);
}
/**
* Adds a list of views to the roster of things to appear
* in the aggregate list.
*
* @param views List of views to add
*/
public void addViews(List<View> views) {
addViews(views, false);
}
/**
* Adds a list of views to the roster of things to appear
* in the aggregate list.
*
* @param views List of views to add
* @param enabled false if views are disabled, true if enabled
*/
public void addViews(List<View> views, boolean enabled) {
if (enabled) {
addAdapter(new EnabledSackAdapter(views));
} else {
addAdapter(new SackOfViewsAdapter(views));
}
}
/**
* Get the data item associated with the specified
* position in the data set.
*
* @param position Position of the item whose data we want
*/
@Override
public Object getItem(int position) {
for (ListAdapter piece : pieces) {
int size = piece.getCount();
if (position < size) {
return piece.getItem(position);
}
position -= size;
}
return null;
}
/**
* Get the adapter associated with the specified
* position in the data set.
*
* @param position Position of the item whose adapter we want
*/
public ListAdapter getAdapter(int position) {
for (ListAdapter piece : pieces) {
int size = piece.getCount();
if (position < size) {
return piece;
}
position -= size;
}
return null;
}
/**
* How many items are in the data set represented by this
* Adapter.
*/
@Override
public int getCount() {
int total = 0;
for (ListAdapter piece : pieces) {
total += piece.getCount();
}
return total;
}
/**
* Returns the number of types of Views that will be
* created by getView().
*/
@Override
public int getViewTypeCount() {
int total = 0;
for (ListAdapter piece : pieces) {
total += piece.getViewTypeCount();
}
return Math.max(total, 1); // needed for setListAdapter() before content add'
}
/**
* Get the type of View that will be created by getView()
* for the specified item.
*
* @param position Position of the item whose data we want
*/
@Override
public int getItemViewType(int position) {
int typeOffset = 0;
int result = -1;
for (ListAdapter piece : pieces) {
int size = piece.getCount();
if (position < size) {
result = typeOffset + piece.getItemViewType(position);
break;
}
position -= size;
typeOffset += piece.getViewTypeCount();
}
return result;
}
/**
* Are all items in this ListAdapter enabled? If yes it
* means all items are selectable and clickable.
*/
@Override
public boolean areAllItemsEnabled() {
return false;
}
/**
* Returns true if the item at the specified position is
* not a separator.
*
* @param position Position of the item whose data we want
*/
@Override
public boolean isEnabled(int position) {
for (ListAdapter piece : pieces) {
int size = piece.getCount();
if (position < size) {
return piece.isEnabled(position);
}
position -= size;
}
return false;
}
/**
* Get a View that displays the data at the specified
* position in the data set.
*
* @param position Position of the item whose data we want
* @param convertView View to recycle, if not null
* @param parent ViewGroup containing the returned View
*/
@Override
public View getView(int position, View convertView,
ViewGroup parent) {
for (ListAdapter piece : pieces) {
int size = piece.getCount();
if (position < size) {
return piece.getView(position, convertView, parent);
}
position -= size;
}
return null;
}
/**
* Get the row id associated with the specified position
* in the list.
*
* @param position Position of the item whose data we want
*/
@Override
public long getItemId(int position) {
for (ListAdapter piece : pieces) {
int size = piece.getCount();
if (position < size) {
return piece.getItemId(position);
}
position -= size;
}
return -1;
}
@Override
public int getPositionForSection(int section) {
int position = 0;
for (ListAdapter piece : pieces) {
if (piece instanceof SectionIndexer) {
Object[] sections = ((SectionIndexer) piece).getSections();
int numSections = 0;
if (sections != null) {
numSections = sections.length;
}
if (section < numSections) {
return position + ((SectionIndexer) piece).getPositionForSection(section);
} else if (sections != null) {
section -= numSections;
}
}
position += piece.getCount();
}
return 0;
}
@Override
public int getSectionForPosition(int position) {
int section = 0;
for (ListAdapter piece : pieces) {
int size = piece.getCount();
if (position < size) {
if (piece instanceof SectionIndexer) {
return section + ((SectionIndexer) piece).getSectionForPosition(position);
}
return 0;
} else {
if (piece instanceof SectionIndexer) {
Object[] sections = ((SectionIndexer) piece).getSections();
if (sections != null) {
section += sections.length;
}
}
}
position -= size;
}
return 0;
}
@Override
public Object[] getSections() {
ArrayList<Object> sections = new ArrayList<Object>();
for (ListAdapter piece : pieces) {
if (piece instanceof SectionIndexer) {
Object[] curSections = ((SectionIndexer) piece).getSections();
if (curSections != null) {
for (Object section : curSections) {
sections.add(section);
}
}
}
}
if (sections.size() == 0) {
return null;
}
return sections.toArray(new Object[0]);
}
private static class EnabledSackAdapter extends SackOfViewsAdapter {
public EnabledSackAdapter(List<View> views) {
super(views);
}
@Override
public boolean areAllItemsEnabled() {
return true;
}
@Override
public boolean isEnabled(int position) {
return true;
}
}
private class CascadeDataSetObserver extends DataSetObserver {
@Override
public void onChanged() {
notifyDataSetChanged();
}
@Override
public void onInvalidated() {
notifyDataSetInvalidated();
}
}
}

@ -1,106 +0,0 @@
/**
* Copyright (c) 2012 Todoroo Inc
*
* See the file "LICENSE" for the full license governing this code.
*/
package com.commonsware.cwac.merge;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListAdapter;
import android.widget.SpinnerAdapter;
import java.util.List;
/**
* Adapter that merges multiple child adapters into a single
* contiguous whole to be consumed by a Spinner.
* <p/>
* Adapters used as pieces within MergeSpinnerAdapter must
* have view type IDs monotonically increasing from 0.
* Ideally, adapters also have distinct ranges for their row
* ids, as returned by getItemId().
* <p/>
* All Adapters used as pieces within MergeSpinnerAdapter
* must be properly-configured implementations of
* SpinnerAdapter (e.g., ArrayAdapter, CursorAdapter).
*/
public class MergeSpinnerAdapter extends MergeAdapter {
/**
* Stock constructor, simply chaining to the superclass.
*/
public MergeSpinnerAdapter() {
}
/*
* Returns the drop-down View for a given position, by
* iterating over the pieces. Assumes that all pieces are
* implementations of SpinnerAdapter.
*
* @see android.widget.BaseAdapter#getDropDownView(int,
* android.view.View, android.view.ViewGroup)
*/
@Override
public View getDropDownView(int position, View convertView,
ViewGroup parent) {
for (ListAdapter piece : pieces) {
int size = piece.getCount();
if (position < size) {
return ((SpinnerAdapter) piece).getDropDownView(position,
convertView,
parent);
}
position -= size;
}
return null;
}
/**
* Adds a new View to the roster of things to appear in
* the aggregate list.
*
* @param view Single view to add
*/
@Override
public void addView(View view) {
throw new RuntimeException("Not supported with MergeSpinnerAdapter");
}
/**
* Adds a new View to the roster of things to appear in
* the aggregate list.
*
* @param view Single view to add
* @param enabled false if views are disabled, true if enabled
*/
@Override
public void addView(View view, boolean enabled) {
throw new RuntimeException("Not supported with MergeSpinnerAdapter");
}
/**
* Adds a list of views to the roster of things to appear
* in the aggregate list.
*
* @param views List of views to add
*/
@Override
public void addViews(List<View> views) {
throw new RuntimeException("Not supported with MergeSpinnerAdapter");
}
/**
* Adds a list of views to the roster of things to appear
* in the aggregate list.
*
* @param views List of views to add
* @param enabled false if views are disabled, true if enabled
*/
@Override
public void addViews(List<View> views, boolean enabled) {
throw new RuntimeException("Not supported with MergeSpinnerAdapter");
}
}

@ -312,16 +312,6 @@ public class AstridActivity extends SherlockFragmentActivity
// --- fragment helpers
protected void removeFragment(String tag) {
FragmentManager fm = getSupportFragmentManager();
Fragment fragment = fm.findFragmentByTag(tag);
if (fragment != null) {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.remove(fragment);
ft.commit();
}
}
protected Fragment setupFragment(String tag, int container, Class<? extends Fragment> cls, boolean createImmediate, boolean replace) {
final FragmentManager fm = getSupportFragmentManager();
Fragment fragment = fm.findFragmentByTag(tag);

@ -16,14 +16,9 @@
package com.todoroo.astrid.activity;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import com.timsu.astrid.R;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.service.TaskService;
@ -41,68 +36,6 @@ public final class Eula {
@Autowired
TaskService taskService;
/**
* Displays the EULA if necessary. This method should be called from the
* onCreate() method of your main Activity.
*
* @param activity The Activity to finish if the user rejects the EULA
*/
public static void showEula(final Activity activity) {
if (!new Eula().shouldShowEula(activity)) {
return;
}
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(R.string.DLG_eula_title);
builder.setCancelable(true);
builder.setPositiveButton(R.string.DLG_accept,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
accept(activity);
}
});
builder.setNegativeButton(R.string.DLG_decline,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
refuse(activity);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
refuse(activity);
}
});
builder.setMessage(AndroidUtilities.readFile(activity, R.raw.eula));
builder.show();
}
public static void showEulaBasic(Activity activity) {
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(R.string.DLG_eula_title);
builder.setMessage(AndroidUtilities.readFile(activity, R.raw.eula));
builder.setNeutralButton(android.R.string.ok, null);
builder.show();
}
private boolean shouldShowEula(Activity activity) {
if (Preferences.getBoolean(PREFERENCE_EULA_ACCEPTED, false)) {
return false;
}
SharedPreferences p = activity.getSharedPreferences("eula", Activity.MODE_PRIVATE); //$NON-NLS-1$
if (p.getBoolean(PREFERENCE_EULA_ACCEPTED, false)) {
return false;
}
if (taskService.countTasks() > 0) {
return false;
}
return true;
}
private static void accept(Activity activity) {
if (activity instanceof EulaCallback) {
((EulaCallback) activity).eulaAccepted();

@ -1,356 +0,0 @@
/**
* Copyright (c) 2012 Todoroo Inc
*
* See the file "LICENSE" for the full license governing this code.
*/
package com.todoroo.astrid.activity;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.ExpandableListAdapter;
import android.widget.ExpandableListView;
import android.widget.FrameLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
public class ExpandableListFragment extends Fragment
implements
ExpandableListView.OnChildClickListener, ExpandableListView.OnGroupCollapseListener,
ExpandableListView.OnGroupExpandListener {
static final int INTERNAL_EMPTY_ID = 0x00ff0001;
final private Handler mHandler = new Handler();
final private Runnable mRequestFocus = new Runnable() {
@Override
public void run() {
mList.focusableViewAvailable(mList);
}
};
final private AdapterView.OnItemClickListener mOnClickListener
= new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
onListItemClick();
}
};
ExpandableListAdapter mAdapter;
ExpandableListView mList;
View mEmptyView;
TextView mStandardEmptyView;
boolean mSetEmptyText;
boolean mListShown;
boolean mFinishedStart = false;
/**
* Provide default implementation to return a simple list view. Subclasses
* can override to replace with their own layout. If doing so, the
* returned view hierarchy <em>must</em> have a ListView whose id
* is {@link android.R.id#list android.R.id.list} and can optionally
* have a sibling view id {@link android.R.id#empty android.R.id.empty}
* that is to be shown when the list is empty.
* <p/>
* <p>If you are overriding this method with your own custom content,
* consider including the standard layout {@link android.R.layout#list_content}
* in your layout file, so that you continue to retain all of the standard
* behavior of ListFragment. In particular, this is currently the only
* way to have the built-in indeterminant progress state be shown.
*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
FrameLayout root = new FrameLayout(getActivity());
TextView tv = new TextView(getActivity());
tv.setId(INTERNAL_EMPTY_ID);
tv.setGravity(Gravity.CENTER);
root.addView(tv, new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
ExpandableListView lv = new ExpandableListView(getActivity());
lv.setId(android.R.id.list);
lv.setDrawSelectorOnTop(false);
root.addView(lv, new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
ListView.LayoutParams lp = new ListView.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
root.setLayoutParams(lp);
return root;
}
/**
* Attach to list view once Fragment is ready to run.
*/
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
ensureList();
}
/**
* Detach from list view.
*/
@Override
public void onDestroyView() {
mHandler.removeCallbacks(mRequestFocus);
mList = null;
super.onDestroyView();
}
/**
* This method will be called when an item in the list is selected.
* Subclasses should override. Subclasses can call
* getListView().getItemAtPosition(position) if they need to access the
* data associated with the selected item.
*/
public void onListItemClick() {
// override me
}
/**
* Provide the cursor for the list view.
*/
public void setListAdapter(ExpandableListAdapter adapter) {
boolean hadAdapter = mAdapter != null;
mAdapter = adapter;
if (mList != null) {
mList.setAdapter(adapter);
if (!mListShown && !hadAdapter) {
// The list was hidden, and previously didn't have an
// adapter. It is now time to show it.
setListShown(true, getView().getWindowToken() != null);
}
}
}
/**
* Set the currently selected list item to the specified
* position with the adapter's data
*
* @param position
*/
public void setSelection(int position) {
ensureList();
mList.setSelection(position);
}
public long getSelectedPosition() {
ensureList();
return mList.getSelectedPosition();
}
/**
* Sets the selection to the specified child. If the child is in a collapsed
* group, the group will only be expanded and child subsequently selected if
* shouldExpandGroup is set to true, otherwise the method will return false.
*
* @param groupPosition The position of the group that contains the child.
* @param childPosition The position of the child within the group.
* @param shouldExpandGroup Whether the child's group should be expanded if
* it is collapsed.
* @return Whether the selection was successfully set on the child.
*/
public boolean setSelectedChild(int groupPosition, int childPosition, boolean shouldExpandGroup) {
ensureList();
return mList.setSelectedChild(groupPosition, childPosition, shouldExpandGroup);
}
public void setItemChecked(int position, boolean value) {
ensureList();
mList.setItemChecked(position, value);
}
/**
* Sets the selection to the specified group.
*
* @param groupPosition The position of the group that should be selected.
*/
public void setSelectedGroup(int groupPosition) {
mList.setSelectedGroup(groupPosition);
}
public long getSelectedId() {
ensureList();
return mList.getSelectedId();
}
public ExpandableListView getExpandableListView() {
ensureList();
return mList;
}
/**
* The default content for a ListFragment has a TextView that can
* be shown when the list is empty. If you would like to have it
* shown, call this method to supply the text it should use.
*/
public void setEmptyText(CharSequence text) {
ensureList();
if (mStandardEmptyView == null) {
throw new IllegalStateException("Can't be used with a custom content view");
}
mStandardEmptyView.setText(text);
if (!mSetEmptyText) {
mList.setEmptyView(mStandardEmptyView);
mSetEmptyText = true;
}
}
/**
* Control whether the list is being displayed. You can make it not
* displayed if you are waiting for the initial data to show in it. During
* this time an indeterminant progress indicator will be shown instead.
* <p/>
* <p>Applications do not normally need to use this themselves. The default
* behavior of ListFragment is to start with the list not being shown, only
* showing it once an adapter is given with {@link #setListAdapter(ListAdapter)}.
* If the list at that point had not been shown, when it does get shown
* it will be do without the user ever seeing the hidden state.
*
* @param shown If true, the list view is shown; if false, the progress
* indicator. The initial value is true.
*/
public void setListShown(boolean shown) {
setListShown(shown, true);
}
/**
* Like {@link #setListShown(boolean)}, but no animation is used when
* transitioning from the previous state.
*/
public void setListShownNoAnimation(boolean shown) {
setListShown(shown, false);
}
/**
* Control whether the list is being displayed. You can make it not
* displayed if you are waiting for the initial data to show in it. During
* this time an indeterminant progress indicator will be shown instead.
*
* @param shown If true, the list view is shown; if false, the progress
* indicator. The initial value is true.
* @param animate If true, an animation will be used to transition to the
* new state.
*/
private void setListShown(boolean shown, boolean animate) {
ensureList();
if (mListShown == shown) {
return;
}
mListShown = shown;
if (shown) {
if (animate) {
mList.startAnimation(AnimationUtils.loadAnimation(
getActivity(), android.R.anim.fade_in));
}
mList.setVisibility(View.VISIBLE);
} else {
if (animate) {
mList.startAnimation(AnimationUtils.loadAnimation(
getActivity(), android.R.anim.fade_out));
}
mList.setVisibility(View.GONE);
}
}
/**
* Get the ListAdapter associated with this activity's ListView.
*/
public ExpandableListAdapter getExpandableListAdapter() {
return mAdapter;
}
private void ensureList() {
if (mList != null) {
return;
}
View root = getView();
if (root == null) {
throw new IllegalStateException("Content view not yet created");
}
if (root instanceof ExpandableListView) {
mList = (ExpandableListView) root;
} else {
mStandardEmptyView = (TextView) root.findViewById(INTERNAL_EMPTY_ID);
if (mStandardEmptyView == null) {
mEmptyView = root.findViewById(android.R.id.empty);
}
View rawListView = root.findViewById(android.R.id.list);
if (!(rawListView instanceof ExpandableListView)) {
if (rawListView == null) {
throw new RuntimeException(
"Your content must have a ExpandableListView whose id attribute is " +
"'android.R.id.list'");
}
throw new RuntimeException(
"Content has view with id attribute 'android.R.id.list' "
+ "that is not a ExpandableListView class");
}
mList = (ExpandableListView) rawListView;
if (mEmptyView != null) {
mList.setEmptyView(mEmptyView);
}
}
mListShown = true;
mList.setOnItemClickListener(mOnClickListener);
if (mAdapter != null) {
setListAdapter(mAdapter);
} else {
// We are starting without an adapter, so assume we won't
// have our data right away and start with the progress indicator.
setListShown(false, false);
}
mHandler.post(mRequestFocus);
}
public void onContentChanged() {
View emptyView = getView().findViewById(android.R.id.empty);
mList = (ExpandableListView) getView().findViewById(android.R.id.list);
if (mList == null) {
throw new RuntimeException(
"Your content must have a ExpandableListView whose id attribute is " +
"'android.R.id.list'");
}
if (emptyView != null) {
mList.setEmptyView(emptyView);
}
mList.setOnChildClickListener(this);
mList.setOnGroupExpandListener(this);
mList.setOnGroupCollapseListener(this);
if (mFinishedStart) {
setListAdapter(mAdapter);
}
mFinishedStart = true;
}
@Override
public void onGroupExpand(int groupPosition) {
// override me
}
@Override
public void onGroupCollapse(int groupPosition) {
// override me
}
@Override
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
return false;
}
}

@ -126,15 +126,12 @@ public class FilterListFragment extends SherlockListFragment {
R.layout.filter_adapter_row, false);
}
/* (non-Javadoc)
* @see com.todoroo.astrid.fragment.ExpandableListFragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Activity activity = getActivity();
int layout = getLayout(activity);
return (ViewGroup) activity.getLayoutInflater().inflate(layout, container, false);
return activity.getLayoutInflater().inflate(layout, container, false);
}
protected int getLayout(Activity activity) {

@ -777,13 +777,6 @@ public final class TaskEditFragment extends SherlockFragment implements
}
public long getTaskIdInProgress() {
if (model != null && model.getId() > 0) {
return model.getId();
}
return getActivity().getIntent().getLongExtra(TOKEN_ID, -1);
}
private void setIsNewTask(boolean isNewTask) {
this.isNewTask = isNewTask;
Activity activity = getActivity();
@ -1344,27 +1337,6 @@ public final class TaskEditFragment extends SherlockFragment implements
}
}
public static void setViewHeightBasedOnChildren(LinearLayout view) {
int totalHeight = 0;
int desiredWidth = MeasureSpec.makeMeasureSpec(view.getWidth(),
MeasureSpec.AT_MOST);
for (int i = 0; i < view.getChildCount(); i++) {
View listItem = view.getChildAt(i);
listItem.measure(desiredWidth, MeasureSpec.UNSPECIFIED);
totalHeight += listItem.getMeasuredHeight();
}
ViewGroup.LayoutParams params = view.getLayoutParams();
if (params == null) {
return;
}
params.height = totalHeight;
view.setLayoutParams(params);
view.requestLayout();
}
// Tab Page listener when page/tab changes
@Override
public void onPageScrolled(int position, float positionOffset,

@ -56,7 +56,6 @@ import com.todoroo.andlib.sql.Join;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.actfm.CommentsActivity;
import com.todoroo.astrid.actfm.TagViewFragment;
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
import com.todoroo.astrid.activity.SortSelectionActivity.OnSortSelectedListener;
@ -1099,24 +1098,6 @@ public class TaskListFragment extends SherlockListFragment implements OnSortSele
protected void onTaskCompleted() {
}
/**
* Comments button in action bar was clicked
*/
protected void handleCommentsButtonClicked() {
Activity activity = getActivity();
if (activity != null) {
Intent intent = new Intent(activity, CommentsActivity.class);
long id = 0;
TagData td = getActiveTagData();
if (td != null) {
id = td.getId();
}
intent.putExtra(TagViewFragment.EXTRA_TAG_DATA, id);
startActivity(intent);
AndroidUtilities.callOverridePendingTransition(activity, R.anim.slide_left_in, R.anim.slide_left_out);
}
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {

@ -36,7 +36,6 @@ import android.view.ViewGroup.LayoutParams;
import android.view.ViewGroup.MarginLayoutParams;
import android.view.animation.Animation;
import android.view.animation.ScaleAnimation;
import android.widget.CheckBox;
import android.widget.CursorAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
@ -1082,18 +1081,6 @@ public class TaskAdapter extends CursorAdapter {
}
}
/**
* Call me when the parent presses trackpad
*/
public void onTrackpadPressed(View container) {
if (container == null) {
return;
}
final CheckBox completeBox = (CheckBox) container.findViewById(R.id.completeBox);
completeBox.performClick();
}
/**
* Helper method to adjust a tasks' appearance if the task is completed or
* uncompleted.

@ -7,7 +7,6 @@ package com.todoroo.astrid.dao;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.sql.Criterion;
import com.todoroo.astrid.actfm.sync.messages.NameMaps;
import com.todoroo.astrid.data.TagData;
@ -31,26 +30,5 @@ public class TagDataDao extends RemoteModelDao<TagData> {
protected boolean shouldRecordOutstandingEntry(String columnName, Object value) {
return NameMaps.shouldRecordOutstandingColumnForTable(NameMaps.TABLE_ID_TAGS, columnName);
}
// --- SQL clause generators
/**
* Generates SQL clauses
*/
public static class TagDataCriteria {
/**
* @returns tasks by id
*/
public static Criterion byId(long id) {
return TagData.ID.eq(id);
}
public static Criterion isTeam() {
return TagData.IS_TEAM.eq(1);
}
}
}

@ -254,26 +254,5 @@ public class TagMetadataDao extends DatabaseDao<TagMetadata> {
metadata.close();
}
}
public boolean memberOfTagData(String email, String tagId, String memberId) {
Criterion criterion;
if (!RemoteModel.isUuidEmpty(memberId) && !TextUtils.isEmpty(email)) {
criterion = Criterion.or(TagMemberMetadata.USER_UUID.eq(email), TagMemberMetadata.USER_UUID.eq(memberId));
} else if (!RemoteModel.isUuidEmpty(memberId)) {
criterion = TagMemberMetadata.USER_UUID.eq(memberId);
} else if (!TextUtils.isEmpty(email)) {
criterion = TagMemberMetadata.USER_UUID.eq(email);
} else {
return false;
}
TodorooCursor<TagMetadata> count = query(Query.select(TagMetadata.ID).where(
Criterion.and(TagMetadataCriteria.withKey(TagMemberMetadata.KEY), TagMetadata.TAG_UUID.eq(tagId), criterion)));
try {
return count.getCount() > 0;
} finally {
//
}
}
}

@ -104,20 +104,6 @@ public class TaskDao extends RemoteModelDao<Task> {
Task.DELETION_DATE.eq(0));
}
/**
* @return tasks that are due within the next 24 hours
*/
public static Criterion dueToday() {
return Criterion.and(TaskCriteria.activeAndVisible(), Task.DUE_DATE.gt(0), Task.DUE_DATE.lt(Functions.fromNow(DateUtilities.ONE_DAY)));
}
/**
* @return tasks that are due within the next 72 hours
*/
public static Criterion dueSoon() {
return Criterion.and(TaskCriteria.activeAndVisible(), Task.DUE_DATE.gt(0), Task.DUE_DATE.lt(Functions.fromNow(3 * DateUtilities.ONE_DAY)));
}
/**
* @return tasks that are not hidden at current time
*/

@ -20,31 +20,10 @@ public abstract class MarketStrategy {
abstract public String strategyId();
/**
* @return if this market has power pack
*/
public boolean includesPowerPack() {
return true;
}
/**
* @return if this market has locale plugin
*/
public boolean includesLocalePlugin() {
return true;
}
public int[] excludedSettings() {
return null;
}
/**
* @return true if ideas tab should be shown
*/
public boolean allowIdeasTab() {
return true;
}
/**
* Return true if the preference to use the phone layout should be
* turned on by default (only true for Nook)
@ -91,11 +70,6 @@ public abstract class MarketStrategy {
packageName));
}
@Override
public boolean includesLocalePlugin() {
return false;
}
/**
* @return true if the device is a kindle fire and needs special treatment
*/
@ -130,16 +104,6 @@ public abstract class MarketStrategy {
packageName));
}
@Override
public boolean includesLocalePlugin() {
return false;
}
@Override
public boolean allowIdeasTab() {
return false;
}
@Override
public int[] excludedSettings() {
return new int[]{

@ -48,15 +48,6 @@ public class SyncV2Service {
return Collections.unmodifiableList(actives);
}
public boolean hasActiveProvider() {
for (SyncV2Provider provider : providers) {
if (provider.isActive()) {
return true;
}
}
return false;
}
/**
* Initiate synchronization of active tasks
*

@ -19,7 +19,6 @@ import com.todoroo.andlib.sql.Join;
import com.todoroo.andlib.sql.Order;
import com.todoroo.andlib.sql.Query;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.astrid.actfm.sync.ActFmSyncService;
import com.todoroo.astrid.adapter.UpdateAdapter;
import com.todoroo.astrid.api.PermaSql;
import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria;
@ -28,17 +27,11 @@ import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.dao.UserActivityDao;
import com.todoroo.astrid.data.History;
import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.RemoteModel;
import com.todoroo.astrid.data.SyncFlags;
import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.User;
import com.todoroo.astrid.data.UserActivity;
import com.todoroo.astrid.tags.TagService;
import com.todoroo.astrid.tags.TaskToTagMetadata;
import org.json.JSONException;
import org.json.JSONObject;
/**
* Service layer for {@link TagData}-centered activities.
*
@ -198,51 +191,4 @@ public class TagDataService {
return userActivityDao.query(resultQuery);
}
public void saveFeaturedList(JSONObject featObject) throws JSONException {
TodorooCursor<TagData> cursor = query(Query.select(TagData.PROPERTIES).where(
Criterion.and(Functions.bitwiseAnd(TagData.FLAGS, TagData.FLAG_FEATURED).gt(0), TagData.UUID.eq(featObject.get("id")))));
try {
cursor.moveToNext();
TagData tagData = new TagData();
if (!cursor.isAfterLast()) {
tagData.readFromCursor(cursor);
if (!tagData.getValue(TagData.NAME).equals(featObject.getString("name"))) {
TagService.getInstance().rename(tagData.getUuid(), featObject.getString("name"), true);
}
cursor.moveToNext();
}
ActFmSyncService.JsonHelper.featuredListFromJson(featObject, tagData);
tagData.putTransitory(SyncFlags.ACTFM_SUPPRESS_OUTSTANDING_ENTRIES, true);
save(tagData);
} finally {
cursor.close();
}
}
/**
* Return update
*
* @param tagData
* @return
*/
public UserActivity getLatestUpdate(TagData tagData) {
if (RemoteModel.NO_UUID.equals(tagData.getValue(TagData.UUID))) {
return null;
}
TodorooCursor<UserActivity> updates = userActivityDao.query(queryForTagData(tagData, null, null, UserActivity.PROPERTIES, null).orderBy(Order.desc(UserActivity.CREATED_AT)).limit(1));
try {
if (updates.getCount() == 0) {
return null;
}
updates.moveToFirst();
return new UserActivity(updates);
} finally {
updates.close();
}
}
}

@ -113,24 +113,6 @@ public class TaskService {
return taskDao.fetch(id, properties);
}
/**
* @param uuid
* @param properties
* @return item, or null if it doesn't exist
*/
public Task fetchByUUID(String uuid, Property<?>... properties) {
TodorooCursor<Task> task = query(Query.select(properties).where(Task.UUID.eq(uuid)));
try {
if (task.getCount() > 0) {
task.moveToFirst();
return new Task(task);
}
return null;
} finally {
task.close();
}
}
/**
* Mark the given task as completed and save it.
*

@ -279,9 +279,4 @@ public class ThemeService {
public static int getTaskEditThemeColor() {
return getDarkVsLight(R.color.task_edit_selected, R.color.blue_theme_color, true);
}
public static void forceTheme(int theme) {
currentTheme = theme;
}
}

@ -44,11 +44,6 @@ public class AstridDialog extends Dialog {
return this;
}
public AstridDialog setButtonColor(int color, int buttonIndex) {
buttons[buttonIndex].setBackgroundColor(color);
return this;
}
public AstridDialog setButtonListener(View.OnClickListener listener, int buttonIndex) {
buttons[buttonIndex].setOnClickListener(listener);
return this;

@ -1,68 +0,0 @@
/**
* Copyright (c) 2012 Todoroo Inc
*
* See the file "LICENSE" for the full license governing this code.
*/
package com.todoroo.astrid.ui;
import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.widget.Button;
import com.timsu.astrid.R;
import com.todoroo.astrid.ui.CalendarView.OnSelectedDateListener;
import java.util.Date;
public class CalendarDialog extends Dialog implements OnClickListener, OnSelectedDateListener {
private final Button cancelButton;
private Date calendarDate;
public CalendarDialog(Context context, Date calendarDate) {
super(context);
this.calendarDate = calendarDate;
/** 'Window.FEATURE_NO_TITLE' - Used to hide the title */
requestWindowFeature(Window.FEATURE_NO_TITLE);
/** Design the dialog in main.xml file */
setContentView(R.layout.calendar);
LayoutParams params = getWindow().getAttributes();
params.height = LayoutParams.FILL_PARENT;
params.width = LayoutParams.FILL_PARENT;
getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);
cancelButton = (Button) findViewById(R.id.CancelButton);
CalendarView calendarView = (CalendarView) findViewById(R.id.CalendarView);
calendarView.setCalendarDate(calendarDate);
calendarView.setOnSelectedDateListener(this);
cancelButton.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if (v == cancelButton) {
cancel();
}
}
@Override
public void onSelectedDate(Date date) {
calendarDate = date;
dismiss();
}
public Date getCalendarDate() {
return calendarDate;
}
public void setCalendarDate(Date calendarDate) {
this.calendarDate = calendarDate;
}
}

@ -93,10 +93,6 @@ public class ContactsAutoComplete extends AutoCompleteTextView {
// --- getters and setters
public boolean isAllowMultiple() {
return allowMultiple;
}
public String getSeperator() {
return seperator;
}
@ -107,13 +103,4 @@ public class ContactsAutoComplete extends AutoCompleteTextView {
adapter.setCompleteSharedTags(value);
}
}
public void setAllowMultiple(boolean allowMultiple) {
this.allowMultiple = allowMultiple;
}
public void setSeperator(final String seperator) {
this.seperator = seperator;
}
}

@ -90,10 +90,6 @@ public class DateAndTimeDialog extends Dialog {
});
}
public long getSelectedDate() {
return dateAndTimePicker.constructDueDate();
}
public void setSelectedDateAndTime(long date) {
dateAndTimePicker.initializeWithDate(date);
}

@ -271,10 +271,6 @@ public class DateAndTimePicker extends LinearLayout {
return timePicker.hasTime();
}
public void setOnDateChangedListener(OnDateChangedListener listener) {
this.listener = listener;
}
public boolean isAfterNow() {
long dueDate = constructDueDate();
return dueDate > DateUtilities.now();

@ -1,195 +0,0 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.todoroo.astrid.ui;
import android.app.AlertDialog;
import android.app.TimePickerDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.text.format.DateFormat;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.TimePicker;
import android.widget.TimePicker.OnTimeChangedListener;
import com.timsu.astrid.R;
import java.util.Calendar;
/**
* A dialog that prompts the user for the time of day using a {@link TimePicker}.
* This is similar to the Android {@link TimePickerDialog} class
* except allows users to specify "no specific time".
*/
public class DeadlineTimePickerDialog extends AlertDialog implements OnClickListener,
OnTimeChangedListener {
/**
* The callback interface used to indicate the user is done filling in
* the time (they clicked on the 'Set' button).
*/
public interface OnDeadlineTimeSetListener {
/**
* @param view The view associated with this listener.
* @param hasTime whether time is set
* @param hourOfDay The hour that was set.
* @param minute The minute that was set.
*/
void onTimeSet(TimePicker view, boolean hasTime, int hourOfDay, int minute);
}
private static final String HOUR = "hour";
private static final String MINUTE = "minute";
private static final String IS_24_HOUR = "is24hour";
private final TimePicker mTimePicker;
private final CheckBox mHasTime;
private final OnDeadlineTimeSetListener mCallback;
private final Calendar mCalendar;
private final java.text.DateFormat mDateFormat;
int mInitialHourOfDay;
int mInitialMinute;
boolean mIs24HourView;
/**
* @param context Parent.
* @param callBack How parent is notified.
* @param hourOfDay The initial hour.
* @param minute The initial minute.
* @param is24HourView Whether this is a 24 hour view, or AM/PM.
*/
public DeadlineTimePickerDialog(Context context,
OnDeadlineTimeSetListener callBack,
int hourOfDay, int minute, boolean is24HourView, boolean hasTime) {
this(context, android.R.style.Theme_Dialog,
callBack, hourOfDay, minute, is24HourView, hasTime);
}
/**
* @param context Parent.
* @param theme the theme to apply to this dialog
* @param callBack How parent is notified.
* @param hourOfDay The initial hour.
* @param minute The initial minute.
* @param is24HourView Whether this is a 24 hour view, or AM/PM.
*/
public DeadlineTimePickerDialog(Context context,
int theme,
OnDeadlineTimeSetListener callBack,
int hourOfDay, int minute, boolean is24HourView, boolean hasTime) {
super(context, theme);
mCallback = callBack;
mInitialHourOfDay = hourOfDay;
mInitialMinute = minute;
mIs24HourView = is24HourView;
mDateFormat = DateFormat.getTimeFormat(context);
mCalendar = Calendar.getInstance();
setButton(context.getText(android.R.string.ok), this);
setButton2(context.getText(android.R.string.cancel), (OnClickListener) null);
setIcon(R.drawable.ic_dialog_time);
LayoutInflater inflater =
(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.time_picker_dialog, null);
setView(view);
mTimePicker = (TimePicker) view.findViewById(R.id.timePicker);
mHasTime = (CheckBox) view.findViewById(R.id.hasTime);
OnCheckedChangeListener listener = new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
mTimePicker.setEnabled(isChecked);
if (isChecked) {
updateTitle();
} else {
setTitle(R.string.TEA_urgency_none);
}
}
};
mHasTime.setOnCheckedChangeListener(listener);
mHasTime.setChecked(hasTime);
listener.onCheckedChanged(null, hasTime);
// initialize state
mTimePicker.setCurrentHour(mInitialHourOfDay);
mTimePicker.setCurrentMinute(mInitialMinute);
mTimePicker.setIs24HourView(mIs24HourView);
mTimePicker.setOnTimeChangedListener(this);
updateTitle();
}
@Override
public void onClick(DialogInterface dialog, int which) {
if (mCallback != null) {
mTimePicker.clearFocus();
mCallback.onTimeSet(mTimePicker,
mHasTime.isChecked(),
mTimePicker.getCurrentHour(),
mTimePicker.getCurrentMinute());
}
}
@Override
public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
updateTitle();
}
public void updateTime(int hourOfDay, int minutOfHour) {
mTimePicker.setCurrentHour(hourOfDay);
mTimePicker.setCurrentMinute(minutOfHour);
}
private void updateTitle() {
int hour = mTimePicker.getCurrentHour();
int minute = mTimePicker.getCurrentMinute();
mCalendar.set(Calendar.HOUR_OF_DAY, hour);
mCalendar.set(Calendar.MINUTE, minute);
setTitle(mDateFormat.format(mCalendar.getTime()));
}
@Override
public Bundle onSaveInstanceState() {
Bundle state = super.onSaveInstanceState();
state.putInt(HOUR, mTimePicker.getCurrentHour());
state.putInt(MINUTE, mTimePicker.getCurrentMinute());
state.putBoolean(IS_24_HOUR, mTimePicker.is24HourView());
return state;
}
@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
int hour = savedInstanceState.getInt(HOUR);
int minute = savedInstanceState.getInt(MINUTE);
mTimePicker.setCurrentHour(hour);
mTimePicker.setCurrentMinute(minute);
mTimePicker.setIs24HourView(savedInstanceState.getBoolean(IS_24_HOUR));
mTimePicker.setOnTimeChangedListener(this);
updateTitle();
}
}

@ -48,10 +48,6 @@ public class MainMenuPopover extends FragmentPopover implements InterceptTouchLi
private boolean suppressNextKeyEvent = false;
private final boolean isTablet;
public void setMenuListener(MainMenuListener listener) {
this.mListener = listener;
}
public MainMenuPopover(Context context, int layout, boolean isTablet, MainMenuListener listener) {
super(context, layout);
@ -130,15 +126,6 @@ public class MainMenuPopover extends FragmentPopover implements InterceptTouchLi
addFixedItems();
}
public void setFixedItemVisibility(int index, int visibility, boolean top) {
LinearLayout container = top ? topFixed : bottomFixed;
if (index < 0 || index >= container.getChildCount()) {
return;
}
container.getChildAt(index).setVisibility(visibility);
}
@Override
protected int getArrowLeftMargin(View arrow) {
return mRect.centerX() - arrow.getMeasuredWidth() / 2 - (int) (12 * metrics.density);
@ -158,10 +145,6 @@ public class MainMenuPopover extends FragmentPopover implements InterceptTouchLi
addMenuItem(title, image, id, customIntent, content);
}
public void addSeparator() {
inflater.inflate(R.layout.fla_separator, content);
}
public void clear() {
content.removeAllViews();
}

@ -1,52 +0,0 @@
/**
* Copyright (c) 2012 Todoroo Inc
*
* See the file "LICENSE" for the full license governing this code.
*/
package com.todoroo.astrid.ui;
import android.content.Context;
import android.view.View;
import android.widget.ListAdapter;
import android.widget.ListView;
public class NestedListView extends ListView {
private static final int MAXIMUM_LIST_ITEMS_VIEWABLE = 2;
public NestedListView(Context context) {
super(context);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int newHeight = 0;
final int heightMode = MeasureSpec.getMode(heightMeasureSpec);
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
if (heightMode != MeasureSpec.EXACTLY) {
ListAdapter listAdapter = getAdapter();
if (listAdapter != null && !listAdapter.isEmpty()) {
int listPosition = 0;
for (listPosition = 0; listPosition < listAdapter.getCount()
&& listPosition < MAXIMUM_LIST_ITEMS_VIEWABLE; listPosition++) {
View listItem = listAdapter.getView(listPosition, null,
this);
listItem.measure(widthMeasureSpec, heightMeasureSpec);
newHeight += listItem.getMeasuredHeight();
}
newHeight += getDividerHeight() * listPosition;
}
if (heightMode == MeasureSpec.AT_MOST && newHeight > heightSize) {
if (newHeight > heightSize) {
newHeight = heightSize;
}
}
} else {
newHeight = getMeasuredHeight();
}
setMeasuredDimension(getMeasuredWidth(), newHeight);
}
}

@ -211,14 +211,6 @@ public class NumberPicker extends LinearLayout implements OnClickListener,
updateView();
}
/**
* The speed (in milliseconds) at which the numbers will scroll when the the
* +/- buttons are longpressed. Default is 300ms.
*/
public void setSpeed(long speed) {
mSpeed = speed;
}
@Override
public void onClick(View v) {

@ -7,7 +7,6 @@ package com.todoroo.astrid.ui;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
@ -21,20 +20,4 @@ public class TaskEditMoreControls extends LinearLayout {
super(context, attrs);
}
public void setViewHeightBasedOnChildren(LayoutParams params) {
int totalHeight = 0;
int desiredWidth = MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.AT_MOST);
for (int i = 0; i < getChildCount(); i++) {
View listItem = getChildAt(i);
listItem.measure(desiredWidth, MeasureSpec.UNSPECIFIED);
totalHeight += listItem.getMeasuredHeight();
}
params.height = totalHeight;
setLayoutParams(params);
requestLayout();
}
}

@ -1,40 +0,0 @@
/**
* Copyright (c) 2012 Todoroo Inc
*
* See the file "LICENSE" for the full license governing this code.
*/
package com.todoroo.astrid.ui;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.TextView;
public class TextViewWithMeasureListener extends TextView {
public interface OnTextMeasureListener {
public void onTextSizeChanged();
}
private OnTextMeasureListener listener;
public TextViewWithMeasureListener(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if (listener != null) {
listener.onTextSizeChanged();
}
}
public OnTextMeasureListener getOnTextSizeChangedListener() {
return listener;
}
public void setOnTextSizeChangedListener(OnTextMeasureListener listener) {
this.listener = listener;
}
}

@ -32,10 +32,6 @@ public class TouchInterceptingFrameLayout extends FrameLayout {
return super.dispatchKeyEvent(event);
}
public InterceptTouchListener getInterceptTouchListener() {
return mListener;
}
public void setInterceptTouchListener(InterceptTouchListener mListener) {
this.mListener = mListener;
}

@ -58,17 +58,6 @@ public class AstridPreferences {
}
public static void resetToDefaults() {
AstridPreferenceSpec spec;
if (Constants.ASTRID_LITE) {
spec = new AstridLitePreferenceSpec();
} else {
spec = new AstridDefaultPreferenceSpec();
}
spec.resetDefaults();
}
private static void setShowFriendsView() {
// Show friends view if necessary
boolean showFriends = false;

@ -1,117 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.todoroo.astrid.utility;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
/**
* <p>Escapes and unescapes <code>String</code>s for
* Java, Java Script, HTML, XML, and SQL.</p>
*
* @author Apache Jakarta Turbine
* @author Purple Technology
* @author <a href="mailto:alex@purpletech.com">Alexander Day Chaffee</a>
* @author Antony Riley
* @author Helge Tesgaard
* @author <a href="sean@boohai.com">Sean Brown</a>
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
* @author Phil Steitz
* @author Pete Gieser
* @version $Id: StringEscapeUtils.java 2696 2007-06-20 13:24:53Z damencho $
* @since 2.0
*/
public class StringEscapeUtils {
/**
* <p><code>StringEscapeUtils</code> instances should NOT be constructed in
* standard programming.</p>
* <p/>
* <p>Instead, the class should be used as:
* <pre>StringEscapeUtils.escapeJava("foo");</pre></p>
* <p/>
* <p>This constructor is public to permit tools that require a JavaBean
* instance to operate.</p>
*/
public StringEscapeUtils() {
}
//-----------------------------------------------------------------------
/**
* <p>Unescapes a string containing entity escapes to a string
* containing the actual Unicode characters corresponding to the
* escapes. Supports HTML 4.0 entities.</p>
* <p/>
* <p>For example, the string "&amp;lt;Fran&amp;ccedil;ais&amp;gt;"
* will become "&lt;Fran&ccedil;ais&gt;"</p>
* <p/>
* <p>If an entity is unrecognized, it is left alone, and inserted
* verbatim into the result string. e.g. "&amp;gt;&amp;zzzz;x" will
* become "&gt;&amp;zzzz;x".</p>
*
* @param str the <code>String</code> to unescape, may be null
* @return a new unescaped <code>String</code>, <code>null</code> if null string input
* @see #escapeHtml(Writer, String)
*/
public static String unescapeHtml(String str) {
if (str == null) {
return null;
}
try {
StringWriter writer = new StringWriter((int) (str.length() * 1.5));
unescapeHtml(writer, str);
return writer.toString();
} catch (IOException e) {
//assert false;
//should be impossible
e.printStackTrace();
return null;
}
}
/**
* <p>Unescapes a string containing entity escapes to a string
* containing the actual Unicode characters corresponding to the
* escapes. Supports HTML 4.0 entities.</p>
* <p/>
* <p>For example, the string "&amp;lt;Fran&amp;ccedil;ais&amp;gt;"
* will become "&lt;Fran&ccedil;ais&gt;"</p>
* <p/>
* <p>If an entity is unrecognized, it is left alone, and inserted
* verbatim into the result string. e.g. "&amp;gt;&amp;zzzz;x" will
* become "&gt;&amp;zzzz;x".</p>
*
* @param writer the writer receiving the unescaped string, not null
* @param string the <code>String</code> to unescape, may be null
* @throws IllegalArgumentException if the writer is null
* @throws IOException if an IOException occurs
* @see #escapeHtml(String)
*/
public static void unescapeHtml(Writer writer, String string) throws IOException {
if (writer == null) {
throw new IllegalArgumentException("The Writer must not be null.");
}
if (string == null) {
return;
}
Entities.HTML40.unescape(writer, string);
}
}

@ -230,30 +230,6 @@ abstract public class SyncMetadataService<TYPE extends SyncContainer> {
getMetadataCriteria());
}
/**
* Reads a task and its metadata
*
* @param task
* @return
*/
public TYPE readTaskAndMetadata(TodorooCursor<Task> taskCursor) {
Task task = new Task(taskCursor);
ArrayList<Metadata> metadata = new ArrayList<Metadata>();
TodorooCursor<Metadata> metadataCursor = metadataDao.query(Query.select(Metadata.PROPERTIES).
where(Criterion.and(MetadataCriteria.byTask(task.getId()),
getMetadataCriteria())));
try {
for (metadataCursor.moveToFirst(); !metadataCursor.isAfterLast(); metadataCursor.moveToNext()) {
metadata.add(new Metadata(metadataCursor));
}
} finally {
metadataCursor.close();
}
return createContainerFromLocalTask(task, metadata);
}
/**
* Reads metadata out of a task
*

@ -67,13 +67,6 @@ public class VoiceInputAssistant {
this.languageModel = languageModel;
}
/**
* @return the languageModel
*/
public String getLanguageModel() {
return languageModel;
}
/**
* Sets whether voice input will append into field
*/
@ -238,35 +231,6 @@ public class VoiceInputAssistant {
return result;
}
/**
* Can also be called from Fragment.onActivityResult to simply get the string result
* of the speech to text, or null if it couldn't be processed. Convenient when you
* don't have a bunch of UI elements to hook into.
*
* @param activityRequestCode
* @param resultCode
* @param data
* @return
*/
public String getActivityResult(int activityRequestCode, int resultCode, Intent data) {
if (activityRequestCode == this.requestCode) {
if (resultCode == Activity.RESULT_OK) {
// Fill the quickAddBox-view with the string the recognizer thought it could have heard
ArrayList<String> match = data.getStringArrayListExtra(
RecognizerIntent.EXTRA_RESULTS);
// make sure we only do this if there is SomeThing (tm) returned
if (match != null && match.size() > 0 && match.get(0).length() > 0) {
String recognizedSpeech = match.get(0);
recognizedSpeech = recognizedSpeech.substring(0, 1).toUpperCase() +
recognizedSpeech.substring(1).toLowerCase();
return recognizedSpeech;
}
}
}
return null;
}
public void configureMicrophoneButton(final Fragment fragment, final int prompt) {
if (Preferences.getBoolean(R.string.p_voiceInputEnabled, true) && VoiceRecognizer.voiceInputAvailable(ContextManager.getContext())) {
voiceButton.setVisibility(View.VISIBLE);

Loading…
Cancel
Save