Convert some Room entities to Kotlin

pull/996/head
Alex Baker 5 years ago
parent dafc99014c
commit f27c5592e1

@ -64,7 +64,7 @@ class CaldavDaoTests : InjectingTestCase() {
val caldavAccount = CaldavAccount()
caldavAccount.uuid = UUIDHelper.newUUID()
caldavDao.insert(caldavAccount)
assertTrue(caldavDao.getCaldavFilters(caldavAccount.uuid, DateUtilities.now()).isEmpty())
assertTrue(caldavDao.getCaldavFilters(caldavAccount.uuid!!, DateUtilities.now()).isEmpty())
}
override fun inject(component: TestComponent) = component.inject(this)

@ -24,7 +24,7 @@ class GoogleTaskListDaoTest : InjectingTestCase() {
account.account = "user@gmail.com"
googleTaskListDao.insert(account)
assertTrue(googleTaskListDao.getGoogleTaskFilters(account.account, now()).isEmpty())
assertTrue(googleTaskListDao.getGoogleTaskFilters(account.account!!, now()).isEmpty())
}
@Test

@ -14,7 +14,7 @@ object GoogleTaskListMaker {
val list = GoogleTaskList()
list.remoteId = lookup.valueOf(REMOTE_ID, "1234")
list.account = lookup.valueOf(ACCOUNT, null as String?)
list.color = 0
list.setColor(0)
list
}

@ -25,7 +25,7 @@ object GtaskListMaker {
list.title = lookup.valueOf(NAME, "Default")
list.remoteOrder = lookup.valueOf(ORDER, 0)
list.lastSync = lookup.valueOf(LAST_SYNC, 0L)
list.color = lookup.valueOf(COLOR, 0)
list.setColor(lookup.valueOf(COLOR, 0))
list
}

