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 {
configFile project.file('google_checks.xml')
toolVersion = '8.8'
toolVersion = '8.10.1'
}
configurations {

@ -205,24 +205,21 @@
<property name="allowSamelineMultipleAnnotations" value="true"/>
</module>
<module name="NonEmptyAtclauseDescription"/>
<module name="JavadocTagContinuationIndentation"/>
<module name="JavadocTagContinuationIndentation">
<property name="severity" value="ignore" />
</module>
<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 name="JavadocParagraph"/>
<module name="AtclauseOrder">
<property name="tagOrder" value="@param, @return, @throws, @deprecated"/>
<property name="target" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
</module>
<module name="JavadocMethod">
<property name="scope" value="public"/>
<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"/>
<property name="severity" value="ignore"/>
</module>
<module name="MethodName">
<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}''."/>
</module>
<module name="SingleLineJavadoc">
<property name="ignoreInlineTags" value="false"/>
<property name="severity" value="ignore" />
</module>
<module name="EmptyCatchBlock">
<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();
CaldavConverter.apply(task, fromResource(path));

@ -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

@ -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;

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

@ -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);
}
}

@ -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;
}

@ -84,14 +84,14 @@ public abstract class Property<TYPE> 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);
}
}
/**

@ -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());
}

@ -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";

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

@ -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<Task> CREATOR =
new Creator<Task>() {
@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;
}
}

@ -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;

@ -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;

@ -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;

@ -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;

@ -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),

@ -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;

@ -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));

@ -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;

@ -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();
}

@ -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);
}

@ -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);

@ -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);

@ -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";
}
}
}

@ -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;
}
}
}

@ -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<String> SKU_SUBS = ImmutableList.of(SKU_PRO);
private final Preferences preferences;

@ -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()) {

@ -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

@ -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<RowViewHolder> implements RowDataProvider,
ButtonClick {
public class SkusAdapter extends RecyclerView.Adapter<RowViewHolder>
implements RowDataProvider, ButtonClick {
public static final int TYPE_HEADER = 0;
public static final int TYPE_NORMAL = 1;

@ -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);
}

@ -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);
}
}

@ -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;
}
}

@ -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() {

@ -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()

@ -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);

@ -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;

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

@ -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

@ -9,6 +9,19 @@ import android.os.Parcelable;
@Entity(tableName = "google_task_accounts")
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)
@ColumnInfo(name = "_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
public int describeContents() {
return 0;

@ -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")

@ -29,7 +29,7 @@ public class LimitOffsetDataSource extends PositionalDataSource<Task> {
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);

@ -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");
}
};

@ -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;

@ -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);

@ -129,7 +129,7 @@ public class GoogleTaskSynchronizer {
public void sync() {
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);
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<Task> 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();

@ -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);
})

@ -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 {

@ -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<File> 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) {

@ -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;
}

@ -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)

@ -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);
}
}

@ -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);
}

@ -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:

@ -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<String> tagUuids) {
List<ColoredString> 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();
}
}
}

@ -282,7 +282,8 @@ class ViewHolder extends RecyclerView.ViewHolder {
} else {
String tags = task.getTagsString();
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)) {
tagBlock.setVisibility(View.GONE);
} else {

@ -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 =

Loading…
Cancel
Save