Fix some inspections

pull/996/head
Alex Baker 5 years ago
parent 5fa35a001e
commit 0b456d177e

@ -125,7 +125,7 @@ public class TranslationTests {
}
});
assertTrue(failures.toString(), errorCount(failures) == 0);
assertEquals(failures.toString(), 0, errorCount(failures));
}
/** check if string contains contains substrings */

@ -1,6 +1,6 @@
package com.todoroo.astrid.sync;
import static junit.framework.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.todoroo.astrid.data.Task;
@ -14,12 +14,12 @@ public class SyncModelTest extends NewSyncTestCase {
@Test
public void testCreateTaskMakesUuid() {
Task task = createTask();
assertFalse(Task.NO_UUID.equals(task.getUuid()));
assertNotEquals(Task.NO_UUID, task.getUuid());
}
@Test
public void testCreateTagMakesUuid() {
TagData tag = createTagData();
assertFalse(Task.NO_UUID.equals(tag.getRemoteId()));
assertNotEquals(Task.NO_UUID, tag.getRemoteId());
}
}

@ -37,7 +37,7 @@ class LocationDaoTest : InjectingTestCase() {
@Test
fun getPlaceWithLessPrecision() {
locationDao.insert(newPlace(with(LATITUDE, 50.7547), with(LONGITUDE, -2.2279)));
locationDao.insert(newPlace(with(LATITUDE, 50.7547), with(LONGITUDE, -2.2279)))
val place = locationDao.findPlace(50.754712.toLikeString(), (-2.227945).toLikeString())
assertEquals(50.7547, place?.latitude)
assertEquals(-2.2279, place?.longitude)

@ -4,9 +4,7 @@ import com.natpryce.makeiteasy.Instantiator
import com.natpryce.makeiteasy.Property
import com.natpryce.makeiteasy.PropertyLookup
import com.natpryce.makeiteasy.PropertyValue
import com.todoroo.astrid.helper.UUIDHelper
import org.tasks.data.Geofence
import org.tasks.data.Place
object GeofenceMaker {
val PLACE: Property<Geofence, String> = Property.newProperty()

@ -6,7 +6,6 @@
package com.todoroo.andlib.sql;
import static com.todoroo.andlib.sql.SqlConstants.COMMA;
import static com.todoroo.andlib.sql.SqlConstants.LEFT_PARENTHESIS;
import static com.todoroo.andlib.sql.SqlConstants.RIGHT_PARENTHESIS;
import static com.todoroo.andlib.sql.SqlConstants.SPACE;
@ -28,13 +27,6 @@ public class Field extends DBObject<Field> {
return UnaryCriterion.eq(this, value);
}
public Criterion neq(Object value) {
if (value == null) {
return UnaryCriterion.isNotNull(this);
}
return UnaryCriterion.neq(this, value);
}
public Criterion gt(Object value) {
return UnaryCriterion.gt(this, value);
}
@ -55,26 +47,6 @@ public class Field extends DBObject<Field> {
return UnaryCriterion.like(this, value);
}
public <T> Criterion in(final Iterable<T> value) {
final Field field = this;
return new Criterion(Operator.in) {
@Override
protected void populate(StringBuilder sb) {
sb.append(field)
.append(SPACE)
.append(Operator.in)
.append(SPACE)
.append(LEFT_PARENTHESIS)
.append(SPACE);
for (T t : value) {
sb.append(t.toString()).append(COMMA);
}
sb.deleteCharAt(sb.length() - 1).append(RIGHT_PARENTHESIS);
}
};
}
public Criterion in(final Query query) {
final Field field = this;
return new Criterion(Operator.in) {

@ -13,11 +13,8 @@ public final class Operator {
public static final Operator and = new Operator("AND");
public static final Operator or = new Operator("OR");
public static final Operator not = new Operator("NOT");
public static final Operator exists = new Operator("EXISTS");
public static final Operator like = new Operator("LIKE");
public static final Operator in = new Operator("IN");
static final Operator neq = new Operator("<>");
static final Operator isNotNull = new Operator("IS NOT NULL");
static final Operator gt = new Operator(">");
static final Operator gte = new Operator(">=");
static final Operator lt = new Operator("<");

@ -7,7 +7,6 @@
package com.todoroo.andlib.sql;
import static com.todoroo.andlib.sql.SqlConstants.COMMA;
import static com.todoroo.andlib.sql.SqlConstants.LIMIT;
import static com.todoroo.andlib.sql.SqlConstants.ORDER_BY;
import static com.todoroo.andlib.sql.SqlConstants.SPACE;
import static com.todoroo.andlib.sql.SqlConstants.WHERE;
@ -25,7 +24,6 @@ public final class QueryTemplate {
private final ArrayList<Criterion> criterions = new ArrayList<>();
private final ArrayList<Join> joins = new ArrayList<>();
private final ArrayList<Order> orders = new ArrayList<>();
private Integer limit = null;
public QueryTemplate join(Join... join) {
joins.addAll(asList(join));
@ -48,9 +46,6 @@ public final class QueryTemplate {
visitJoinClause(sql);
visitWhereClause(sql);
visitOrderByClause(sql);
if (limit != null) {
sql.append(LIMIT).append(SPACE).append(limit);
}
return sql.toString();
}
@ -80,9 +75,4 @@ public final class QueryTemplate {
sql.append(join).append(SPACE);
}
}
public QueryTemplate limit(int limitValue) {
this.limit = limitValue;
return this;
}
}

@ -10,16 +10,15 @@ public final class SqlConstants {
public static final Field COUNT = Field.field("COUNT(*)");
public static final String SELECT = "SELECT";
public static final String SPACE = " ";
static final String SPACE = " ";
public static final String AS = "AS";
public static final String FROM = "FROM";
public static final String ON = "ON";
public static final String ALL = "*";
static final String ALL = "*";
public static final String AND = "AND";
public static final String OR = "OR";
public static final String WHERE = "WHERE";
public static final String NOT = "NOT";
public static final String LIMIT = "LIMIT";
static final String COMMA = ",";
static final String JOIN = "JOIN";
static final String LEFT_PARENTHESIS = "(";

@ -28,10 +28,6 @@ public class UnaryCriterion extends Criterion {
return input.replace("'", "''");
}
static Criterion neq(Field field, Object value) {
return new UnaryCriterion(field, Operator.neq, value);
}
static Criterion gt(Field field, Object value) {
return new UnaryCriterion(field, Operator.gt, value);
}
@ -57,15 +53,6 @@ public class UnaryCriterion extends Criterion {
};
}
static Criterion isNotNull(Field field) {
return new UnaryCriterion(field, Operator.isNotNull, null) {
@Override
protected void populateOperator(StringBuilder sb) {
sb.append(SPACE).append(operator);
}
};
}
public static Criterion like(Field field, String value) {
return new UnaryCriterion(field, Operator.like, value) {
@Override
@ -87,7 +74,6 @@ public class UnaryCriterion extends Criterion {
sb.append(expression);
}
@SuppressWarnings("WeakerAccess")
void populateOperator(StringBuilder sb) {
sb.append(operator);
}

@ -110,14 +110,12 @@ public class BeastModePreferences extends ThemedInjectingAppCompatActivity
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_reset_to_defaults:
String[] prefsArray = getResources().getStringArray(R.array.TEA_control_sets_prefs);
adapter.setItems(asList(prefsArray));
return true;
default:
return onOptionsItemSelected(item);
if (item.getItemId() == R.id.menu_reset_to_defaults) {
String[] prefsArray = getResources().getStringArray(R.array.TEA_control_sets_prefs);
adapter.setItems(asList(prefsArray));
return true;
}
return onOptionsItemSelected(item);
}
@Override

@ -146,12 +146,6 @@ public class FilterAdapter extends BaseAdapter {
return newArrayList(items);
}
public int indexOf(FilterListItem item, int defaultValue) {
assertMainThread();
int index = items.indexOf(item);
return index == -1 ? defaultValue : index;
}
@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {

@ -3,7 +3,6 @@ package com.todoroo.astrid.adapter;
import static com.todoroo.andlib.utility.AndroidUtilities.preLollipop;
import android.app.Activity;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
import android.view.View;
@ -27,7 +26,6 @@ import org.tasks.R;
import org.tasks.billing.Inventory;
import org.tasks.filters.PlaceFilter;
import org.tasks.locale.Locale;
import org.tasks.preferences.SyncPreferences;
import org.tasks.themes.ColorProvider;
import org.tasks.themes.CustomIcons;
import org.tasks.themes.DrawableUtil;
@ -99,15 +97,6 @@ public class FilterViewHolder extends RecyclerView.ViewHolder {
}
}
FilterViewHolder(@NonNull View itemView, Activity activity) {
super(itemView);
ButterKnife.bind(this, itemView);
icon.setOnClickListener(
v -> activity.startActivity(new Intent(activity, SyncPreferences.class)));
}
FilterViewHolder(@NonNull View itemView) {
super(itemView);
}

@ -103,10 +103,6 @@ public class NavigationDrawerAdapter extends RecyclerView.Adapter<ViewHolder> {
return differ.getCurrentList().size();
}
public Filter getSelected() {
return selected;
}
public void setSelected(Filter selected) {
this.selected = selected;
notifyDataSetChanged();

@ -304,10 +304,9 @@ public class CustomFilterActivity extends ThemedInjectingAppCompatActivity
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_save:
saveAndView();
return true;
if (item.getItemId() == R.id.menu_save) {
saveAndView();
return true;
}
return onOptionsItemSelected(item);
}

@ -206,8 +206,7 @@ class CustomFilterAdapter extends ArrayAdapter<CriterionInstance> {
viewHolder.filterCount.setText(locale.formatNumber(item.end));
}
private class ViewHolder {
private static class ViewHolder {
CriterionInstance item;
ImageView type;
TextView name;

@ -10,10 +10,8 @@ import static org.tasks.db.QueryUtils.showCompleted;
import static org.tasks.db.QueryUtils.showHidden;
import static org.tasks.db.QueryUtils.showRecentlyCompleted;
import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Functions;
import com.todoroo.andlib.sql.Order;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.astrid.data.Task;
import org.tasks.R;
import org.tasks.preferences.Preferences;

@ -86,7 +86,7 @@ public class FilesControlSet extends TaskEditControlFragment {
}
@OnClick(R.id.add_attachment)
void addAttachment(View view) {
void addAttachment() {
newAddAttachmentDialog(this).show(getParentFragmentManager(), FRAG_TAG_ADD_ATTACHMENT_DIALOG);
}

@ -8,7 +8,6 @@ import static com.todoroo.andlib.utility.DateUtilities.now;
import static java.util.Collections.emptyList;
import androidx.annotation.Nullable;
import com.google.common.collect.Lists;
import com.todoroo.astrid.api.CaldavFilter;
import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.api.GtasksFilter;

@ -157,10 +157,7 @@ public class SubtasksFilterUpdater {
private void verifyTreeModel(TaskListMetadata list, Filter filter) {
boolean changedThings = false;
Set<String> keySet = idToNode.keySet();
Set<String> currentIds = new HashSet<>();
for (String id : keySet) {
currentIds.add(id);
}
Set<String> currentIds = new HashSet<>(keySet);
Set<String> idsInQuery = new HashSet<>();
String sql = filter.getSqlQuery().replaceAll("ORDER BY .*", ""); // $NON-NLS-1$//$NON-NLS-2$
sql = sql + " ORDER BY created"; // $NON-NLS-1$
@ -214,7 +211,7 @@ public class SubtasksFilterUpdater {
private String[] getOrderedIds() {
ArrayList<String> ids = new ArrayList<>();
orderedIdHelper(treeRoot, ids);
return ids.toArray(new String[ids.size()]);
return ids.toArray(new String[0]);
}
private String getOrderString() {

@ -8,7 +8,6 @@ import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.api.GtasksFilter;
import com.todoroo.astrid.core.BuiltInFilterExposer;
import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.subtasks.SubtasksFilterUpdater.Node;
import java.util.ArrayList;
@ -71,7 +70,7 @@ public class SubtasksHelper {
ids.add(idString);
}
}
return ids.toArray(new String[ids.size()]);
return ids.toArray(new String[0]);
}
/** Takes a subtasks string containing local ids and remaps it to one containing UUIDs */
@ -107,7 +106,7 @@ public class SubtasksHelper {
root,
idMap,
uuid -> {
Long localId = -1L;
long localId = -1L;
try {
localId = Long.parseLong(uuid);
} catch (NumberFormatException e) {

@ -1,16 +0,0 @@
/*
* Copyright (c) 2012 Todoroo Inc
*
* See the file "LICENSE" for the full license governing this code.
*/
package com.todoroo.astrid.sync;
public interface SyncResultCallback {
/** Provider started sync */
void started();
/** Provider finished sync */
void finished();
}

@ -135,7 +135,7 @@ public class TimerControlSet extends TaskEditControlFragment {
}
@OnClick(R.id.timer_container)
void timerClicked(View view) {
void timerClicked() {
if (timerActive()) {
Task task = callback.stopTimer();
elapsed.setTimeDuration(task.getElapsedSeconds());

@ -82,7 +82,7 @@ public class HideUntilControlSet extends TaskEditControlFragment implements OnIt
private HideUntilValue selectedValue;
@OnClick(R.id.clear)
void clearHideUntil(View view) {
void clearHideUntil() {
updateSpinnerOptions(0);
selection = 0;
spinner.setSelection(selection);
@ -337,7 +337,7 @@ public class HideUntilControlSet extends TaskEditControlFragment implements OnIt
*
* @author Tim Su <tim@todoroo.com>
*/
private class HideUntilValue {
private static class HideUntilValue {
final String labelSpinner;
final String labelDisplay;

@ -151,7 +151,7 @@ public class ReminderControlSet extends TaskEditControlFragment {
}
@OnClick(R.id.alarms_add)
void addAlarm(View view) {
void addAlarm() {
List<String> options = getOptions();
if (options.size() == 1) {
addNewAlarm();

@ -175,7 +175,7 @@ public class TitleParser {
private static void dayHelper(Task task) {
String inputText = task.getTitle();
Calendar cal = null;
Boolean containsSpecificTime = false;
boolean containsSpecificTime = false;
String[] daysOfWeek = {
"(?i)(\\(|\\b)today(\\)|\\b)",
"(?i)(\\(|\\b)tomorrow(\\)|\\b)",

@ -65,7 +65,7 @@ public class FilterSettingsActivity extends BaseListSettingsActivity {
}
@OnTextChanged(R.id.name)
void onTextChanged(CharSequence ignored) {
void onTextChanged() {
nameLayout.setError(null);
}

@ -86,7 +86,7 @@ public class TagSettingsActivity extends BaseListSettingsActivity {
}
@OnTextChanged(R.id.name)
void onTextChanged(CharSequence ignored) {
void onTextChanged() {
nameLayout.setError(null);
}

@ -261,7 +261,6 @@ public class TasksJsonExporter {
public enum ExportType {
EXPORT_TYPE_SERVICE,
EXPORT_TYPE_MANUAL,
EXPORT_TYPE_ON_UPGRADE
EXPORT_TYPE_MANUAL
}
}

@ -51,13 +51,6 @@ public class XmlReader {
return value == null || XML_NULL.equals(value) ? null : Double.parseDouble(value);
}
public void readDouble(String name, ValueWriter<Double> writer) {
Double value = readDouble(name);
if (value != null) {
writer.write(value);
}
}
public interface ValueWriter<T> {
void write(T value);

@ -103,7 +103,7 @@ public abstract class BaseCaldavCalendarSettingsActivity extends BaseListSetting
}
@OnTextChanged(R.id.name)
void onNameChanged(CharSequence text) {
void onNameChanged() {
nameLayout.setError(null);
}

@ -10,12 +10,8 @@ import okhttp3.RequestBody
import okhttp3.Response
import java.io.IOException
import java.net.HttpURLConnection
import java.util.logging.Logger
class PatchableDavResource : DavResource {
constructor(client: OkHttpClient, url: HttpUrl, log: Logger) : super(client, url, log)
constructor(client: OkHttpClient, url: HttpUrl) : super(client, url)
class PatchableDavResource(client: OkHttpClient, url: HttpUrl) : DavResource(client, url) {
/**
* Sends a PROPPATCH request to this resource. Follows up to [MAX_REDIRECTS] redirects.

@ -1,42 +1,19 @@
package org.tasks.caldav;
import java.io.IOException;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import timber.log.Timber;
public class Response implements Function1<okhttp3.Response, Unit> {
class Response implements Function1<okhttp3.Response, Unit> {
private final boolean parseBody;
private okhttp3.Response response;
private String body;
public Response() {
this(false);
}
public Response(boolean parseBody) {
this.parseBody = parseBody;
}
@Override
public Unit invoke(okhttp3.Response response) {
this.response = response;
if (parseBody) {
try {
body = response.body().string();
} catch (IOException e) {
Timber.e(e);
}
}
return null;
}
public okhttp3.Response get() {
return response;
}
public String getBody() {
return body;
}
}

@ -58,7 +58,7 @@ public class CalendarPicker extends InjectingDialogFragment {
adapter =
new SingleCheckedArrayAdapter(getActivity(), calendarNames, theme.getThemeAccent()) {
@Override
protected int getDrawable(int position) {
protected int getDrawable() {
return R.drawable.ic_outline_event_24px;
}

@ -132,9 +132,6 @@ public abstract class CaldavDao {
@Query("SELECT * FROM caldav_lists WHERE cdl_account = :account AND cdl_url = :url LIMIT 1")
public abstract CaldavCalendar getCalendarByUrl(String account, String url);
@Query("SELECT * FROM caldav_accounts WHERE cda_name = :name COLLATE NOCASE LIMIT 1")
public abstract CaldavAccount getAccountByName(String name);
@Query(
"SELECT caldav_accounts.* from caldav_accounts"
+ " INNER JOIN caldav_tasks ON cd_task = :task"

@ -22,9 +22,6 @@ public class GoogleTask {
public static final Table TABLE = new Table("google_tasks");
public static final Property.IntegerProperty ORDER =
new Property.IntegerProperty(GoogleTask.TABLE, "gt_order");
public static final Property.IntegerProperty PARENT =
new Property.IntegerProperty(TABLE, "gt_parent");
@ -135,10 +132,6 @@ public class GoogleTask {
this.moved = moved;
}
public int getIndent() {
return parent > 0 ? 1 : 0;
}
public long getRemoteOrder() {
return remoteOrder;
}

@ -127,7 +127,7 @@ public abstract class GoogleTaskDao {
@Query("SELECT gt_task FROM google_tasks WHERE gt_remote_id = :remoteId")
public abstract long getTask(String remoteId);
@SuppressWarnings({RoomWarnings.CURSOR_MISMATCH, "AndroidUnresolvedRoomSqlReference"})
@SuppressWarnings({RoomWarnings.CURSOR_MISMATCH})
@Query(
"SELECT google_tasks.*, gt_order AS primary_sort, NULL AS secondary_sort FROM google_tasks JOIN tasks ON tasks._id = gt_task WHERE gt_parent = 0 AND gt_list_id = :listId AND tasks.deleted = 0 UNION SELECT c.*, p.gt_order AS primary_sort, c.gt_order AS secondary_sort FROM google_tasks AS c LEFT JOIN google_tasks AS p ON c.gt_parent = p.gt_task JOIN tasks ON tasks._id = c.gt_task WHERE c.gt_parent > 0 AND c.gt_list_id = :listId AND tasks.deleted = 0 ORDER BY primary_sort ASC, secondary_sort ASC")
abstract List<GoogleTask> getByLocalOrder(String listId);

@ -40,90 +40,38 @@ public class Location implements Serializable, Parcelable {
place = in.readParcelable(Place.class.getClassLoader());
}
public long getId() {
return geofence.getId();
}
public void setId(long id) {
geofence.setId(id);
}
public long getTask() {
return geofence.getTask();
}
public void setTask(long task) {
geofence.setTask(task);
}
@Nullable public String getName() {
return place.getName();
}
public void setName(String name) {
place.setName(name);
}
public double getLatitude() {
return place.getLatitude();
}
public void setLatitude(double latitude) {
place.setLatitude(latitude);
}
public double getLongitude() {
return place.getLongitude();
}
public void setLongitude(double longitude) {
place.setLongitude(longitude);
}
public int getRadius() {
return geofence.getRadius();
}
public void setRadius(int radius) {
geofence.setRadius(radius);
}
public String getAddress() {
return place.getAddress();
}
public String getPhone() {
return place.getPhone();
}
public void setPhone(String phone) {
place.setPhone(phone);
}
public String getUrl() {
return place.getUrl();
}
public void setUrl(String url) {
place.setUrl(url);
}
public boolean isArrival() {
return geofence.isArrival();
}
public void setArrival(boolean arrival) {
geofence.setArrival(arrival);
}
public boolean isDeparture() {
return geofence.isDeparture();
}
public void setDeparture(boolean departure) {
geofence.setDeparture(departure);
}
public String getDisplayName() {
return place.getDisplayName();
}

@ -8,10 +8,6 @@ public class MergedGeofence {
boolean departure;
int radius;
public Place getPlace() {
return place;
}
public String getUid() {
return place.getUid();
}

@ -14,14 +14,6 @@ public class SubsetCaldav {
return cd_calendar;
}
public long getParent() {
return cd_parent;
}
public void setParent(long parent) {
cd_parent = parent;
}
public String getRemoteParent() {
return cd_remote_parent;
}

@ -1,6 +1,5 @@
package org.tasks.data;
import androidx.annotation.Nullable;
import androidx.room.Embedded;
import com.todoroo.astrid.data.Task;
@ -49,14 +48,6 @@ public class TaskContainer {
return task.isCompleted();
}
public int getPriority() {
return task.getPriority();
}
public String getRecurrence() {
return task.getRecurrence();
}
public boolean hasDueDate() {
return task.hasDueDate();
}

@ -19,7 +19,6 @@ import org.tasks.injection.DialogFragmentComponent;
import org.tasks.injection.ForActivity;
import org.tasks.injection.InjectingDialogFragment;
import org.tasks.preferences.Device;
import org.tasks.preferences.Preferences;
public class AddAttachmentDialog extends InjectingDialogFragment {
@ -31,7 +30,6 @@ public class AddAttachmentDialog extends InjectingDialogFragment {
@Inject @ForActivity Context context;
@Inject DialogBuilder dialogBuilder;
@Inject Device device;
@Inject Preferences preferences;
public static AddAttachmentDialog newAddAttachmentDialog(FilesControlSet target) {
AddAttachmentDialog dialog = new AddAttachmentDialog();

@ -69,11 +69,6 @@ public class AlertDialogBuilder {
return this;
}
public AlertDialogBuilder setView(int layoutResId) {
builder.setView(layoutResId);
return this;
}
public AlertDialogBuilder setOnCancelListener(DialogInterface.OnCancelListener onCancelListener) {
builder.setOnCancelListener(onCancelListener);
return this;

@ -22,7 +22,6 @@ import org.tasks.dialogs.ColorWheelPicker.Companion.newColorWheel
import org.tasks.injection.DialogFragmentComponent
import org.tasks.injection.InjectingDialogFragment
import org.tasks.themes.ColorProvider
import org.tasks.themes.ThemeAccent
import org.tasks.themes.ThemeColor
import javax.inject.Inject

@ -89,7 +89,7 @@ class ThemePickerDialog : InjectingDialogFragment() {
Handler().post {
ThemeBase(which).setDefaultNightMode()
activity?.recreate()
activity?.overridePendingTransition(R.anim.fragment_fade_enter, R.anim.fragment_fade_exit);
activity?.overridePendingTransition(R.anim.fragment_fade_enter, R.anim.fragment_fade_exit)
}
}
}

@ -17,7 +17,6 @@ import com.todoroo.astrid.api.TextInputCriterion;
import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.Task.Priority;
import com.todoroo.astrid.gtasks.GtasksListService;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -33,7 +32,6 @@ import org.tasks.data.Tag;
import org.tasks.data.TagData;
import org.tasks.data.TagDataDao;
import org.tasks.injection.ForApplication;
import org.tasks.sync.SyncAdapters;
public class FilterCriteriaProvider {
@ -55,8 +53,6 @@ public class FilterCriteriaProvider {
public FilterCriteriaProvider(
@ForApplication Context context,
TagDataDao tagDataDao,
GtasksListService gtasksListService,
SyncAdapters syncAdapters,
GoogleTaskListDao googleTaskListDao,
CaldavDao caldavDao) {
this.context = context;

@ -6,7 +6,6 @@ import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Order;
import com.todoroo.andlib.sql.QueryTemplate;
import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.core.SortHelper;
import com.todoroo.astrid.data.Task;
import org.tasks.time.DateTime;

@ -14,10 +14,6 @@ public class TagFilters {
return filter;
}
public String getName() {
return tagData.getName();
}
@Override
public boolean equals(Object o) {
if (this == o) {

@ -36,7 +36,6 @@ import org.tasks.reminders.NotificationActivity;
import org.tasks.reminders.SnoozeActivity;
import org.tasks.tags.TagPickerActivity;
import org.tasks.tags.TagPickerViewModel;
import org.tasks.themes.Theme;
import org.tasks.ui.TaskListViewModel;
import org.tasks.voice.VoiceCommandActivity;
import org.tasks.widget.ShortcutConfigActivity;
@ -49,8 +48,6 @@ public interface ActivityComponent {
void inject(GtasksLoginActivity gtasksLoginActivity);
Theme getTheme();
FragmentComponent plus(FragmentModule module);
DialogFragmentComponent plus(DialogFragmentModule dialogFragmentModule);

@ -43,7 +43,7 @@ class ReverseGeocodeWork(context: Context, workerParams: WorkerParameters) : Inj
Timber.d("found $result")
Result.success()
} catch (e: IOException) {
tracker.reportException(e);
tracker.reportException(e)
Result.failure()
}
}

@ -200,8 +200,4 @@ public class Locale implements Serializable {
}
}
}
public String getLanguage() {
return appLocale.getLanguage();
}
}

@ -4,7 +4,6 @@ import static android.app.Activity.RESULT_OK;
import static com.google.common.collect.Lists.transform;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import java.util.ArrayList;
@ -13,17 +12,13 @@ import javax.inject.Inject;
import org.tasks.R;
import org.tasks.dialogs.DialogBuilder;
import org.tasks.injection.DialogFragmentComponent;
import org.tasks.injection.ForActivity;
import org.tasks.injection.InjectingDialogFragment;
import org.tasks.themes.ThemeAccent;
public class LocalePickerDialog extends InjectingDialogFragment {
public static final String EXTRA_LOCALE = "extra_locale";
@Inject @ForActivity Context context;
@Inject DialogBuilder dialogBuilder;
@Inject ThemeAccent themeAccent;
@Inject Locale locale;
public static LocalePickerDialog newLocalePickerDialog() {

@ -19,7 +19,7 @@ public interface NotificationDao {
void insertAll(List<Notification> notifications);
@Query("DELETE FROM notification WHERE task = :taskId")
int delete(long taskId);
void delete(long taskId);
@Query("DELETE FROM notification WHERE task IN(:taskIds)")
void deleteAll(List<Long> taskIds);

@ -22,7 +22,7 @@ import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.schedulers.Schedulers;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -124,7 +124,7 @@ public class AttributionActivity extends ThemedInjectingAppCompatActivity {
() -> {
InputStream licenses = context.getAssets().open("licenses.json");
InputStreamReader reader =
new InputStreamReader(licenses, Charset.forName("UTF-8"));
new InputStreamReader(licenses, StandardCharsets.UTF_8);
AttributionList list =
new GsonBuilder().create().fromJson(reader, AttributionList.class);
return list.libraries;

@ -29,7 +29,7 @@ class BeastModeViewHolder extends RecyclerView.ViewHolder {
}
@OnTouch(R.id.grabber)
boolean onTouch(View view, MotionEvent event) {
boolean onTouch(MotionEvent event) {
if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) {
itemTouchHelper.startDrag(this);
}

@ -238,7 +238,5 @@ class Advanced : InjectingPreferenceFragment() {
.show()
}
override fun inject(component: FragmentComponent) {
component.inject(this);
}
override fun inject(component: FragmentComponent) = component.inject(this)
}

@ -166,7 +166,5 @@ class Backups : InjectingPreferenceFragment() {
FileHelper.uri2String(preferences.backupDirectory)
}
override fun inject(component: FragmentComponent) {
component.inject(this);
}
override fun inject(component: FragmentComponent) = component.inject(this)
}

@ -7,8 +7,6 @@ import com.todoroo.astrid.api.Filter
import org.tasks.LocalBroadcastManager
import org.tasks.R
import org.tasks.activities.FilterSelectionActivity
import org.tasks.billing.Inventory
import org.tasks.billing.PurchaseActivity
import org.tasks.injection.FragmentComponent
import org.tasks.injection.InjectingPreferenceFragment
import org.tasks.preferences.DefaultFilterProvider

@ -65,9 +65,7 @@ class HelpAndFeedback : InjectingPreferenceFragment() {
}
}
override fun inject(component: FragmentComponent) {
component.inject(this);
}
override fun inject(component: FragmentComponent) = component.inject(this)
override fun getMenu() = 0
}

@ -232,7 +232,5 @@ class Synchronization : InjectingPreferenceFragment() {
else defaultFilter.listingTitle
}
override fun inject(component: FragmentComponent) {
component.inject(this);
}
override fun inject(component: FragmentComponent) = component.inject(this)
}

@ -96,7 +96,5 @@ class TaskDefaults : InjectingPreferenceFragment() {
else defaultFilter.listingTitle
}
override fun inject(component: FragmentComponent) {
component.inject(this);
}
override fun inject(component: FragmentComponent) = component.inject(this)
}

@ -1,50 +0,0 @@
package org.tasks.sync;
import static java.util.concurrent.Executors.newSingleThreadExecutor;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.todoroo.astrid.sync.SyncResultCallback;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.RejectedExecutionException;
import javax.inject.Inject;
import org.tasks.analytics.Tracker;
import org.tasks.injection.ApplicationScope;
import timber.log.Timber;
@ApplicationScope
public class SyncExecutor {
private final ExecutorService executor =
newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat("sync-executor-%d").build());
private final Tracker tracker;
@Inject
public SyncExecutor(Tracker tracker) {
this.tracker = tracker;
}
public void execute(SyncResultCallback callback, Runnable command) {
try {
executor.execute(wrapWithExceptionHandling(callback, command));
} catch (RejectedExecutionException e) {
Timber.e(e);
tracker.reportException(e);
callback.finished();
}
}
private Runnable wrapWithExceptionHandling(
final SyncResultCallback callback, final Runnable command) {
return () -> {
try {
command.run();
} catch (Exception e) {
Timber.e(e);
tracker.reportException(e);
executor.shutdownNow();
callback.finished();
}
};
}
}

@ -59,10 +59,6 @@ public class CheckBoxTriStates extends AppCompatCheckBox {
init();
}
public State getState() {
return state;
}
public void setState(State state, boolean notify) {
if (this.state != state) {
this.state = state;
@ -153,7 +149,6 @@ public class CheckBoxTriStates extends AppCompatCheckBox {
}
static class SavedState extends BaseSavedState {
@SuppressWarnings("hiding")
public static final Parcelable.Creator<SavedState> CREATOR =
new Parcelable.Creator<SavedState>() {
@Override

@ -81,10 +81,6 @@ public class TagPickerViewModel extends ViewModel {
disposables.dispose();
}
public boolean isChecked(TagData tagData) {
return selected.contains(tagData);
}
State getState(TagData tagData) {
if (partiallySelected.contains(tagData)) {
return State.PARTIALLY_CHECKED;

@ -215,11 +215,8 @@ public class DragAndDropRecyclerAdapter extends TaskListRecyclerAdapter {
}
if (targetIndent < minIndent) {
task.setTargetIndent(minIndent);
} else if (targetIndent > maxIndent) {
task.setTargetIndent(maxIndent);
} else {
task.setTargetIndent(targetIndent);
}
} else
task.setTargetIndent(Math.min(targetIndent, maxIndent));
}
dX = (task.getTargetIndent() - task.getIndent()) * shiftSize;

@ -2,7 +2,6 @@ package org.tasks.tasklist;
import static com.todoroo.andlib.utility.AndroidUtilities.atLeastLollipop;
import android.annotation.SuppressLint;
import android.graphics.Paint;
import android.util.DisplayMetrics;
import android.view.View;
@ -43,8 +42,6 @@ public class SubtaskViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.chip_group)
ChipGroup chipGroup;
private int indent;
SubtaskViewHolder(
ViewGroup view,
Callbacks callbacks,
@ -104,12 +101,12 @@ public class SubtaskViewHolder extends RecyclerView.ViewHolder {
}
@OnClick(R.id.title)
void openSubtask(View v) {
void openSubtask() {
callbacks.openSubtask(task.getTask());
}
@OnClick(R.id.completeBox)
void onCompleteBoxClick(View v) {
void onCompleteBoxClick() {
if (task == null) {
return;
}
@ -124,12 +121,7 @@ public class SubtaskViewHolder extends RecyclerView.ViewHolder {
setupTitleAndCheckbox();
}
public int getIndent() {
return indent;
}
private void setIndent(int indent) {
this.indent = indent;
int indentSize = getIndentSize(indent);
if (atLeastLollipop()) {
MarginLayoutParams layoutParams = (MarginLayoutParams) rowBody.getLayoutParams();

@ -14,7 +14,6 @@ import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.dao.TaskDao;
import org.tasks.data.TaskContainer;
import org.tasks.dialogs.DateTimePicker;
import org.tasks.intents.TaskIntents;
import org.tasks.tasklist.ViewHolder.ViewHolderCallbacks;

@ -293,7 +293,7 @@ public class ViewHolder extends RecyclerView.ViewHolder {
}
@OnClick(R.id.completeBox)
void onCompleteBoxClick(View v) {
void onCompleteBoxClick() {
if (task == null) {
return;
}

@ -28,24 +28,6 @@ class ColorUtil {
return Color.HSVToColor(hsv);
}
/**
* lightens a given color
* @param base base color
* @param amount amount between 0 and 100
* @return lightened
*/
public static int lighten(int base, int amount) {
float[] hsv = new float[3];
Color.colorToHSV(base, hsv);
float[] hsl = hsv2hsl(hsv);
hsl[2] += amount / 100f;
if (hsl[2] > 1)
hsl[2] = 1f;
hsv = hsl2hsv(hsl);
return Color.HSVToColor(hsv);
}
/**
* Converts HSV (Hue, Saturation, Value) color to HSL (Hue, Saturation, Lightness)
* Credit goes to xpansive
@ -104,8 +86,4 @@ class ColorUtil {
light + sat //Value
};
}
public static String colorToHex(int color) {
return String.format("#%06X", (0xFFFFFF & color));
}
}

@ -193,7 +193,7 @@ public class CalendarControlSet extends TaskEditControlFragment {
}
@OnClick(R.id.clear)
void clearCalendar(View view) {
void clearCalendar() {
if (isNullOrEmpty(eventUri)) {
clear();
} else {

@ -144,16 +144,6 @@ public class ChipProvider {
return chips;
}
public void apply(Chip chip, Filter filter) {
apply(
chip,
getIcon(filter.icon, R.drawable.ic_outline_cloud_24px),
filter.listingTitle,
filter.tint,
true,
true);
}
public void apply(Chip chip, @NonNull TagData tagData) {
apply(
chip,

@ -187,7 +187,7 @@ public class LocationControlSet extends TaskEditControlFragment {
}
@OnClick(R.id.geofence_options)
void geofenceOptions(View view) {
void geofenceOptions() {
if (permissionRequestor.requestFineLocation()) {
showGeofenceOptions();
}

@ -6,7 +6,6 @@ import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatRadioButton;
import androidx.core.widget.CompoundButtonCompat;
@ -48,7 +47,7 @@ public class PriorityControlSet extends TaskEditControlFragment {
}
@OnClick({R.id.priority_high, R.id.priority_medium, R.id.priority_low, R.id.priority_none})
void onPriorityChanged(CompoundButton button) {
void onPriorityChanged() {
priority = getPriority();
}

@ -54,7 +54,7 @@ public class SingleCheckedArrayAdapter extends ArrayAdapter<String> {
DrawableCompat.setTintList(wrapped, tintList);
view.setCheckMarkDrawable(wrapped);
}
int drawable = getDrawable(position);
int drawable = getDrawable();
if (drawable > 0) {
Drawable original = ContextCompat.getDrawable(context, drawable);
Drawable wrapped = DrawableCompat.wrap(original.mutate());
@ -71,7 +71,7 @@ public class SingleCheckedArrayAdapter extends ArrayAdapter<String> {
return view;
}
protected int getDrawable(int position) {
protected int getDrawable() {
return 0;
}

@ -21,18 +21,10 @@ public class Toaster {
this.locale = locale;
}
public void longToast(@StringRes int resId, String arg) {
longToast(context.getString(resId, arg));
}
public void longToast(@StringRes int resId, int number) {
longToast(context.getString(resId, locale.formatNumber(number)));
}
public void longToast(@StringRes int resId, double number) {
longToast(context.getString(resId, locale.formatNumber(number)));
}
public void longToast(@StringRes int resId) {
longToast(context.getString(resId));
}

@ -23,15 +23,14 @@ public class VoiceCommandActivity extends InjectingAppCompatActivity {
Intent intent = getIntent();
switch (intent.getAction()) {
case "com.google.android.gm.action.AUTO_SEND":
final String text = intent.getStringExtra(Intent.EXTRA_TEXT);
if (!Strings.isNullOrEmpty(text)) {
taskCreator.basicQuickAddTask(text);
Toast.makeText(context, getString(R.string.voice_command_added_task), Toast.LENGTH_LONG)
.show();
}
finish();
if ("com.google.android.gm.action.AUTO_SEND".equals(intent.getAction())) {
final String text = intent.getStringExtra(Intent.EXTRA_TEXT);
if (!Strings.isNullOrEmpty(text)) {
taskCreator.basicQuickAddTask(text);
Toast.makeText(context, getString(R.string.voice_command_added_task), Toast.LENGTH_LONG)
.show();
}
finish();
}
}

@ -61,10 +61,6 @@ public class WidgetPreferences {
return preferences.getInt(getKey(R.string.p_widget_opacity), 100);
}
public void setOpacity(int value) {
preferences.setInt(getKey(R.string.p_widget_opacity), value);
}
public void setColor(int color) {
preferences.setInt(getKey(R.string.p_widget_color_v2), color);
}

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/root_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"

@ -33,6 +33,7 @@
android:text="@android:string/cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="@dimen/keyline_first"
android:paddingEnd="@dimen/keyline_first"
android:layout_toStartOf="@id/ok_button" />

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
<string name="app_name" tools:ignore="PrivateResource">Tasks</string>
<resources>
<string name="app_name">Tasks</string>
<string name="app_package">org.tasks</string>
<string name="backup_api_key">AEdPqrEAAAAI49v5bBusi_bq1bgLBB1LIsepNV0eBrFkQrBZkw</string>
</resources>
Loading…
Cancel
Save