@ -19,7 +19,7 @@ object TagMaker {
val tag = Tag()
val task = lookup.valueOf(TASK, null as Task?)!!
tag.task = task.getId()
tag.taskUid = task.uuid
tag.setTaskUid(task.uuid)
tag.tagUid = lookup.valueOf(TAGUID, null as String?)
val tagData = lookup.valueOf(TAGDATA, null as TagData?)
if (tagData != null) {

@ -73,10 +73,10 @@ public class GeofenceApi {
private com.google.android.gms.location.Geofence toGoogleGeofence(MergedGeofence geofence) {
int transitionTypes = 0;
if (geofence.isArrival()) {
if (geofence.getArrival()) {
transitionTypes |= GeofencingRequest.INITIAL_TRIGGER_ENTER;
}
if (geofence.isDeparture()) {
if (geofence.getDeparture()) {
transitionTypes |= GeofencingRequest.INITIAL_TRIGGER_EXIT;
}
return new com.google.android.gms.location.Geofence.Builder()

@ -77,10 +77,10 @@ public class GeofenceTransitionsIntentService extends InjectingJobIntentService
private Notification toNotification(Place place, Geofence geofence, boolean arrival) {
Notification notification = new Notification();
notification.taskId = geofence.getTask();
notification.type = arrival ? TYPE_GEOFENCE_ENTER : TYPE_GEOFENCE_EXIT;
notification.timestamp = currentTimeMillis();
notification.location = place.getId();
notification.setTaskId(geofence.getTask());
notification.setType(arrival ? TYPE_GEOFENCE_ENTER : TYPE_GEOFENCE_EXIT);
notification.setTimestamp(currentTimeMillis());
notification.setLocation(place.getId());
return notification;
}

@ -249,9 +249,9 @@ public class Upgrader {
List<Long> tasksWithTags = caldavDao.getTasksWithTags();
for (CaldavTaskContainer container : caldavDao.getTasks()) {
at.bitfire.ical4android.Task remoteTask =
iCalendar.Companion.fromVtodo(container.caldavTask.getVtodo());
iCalendar.Companion.fromVtodo(container.getVtodo());
if (remoteTask != null) {
tagDao.insert(container.task, iCal.getTags(remoteTask.getCategories()));
tagDao.insert(container.getTask(), iCal.getTags(remoteTask.getCategories()));
}
}
batch(tasksWithTags, taskDao::touch);

@ -109,11 +109,11 @@ public class Notifier {
boolean ringNonstop = false;
for (int i = 0; i < entries.size(); i++) {
org.tasks.notifications.Notification entry = entries.get(i);
Task task = taskDao.fetch(entry.taskId);
Task task = taskDao.fetch(entry.getTaskId());
if (task == null) {
continue;
}
if (entry.type != ReminderService.TYPE_RANDOM) {
if (entry.getType() != ReminderService.TYPE_RANDOM) {
ringFiveTimes |= task.isNotifyModeFive();
ringNonstop |= task.isNotifyModeNonstop();
}

@ -1,85 +0,0 @@
package org.tasks.data;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.PrimaryKey;
@Entity(tableName = "alarms")
public class Alarm {
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "_id")
private transient long id;
@ColumnInfo(name = "task")
private transient long task;
@ColumnInfo(name = "time")
private long time;
public Alarm() {}
@Ignore
public Alarm(long task, long time) {
this.task = task;
this.time = time;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public long getTask() {
return task;
}
public void setTask(long task) {
this.task = task;
}
public long getTime() {
return time;
}
public void setTime(long time) {
this.time = time;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Alarm alarm = (Alarm) o;
if (id != alarm.id) {
return false;
}
if (task != alarm.task) {
return false;
}
return time == alarm.time;
}
@Override
public int hashCode() {
int result = (int) (id ^ (id >>> 32));
result = 31 * result + (int) (task ^ (task >>> 32));
result = 31 * result + (int) (time ^ (time >>> 32));
return result;
}
@Override
public String toString() {
return "Alarm{" + "id=" + id + ", task=" + task + ", time=" + time + '}';
}
}

@ -0,0 +1,51 @@
package org.tasks.data
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.Ignore
import androidx.room.PrimaryKey
@Entity(tableName = "alarms")
class Alarm {
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "_id")
@Transient
var id: Long = 0
@ColumnInfo(name = "task")
@Transient
var task: Long = 0
@ColumnInfo(name = "time")
var time: Long = 0
constructor()
@Ignore
constructor(task: Long, time: Long) {
this.task = task
this.time = time
}
override fun toString(): String {
return "Alarm(id=$id, task=$task, time=$time)"
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is Alarm) return false
if (id != other.id) return false
if (task != other.task) return false
if (time != other.time) return false
return true
}
override fun hashCode(): Int {
var result = id.hashCode()
result = 31 * result + task.hashCode()
result = 31 * result + time.hashCode()
return result
}
}

@ -1,272 +0,0 @@
package org.tasks.data;
import static com.todoroo.astrid.data.Task.NO_UUID;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.core.os.ParcelCompat;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.PrimaryKey;
import java.util.Objects;
import org.tasks.security.KeyStoreEncryption;
@Entity(tableName = "caldav_accounts")
public class CaldavAccount implements Parcelable {
private static final int TYPE_CALDAV = 0;
public static final int TYPE_ETESYNC = 1;
public static final Parcelable.Creator<CaldavAccount> CREATOR =
new Parcelable.Creator<CaldavAccount>() {
@Override
public CaldavAccount createFromParcel(Parcel source) {
return new CaldavAccount(source);
}
@Override
public CaldavAccount[] newArray(int size) {
return new CaldavAccount[size];
}
};
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "cda_id")
private long id;
@ColumnInfo(name = "cda_uuid")
private String uuid = NO_UUID;
@ColumnInfo(name = "cda_name")
private String name = "";
@ColumnInfo(name = "cda_url")
private String url = "";
@ColumnInfo(name = "cda_username")
private String username = "";
@ColumnInfo(name = "cda_password")
private transient String password = "";
@ColumnInfo(name = "cda_error")
private transient String error = "";
@ColumnInfo(name = "cda_repeat")
private boolean suppressRepeatingTasks;
@ColumnInfo(name = "cda_encryption_key")
private transient String encryptionKey;
@ColumnInfo(name = "cda_account_type")
private int accountType;
@ColumnInfo(name = "cda_collapsed")
private boolean collapsed;
public CaldavAccount() {}
@Ignore
public CaldavAccount(Parcel source) {
id = source.readLong();
uuid = source.readString();
name = source.readString();
url = source.readString();
username = source.readString();
password = source.readString();
error = source.readString();
suppressRepeatingTasks = ParcelCompat.readBoolean(source);
accountType = source.readInt();
encryptionKey = source.readString();
collapsed = ParcelCompat.readBoolean(source);
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getPassword(KeyStoreEncryption encryption) {
return encryption.decrypt(password);
}
public String getEncryptionKey() {
return encryptionKey;
}
public void setEncryptionKey(String encryptionKey) {
this.encryptionKey = encryptionKey;
}
public String getEncryptionPassword(KeyStoreEncryption encryption) {
return encryption.decrypt(encryptionKey);
}
public String getError() {
return error;
}
public void setError(String error) {
this.error = error;
}
public boolean isSuppressRepeatingTasks() {
return suppressRepeatingTasks;
}
public void setSuppressRepeatingTasks(boolean suppressRepeatingTasks) {
this.suppressRepeatingTasks = suppressRepeatingTasks;
}
public int getAccountType() {
return accountType;
}
public void setAccountType(int accountType) {
this.accountType = accountType;
}
public boolean isCaldavAccount() {
return accountType == TYPE_CALDAV;
}
public boolean isEteSyncAccount() {
return accountType == TYPE_ETESYNC;
}
public boolean isCollapsed() {
return collapsed;
}
public void setCollapsed(boolean collapsed) {
this.collapsed = collapsed;
}
@Override
public String toString() {
return "CaldavAccount{"
+ "id="
+ id
+ ", uuid='"
+ uuid
+ '\''
+ ", name='"
+ name
+ '\''
+ ", url='"
+ url
+ '\''
+ ", username='"
+ username
+ '\''
+ ", password='"
+ password
+ '\''
+ ", error='"
+ error
+ '\''
+ ", suppressRepeatingTasks="
+ suppressRepeatingTasks
+ ", encryptionKey='"
+ encryptionKey
+ '\''
+ ", accountType="
+ accountType
+ ", collapsed="
+ collapsed
+ '}';
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof CaldavAccount)) {
return false;
}
CaldavAccount that = (CaldavAccount) o;
return id == that.id
&& suppressRepeatingTasks == that.suppressRepeatingTasks
&& accountType == that.accountType
&& collapsed == that.collapsed
&& Objects.equals(uuid, that.uuid)
&& Objects.equals(name, that.name)
&& Objects.equals(url, that.url)
&& Objects.equals(username, that.username)
&& Objects.equals(password, that.password)
&& Objects.equals(error, that.error)
&& Objects.equals(encryptionKey, that.encryptionKey);
}
@Override
public int hashCode() {
return Objects
.hash(id, uuid, name, url, username, password, error, suppressRepeatingTasks, encryptionKey,
accountType, collapsed);
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(id);
dest.writeString(uuid);
dest.writeString(name);
dest.writeString(url);
dest.writeString(username);
dest.writeString(password);
dest.writeString(error);
ParcelCompat.writeBoolean(dest, suppressRepeatingTasks);
dest.writeInt(accountType);
dest.writeString(encryptionKey);
ParcelCompat.writeBoolean(dest, collapsed);
}
}

@ -0,0 +1,150 @@
package org.tasks.data
import android.os.Parcel
import android.os.Parcelable
import androidx.core.os.ParcelCompat
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.Ignore
import androidx.room.PrimaryKey
import com.todoroo.astrid.data.Task
import org.tasks.security.KeyStoreEncryption
@Entity(tableName = "caldav_accounts")
class CaldavAccount : Parcelable {
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "cda_id")
var id: Long = 0
@ColumnInfo(name = "cda_uuid")
var uuid: String? = Task.NO_UUID
@ColumnInfo(name = "cda_name")
var name: String? = ""
@ColumnInfo(name = "cda_url")
var url: String? = ""
@ColumnInfo(name = "cda_username")
var username: String? = ""
@ColumnInfo(name = "cda_password")
@Transient
var password: String? = ""
@ColumnInfo(name = "cda_error")
@Transient
var error: String? = ""
@ColumnInfo(name = "cda_repeat")
var isSuppressRepeatingTasks = false
@ColumnInfo(name = "cda_encryption_key")
@Transient
var encryptionKey: String? = null
@ColumnInfo(name = "cda_account_type")
var accountType = 0
@ColumnInfo(name = "cda_collapsed")
var isCollapsed = false
constructor()
@Ignore
constructor(source: Parcel) {
id = source.readLong()
uuid = source.readString()
name = source.readString()
url = source.readString()
username = source.readString()
password = source.readString()
error = source.readString()
isSuppressRepeatingTasks = ParcelCompat.readBoolean(source)
accountType = source.readInt()
encryptionKey = source.readString()
isCollapsed = ParcelCompat.readBoolean(source)
}
fun getPassword(encryption: KeyStoreEncryption): String {
return encryption.decrypt(password)
}
fun getEncryptionPassword(encryption: KeyStoreEncryption): String {
return encryption.decrypt(encryptionKey)
}
val isCaldavAccount: Boolean
get() = accountType == TYPE_CALDAV
val isEteSyncAccount: Boolean
get() = accountType == TYPE_ETESYNC
override fun describeContents() = 0
override fun writeToParcel(dest: Parcel, flags: Int) {
dest.writeLong(id)
dest.writeString(uuid)
dest.writeString(name)
dest.writeString(url)
dest.writeString(username)
dest.writeString(password)
dest.writeString(error)
ParcelCompat.writeBoolean(dest, isSuppressRepeatingTasks)
dest.writeInt(accountType)
dest.writeString(encryptionKey)
ParcelCompat.writeBoolean(dest, isCollapsed)
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is CaldavAccount) return false
if (id != other.id) return false
if (uuid != other.uuid) return false
if (name != other.name) return false
if (url != other.url) return false
if (username != other.username) return false
if (password != other.password) return false
if (error != other.error) return false
if (isSuppressRepeatingTasks != other.isSuppressRepeatingTasks) return false
if (encryptionKey != other.encryptionKey) return false
if (accountType != other.accountType) return false
if (isCollapsed != other.isCollapsed) return false
return true
}
override fun hashCode(): Int {
var result = id.hashCode()
result = 31 * result + (uuid?.hashCode() ?: 0)
result = 31 * result + (name?.hashCode() ?: 0)
result = 31 * result + (url?.hashCode() ?: 0)
result = 31 * result + (username?.hashCode() ?: 0)
result = 31 * result + (password?.hashCode() ?: 0)
result = 31 * result + (error?.hashCode() ?: 0)
result = 31 * result + isSuppressRepeatingTasks.hashCode()
result = 31 * result + (encryptionKey?.hashCode() ?: 0)
result = 31 * result + accountType
result = 31 * result + isCollapsed.hashCode()
return result
}
override fun toString(): String {
return "CaldavAccount(id=$id, uuid=$uuid, name=$name, url=$url, username=$username, password=$password, error=$error, isSuppressRepeatingTasks=$isSuppressRepeatingTasks, encryptionKey=$encryptionKey, accountType=$accountType, isCollapsed=$isCollapsed)"
}
companion object {
private const val TYPE_CALDAV = 0
const val TYPE_ETESYNC = 1
@JvmField val CREATOR: Parcelable.Creator<CaldavAccount> = object : Parcelable.Creator<CaldavAccount> {
override fun createFromParcel(source: Parcel): CaldavAccount? {
return CaldavAccount(source)
}
override fun newArray(size: Int): Array<CaldavAccount?> {
return arrayOfNulls(size)
}
}
}
}

@ -1,206 +0,0 @@
package org.tasks.data;
import static com.todoroo.astrid.data.Task.NO_UUID;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.PrimaryKey;
import java.util.Objects;
import org.tasks.themes.CustomIcons;
@Entity(tableName = "caldav_lists")
public final class CaldavCalendar implements Parcelable {
public static final Parcelable.Creator<CaldavCalendar> CREATOR =
new Parcelable.Creator<CaldavCalendar>() {
@Override
public CaldavCalendar createFromParcel(Parcel source) {
return new CaldavCalendar(source);
}
@Override
public CaldavCalendar[] newArray(int size) {
return new CaldavCalendar[size];
}
};
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "cdl_id")
private long id;
@ColumnInfo(name = "cdl_account")
private String account = NO_UUID;
@ColumnInfo(name = "cdl_uuid")
private String uuid = NO_UUID;
@ColumnInfo(name = "cdl_name")
private String name = "";
@ColumnInfo(name = "cdl_color")
private int color;
@ColumnInfo(name = "cdl_ctag")
private String ctag;
@ColumnInfo(name = "cdl_url")
private String url = "";
@ColumnInfo(name = "cdl_icon")
private Integer icon = -1;
public CaldavCalendar() {}
@Ignore
public CaldavCalendar(String name, String uuid) {
this.name = name;
this.uuid = uuid;
}
@Ignore
public CaldavCalendar(Parcel source) {
id = source.readLong();
account = source.readString();
uuid = source.readString();
name = source.readString();
color = source.readInt();
ctag = source.readString();
url = source.readString();
icon = source.readInt();
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getColor() {
return color;
}
public void setColor(int color) {
this.color = color;
}
public String getCtag() {
return ctag;
}
public void setCtag(String ctag) {
this.ctag = ctag;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public Integer getIcon() {
return icon == null ? CustomIcons.getCLOUD() : icon;
}
public void setIcon(Integer icon) {
this.icon = icon;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(id);
dest.writeString(account);
dest.writeString(uuid);
dest.writeString(name);
dest.writeInt(color);
dest.writeString(ctag);
dest.writeString(url);
dest.writeInt(getIcon());
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof CaldavCalendar)) {
return false;
}
CaldavCalendar that = (CaldavCalendar) o;
return id == that.id
&& color == that.color
&& Objects.equals(account, that.account)
&& Objects.equals(uuid, that.uuid)
&& Objects.equals(name, that.name)
&& Objects.equals(ctag, that.ctag)
&& Objects.equals(url, that.url)
&& Objects.equals(icon, that.icon);
}
@Override
public int hashCode() {
return Objects.hash(id, account, uuid, name, color, ctag, url, icon);
}
@Override
public String toString() {
return "CaldavCalendar{"
+ "id="
+ id
+ ", account='"
+ account
+ '\''
+ ", uuid='"
+ uuid
+ '\''
+ ", name='"
+ name
+ '\''
+ ", color="
+ color
+ ", ctag='"
+ ctag
+ '\''
+ ", url='"
+ url
+ '\''
+ ", icon="
+ icon
+ '}';
}
}

@ -0,0 +1,123 @@
package org.tasks.data
import android.os.Parcel
import android.os.Parcelable
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.Ignore
import androidx.room.PrimaryKey
import com.todoroo.astrid.data.Task
import org.tasks.themes.CustomIcons.CLOUD
@Entity(tableName = "caldav_lists")
class CaldavCalendar : Parcelable {
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "cdl_id")
var id: Long = 0
@ColumnInfo(name = "cdl_account")
var account: String? = Task.NO_UUID
@ColumnInfo(name = "cdl_uuid")
var uuid: String? = Task.NO_UUID
@ColumnInfo(name = "cdl_name")
var name: String? = ""
@ColumnInfo(name = "cdl_color")
var color = 0
@ColumnInfo(name = "cdl_ctag")
var ctag: String? = null
@ColumnInfo(name = "cdl_url")
var url: String? = ""
@ColumnInfo(name = "cdl_icon")
private var icon: Int? = -1
constructor()
@Ignore
constructor(name: String?, uuid: String?) {
this.name = name
this.uuid = uuid
}
@Ignore
constructor(source: Parcel) {
id = source.readLong()
account = source.readString()
uuid = source.readString()
name = source.readString()
color = source.readInt()
ctag = source.readString()
url = source.readString()
icon = source.readInt()
}
fun getIcon(): Int? {
return (if (icon == null) CLOUD else icon!!)
}
fun setIcon(icon: Int?) {
this.icon = icon
}
override fun describeContents() = 0
override fun writeToParcel(dest: Parcel, flags: Int) {
dest.writeLong(id)
dest.writeString(account)
dest.writeString(uuid)
dest.writeString(name)
dest.writeInt(color)
dest.writeString(ctag)
dest.writeString(url)
dest.writeInt(getIcon()!!)
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is CaldavCalendar) return false
if (id != other.id) return false
if (account != other.account) return false
if (uuid != other.uuid) return false
if (name != other.name) return false
if (color != other.color) return false
if (ctag != other.ctag) return false
if (url != other.url) return false
if (icon != other.icon) return false
return true
}
override fun hashCode(): Int {
var result = id.hashCode()
result = 31 * result + (account?.hashCode() ?: 0)
result = 31 * result + (uuid?.hashCode() ?: 0)
result = 31 * result + (name?.hashCode() ?: 0)
result = 31 * result + color
result = 31 * result + (ctag?.hashCode() ?: 0)
result = 31 * result + (url?.hashCode() ?: 0)
result = 31 * result + (icon ?: 0)
return result
}
override fun toString(): String {
return "CaldavCalendar(id=$id, account=$account, uuid=$uuid, name=$name, color=$color, ctag=$ctag, url=$url, icon=$icon)"
}
companion object {
@JvmField val CREATOR: Parcelable.Creator<CaldavCalendar> = object : Parcelable.Creator<CaldavCalendar> {
override fun createFromParcel(source: Parcel): CaldavCalendar? {
return CaldavCalendar(source)
}
override fun newArray(size: Int): Array<CaldavCalendar?> {
return arrayOfNulls(size)
}
}
}
}

@ -1,193 +0,0 @@
package org.tasks.data;
import static com.todoroo.astrid.helper.UUIDHelper.newUUID;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.Index;
import androidx.room.PrimaryKey;
import com.todoroo.andlib.data.Property;
import com.todoroo.andlib.data.Table;
@Entity(tableName = "caldav_tasks", indices = @Index(name = "cd_task", value = "cd_task"))
public class CaldavTask {
public static final String KEY = "caldav";
public static final Table TABLE = new Table("caldav_tasks");
public static final Property.IntegerProperty TASK =
new Property.IntegerProperty(TABLE, "cd_task");
public static final Property.LongProperty DELETED =
new Property.LongProperty(TABLE, "cd_deleted");
public static final Property.StringProperty CALENDAR =
new Property.StringProperty(TABLE, "cd_calendar");
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "cd_id")
private transient long id;
@ColumnInfo(name = "cd_task")
private transient long task;
@ColumnInfo(name = "cd_calendar")
private String calendar;
@ColumnInfo(name = "cd_object")
private String object;
@ColumnInfo(name = "cd_remote_id")
private String remoteId;
@ColumnInfo(name = "cd_etag")
private String etag;
@ColumnInfo(name = "cd_last_sync")
private long lastSync;
@ColumnInfo(name = "cd_deleted")
private long deleted;
@ColumnInfo(name = "cd_vtodo")
private String vtodo;
@ColumnInfo(name = "cd_remote_parent")
private String remoteParent;
public CaldavTask() {}
@Ignore
public CaldavTask(long task, String calendar) {
this.task = task;
this.calendar = calendar;
this.remoteId = newUUID();
this.object = remoteId + ".ics";
}
@Ignore
public CaldavTask(long task, String calendar, String remoteId, String object) {
this.task = task;
this.calendar = calendar;
this.remoteId = remoteId;
this.object = object;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public long getTask() {
return task;
}
public void setTask(long task) {
this.task = task;
}
public String getCalendar() {
return calendar;
}
public void setCalendar(String calendar) {
this.calendar = calendar;
}
public String getObject() {
return object;
}
public void setObject(String object) {
this.object = object;
}
public String getRemoteId() {
return remoteId;
}
public void setRemoteId(String remoteId) {
this.remoteId = remoteId;
}
public String getEtag() {
return etag;
}
public void setEtag(String etag) {
this.etag = etag;
}
public long getLastSync() {
return lastSync;
}
public void setLastSync(long lastSync) {
this.lastSync = lastSync;
}
public long getDeleted() {
return deleted;
}
public void setDeleted(long deleted) {
this.deleted = deleted;
}
public String getVtodo() {
return vtodo;
}
public void setVtodo(String vtodo) {
this.vtodo = vtodo;
}
public String getRemoteParent() {
return remoteParent;
}
public void setRemoteParent(String remoteParent) {
this.remoteParent = remoteParent;
}
@Override
public String toString() {
return "CaldavTask{"
+ "id="
+ id
+ ", task="
+ task
+ ", calendar='"
+ calendar
+ '\''
+ ", object='"
+ object
+ '\''
+ ", remoteId='"
+ remoteId
+ '\''
+ ", etag='"
+ etag
+ '\''
+ ", lastSync="
+ lastSync
+ ", deleted="
+ deleted
+ ", vtodo='"
+ vtodo
+ '\''
+ ", remoteParent='"
+ remoteParent
+ '\''
+ '}';
}
public boolean isDeleted() {
return deleted > 0;
}
}

@ -0,0 +1,74 @@
package org.tasks.data
import androidx.room.*
import com.todoroo.andlib.data.Property.*
import com.todoroo.andlib.data.Table
import com.todoroo.astrid.helper.UUIDHelper
@Entity(tableName = "caldav_tasks", indices = [Index(name = "cd_task", value = ["cd_task"])])
class CaldavTask {
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "cd_id")
@Transient
var id: Long = 0
@ColumnInfo(name = "cd_task")
@Transient
var task: Long = 0
@ColumnInfo(name = "cd_calendar")
var calendar: String? = null
@ColumnInfo(name = "cd_object")
var `object`: String? = null
@ColumnInfo(name = "cd_remote_id")
var remoteId: String? = null
@ColumnInfo(name = "cd_etag")
var etag: String? = null
@ColumnInfo(name = "cd_last_sync")
var lastSync: Long = 0
@ColumnInfo(name = "cd_deleted")
var deleted: Long = 0
@ColumnInfo(name = "cd_vtodo")
var vtodo: String? = null
@ColumnInfo(name = "cd_remote_parent")
var remoteParent: String? = null
constructor()
@Ignore
constructor(task: Long, calendar: String?) {
this.task = task
this.calendar = calendar
remoteId = UUIDHelper.newUUID()
`object` = "$remoteId.ics"
}
@Ignore
constructor(task: Long, calendar: String?, remoteId: String?, `object`: String?) {
this.task = task
this.calendar = calendar
this.remoteId = remoteId
this.`object` = `object`
}
fun isDeleted() = deleted > 0
override fun toString(): String {
return "CaldavTask(id=$id, task=$task, calendar=$calendar, `object`=$`object`, remoteId=$remoteId, etag=$etag, lastSync=$lastSync, deleted=$deleted, vtodo=$vtodo, remoteParent=$remoteParent)"
}
companion object {
const val KEY = "caldav"
@JvmField val TABLE = Table("caldav_tasks")
@JvmField val TASK = IntegerProperty(TABLE, "cd_task")
@JvmField val DELETED = LongProperty(TABLE, "cd_deleted")
@JvmField val CALENDAR = StringProperty(TABLE, "cd_calendar")
}
}

