Remove exception service, add slf4j-android

pull/143/head
Alex Baker 11 years ago
parent 29cf45fc8f
commit 0abf63e8a7

@ -34,5 +34,7 @@ android {
dependencies {
compile group: 'com.android.support', name: 'support-v4', version: '19.1.+'
compile group: 'org.slf4j', name: 'slf4j-android', version: '1.7.7', transitive: false
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.7'
compile group: 'joda-time', name: 'joda-time', version: '2.3', transitive: false
}

@ -14,12 +14,12 @@ import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import com.todoroo.andlib.data.Property.PropertyVisitor;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.service.ExceptionService;
import com.todoroo.andlib.utility.AndroidUtilities;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
/**
@ -39,6 +39,8 @@ import java.util.ArrayList;
*/
abstract public class AbstractDatabase {
Logger log = LoggerFactory.getLogger(AbstractDatabase.class);
// --- abstract methods
/**
@ -105,15 +107,6 @@ abstract public class AbstractDatabase {
}
}
// --- internal implementation
@Autowired
private ExceptionService exceptionService;
public AbstractDatabase() {
DependencyInjectionService.getInstance().inject(this);
}
/**
* Return the name of the table containing these models
*/
@ -159,8 +152,7 @@ abstract public class AbstractDatabase {
// provide read-only database
openForReading();
} catch (Exception readException) {
exceptionService.reportError("database-open-" + getName(), original);
log.error("database-open-{}", getName(), original);
// throw original write exception
throw original;
}
@ -312,8 +304,7 @@ abstract public class AbstractDatabase {
"from " + oldVersion + " to " + newVersion);
}
} catch (Exception e) {
exceptionService.reportError(String.format("database-upgrade-%s-%d-%d",
getName(), oldVersion, newVersion), e);
log.error("database-upgrade-{}-{}-{}", getName(), oldVersion, newVersion, e);
}
}
}

