google-java-format 1.6.1

pull/513/head
Alex Baker 6 years ago
parent 043b6f9f9e
commit 9b53257d5f

@ -99,7 +99,7 @@ task checkstyle(type: Checkstyle) {
checkstyle { checkstyle {
configFile project.file('google_checks.xml') configFile project.file('google_checks.xml')
toolVersion = '8.8' toolVersion = '8.10.1'
} }
configurations { configurations {

@ -205,24 +205,21 @@
<property name="allowSamelineMultipleAnnotations" value="true"/> <property name="allowSamelineMultipleAnnotations" value="true"/>
</module> </module>
<module name="NonEmptyAtclauseDescription"/> <module name="NonEmptyAtclauseDescription"/>
<module name="JavadocTagContinuationIndentation"/> <module name="JavadocTagContinuationIndentation">
<property name="severity" value="ignore" />
</module>
<module name="SummaryJavadoc"> <module name="SummaryJavadoc">
<property name="forbiddenSummaryFragments" value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/> <property name="severity" value="ignore" />
</module>
<module name="JavadocParagraph">
<property name="severity" value="ignore" />
</module> </module>
<module name="JavadocParagraph"/>
<module name="AtclauseOrder"> <module name="AtclauseOrder">
<property name="tagOrder" value="@param, @return, @throws, @deprecated"/> <property name="tagOrder" value="@param, @return, @throws, @deprecated"/>
<property name="target" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/> <property name="target" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
</module> </module>
<module name="JavadocMethod"> <module name="JavadocMethod">
<property name="scope" value="public"/> <property name="severity" value="ignore"/>
<property name="allowMissingParamTags" value="true"/>
<property name="allowMissingThrowsTags" value="true"/>
<property name="allowMissingReturnTag" value="true"/>
<property name="allowMissingJavadoc" value="true"/> <!-- not from style guide -->
<property name="minLineCount" value="2"/>
<property name="allowedAnnotations" value="Override, Test"/>
<property name="allowThrowsTagsForSubclasses" value="true"/>
</module> </module>
<module name="MethodName"> <module name="MethodName">
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/> <property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
@ -230,7 +227,7 @@
value="Method name ''{0}'' must match pattern ''{1}''."/> value="Method name ''{0}'' must match pattern ''{1}''."/>
</module> </module>
<module name="SingleLineJavadoc"> <module name="SingleLineJavadoc">
<property name="ignoreInlineTags" value="false"/> <property name="severity" value="ignore" />
</module> </module>
<module name="EmptyCatchBlock"> <module name="EmptyCatchBlock">
<property name="exceptionVariableName" value="expected"/> <property name="exceptionVariableName" value="expected"/>

@ -23,7 +23,7 @@ public class TestUtilities {
} }
} }
public static Task vtodo(String path) { public static Task vtodo(String path) {
Task task = new Task(); Task task = new Task();
CaldavConverter.apply(task, fromResource(path)); CaldavConverter.apply(task, fromResource(path));

@ -60,7 +60,8 @@ public class ThunderbirdTests {
@Test @Test
public void repeatDaily() { 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 @Test

@ -17,7 +17,6 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import javax.inject.Inject; import javax.inject.Inject;
import org.junit.After; import org.junit.After;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.tasks.R; import org.tasks.R;

@ -204,5 +204,4 @@ public class GtasksIndentActionTest extends InjectingTestCase {
taskDao.createNew(task); taskDao.createNew(task);
return task; return task;
} }
} }

@ -8,6 +8,10 @@ public class Tracker {
@Inject @Inject
public Tracker() {} public Tracker() {}
public static void report(Exception e) {
Timber.e(e);
}
public void reportException(Throwable t) { public void reportException(Throwable t) {
Timber.e(t); Timber.e(t);
} }
@ -21,8 +25,4 @@ public class Tracker {
public void reportEvent(Tracking.Events category, String action, String label) {} public void reportEvent(Tracking.Events category, String action, String label) {}
public void reportIabResult(int resultCode, String skus) {} public void reportIabResult(int resultCode, String skus) {}
public static void report(Exception e) {
Timber.e(e);
}
} }

@ -10,8 +10,7 @@ public class FlavorSetup {
private final BillingClient billingClient; private final BillingClient billingClient;
@Inject @Inject
public FlavorSetup(PlayServices playServices, public FlavorSetup(PlayServices playServices, BillingClient billingClient) {
BillingClient billingClient) {
this.playServices = playServices; this.playServices = playServices;
this.billingClient = billingClient; this.billingClient = billingClient;
} }

@ -84,14 +84,14 @@ public abstract class Property<TYPE> extends Field implements Cloneable {
super(table, name); super(table, name);
} }
IntegerProperty(String name, String expression) {
super(null, name, expression);
}
@Override @Override
public IntegerProperty as(String newAlias) { public IntegerProperty as(String newAlias) {
return (IntegerProperty) super.as(newAlias); return (IntegerProperty) super.as(newAlias);
} }
IntegerProperty(String name, String expression) {
super(null, name, expression);
}
} }
/** /**

@ -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 GTASK_METADATA_JOIN = "for_gtask"; // $NON-NLS-1$
public static final String CALDAV_METADATA_JOIN = "for_caldav"; // $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 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 int VOICE_RECOGNITION_REQUEST_CODE = 1234;
private static final String EXTRA_FILTER = "extra_filter"; private static final String EXTRA_FILTER = "extra_filter";
private static final String FRAG_TAG_SORT_DIALOG = "frag_tag_sort_dialog"; private static final String FRAG_TAG_SORT_DIALOG = "frag_tag_sort_dialog";
// --- instance variables // --- instance variables
private static final int REQUEST_EDIT_FILTER = 11544; private static final int REQUEST_EDIT_FILTER = 11544;
public static final int REQUEST_MOVE_TASKS = 11545;
private final RefreshReceiver refreshReceiver = new RefreshReceiver(); private final RefreshReceiver refreshReceiver = new RefreshReceiver();
@Inject protected Tracker tracker; @Inject protected Tracker tracker;
protected Filter filter; protected Filter filter;
@ -446,11 +445,7 @@ public class TaskListFragment extends InjectingFragment
// set up list adapters // set up list adapters
taskAdapter = createTaskAdapter(); taskAdapter = createTaskAdapter();
recyclerAdapter = recyclerAdapter =
new TaskListRecyclerAdapter( new TaskListRecyclerAdapter(taskAdapter, viewHolderFactory, this, actionModeProvider);
taskAdapter,
viewHolderFactory,
this,
actionModeProvider);
taskAdapter.setHelper(recyclerAdapter.getAsyncPagedListDiffer()); taskAdapter.setHelper(recyclerAdapter.getAsyncPagedListDiffer());
} }

@ -11,7 +11,6 @@ import android.database.Cursor;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import java.io.IOException; import java.io.IOException;
import org.tasks.analytics.Tracker; import org.tasks.analytics.Tracker;
import org.tasks.analytics.Tracking;
import org.tasks.data.Alarm; import org.tasks.data.Alarm;
import org.tasks.data.AlarmDao; import org.tasks.data.AlarmDao;
import org.tasks.data.CaldavAccount; import org.tasks.data.CaldavAccount;
@ -43,26 +42,25 @@ import org.tasks.notifications.NotificationDao;
import timber.log.Timber; import timber.log.Timber;
@android.arch.persistence.room.Database( @android.arch.persistence.room.Database(
entities = { entities = {
Notification.class, Notification.class,
TagData.class, TagData.class,
UserActivity.class, UserActivity.class,
TaskAttachment.class, TaskAttachment.class,
TaskListMetadata.class, TaskListMetadata.class,
Task.class, Task.class,
Alarm.class, Alarm.class,
Location.class, Location.class,
Tag.class, Tag.class,
GoogleTask.class, GoogleTask.class,
Filter.class, Filter.class,
GoogleTaskList.class, GoogleTaskList.class,
CaldavCalendar.class, CaldavCalendar.class,
CaldavTask.class, CaldavTask.class,
CaldavAccount.class, CaldavAccount.class,
GoogleTaskAccount.class GoogleTaskAccount.class
}, },
version = 59 version = 59)
)
public abstract class Database extends RoomDatabase { public abstract class Database extends RoomDatabase {
public static final String NAME = "database"; public static final String NAME = "database";

@ -57,7 +57,8 @@ public abstract class TaskDao {
@android.arch.persistence.room.Query("SELECT * FROM tasks WHERE _id IN (:taskIds)") @android.arch.persistence.room.Query("SELECT * FROM tasks WHERE _id IN (:taskIds)")
public abstract List<Task> fetch(List<Long> taskIds); public abstract List<Task> fetch(List<Long> 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(); public abstract int activeTimers();
@android.arch.persistence.room.Query( @android.arch.persistence.room.Query(

@ -99,15 +99,6 @@ public class Task implements Parcelable {
/** reminder mode five times (exclusive with non-stop) */ /** reminder mode five times (exclusive with non-stop) */
public static final int NOTIFY_MODE_FIVE = 1 << 4; 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<Task> CREATOR = public static final Creator<Task> CREATOR =
new Creator<Task>() { new Creator<Task>() {
@Override @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_DAY_BEFORE = 2;
public static final int HIDE_UNTIL_WEEK_BEFORE = 3; public static final int HIDE_UNTIL_WEEK_BEFORE = 3;
public static final int HIDE_UNTIL_SPECIFIC_DAY = 4; public static final int HIDE_UNTIL_SPECIFIC_DAY = 4;
// --- for astrid.com // --- for astrid.com
public static final int HIDE_UNTIL_SPECIFIC_DAY_TIME = 5; public static final int HIDE_UNTIL_SPECIFIC_DAY_TIME = 5;
public static final int HIDE_UNTIL_DUE_TIME = 6; public static final int HIDE_UNTIL_DUE_TIME = 6;
static final int URGENCY_TODAY = 1; static final int URGENCY_TODAY = 1;
static final int URGENCY_TOMORROW = 2; static final int URGENCY_TOMORROW = 2;
// --- notification flags // --- notification flags
static final int URGENCY_DAY_AFTER = 3; static final int URGENCY_DAY_AFTER = 3;
static final int URGENCY_NEXT_WEEK = 4; static final int URGENCY_NEXT_WEEK = 4;
static final int URGENCY_IN_TWO_WEEKS = 5; static final int URGENCY_IN_TWO_WEEKS = 5;
static final int URGENCY_NEXT_MONTH = 6; static final int URGENCY_NEXT_MONTH = 6;
// --- importance settings (note: importance > 3 are supported via plugin)
/** ID */ /** ID */
@PrimaryKey(autoGenerate = true) @PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "_id") @ColumnInfo(name = "_id")
public transient Long id = NO_ID; public transient Long id = NO_ID;
// --- importance settings (note: importance > 3 are supported via plugin)
/** Name of Task */ /** Name of Task */
@ColumnInfo(name = "title") @ColumnInfo(name = "title")
public String title = ""; public String title = "";
@ -171,12 +160,11 @@ public class Task implements Parcelable {
/** Unixtime Task was completed. 0 means active */ /** Unixtime Task was completed. 0 means active */
@ColumnInfo(name = "completed") @ColumnInfo(name = "completed")
public Long completed = 0L; public Long completed = 0L;
// --- data access boilerplate
/** Unixtime Task was deleted. 0 means not deleted */ /** Unixtime Task was deleted. 0 means not deleted */
@ColumnInfo(name = "deleted") @ColumnInfo(name = "deleted")
public Long deleted = 0L; public Long deleted = 0L;
// --- data access boilerplate
@ColumnInfo(name = "notes") @ColumnInfo(name = "notes")
public String notes = ""; public String notes = "";
@ -191,16 +179,16 @@ public class Task implements Parcelable {
/** Flags for when to send reminders */ /** Flags for when to send reminders */
@ColumnInfo(name = "notificationFlags") @ColumnInfo(name = "notificationFlags")
public Integer notificationFlags = 0; public Integer notificationFlags = 0;
// --- parcelable helpers
/** Reminder period, in milliseconds. 0 means disabled */ /** Reminder period, in milliseconds. 0 means disabled */
@ColumnInfo(name = "notifications") @ColumnInfo(name = "notifications")
public Long notifications = 0L; public Long notifications = 0L;
// --- data access methods // --- parcelable helpers
/** Unixtime the last reminder was triggered */ /** Unixtime the last reminder was triggered */
@ColumnInfo(name = "lastNotified") @ColumnInfo(name = "lastNotified")
public Long lastNotified = 0L; public Long lastNotified = 0L;
// --- data access methods
/** Unixtime snooze is set (0 -> no snooze) */ /** Unixtime snooze is set (0 -> no snooze) */
@ColumnInfo(name = "snoozeTime") @ColumnInfo(name = "snoozeTime")
public Long snoozeTime = 0L; public Long snoozeTime = 0L;
@ -213,12 +201,11 @@ public class Task implements Parcelable {
@ColumnInfo(name = "calendarUri") @ColumnInfo(name = "calendarUri")
public String calendarUri = ""; public String calendarUri = "";
// --- due and hide until date management
/** Remote id */ /** Remote id */
@ColumnInfo(name = "remoteId") @ColumnInfo(name = "remoteId")
public String remoteId = NO_UUID; public String remoteId = NO_UUID;
// --- due and hide until date management
@Ignore private transient int indent; @Ignore private transient int indent;
@Ignore private transient String tags; @Ignore private transient String tags;
@Ignore private transient String googleTaskList; @Ignore private transient String googleTaskList;
@ -1215,4 +1202,13 @@ public class Task implements Parcelable {
public boolean hasFiles() { public boolean hasFiles() {
return 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;
}
} }

@ -30,7 +30,10 @@ public class GtasksFilterExposer {
private final GoogleTaskListDao googleTaskListDao; private final GoogleTaskListDao googleTaskListDao;
@Inject @Inject
public GtasksFilterExposer(GtasksListService gtasksListService, SyncAdapters syncAdapters, GoogleTaskListDao googleTaskListDao) { public GtasksFilterExposer(
GtasksListService gtasksListService,
SyncAdapters syncAdapters,
GoogleTaskListDao googleTaskListDao) {
this.gtasksListService = gtasksListService; this.gtasksListService = gtasksListService;
this.syncAdapters = syncAdapters; this.syncAdapters = syncAdapters;
this.googleTaskListDao = googleTaskListDao; this.googleTaskListDao = googleTaskListDao;

@ -16,7 +16,6 @@ import com.google.api.services.tasks.model.TaskLists;
import java.io.IOException; import java.io.IOException;
import java.util.Collections; import java.util.Collections;
import org.tasks.BuildConfig; import org.tasks.BuildConfig;
import org.tasks.data.GoogleTaskAccount;
import org.tasks.gtasks.GoogleTasksUnsuccessfulResponseHandler; import org.tasks.gtasks.GoogleTasksUnsuccessfulResponseHandler;
import org.tasks.gtasks.PlayServices; import org.tasks.gtasks.PlayServices;
import timber.log.Timber; import timber.log.Timber;

@ -166,8 +166,8 @@ public class GtasksSyncService {
private class MoveOp implements SyncOnSaveOperation { private class MoveOp implements SyncOnSaveOperation {
private final GoogleTaskList googleTaskList;
final GoogleTask googleTask; final GoogleTask googleTask;
private final GoogleTaskList googleTaskList;
MoveOp(GoogleTaskList googleTaskList, GoogleTask googleTask) { MoveOp(GoogleTaskList googleTaskList, GoogleTask googleTask) {
this.googleTaskList = googleTaskList; this.googleTaskList = googleTaskList;

@ -8,7 +8,6 @@ package com.todoroo.astrid.service;
import static com.google.common.base.Strings.isNullOrEmpty; import static com.google.common.base.Strings.isNullOrEmpty;
import android.content.Context; import android.content.Context;
import android.database.sqlite.SQLiteException;
import android.os.Environment; import android.os.Environment;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ImmutableListMultimap;

@ -127,8 +127,7 @@ public class TaskCreator {
task.setUuid(UUIDHelper.newUUID()); task.setUuid(UUIDHelper.newUUID());
task.setPriority( task.setPriority(
preferences.getIntegerFromString( preferences.getIntegerFromString(R.string.p_default_importance_key, Priority.LOW));
R.string.p_default_importance_key, Priority.LOW));
task.setDueDate( task.setDueDate(
Task.createDueDate( Task.createDueDate(
preferences.getIntegerFromString(R.string.p_default_urgency_key, Task.URGENCY_NONE), preferences.getIntegerFromString(R.string.p_default_urgency_key, Task.URGENCY_NONE),

@ -27,7 +27,11 @@ public class TaskDeleter {
private final DeletionDao deletionDao; private final DeletionDao deletionDao;
@Inject @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.deletionDao = deletionDao;
this.jobManager = jobManager; this.jobManager = jobManager;
this.taskDao = taskDao; this.taskDao = taskDao;

@ -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[1], labelsDisplay[1], Task.HIDE_UNTIL_DUE_TIME),
new HideUntilValue(labelsSpinner[2], labelsDisplay[2], Task.HIDE_UNTIL_DAY_BEFORE), 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[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) { if (specificDate > 0) {
spinnerItems.add(0, getHideUntilValue(specificDate)); spinnerItems.add(0, getHideUntilValue(specificDate));

@ -4,7 +4,6 @@ import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import com.android.billingclient.api.BillingClient.BillingResponse;
import com.todoroo.astrid.api.AstridApiConstants; import com.todoroo.astrid.api.AstridApiConstants;
import javax.inject.Inject; import javax.inject.Inject;
import org.tasks.injection.ForApplication; import org.tasks.injection.ForApplication;

@ -172,7 +172,8 @@ public class GoogleTaskListSettingsActivity extends ThemedInjectingAppCompatActi
} }
if (isNewList) { 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()) { } else if (nameChanged()) {
newRenameListDialog(gtasksList, newName) newRenameListDialog(gtasksList, newName)
.show(getSupportFragmentManager(), FRAG_TAG_RENAME_LIST_DIALOG); .show(getSupportFragmentManager(), FRAG_TAG_RENAME_LIST_DIALOG);
@ -267,8 +268,7 @@ public class GoogleTaskListSettingsActivity extends ThemedInjectingAppCompatActi
gtasksList.setColor(selectedTheme); gtasksList.setColor(selectedTheme);
gtasksList.setId(googleTaskListDao.insertOrReplace(gtasksList)); gtasksList.setId(googleTaskListDao.insertOrReplace(gtasksList));
setResult( setResult(
RESULT_OK, RESULT_OK, new Intent().putExtra(MainActivity.OPEN_FILTER, new GtasksFilter(gtasksList)));
new Intent().putExtra(MainActivity.OPEN_FILTER, new GtasksFilter(gtasksList)));
finish(); finish();
} }
@ -288,8 +288,7 @@ public class GoogleTaskListSettingsActivity extends ThemedInjectingAppCompatActi
googleTaskListDao.insertOrReplace(gtasksList); googleTaskListDao.insertOrReplace(gtasksList);
setResult( setResult(
RESULT_OK, RESULT_OK,
new Intent(ACTION_RELOAD) new Intent(ACTION_RELOAD).putExtra(MainActivity.OPEN_FILTER, new GtasksFilter(gtasksList)));
.putExtra(MainActivity.OPEN_FILTER, new GtasksFilter(gtasksList)));
finish(); finish();
} }

@ -77,7 +77,8 @@ public class RemoteListSupportPicker extends InjectingDialogFragment {
Bundle arguments = getArguments(); Bundle arguments = getArguments();
int selected = int selected =
arguments.getBoolean(EXTRA_NO_SELECTION, false) 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); return createDialog(filterAdapter, dialogBuilder, selected, this::selected);
} }

@ -189,8 +189,7 @@ public class TagSettingsActivity extends ThemedInjectingAppCompatActivity
tagData.setName(newName); tagData.setName(newName);
tagData.setColor(selectedTheme); tagData.setColor(selectedTheme);
tagDataDao.createNew(tagData); tagDataDao.createNew(tagData);
setResult( setResult(RESULT_OK, new Intent().putExtra(MainActivity.OPEN_FILTER, new TagFilter(tagData)));
RESULT_OK, new Intent().putExtra(MainActivity.OPEN_FILTER, new TagFilter(tagData)));
} else if (hasChanges()) { } else if (hasChanges()) {
tagData.setName(newName); tagData.setName(newName);
tagData.setColor(selectedTheme); tagData.setColor(selectedTheme);

@ -46,7 +46,8 @@ public class Tracking {
IMPORT_JSON(R.string.tracking_category_backup, R.string.tracking_action_import_json), IMPORT_JSON(R.string.tracking_category_backup, R.string.tracking_action_import_json),
EXPORT(R.string.tracking_category_backup, R.string.tracking_action_export), 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_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_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); CALDAV_LIST_DELETED(R.string.tracking_category_caldav, R.string.tracking_action_delete_list);

@ -47,6 +47,35 @@ public class BillingClient implements PurchasesUpdatedListener {
com.android.billingclient.api.BillingClient.newBuilder(context).setListener(this).build(); 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() { public void initialize() {
startServiceConnection(this::queryPurchases); startServiceConnection(this::queryPurchases);
} }
@ -233,33 +262,4 @@ public class BillingClient implements PurchasesUpdatedListener {
public int getBillingClientResponseCode() { public int getBillingClientResponseCode() {
return billingClientResponseCode; 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";
}
}
} }

@ -19,38 +19,35 @@ import android.view.View;
import org.tasks.billing.row.RowDataProvider; import org.tasks.billing.row.RowDataProvider;
import org.tasks.billing.row.SkuRowData; 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 { public class CardsWithHeadersDecoration extends RecyclerView.ItemDecoration {
private final RowDataProvider mRowDataProvider; private final RowDataProvider mRowDataProvider;
private final int mHeaderGap, mRowGap; private final int mHeaderGap, mRowGap;
public CardsWithHeadersDecoration(RowDataProvider rowDataProvider, int headerGap, public CardsWithHeadersDecoration(RowDataProvider rowDataProvider, int headerGap, int rowGap) {
int rowGap) { this.mRowDataProvider = rowDataProvider;
this.mRowDataProvider = rowDataProvider; this.mHeaderGap = headerGap;
this.mHeaderGap = headerGap; this.mRowGap = rowGap;
this.mRowGap = rowGap; }
}
@Override
@Override public void getItemOffsets(
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
RecyclerView.State state) {
final int position = parent.getChildAdapterPosition(view);
final int position = parent.getChildAdapterPosition(view); final SkuRowData data = mRowDataProvider.getData(position);
final SkuRowData data = mRowDataProvider.getData(position);
// We should add a space on top of every header card
// We should add a space on top of every header card if (data.getRowType() == SkusAdapter.TYPE_HEADER || position == 0) {
if (data.getRowType() == SkusAdapter.TYPE_HEADER || position == 0) { outRect.top = mHeaderGap;
outRect.top = mHeaderGap; }
}
// Adding a space under the last item
// Adding a space under the last item if (position == parent.getAdapter().getItemCount() - 1) {
if (position == parent.getAdapter().getItemCount() - 1) { outRect.bottom = mHeaderGap;
outRect.bottom = mHeaderGap; } else {
} else { outRect.bottom = mRowGap;
outRect.bottom = mRowGap; }
} }
}
} }

@ -15,12 +15,11 @@ import timber.log.Timber;
@ApplicationScope @ApplicationScope
public class Inventory { public class Inventory {
private static final String SKU_PRO = "annual_499";
static final String SKU_VIP = "vip"; static final String SKU_VIP = "vip";
static final String SKU_TASKER = "tasker"; static final String SKU_TASKER = "tasker";
static final String SKU_THEMES = "themes"; static final String SKU_THEMES = "themes";
static final String SKU_DASHCLOCK = "dashclock"; static final String SKU_DASHCLOCK = "dashclock";
private static final String SKU_PRO = "annual_499";
public static final List<String> SKU_SUBS = ImmutableList.of(SKU_PRO); public static final List<String> SKU_SUBS = ImmutableList.of(SKU_PRO);
private final Preferences preferences; private final Preferences preferences;

@ -55,8 +55,6 @@ public class PurchaseActivity extends ThemedInjectingAppCompatActivity
@Inject Inventory inventory; @Inject Inventory inventory;
@Inject LocalBroadcastManager localBroadcastManager; @Inject LocalBroadcastManager localBroadcastManager;
private SkusAdapter adapter;
@BindView(R.id.toolbar) @BindView(R.id.toolbar)
Toolbar toolbar; Toolbar toolbar;
@ -69,6 +67,15 @@ public class PurchaseActivity extends ThemedInjectingAppCompatActivity
@BindView(R.id.error_textview) @BindView(R.id.error_textview)
TextView errorTextView; TextView errorTextView;
private SkusAdapter adapter;
private BroadcastReceiver purchaseReceiver =
new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
querySkuDetails();
}
};
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(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 @Override
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {

@ -40,17 +40,17 @@ public class Security {
private static final String SIGNATURE_ALGORITHM = "SHA1withRSA"; private static final String SIGNATURE_ALGORITHM = "SHA1withRSA";
/** /**
* Verifies that the data was signed with the given signature, and returns the verified * Verifies that the data was signed with the given signature, and returns the verified purchase.
* purchase. *
* @param base64PublicKey the base64-encoded public key to use for verifying. * @param base64PublicKey the base64-encoded public key to use for verifying.
* @param signedData the signed JSON string (signed, not encrypted) * @param signedData the signed JSON string (signed, not encrypted)
* @param signature the signature for the data, signed with the private key * @param signature the signature for the data, signed with the private key
* @throws IOException if encoding algorithm is not supported or key specification * @throws IOException if encoding algorithm is not supported or key specification is invalid
* is invalid
*/ */
public static boolean verifyPurchase(String base64PublicKey, String signedData, public static boolean verifyPurchase(String base64PublicKey, String signedData, String signature)
String signature) throws IOException { throws IOException {
if (TextUtils.isEmpty(signedData) || TextUtils.isEmpty(base64PublicKey) if (TextUtils.isEmpty(signedData)
|| TextUtils.isEmpty(base64PublicKey)
|| TextUtils.isEmpty(signature)) { || TextUtils.isEmpty(signature)) {
BillingHelper.logWarn(TAG, "Purchase verification failed: missing data."); BillingHelper.logWarn(TAG, "Purchase verification failed: missing data.");
return false; return false;
@ -64,8 +64,7 @@ public class Security {
* Generates a PublicKey instance from a string containing the Base64-encoded public key. * Generates a PublicKey instance from a string containing the Base64-encoded public key.
* *
* @param encodedPublicKey Base64-encoded public key * @param encodedPublicKey Base64-encoded public key
* @throws IOException if encoding algorithm is not supported or key specification * @throws IOException if encoding algorithm is not supported or key specification is invalid
* is invalid
*/ */
public static PublicKey generatePublicKey(String encodedPublicKey) throws IOException { public static PublicKey generatePublicKey(String encodedPublicKey) throws IOException {
try { try {
@ -83,8 +82,8 @@ public class Security {
} }
/** /**
* Verifies that the signature from the server matches the computed signature on the data. * Verifies that the signature from the server matches the computed signature on the data. Returns
* Returns true if the data is correctly signed. * true if the data is correctly signed.
* *
* @param publicKey public key associated with the developer account * @param publicKey public key associated with the developer account
* @param signedData signed data from server * @param signedData signed data from server

@ -38,8 +38,8 @@ import org.tasks.billing.row.RowViewHolder;
import org.tasks.billing.row.RowViewHolder.ButtonClick; import org.tasks.billing.row.RowViewHolder.ButtonClick;
import org.tasks.billing.row.SkuRowData; import org.tasks.billing.row.SkuRowData;
public class SkusAdapter extends RecyclerView.Adapter<RowViewHolder> implements RowDataProvider, public class SkusAdapter extends RecyclerView.Adapter<RowViewHolder>
ButtonClick { implements RowDataProvider, ButtonClick {
public static final int TYPE_HEADER = 0; public static final int TYPE_HEADER = 0;
public static final int TYPE_NORMAL = 1; public static final int TYPE_NORMAL = 1;

@ -15,12 +15,7 @@
*/ */
package org.tasks.billing.row; 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 { public interface RowDataProvider {
SkuRowData getData(int position); SkuRowData getData(int position);
} }

@ -13,12 +13,6 @@ public final class RowViewHolder extends RecyclerView.ViewHolder {
public final Button subscribeButton; public final Button subscribeButton;
public final Button auxiliaryButton; public final Button auxiliaryButton;
public interface ButtonClick {
void onAuxiliaryClick(int row);
void onClick(int row);
}
public RowViewHolder(final View itemView, final ButtonClick onClick) { public RowViewHolder(final View itemView, final ButtonClick onClick) {
super(itemView); super(itemView);
title = itemView.findViewById(R.id.title); title = itemView.findViewById(R.id.title);
@ -33,4 +27,10 @@ public final class RowViewHolder extends RecyclerView.ViewHolder {
subscribeButton.setOnClickListener(view -> onClick.onClick(getAdapterPosition())); subscribeButton.setOnClickListener(view -> onClick.onClick(getAdapterPosition()));
} }
} }
public interface ButtonClick {
void onAuxiliaryClick(int row);
void onClick(int row);
}
} }

@ -20,51 +20,47 @@ import com.android.billingclient.api.SkuDetails;
import org.tasks.billing.SkusAdapter; import org.tasks.billing.SkusAdapter;
import org.tasks.billing.SkusAdapter.RowTypeDef; import org.tasks.billing.SkusAdapter.RowTypeDef;
/** /** A model for SkusAdapter's row */
* A model for SkusAdapter's row
*/
public class SkuRowData { public class SkuRowData {
private String sku, title, price, description; private String sku, title, price, description;
private @RowTypeDef int type; private @RowTypeDef int type;
private @SkuType String billingType; private @SkuType String billingType;
public SkuRowData(SkuDetails details, @RowTypeDef int rowType, public SkuRowData(SkuDetails details, @RowTypeDef int rowType, @SkuType String billingType) {
@SkuType String billingType) { this.sku = details.getSku();
this.sku = details.getSku(); this.title = details.getTitle();
this.title = details.getTitle(); this.price = details.getPrice();
this.price = details.getPrice(); this.description = details.getDescription();
this.description = details.getDescription(); this.type = rowType;
this.type = rowType; this.billingType = billingType;
this.billingType = billingType; }
}
public SkuRowData(String title) { public SkuRowData(String title) {
this.title = title; this.title = title;
this.type = SkusAdapter.TYPE_HEADER; this.type = SkusAdapter.TYPE_HEADER;
} }
public String getSku() { public String getSku() {
return sku; return sku;
} }
public String getTitle() { public String getTitle() {
return title; return title;
} }
public String getPrice() { public String getPrice() {
return price; return price;
} }
public String getDescription() { public String getDescription() {
return description; return description;
} }
public @RowTypeDef int getRowType() { public @RowTypeDef int getRowType() {
return type; return type;
} }
public @SkuType public @SkuType String getSkuType() {
String getSkuType() { return billingType;
return billingType; }
}
} }

@ -191,9 +191,7 @@ public class CaldavAccountSettingsActivity extends ThemedInjectingAppCompatActiv
private String getNewPassword() { private String getNewPassword() {
String input = password.getText().toString().trim(); String input = password.getText().toString().trim();
return PASSWORD_MASK.equals(input) return PASSWORD_MASK.equals(input) ? encryption.decrypt(caldavAccount.getPassword()) : input;
? encryption.decrypt(caldavAccount.getPassword())
: input;
} }
private void save() { private void save() {

@ -118,9 +118,7 @@ public class CaldavCalendarSettingsActivity extends ThemedInjectingAppCompatActi
final boolean backButtonSavesTask = preferences.backButtonSavesTask(); final boolean backButtonSavesTask = preferences.backButtonSavesTask();
toolbar.setTitle( toolbar.setTitle(
caldavCalendar == null caldavCalendar == null ? getString(R.string.new_list) : caldavCalendar.getName());
? getString(R.string.new_list)
: caldavCalendar.getName());
toolbar.setNavigationIcon( toolbar.setNavigationIcon(
ContextCompat.getDrawable( ContextCompat.getDrawable(
this, backButtonSavesTask ? R.drawable.ic_close_24dp : R.drawable.ic_save_24dp)); this, backButtonSavesTask ? R.drawable.ic_close_24dp : R.drawable.ic_save_24dp));
@ -359,7 +357,8 @@ public class CaldavCalendarSettingsActivity extends ThemedInjectingAppCompatActi
(dialog, which) -> { (dialog, which) -> {
CaldavClient caldavClient = CaldavClient caldavClient =
new CaldavClient(caldavAccount, caldavCalendar, encryption); new CaldavClient(caldavAccount, caldavCalendar, encryption);
ProgressDialog progressDialog = dialogBuilder.newProgressDialog(R.string.contacting_server); ProgressDialog progressDialog =
dialogBuilder.newProgressDialog(R.string.contacting_server);
progressDialog.show(); progressDialog.show();
caldavClient caldavClient
.deleteCollection() .deleteCollection()

@ -97,7 +97,9 @@ public class CaldavConverter {
try { try {
if (!Strings.isNullOrEmpty(caldavTask.getVtodo())) { if (!Strings.isNullOrEmpty(caldavTask.getVtodo())) {
remote = 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) { } catch (Exception e) {
Timber.e(e); Timber.e(e);

@ -20,7 +20,8 @@ public class CaldavListFragment extends TaskListFragment {
private static final int REQUEST_ACCOUNT_SETTINGS = 10101; private static final int REQUEST_ACCOUNT_SETTINGS = 10101;
private CaldavCalendar calendar; private CaldavCalendar calendar;
public static TaskListFragment newCaldavListFragment(CaldavFilter filter, CaldavCalendar calendar) { public static TaskListFragment newCaldavListFragment(
CaldavFilter filter, CaldavCalendar calendar) {
CaldavListFragment fragment = new CaldavListFragment(); CaldavListFragment fragment = new CaldavListFragment();
fragment.filter = filter; fragment.filter = filter;
fragment.calendar = calendar; fragment.calendar = calendar;

@ -209,8 +209,7 @@ public class CaldavSynchronizer {
} }
} }
} else { } else {
ArrayList<HttpUrl> urls = ArrayList<HttpUrl> urls = newArrayList(Iterables.transform(items, DavResponse::getUrl));
newArrayList(Iterables.transform(items, DavResponse::getUrl));
DavResponse response = davCalendar.multiget(urls); DavResponse response = davCalendar.multiget(urls);
Timber.d("MULTI %s", urls); Timber.d("MULTI %s", urls);

@ -140,15 +140,27 @@ public final class CaldavCalendar implements Parcelable {
@Override @Override
public String toString() { public String toString() {
return "CaldavCalendar{" + return "CaldavCalendar{"
"id=" + id + + "id="
", account='" + account + '\'' + + id
", uuid='" + uuid + '\'' + + ", account='"
", name='" + name + '\'' + + account
", color=" + color + + '\''
", ctag='" + ctag + '\'' + + ", uuid='"
", url='" + url + '\'' + + uuid
'}'; + '\''
+ ", name='"
+ name
+ '\''
+ ", color="
+ color
+ ", ctag='"
+ ctag
+ '\''
+ ", url='"
+ url
+ '\''
+ '}';
} }
@Override @Override

@ -9,6 +9,19 @@ import android.os.Parcelable;
@Entity(tableName = "google_task_accounts") @Entity(tableName = "google_task_accounts")
public class GoogleTaskAccount implements Parcelable { public class GoogleTaskAccount implements Parcelable {
public static final Creator<GoogleTaskAccount> CREATOR =
new Creator<GoogleTaskAccount>() {
@Override
public GoogleTaskAccount createFromParcel(Parcel source) {
return new GoogleTaskAccount(source);
}
@Override
public GoogleTaskAccount[] newArray(int size) {
return new GoogleTaskAccount[size];
}
};
@PrimaryKey(autoGenerate = true) @PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "_id") @ColumnInfo(name = "_id")
private transient long id; private transient long id;
@ -99,19 +112,6 @@ public class GoogleTaskAccount implements Parcelable {
+ '}'; + '}';
} }
public static final Creator<GoogleTaskAccount> CREATOR =
new Creator<GoogleTaskAccount>() {
@Override
public GoogleTaskAccount createFromParcel(Parcel source) {
return new GoogleTaskAccount(source);
}
@Override
public GoogleTaskAccount[] newArray(int size) {
return new GoogleTaskAccount[size];
}
};
@Override @Override
public int describeContents() { public int describeContents() {
return 0; return 0;

@ -1,11 +1,9 @@
package org.tasks.data; package org.tasks.data;
import android.arch.persistence.room.Dao; import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Delete;
import android.arch.persistence.room.Insert; import android.arch.persistence.room.Insert;
import android.arch.persistence.room.OnConflictStrategy; import android.arch.persistence.room.OnConflictStrategy;
import android.arch.persistence.room.Query; import android.arch.persistence.room.Query;
import android.arch.persistence.room.Transaction;
import android.arch.persistence.room.Update; import android.arch.persistence.room.Update;
import java.util.List; import java.util.List;
@ -27,7 +25,8 @@ public abstract class GoogleTaskListDao {
@Query("SELECT * FROM google_task_lists WHERE remote_id = :remoteId LIMIT 1") @Query("SELECT * FROM google_task_lists WHERE remote_id = :remoteId LIMIT 1")
public abstract GoogleTaskList getByRemoteId(String remoteId); 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); public abstract GoogleTaskList findExistingList(String remoteId);
@Query("SELECT * FROM google_task_lists") @Query("SELECT * FROM google_task_lists")

@ -29,7 +29,7 @@ public class LimitOffsetDataSource extends PositionalDataSource<Task> {
private int countItems() { private int countItems() {
Cursor cursor; Cursor cursor;
try { try {
cursor = mDb.query(mCountQuery, null); cursor = mDb.query(mCountQuery, null);
} catch (Exception e) { } catch (Exception e) {
Timber.e(e); Timber.e(e);
Tracker.report(e); Tracker.report(e);

@ -198,10 +198,8 @@ public class Migrations {
public void migrate(@NonNull SupportSQLiteDatabase database) { public void migrate(@NonNull SupportSQLiteDatabase database) {
database.execSQL( database.execSQL(
"CREATE TABLE IF NOT EXISTS `google_task_accounts` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `account` TEXT, `error` TEXT)"); "CREATE TABLE IF NOT EXISTS `google_task_accounts` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `account` TEXT, `error` TEXT)");
database.execSQL( database.execSQL("ALTER TABLE `google_task_lists` ADD COLUMN `account` TEXT");
"ALTER TABLE `google_task_lists` ADD COLUMN `account` TEXT"); database.execSQL("ALTER TABLE `caldav_account` ADD COLUMN `error` TEXT");
database.execSQL(
"ALTER TABLE `caldav_account` ADD COLUMN `error` TEXT");
} }
}; };

@ -1,7 +1,6 @@
package org.tasks.filters; package org.tasks.filters;
import android.support.v4.util.Pair; import android.support.v4.util.Pair;
import com.todoroo.astrid.api.CaldavFilter;
import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.core.BuiltInFilterExposer; import com.todoroo.astrid.core.BuiltInFilterExposer;
import com.todoroo.astrid.core.CustomFilterExposer; import com.todoroo.astrid.core.CustomFilterExposer;
@ -10,7 +9,6 @@ import com.todoroo.astrid.tags.TagFilterExposer;
import com.todoroo.astrid.timers.TimerFilterExposer; import com.todoroo.astrid.timers.TimerFilterExposer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.inject.Inject; import javax.inject.Inject;
import org.tasks.caldav.CaldavFilterExposer; import org.tasks.caldav.CaldavFilterExposer;
import org.tasks.data.CaldavAccount; import org.tasks.data.CaldavAccount;

@ -20,8 +20,7 @@ public class GoogleAccountManager {
@Inject @Inject
public GoogleAccountManager( public GoogleAccountManager(
@ForApplication Context context, @ForApplication Context context, PermissionChecker permissionChecker) {
PermissionChecker permissionChecker) {
this.permissionChecker = permissionChecker; this.permissionChecker = permissionChecker;
accountManager = android.accounts.AccountManager.get(context); accountManager = android.accounts.AccountManager.get(context);

@ -129,7 +129,7 @@ public class GoogleTaskSynchronizer {
public void sync() { public void sync() {
List<GoogleTaskAccount> accounts = googleTaskListDao.getAccounts(); List<GoogleTaskAccount> accounts = googleTaskListDao.getAccounts();
for (int i = 0 ; i < accounts.size() ; i++) { for (int i = 0; i < accounts.size(); i++) {
GoogleTaskAccount account = accounts.get(i); GoogleTaskAccount account = accounts.get(i);
Timber.d("%s: start sync", account); Timber.d("%s: start sync", account);
try { try {
@ -174,7 +174,8 @@ public class GoogleTaskSynchronizer {
} }
private void synchronize(GoogleTaskAccount account) throws IOException { 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)); account.setError(context.getString(R.string.cannot_access_account));
googleTaskListDao.update(account); googleTaskListDao.update(account);
localBroadcastManager.broadcastRefreshList(); localBroadcastManager.broadcastRefreshList();
@ -212,7 +213,8 @@ public class GoogleTaskSynchronizer {
account.setError(""); account.setError("");
} }
private void pushLocalChanges(GoogleTaskAccount account, GtasksInvoker gtasksInvoker) throws UserRecoverableAuthIOException { private void pushLocalChanges(GoogleTaskAccount account, GtasksInvoker gtasksInvoker)
throws UserRecoverableAuthIOException {
List<Task> tasks = taskDao.getGoogleTasksToPush(account.getAccount()); List<Task> tasks = taskDao.getGoogleTasksToPush(account.getAccount());
for (Task task : tasks) { for (Task task : tasks) {
try { try {
@ -322,8 +324,8 @@ public class GoogleTaskSynchronizer {
taskDao.save(task); taskDao.save(task);
} }
private synchronized void fetchAndApplyRemoteChanges(GtasksInvoker gtasksInvoker, GoogleTaskList list) private synchronized void fetchAndApplyRemoteChanges(
throws UserRecoverableAuthIOException { GtasksInvoker gtasksInvoker, GoogleTaskList list) throws UserRecoverableAuthIOException {
String listId = list.getRemoteId(); String listId = list.getRemoteId();
long lastSyncDate = list.getLastSync(); long lastSyncDate = list.getLastSync();

@ -127,8 +127,7 @@ public abstract class InjectingPreferenceActivity extends AppCompatPreferenceAct
.setPositiveButton( .setPositiveButton(
R.string.restart_now, R.string.restart_now,
(dialogInterface, i) -> { (dialogInterface, i) -> {
Intent nextIntent = Intent nextIntent = new Intent(InjectingPreferenceActivity.this, MainActivity.class);
new Intent(InjectingPreferenceActivity.this, MainActivity.class);
nextIntent.putExtra(MainActivity.OPEN_FILTER, (Filter) null); nextIntent.putExtra(MainActivity.OPEN_FILTER, (Filter) null);
ProcessPhoenix.triggerRebirth(InjectingPreferenceActivity.this, nextIntent); ProcessPhoenix.triggerRebirth(InjectingPreferenceActivity.this, nextIntent);
}) })

@ -1,18 +1,11 @@
package org.tasks.injection; package org.tasks.injection;
import dagger.Subcomponent; import dagger.Subcomponent;
import org.tasks.jobs.AfterSaveIntentService;
import org.tasks.jobs.BackupJob; import org.tasks.jobs.BackupJob;
import org.tasks.jobs.CleanupJob; import org.tasks.jobs.CleanupJob;
import org.tasks.jobs.NotificationJob; import org.tasks.jobs.NotificationJob;
import org.tasks.jobs.RefreshJob; import org.tasks.jobs.RefreshJob;
import org.tasks.jobs.SyncJob; 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) @Subcomponent(modules = JobModule.class)
public interface JobComponent { public interface JobComponent {

@ -32,6 +32,14 @@ public class BackupJob extends InjectingJob {
@Inject TasksJsonExporter tasksJsonExporter; @Inject TasksJsonExporter tasksJsonExporter;
@Inject Preferences preferences; @Inject Preferences preferences;
public BackupJob() {}
BackupJob(Context context, TasksJsonExporter tasksJsonExporter, Preferences preferences) {
this.context = context;
this.tasksJsonExporter = tasksJsonExporter;
this.preferences = preferences;
}
static List<File> getDeleteList(File[] fileArray, int keepNewest) { static List<File> getDeleteList(File[] fileArray, int keepNewest) {
if (fileArray == null) { if (fileArray == null) {
return emptyList(); return emptyList();
@ -42,16 +50,6 @@ public class BackupJob extends InjectingJob {
return newArrayList(skip(files, keepNewest)); return newArrayList(skip(files, keepNewest));
} }
public BackupJob() {
}
BackupJob(Context context, TasksJsonExporter tasksJsonExporter, Preferences preferences) {
this.context = context;
this.tasksJsonExporter = tasksJsonExporter;
this.preferences = preferences;
}
@NonNull @NonNull
@Override @Override
protected Result onRunJob(@NonNull Params params) { protected Result onRunJob(@NonNull Params params) {

@ -29,7 +29,7 @@ public class CleanupJob extends InjectingJob {
PersistableBundleCompat extras = params.getExtras(); PersistableBundleCompat extras = params.getExtras();
long[] tasks = extras.getLongArray(EXTRA_TASK_IDS); long[] tasks = extras.getLongArray(EXTRA_TASK_IDS);
if (tasks == null) { if (tasks == null) {
Timber.e("No task ids provided"); Timber.e("No task ids provided");
return Result.FAILURE; return Result.FAILURE;
} }

@ -6,9 +6,8 @@ import android.arch.persistence.room.Index;
import android.arch.persistence.room.PrimaryKey; import android.arch.persistence.room.PrimaryKey;
@Entity( @Entity(
tableName = "notification", tableName = "notification",
indices = {@Index(value = "task", unique = true)} indices = {@Index(value = "task", unique = true)})
)
public class Notification { public class Notification {
@PrimaryKey(autoGenerate = true) @PrimaryKey(autoGenerate = true)

@ -447,11 +447,11 @@ public class Preferences {
return getBoolean(R.string.p_rmd_persistent, true); return getBoolean(R.string.p_rmd_persistent, true);
} }
public void setSyncOngoing(boolean value) {
setBoolean(R.string.p_sync_ongoing, value);
}
public boolean isSyncOngoing() { public boolean isSyncOngoing() {
return getBoolean(R.string.p_sync_ongoing, false); return getBoolean(R.string.p_sync_ongoing, false);
} }
public void setSyncOngoing(boolean value) {
setBoolean(R.string.p_sync_ongoing, value);
}
} }

@ -159,17 +159,19 @@ public class SynchronizationPreferences extends InjectingPreferenceActivity {
addGoogleTaskAccount.setKey(KEY_ADD_GOOGLE_TASKS); addGoogleTaskAccount.setKey(KEY_ADD_GOOGLE_TASKS);
addGoogleTaskAccount.setTitle(R.string.add_account); addGoogleTaskAccount.setTitle(R.string.add_account);
if (inventory.hasPro() || googleTaskListDao.getAccounts().isEmpty()) { if (inventory.hasPro() || googleTaskListDao.getAccounts().isEmpty()) {
addGoogleTaskAccount.setOnPreferenceClickListener(preference -> { addGoogleTaskAccount.setOnPreferenceClickListener(
addGoogleTaskAccount(); preference -> {
return false; addGoogleTaskAccount();
}); return false;
});
} else { } else {
addGoogleTaskAccount.setSummary(R.string.requires_pro_subscription); addGoogleTaskAccount.setSummary(R.string.requires_pro_subscription);
addGoogleTaskAccount.setOnPreferenceClickListener(preference -> { addGoogleTaskAccount.setOnPreferenceClickListener(
startActivityForResult( preference -> {
new Intent(this, PurchaseActivity.class), REQUEST_GOOGLE_TASKS_SUBSCRIBE); startActivityForResult(
return false; new Intent(this, PurchaseActivity.class), REQUEST_GOOGLE_TASKS_SUBSCRIBE);
}); return false;
});
} }
googleTaskPreferences.addPreference(addGoogleTaskAccount); googleTaskPreferences.addPreference(addGoogleTaskAccount);
} }

@ -46,8 +46,7 @@ public class ActionModeProvider {
TaskDuplicator taskDuplicator, TaskDuplicator taskDuplicator,
TaskMover taskMover, TaskMover taskMover,
Tracker tracker, Tracker tracker,
SyncAdapters syncAdapters SyncAdapters syncAdapters) {
) {
this.context = context; this.context = context;
this.dialogBuilder = dialogBuilder; this.dialogBuilder = dialogBuilder;
this.taskDeleter = taskDeleter; this.taskDeleter = taskDeleter;
@ -87,7 +86,8 @@ public class ActionModeProvider {
Filter singleFilter = taskMover.getSingleFilter(adapter.getSelected()); Filter singleFilter = taskMover.getSingleFilter(adapter.getSelected());
(singleFilter == null (singleFilter == null
? newRemoteListSupportPicker(taskList, REQUEST_MOVE_TASKS) ? 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); .show(taskList.getFragmentManager(), FRAG_TAG_REMOTE_LIST_PICKER);
return true; return true;
case R.id.delete: case R.id.delete:

@ -21,7 +21,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import javax.inject.Inject; import javax.inject.Inject;
import org.tasks.R; import org.tasks.R;
import org.tasks.data.CaldavAccount;
import org.tasks.data.CaldavCalendar; import org.tasks.data.CaldavCalendar;
import org.tasks.data.CaldavDao; import org.tasks.data.CaldavDao;
import org.tasks.data.GoogleTaskList; 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<String> tagUuids) { CharSequence getTagString(String caldav, String googleTask, List<String> tagUuids) {
List<ColoredString> strings = new ArrayList<>(); List<ColoredString> strings = new ArrayList<>();
if (!Strings.isNullOrEmpty(googleTask)) { if (!Strings.isNullOrEmpty(googleTask)) {
@ -217,4 +195,25 @@ public class TagFormatter {
} }
return tagData; 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();
}
}
} }

@ -282,7 +282,8 @@ class ViewHolder extends RecyclerView.ViewHolder {
} else { } else {
String tags = task.getTagsString(); String tags = task.getTagsString();
List<String> tagUuids = tags != null ? newArrayList(tags.split(",")) : Lists.newArrayList(); List<String> 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)) { if (TextUtils.isEmpty(tagString)) {
tagBlock.setVisibility(View.GONE); tagBlock.setVisibility(View.GONE);
} else { } else {

@ -23,26 +23,26 @@ public class ThemeColor implements ColorPickerDialog.Pickable {
public static final int[] ICONS = public static final int[] ICONS =
new int[] { new int[] {
R.mipmap.ic_launcher_blue_grey, R.mipmap.ic_launcher_blue_grey,
R.mipmap.ic_launcher_dark_grey, R.mipmap.ic_launcher_dark_grey,
R.mipmap.ic_launcher_red, R.mipmap.ic_launcher_red,
R.mipmap.ic_launcher_pink, R.mipmap.ic_launcher_pink,
R.mipmap.ic_launcher_purple, R.mipmap.ic_launcher_purple,
R.mipmap.ic_launcher_deep_purple, R.mipmap.ic_launcher_deep_purple,
R.mipmap.ic_launcher_indigo, R.mipmap.ic_launcher_indigo,
R.mipmap.ic_launcher_blue, R.mipmap.ic_launcher_blue,
R.mipmap.ic_launcher_light_blue, R.mipmap.ic_launcher_light_blue,
R.mipmap.ic_launcher_cyan, R.mipmap.ic_launcher_cyan,
R.mipmap.ic_launcher_teal, R.mipmap.ic_launcher_teal,
R.mipmap.ic_launcher_green, R.mipmap.ic_launcher_green,
R.mipmap.ic_launcher_light_green, R.mipmap.ic_launcher_light_green,
R.mipmap.ic_launcher_lime, R.mipmap.ic_launcher_lime,
R.mipmap.ic_launcher_yellow, R.mipmap.ic_launcher_yellow,
R.mipmap.ic_launcher_amber, R.mipmap.ic_launcher_amber,
R.mipmap.ic_launcher_orange, R.mipmap.ic_launcher_orange,
R.mipmap.ic_launcher_deep_orange, R.mipmap.ic_launcher_deep_orange,
R.mipmap.ic_launcher_brown, R.mipmap.ic_launcher_brown,
R.mipmap.ic_launcher_grey R.mipmap.ic_launcher_grey
}; };
public static final String[] LAUNCHERS = public static final String[] LAUNCHERS =

Loading…
Cancel
Save