@ -1,34 +0,0 @@
package org.tasks.data;
import androidx.room.Embedded;
import com.todoroo.astrid.data.Task;
public class CaldavTaskContainer {
@Embedded public Task task;
@Embedded public CaldavTask caldavTask;
public Task getTask() {
return task;
}
public CaldavTask getCaldavTask() {
return caldavTask;
}
public String getRemoteId() {
return caldavTask.getRemoteId();
}
public boolean isDeleted() {
return task.isDeleted();
}
public String getVtodo() {
return caldavTask.getVtodo();
}
@Override
public String toString() {
return "CaldavTaskContainer{" + "task=" + task + ", caldavTask=" + caldavTask + '}';
}
}

@ -0,0 +1,22 @@
package org.tasks.data
import androidx.room.Embedded
import com.todoroo.astrid.data.Task
class CaldavTaskContainer {
@Embedded lateinit var task: Task
@Embedded lateinit var caldavTask: CaldavTask
val remoteId: String?
get() = caldavTask.remoteId
val isDeleted: Boolean
get() = task.isDeleted
val vtodo: String?
get() = caldavTask.vtodo
override fun toString(): String {
return "CaldavTaskContainer{task=$task, caldavTask=$caldavTask}"
}
}

@ -59,7 +59,7 @@ abstract class DeletionDao {
@Transaction
open fun delete(googleTaskList: GoogleTaskList): List<Long> {
val tasks = getActiveGoogleTasks(googleTaskList.remoteId)
val tasks = getActiveGoogleTasks(googleTaskList.remoteId!!)
delete(tasks)
deleteGoogleTaskList(googleTaskList)
return tasks
@ -74,7 +74,7 @@ abstract class DeletionDao {
@Transaction
open fun delete(googleTaskAccount: GoogleTaskAccount): List<Long> {
val deleted = ArrayList<Long>()
for (list in getLists(googleTaskAccount.account)) {
for (list in getLists(googleTaskAccount.account!!)) {
deleted.addAll(delete(list))
}
deleteGoogleTaskAccount(googleTaskAccount)

@ -1,145 +0,0 @@
package org.tasks.data;
import static org.tasks.Strings.isNullOrEmpty;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.PrimaryKey;
import com.todoroo.andlib.utility.AndroidUtilities;
import java.util.Map;
import java.util.Objects;
import org.tasks.themes.CustomIcons;
@Entity(tableName = "filters")
public class Filter {
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "_id")
private transient long id;
@ColumnInfo(name = "title")
private String title;
@ColumnInfo(name = "sql")
private String sql;
@ColumnInfo(name = "values")
private String values;
@ColumnInfo(name = "criterion")
private String criterion;
@ColumnInfo(name = "f_color")
private Integer color = 0;
@ColumnInfo(name = "f_icon")
private Integer icon = -1;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getSql() {
// TODO: replace dirty hack for missing column
return sql.replace("tasks.userId=0", "1");
}
public void setSql(String sql) {
this.sql = sql;
}
public String getValues() {
return values;
}
public Map<String, Object> getValuesAsMap() {
return isNullOrEmpty(values) ? null : AndroidUtilities.mapFromSerializedString(values);
}
public void setValues(String values) {
this.values = values;
}
public String getCriterion() {
return criterion;
}
public void setCriterion(String criterion) {
this.criterion = criterion;
}
public Integer getColor() {
return color == null ? 0 : color;
}
public void setColor(Integer color) {
this.color = color;
}
public Integer getIcon() {
return icon == null ? CustomIcons.getFILTER() : icon;
}
public void setIcon(Integer icon) {
this.icon = icon;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Filter)) {
return false;
}
Filter filter = (Filter) o;
return id == filter.id
&& Objects.equals(title, filter.title)
&& Objects.equals(sql, filter.sql)
&& Objects.equals(values, filter.values)
&& Objects.equals(criterion, filter.criterion)
&& Objects.equals(color, filter.color)
&& Objects.equals(icon, filter.icon);
}
@Override
public int hashCode() {
return Objects.hash(id, title, sql, values, criterion, color, icon);
}
@Override
public String toString() {
return "Filter{"
+ "id="
+ id
+ ", title='"
+ title
+ '\''
+ ", sql='"
+ sql
+ '\''
+ ", values='"
+ values
+ '\''
+ ", criterion='"
+ criterion
+ '\''
+ ", color="
+ color
+ ", icon="
+ icon
+ '}';
}
}

@ -0,0 +1,92 @@
package org.tasks.data
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
import com.todoroo.andlib.utility.AndroidUtilities
import org.tasks.Strings
import org.tasks.themes.CustomIcons.FILTER
@Entity(tableName = "filters")
class Filter {
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "_id")
@Transient
var id: Long = 0
@ColumnInfo(name = "title")
var title: String? = null
@ColumnInfo(name = "sql")
private var sql: String? = null
@ColumnInfo(name = "values")
var values: String? = null
@ColumnInfo(name = "criterion")
var criterion: String? = null
@ColumnInfo(name = "f_color")
private var color: Int? = 0
@ColumnInfo(name = "f_icon")
private var icon: Int? = -1
fun getSql(): String {
// TODO: replace dirty hack for missing column
return sql!!.replace("tasks.userId=0", "1")
}
fun setSql(sql: String?) {
this.sql = sql
}
val valuesAsMap: Map<String, Any>?
get() = if (Strings.isNullOrEmpty(values)) null else AndroidUtilities.mapFromSerializedString(values)
fun getColor(): Int? {
return (if (color == null) 0 else color)!!
}
fun setColor(color: Int?) {
this.color = color
}
fun getIcon(): Int? {
return (if (icon == null) FILTER else icon!!)
}
fun setIcon(icon: Int?) {
this.icon = icon
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is Filter) return false
if (id != other.id) return false
if (title != other.title) return false
if (sql != other.sql) return false
if (values != other.values) return false
if (criterion != other.criterion) return false
if (color != other.color) return false
if (icon != other.icon) return false
return true
}
override fun hashCode(): Int {
var result = id.hashCode()
result = 31 * result + (title?.hashCode() ?: 0)
result = 31 * result + (sql?.hashCode() ?: 0)
result = 31 * result + (values?.hashCode() ?: 0)
result = 31 * result + (criterion?.hashCode() ?: 0)
result = 31 * result + (color ?: 0)
result = 31 * result + (icon ?: 0)
return result
}
override fun toString(): String {
return "Filter(id=$id, title=$title, sql=$sql, values=$values, criterion=$criterion, color=$color, icon=$icon)"
}
}