@ -5,8 +5,6 @@
*/
package com.todoroo.andlib.service;
import com.todoroo.andlib.service.ExceptionService.ErrorReporter;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.util.HashMap;
@ -24,7 +22,6 @@ abstract public class AbstractDependencyInjector {
/**
* Initialize list of injection variables. Special care must used when
* instantiating classes that themselves depend on dependency injection
* (i.e. {@link ErrorReporter}.
*/
protected void addInjectables() {
// your injectables here

@ -5,9 +5,6 @@
*/
package com.todoroo.andlib.service;
import com.todoroo.andlib.service.ExceptionService.AndroidLogReporter;
import com.todoroo.andlib.service.ExceptionService.ErrorReporter;
import java.lang.reflect.Field;
import java.util.LinkedList;
@ -124,10 +121,6 @@ public class DependencyInjectionService {
@Override
protected void addInjectables() {
injectables.put("debug", false);
injectables.put("exceptionService", ExceptionService.class);
injectables.put("errorReporters", new ErrorReporter[] {
new AndroidLogReporter(),
});
}
}

@ -1,142 +0,0 @@
/**
* Copyright (c) 2012 Todoroo Inc
*
* See the file "LICENSE" for the full license governing this code.
*/
package com.todoroo.andlib.service;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.util.Log;
import org.tasks.api.R;
/**
* Exception handling utility class - reports and logs errors
*
* @author Tim Su <tim@todoroo.com>
*
*/
public class ExceptionService {
@Autowired
public ErrorReporter[] errorReporters;
public ExceptionService() {
DependencyInjectionService.getInstance().inject(this);
if(errorReporters == null) {
errorReporters = new ErrorReporter[] {
new AndroidLogReporter()
};
}
}
/**
* Report the error via registered error handlers
*
* @param name Internal error name. Not displayed to user
* @param error Exception encountered. Message will be displayed to user
*/
public void reportError(String name, Throwable error) {
if(errorReporters == null) {
return;
}
for(ErrorReporter reporter : errorReporters) {
try {
reporter.handleError(name, error);
} catch (Exception e) {
Log.e("astrid-exception-service", "Exception handling error", e); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}
/**
* Display error dialog if context is activity and report error
*
* @param context Application Context
* @param name Internal error name. Not displayed to user
* @param error Exception encountered. Message will be displayed to user
*/
public void displayAndReportError(final Context context, String name, Throwable error) {
if(context instanceof Activity) {
final String messageToDisplay;
// pretty up the message when displaying to user
if(error == null) {
messageToDisplay = context.getString(R.string.DLG_error_generic);
} else {
messageToDisplay = context.getString(R.string.DLG_error, error);
}
((Activity)context).runOnUiThread(new Runnable() {
@Override
public void run() {
try {
new AlertDialog.Builder(context)
.setTitle(R.string.DLG_error_title)
.setMessage(messageToDisplay)
.setIcon(android.R.drawable.ic_dialog_alert)
.setPositiveButton(android.R.string.ok, null)
.show();
} catch (Exception e) {
// suppress errors during dialog creation
}
}
});
}
reportError(name, error);
}
/**
* Error reporter interface
*
* @author Tim Su <tim@todoroo.com>
*
*/
public interface ErrorReporter {
public void handleError(String name, Throwable error);
}
/**
* AndroidLogReporter reports errors to LogCat
*
* @author Tim Su <tim@todoroo.com>
*
*/
public static class AndroidLogReporter implements ErrorReporter {
/**
* Report the error to the logs
*/
@Override
public void handleError(String name, Throwable error) {
String tag = null;
if(ContextManager.getContext() != null) {
PackageManager pm = ContextManager.getContext().getPackageManager();
try {
String appName = pm.getApplicationInfo(ContextManager.getContext().
getPackageName(), 0).loadLabel(pm).toString();
tag = appName + "-" + name; //$NON-NLS-1$
} catch (NameNotFoundException e) {
// give up
}
}
if(tag == null) {
tag = "unknown-" + name; //$NON-NLS-1$
}
if(error == null) {
Log.e(tag, "Exception: " + name); //$NON-NLS-1$
} else {
Log.e(tag, error.toString(), error);
}
}
}
}

@ -23,7 +23,8 @@ import android.view.View.OnTouchListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.TextView;
import com.todoroo.andlib.service.ExceptionService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileInputStream;
@ -44,6 +45,8 @@ import java.util.Map.Entry;
*/
public class AndroidUtilities {
private static final Logger log = LoggerFactory.getLogger(AndroidUtilities.class);
public static final String SEPARATOR_ESCAPE = "!PIPE!"; //$NON-NLS-1$
public static final String SERIALIZATION_SEPARATOR = "|"; //$NON-NLS-1$
@ -97,9 +100,7 @@ public class AndroidUtilities {
context.startActivity(intent);
}
} catch (Exception e) {
getExceptionService().displayAndReportError(context,
"start-external-intent-" + intent.toString(), //$NON-NLS-1$
e);
log.error("start-external-intent-{}", intent.toString(), e);
}
}
@ -470,21 +471,6 @@ public class AndroidUtilities {
return newList;
}
// --- internal
private static ExceptionService exceptionService = null;
private static ExceptionService getExceptionService() {
if(exceptionService == null) {
synchronized (AndroidUtilities.class) {
if (exceptionService == null) {
exceptionService = new ExceptionService();
}
}
}
return exceptionService;
}
/**
* Capitalize the first character
*/

@ -13,14 +13,14 @@ import android.content.Intent;
import android.os.IBinder;
import android.util.Log;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.service.ExceptionService;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.api.AstridApiConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.atomic.AtomicBoolean;
/**
@ -36,24 +36,15 @@ import java.util.concurrent.atomic.AtomicBoolean;
*/
abstract public class SyncV2BackgroundService extends Service {
private static final Logger log = LoggerFactory.getLogger(SyncV2BackgroundService.class);
/** Minimum time before an auto-sync */
private static final long AUTO_SYNC_MIN_OFFSET = 5*60*1000L;
@Autowired private ExceptionService exceptionService;
// --- abstract methods
abstract protected SyncV2Provider getSyncProvider();
abstract protected SyncProviderUtilities getSyncUtilities();
// --- implementation
@SuppressWarnings("unused")
public SyncV2BackgroundService() {
DependencyInjectionService.getInstance().inject(this);
}
private final AtomicBoolean started = new AtomicBoolean(false);
/** Receive the alarm - start the synchronize service! */
@ -64,7 +55,7 @@ abstract public class SyncV2BackgroundService extends Service {
startSynchronization(this);
}
} catch (Exception e) {
exceptionService.reportError(getSyncUtilities().getIdentifier() + "-bg-sync", e); //$NON-NLS-1$
log.error("{}-bg-sync", getSyncUtilities().getIdentifier(), e);
}
}

@ -5,45 +5,22 @@
*/
package com.todoroo.astrid.sync;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.service.ExceptionService;
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
abstract public class SyncV2Provider {
private static final Logger log = LoggerFactory.getLogger(SyncV2Provider.class);
public class SyncExceptionHandler {
public void handleException(String tag, Exception e, String type) {
getUtilities().setLastError(e.toString(), type);
// occurs when application was closed
if(e instanceof IllegalStateException) {
exceptionService.reportError(tag + "-caught", e); //$NON-NLS-1$
}
// occurs when network error
else if(e instanceof IOException) {
exceptionService.reportError(tag + "-io", e); //$NON-NLS-1$
}
// unhandled error
else {
exceptionService.reportError(tag + "-unhandled", e); //$NON-NLS-1$
}
log.error("{}: {}", tag, e.getMessage(), e);
}
}
@Autowired
protected ExceptionService exceptionService;
protected final SyncExceptionHandler handler;
public SyncV2Provider() {
DependencyInjectionService.getInstance().inject(this);
handler = new SyncExceptionHandler();
}
protected final SyncExceptionHandler handler = new SyncExceptionHandler();
/**
* @return sync provider name (displayed in sync menu)

@ -44,7 +44,6 @@ import android.widget.Toast;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.service.ExceptionService;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.andlib.utility.DialogUtilities;
@ -83,6 +82,8 @@ import com.todoroo.astrid.utility.Flags;
import com.todoroo.astrid.voice.VoiceInputAssistant;
import com.todoroo.astrid.voice.VoiceRecognizer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tasks.R;
import java.io.File;
@ -106,6 +107,8 @@ import static android.support.v4.view.MenuItemCompat.setShowAsAction;
public final class TaskEditFragment extends Fragment implements
ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
private static final Logger log = LoggerFactory.getLogger(TaskEditFragment.class);
public static final String TAG_TASKEDIT_FRAGMENT = "taskedit_fragment"; //$NON-NLS-1$
// --- bundle tokens
@ -164,9 +167,6 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
public static final int TAB_VIEW_UPDATES = 0;
@Autowired
private ExceptionService exceptionService;
@Autowired
private TaskService taskService;
@ -612,8 +612,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
setIsNewTask(model.getTitle().length() == 0);
if (model == null) {
exceptionService.reportError("task-edit-no-task",
new NullPointerException("model"));
log.error("task-edit-no-task", new NullPointerException("model"));
getActivity().onBackPressed();
return;
}

@ -48,7 +48,6 @@ import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.service.ExceptionService;
import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Field;
import com.todoroo.andlib.sql.Join;
@ -90,6 +89,8 @@ import com.todoroo.astrid.utility.AstridPreferences;
import com.todoroo.astrid.utility.Flags;
import com.todoroo.astrid.widget.TasksWidget;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tasks.R;
import java.util.List;
@ -106,6 +107,8 @@ import java.util.concurrent.atomic.AtomicReference;
*/
public class TaskListFragment extends ListFragment implements OnSortSelectedListener {
private static final Logger log = LoggerFactory.getLogger(TaskListFragment.class);
public static final String TAG_TASKLIST_FRAGMENT = "tasklist_fragment"; //$NON-NLS-1$
// --- activities
@ -139,9 +142,6 @@ public class TaskListFragment extends ListFragment implements OnSortSelectedList
// --- instance variables
@Autowired
protected ExceptionService exceptionService;
@Autowired
protected TaskService taskService;
@ -693,9 +693,7 @@ public class TaskListFragment extends ListFragment implements OnSortSelectedList
taskAdapter.addDetails(taskId, detail);
}
} catch (Exception e) {
exceptionService.reportError("receive-detail-" + //$NON-NLS-1$
intent.getStringExtra(AstridApiConstants.EXTRAS_ADDON),
e);
log.error("receive-detail-{}", intent.getStringExtra(AstridApiConstants.EXTRAS_ADDON), e);
}
}
}

