diff --git a/src/androidTest/java/com/todoroo/astrid/reminders/NotifyAtDeadlineTest.java b/src/androidTest/java/com/todoroo/astrid/reminders/NotifyAtDeadlineTest.java index 107f1a9fd..0b570613a 100644 --- a/src/androidTest/java/com/todoroo/astrid/reminders/NotifyAtDeadlineTest.java +++ b/src/androidTest/java/com/todoroo/astrid/reminders/NotifyAtDeadlineTest.java @@ -1,6 +1,5 @@ package com.todoroo.astrid.reminders; -import android.annotation.SuppressLint; import android.test.AndroidTestCase; import com.todoroo.astrid.data.Task; @@ -9,30 +8,18 @@ import org.tasks.preferences.Preferences; import org.tasks.scheduling.AlarmManager; import org.tasks.time.DateTime; -import java.util.concurrent.TimeUnit; - import static com.todoroo.astrid.reminders.ReminderService.NO_ALARM; import static org.mockito.Mockito.mock; import static org.tasks.Freeze.freezeAt; import static org.tasks.Freeze.thaw; -import static org.tasks.date.DateTimeUtils.newDate; public class NotifyAtDeadlineTest extends AndroidTestCase { - @SuppressLint("NewApi") - private static final int MILLIS_PER_HOUR = (int) TimeUnit.HOURS.toMillis(1); - - private final Task dueAtNoon = new Task() {{ - setDueDate(Task.URGENCY_SPECIFIC_DAY, newDate(2014, 1, 27).getMillis()); - setReminderFlags(Task.NOTIFY_AT_DEADLINE); - }}; - private ReminderService reminderService; - private Preferences preferences; @Override public void setUp() { - preferences = new Preferences(getContext(), null, null); + Preferences preferences = new Preferences(getContext(), null, null); reminderService = new ReminderService(getContext(), preferences, mock(AlarmManager.class)); freezeAt(new DateTime(2014, 1, 24, 17, 23, 37)); } diff --git a/src/googleplay/java/com/todoroo/astrid/gtasks/auth/GtasksLoginActivity.java b/src/googleplay/java/com/todoroo/astrid/gtasks/auth/GtasksLoginActivity.java index a71562d93..cdef9c958 100644 --- a/src/googleplay/java/com/todoroo/astrid/gtasks/auth/GtasksLoginActivity.java +++ b/src/googleplay/java/com/todoroo/astrid/gtasks/auth/GtasksLoginActivity.java @@ -72,7 +72,7 @@ public class GtasksLoginActivity extends InjectingAppCompatActivity implements A private void getAuthToken(String a, final ProgressDialog pd) { accountManager.getAuthToken(this, a, new AccountManager.AuthResultHandler() { @Override - public void authenticationSuccessful(String accountName, String authToken) { + public void authenticationSuccessful(String accountName) { gtasksPreferenceService.setUserName(accountName); gtasksInvoker.setUserName(accountName); setResult(RESULT_OK); diff --git a/src/googleplay/java/org/tasks/AccountManager.java b/src/googleplay/java/org/tasks/AccountManager.java index c5473ae89..0392171e8 100644 --- a/src/googleplay/java/org/tasks/AccountManager.java +++ b/src/googleplay/java/org/tasks/AccountManager.java @@ -42,7 +42,7 @@ public class AccountManager { } public interface AuthResultHandler { - void authenticationSuccessful(String accountName, String authToken); + void authenticationSuccessful(String accountName); void authenticationFailed(String message); } @@ -85,7 +85,8 @@ public class AccountManager { @Override public void run() { try { - handler.authenticationSuccessful(accountName, GoogleAuthUtil.getToken(activity, account, "oauth2:" + TasksScopes.TASKS, null)); + GoogleAuthUtil.getToken(activity, account, "oauth2:" + TasksScopes.TASKS, null); + handler.authenticationSuccessful(accountName); } catch(UserRecoverableAuthException e) { Timber.e(e, e.getMessage()); activity.startActivityForResult(e.getIntent(), REQUEST_AUTHORIZATION); diff --git a/src/main/java/com/todoroo/andlib/utility/AndroidUtilities.java b/src/main/java/com/todoroo/andlib/utility/AndroidUtilities.java index 591c2753d..04a63d2f8 100644 --- a/src/main/java/com/todoroo/andlib/utility/AndroidUtilities.java +++ b/src/main/java/com/todoroo/andlib/utility/AndroidUtilities.java @@ -260,37 +260,6 @@ public class AndroidUtilities { } } - - - - /** - * Turn ContentValues into a string - */ - public static ContentValues contentValuesFromString(String string) { - if(string == null) { - return null; - } - - String[] pairs = string.split("="); - ContentValues result = new ContentValues(); - String key = null; - for(int i = 0; i < pairs.length; i++) { - String newKey; - int lastSpace = pairs[i].lastIndexOf(' '); - if(lastSpace != -1) { - newKey = pairs[i].substring(lastSpace + 1); - pairs[i] = pairs[i].substring(0, lastSpace); - } else { - newKey = pairs[i]; - } - if(key != null) { - result.put(key.trim(), pairs[i].trim()); - } - key = newKey; - } - return result; - } - /** * Copy a file from one place to another * @throws Exception diff --git a/src/main/java/com/todoroo/andlib/utility/Preferences.java b/src/main/java/com/todoroo/andlib/utility/Preferences.java deleted file mode 100644 index 0bec13816..000000000 --- a/src/main/java/com/todoroo/andlib/utility/Preferences.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright (c) 2012 Todoroo Inc - * - * See the file "LICENSE" for the full license governing this code. - */ -package com.todoroo.andlib.utility; - -import android.content.Context; -import android.content.SharedPreferences; -import android.preference.PreferenceManager; - -import timber.log.Timber; - -/** - * Helper class for reading and writing SharedPreferences - * - * @author Tim Su - * - */ -@Deprecated -public class Preferences { - - private static SharedPreferences preferences = null; - - /** Get preferences object from the context */ - private static SharedPreferences getPrefs(Context context) { - if(preferences != null) { - return preferences; - } - - context = context.getApplicationContext(); - try { - preferences = PreferenceManager.getDefaultSharedPreferences(context); - - // try writing - preferences.edit().commit(); - - } catch (Exception e) { - Timber.e(e, e.getMessage()); - String alternate = "preferences" + android.os.Process.myUid(); //$NON-NLS-1$ - preferences = context.getSharedPreferences(alternate, Context.MODE_PRIVATE); - } - - return preferences; - } - - public static boolean getBoolean(Context context, int keyResources, boolean defValue) { - try { - return getPrefs(context).getBoolean(context.getString(keyResources), defValue); - } catch (ClassCastException e) { - Timber.e(e, e.getMessage()); - return defValue; - } - } -} diff --git a/src/main/java/com/todoroo/astrid/activity/TaskEditFragment.java b/src/main/java/com/todoroo/astrid/activity/TaskEditFragment.java index 814b572fb..cce2ea880 100755 --- a/src/main/java/com/todoroo/astrid/activity/TaskEditFragment.java +++ b/src/main/java/com/todoroo/astrid/activity/TaskEditFragment.java @@ -177,7 +177,6 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener { private EditNoteActivity editNotes; private HideUntilControlSet hideUntilControls; private ReminderControlSet reminderControlSet; - private GCalControlSet gcalControl; @Bind(R.id.title) EditText title; @Bind(R.id.pager) ViewPager mPager; @@ -350,7 +349,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener { RepeatControlSet repeatControls = new RepeatControlSet(preferences, getActivity(), dialogBuilder); controlSetMap.put(getString(R.string.TEA_ctrl_repeat_pref), repeatControls); - gcalControl = new GCalControlSet(gcalHelper, preferences, this, permissionRequestor); + GCalControlSet gcalControl = new GCalControlSet(gcalHelper, preferences, this, permissionRequestor); controlSetMap.put(getString(R.string.TEA_ctrl_gcal), gcalControl); // The deadline control set contains the repeat controls and the @@ -799,7 +798,6 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener { } else { Timber.e("Invalid timestamp"); } - return; } else if (requestCode == ReminderControlSet.REQUEST_NEW_ALARM && resultCode == Activity.RESULT_OK) { long timestamp = data.getLongExtra(TimePickerActivity.EXTRA_TIMESTAMP, 0L); if (timestamp > 0) { diff --git a/src/main/java/com/todoroo/astrid/alarms/AlarmService.java b/src/main/java/com/todoroo/astrid/alarms/AlarmService.java index 71578f210..3235f145f 100644 --- a/src/main/java/com/todoroo/astrid/alarms/AlarmService.java +++ b/src/main/java/com/todoroo/astrid/alarms/AlarmService.java @@ -51,12 +51,6 @@ public class AlarmService { private final MetadataDao metadataDao; private final Context context; private final AlarmManager alarmManager; - private final Callback scheduleAlarm = new Callback() { - @Override - public void apply(Metadata alarm) { - scheduleAlarm(alarm); - } - }; @Inject public AlarmService(MetadataDao metadataDao, @ForApplication Context context, AlarmManager alarmManager) { @@ -119,14 +113,24 @@ public class AlarmService { * Schedules all alarms */ public void scheduleAllAlarms() { - getActiveAlarms(scheduleAlarm); + getActiveAlarms(new Callback() { + @Override + public void apply(Metadata alarm) { + scheduleAlarm(alarm); + } + }); } /** * Schedules alarms for a single task */ private void scheduleAlarms(long taskId) { - getActiveAlarmsForTask(taskId, scheduleAlarm); + getActiveAlarmsForTask(taskId, new Callback() { + @Override + public void apply(Metadata alarm) { + scheduleAlarm(alarm); + } + }); } private PendingIntent pendingIntentForAlarm(Metadata alarm, long taskId) { diff --git a/src/main/java/com/todoroo/astrid/core/SavedFilter.java b/src/main/java/com/todoroo/astrid/core/SavedFilter.java index fb14fe431..d77ecc13d 100644 --- a/src/main/java/com/todoroo/astrid/core/SavedFilter.java +++ b/src/main/java/com/todoroo/astrid/core/SavedFilter.java @@ -11,7 +11,6 @@ import android.text.TextUtils; import com.todoroo.andlib.data.Property.StringProperty; import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.astrid.api.CustomFilter; -import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.core.CustomFilterActivity.CriterionInstance; import com.todoroo.astrid.dao.StoreObjectDao; import com.todoroo.astrid.data.StoreObject; diff --git a/src/main/java/com/todoroo/astrid/dao/StoreObjectDao.java b/src/main/java/com/todoroo/astrid/dao/StoreObjectDao.java index 319d55002..e18b34eb3 100644 --- a/src/main/java/com/todoroo/astrid/dao/StoreObjectDao.java +++ b/src/main/java/com/todoroo/astrid/dao/StoreObjectDao.java @@ -86,9 +86,5 @@ public class StoreObjectDao { public void createNew(StoreObject storeObject) { dao.createNew(storeObject); } - - public StoreObject getById(long id) { - return dao.fetch(id, StoreObject.PROPERTIES); - } } diff --git a/src/main/java/com/todoroo/astrid/data/TaskAttachment.java b/src/main/java/com/todoroo/astrid/data/TaskAttachment.java index 2f04e6cfa..57cc9eb03 100644 --- a/src/main/java/com/todoroo/astrid/data/TaskAttachment.java +++ b/src/main/java/com/todoroo/astrid/data/TaskAttachment.java @@ -131,10 +131,6 @@ public final class TaskAttachment extends RemoteModel { setValue(CONTENT_TYPE, contentType); } - public String getUUID() { - return getValue(UUID); - } - public String getFilePath() { return getValue(FILE_PATH); } diff --git a/src/main/java/com/todoroo/astrid/service/UpgradeActivity.java b/src/main/java/com/todoroo/astrid/service/UpgradeActivity.java index e9beaffca..91a53af7c 100644 --- a/src/main/java/com/todoroo/astrid/service/UpgradeActivity.java +++ b/src/main/java/com/todoroo/astrid/service/UpgradeActivity.java @@ -11,7 +11,6 @@ import android.os.Bundle; import android.os.Environment; import com.todoroo.andlib.utility.DialogUtilities; -import com.todoroo.astrid.activity.AstridActivity; import com.todoroo.astrid.api.AstridApiConstants; import org.tasks.R; diff --git a/src/main/java/com/todoroo/astrid/ui/CustomBorderDrawable.java b/src/main/java/com/todoroo/astrid/ui/CustomBorderDrawable.java deleted file mode 100644 index 3dc1b83e8..000000000 --- a/src/main/java/com/todoroo/astrid/ui/CustomBorderDrawable.java +++ /dev/null @@ -1,59 +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.graphics.Canvas; -import android.graphics.Matrix; -import android.graphics.Paint; -import android.graphics.RectF; -import android.graphics.drawable.ShapeDrawable; -import android.graphics.drawable.StateListDrawable; -import android.graphics.drawable.shapes.RoundRectShape; -import android.graphics.drawable.shapes.Shape; - -public class CustomBorderDrawable extends ShapeDrawable { - private final Paint fillpaint, strokepaint; - private final float strokeWidth; - - public CustomBorderDrawable(Shape s, int fill, int stroke, int strokeWidth) { - super(s); - fillpaint = new Paint(this.getPaint()); - fillpaint.setColor(fill); - strokepaint = new Paint(fillpaint); - strokepaint.setStyle(Paint.Style.STROKE); - strokepaint.setStrokeWidth(strokeWidth); - strokepaint.setColor(stroke); - this.strokeWidth = strokeWidth; - } - - @Override - protected void onDraw(Shape shape, Canvas canvas, Paint paint) { - shape.resize(canvas.getClipBounds().right, - canvas.getClipBounds().bottom); - - Matrix matrix = new Matrix(); - matrix.setRectToRect(new RectF(0, 0, canvas.getClipBounds().right, - canvas.getClipBounds().bottom), - new RectF(strokeWidth/2, strokeWidth/2, canvas.getClipBounds().right - strokeWidth/2, - canvas.getClipBounds().bottom - strokeWidth/2), - Matrix.ScaleToFit.FILL); - canvas.concat(matrix); - - shape.draw(canvas, fillpaint); - shape.draw(canvas, strokepaint); - } - - public static StateListDrawable customButton(int tl, int tr, int br, int bl, int onColor, int offColor, int borderColor, int strokeWidth) { - Shape shape = new RoundRectShape(new float[] { tl, tl, tr, tr, br, br, bl, bl}, null, null); - ShapeDrawable sdOn = new CustomBorderDrawable(shape, onColor, borderColor, strokeWidth); - ShapeDrawable sdOff = new CustomBorderDrawable(shape, offColor, borderColor, strokeWidth); - - StateListDrawable stld = new StateListDrawable(); - stld.addState(new int[] { android.R.attr.state_pressed }, sdOn); - stld.addState(new int[] { android.R.attr.state_checked }, sdOn); - stld.addState(new int[] { android.R.attr.state_enabled }, sdOff); - return stld; - } -} diff --git a/src/main/java/com/todoroo/astrid/ui/EditDialogOkBackground.java b/src/main/java/com/todoroo/astrid/ui/EditDialogOkBackground.java deleted file mode 100644 index 695eecebe..000000000 --- a/src/main/java/com/todoroo/astrid/ui/EditDialogOkBackground.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.todoroo.astrid.ui; - -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.ColorFilter; -import android.graphics.Paint; -import android.graphics.PixelFormat; -import android.graphics.Rect; -import android.graphics.drawable.ColorDrawable; -import android.graphics.drawable.Drawable; -import android.graphics.drawable.StateListDrawable; - -public class EditDialogOkBackground { - - public static StateListDrawable getBg(int colorValue) { - final Paint p = new Paint(); - p.setColor(Color.GRAY); - Drawable d = new Drawable() { - @Override - public void setColorFilter(ColorFilter cf) { - // - } - - @Override - public void setAlpha(int alpha) { - // - } - - @Override - public int getOpacity() { - return PixelFormat.OPAQUE; - } - - @Override - public void draw(Canvas canvas) { - Rect r = canvas.getClipBounds(); - canvas.drawLine(r.left, r.top, r.right, r.top, p); - } - }; - - ColorDrawable color = new ColorDrawable(colorValue); - - StateListDrawable stld = new StateListDrawable(); - stld.addState(new int[] { android.R.attr.state_pressed }, color); - stld.addState(new int[] { android.R.attr.state_enabled }, d); - return stld; - } - -} diff --git a/src/main/java/org/tasks/activities/ClearAllDataActivity.java b/src/main/java/org/tasks/activities/ClearAllDataActivity.java index 445ca7019..151bafd04 100644 --- a/src/main/java/org/tasks/activities/ClearAllDataActivity.java +++ b/src/main/java/org/tasks/activities/ClearAllDataActivity.java @@ -8,7 +8,6 @@ import com.todoroo.astrid.dao.Database; import org.tasks.R; import org.tasks.dialogs.DialogBuilder; import org.tasks.injection.InjectingAppCompatActivity; -import org.tasks.preferences.Preferences; import javax.inject.Inject; diff --git a/src/main/java/org/tasks/activities/ImportTaskActivity.java b/src/main/java/org/tasks/activities/ImportTaskActivity.java index 16a413f21..e946b693b 100644 --- a/src/main/java/org/tasks/activities/ImportTaskActivity.java +++ b/src/main/java/org/tasks/activities/ImportTaskActivity.java @@ -11,7 +11,6 @@ import com.todoroo.astrid.utility.Flags; import org.tasks.R; import org.tasks.injection.InjectingAppCompatActivity; import org.tasks.preferences.ActivityPreferences; -import org.tasks.preferences.Preferences; import javax.inject.Inject; diff --git a/src/main/java/org/tasks/location/GeofenceService.java b/src/main/java/org/tasks/location/GeofenceService.java index f49cc228e..71dc02474 100644 --- a/src/main/java/org/tasks/location/GeofenceService.java +++ b/src/main/java/org/tasks/location/GeofenceService.java @@ -16,9 +16,6 @@ import com.todoroo.astrid.data.Metadata; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.service.SynchronizeMetadataCallback; -import org.tasks.R; -import org.tasks.preferences.Preferences; - import java.util.HashSet; import java.util.List; import java.util.Map; diff --git a/src/main/java/org/tasks/preferences/PermissionChecker.java b/src/main/java/org/tasks/preferences/PermissionChecker.java index 4db089bc1..150bdac80 100644 --- a/src/main/java/org/tasks/preferences/PermissionChecker.java +++ b/src/main/java/org/tasks/preferences/PermissionChecker.java @@ -14,6 +14,7 @@ import javax.inject.Inject; import timber.log.Timber; import static java.util.Arrays.asList; +import static java.util.Collections.singletonList; public class PermissionChecker { @@ -50,7 +51,7 @@ public class PermissionChecker { } private boolean checkPermission(String permission) { - return checkPermissions(asList(permission)); + return checkPermissions(singletonList(permission)); } private boolean checkPermissions(List permissions) { diff --git a/src/main/java/org/tasks/widget/DueDateFormatter.java b/src/main/java/org/tasks/widget/DueDateFormatter.java index b4ac16577..74e9d9f70 100644 --- a/src/main/java/org/tasks/widget/DueDateFormatter.java +++ b/src/main/java/org/tasks/widget/DueDateFormatter.java @@ -16,8 +16,6 @@ import java.util.Map; import javax.inject.Inject; -import static org.tasks.date.DateTimeUtils.newDate; - public class DueDateFormatter { private final Map dateCache = new HashMap<>();