@ -1,210 +0,0 @@
package org.tasks.data;
import static org.tasks.data.Geofence.TABLE_NAME;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.Index;
import androidx.room.PrimaryKey;
import com.todoroo.andlib.data.Property.LongProperty;
import com.todoroo.andlib.data.Property.StringProperty;
import com.todoroo.andlib.data.Table;
import java.io.Serializable;
import java.util.Objects;
import org.tasks.R;
import org.tasks.preferences.Preferences;
@Entity(tableName = TABLE_NAME, indices = @Index(name = "geo_task", value = "task"))
public class Geofence implements Serializable, Parcelable {
static final String TABLE_NAME = "geofences";
public static final Table TABLE = new Table(TABLE_NAME);
public static final LongProperty TASK = new LongProperty(TABLE, "task");
static final StringProperty PLACE = new StringProperty(TABLE, "place");
public static final Parcelable.Creator<Geofence> CREATOR =
new Parcelable.Creator<Geofence>() {
@Override
public Geofence createFromParcel(Parcel source) {
return new Geofence(source);
}
@Override
public Geofence[] newArray(int size) {
return new Geofence[size];
}
};
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "geofence_id")
private transient long id;
@ColumnInfo(name = "task")
private transient long task;
@ColumnInfo(name = "place")
private String place;
@ColumnInfo(name = "radius")
private int radius;
@ColumnInfo(name = "arrival")
private boolean arrival;
@ColumnInfo(name = "departure")
private boolean departure;
public Geofence() {}
@Ignore
public Geofence(long task, String place, boolean arrival, boolean departure, int radius) {
this(place, arrival, departure, radius);
this.task = task;
}
@Ignore
public Geofence(String place, Preferences preferences) {
this.place = place;
int defaultReminders =
preferences.getIntegerFromString(R.string.p_default_location_reminder_key, 1);
arrival = defaultReminders == 1 || defaultReminders == 3;
departure = defaultReminders == 2 || defaultReminders == 3;
radius = preferences.getInt(R.string.p_default_location_radius, 250);
}
@Ignore
public Geofence(String place, boolean arrival, boolean departure, int radius) {
this.place = place;
this.arrival = arrival;
this.departure = departure;
this.radius = radius;
}
@Ignore
public Geofence(Geofence o) {
id = o.id;
task = o.task;
place = o.place;
radius = o.radius;
arrival = o.arrival;
departure = o.departure;
}
@Ignore
public Geofence(Parcel parcel) {
id = parcel.readLong();
task = parcel.readLong();
place = parcel.readString();
radius = parcel.readInt();
arrival = parcel.readInt() == 1;
departure = parcel.readInt() == 1;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public long getTask() {
return task;
}
public void setTask(long task) {
this.task = task;
}
public String getPlace() {
return place;
}
public void setPlace(String place) {
this.place = place;
}
public int getRadius() {
return radius;
}
public void setRadius(int radius) {
this.radius = radius;
}
public boolean isArrival() {
return arrival;
}
public void setArrival(boolean arrival) {
this.arrival = arrival;
}
public boolean isDeparture() {
return departure;
}
public void setDeparture(boolean departure) {
this.departure = departure;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Geofence)) {
return false;
}
Geofence geofence = (Geofence) o;
return id == geofence.id
&& task == geofence.task
&& radius == geofence.radius
&& arrival == geofence.arrival
&& departure == geofence.departure
&& Objects.equals(place, geofence.place);
}
@Override
public int hashCode() {
return Objects.hash(id, task, place, radius, arrival, departure);
}
@Override
public String toString() {
return "Location{"
+ "id="
+ id
+ ", task="
+ task
+ ", place='"
+ place
+ '\''
+ ", radius="
+ radius
+ ", arrival="
+ arrival
+ ", departure="
+ departure
+ '}';
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeLong(id);
out.writeLong(task);
out.writeString(place);
out.writeInt(radius);
out.writeInt(arrival ? 1 : 0);
out.writeInt(departure ? 1 : 0);
}
}

@ -0,0 +1,134 @@
package org.tasks.data
import android.os.Parcel
import android.os.Parcelable
import androidx.room.*
import com.todoroo.andlib.data.Property.LongProperty
import com.todoroo.andlib.data.Property.StringProperty
import com.todoroo.andlib.data.Table
import org.tasks.R
import org.tasks.preferences.Preferences
import java.io.Serializable
@Entity(tableName = Geofence.TABLE_NAME, indices = [Index(name = "geo_task", value = ["task"])])
class Geofence : Serializable, Parcelable {
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "geofence_id")
@Transient
var id: Long = 0
@ColumnInfo(name = "task")
@Transient
var task: Long = 0
@ColumnInfo(name = "place")
var place: String? = null
@ColumnInfo(name = "radius")
var radius = 0
@ColumnInfo(name = "arrival")
var isArrival = false
@ColumnInfo(name = "departure")
var isDeparture = false
constructor()
@Ignore
constructor(task: Long, place: String?, arrival: Boolean, departure: Boolean, radius: Int) : this(place, arrival, departure, radius) {
this.task = task
}
@Ignore
constructor(place: String?, preferences: Preferences) {
this.place = place
val defaultReminders = preferences.getIntegerFromString(R.string.p_default_location_reminder_key, 1)
isArrival = defaultReminders == 1 || defaultReminders == 3
isDeparture = defaultReminders == 2 || defaultReminders == 3
radius = preferences.getInt(R.string.p_default_location_radius, 250)
}
@Ignore
constructor(place: String?, arrival: Boolean, departure: Boolean, radius: Int) {
this.place = place
isArrival = arrival
isDeparture = departure
this.radius = radius
}
@Ignore
constructor(o: Geofence) {
id = o.id
task = o.task
place = o.place
radius = o.radius
isArrival = o.isArrival
isDeparture = o.isDeparture
}
@Ignore
constructor(parcel: Parcel) {
id = parcel.readLong()
task = parcel.readLong()
place = parcel.readString()
radius = parcel.readInt()
isArrival = parcel.readInt() == 1
isDeparture = parcel.readInt() == 1
}
override fun describeContents() = 0
override fun writeToParcel(out: Parcel, flags: Int) {
out.writeLong(id)
out.writeLong(task)
out.writeString(place)
out.writeInt(radius)
out.writeInt(if (isArrival) 1 else 0)
out.writeInt(if (isDeparture) 1 else 0)
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is Geofence) return false
if (id != other.id) return false
if (task != other.task) return false
if (place != other.place) return false
if (radius != other.radius) return false
if (isArrival != other.isArrival) return false
if (isDeparture != other.isDeparture) return false
return true
}
override fun hashCode(): Int {
var result = id.hashCode()
result = 31 * result + task.hashCode()
result = 31 * result + (place?.hashCode() ?: 0)
result = 31 * result + radius
result = 31 * result + isArrival.hashCode()
result = 31 * result + isDeparture.hashCode()
return result
}
override fun toString(): String {
return "Geofence(id=$id, task=$task, place=$place, radius=$radius, isArrival=$isArrival, isDeparture=$isDeparture)"
}
companion object {
const val TABLE_NAME = "geofences"
@JvmField val TABLE = Table(TABLE_NAME)
@JvmField val TASK = LongProperty(TABLE, "task")
@JvmField val PLACE = StringProperty(TABLE, "place")
@JvmField val CREATOR: Parcelable.Creator<Geofence> = object : Parcelable.Creator<Geofence> {
override fun createFromParcel(source: Parcel): Geofence? {
return Geofence(source)
}
override fun newArray(size: Int): Array<Geofence?> {
return arrayOfNulls(size)
}
}
}
}

@ -1,227 +0,0 @@
package org.tasks.data;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.Index;
import androidx.room.PrimaryKey;
import com.todoroo.andlib.data.Property;
import com.todoroo.andlib.data.Table;
import java.util.Objects;
@Entity(
tableName = "google_tasks",
indices = {
@Index(name = "gt_task", value = "gt_task"),
@Index(
name = "gt_list_parent",
value = {"gt_list_id", "gt_parent"})
})
public class GoogleTask {
public static final String KEY = "gtasks"; // $NON-NLS-1$
public static final Table TABLE = new Table("google_tasks");
public static final Property.IntegerProperty PARENT =
new Property.IntegerProperty(TABLE, "gt_parent");
public static final Property.IntegerProperty TASK =
new Property.IntegerProperty(TABLE, "gt_task");
public static final Property.LongProperty DELETED =
new Property.LongProperty(TABLE, "gt_deleted");
public static final Property.StringProperty LIST =
new Property.StringProperty(TABLE, "gt_list_id");
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "gt_id")
private transient long id;
@ColumnInfo(name = "gt_task")
private transient long task;
@ColumnInfo(name = "gt_remote_id")
private String remoteId = "";
@ColumnInfo(name = "gt_list_id")
private String listId = "";
@ColumnInfo(name = "gt_parent")
private transient long parent;
@ColumnInfo(name = "gt_remote_parent")
private String remoteParent;
@ColumnInfo(name = "gt_moved")
private transient boolean moved;
@ColumnInfo(name = "gt_order")
private transient long order;
@ColumnInfo(name = "gt_remote_order")
private long remoteOrder;
@ColumnInfo(name = "gt_last_sync")
private long lastSync;
@ColumnInfo(name = "gt_deleted")
private long deleted;
public GoogleTask() {}
@Ignore
public GoogleTask(long task, String listId) {
this.task = task;
this.listId = listId;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public long getTask() {
return task;
}
public void setTask(long task) {
this.task = task;
}
public String getRemoteId() {
return remoteId;
}
public void setRemoteId(String remoteId) {
this.remoteId = remoteId;
}
public String getListId() {
return listId;
}
public void setListId(String listId) {
this.listId = listId;
}
public long getParent() {
return parent;
}
public void setParent(long parent) {
this.parent = parent;
}
public long getOrder() {
return order;
}
public void setOrder(long order) {
this.order = order;
}
public boolean isMoved() {
return moved;
}
public void setMoved(boolean moved) {
this.moved = moved;
}
public long getRemoteOrder() {
return remoteOrder;
}
public void setRemoteOrder(long remoteOrder) {
this.remoteOrder = remoteOrder;
}
public long getLastSync() {
return lastSync;
}
public void setLastSync(long lastSync) {
this.lastSync = lastSync;
}
public long getDeleted() {
return deleted;
}
public void setDeleted(long deleted) {
this.deleted = deleted;
}
public String getRemoteParent() {
return remoteParent;
}
public void setRemoteParent(String remoteParent) {
this.remoteParent = remoteParent;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof GoogleTask)) {
return false;
}
GoogleTask that = (GoogleTask) o;
return id == that.id
&& task == that.task
&& parent == that.parent
&& moved == that.moved
&& order == that.order
&& remoteOrder == that.remoteOrder
&& lastSync == that.lastSync
&& deleted == that.deleted
&& Objects.equals(remoteId, that.remoteId)
&& Objects.equals(listId, that.listId)
&& Objects.equals(remoteParent, that.remoteParent);
}
@Override
public int hashCode() {
return Objects
.hash(id, task, remoteId, listId, parent, remoteParent, moved, order, remoteOrder, lastSync,
deleted);
}
@Override
public String toString() {
return "GoogleTask{"
+ "id="
+ id
+ ", task="
+ task
+ ", remoteId='"
+ remoteId
+ '\''
+ ", listId='"
+ listId
+ '\''
+ ", parent="
+ parent
+ ", moved="
+ moved
+ ", order="
+ order
+ ", remoteParent='"
+ remoteParent
+ '\''
+ ", remoteOrder="
+ remoteOrder
+ ", lastSync="
+ lastSync
+ ", deleted="
+ deleted
+ '}';
}
}