@ -24,15 +24,14 @@ import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.service.ExceptionService;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.gcal.Calendars.CalendarResult;
import com.todoroo.astrid.service.ThemeService;
import com.todoroo.astrid.ui.PopupControlSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tasks.R;
import java.util.ArrayList;
@ -46,10 +45,9 @@ import java.util.Collections;
*/
public class GCalControlSet extends PopupControlSet {
// --- instance variables
private static final Logger log = LoggerFactory.getLogger(GCalControlSet.class);
@Autowired
private ExceptionService exceptionService;
// --- instance variables
private Uri calendarUri = null;
@ -61,7 +59,6 @@ public class GCalControlSet extends PopupControlSet {
public GCalControlSet(final Activity activity, int viewLayout, int displayViewLayout, int title) {
super(activity, viewLayout, displayViewLayout, title);
DependencyInjectionService.getInstance().inject(this);
this.title = title;
calendars = Calendars.getCalendars();
getView(); // Hack to force initialized
@ -121,8 +118,7 @@ public class GCalControlSet extends PopupControlSet {
hasEvent = true;
} catch (Exception e) {
exceptionService.reportError("unable-to-parse-calendar: " + //$NON-NLS-1$
model.getCalendarURI(), e);
log.error("unable-to-parse-calendar: {}", model.getCalendarURI(), e);
}
} else {
hasEvent = false;
@ -169,8 +165,7 @@ public class GCalControlSet extends PopupControlSet {
}
} catch (Exception e) {
exceptionService.displayAndReportError(activity,
activity.getString(R.string.gcal_TEA_error), e);
log.error(e.getMessage(), e);
}
} else if(calendarUri != null) {
try {
@ -191,8 +186,7 @@ public class GCalControlSet extends PopupControlSet {
ContentResolver cr = activity.getContentResolver();
cr.update(calendarUri, updateValues, null, null);
} catch (Exception e) {
exceptionService.reportError("unable-to-update-calendar: " + //$NON-NLS-1$
task.getCalendarURI(), e);
log.error("unable-to-update-calendar: {}", task.getCalendarURI(), e);
}
}
}

@ -14,12 +14,11 @@ import com.google.api.services.tasks.Tasks.TasksOperations.Move;
import com.google.api.services.tasks.model.Task;
import com.google.api.services.tasks.model.TaskList;
import com.google.api.services.tasks.model.TaskLists;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.service.ExceptionService;
import com.todoroo.astrid.gtasks.auth.GtasksTokenValidator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tasks.R;
import java.io.IOException;
@ -31,16 +30,16 @@ import java.io.IOException;
*
*/
public class GtasksInvoker {
private static final Logger log = LoggerFactory.getLogger(GtasksInvoker.class);
private Tasks service;
private GoogleAccessProtectedResource accessProtectedResource;
private String token;
@Autowired ExceptionService exceptionService;
public static final String AUTH_TOKEN_TYPE = "Manage your tasks"; //"oauth2:https://www.googleapis.com/auth/tasks";
public GtasksInvoker(String authToken) {
DependencyInjectionService.getInstance().inject(this);
authenticate(authToken);
}
@ -68,10 +67,7 @@ public class GtasksInvoker {
accessProtectedResource.setAccessToken(token);
}
} else if (statusCode == 503) { // 503 errors are generally either 1) quota limit reached or 2) problems on Google's end
System.err.println("Encountered 503 error");
final Context context = ContextManager.getContext();
String message = context.getString(R.string.gtasks_error_backend);
exceptionService.reportError(message, h);
log.error("503: {}", e.getMessage(), e);
} else if (statusCode == 400 || statusCode == 500) {
System.err.println("Encountered " + statusCode + " error");
System.err.println(h.getResponse().getStatusMessage());

@ -12,6 +12,7 @@ import com.todoroo.andlib.data.AbstractModel;
import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Join;
import com.todoroo.andlib.sql.Query;
@ -71,7 +72,7 @@ public class GtasksSyncV2Provider extends SyncV2Provider {
private static GtasksSyncV2Provider instance = null;
protected GtasksSyncV2Provider() {
// prevent multiple sync providers
DependencyInjectionService.getInstance().inject(this);
}
public synchronized static GtasksSyncV2Provider getInstance() {

@ -21,7 +21,6 @@ import android.widget.ArrayAdapter;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.service.ExceptionService;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.andlib.utility.Preferences;
@ -33,6 +32,8 @@ import com.todoroo.astrid.service.SyncV2Service;
import com.todoroo.astrid.sync.SyncResultCallback;
import com.todoroo.astrid.sync.SyncV2Provider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tasks.R;
import java.util.ArrayList;
@ -52,6 +53,8 @@ import java.util.List;
*/
public class SyncActionHelper {
private static final Logger log = LoggerFactory.getLogger(SyncActionHelper.class);
public static final String PREF_LAST_AUTO_SYNC = "taskListLastAutoSync"; //$NON-NLS-1$
private final LinkedHashSet<SyncAction> syncActions = new LinkedHashSet<>();
@ -65,7 +68,6 @@ public class SyncActionHelper {
protected SyncActionReceiver syncActionReceiver = new SyncActionReceiver();
@Autowired SyncV2Service syncService;
@Autowired ExceptionService exceptionService;
// --- boilerplate
@ -113,9 +115,7 @@ public class SyncActionHelper {
SyncAction syncAction = extras.getParcelable(AstridApiConstants.EXTRAS_RESPONSE);
syncActions.add(syncAction);
} catch (Exception e) {
exceptionService.reportError("receive-sync-action-" + //$NON-NLS-1$
intent.getStringExtra(AstridApiConstants.EXTRAS_ADDON),
e);
log.error("receive-sync-action-{}", intent.getStringExtra(AstridApiConstants.EXTRAS_ADDON), e);
}
}
}

@ -22,7 +22,6 @@ import com.todoroo.andlib.data.DatabaseDao;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.service.ExceptionService;
import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.dao.Database;
import com.todoroo.astrid.dao.MetadataDao;
@ -35,6 +34,9 @@ import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.UserActivity;
import com.todoroo.astrid.service.AstridDependencyInjector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.Set;
@ -68,6 +70,8 @@ import java.util.Set;
*/
public class Astrid3ContentProvider extends ContentProvider {
private static final Logger log = LoggerFactory.getLogger(Astrid3ContentProvider.class);
static {
AstridDependencyInjector.initialize();
}
@ -103,16 +107,13 @@ public class Astrid3ContentProvider extends ContentProvider {
@Autowired
private UserActivityDao userActivityDao;
@Autowired
private ExceptionService exceptionService;
@Override
public boolean onCreate() {
try {
database.openForWriting();
return database.getDatabase() != null;
} catch (Exception e) {
exceptionService.reportError("astrid-provider", e);
log.error(e.getMessage(), e);
return false;
}
}

@ -13,11 +13,13 @@ import android.net.Uri;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.service.ExceptionService;
import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.dao.Database;
import com.todoroo.astrid.service.AstridDependencyInjector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Non-public-API SQL content provider.
*
@ -30,6 +32,8 @@ import com.todoroo.astrid.service.AstridDependencyInjector;
*/
public class SqlContentProvider extends ContentProvider {
private static final Logger log = LoggerFactory.getLogger(SqlContentProvider.class);
// --- instance variables
private static UriMatcher uriMatcher;
@ -46,16 +50,13 @@ public class SqlContentProvider extends ContentProvider {
@Autowired
private Database database;
@Autowired
private ExceptionService exceptionService;
@Override
public boolean onCreate() {
try {
database.openForWriting();
return database.getDatabase() != null;
} catch (Exception e) {
exceptionService.reportError("astrid-provider", e);
log.error(e.getMessage(), e);
return false;
}
}

@ -23,7 +23,6 @@ import android.util.Log;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.service.ExceptionService;
import com.todoroo.andlib.service.NotificationManager;
import com.todoroo.andlib.service.NotificationManager.AndroidNotificationManager;
import com.todoroo.andlib.sql.QueryTemplate;
@ -43,6 +42,8 @@ import com.todoroo.astrid.utility.Flags;
import com.todoroo.astrid.voice.VoiceOutputService;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tasks.R;
import java.util.concurrent.ExecutorService;
@ -53,6 +54,8 @@ import static org.tasks.date.DateTimeUtils.currentTimeMillis;
public class Notifications extends BroadcastReceiver {
private static final Logger log = LoggerFactory.getLogger(Notifications.class);
// --- constants
/** task id extra */
@ -82,9 +85,6 @@ public class Notifications extends BroadcastReceiver {
@Autowired
private TaskDao taskDao;
@Autowired
private ExceptionService exceptionService;
public static NotificationManager notificationManager = null;
private static boolean forceNotificationManager = false;
@ -154,7 +154,7 @@ public class Notifications extends BroadcastReceiver {
}
} catch (Exception e) {
exceptionService.reportError("show-notif", e); //$NON-NLS-1$
log.error(e.getMessage(), e);
return false;
}

@ -25,9 +25,6 @@ import com.google.ical.values.Frequency;
import com.google.ical.values.RRule;
import com.google.ical.values.Weekday;
import com.google.ical.values.WeekdayNum;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.service.ExceptionService;
import com.todoroo.andlib.utility.DialogUtilities;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.service.TaskService;
@ -39,6 +36,8 @@ import com.todoroo.astrid.ui.NumberPickerDialog;
import com.todoroo.astrid.ui.NumberPickerDialog.OnNumberPickedListener;
import com.todoroo.astrid.ui.PopupControlSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tasks.R;
import java.text.DateFormatSymbols;
@ -58,6 +57,8 @@ import static org.tasks.date.DateTimeUtils.newDate;
*/
public class RepeatControlSet extends PopupControlSet {
private static final Logger log = LoggerFactory.getLogger(RepeatControlSet.class);
// --- spinner constants
public static final int INTERVAL_DAYS = 0;
@ -91,14 +92,10 @@ public class RepeatControlSet extends PopupControlSet {
public void repeatChanged(boolean repeat);
}
@Autowired
ExceptionService exceptionService;
// --- implementation
public RepeatControlSet(Activity activity, int viewLayout, int displayViewLayout, int title) {
super(activity, viewLayout, displayViewLayout, title);
DependencyInjectionService.getInstance().inject(this);
}
/** Set up the repeat value button */
@ -189,14 +186,12 @@ public class RepeatControlSet extends PopupControlSet {
intervalValue = INTERVAL_YEARS;
break;
default:
// an unhandled recurrence
exceptionService.reportError("repeat-unhandled-rule", //$NON-NLS-1$
new Exception("Unhandled rrule frequency: " + recurrence));
log.error("repeat-unhandled-rule", new Exception("Unhandled rrule frequency: " + recurrence));
}
} catch (Exception e) {
// invalid RRULE
recurrence = ""; //$NON-NLS-1$
exceptionService.reportError("repeat-parse-exception", e);
log.error(e.getMessage(), e);
}
}
doRepeat = recurrence.length() > 0;
@ -239,7 +234,7 @@ public class RepeatControlSet extends PopupControlSet {
} catch (Exception e) {
// invalid RRULE
recurrence = ""; //$NON-NLS-1$
exceptionService.reportError("repeat-parse-exception", e);
log.error(e.getMessage(), e);
}
}
doRepeat = recurrence.length() > 0;

@ -7,8 +7,6 @@ package com.todoroo.astrid.service;
import com.todoroo.andlib.service.AbstractDependencyInjector;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.service.ExceptionService.AndroidLogReporter;
import com.todoroo.andlib.service.ExceptionService.ErrorReporter;
import com.todoroo.astrid.dao.Database;
import com.todoroo.astrid.dao.MetadataDao;
import com.todoroo.astrid.dao.StoreObjectDao;
@ -49,7 +47,6 @@ public class AstridDependencyInjector extends AbstractDependencyInjector {
/**
* Initialize list of injectables. Special care must used when
* instantiating classes that themselves depend on dependency injection
* (i.e. {@link ErrorReporter}.
*/
@Override
protected void addInjectables() {
@ -90,11 +87,6 @@ public class AstridDependencyInjector extends AbstractDependencyInjector {
injectables.put("filterCounter", FilterCounter.class);
injectables.put("refreshScheduler", RefreshScheduler.class);
// these make reference to fields defined above
injectables.put("errorReporters", new ErrorReporter[] {
new AndroidLogReporter(),
});
}
/**

@ -24,7 +24,6 @@ import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.service.ExceptionService;
import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Query;
import com.todoroo.andlib.utility.AndroidUtilities;
@ -50,6 +49,8 @@ import com.todoroo.astrid.tags.TaskToTagMetadata;
import com.todoroo.astrid.utility.AstridPreferences;
import com.todoroo.astrid.utility.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tasks.R;
import java.io.File;
@ -63,6 +64,7 @@ import java.util.List;
*/
public class StartupService {
private static final Logger log = LoggerFactory.getLogger(StartupService.class);
static {
AstridDependencyInjector.initialize();
@ -74,8 +76,6 @@ public class StartupService {
// --- application startup
@Autowired ExceptionService exceptionService;
@Autowired UpgradeService upgradeService;
@Autowired TaskService taskService;
@ -128,7 +128,7 @@ public class StartupService {
try {
latestSetVersion = AstridPreferences.getCurrentVersion();
} catch (Exception e) {
exceptionService.reportError("astrid-startup-version-read", e); //$NON-NLS-1$
log.error(e.getMessage(), e);
}
if (latestSetVersion == 0) {
@ -147,7 +147,7 @@ public class StartupService {
version = pi.versionCode;
versionName = pi.versionName;
} catch (Exception e) {
exceptionService.reportError("astrid-startup-package-read", e); //$NON-NLS-1$
log.error(e.getMessage(), e);
}
Log.i("astrid", "Astrid Startup. " + latestSetVersion + //$NON-NLS-1$ //$NON-NLS-2$

@ -27,7 +27,6 @@ import android.widget.TextView.OnEditorActionListener;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.service.ExceptionService;
import com.todoroo.andlib.utility.DialogUtilities;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.activity.AstridActivity;
@ -47,6 +46,8 @@ import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.utility.Flags;
import com.todoroo.astrid.voice.VoiceRecognizer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tasks.R;
import java.util.HashSet;
@ -59,6 +60,8 @@ import java.util.HashSet;
*/
public class QuickAddBar extends LinearLayout {
private static final Logger log = LoggerFactory.getLogger(QuickAddBar.class);
private ImageButton voiceAddButton;
private ImageButton quickAddButton;
private EditText quickAddBox;
@ -69,7 +72,6 @@ public class QuickAddBar extends LinearLayout {
private RepeatControlSet repeatControl;
private GCalControlSet gcalControl;
@Autowired ExceptionService exceptionService;
@Autowired
private TaskAttachmentDao taskAttachmentDao;
@ -293,8 +295,7 @@ public class QuickAddBar extends LinearLayout {
return task;
} catch (Exception e) {
exceptionService.displayAndReportError(activity,
"quick-add-task", e);
log.error(e.getMessage(), e);
return new Task();
}
}

Loading…
Cancel
Save