From 9b53257d5fb7c2a81c16e696a3f13a574722c372 Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Thu, 28 Jun 2018 10:40:02 -0500 Subject: [PATCH] google-java-format 1.6.1 --- app/build.gradle | 2 +- app/google_checks.xml | 21 +++--- .../java/org/tasks/TestUtilities.java | 2 +- .../org/tasks/caldav/ThunderbirdTests.java | 3 +- .../org/tasks/jobs/BackupServiceTests.java | 1 - .../astrid/gtasks/GtasksIndentActionTest.java | 1 - .../java/org/tasks/analytics/Tracker.java | 8 +-- .../java/org/tasks/FlavorSetup.java | 3 +- .../com/todoroo/andlib/data/Property.java | 8 +-- .../astrid/activity/TaskListFragment.java | 9 +-- .../java/com/todoroo/astrid/dao/Database.java | 40 +++++------ .../java/com/todoroo/astrid/dao/TaskDao.java | 3 +- .../java/com/todoroo/astrid/data/Task.java | 36 +++++----- .../astrid/gtasks/GtasksFilterExposer.java | 5 +- .../astrid/gtasks/api/GtasksInvoker.java | 1 - .../astrid/gtasks/sync/GtasksSyncService.java | 2 +- .../astrid/service/StartupService.java | 1 - .../todoroo/astrid/service/TaskCreator.java | 3 +- .../todoroo/astrid/service/TaskDeleter.java | 6 +- .../astrid/ui/HideUntilControlSet.java | 7 +- .../java/org/tasks/LocalBroadcastManager.java | 1 - .../GoogleTaskListSettingsActivity.java | 9 ++- .../activities/RemoteListSupportPicker.java | 3 +- .../tasks/activities/TagSettingsActivity.java | 3 +- .../java/org/tasks/analytics/Tracking.java | 3 +- .../java/org/tasks/billing/BillingClient.java | 58 +++++++-------- .../billing/CardsWithHeadersDecoration.java | 61 ++++++++-------- .../java/org/tasks/billing/Inventory.java | 3 +- .../org/tasks/billing/PurchaseActivity.java | 19 +++-- .../main/java/org/tasks/billing/Security.java | 21 +++--- .../java/org/tasks/billing/SkusAdapter.java | 4 +- .../tasks/billing/row/RowDataProvider.java | 9 +-- .../org/tasks/billing/row/RowViewHolder.java | 12 ++-- .../org/tasks/billing/row/SkuRowData.java | 72 +++++++++---------- .../caldav/CaldavAccountSettingsActivity.java | 4 +- .../CaldavCalendarSettingsActivity.java | 7 +- .../org/tasks/caldav/CaldavConverter.java | 4 +- .../org/tasks/caldav/CaldavListFragment.java | 3 +- .../org/tasks/caldav/CaldavSynchronizer.java | 3 +- .../java/org/tasks/data/CaldavCalendar.java | 30 +++++--- .../org/tasks/data/GoogleTaskAccount.java | 26 +++---- .../org/tasks/data/GoogleTaskListDao.java | 5 +- .../org/tasks/data/LimitOffsetDataSource.java | 2 +- .../main/java/org/tasks/db/Migrations.java | 6 +- .../org/tasks/filters/FilterProvider.java | 2 - .../tasks/gtasks/GoogleAccountManager.java | 3 +- .../tasks/gtasks/GoogleTaskSynchronizer.java | 12 ++-- .../InjectingPreferenceActivity.java | 3 +- .../org/tasks/injection/JobComponent.java | 7 -- .../main/java/org/tasks/jobs/BackupJob.java | 18 +++-- .../main/java/org/tasks/jobs/CleanupJob.java | 2 +- .../org/tasks/notifications/Notification.java | 5 +- .../org/tasks/preferences/Preferences.java | 8 +-- .../sync/SynchronizationPreferences.java | 20 +++--- .../tasks/tasklist/ActionModeProvider.java | 6 +- .../java/org/tasks/tasklist/TagFormatter.java | 43 ++++++----- .../java/org/tasks/tasklist/ViewHolder.java | 3 +- .../java/org/tasks/themes/ThemeColor.java | 40 +++++------ 58 files changed, 339 insertions(+), 363 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index b3e7fc2f8..d25dc6856 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -99,7 +99,7 @@ task checkstyle(type: Checkstyle) { checkstyle { configFile project.file('google_checks.xml') - toolVersion = '8.8' + toolVersion = '8.10.1' } configurations { diff --git a/app/google_checks.xml b/app/google_checks.xml index 04286da6e..8e97dd428 100644 --- a/app/google_checks.xml +++ b/app/google_checks.xml @@ -205,24 +205,21 @@ - + + + - + + + + - - - - - - - - - + @@ -230,7 +227,7 @@ value="Method name ''{0}'' must match pattern ''{1}''."/> - + diff --git a/app/src/androidTest/java/org/tasks/TestUtilities.java b/app/src/androidTest/java/org/tasks/TestUtilities.java index b6475c3a2..41e89acf0 100644 --- a/app/src/androidTest/java/org/tasks/TestUtilities.java +++ b/app/src/androidTest/java/org/tasks/TestUtilities.java @@ -23,7 +23,7 @@ public class TestUtilities { } } - public static Task vtodo(String path) { + public static Task vtodo(String path) { Task task = new Task(); CaldavConverter.apply(task, fromResource(path)); diff --git a/app/src/androidTest/java/org/tasks/caldav/ThunderbirdTests.java b/app/src/androidTest/java/org/tasks/caldav/ThunderbirdTests.java index 6e8abafa8..7e53cb499 100644 --- a/app/src/androidTest/java/org/tasks/caldav/ThunderbirdTests.java +++ b/app/src/androidTest/java/org/tasks/caldav/ThunderbirdTests.java @@ -60,7 +60,8 @@ public class ThunderbirdTests { @Test public void repeatDaily() { - assertEquals("RRULE:FREQ=DAILY;INTERVAL=1", vtodo("thunderbird/repeat_daily.txt").getRecurrence()); + assertEquals( + "RRULE:FREQ=DAILY;INTERVAL=1", vtodo("thunderbird/repeat_daily.txt").getRecurrence()); } @Test diff --git a/app/src/androidTest/java/org/tasks/jobs/BackupServiceTests.java b/app/src/androidTest/java/org/tasks/jobs/BackupServiceTests.java index 2591f4cda..aaf88fc9b 100644 --- a/app/src/androidTest/java/org/tasks/jobs/BackupServiceTests.java +++ b/app/src/androidTest/java/org/tasks/jobs/BackupServiceTests.java @@ -17,7 +17,6 @@ import java.io.File; import java.io.IOException; import javax.inject.Inject; import org.junit.After; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.tasks.R; diff --git a/app/src/androidTestGoogleplay/java/com/todoroo/astrid/gtasks/GtasksIndentActionTest.java b/app/src/androidTestGoogleplay/java/com/todoroo/astrid/gtasks/GtasksIndentActionTest.java index 352117b34..d6e3f8ec9 100644 --- a/app/src/androidTestGoogleplay/java/com/todoroo/astrid/gtasks/GtasksIndentActionTest.java +++ b/app/src/androidTestGoogleplay/java/com/todoroo/astrid/gtasks/GtasksIndentActionTest.java @@ -204,5 +204,4 @@ public class GtasksIndentActionTest extends InjectingTestCase { taskDao.createNew(task); return task; } - } diff --git a/app/src/generic/java/org/tasks/analytics/Tracker.java b/app/src/generic/java/org/tasks/analytics/Tracker.java index e7921d287..65d2d8a96 100644 --- a/app/src/generic/java/org/tasks/analytics/Tracker.java +++ b/app/src/generic/java/org/tasks/analytics/Tracker.java @@ -8,6 +8,10 @@ public class Tracker { @Inject public Tracker() {} + public static void report(Exception e) { + Timber.e(e); + } + public void reportException(Throwable t) { Timber.e(t); } @@ -21,8 +25,4 @@ public class Tracker { public void reportEvent(Tracking.Events category, String action, String label) {} public void reportIabResult(int resultCode, String skus) {} - - public static void report(Exception e) { - Timber.e(e); - } } diff --git a/app/src/googleplay/java/org/tasks/FlavorSetup.java b/app/src/googleplay/java/org/tasks/FlavorSetup.java index 3f23b1eda..93b572c75 100644 --- a/app/src/googleplay/java/org/tasks/FlavorSetup.java +++ b/app/src/googleplay/java/org/tasks/FlavorSetup.java @@ -10,8 +10,7 @@ public class FlavorSetup { private final BillingClient billingClient; @Inject - public FlavorSetup(PlayServices playServices, - BillingClient billingClient) { + public FlavorSetup(PlayServices playServices, BillingClient billingClient) { this.playServices = playServices; this.billingClient = billingClient; } diff --git a/app/src/main/java/com/todoroo/andlib/data/Property.java b/app/src/main/java/com/todoroo/andlib/data/Property.java index 98f6bc77c..999385266 100644 --- a/app/src/main/java/com/todoroo/andlib/data/Property.java +++ b/app/src/main/java/com/todoroo/andlib/data/Property.java @@ -84,14 +84,14 @@ public abstract class Property extends Field implements Cloneable { super(table, name); } + IntegerProperty(String name, String expression) { + super(null, name, expression); + } + @Override public IntegerProperty as(String newAlias) { return (IntegerProperty) super.as(newAlias); } - - IntegerProperty(String name, String expression) { - super(null, name, expression); - } } /** diff --git a/app/src/main/java/com/todoroo/astrid/activity/TaskListFragment.java b/app/src/main/java/com/todoroo/astrid/activity/TaskListFragment.java index 671a62aba..e811a8519 100644 --- a/app/src/main/java/com/todoroo/astrid/activity/TaskListFragment.java +++ b/app/src/main/java/com/todoroo/astrid/activity/TaskListFragment.java @@ -82,13 +82,12 @@ public class TaskListFragment extends InjectingFragment public static final String GTASK_METADATA_JOIN = "for_gtask"; // $NON-NLS-1$ public static final String CALDAV_METADATA_JOIN = "for_caldav"; // $NON-NLS-1$ public static final String FILE_METADATA_JOIN = "for_actions"; // $NON-NLS-1$ + public static final int REQUEST_MOVE_TASKS = 11545; private static final int VOICE_RECOGNITION_REQUEST_CODE = 1234; private static final String EXTRA_FILTER = "extra_filter"; private static final String FRAG_TAG_SORT_DIALOG = "frag_tag_sort_dialog"; - // --- instance variables private static final int REQUEST_EDIT_FILTER = 11544; - public static final int REQUEST_MOVE_TASKS = 11545; private final RefreshReceiver refreshReceiver = new RefreshReceiver(); @Inject protected Tracker tracker; protected Filter filter; @@ -446,11 +445,7 @@ public class TaskListFragment extends InjectingFragment // set up list adapters taskAdapter = createTaskAdapter(); recyclerAdapter = - new TaskListRecyclerAdapter( - taskAdapter, - viewHolderFactory, - this, - actionModeProvider); + new TaskListRecyclerAdapter(taskAdapter, viewHolderFactory, this, actionModeProvider); taskAdapter.setHelper(recyclerAdapter.getAsyncPagedListDiffer()); } diff --git a/app/src/main/java/com/todoroo/astrid/dao/Database.java b/app/src/main/java/com/todoroo/astrid/dao/Database.java index 75cb95c80..9c14c8536 100644 --- a/app/src/main/java/com/todoroo/astrid/dao/Database.java +++ b/app/src/main/java/com/todoroo/astrid/dao/Database.java @@ -11,7 +11,6 @@ import android.database.Cursor; import com.todoroo.astrid.data.Task; import java.io.IOException; import org.tasks.analytics.Tracker; -import org.tasks.analytics.Tracking; import org.tasks.data.Alarm; import org.tasks.data.AlarmDao; import org.tasks.data.CaldavAccount; @@ -43,26 +42,25 @@ import org.tasks.notifications.NotificationDao; import timber.log.Timber; @android.arch.persistence.room.Database( - entities = { - Notification.class, - TagData.class, - UserActivity.class, - TaskAttachment.class, - TaskListMetadata.class, - Task.class, - Alarm.class, - Location.class, - Tag.class, - GoogleTask.class, - Filter.class, - GoogleTaskList.class, - CaldavCalendar.class, - CaldavTask.class, - CaldavAccount.class, - GoogleTaskAccount.class - }, - version = 59 -) + entities = { + Notification.class, + TagData.class, + UserActivity.class, + TaskAttachment.class, + TaskListMetadata.class, + Task.class, + Alarm.class, + Location.class, + Tag.class, + GoogleTask.class, + Filter.class, + GoogleTaskList.class, + CaldavCalendar.class, + CaldavTask.class, + CaldavAccount.class, + GoogleTaskAccount.class + }, + version = 59) public abstract class Database extends RoomDatabase { public static final String NAME = "database"; diff --git a/app/src/main/java/com/todoroo/astrid/dao/TaskDao.java b/app/src/main/java/com/todoroo/astrid/dao/TaskDao.java index 9129c18dd..0e8a53eff 100644 --- a/app/src/main/java/com/todoroo/astrid/dao/TaskDao.java +++ b/app/src/main/java/com/todoroo/astrid/dao/TaskDao.java @@ -57,7 +57,8 @@ public abstract class TaskDao { @android.arch.persistence.room.Query("SELECT * FROM tasks WHERE _id IN (:taskIds)") public abstract List fetch(List taskIds); - @android.arch.persistence.room.Query("SELECT COUNT(1) FROM tasks WHERE timerStart > 0 AND deleted = 0") + @android.arch.persistence.room.Query( + "SELECT COUNT(1) FROM tasks WHERE timerStart > 0 AND deleted = 0") public abstract int activeTimers(); @android.arch.persistence.room.Query( diff --git a/app/src/main/java/com/todoroo/astrid/data/Task.java b/app/src/main/java/com/todoroo/astrid/data/Task.java index 9e2857687..cd617d662 100644 --- a/app/src/main/java/com/todoroo/astrid/data/Task.java +++ b/app/src/main/java/com/todoroo/astrid/data/Task.java @@ -99,15 +99,6 @@ public class Task implements Parcelable { /** reminder mode five times (exclusive with non-stop) */ public static final int NOTIFY_MODE_FIVE = 1 << 4; - @Retention(SOURCE) - @IntDef({Priority.HIGH, Priority.MEDIUM, Priority.LOW, Priority.NONE}) - public @interface Priority { - int HIGH = 0; - int MEDIUM = 1; - int LOW = 2; - int NONE = 3; - } - public static final Creator CREATOR = new Creator() { @Override @@ -132,24 +123,22 @@ public class Task implements Parcelable { public static final int HIDE_UNTIL_DAY_BEFORE = 2; public static final int HIDE_UNTIL_WEEK_BEFORE = 3; public static final int HIDE_UNTIL_SPECIFIC_DAY = 4; - // --- for astrid.com public static final int HIDE_UNTIL_SPECIFIC_DAY_TIME = 5; public static final int HIDE_UNTIL_DUE_TIME = 6; static final int URGENCY_TODAY = 1; static final int URGENCY_TOMORROW = 2; - // --- notification flags static final int URGENCY_DAY_AFTER = 3; static final int URGENCY_NEXT_WEEK = 4; static final int URGENCY_IN_TWO_WEEKS = 5; static final int URGENCY_NEXT_MONTH = 6; - - // --- importance settings (note: importance > 3 are supported via plugin) /** ID */ @PrimaryKey(autoGenerate = true) @ColumnInfo(name = "_id") public transient Long id = NO_ID; + + // --- importance settings (note: importance > 3 are supported via plugin) /** Name of Task */ @ColumnInfo(name = "title") public String title = ""; @@ -171,12 +160,11 @@ public class Task implements Parcelable { /** Unixtime Task was completed. 0 means active */ @ColumnInfo(name = "completed") public Long completed = 0L; - - // --- data access boilerplate /** Unixtime Task was deleted. 0 means not deleted */ @ColumnInfo(name = "deleted") public Long deleted = 0L; + // --- data access boilerplate @ColumnInfo(name = "notes") public String notes = ""; @@ -191,16 +179,16 @@ public class Task implements Parcelable { /** Flags for when to send reminders */ @ColumnInfo(name = "notificationFlags") public Integer notificationFlags = 0; - - // --- parcelable helpers /** Reminder period, in milliseconds. 0 means disabled */ @ColumnInfo(name = "notifications") public Long notifications = 0L; - // --- data access methods + // --- parcelable helpers /** Unixtime the last reminder was triggered */ @ColumnInfo(name = "lastNotified") public Long lastNotified = 0L; + + // --- data access methods /** Unixtime snooze is set (0 -> no snooze) */ @ColumnInfo(name = "snoozeTime") public Long snoozeTime = 0L; @@ -213,12 +201,11 @@ public class Task implements Parcelable { @ColumnInfo(name = "calendarUri") public String calendarUri = ""; - - // --- due and hide until date management /** Remote id */ @ColumnInfo(name = "remoteId") public String remoteId = NO_UUID; + // --- due and hide until date management @Ignore private transient int indent; @Ignore private transient String tags; @Ignore private transient String googleTaskList; @@ -1215,4 +1202,13 @@ public class Task implements Parcelable { public boolean hasFiles() { return hasFiles; } + + @Retention(SOURCE) + @IntDef({Priority.HIGH, Priority.MEDIUM, Priority.LOW, Priority.NONE}) + public @interface Priority { + int HIGH = 0; + int MEDIUM = 1; + int LOW = 2; + int NONE = 3; + } } diff --git a/app/src/main/java/com/todoroo/astrid/gtasks/GtasksFilterExposer.java b/app/src/main/java/com/todoroo/astrid/gtasks/GtasksFilterExposer.java index 360a8d318..7c61647ae 100644 --- a/app/src/main/java/com/todoroo/astrid/gtasks/GtasksFilterExposer.java +++ b/app/src/main/java/com/todoroo/astrid/gtasks/GtasksFilterExposer.java @@ -30,7 +30,10 @@ public class GtasksFilterExposer { private final GoogleTaskListDao googleTaskListDao; @Inject - public GtasksFilterExposer(GtasksListService gtasksListService, SyncAdapters syncAdapters, GoogleTaskListDao googleTaskListDao) { + public GtasksFilterExposer( + GtasksListService gtasksListService, + SyncAdapters syncAdapters, + GoogleTaskListDao googleTaskListDao) { this.gtasksListService = gtasksListService; this.syncAdapters = syncAdapters; this.googleTaskListDao = googleTaskListDao; diff --git a/app/src/main/java/com/todoroo/astrid/gtasks/api/GtasksInvoker.java b/app/src/main/java/com/todoroo/astrid/gtasks/api/GtasksInvoker.java index a75ee5aea..4c105bd04 100644 --- a/app/src/main/java/com/todoroo/astrid/gtasks/api/GtasksInvoker.java +++ b/app/src/main/java/com/todoroo/astrid/gtasks/api/GtasksInvoker.java @@ -16,7 +16,6 @@ import com.google.api.services.tasks.model.TaskLists; import java.io.IOException; import java.util.Collections; import org.tasks.BuildConfig; -import org.tasks.data.GoogleTaskAccount; import org.tasks.gtasks.GoogleTasksUnsuccessfulResponseHandler; import org.tasks.gtasks.PlayServices; import timber.log.Timber; diff --git a/app/src/main/java/com/todoroo/astrid/gtasks/sync/GtasksSyncService.java b/app/src/main/java/com/todoroo/astrid/gtasks/sync/GtasksSyncService.java index d26b1412b..17fca6dd4 100644 --- a/app/src/main/java/com/todoroo/astrid/gtasks/sync/GtasksSyncService.java +++ b/app/src/main/java/com/todoroo/astrid/gtasks/sync/GtasksSyncService.java @@ -166,8 +166,8 @@ public class GtasksSyncService { private class MoveOp implements SyncOnSaveOperation { - private final GoogleTaskList googleTaskList; final GoogleTask googleTask; + private final GoogleTaskList googleTaskList; MoveOp(GoogleTaskList googleTaskList, GoogleTask googleTask) { this.googleTaskList = googleTaskList; diff --git a/app/src/main/java/com/todoroo/astrid/service/StartupService.java b/app/src/main/java/com/todoroo/astrid/service/StartupService.java index 6e5a946f7..f98b65676 100644 --- a/app/src/main/java/com/todoroo/astrid/service/StartupService.java +++ b/app/src/main/java/com/todoroo/astrid/service/StartupService.java @@ -8,7 +8,6 @@ package com.todoroo.astrid.service; import static com.google.common.base.Strings.isNullOrEmpty; import android.content.Context; -import android.database.sqlite.SQLiteException; import android.os.Environment; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableListMultimap; diff --git a/app/src/main/java/com/todoroo/astrid/service/TaskCreator.java b/app/src/main/java/com/todoroo/astrid/service/TaskCreator.java index e18231c69..b2f51c5e0 100644 --- a/app/src/main/java/com/todoroo/astrid/service/TaskCreator.java +++ b/app/src/main/java/com/todoroo/astrid/service/TaskCreator.java @@ -127,8 +127,7 @@ public class TaskCreator { task.setUuid(UUIDHelper.newUUID()); task.setPriority( - preferences.getIntegerFromString( - R.string.p_default_importance_key, Priority.LOW)); + preferences.getIntegerFromString(R.string.p_default_importance_key, Priority.LOW)); task.setDueDate( Task.createDueDate( preferences.getIntegerFromString(R.string.p_default_urgency_key, Task.URGENCY_NONE), diff --git a/app/src/main/java/com/todoroo/astrid/service/TaskDeleter.java b/app/src/main/java/com/todoroo/astrid/service/TaskDeleter.java index 3af45d341..7c85aeec1 100644 --- a/app/src/main/java/com/todoroo/astrid/service/TaskDeleter.java +++ b/app/src/main/java/com/todoroo/astrid/service/TaskDeleter.java @@ -27,7 +27,11 @@ public class TaskDeleter { private final DeletionDao deletionDao; @Inject - public TaskDeleter(DeletionDao deletionDao, JobManager jobManager, TaskDao taskDao, LocalBroadcastManager localBroadcastManager) { + public TaskDeleter( + DeletionDao deletionDao, + JobManager jobManager, + TaskDao taskDao, + LocalBroadcastManager localBroadcastManager) { this.deletionDao = deletionDao; this.jobManager = jobManager; this.taskDao = taskDao; diff --git a/app/src/main/java/com/todoroo/astrid/ui/HideUntilControlSet.java b/app/src/main/java/com/todoroo/astrid/ui/HideUntilControlSet.java index 8baf508a2..b9f60f911 100644 --- a/app/src/main/java/com/todoroo/astrid/ui/HideUntilControlSet.java +++ b/app/src/main/java/com/todoroo/astrid/ui/HideUntilControlSet.java @@ -241,7 +241,12 @@ public class HideUntilControlSet extends TaskEditControlFragment implements OnIt new HideUntilValue(labelsSpinner[1], labelsDisplay[1], Task.HIDE_UNTIL_DUE_TIME), new HideUntilValue(labelsSpinner[2], labelsDisplay[2], Task.HIDE_UNTIL_DAY_BEFORE), new HideUntilValue(labelsSpinner[3], labelsDisplay[3], Task.HIDE_UNTIL_WEEK_BEFORE), - new HideUntilValue(labelsSpinner[4], "", Task.HIDE_UNTIL_SPECIFIC_DAY, -1)))); // no need for a string for display here, since the chosen day will be displayed + new HideUntilValue( + labelsSpinner[4], + "", + Task.HIDE_UNTIL_SPECIFIC_DAY, + -1)))); // no need for a string for display here, since the chosen day will be + // displayed if (specificDate > 0) { spinnerItems.add(0, getHideUntilValue(specificDate)); diff --git a/app/src/main/java/org/tasks/LocalBroadcastManager.java b/app/src/main/java/org/tasks/LocalBroadcastManager.java index a6bbd46e3..f07be3edd 100644 --- a/app/src/main/java/org/tasks/LocalBroadcastManager.java +++ b/app/src/main/java/org/tasks/LocalBroadcastManager.java @@ -4,7 +4,6 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; -import com.android.billingclient.api.BillingClient.BillingResponse; import com.todoroo.astrid.api.AstridApiConstants; import javax.inject.Inject; import org.tasks.injection.ForApplication; diff --git a/app/src/main/java/org/tasks/activities/GoogleTaskListSettingsActivity.java b/app/src/main/java/org/tasks/activities/GoogleTaskListSettingsActivity.java index 5b0724bce..27a192c2e 100644 --- a/app/src/main/java/org/tasks/activities/GoogleTaskListSettingsActivity.java +++ b/app/src/main/java/org/tasks/activities/GoogleTaskListSettingsActivity.java @@ -172,7 +172,8 @@ public class GoogleTaskListSettingsActivity extends ThemedInjectingAppCompatActi } if (isNewList) { - newCreateListDialog(gtasksList.getAccount(), newName).show(getSupportFragmentManager(), FRAG_TAG_CREATE_LIST_DIALOG); + newCreateListDialog(gtasksList.getAccount(), newName) + .show(getSupportFragmentManager(), FRAG_TAG_CREATE_LIST_DIALOG); } else if (nameChanged()) { newRenameListDialog(gtasksList, newName) .show(getSupportFragmentManager(), FRAG_TAG_RENAME_LIST_DIALOG); @@ -267,8 +268,7 @@ public class GoogleTaskListSettingsActivity extends ThemedInjectingAppCompatActi gtasksList.setColor(selectedTheme); gtasksList.setId(googleTaskListDao.insertOrReplace(gtasksList)); setResult( - RESULT_OK, - new Intent().putExtra(MainActivity.OPEN_FILTER, new GtasksFilter(gtasksList))); + RESULT_OK, new Intent().putExtra(MainActivity.OPEN_FILTER, new GtasksFilter(gtasksList))); finish(); } @@ -288,8 +288,7 @@ public class GoogleTaskListSettingsActivity extends ThemedInjectingAppCompatActi googleTaskListDao.insertOrReplace(gtasksList); setResult( RESULT_OK, - new Intent(ACTION_RELOAD) - .putExtra(MainActivity.OPEN_FILTER, new GtasksFilter(gtasksList))); + new Intent(ACTION_RELOAD).putExtra(MainActivity.OPEN_FILTER, new GtasksFilter(gtasksList))); finish(); } diff --git a/app/src/main/java/org/tasks/activities/RemoteListSupportPicker.java b/app/src/main/java/org/tasks/activities/RemoteListSupportPicker.java index 1296cebe3..5ed9f9273 100644 --- a/app/src/main/java/org/tasks/activities/RemoteListSupportPicker.java +++ b/app/src/main/java/org/tasks/activities/RemoteListSupportPicker.java @@ -77,7 +77,8 @@ public class RemoteListSupportPicker extends InjectingDialogFragment { Bundle arguments = getArguments(); int selected = arguments.getBoolean(EXTRA_NO_SELECTION, false) - ? -1 : filterAdapter.indexOf(arguments.getParcelable(EXTRA_SELECTED_FILTER), 0); + ? -1 + : filterAdapter.indexOf(arguments.getParcelable(EXTRA_SELECTED_FILTER), 0); return createDialog(filterAdapter, dialogBuilder, selected, this::selected); } diff --git a/app/src/main/java/org/tasks/activities/TagSettingsActivity.java b/app/src/main/java/org/tasks/activities/TagSettingsActivity.java index 5cc0945e8..f624ad2b2 100644 --- a/app/src/main/java/org/tasks/activities/TagSettingsActivity.java +++ b/app/src/main/java/org/tasks/activities/TagSettingsActivity.java @@ -189,8 +189,7 @@ public class TagSettingsActivity extends ThemedInjectingAppCompatActivity tagData.setName(newName); tagData.setColor(selectedTheme); tagDataDao.createNew(tagData); - setResult( - RESULT_OK, new Intent().putExtra(MainActivity.OPEN_FILTER, new TagFilter(tagData))); + setResult(RESULT_OK, new Intent().putExtra(MainActivity.OPEN_FILTER, new TagFilter(tagData))); } else if (hasChanges()) { tagData.setName(newName); tagData.setColor(selectedTheme); diff --git a/app/src/main/java/org/tasks/analytics/Tracking.java b/app/src/main/java/org/tasks/analytics/Tracking.java index 9824ddbc4..6e2f780d6 100644 --- a/app/src/main/java/org/tasks/analytics/Tracking.java +++ b/app/src/main/java/org/tasks/analytics/Tracking.java @@ -46,7 +46,8 @@ public class Tracking { IMPORT_JSON(R.string.tracking_category_backup, R.string.tracking_action_import_json), EXPORT(R.string.tracking_category_backup, R.string.tracking_action_export), CALDAV_ACCOUNT_ADDED(R.string.tracking_category_caldav, R.string.tracking_action_add_account), - CALDAV_ACCOUNT_REMOVED(R.string.tracking_category_caldav, R.string.tracking_action_remove_account), + CALDAV_ACCOUNT_REMOVED( + R.string.tracking_category_caldav, R.string.tracking_action_remove_account), CALDAV_LIST_ADDED(R.string.tracking_category_caldav, R.string.tracking_action_new_list), CALDAV_LIST_DELETED(R.string.tracking_category_caldav, R.string.tracking_action_delete_list); diff --git a/app/src/main/java/org/tasks/billing/BillingClient.java b/app/src/main/java/org/tasks/billing/BillingClient.java index 67c5bc819..6f00cc06c 100644 --- a/app/src/main/java/org/tasks/billing/BillingClient.java +++ b/app/src/main/java/org/tasks/billing/BillingClient.java @@ -47,6 +47,35 @@ public class BillingClient implements PurchasesUpdatedListener { com.android.billingclient.api.BillingClient.newBuilder(context).setListener(this).build(); } + public static String BillingResponseToString(@BillingResponse int response) { + switch (response) { + case BillingResponse.FEATURE_NOT_SUPPORTED: + return "FEATURE_NOT_SUPPORTED"; + case BillingResponse.SERVICE_DISCONNECTED: + return "SERVICE_DISCONNECTED"; + case BillingResponse.OK: + return "OK"; + case BillingResponse.USER_CANCELED: + return "USER_CANCELED"; + case BillingResponse.SERVICE_UNAVAILABLE: + return "SERVICE_UNAVAILABLE"; + case BillingResponse.BILLING_UNAVAILABLE: + return "BILLING_UNAVAILABLE"; + case BillingResponse.ITEM_UNAVAILABLE: + return "ITEM_UNAVAILABLE"; + case BillingResponse.DEVELOPER_ERROR: + return "DEVELOPER_ERROR"; + case BillingResponse.ERROR: + return "ERROR"; + case BillingResponse.ITEM_ALREADY_OWNED: + return "ITEM_ALREADY_OWNED"; + case BillingResponse.ITEM_NOT_OWNED: + return "ITEM_NOT_OWNED"; + default: + return "Unknown"; + } + } + public void initialize() { startServiceConnection(this::queryPurchases); } @@ -233,33 +262,4 @@ public class BillingClient implements PurchasesUpdatedListener { public int getBillingClientResponseCode() { return billingClientResponseCode; } - - public static String BillingResponseToString(@BillingResponse int response) { - switch (response) { - case BillingResponse.FEATURE_NOT_SUPPORTED: - return "FEATURE_NOT_SUPPORTED"; - case BillingResponse.SERVICE_DISCONNECTED: - return "SERVICE_DISCONNECTED"; - case BillingResponse.OK: - return "OK"; - case BillingResponse.USER_CANCELED: - return "USER_CANCELED"; - case BillingResponse.SERVICE_UNAVAILABLE: - return "SERVICE_UNAVAILABLE"; - case BillingResponse.BILLING_UNAVAILABLE: - return "BILLING_UNAVAILABLE"; - case BillingResponse.ITEM_UNAVAILABLE: - return "ITEM_UNAVAILABLE"; - case BillingResponse.DEVELOPER_ERROR: - return "DEVELOPER_ERROR"; - case BillingResponse.ERROR: - return "ERROR"; - case BillingResponse.ITEM_ALREADY_OWNED: - return "ITEM_ALREADY_OWNED"; - case BillingResponse.ITEM_NOT_OWNED: - return "ITEM_NOT_OWNED"; - default: - return "Unknown"; - } - } } diff --git a/app/src/main/java/org/tasks/billing/CardsWithHeadersDecoration.java b/app/src/main/java/org/tasks/billing/CardsWithHeadersDecoration.java index a9352460a..6cd684b8e 100644 --- a/app/src/main/java/org/tasks/billing/CardsWithHeadersDecoration.java +++ b/app/src/main/java/org/tasks/billing/CardsWithHeadersDecoration.java @@ -19,38 +19,35 @@ import android.view.View; import org.tasks.billing.row.RowDataProvider; import org.tasks.billing.row.SkuRowData; -/** - * A separator for RecyclerView that keeps the specified spaces between headers and the cards. - */ +/** A separator for RecyclerView that keeps the specified spaces between headers and the cards. */ public class CardsWithHeadersDecoration extends RecyclerView.ItemDecoration { - private final RowDataProvider mRowDataProvider; - private final int mHeaderGap, mRowGap; - - public CardsWithHeadersDecoration(RowDataProvider rowDataProvider, int headerGap, - int rowGap) { - this.mRowDataProvider = rowDataProvider; - this.mHeaderGap = headerGap; - this.mRowGap = rowGap; - } - - @Override - public void getItemOffsets(Rect outRect, View view, RecyclerView parent, - RecyclerView.State state) { - - final int position = parent.getChildAdapterPosition(view); - final SkuRowData data = mRowDataProvider.getData(position); - - // We should add a space on top of every header card - if (data.getRowType() == SkusAdapter.TYPE_HEADER || position == 0) { - outRect.top = mHeaderGap; - } - - // Adding a space under the last item - if (position == parent.getAdapter().getItemCount() - 1) { - outRect.bottom = mHeaderGap; - } else { - outRect.bottom = mRowGap; - } - } + private final RowDataProvider mRowDataProvider; + private final int mHeaderGap, mRowGap; + + public CardsWithHeadersDecoration(RowDataProvider rowDataProvider, int headerGap, int rowGap) { + this.mRowDataProvider = rowDataProvider; + this.mHeaderGap = headerGap; + this.mRowGap = rowGap; + } + + @Override + public void getItemOffsets( + Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { + + final int position = parent.getChildAdapterPosition(view); + final SkuRowData data = mRowDataProvider.getData(position); + + // We should add a space on top of every header card + if (data.getRowType() == SkusAdapter.TYPE_HEADER || position == 0) { + outRect.top = mHeaderGap; + } + + // Adding a space under the last item + if (position == parent.getAdapter().getItemCount() - 1) { + outRect.bottom = mHeaderGap; + } else { + outRect.bottom = mRowGap; + } + } } diff --git a/app/src/main/java/org/tasks/billing/Inventory.java b/app/src/main/java/org/tasks/billing/Inventory.java index 8fe24341b..1d4225088 100644 --- a/app/src/main/java/org/tasks/billing/Inventory.java +++ b/app/src/main/java/org/tasks/billing/Inventory.java @@ -15,12 +15,11 @@ import timber.log.Timber; @ApplicationScope public class Inventory { - private static final String SKU_PRO = "annual_499"; static final String SKU_VIP = "vip"; static final String SKU_TASKER = "tasker"; static final String SKU_THEMES = "themes"; static final String SKU_DASHCLOCK = "dashclock"; - + private static final String SKU_PRO = "annual_499"; public static final List SKU_SUBS = ImmutableList.of(SKU_PRO); private final Preferences preferences; diff --git a/app/src/main/java/org/tasks/billing/PurchaseActivity.java b/app/src/main/java/org/tasks/billing/PurchaseActivity.java index c503b4ae9..99f67edfa 100644 --- a/app/src/main/java/org/tasks/billing/PurchaseActivity.java +++ b/app/src/main/java/org/tasks/billing/PurchaseActivity.java @@ -55,8 +55,6 @@ public class PurchaseActivity extends ThemedInjectingAppCompatActivity @Inject Inventory inventory; @Inject LocalBroadcastManager localBroadcastManager; - private SkusAdapter adapter; - @BindView(R.id.toolbar) Toolbar toolbar; @@ -69,6 +67,15 @@ public class PurchaseActivity extends ThemedInjectingAppCompatActivity @BindView(R.id.error_textview) TextView errorTextView; + private SkusAdapter adapter; + private BroadcastReceiver purchaseReceiver = + new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + querySkuDetails(); + } + }; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -226,14 +233,6 @@ public class PurchaseActivity extends ThemedInjectingAppCompatActivity } } - private BroadcastReceiver purchaseReceiver = - new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - querySkuDetails(); - } - }; - @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { diff --git a/app/src/main/java/org/tasks/billing/Security.java b/app/src/main/java/org/tasks/billing/Security.java index c2b4c4cde..18c2b7d19 100644 --- a/app/src/main/java/org/tasks/billing/Security.java +++ b/app/src/main/java/org/tasks/billing/Security.java @@ -40,17 +40,17 @@ public class Security { private static final String SIGNATURE_ALGORITHM = "SHA1withRSA"; /** - * Verifies that the data was signed with the given signature, and returns the verified - * purchase. + * Verifies that the data was signed with the given signature, and returns the verified purchase. + * * @param base64PublicKey the base64-encoded public key to use for verifying. * @param signedData the signed JSON string (signed, not encrypted) * @param signature the signature for the data, signed with the private key - * @throws IOException if encoding algorithm is not supported or key specification - * is invalid + * @throws IOException if encoding algorithm is not supported or key specification is invalid */ - public static boolean verifyPurchase(String base64PublicKey, String signedData, - String signature) throws IOException { - if (TextUtils.isEmpty(signedData) || TextUtils.isEmpty(base64PublicKey) + public static boolean verifyPurchase(String base64PublicKey, String signedData, String signature) + throws IOException { + if (TextUtils.isEmpty(signedData) + || TextUtils.isEmpty(base64PublicKey) || TextUtils.isEmpty(signature)) { BillingHelper.logWarn(TAG, "Purchase verification failed: missing data."); return false; @@ -64,8 +64,7 @@ public class Security { * Generates a PublicKey instance from a string containing the Base64-encoded public key. * * @param encodedPublicKey Base64-encoded public key - * @throws IOException if encoding algorithm is not supported or key specification - * is invalid + * @throws IOException if encoding algorithm is not supported or key specification is invalid */ public static PublicKey generatePublicKey(String encodedPublicKey) throws IOException { try { @@ -83,8 +82,8 @@ public class Security { } /** - * Verifies that the signature from the server matches the computed signature on the data. - * Returns true if the data is correctly signed. + * Verifies that the signature from the server matches the computed signature on the data. Returns + * true if the data is correctly signed. * * @param publicKey public key associated with the developer account * @param signedData signed data from server diff --git a/app/src/main/java/org/tasks/billing/SkusAdapter.java b/app/src/main/java/org/tasks/billing/SkusAdapter.java index b6399ccc2..7f78b5a63 100644 --- a/app/src/main/java/org/tasks/billing/SkusAdapter.java +++ b/app/src/main/java/org/tasks/billing/SkusAdapter.java @@ -38,8 +38,8 @@ import org.tasks.billing.row.RowViewHolder; import org.tasks.billing.row.RowViewHolder.ButtonClick; import org.tasks.billing.row.SkuRowData; -public class SkusAdapter extends RecyclerView.Adapter implements RowDataProvider, - ButtonClick { +public class SkusAdapter extends RecyclerView.Adapter + implements RowDataProvider, ButtonClick { public static final int TYPE_HEADER = 0; public static final int TYPE_NORMAL = 1; diff --git a/app/src/main/java/org/tasks/billing/row/RowDataProvider.java b/app/src/main/java/org/tasks/billing/row/RowDataProvider.java index c4fa6f180..2c798dd08 100644 --- a/app/src/main/java/org/tasks/billing/row/RowDataProvider.java +++ b/app/src/main/java/org/tasks/billing/row/RowDataProvider.java @@ -15,12 +15,7 @@ */ package org.tasks.billing.row; - - -/** - * Provider for data that corresponds to a particular row - */ +/** Provider for data that corresponds to a particular row */ public interface RowDataProvider { - SkuRowData getData(int position); + SkuRowData getData(int position); } - diff --git a/app/src/main/java/org/tasks/billing/row/RowViewHolder.java b/app/src/main/java/org/tasks/billing/row/RowViewHolder.java index f3a4344a9..07ddc6ef6 100644 --- a/app/src/main/java/org/tasks/billing/row/RowViewHolder.java +++ b/app/src/main/java/org/tasks/billing/row/RowViewHolder.java @@ -13,12 +13,6 @@ public final class RowViewHolder extends RecyclerView.ViewHolder { public final Button subscribeButton; public final Button auxiliaryButton; - public interface ButtonClick { - void onAuxiliaryClick(int row); - - void onClick(int row); - } - public RowViewHolder(final View itemView, final ButtonClick onClick) { super(itemView); title = itemView.findViewById(R.id.title); @@ -33,4 +27,10 @@ public final class RowViewHolder extends RecyclerView.ViewHolder { subscribeButton.setOnClickListener(view -> onClick.onClick(getAdapterPosition())); } } + + public interface ButtonClick { + void onAuxiliaryClick(int row); + + void onClick(int row); + } } diff --git a/app/src/main/java/org/tasks/billing/row/SkuRowData.java b/app/src/main/java/org/tasks/billing/row/SkuRowData.java index b59149bbf..bc069ffcd 100644 --- a/app/src/main/java/org/tasks/billing/row/SkuRowData.java +++ b/app/src/main/java/org/tasks/billing/row/SkuRowData.java @@ -20,51 +20,47 @@ import com.android.billingclient.api.SkuDetails; import org.tasks.billing.SkusAdapter; import org.tasks.billing.SkusAdapter.RowTypeDef; -/** - * A model for SkusAdapter's row - */ +/** A model for SkusAdapter's row */ public class SkuRowData { - private String sku, title, price, description; - private @RowTypeDef int type; - private @SkuType String billingType; + private String sku, title, price, description; + private @RowTypeDef int type; + private @SkuType String billingType; - public SkuRowData(SkuDetails details, @RowTypeDef int rowType, - @SkuType String billingType) { - this.sku = details.getSku(); - this.title = details.getTitle(); - this.price = details.getPrice(); - this.description = details.getDescription(); - this.type = rowType; - this.billingType = billingType; - } + public SkuRowData(SkuDetails details, @RowTypeDef int rowType, @SkuType String billingType) { + this.sku = details.getSku(); + this.title = details.getTitle(); + this.price = details.getPrice(); + this.description = details.getDescription(); + this.type = rowType; + this.billingType = billingType; + } - public SkuRowData(String title) { - this.title = title; - this.type = SkusAdapter.TYPE_HEADER; - } + public SkuRowData(String title) { + this.title = title; + this.type = SkusAdapter.TYPE_HEADER; + } - public String getSku() { - return sku; - } + public String getSku() { + return sku; + } - public String getTitle() { - return title; - } + public String getTitle() { + return title; + } - public String getPrice() { - return price; - } + public String getPrice() { + return price; + } - public String getDescription() { - return description; - } + public String getDescription() { + return description; + } - public @RowTypeDef int getRowType() { - return type; - } + public @RowTypeDef int getRowType() { + return type; + } - public @SkuType - String getSkuType() { - return billingType; - } + public @SkuType String getSkuType() { + return billingType; + } } diff --git a/app/src/main/java/org/tasks/caldav/CaldavAccountSettingsActivity.java b/app/src/main/java/org/tasks/caldav/CaldavAccountSettingsActivity.java index 3568d9aa5..c138db04f 100644 --- a/app/src/main/java/org/tasks/caldav/CaldavAccountSettingsActivity.java +++ b/app/src/main/java/org/tasks/caldav/CaldavAccountSettingsActivity.java @@ -191,9 +191,7 @@ public class CaldavAccountSettingsActivity extends ThemedInjectingAppCompatActiv private String getNewPassword() { String input = password.getText().toString().trim(); - return PASSWORD_MASK.equals(input) - ? encryption.decrypt(caldavAccount.getPassword()) - : input; + return PASSWORD_MASK.equals(input) ? encryption.decrypt(caldavAccount.getPassword()) : input; } private void save() { diff --git a/app/src/main/java/org/tasks/caldav/CaldavCalendarSettingsActivity.java b/app/src/main/java/org/tasks/caldav/CaldavCalendarSettingsActivity.java index f8aa50da0..3d9153abc 100644 --- a/app/src/main/java/org/tasks/caldav/CaldavCalendarSettingsActivity.java +++ b/app/src/main/java/org/tasks/caldav/CaldavCalendarSettingsActivity.java @@ -118,9 +118,7 @@ public class CaldavCalendarSettingsActivity extends ThemedInjectingAppCompatActi final boolean backButtonSavesTask = preferences.backButtonSavesTask(); toolbar.setTitle( - caldavCalendar == null - ? getString(R.string.new_list) - : caldavCalendar.getName()); + caldavCalendar == null ? getString(R.string.new_list) : caldavCalendar.getName()); toolbar.setNavigationIcon( ContextCompat.getDrawable( this, backButtonSavesTask ? R.drawable.ic_close_24dp : R.drawable.ic_save_24dp)); @@ -359,7 +357,8 @@ public class CaldavCalendarSettingsActivity extends ThemedInjectingAppCompatActi (dialog, which) -> { CaldavClient caldavClient = new CaldavClient(caldavAccount, caldavCalendar, encryption); - ProgressDialog progressDialog = dialogBuilder.newProgressDialog(R.string.contacting_server); + ProgressDialog progressDialog = + dialogBuilder.newProgressDialog(R.string.contacting_server); progressDialog.show(); caldavClient .deleteCollection() diff --git a/app/src/main/java/org/tasks/caldav/CaldavConverter.java b/app/src/main/java/org/tasks/caldav/CaldavConverter.java index 9c0f35705..da498c2e1 100644 --- a/app/src/main/java/org/tasks/caldav/CaldavConverter.java +++ b/app/src/main/java/org/tasks/caldav/CaldavConverter.java @@ -97,7 +97,9 @@ public class CaldavConverter { try { if (!Strings.isNullOrEmpty(caldavTask.getVtodo())) { remote = - at.bitfire.ical4android.Task.Companion.fromReader(new StringReader(caldavTask.getVtodo())).get(0); + at.bitfire.ical4android.Task.Companion.fromReader( + new StringReader(caldavTask.getVtodo())) + .get(0); } } catch (Exception e) { Timber.e(e); diff --git a/app/src/main/java/org/tasks/caldav/CaldavListFragment.java b/app/src/main/java/org/tasks/caldav/CaldavListFragment.java index 4d739e3f2..866dc2e79 100644 --- a/app/src/main/java/org/tasks/caldav/CaldavListFragment.java +++ b/app/src/main/java/org/tasks/caldav/CaldavListFragment.java @@ -20,7 +20,8 @@ public class CaldavListFragment extends TaskListFragment { private static final int REQUEST_ACCOUNT_SETTINGS = 10101; private CaldavCalendar calendar; - public static TaskListFragment newCaldavListFragment(CaldavFilter filter, CaldavCalendar calendar) { + public static TaskListFragment newCaldavListFragment( + CaldavFilter filter, CaldavCalendar calendar) { CaldavListFragment fragment = new CaldavListFragment(); fragment.filter = filter; fragment.calendar = calendar; diff --git a/app/src/main/java/org/tasks/caldav/CaldavSynchronizer.java b/app/src/main/java/org/tasks/caldav/CaldavSynchronizer.java index ab4daa7f7..9ce54c264 100644 --- a/app/src/main/java/org/tasks/caldav/CaldavSynchronizer.java +++ b/app/src/main/java/org/tasks/caldav/CaldavSynchronizer.java @@ -209,8 +209,7 @@ public class CaldavSynchronizer { } } } else { - ArrayList urls = - newArrayList(Iterables.transform(items, DavResponse::getUrl)); + ArrayList urls = newArrayList(Iterables.transform(items, DavResponse::getUrl)); DavResponse response = davCalendar.multiget(urls); Timber.d("MULTI %s", urls); diff --git a/app/src/main/java/org/tasks/data/CaldavCalendar.java b/app/src/main/java/org/tasks/data/CaldavCalendar.java index 2d741c577..e4873703b 100644 --- a/app/src/main/java/org/tasks/data/CaldavCalendar.java +++ b/app/src/main/java/org/tasks/data/CaldavCalendar.java @@ -140,15 +140,27 @@ public final class CaldavCalendar implements Parcelable { @Override public String toString() { - return "CaldavCalendar{" + - "id=" + id + - ", account='" + account + '\'' + - ", uuid='" + uuid + '\'' + - ", name='" + name + '\'' + - ", color=" + color + - ", ctag='" + ctag + '\'' + - ", url='" + url + '\'' + - '}'; + return "CaldavCalendar{" + + "id=" + + id + + ", account='" + + account + + '\'' + + ", uuid='" + + uuid + + '\'' + + ", name='" + + name + + '\'' + + ", color=" + + color + + ", ctag='" + + ctag + + '\'' + + ", url='" + + url + + '\'' + + '}'; } @Override diff --git a/app/src/main/java/org/tasks/data/GoogleTaskAccount.java b/app/src/main/java/org/tasks/data/GoogleTaskAccount.java index 447979afd..15d9ca16c 100644 --- a/app/src/main/java/org/tasks/data/GoogleTaskAccount.java +++ b/app/src/main/java/org/tasks/data/GoogleTaskAccount.java @@ -9,6 +9,19 @@ import android.os.Parcelable; @Entity(tableName = "google_task_accounts") public class GoogleTaskAccount implements Parcelable { + public static final Creator CREATOR = + new Creator() { + @Override + public GoogleTaskAccount createFromParcel(Parcel source) { + return new GoogleTaskAccount(source); + } + + @Override + public GoogleTaskAccount[] newArray(int size) { + return new GoogleTaskAccount[size]; + } + }; + @PrimaryKey(autoGenerate = true) @ColumnInfo(name = "_id") private transient long id; @@ -99,19 +112,6 @@ public class GoogleTaskAccount implements Parcelable { + '}'; } - public static final Creator CREATOR = - new Creator() { - @Override - public GoogleTaskAccount createFromParcel(Parcel source) { - return new GoogleTaskAccount(source); - } - - @Override - public GoogleTaskAccount[] newArray(int size) { - return new GoogleTaskAccount[size]; - } - }; - @Override public int describeContents() { return 0; diff --git a/app/src/main/java/org/tasks/data/GoogleTaskListDao.java b/app/src/main/java/org/tasks/data/GoogleTaskListDao.java index 6436b9756..cb21be191 100644 --- a/app/src/main/java/org/tasks/data/GoogleTaskListDao.java +++ b/app/src/main/java/org/tasks/data/GoogleTaskListDao.java @@ -1,11 +1,9 @@ package org.tasks.data; import android.arch.persistence.room.Dao; -import android.arch.persistence.room.Delete; import android.arch.persistence.room.Insert; import android.arch.persistence.room.OnConflictStrategy; import android.arch.persistence.room.Query; -import android.arch.persistence.room.Transaction; import android.arch.persistence.room.Update; import java.util.List; @@ -27,7 +25,8 @@ public abstract class GoogleTaskListDao { @Query("SELECT * FROM google_task_lists WHERE remote_id = :remoteId LIMIT 1") public abstract GoogleTaskList getByRemoteId(String remoteId); - @Query("SELECT * FROM google_task_lists WHERE remote_id = :remoteId AND IFNULL(account, '') = '' LIMIT 1") + @Query( + "SELECT * FROM google_task_lists WHERE remote_id = :remoteId AND IFNULL(account, '') = '' LIMIT 1") public abstract GoogleTaskList findExistingList(String remoteId); @Query("SELECT * FROM google_task_lists") diff --git a/app/src/main/java/org/tasks/data/LimitOffsetDataSource.java b/app/src/main/java/org/tasks/data/LimitOffsetDataSource.java index 87d3839e7..df936d61b 100644 --- a/app/src/main/java/org/tasks/data/LimitOffsetDataSource.java +++ b/app/src/main/java/org/tasks/data/LimitOffsetDataSource.java @@ -29,7 +29,7 @@ public class LimitOffsetDataSource extends PositionalDataSource { private int countItems() { Cursor cursor; try { - cursor = mDb.query(mCountQuery, null); + cursor = mDb.query(mCountQuery, null); } catch (Exception e) { Timber.e(e); Tracker.report(e); diff --git a/app/src/main/java/org/tasks/db/Migrations.java b/app/src/main/java/org/tasks/db/Migrations.java index e5c300b63..3a09468aa 100644 --- a/app/src/main/java/org/tasks/db/Migrations.java +++ b/app/src/main/java/org/tasks/db/Migrations.java @@ -198,10 +198,8 @@ public class Migrations { public void migrate(@NonNull SupportSQLiteDatabase database) { database.execSQL( "CREATE TABLE IF NOT EXISTS `google_task_accounts` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `account` TEXT, `error` TEXT)"); - database.execSQL( - "ALTER TABLE `google_task_lists` ADD COLUMN `account` TEXT"); - database.execSQL( - "ALTER TABLE `caldav_account` ADD COLUMN `error` TEXT"); + database.execSQL("ALTER TABLE `google_task_lists` ADD COLUMN `account` TEXT"); + database.execSQL("ALTER TABLE `caldav_account` ADD COLUMN `error` TEXT"); } }; diff --git a/app/src/main/java/org/tasks/filters/FilterProvider.java b/app/src/main/java/org/tasks/filters/FilterProvider.java index fdff90f63..0bef4bd41 100644 --- a/app/src/main/java/org/tasks/filters/FilterProvider.java +++ b/app/src/main/java/org/tasks/filters/FilterProvider.java @@ -1,7 +1,6 @@ package org.tasks.filters; import android.support.v4.util.Pair; -import com.todoroo.astrid.api.CaldavFilter; import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.core.BuiltInFilterExposer; import com.todoroo.astrid.core.CustomFilterExposer; @@ -10,7 +9,6 @@ import com.todoroo.astrid.tags.TagFilterExposer; import com.todoroo.astrid.timers.TimerFilterExposer; import java.util.ArrayList; import java.util.List; -import java.util.Map; import javax.inject.Inject; import org.tasks.caldav.CaldavFilterExposer; import org.tasks.data.CaldavAccount; diff --git a/app/src/main/java/org/tasks/gtasks/GoogleAccountManager.java b/app/src/main/java/org/tasks/gtasks/GoogleAccountManager.java index 00f234824..4d2397ab1 100644 --- a/app/src/main/java/org/tasks/gtasks/GoogleAccountManager.java +++ b/app/src/main/java/org/tasks/gtasks/GoogleAccountManager.java @@ -20,8 +20,7 @@ public class GoogleAccountManager { @Inject public GoogleAccountManager( - @ForApplication Context context, - PermissionChecker permissionChecker) { + @ForApplication Context context, PermissionChecker permissionChecker) { this.permissionChecker = permissionChecker; accountManager = android.accounts.AccountManager.get(context); diff --git a/app/src/main/java/org/tasks/gtasks/GoogleTaskSynchronizer.java b/app/src/main/java/org/tasks/gtasks/GoogleTaskSynchronizer.java index bf7eba651..1017c52dd 100644 --- a/app/src/main/java/org/tasks/gtasks/GoogleTaskSynchronizer.java +++ b/app/src/main/java/org/tasks/gtasks/GoogleTaskSynchronizer.java @@ -129,7 +129,7 @@ public class GoogleTaskSynchronizer { public void sync() { List accounts = googleTaskListDao.getAccounts(); - for (int i = 0 ; i < accounts.size() ; i++) { + for (int i = 0; i < accounts.size(); i++) { GoogleTaskAccount account = accounts.get(i); Timber.d("%s: start sync", account); try { @@ -174,7 +174,8 @@ public class GoogleTaskSynchronizer { } private void synchronize(GoogleTaskAccount account) throws IOException { - if (!permissionChecker.canAccessAccounts() || googleAccountManager.getAccount(account.getAccount()) == null) { + if (!permissionChecker.canAccessAccounts() + || googleAccountManager.getAccount(account.getAccount()) == null) { account.setError(context.getString(R.string.cannot_access_account)); googleTaskListDao.update(account); localBroadcastManager.broadcastRefreshList(); @@ -212,7 +213,8 @@ public class GoogleTaskSynchronizer { account.setError(""); } - private void pushLocalChanges(GoogleTaskAccount account, GtasksInvoker gtasksInvoker) throws UserRecoverableAuthIOException { + private void pushLocalChanges(GoogleTaskAccount account, GtasksInvoker gtasksInvoker) + throws UserRecoverableAuthIOException { List tasks = taskDao.getGoogleTasksToPush(account.getAccount()); for (Task task : tasks) { try { @@ -322,8 +324,8 @@ public class GoogleTaskSynchronizer { taskDao.save(task); } - private synchronized void fetchAndApplyRemoteChanges(GtasksInvoker gtasksInvoker, GoogleTaskList list) - throws UserRecoverableAuthIOException { + private synchronized void fetchAndApplyRemoteChanges( + GtasksInvoker gtasksInvoker, GoogleTaskList list) throws UserRecoverableAuthIOException { String listId = list.getRemoteId(); long lastSyncDate = list.getLastSync(); diff --git a/app/src/main/java/org/tasks/injection/InjectingPreferenceActivity.java b/app/src/main/java/org/tasks/injection/InjectingPreferenceActivity.java index 6e336395f..91d5e4718 100644 --- a/app/src/main/java/org/tasks/injection/InjectingPreferenceActivity.java +++ b/app/src/main/java/org/tasks/injection/InjectingPreferenceActivity.java @@ -127,8 +127,7 @@ public abstract class InjectingPreferenceActivity extends AppCompatPreferenceAct .setPositiveButton( R.string.restart_now, (dialogInterface, i) -> { - Intent nextIntent = - new Intent(InjectingPreferenceActivity.this, MainActivity.class); + Intent nextIntent = new Intent(InjectingPreferenceActivity.this, MainActivity.class); nextIntent.putExtra(MainActivity.OPEN_FILTER, (Filter) null); ProcessPhoenix.triggerRebirth(InjectingPreferenceActivity.this, nextIntent); }) diff --git a/app/src/main/java/org/tasks/injection/JobComponent.java b/app/src/main/java/org/tasks/injection/JobComponent.java index b425cf538..6858eaf84 100644 --- a/app/src/main/java/org/tasks/injection/JobComponent.java +++ b/app/src/main/java/org/tasks/injection/JobComponent.java @@ -1,18 +1,11 @@ package org.tasks.injection; import dagger.Subcomponent; -import org.tasks.jobs.AfterSaveIntentService; import org.tasks.jobs.BackupJob; import org.tasks.jobs.CleanupJob; import org.tasks.jobs.NotificationJob; import org.tasks.jobs.RefreshJob; import org.tasks.jobs.SyncJob; -import org.tasks.locale.receiver.TaskerIntentService; -import org.tasks.location.GeofenceTransitionsIntentService; -import org.tasks.scheduling.BackgroundScheduler; -import org.tasks.scheduling.CalendarNotificationIntentService; -import org.tasks.scheduling.GeofenceSchedulingIntentService; -import org.tasks.scheduling.NotificationSchedulerIntentService; @Subcomponent(modules = JobModule.class) public interface JobComponent { diff --git a/app/src/main/java/org/tasks/jobs/BackupJob.java b/app/src/main/java/org/tasks/jobs/BackupJob.java index 27e2395d6..83b649a82 100644 --- a/app/src/main/java/org/tasks/jobs/BackupJob.java +++ b/app/src/main/java/org/tasks/jobs/BackupJob.java @@ -32,6 +32,14 @@ public class BackupJob extends InjectingJob { @Inject TasksJsonExporter tasksJsonExporter; @Inject Preferences preferences; + public BackupJob() {} + + BackupJob(Context context, TasksJsonExporter tasksJsonExporter, Preferences preferences) { + this.context = context; + this.tasksJsonExporter = tasksJsonExporter; + this.preferences = preferences; + } + static List getDeleteList(File[] fileArray, int keepNewest) { if (fileArray == null) { return emptyList(); @@ -42,16 +50,6 @@ public class BackupJob extends InjectingJob { return newArrayList(skip(files, keepNewest)); } - public BackupJob() { - - } - - BackupJob(Context context, TasksJsonExporter tasksJsonExporter, Preferences preferences) { - this.context = context; - this.tasksJsonExporter = tasksJsonExporter; - this.preferences = preferences; - } - @NonNull @Override protected Result onRunJob(@NonNull Params params) { diff --git a/app/src/main/java/org/tasks/jobs/CleanupJob.java b/app/src/main/java/org/tasks/jobs/CleanupJob.java index 5d6822fe5..2b5e77a59 100644 --- a/app/src/main/java/org/tasks/jobs/CleanupJob.java +++ b/app/src/main/java/org/tasks/jobs/CleanupJob.java @@ -29,7 +29,7 @@ public class CleanupJob extends InjectingJob { PersistableBundleCompat extras = params.getExtras(); long[] tasks = extras.getLongArray(EXTRA_TASK_IDS); - if (tasks == null) { + if (tasks == null) { Timber.e("No task ids provided"); return Result.FAILURE; } diff --git a/app/src/main/java/org/tasks/notifications/Notification.java b/app/src/main/java/org/tasks/notifications/Notification.java index 21b22cdab..a39584f64 100644 --- a/app/src/main/java/org/tasks/notifications/Notification.java +++ b/app/src/main/java/org/tasks/notifications/Notification.java @@ -6,9 +6,8 @@ import android.arch.persistence.room.Index; import android.arch.persistence.room.PrimaryKey; @Entity( - tableName = "notification", - indices = {@Index(value = "task", unique = true)} -) + tableName = "notification", + indices = {@Index(value = "task", unique = true)}) public class Notification { @PrimaryKey(autoGenerate = true) diff --git a/app/src/main/java/org/tasks/preferences/Preferences.java b/app/src/main/java/org/tasks/preferences/Preferences.java index 1ee14b0fc..ab8cdb3f6 100644 --- a/app/src/main/java/org/tasks/preferences/Preferences.java +++ b/app/src/main/java/org/tasks/preferences/Preferences.java @@ -447,11 +447,11 @@ public class Preferences { return getBoolean(R.string.p_rmd_persistent, true); } - public void setSyncOngoing(boolean value) { - setBoolean(R.string.p_sync_ongoing, value); - } - public boolean isSyncOngoing() { return getBoolean(R.string.p_sync_ongoing, false); } + + public void setSyncOngoing(boolean value) { + setBoolean(R.string.p_sync_ongoing, value); + } } diff --git a/app/src/main/java/org/tasks/sync/SynchronizationPreferences.java b/app/src/main/java/org/tasks/sync/SynchronizationPreferences.java index 80a042da5..11886f7f3 100644 --- a/app/src/main/java/org/tasks/sync/SynchronizationPreferences.java +++ b/app/src/main/java/org/tasks/sync/SynchronizationPreferences.java @@ -159,17 +159,19 @@ public class SynchronizationPreferences extends InjectingPreferenceActivity { addGoogleTaskAccount.setKey(KEY_ADD_GOOGLE_TASKS); addGoogleTaskAccount.setTitle(R.string.add_account); if (inventory.hasPro() || googleTaskListDao.getAccounts().isEmpty()) { - addGoogleTaskAccount.setOnPreferenceClickListener(preference -> { - addGoogleTaskAccount(); - return false; - }); + addGoogleTaskAccount.setOnPreferenceClickListener( + preference -> { + addGoogleTaskAccount(); + return false; + }); } else { addGoogleTaskAccount.setSummary(R.string.requires_pro_subscription); - addGoogleTaskAccount.setOnPreferenceClickListener(preference -> { - startActivityForResult( - new Intent(this, PurchaseActivity.class), REQUEST_GOOGLE_TASKS_SUBSCRIBE); - return false; - }); + addGoogleTaskAccount.setOnPreferenceClickListener( + preference -> { + startActivityForResult( + new Intent(this, PurchaseActivity.class), REQUEST_GOOGLE_TASKS_SUBSCRIBE); + return false; + }); } googleTaskPreferences.addPreference(addGoogleTaskAccount); } diff --git a/app/src/main/java/org/tasks/tasklist/ActionModeProvider.java b/app/src/main/java/org/tasks/tasklist/ActionModeProvider.java index 7f8d0fd6b..e8d142afb 100644 --- a/app/src/main/java/org/tasks/tasklist/ActionModeProvider.java +++ b/app/src/main/java/org/tasks/tasklist/ActionModeProvider.java @@ -46,8 +46,7 @@ public class ActionModeProvider { TaskDuplicator taskDuplicator, TaskMover taskMover, Tracker tracker, - SyncAdapters syncAdapters - ) { + SyncAdapters syncAdapters) { this.context = context; this.dialogBuilder = dialogBuilder; this.taskDeleter = taskDeleter; @@ -87,7 +86,8 @@ public class ActionModeProvider { Filter singleFilter = taskMover.getSingleFilter(adapter.getSelected()); (singleFilter == null ? newRemoteListSupportPicker(taskList, REQUEST_MOVE_TASKS) - : newRemoteListSupportPicker(singleFilter, taskList, REQUEST_MOVE_TASKS)) + : newRemoteListSupportPicker( + singleFilter, taskList, REQUEST_MOVE_TASKS)) .show(taskList.getFragmentManager(), FRAG_TAG_REMOTE_LIST_PICKER); return true; case R.id.delete: diff --git a/app/src/main/java/org/tasks/tasklist/TagFormatter.java b/app/src/main/java/org/tasks/tasklist/TagFormatter.java index 954d99100..06af6e1f9 100644 --- a/app/src/main/java/org/tasks/tasklist/TagFormatter.java +++ b/app/src/main/java/org/tasks/tasklist/TagFormatter.java @@ -21,7 +21,6 @@ import java.util.List; import java.util.Map; import javax.inject.Inject; import org.tasks.R; -import org.tasks.data.CaldavAccount; import org.tasks.data.CaldavCalendar; import org.tasks.data.CaldavDao; import org.tasks.data.GoogleTaskList; @@ -95,27 +94,6 @@ public class TagFormatter { } } - private class ColoredString { - - final String name; - final int color; - - ColoredString(TagData tagData) { - name = tagData.getName(); - color = tagData.getColor(); - } - - ColoredString(GoogleTaskList googleTaskList) { - name = googleTaskList.getTitle(); - color = googleTaskList.getColor(); - } - - ColoredString(CaldavCalendar caldavCalendar) { - name = caldavCalendar.getName(); - color = caldavCalendar.getColor(); - } - } - CharSequence getTagString(String caldav, String googleTask, List tagUuids) { List strings = new ArrayList<>(); if (!Strings.isNullOrEmpty(googleTask)) { @@ -217,4 +195,25 @@ public class TagFormatter { } return tagData; } + + private class ColoredString { + + final String name; + final int color; + + ColoredString(TagData tagData) { + name = tagData.getName(); + color = tagData.getColor(); + } + + ColoredString(GoogleTaskList googleTaskList) { + name = googleTaskList.getTitle(); + color = googleTaskList.getColor(); + } + + ColoredString(CaldavCalendar caldavCalendar) { + name = caldavCalendar.getName(); + color = caldavCalendar.getColor(); + } + } } diff --git a/app/src/main/java/org/tasks/tasklist/ViewHolder.java b/app/src/main/java/org/tasks/tasklist/ViewHolder.java index 7c1cf151e..8e6eca552 100644 --- a/app/src/main/java/org/tasks/tasklist/ViewHolder.java +++ b/app/src/main/java/org/tasks/tasklist/ViewHolder.java @@ -282,7 +282,8 @@ class ViewHolder extends RecyclerView.ViewHolder { } else { String tags = task.getTagsString(); List tagUuids = tags != null ? newArrayList(tags.split(",")) : Lists.newArrayList(); - CharSequence tagString = tagFormatter.getTagString(task.getCaldav(), task.getGoogleTaskList(), tagUuids); + CharSequence tagString = + tagFormatter.getTagString(task.getCaldav(), task.getGoogleTaskList(), tagUuids); if (TextUtils.isEmpty(tagString)) { tagBlock.setVisibility(View.GONE); } else { diff --git a/app/src/main/java/org/tasks/themes/ThemeColor.java b/app/src/main/java/org/tasks/themes/ThemeColor.java index 83c45cc23..2baa491f3 100644 --- a/app/src/main/java/org/tasks/themes/ThemeColor.java +++ b/app/src/main/java/org/tasks/themes/ThemeColor.java @@ -23,26 +23,26 @@ public class ThemeColor implements ColorPickerDialog.Pickable { public static final int[] ICONS = new int[] { - R.mipmap.ic_launcher_blue_grey, - R.mipmap.ic_launcher_dark_grey, - R.mipmap.ic_launcher_red, - R.mipmap.ic_launcher_pink, - R.mipmap.ic_launcher_purple, - R.mipmap.ic_launcher_deep_purple, - R.mipmap.ic_launcher_indigo, - R.mipmap.ic_launcher_blue, - R.mipmap.ic_launcher_light_blue, - R.mipmap.ic_launcher_cyan, - R.mipmap.ic_launcher_teal, - R.mipmap.ic_launcher_green, - R.mipmap.ic_launcher_light_green, - R.mipmap.ic_launcher_lime, - R.mipmap.ic_launcher_yellow, - R.mipmap.ic_launcher_amber, - R.mipmap.ic_launcher_orange, - R.mipmap.ic_launcher_deep_orange, - R.mipmap.ic_launcher_brown, - R.mipmap.ic_launcher_grey + R.mipmap.ic_launcher_blue_grey, + R.mipmap.ic_launcher_dark_grey, + R.mipmap.ic_launcher_red, + R.mipmap.ic_launcher_pink, + R.mipmap.ic_launcher_purple, + R.mipmap.ic_launcher_deep_purple, + R.mipmap.ic_launcher_indigo, + R.mipmap.ic_launcher_blue, + R.mipmap.ic_launcher_light_blue, + R.mipmap.ic_launcher_cyan, + R.mipmap.ic_launcher_teal, + R.mipmap.ic_launcher_green, + R.mipmap.ic_launcher_light_green, + R.mipmap.ic_launcher_lime, + R.mipmap.ic_launcher_yellow, + R.mipmap.ic_launcher_amber, + R.mipmap.ic_launcher_orange, + R.mipmap.ic_launcher_deep_orange, + R.mipmap.ic_launcher_brown, + R.mipmap.ic_launcher_grey }; public static final String[] LAUNCHERS =