@ -0,0 +1,105 @@
package org.tasks.data
import androidx.room.*
import com.todoroo.andlib.data.Property.*
import com.todoroo.andlib.data.Table
@Entity(tableName = "google_tasks",
indices = [
Index(name = "gt_task", value = ["gt_task"]),
Index(name = "gt_list_parent", value = ["gt_list_id", "gt_parent"])])
class GoogleTask {
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "gt_id")
@Transient
var id: Long = 0
@ColumnInfo(name = "gt_task")
@Transient
var task: Long = 0
@ColumnInfo(name = "gt_remote_id")
var remoteId: String? = ""
@ColumnInfo(name = "gt_list_id")
var listId: String? = ""
@ColumnInfo(name = "gt_parent")
@Transient
var parent: Long = 0
@ColumnInfo(name = "gt_remote_parent")
var remoteParent: String? = null
@ColumnInfo(name = "gt_moved")
@Transient
var isMoved = false
@ColumnInfo(name = "gt_order")
@Transient
var order: Long = 0
@ColumnInfo(name = "gt_remote_order")
var remoteOrder: Long = 0
@ColumnInfo(name = "gt_last_sync")
var lastSync: Long = 0
@ColumnInfo(name = "gt_deleted")
var deleted: Long = 0
constructor()
@Ignore
constructor(task: Long, listId: String) {
this.task = task
this.listId = listId
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is GoogleTask) return false
if (id != other.id) return false
if (task != other.task) return false
if (remoteId != other.remoteId) return false
if (listId != other.listId) return false
if (parent != other.parent) return false
if (remoteParent != other.remoteParent) return false
if (isMoved != other.isMoved) return false
if (order != other.order) return false
if (remoteOrder != other.remoteOrder) return false
if (lastSync != other.lastSync) return false
if (deleted != other.deleted) return false
return true
}
override fun hashCode(): Int {
var result = id.hashCode()
result = 31 * result + task.hashCode()
result = 31 * result + remoteId.hashCode()
result = 31 * result + listId.hashCode()
result = 31 * result + parent.hashCode()
result = 31 * result + (remoteParent?.hashCode() ?: 0)
result = 31 * result + isMoved.hashCode()
result = 31 * result + order.hashCode()
result = 31 * result + remoteOrder.hashCode()
result = 31 * result + lastSync.hashCode()
result = 31 * result + deleted.hashCode()
return result
}
override fun toString(): String {
return "GoogleTask(id=$id, task=$task, remoteId='$remoteId', listId='$listId', parent=$parent, remoteParent=$remoteParent, isMoved=$isMoved, order=$order, remoteOrder=$remoteOrder, lastSync=$lastSync, deleted=$deleted)"
}
companion object {
const val KEY = "gtasks"
@JvmField val TABLE = Table("google_tasks")
@JvmField val PARENT = IntegerProperty(TABLE, "gt_parent")
@JvmField val TASK = IntegerProperty(TABLE, "gt_task")
@JvmField val DELETED = LongProperty(TABLE, "gt_deleted")
@JvmField val LIST = StringProperty(TABLE, "gt_list_id")
}
}

@ -1,152 +0,0 @@
package org.tasks.data;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.core.os.ParcelCompat;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.PrimaryKey;
import java.util.Objects;
@Entity(tableName = "google_task_accounts")
public class GoogleTaskAccount implements Parcelable {
public static final Parcelable.Creator<GoogleTaskAccount> CREATOR =
new Parcelable.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 = "gta_id")
private transient long id;
@ColumnInfo(name = "gta_account")
private String account;
@ColumnInfo(name = "gta_error")
private transient String error = "";
@ColumnInfo(name = "gta_etag")
private String etag;
@ColumnInfo(name = "gta_collapsed")
private boolean collapsed;
public GoogleTaskAccount() {}
@Ignore
public GoogleTaskAccount(Parcel source) {
id = source.readLong();
account = source.readString();
error = source.readString();
etag = source.readString();
collapsed = ParcelCompat.readBoolean(source);
}
@Ignore
public GoogleTaskAccount(String account) {
this.account = account;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getError() {
return error;
}
public void setError(String error) {
this.error = error;
}
public String getEtag() {
return etag;
}
public void setEtag(String etag) {
this.etag = etag;
}
public boolean isCollapsed() {
return collapsed;
}
public void setCollapsed(boolean collapsed) {
this.collapsed = collapsed;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof GoogleTaskAccount)) {
return false;
}
GoogleTaskAccount that = (GoogleTaskAccount) o;
return id == that.id
&& collapsed == that.collapsed
&& Objects.equals(account, that.account)
&& Objects.equals(error, that.error)
&& Objects.equals(etag, that.etag);
}
@Override
public int hashCode() {
return Objects.hash(id, account, error, etag, collapsed);
}
@Override
public String toString() {
return "GoogleTaskAccount{"
+ "id="
+ id
+ ", account='"
+ account
+ '\''
+ ", error='"
+ error
+ '\''
+ ", etag='"
+ etag
+ '\''
+ ", collapsed="
+ collapsed
+ '}';
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(id);
dest.writeString(account);
dest.writeString(error);
dest.writeString(etag);
ParcelCompat.writeBoolean(dest, collapsed);
}
}

@ -0,0 +1,94 @@
package org.tasks.data
import android.os.Parcel
import android.os.Parcelable
import androidx.core.os.ParcelCompat
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.Ignore
import androidx.room.PrimaryKey
@Entity(tableName = "google_task_accounts")
class GoogleTaskAccount : Parcelable {
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "gta_id")
@Transient
var id: Long = 0
@ColumnInfo(name = "gta_account")
var account: String? = null
@ColumnInfo(name = "gta_error")
@Transient
var error: String? = ""
@ColumnInfo(name = "gta_etag")
var etag: String? = null
@ColumnInfo(name = "gta_collapsed")
var isCollapsed = false
constructor()
@Ignore
constructor(source: Parcel) {
id = source.readLong()
account = source.readString()
error = source.readString()
etag = source.readString()
isCollapsed = ParcelCompat.readBoolean(source)
}
@Ignore
constructor(account: String?) {
this.account = account
}
override fun describeContents() = 0
override fun writeToParcel(dest: Parcel, flags: Int) {
dest.writeLong(id)
dest.writeString(account)
dest.writeString(error)
dest.writeString(etag)
ParcelCompat.writeBoolean(dest, isCollapsed)
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is GoogleTaskAccount) return false
if (id != other.id) return false
if (account != other.account) return false
if (error != other.error) return false
if (etag != other.etag) return false
if (isCollapsed != other.isCollapsed) return false
return true
}
override fun hashCode(): Int {
var result = id.hashCode()
result = 31 * result + (account?.hashCode() ?: 0)
result = 31 * result + (error?.hashCode() ?: 0)
result = 31 * result + (etag?.hashCode() ?: 0)
result = 31 * result + isCollapsed.hashCode()
return result
}
override fun toString(): String {
return "GoogleTaskAccount(id=$id, account=$account, error=$error, etag=$etag, isCollapsed=$isCollapsed)"
}
companion object {
@JvmField val CREATOR: Parcelable.Creator<GoogleTaskAccount> = object : Parcelable.Creator<GoogleTaskAccount> {
override fun createFromParcel(source: Parcel): GoogleTaskAccount? {
return GoogleTaskAccount(source)
}
override fun newArray(size: Int): Array<GoogleTaskAccount?> {
return arrayOfNulls(size)
}
}
}
}

@ -1,196 +0,0 @@
package org.tasks.data;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.PrimaryKey;
import java.util.Objects;
import org.tasks.themes.CustomIcons;
@Entity(tableName = "google_task_lists")
public class GoogleTaskList implements Parcelable {
public static final Parcelable.Creator<GoogleTaskList> CREATOR =
new Parcelable.Creator<GoogleTaskList>() {
@Override
public GoogleTaskList createFromParcel(Parcel parcel) {
return new GoogleTaskList(parcel);
}
@Override
public GoogleTaskList[] newArray(int size) {
return new GoogleTaskList[size];
}
};
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "gtl_id")
private transient long id;
@ColumnInfo(name = "gtl_account")
private String account;
@ColumnInfo(name = "gtl_remote_id")
private String remoteId;
@ColumnInfo(name = "gtl_title")
private String title;
@ColumnInfo(name = "gtl_remote_order")
private int remoteOrder;
@ColumnInfo(name = "gtl_last_sync")
private long lastSync;
@ColumnInfo(name = "gtl_color")
private Integer color;
@ColumnInfo(name = "gtl_icon")
private Integer icon = -1;
public GoogleTaskList() {}
@Ignore
public GoogleTaskList(Parcel parcel) {
id = parcel.readLong();
account = parcel.readString();
remoteId = parcel.readString();
title = parcel.readString();
remoteOrder = parcel.readInt();
lastSync = parcel.readLong();
color = parcel.readInt();
icon = parcel.readInt();
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getRemoteId() {
return remoteId;
}
public void setRemoteId(String remoteId) {
this.remoteId = remoteId;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public int getRemoteOrder() {
return remoteOrder;
}
public void setRemoteOrder(int remoteOrder) {
this.remoteOrder = remoteOrder;
}
public long getLastSync() {
return lastSync;
}
public void setLastSync(long lastSync) {
this.lastSync = lastSync;
}
public Integer getColor() {
return color == null ? 0 : color;
}
public void setColor(Integer color) {
this.color = color;
}
public Integer getIcon() {
return icon == null ? CustomIcons.getCLOUD() : icon;
}
public void setIcon(Integer icon) {
this.icon = icon;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel parcel, int i) {
parcel.writeLong(id);
parcel.writeString(account);
parcel.writeString(remoteId);
parcel.writeString(title);
parcel.writeInt(remoteOrder);
parcel.writeLong(lastSync);
parcel.writeInt(getColor());
parcel.writeInt(getIcon());
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof GoogleTaskList)) {
return false;
}
GoogleTaskList that = (GoogleTaskList) o;
return id == that.id
&& remoteOrder == that.remoteOrder
&& lastSync == that.lastSync
&& Objects.equals(account, that.account)
&& Objects.equals(remoteId, that.remoteId)
&& Objects.equals(title, that.title)
&& Objects.equals(color, that.color)
&& Objects.equals(icon, that.icon);
}
@Override
public int hashCode() {
return Objects.hash(id, account, remoteId, title, remoteOrder, lastSync, color, icon);
}
@Override
public String toString() {
return "GoogleTaskList{"
+ "id="
+ id
+ ", account='"
+ account
+ '\''
+ ", remoteId='"
+ remoteId
+ '\''
+ ", title='"
+ title
+ '\''
+ ", remoteOrder="
+ remoteOrder
+ ", lastSync="
+ lastSync
+ ", color="
+ color
+ ", icon="
+ icon
+ '}';
}
}

@ -0,0 +1,125 @@
package org.tasks.data
import android.os.Parcel
import android.os.Parcelable
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.Ignore
import androidx.room.PrimaryKey
import org.tasks.themes.CustomIcons.CLOUD
@Entity(tableName = "google_task_lists")
class GoogleTaskList : Parcelable {
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "gtl_id")
@Transient
var id: Long = 0
@ColumnInfo(name = "gtl_account")
var account: String? = null
@ColumnInfo(name = "gtl_remote_id")
var remoteId: String? = null
@ColumnInfo(name = "gtl_title")
var title: String? = null
@ColumnInfo(name = "gtl_remote_order")
var remoteOrder = 0
@ColumnInfo(name = "gtl_last_sync")
var lastSync: Long = 0
@ColumnInfo(name = "gtl_color")
private var color: Int? = null
@ColumnInfo(name = "gtl_icon")
private var icon: Int? = -1
constructor()
@Ignore
constructor(parcel: Parcel) {
id = parcel.readLong()
account = parcel.readString()
remoteId = parcel.readString()
title = parcel.readString()
remoteOrder = parcel.readInt()
lastSync = parcel.readLong()
color = parcel.readInt()
icon = parcel.readInt()
}
fun getColor(): Int? {
return (if (color == null) 0 else color)!!
}
fun setColor(color: Int?) {
this.color = color
}
fun getIcon(): Int? {
return (if (icon == null) CLOUD else icon!!)
}
fun setIcon(icon: Int?) {
this.icon = icon
}
override fun describeContents() = 0
override fun writeToParcel(parcel: Parcel, i: Int) {
parcel.writeLong(id)
parcel.writeString(account)
parcel.writeString(remoteId)
parcel.writeString(title)
parcel.writeInt(remoteOrder)
parcel.writeLong(lastSync)
parcel.writeInt(getColor()!!)
parcel.writeInt(getIcon()!!)
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is GoogleTaskList) return false
if (id != other.id) return false
if (account != other.account) return false
if (remoteId != other.remoteId) return false
if (title != other.title) return false
if (remoteOrder != other.remoteOrder) return false
if (lastSync != other.lastSync) return false
if (color != other.color) return false
if (icon != other.icon) return false
return true
}
override fun hashCode(): Int {
var result = id.hashCode()
result = 31 * result + (account?.hashCode() ?: 0)
result = 31 * result + (remoteId?.hashCode() ?: 0)
result = 31 * result + (title?.hashCode() ?: 0)
result = 31 * result + remoteOrder
result = 31 * result + lastSync.hashCode()
result = 31 * result + (color ?: 0)
result = 31 * result + (icon ?: 0)
return result
}
override fun toString(): String {
return "GoogleTaskList(id=$id, account=$account, remoteId=$remoteId, title=$title, remoteOrder=$remoteOrder, lastSync=$lastSync, color=$color, icon=$icon)"
}
companion object {
@JvmField val CREATOR: Parcelable.Creator<GoogleTaskList> = object : Parcelable.Creator<GoogleTaskList> {
override fun createFromParcel(parcel: Parcel): GoogleTaskList? {
return GoogleTaskList(parcel)
}
override fun newArray(size: Int): Array<GoogleTaskList?> {
return arrayOfNulls(size)
}
}
}
}

@ -1,124 +0,0 @@
package org.tasks.data;
import android.content.Context;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.annotation.Nullable;
import androidx.room.Embedded;
import androidx.room.Ignore;
import java.io.Serializable;
import java.util.Objects;
public class Location implements Serializable, Parcelable {
public static final Parcelable.Creator<Location> CREATOR =
new Parcelable.Creator<Location>() {
@Override
public Location createFromParcel(Parcel in) {
return new Location(in);
}
@Override
public Location[] newArray(int size) {
return new Location[size];
}
};
@Embedded public Geofence geofence;
@Embedded public Place place;
public Location() {}
@Ignore
public Location(Geofence geofence, Place place) {
this.geofence = geofence;
this.place = place;
}
@Ignore
private Location(Parcel in) {
geofence = in.readParcelable(Geofence.class.getClassLoader());
place = in.readParcelable(Place.class.getClassLoader());
}
public long getTask() {
return geofence.getTask();
}
public double getLatitude() {
return place.getLatitude();
}
public double getLongitude() {
return place.getLongitude();
}
public int getRadius() {
return geofence.getRadius();
}
public String getPhone() {
return place.getPhone();
}
public String getUrl() {
return place.getUrl();
}
public boolean isArrival() {
return geofence.isArrival();
}
public boolean isDeparture() {
return geofence.isDeparture();
}
public String getDisplayName() {
return place.getDisplayName();
}
public String getDisplayAddress() {
return place.getDisplayAddress();
}
public void open(@Nullable Context context) {
place.open(context);
}
@Override
public String toString() {
return "Location{" + "geofence=" + geofence + ", place=" + place + '}';
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Location)) {
return false;
}
Location location = (Location) o;
return Objects.equals(geofence, location.geofence) && Objects.equals(place, location.place);
}
@Override
public int hashCode() {
return Objects.hash(geofence, place);
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(geofence, flags);
dest.writeParcelable(place, flags);
}
public Place getPlace() {
return place;
}
}

@ -0,0 +1,100 @@
package org.tasks.data
import android.content.Context
import android.os.Parcel
import android.os.Parcelable
import androidx.room.Embedded
import androidx.room.Ignore
import java.io.Serializable
class Location : Serializable, Parcelable {
@Embedded lateinit var geofence: Geofence
@Embedded lateinit var place: Place
constructor()
@Ignore
constructor(geofence: Geofence, place: Place) {
this.geofence = geofence
this.place = place
}
@Ignore
private constructor(parcel: Parcel) {
geofence = parcel.readParcelable(Geofence::class.java.classLoader)!!
place = parcel.readParcelable(Place::class.java.classLoader)!!
}
val task: Long
get() = geofence.task
val latitude: Double
get() = place.latitude
val longitude: Double
get() = place.longitude
val radius: Int
get() = geofence.radius
val phone: String
get() = place.phone
val url: String
get() = place.url
val isArrival: Boolean
get() = geofence.isArrival
val isDeparture: Boolean
get() = geofence.isDeparture
val displayName: String
get() = place.displayName
val displayAddress: String
get() = place.displayAddress
fun open(context: Context?) {
place.open(context)
}
override fun describeContents() = 0
override fun writeToParcel(dest: Parcel, flags: Int) {
dest.writeParcelable(geofence, flags)
dest.writeParcelable(place, flags)
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is Location) return false
if (geofence != other.geofence) return false
if (place != other.place) return false
return true
}
override fun hashCode(): Int {
var result = geofence.hashCode()
result = 31 * result + place.hashCode()
return result
}
override fun toString(): String {
return "Location(geofence=$geofence, place=$place)"
}
companion object {
@JvmField val CREATOR: Parcelable.Creator<Location> = object : Parcelable.Creator<Location> {
override fun createFromParcel(`in`: Parcel): Location? {
return Location(`in`)
}
override fun newArray(size: Int): Array<Location?> {
return arrayOfNulls(size)
}
}
}
}

@ -1,48 +0,0 @@
package org.tasks.data;
import androidx.room.Embedded;
public class MergedGeofence {
@Embedded Place place;
boolean arrival;
boolean departure;
int radius;
public String getUid() {
return place.getUid();
}
public double getLatitude() {
return place.getLatitude();
}
public double getLongitude() {
return place.getLongitude();
}
public boolean isArrival() {
return arrival;
}
public boolean isDeparture() {
return departure;
}
public int getRadius() {
return radius;
}
@Override
public String toString() {
return "MergedGeofence{"
+ "place="
+ place.getDisplayName()
+ ", arrival="
+ arrival
+ ", departure="
+ departure
+ ", radius="
+ radius
+ '}';
}
}

@ -0,0 +1,23 @@
package org.tasks.data
import androidx.room.Embedded
class MergedGeofence {
@Embedded lateinit var place: Place
var arrival = false
var departure = false
var radius = 0
val uid: String
get() = place.uid
val latitude: Double
get() = place.latitude
val longitude: Double
get() = place.longitude
override fun toString(): String {
return "MergedGeofence(place=$place, arrival=$arrival, departure=$departure, radius=$radius)"
}
}

@ -1,43 +0,0 @@
package org.tasks.data;
import androidx.room.Embedded;
import java.util.Objects;
public class PlaceUsage {
@Embedded public Place place;
public int count;
public Place getPlace() {
return place;
}
public int getColor() {
return place.getColor();
}
public int getIcon() {
return place.getIcon();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof PlaceUsage)) {
return false;
}
PlaceUsage that = (PlaceUsage) o;
return count == that.count && Objects.equals(place, that.place);
}
@Override
public int hashCode() {
return Objects.hash(place, count);
}
@Override
public String toString() {
return "PlaceUsage{" + "place=" + place + ", count=" + count + '}';
}
}

@ -0,0 +1,34 @@
package org.tasks.data
import androidx.room.Embedded
class PlaceUsage {
@Embedded lateinit var place: Place
var count = 0
val color: Int
get() = place.color
val icon: Int
get() = place.icon
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is PlaceUsage) return false
if (place != other.place) return false
if (count != other.count) return false
return true
}
override fun hashCode(): Int {
var result = place.hashCode()
result = 31 * result + count
return result
}
override fun toString(): String {
return "PlaceUsage(place=$place, count=$count)"
}
}

@ -1,109 +0,0 @@
package org.tasks.data;
import androidx.annotation.NonNull;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.Index;
import androidx.room.PrimaryKey;
import com.todoroo.andlib.data.Property.LongProperty;
import com.todoroo.andlib.data.Property.StringProperty;
import com.todoroo.andlib.data.Table;
import com.todoroo.astrid.data.Task;
import org.tasks.backup.XmlReader;
@Entity(tableName = "tags", indices = @Index(name = "tag_task", value = "task"))
public class Tag {
public static final String KEY = "tags-tag"; // $NON-NLS-1$
public static final Table TABLE = new Table("tags");
public static final LongProperty TASK = new LongProperty(TABLE, "task");
public static final StringProperty TAG_UID = new StringProperty(TABLE, "tag_uid");
public static final StringProperty NAME = new StringProperty(TABLE, "name");
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "_id")
private transient long id;
@ColumnInfo(name = "task")
private transient long task;
@ColumnInfo(name = "name")
private String name;
@ColumnInfo(name = "tag_uid")
private String tagUid;
@ColumnInfo(name = "task_uid")
private transient String taskUid;
public Tag() {}
@Ignore
public Tag(Task task, TagData tagData) {
this(task, tagData.getName(), tagData.getRemoteId());
}
@Ignore
public Tag(Task task, String name, String tagUid) {
this(task.getId(), task.getUuid(), name, tagUid);
}
@Ignore
public Tag(long taskId, String taskUid, String name, String tagUid) {
this.task = taskId;
this.taskUid = taskUid;
this.name = name;
this.tagUid = tagUid;
}
@Ignore
public Tag(XmlReader xmlReader) {
xmlReader.readString("name", this::setName);
xmlReader.readString("tag_uid", this::setTagUid);
xmlReader.readString("task_uid", this::setTaskUid);
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public long getTask() {
return task;
}
public void setTask(long task) {
this.task = task;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getTagUid() {
return tagUid;
}
public void setTagUid(String tagUid) {
this.tagUid = tagUid;
}
@NonNull
public String getTaskUid() {
return taskUid;
}
public void setTaskUid(@NonNull String taskUid) {
this.taskUid = taskUid;
}
}

@ -0,0 +1,69 @@
package org.tasks.data
import androidx.room.*
import com.todoroo.andlib.data.Property.LongProperty
import com.todoroo.andlib.data.Property.StringProperty
import com.todoroo.andlib.data.Table
import com.todoroo.astrid.data.Task
import org.tasks.backup.XmlReader
@Entity(tableName = "tags", indices = [Index(name = "tag_task", value = ["task"])])
class Tag {
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "_id")
@Transient
var id: Long = 0
@ColumnInfo(name = "task")
@Transient
var task: Long = 0
@ColumnInfo(name = "name")
var name: String? = null
@ColumnInfo(name = "tag_uid")
var tagUid: String? = null
@ColumnInfo(name = "task_uid")
@Transient
private var taskUid: String? = null
constructor()
@Ignore
constructor(task: Task, tagData: TagData) : this(task, tagData.name, tagData.remoteId)
@Ignore
constructor(task: Task, name: String?, tagUid: String?) : this(task.getId(), task.uuid, name, tagUid)
@Ignore
constructor(taskId: Long, taskUid: String?, name: String?, tagUid: String?) {
task = taskId
this.taskUid = taskUid
this.name = name
this.tagUid = tagUid
}
@Ignore
constructor(xmlReader: XmlReader) {
xmlReader.readString("name") { name: String? -> this.name = name }
xmlReader.readString("tag_uid") { tagUid: String? -> this.tagUid = tagUid }
xmlReader.readString("task_uid") { taskUid: String -> setTaskUid(taskUid) }
}
fun getTaskUid(): String {
return taskUid!!
}
fun setTaskUid(taskUid: String) {
this.taskUid = taskUid
}
companion object {
const val KEY = "tags-tag" // $NON-NLS-1$
@JvmField val TABLE = Table("tags")
@JvmField val TASK = LongProperty(TABLE, "task")
@JvmField val TAG_UID = StringProperty(TABLE, "tag_uid")
@JvmField val NAME = StringProperty(TABLE, "name")
}
}

@ -1,181 +0,0 @@
package org.tasks.data;
import android.annotation.SuppressLint;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.PrimaryKey;
import com.todoroo.astrid.data.Task;
import java.util.Objects;
import org.tasks.backup.XmlReader;
import org.tasks.themes.CustomIcons;
@Entity(tableName = "tagdata")
public final class TagData implements Parcelable {
public static final Parcelable.Creator<TagData> CREATOR =
new Parcelable.Creator<TagData>() {
@Override
public TagData createFromParcel(Parcel source) {
return new TagData(source);
}
@Override
public TagData[] newArray(int size) {
return new TagData[size];
}
};
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "_id")
private transient Long id;
@ColumnInfo(name = "remoteId")
private String remoteId = Task.NO_UUID;
@ColumnInfo(name = "name")
private String name = "";
@ColumnInfo(name = "color")
private Integer color = 0;
@ColumnInfo(name = "tagOrdering")
private String tagOrdering = "[]";
@ColumnInfo(name = "td_icon")
private Integer icon = -1;
@Ignore
public TagData(String name) {
this.name = name;
}
public TagData() {}
@Ignore
public TagData(XmlReader reader) {
reader.readString("remoteId", this::setRemoteId);
reader.readString("name", this::setName);
reader.readInteger("color", this::setColor);
reader.readString("tagOrdering", this::setTagOrdering);
}
@SuppressLint("ParcelClassLoader")
@Ignore
private TagData(Parcel parcel) {
id = (Long) parcel.readValue(null);
remoteId = parcel.readString();
name = parcel.readString();
color = parcel.readInt();
tagOrdering = parcel.readString();
icon = parcel.readInt();
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getRemoteId() {
return remoteId;
}
public void setRemoteId(String remoteId) {
this.remoteId = remoteId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getTagOrdering() {
return tagOrdering;
}
public void setTagOrdering(String tagOrdering) {
this.tagOrdering = tagOrdering;
}
public Integer getColor() {
return color == null ? 0 : color;
}
public void setColor(Integer color) {
this.color = color;
}
public Integer getIcon() {
return icon == null ? CustomIcons.getLABEL() : icon;
}
public void setIcon(Integer icon) {
this.icon = icon;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeValue(id);
dest.writeString(remoteId);
dest.writeString(name);
dest.writeInt(color);
dest.writeString(tagOrdering);
dest.writeInt(getIcon());
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof TagData)) {
return false;
}
TagData tagData = (TagData) o;
return Objects.equals(id, tagData.id)
&& Objects.equals(remoteId, tagData.remoteId)
&& Objects.equals(name, tagData.name)
&& Objects.equals(color, tagData.color)
&& Objects.equals(tagOrdering, tagData.tagOrdering)
&& Objects.equals(icon, tagData.icon);
}
@Override
public int hashCode() {
return Objects.hash(id, remoteId, name, color, tagOrdering, icon);
}
@Override
public String toString() {
return "TagData{"
+ "id="
+ id
+ ", remoteId='"
+ remoteId
+ '\''
+ ", name='"
+ name
+ '\''
+ ", color="
+ color
+ ", icon="
+ icon
+ ", tagOrdering='"
+ tagOrdering
+ '\''
+ '}';
}
}

@ -0,0 +1,128 @@
package org.tasks.data
import android.annotation.SuppressLint
import android.os.Parcel
import android.os.Parcelable
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.Ignore
import androidx.room.PrimaryKey
import com.todoroo.astrid.data.Task
import org.tasks.backup.XmlReader
import org.tasks.themes.CustomIcons.LABEL
@Entity(tableName = "tagdata")
class TagData : Parcelable {
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "_id")
@Transient
var id: Long? = null
@ColumnInfo(name = "remoteId")
var remoteId: String? = Task.NO_UUID
@ColumnInfo(name = "name")
var name: String? = ""
@ColumnInfo(name = "color")
private var color: Int? = 0
@ColumnInfo(name = "tagOrdering")
var tagOrdering: String? = "[]"
@ColumnInfo(name = "td_icon")
private var icon: Int? = -1
@Ignore
constructor(name: String?) {
this.name = name
}
constructor()
@Ignore
constructor(reader: XmlReader) {
reader.readString("remoteId") { remoteId: String? -> this.remoteId = remoteId }
reader.readString("name") { name: String? -> this.name = name }
reader.readInteger("color") { color: Int? -> setColor(color) }
reader.readString("tagOrdering") { tagOrdering: String? -> this.tagOrdering = tagOrdering }
}
@SuppressLint("ParcelClassLoader")
@Ignore
private constructor(parcel: Parcel) {
id = parcel.readValue(null) as Long?
remoteId = parcel.readString()
name = parcel.readString()
color = parcel.readInt()
tagOrdering = parcel.readString()
icon = parcel.readInt()
}
fun getColor(): Int? {
return (if (color == null) 0 else color)!!
}
fun setColor(color: Int?) {
this.color = color
}
fun getIcon(): Int? {
return (if (icon == null) LABEL else icon!!)
}
fun setIcon(icon: Int?) {
this.icon = icon
}
override fun describeContents() = 0
override fun writeToParcel(dest: Parcel, flags: Int) {
dest.writeValue(id)
dest.writeString(remoteId)
dest.writeString(name)
dest.writeInt(color!!)
dest.writeString(tagOrdering)
dest.writeInt(getIcon()!!)
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is TagData) return false
if (id != other.id) return false
if (remoteId != other.remoteId) return false
if (name != other.name) return false
if (color != other.color) return false
if (tagOrdering != other.tagOrdering) return false
if (icon != other.icon) return false
return true
}
override fun hashCode(): Int {
var result = id?.hashCode() ?: 0
result = 31 * result + (remoteId?.hashCode() ?: 0)
result = 31 * result + (name?.hashCode() ?: 0)
result = 31 * result + (color ?: 0)
result = 31 * result + (tagOrdering?.hashCode() ?: 0)
result = 31 * result + (icon ?: 0)
return result
}
override fun toString(): String {
return "TagData(id=$id, remoteId=$remoteId, name=$name, color=$color, tagOrdering=$tagOrdering, icon=$icon)"
}
companion object {
@JvmField val CREATOR: Parcelable.Creator<TagData> = object : Parcelable.Creator<TagData> {
override fun createFromParcel(source: Parcel): TagData? {
return TagData(source)
}
override fun newArray(size: Int): Array<TagData?> {
return arrayOfNulls(size)
}
}
}
}

@ -1,112 +0,0 @@
package org.tasks.data;
import static org.tasks.Strings.isNullOrEmpty;
import android.net.Uri;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.PrimaryKey;
import com.todoroo.andlib.data.Table;
import com.todoroo.astrid.data.Task;
import java.io.File;
@Entity(tableName = "task_attachments")
public final class TaskAttachment {
@Deprecated public static final Table TABLE = new Table("task_attachments");
public static final String KEY = "attachment";
/** default directory for files on external storage */
public static final String FILES_DIRECTORY_DEFAULT = "attachments"; // $NON-NLS-1$
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "_id")
private transient Long id;
@ColumnInfo(name = "remoteId")
private String remoteId = Task.NO_UUID;
// -- Constants
@ColumnInfo(name = "task_id")
private String taskId = Task.NO_UUID;
@ColumnInfo(name = "name")
private String name = "";
@ColumnInfo(name = "path")
private String uri = "";
@ColumnInfo(name = "content_type")
private String contentType = "";
public TaskAttachment() {}
@Ignore
public TaskAttachment(String taskUuid, Uri uri, String fileName) {
taskId = taskUuid;
name = fileName;
setUri(uri);
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getRemoteId() {
return remoteId;
}
public void setRemoteId(String remoteId) {
this.remoteId = remoteId;
}
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getUri() {
return uri;
}
public void setUri(Uri uri) {
setUri(uri == null ? null : uri.toString());
}
public void setUri(String uri) {
this.uri = uri;
}
public String getContentType() {
return contentType;
}
public void setContentType(String contentType) {
this.contentType = contentType;
}
public void convertPathUri() {
setUri(Uri.fromFile(new File(uri)).toString());
}
public Uri parseUri() {
return isNullOrEmpty(uri) ? null : Uri.parse(uri);
}
}

@ -0,0 +1,63 @@
package org.tasks.data
import android.net.Uri
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.Ignore
import androidx.room.PrimaryKey
import com.todoroo.astrid.data.Task
import org.tasks.Strings
import java.io.File
@Entity(tableName = "task_attachments")
class TaskAttachment {
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "_id")
@Transient
var id: Long? = null
@ColumnInfo(name = "remoteId")
var remoteId: String? = Task.NO_UUID
// -- Constants
@ColumnInfo(name = "task_id")
var taskId: String? = Task.NO_UUID
@ColumnInfo(name = "name")
var name: String? = ""
@ColumnInfo(name = "path")
var uri: String? = ""
private set
@ColumnInfo(name = "content_type")
var contentType: String? = ""
constructor()
@Ignore
constructor(taskUuid: String, uri: Uri?, fileName: String) {
taskId = taskUuid
name = fileName
setUri(uri?.toString())
}
fun setUri(uri: String?) {
this.uri = uri
}
fun convertPathUri() {
setUri(Uri.fromFile(File(uri)).toString())
}
fun parseUri(): Uri? {
return if (Strings.isNullOrEmpty(uri)) null else Uri.parse(uri)
}
companion object {
const val KEY = "attachment"
/** default directory for files on external storage */
const val FILES_DIRECTORY_DEFAULT = "attachments" // $NON-NLS-1$
}
}

@ -1,74 +0,0 @@
package org.tasks.data;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.PrimaryKey;
import com.todoroo.astrid.data.Task;
/**
* Data Model which represents a user.
*
* @author Tim Su <tim@todoroo.com>
*/
@Entity(tableName = "task_list_metadata")
public class TaskListMetadata {
public static final String FILTER_ID_ALL = "all";
public static final String FILTER_ID_TODAY = "today";
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "_id")
private Long id;
@ColumnInfo(name = "remoteId")
private String remoteId = Task.NO_UUID;
@ColumnInfo(name = "tag_uuid")
private String tagUuid = Task.NO_UUID;
@ColumnInfo(name = "filter")
private String filter = "";
@ColumnInfo(name = "task_ids")
private String taskIds = "[]";
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getRemoteId() {
return remoteId;
}
public void setRemoteId(String remoteId) {
this.remoteId = remoteId;
}
public String getTagUuid() {
return tagUuid;
}
public void setTagUuid(String tagUuid) {
this.tagUuid = tagUuid;
}
public String getFilter() {
return filter;
}
public void setFilter(String filter) {
this.filter = filter;
}
public String getTaskIds() {
return taskIds;
}
public void setTaskIds(String taskIds) {
this.taskIds = taskIds;
}
}

@ -0,0 +1,35 @@
package org.tasks.data
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
import com.todoroo.astrid.data.Task
/**
* Data Model which represents a user.
*
* @author Tim Su <tim></tim>@todoroo.com>
*/
@Entity(tableName = "task_list_metadata")
class TaskListMetadata {
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "_id")
var id: Long? = null
@ColumnInfo(name = "remoteId")
var remoteId: String? = Task.NO_UUID
@ColumnInfo(name = "tag_uuid")
var tagUuid: String? = Task.NO_UUID
@ColumnInfo(name = "filter")
var filter: String? = ""
@ColumnInfo(name = "task_ids")
var taskIds: String? = "[]"
companion object {
const val FILTER_ID_ALL = "all"
const val FILTER_ID_TODAY = "today"
}
}

@ -1,176 +0,0 @@
package org.tasks.data;
import static org.tasks.Strings.isNullOrEmpty;
import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.PrimaryKey;
import com.todoroo.astrid.data.Task;
import java.io.File;
import org.json.JSONException;
import org.json.JSONObject;
import org.tasks.backup.XmlReader;
import timber.log.Timber;
@Entity(tableName = "userActivity")
public class UserActivity implements Parcelable {
public static final Parcelable.Creator<UserActivity> CREATOR =
new Parcelable.Creator<UserActivity>() {
@Override
public UserActivity createFromParcel(Parcel source) {
return new UserActivity(source);
}
@Override
public UserActivity[] newArray(int size) {
return new UserActivity[size];
}
};
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "_id")
private transient Long id;
@ColumnInfo(name = "remoteId")
private String remoteId = Task.NO_UUID;
@ColumnInfo(name = "message")
private String message = "";
@ColumnInfo(name = "picture")
private String picture = "";
@ColumnInfo(name = "target_id")
private transient String targetId = Task.NO_UUID;
@ColumnInfo(name = "created_at")
private Long created = 0L;
public UserActivity() {}
@Ignore
public UserActivity(XmlReader reader) {
reader.readString("remoteId", this::setRemoteId);
reader.readString("message", this::setMessage);
reader.readString(
"picture",
p -> {
setPicture(p);
convertPictureUri();
});
reader.readString("target_id", this::setTargetId);
reader.readLong("created_at", this::setCreated);
}
@Ignore
private UserActivity(Parcel parcel) {
id = parcel.readLong();
remoteId = parcel.readString();
message = parcel.readString();
picture = parcel.readString();
targetId = parcel.readString();
created = parcel.readLong();
}
private static Uri getLegacyPictureUri(String value) {
try {
if (isNullOrEmpty(value)) {
return null;
}
if (value.contains("uri") || value.contains("path")) {
JSONObject json = new JSONObject(value);
if (json.has("uri")) {
return Uri.parse(json.getString("uri"));
}
if (json.has("path")) {
String path = json.getString("path");
return Uri.fromFile(new File(path));
}
}
return null;
} catch (JSONException e) {
Timber.e(e);
return null;
}
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getRemoteId() {
return remoteId;
}
public void setRemoteId(String remoteId) {
this.remoteId = remoteId;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getPicture() {
return picture;
}
public void setPicture(String picture) {
this.picture = picture;
}
public void setPicture(Uri uri) {
picture = uri == null ? null : uri.toString();
}
public String getTargetId() {
return targetId;
}
public void setTargetId(String targetId) {
this.targetId = targetId;
}
public Long getCreated() {
return created;
}
public void setCreated(Long created) {
this.created = created;
}
public Uri getPictureUri() {
return isNullOrEmpty(picture) ? null : Uri.parse(picture);
}
public void convertPictureUri() {
setPicture(getLegacyPictureUri(picture));
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(id);
dest.writeString(remoteId);
dest.writeString(message);
dest.writeString(picture);
dest.writeString(targetId);
dest.writeLong(created);
}
}

@ -0,0 +1,120 @@
package org.tasks.data
import android.net.Uri
import android.os.Parcel
import android.os.Parcelable
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.Ignore
import androidx.room.PrimaryKey
import com.todoroo.astrid.data.Task
import org.json.JSONException
import org.json.JSONObject
import org.tasks.Strings
import org.tasks.backup.XmlReader
import timber.log.Timber
import java.io.File
@Entity(tableName = "userActivity")
class UserActivity : Parcelable {
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "_id")
@Transient
var id: Long? = null
@ColumnInfo(name = "remoteId")
var remoteId: String? = Task.NO_UUID
@ColumnInfo(name = "message")
var message: String? = ""
@ColumnInfo(name = "picture")
var picture: String? = ""
@ColumnInfo(name = "target_id")
@Transient
var targetId: String? = Task.NO_UUID
@ColumnInfo(name = "created_at")
var created: Long? = 0L
constructor()
@Ignore
constructor(reader: XmlReader) {
reader.readString("remoteId") { remoteId: String? -> this.remoteId = remoteId }
reader.readString("message") { message: String? -> this.message = message }
reader.readString("picture") { p: String? ->
picture = p
convertPictureUri()
}
reader.readString("target_id") { targetId: String? -> this.targetId = targetId }
reader.readLong("created_at") { created: Long -> this.created = created }
}
@Ignore
private constructor(parcel: Parcel) {
id = parcel.readLong()
remoteId = parcel.readString()
message = parcel.readString()
picture = parcel.readString()
targetId = parcel.readString()
created = parcel.readLong()
}
fun setPicture(uri: Uri?) {
picture = uri?.toString()
}
val pictureUri: Uri?
get() = if (Strings.isNullOrEmpty(picture)) null else Uri.parse(picture)
fun convertPictureUri() {
setPicture(getLegacyPictureUri(picture))
}
override fun describeContents() = 0
override fun writeToParcel(dest: Parcel, flags: Int) {
dest.writeLong(id!!)
dest.writeString(remoteId)
dest.writeString(message)
dest.writeString(picture)
dest.writeString(targetId)
dest.writeLong(created!!)
}
companion object {
@JvmField val CREATOR: Parcelable.Creator<UserActivity> = object : Parcelable.Creator<UserActivity> {
override fun createFromParcel(source: Parcel): UserActivity? {
return UserActivity(source)
}
override fun newArray(size: Int): Array<UserActivity?> {
return arrayOfNulls(size)
}
}
private fun getLegacyPictureUri(value: String?): Uri? {
return try {
if (Strings.isNullOrEmpty(value)) {
return null
}
if (value!!.contains("uri") || value.contains("path")) {
val json = JSONObject(value)
if (json.has("uri")) {
return Uri.parse(json.getString("uri"))
}
if (json.has("path")) {
val path = json.getString("path")
return Uri.fromFile(File(path))
}
}
null
} catch (e: JSONException) {
Timber.e(e)
null
}
}
}
}

@ -34,9 +34,9 @@ public class AlarmEntry implements NotificationQueueEntry {
@Override
public Notification toNotification() {
Notification notification = new Notification();
notification.taskId = taskId;
notification.type = ReminderService.TYPE_ALARM;
notification.timestamp = currentTimeMillis();
notification.setTaskId(taskId);
notification.setType(ReminderService.TYPE_ALARM);
notification.setTimestamp(currentTimeMillis());
return notification;
}

@ -29,9 +29,9 @@ public class ReminderEntry implements NotificationQueueEntry {
@Override
public Notification toNotification() {
Notification notification = new Notification();
notification.taskId = taskId;
notification.type = type;
notification.timestamp = currentTimeMillis();
notification.setTaskId(taskId);
notification.setType(type);
notification.setTimestamp(currentTimeMillis());
return notification;
}

@ -1,51 +0,0 @@
package org.tasks.notifications;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.Index;
import androidx.room.PrimaryKey;
import com.todoroo.andlib.data.Property.LongProperty;
import com.todoroo.andlib.data.Table;
@Entity(
tableName = Notification.TABLE_NAME,
indices = {@Index(value = "task", unique = true)})
public class Notification {
static final String TABLE_NAME = "notification";
public static final Table TABLE = new Table(TABLE_NAME);
public static final LongProperty TASK = new LongProperty(TABLE, "task");
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "uid")
public int uid;
@ColumnInfo(name = "task")
public long taskId;
@ColumnInfo(name = "timestamp")
public long timestamp;
@ColumnInfo(name = "type")
public int type;
@ColumnInfo(name = "location")
public Long location;
@Override
public String toString() {
return "Notification{"
+ "uid="
+ uid
+ ", taskId="
+ taskId
+ ", timestamp="
+ timestamp
+ ", type="
+ type
+ ", location="
+ location
+ '}';
}
}

@ -0,0 +1,37 @@
package org.tasks.notifications
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.Index
import androidx.room.PrimaryKey
import com.todoroo.andlib.data.Property.LongProperty
import com.todoroo.andlib.data.Table
@Entity(tableName = Notification.TABLE_NAME, indices = [Index(value = ["task"], unique = true)])
class Notification {
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "uid")
var uid = 0
@ColumnInfo(name = "task")
var taskId: Long = 0
@ColumnInfo(name = "timestamp")
var timestamp: Long = 0
@ColumnInfo(name = "type")
var type = 0
@ColumnInfo(name = "location")
var location: Long? = null
override fun toString(): String {
return "Notification(uid=$uid, taskId=$taskId, timestamp=$timestamp, type=$type, location=$location)"
}
companion object {
const val TABLE_NAME = "notification"
@JvmField val TABLE = Table(TABLE_NAME)
@JvmField val TASK = LongProperty(TABLE, "task")
}
}

@ -126,7 +126,7 @@ public class NotificationManager {
List<Notification> notifications = notificationDao.getAllOrdered();
if (cancelExisting) {
for (Notification notification : notifications) {
notificationManagerCompat.cancel((int) notification.taskId);
notificationManagerCompat.cancel((int) notification.getTaskId());
}
}
@ -180,19 +180,19 @@ public class NotificationManager {
for (Notification notification : notifications) {
NotificationCompat.Builder builder = getTaskNotification(notification);
if (builder == null) {
notificationManagerCompat.cancel((int) notification.taskId);
notificationDao.delete(notification.taskId);
notificationManagerCompat.cancel((int) notification.getTaskId());
notificationDao.delete(notification.getTaskId());
} else {
builder
.setGroup(
useGroupKey
? GROUP_KEY
: (atLeastNougat() ? Long.toString(notification.taskId) : null))
: (atLeastNougat() ? Long.toString(notification.getTaskId()) : null))
.setGroupAlertBehavior(
alert
? NotificationCompat.GROUP_ALERT_CHILDREN
: NotificationCompat.GROUP_ALERT_SUMMARY);
notify(notification.taskId, builder, alert, nonstop, fiveTimes);
notify(notification.getTaskId(), builder, alert, nonstop, fiveTimes);
alert = false;
}
}
@ -272,7 +272,7 @@ public class NotificationManager {
maxPriority = Math.min(maxPriority, task.getPriority());
}
for (Notification notification : newNotifications) {
Task task = tryFind(tasks, t -> t.getId() == notification.taskId).orNull();
Task task = tryFind(tasks, t -> t.getId() == notification.getTaskId()).orNull();
if (task == null) {
continue;
}
@ -316,9 +316,9 @@ public class NotificationManager {
}
public NotificationCompat.Builder getTaskNotification(Notification notification) {
long id = notification.taskId;
int type = notification.type;
long when = notification.timestamp;
long id = notification.getTaskId();
int type = notification.getType();
long when = notification.getTimestamp();
Task task = taskDao.fetch(id);
if (task == null) {
Timber.e("Could not find %s", id);
@ -382,7 +382,7 @@ public class NotificationManager {
PendingIntent.getActivity(context, (int) id, intent, PendingIntent.FLAG_UPDATE_CURRENT));
if (type == TYPE_GEOFENCE_ENTER || type == TYPE_GEOFENCE_EXIT) {
Place place = locationDao.getPlace(notification.location);
Place place = locationDao.getPlace(notification.getLocation());
if (place != null) {
builder.setContentText(
context.getString(

Loading…
Cancel
Save