Add order columns to nav drawer items

pull/1020/head
Alex Baker 4 years ago
parent 7f964ecc97
commit 8ff6057531

File diff suppressed because it is too large Load Diff

@ -23,7 +23,7 @@ object GtaskListMaker {
list.account = lookup.valueOf(ACCOUNT, "account") list.account = lookup.valueOf(ACCOUNT, "account")
list.remoteId = lookup.valueOf(REMOTE_ID, "1") list.remoteId = lookup.valueOf(REMOTE_ID, "1")
list.title = lookup.valueOf(NAME, "Default") list.title = lookup.valueOf(NAME, "Default")
list.remoteOrder = lookup.valueOf(ORDER, 0) list.order = lookup.valueOf(ORDER, 0)
list.lastSync = lookup.valueOf(LAST_SYNC, 0L) list.lastSync = lookup.valueOf(LAST_SYNC, 0L)
list.setColor(lookup.valueOf(COLOR, 0)) list.setColor(lookup.valueOf(COLOR, 0))
list list

@ -47,6 +47,7 @@ public class CaldavFilter extends Filter {
this.calendar = calendar; this.calendar = calendar;
tint = calendar.getColor(); tint = calendar.getColor();
icon = calendar.getIcon(); icon = calendar.getIcon();
order = calendar.getOrder();
} }
private static QueryTemplate queryTemplate(CaldavCalendar caldavCalendar) { private static QueryTemplate queryTemplate(CaldavCalendar caldavCalendar) {

@ -34,6 +34,7 @@ public class CustomFilter extends Filter {
criterion = filter.getCriterion(); criterion = filter.getCriterion();
tint = filter.getColor(); tint = filter.getColor();
icon = filter.getIcon(); icon = filter.getIcon();
order = filter.getOrder();
} }
private CustomFilter(Parcel parcel) { private CustomFilter(Parcel parcel) {

@ -26,6 +26,7 @@ public abstract class FilterListItem implements Parcelable {
public int icon = -1; public int icon = -1;
public int tint = 0; public int tint = 0;
public int count = -1; public int count = -1;
public int order = 0;
public abstract Type getItemType(); public abstract Type getItemType();
@ -41,6 +42,7 @@ public abstract class FilterListItem implements Parcelable {
dest.writeInt(icon); dest.writeInt(icon);
dest.writeInt(tint); dest.writeInt(tint);
dest.writeInt(count); dest.writeInt(count);
dest.writeInt(order);
} }
// --- parcelable helpers // --- parcelable helpers
@ -51,6 +53,7 @@ public abstract class FilterListItem implements Parcelable {
icon = source.readInt(); icon = source.readInt();
tint = source.readInt(); tint = source.readInt();
count = source.readInt(); count = source.readInt();
order = source.readInt();
} }
public abstract boolean areItemsTheSame(@NonNull FilterListItem other); public abstract boolean areItemsTheSame(@NonNull FilterListItem other);
@ -59,7 +62,8 @@ public abstract class FilterListItem implements Parcelable {
return Objects.equals(listingTitle, other.listingTitle) return Objects.equals(listingTitle, other.listingTitle)
&& icon == other.icon && icon == other.icon
&& tint == other.tint && tint == other.tint
&& count == other.count; && count == other.count
&& order == other.order;
} }
@Override @Override
@ -74,6 +78,8 @@ public abstract class FilterListItem implements Parcelable {
+ tint + tint
+ ", count=" + ", count="
+ count + count
+ ", order="
+ order
+ '}'; + '}';
} }

@ -47,6 +47,7 @@ public class GtasksFilter extends Filter {
this.list = list; this.list = list;
tint = list.getColor(); tint = list.getColor();
icon = list.getIcon(); icon = list.getIcon();
order = list.getOrder();
} }
private static QueryTemplate getQueryTemplate(GoogleTaskList list) { private static QueryTemplate getQueryTemplate(GoogleTaskList list) {

@ -46,6 +46,7 @@ public class TagFilter extends Filter {
this.tagData = tagData; this.tagData = tagData;
tint = tagData.getColor(); tint = tagData.getColor();
icon = tagData.getIcon(); icon = tagData.getIcon();
order = tagData.getOrder();
} }
private static QueryTemplate queryTemplate(String uuid) { private static QueryTemplate queryTemplate(String uuid) {

@ -26,7 +26,7 @@ import org.tasks.notifications.NotificationDao
CaldavTask::class, CaldavTask::class,
CaldavAccount::class, CaldavAccount::class,
GoogleTaskAccount::class], GoogleTaskAccount::class],
version = 75) version = 76)
abstract class Database : RoomDatabase() { abstract class Database : RoomDatabase() {
abstract fun notificationDao(): NotificationDao abstract fun notificationDao(): NotificationDao
abstract val tagDataDao: TagDataDao abstract val tagDataDao: TagDataDao

@ -78,7 +78,6 @@ public class GtasksListService {
} }
local.setTitle(title); local.setTitle(title);
local.setRemoteOrder(i);
googleTaskListDao.insertOrReplace(local); googleTaskListDao.insertOrReplace(local);
previousLists.remove(local.getId()); previousLists.remove(local.getId());
} }

@ -37,6 +37,9 @@ class CaldavCalendar : Parcelable {
@ColumnInfo(name = "cdl_icon") @ColumnInfo(name = "cdl_icon")
private var icon: Int? = -1 private var icon: Int? = -1
@ColumnInfo(name = "cdl_order")
var order = 0
constructor() constructor()
@Ignore @Ignore
@ -55,6 +58,7 @@ class CaldavCalendar : Parcelable {
ctag = source.readString() ctag = source.readString()
url = source.readString() url = source.readString()
icon = source.readInt() icon = source.readInt()
order = source.readInt()
} }
fun getIcon(): Int? { fun getIcon(): Int? {
@ -76,6 +80,7 @@ class CaldavCalendar : Parcelable {
dest.writeString(ctag) dest.writeString(ctag)
dest.writeString(url) dest.writeString(url)
dest.writeInt(getIcon()!!) dest.writeInt(getIcon()!!)
dest.writeInt(order)
} }
override fun equals(other: Any?): Boolean { override fun equals(other: Any?): Boolean {
@ -90,6 +95,7 @@ class CaldavCalendar : Parcelable {
if (ctag != other.ctag) return false if (ctag != other.ctag) return false
if (url != other.url) return false if (url != other.url) return false
if (icon != other.icon) return false if (icon != other.icon) return false
if (order != other.order) return false
return true return true
} }
@ -103,11 +109,12 @@ class CaldavCalendar : Parcelable {
result = 31 * result + (ctag?.hashCode() ?: 0) result = 31 * result + (ctag?.hashCode() ?: 0)
result = 31 * result + (url?.hashCode() ?: 0) result = 31 * result + (url?.hashCode() ?: 0)
result = 31 * result + (icon ?: 0) result = 31 * result + (icon ?: 0)
result = 31 * result + order
return result return result
} }
override fun toString(): String { override fun toString(): String {
return "CaldavCalendar(id=$id, account=$account, uuid=$uuid, name=$name, color=$color, ctag=$ctag, url=$url, icon=$icon)" return "CaldavCalendar(id=$id, account=$account, uuid=$uuid, name=$name, color=$color, ctag=$ctag, url=$url, icon=$icon, order=$order)"
} }
companion object { companion object {

@ -32,6 +32,9 @@ class Filter {
@ColumnInfo(name = "f_icon") @ColumnInfo(name = "f_icon")
private var icon: Int? = -1 private var icon: Int? = -1
@ColumnInfo(name = "f_order")
var order = 0
fun getSql(): String { fun getSql(): String {
// TODO: replace dirty hack for missing column // TODO: replace dirty hack for missing column
return sql!!.replace("tasks.userId=0", "1") return sql!!.replace("tasks.userId=0", "1")
@ -71,6 +74,7 @@ class Filter {
if (criterion != other.criterion) return false if (criterion != other.criterion) return false
if (color != other.color) return false if (color != other.color) return false
if (icon != other.icon) return false if (icon != other.icon) return false
if (order != other.order) return false
return true return true
} }
@ -83,10 +87,11 @@ class Filter {
result = 31 * result + (criterion?.hashCode() ?: 0) result = 31 * result + (criterion?.hashCode() ?: 0)
result = 31 * result + (color ?: 0) result = 31 * result + (color ?: 0)
result = 31 * result + (icon ?: 0) result = 31 * result + (icon ?: 0)
result = 31 * result + order
return result return result
} }
override fun toString(): String { override fun toString(): String {
return "Filter(id=$id, title=$title, sql=$sql, values=$values, criterion=$criterion, color=$color, icon=$icon)" return "Filter(id=$id, title=$title, sql=$sql, values=$values, criterion=$criterion, color=$color, icon=$icon, order=$order)"
} }
} }

@ -26,7 +26,7 @@ class GoogleTaskList : Parcelable {
var title: String? = null var title: String? = null
@ColumnInfo(name = "gtl_remote_order") @ColumnInfo(name = "gtl_remote_order")
var remoteOrder = 0 var order = 0
@ColumnInfo(name = "gtl_last_sync") @ColumnInfo(name = "gtl_last_sync")
var lastSync: Long = 0 var lastSync: Long = 0
@ -45,7 +45,7 @@ class GoogleTaskList : Parcelable {
account = parcel.readString() account = parcel.readString()
remoteId = parcel.readString() remoteId = parcel.readString()
title = parcel.readString() title = parcel.readString()
remoteOrder = parcel.readInt() order = parcel.readInt()
lastSync = parcel.readLong() lastSync = parcel.readLong()
color = parcel.readInt() color = parcel.readInt()
icon = parcel.readInt() icon = parcel.readInt()
@ -74,7 +74,7 @@ class GoogleTaskList : Parcelable {
parcel.writeString(account) parcel.writeString(account)
parcel.writeString(remoteId) parcel.writeString(remoteId)
parcel.writeString(title) parcel.writeString(title)
parcel.writeInt(remoteOrder) parcel.writeInt(order)
parcel.writeLong(lastSync) parcel.writeLong(lastSync)
parcel.writeInt(getColor()!!) parcel.writeInt(getColor()!!)
parcel.writeInt(getIcon()!!) parcel.writeInt(getIcon()!!)
@ -88,7 +88,7 @@ class GoogleTaskList : Parcelable {
if (account != other.account) return false if (account != other.account) return false
if (remoteId != other.remoteId) return false if (remoteId != other.remoteId) return false
if (title != other.title) return false if (title != other.title) return false
if (remoteOrder != other.remoteOrder) return false if (order != other.order) return false
if (lastSync != other.lastSync) return false if (lastSync != other.lastSync) return false
if (color != other.color) return false if (color != other.color) return false
if (icon != other.icon) return false if (icon != other.icon) return false
@ -101,7 +101,7 @@ class GoogleTaskList : Parcelable {
result = 31 * result + (account?.hashCode() ?: 0) result = 31 * result + (account?.hashCode() ?: 0)
result = 31 * result + (remoteId?.hashCode() ?: 0) result = 31 * result + (remoteId?.hashCode() ?: 0)
result = 31 * result + (title?.hashCode() ?: 0) result = 31 * result + (title?.hashCode() ?: 0)
result = 31 * result + remoteOrder result = 31 * result + order
result = 31 * result + lastSync.hashCode() result = 31 * result + lastSync.hashCode()
result = 31 * result + (color ?: 0) result = 31 * result + (color ?: 0)
result = 31 * result + (icon ?: 0) result = 31 * result + (icon ?: 0)
@ -109,7 +109,7 @@ class GoogleTaskList : Parcelable {
} }
override fun toString(): String { override fun toString(): String {
return "GoogleTaskList(id=$id, account=$account, remoteId=$remoteId, title=$title, remoteOrder=$remoteOrder, lastSync=$lastSync, color=$color, icon=$icon)" return "GoogleTaskList(id=$id, account=$account, remoteId=$remoteId, title=$title, remoteOrder=$order, lastSync=$lastSync, color=$color, icon=$icon)"
} }
companion object { companion object {

@ -10,7 +10,6 @@ import android.widget.Toast
import androidx.room.* import androidx.room.*
import com.mapbox.api.geocoding.v5.GeocodingCriteria import com.mapbox.api.geocoding.v5.GeocodingCriteria
import com.mapbox.api.geocoding.v5.models.CarmenFeature import com.mapbox.api.geocoding.v5.models.CarmenFeature
import com.todoroo.andlib.data.Property
import com.todoroo.andlib.data.Table import com.todoroo.andlib.data.Table
import com.todoroo.astrid.helper.UUIDHelper import com.todoroo.astrid.helper.UUIDHelper
import net.fortuna.ical4j.model.property.Geo import net.fortuna.ical4j.model.property.Geo
@ -56,6 +55,9 @@ class Place : Serializable, Parcelable {
@ColumnInfo(name = "place_icon") @ColumnInfo(name = "place_icon")
private var icon = -1 private var icon = -1
@ColumnInfo(name = "place_order")
var order = 0
constructor() constructor()
@Ignore @Ignore
@ -70,6 +72,7 @@ class Place : Serializable, Parcelable {
longitude = o.longitude longitude = o.longitude
color = o.color color = o.color
icon = o.icon icon = o.icon
order = o.order
} }
@Ignore @Ignore
@ -84,6 +87,7 @@ class Place : Serializable, Parcelable {
longitude = parcel.readDouble() longitude = parcel.readDouble()
color = parcel.readInt() color = parcel.readInt()
icon = parcel.readInt() icon = parcel.readInt()
order = parcel.readInt()
} }
fun getIcon(): Int? { fun getIcon(): Int? {
@ -140,6 +144,7 @@ class Place : Serializable, Parcelable {
out.writeDouble(longitude) out.writeDouble(longitude)
out.writeInt(color) out.writeInt(color)
out.writeInt(icon) out.writeInt(icon)
out.writeInt(order)
} }
override fun equals(other: Any?): Boolean { override fun equals(other: Any?): Boolean {
@ -156,6 +161,7 @@ class Place : Serializable, Parcelable {
if (longitude != other.longitude) return false if (longitude != other.longitude) return false
if (color != other.color) return false if (color != other.color) return false
if (icon != other.icon) return false if (icon != other.icon) return false
if (order != other.order) return false
return true return true
} }
@ -171,11 +177,12 @@ class Place : Serializable, Parcelable {
result = 31 * result + longitude.hashCode() result = 31 * result + longitude.hashCode()
result = 31 * result + color result = 31 * result + color
result = 31 * result + icon result = 31 * result + icon
result = 31 * result + order
return result return result
} }
override fun toString(): String { override fun toString(): String {
return "Place(id=$id, uid=$uid, name=$name, address=$address, phone=$phone, url=$url, latitude=$latitude, longitude=$longitude, color=$color, icon=$icon)" return "Place(id=$id, uid=$uid, name=$name, address=$address, phone=$phone, url=$url, latitude=$latitude, longitude=$longitude, color=$color, icon=$icon, order=$order)"
} }
companion object { companion object {

@ -33,6 +33,9 @@ class TagData : Parcelable {
@ColumnInfo(name = "td_icon") @ColumnInfo(name = "td_icon")
private var icon: Int? = -1 private var icon: Int? = -1
@ColumnInfo(name = "td_order")
var order = 0
@Ignore @Ignore
constructor(name: String?) { constructor(name: String?) {
this.name = name this.name = name
@ -57,6 +60,7 @@ class TagData : Parcelable {
color = parcel.readInt() color = parcel.readInt()
tagOrdering = parcel.readString() tagOrdering = parcel.readString()
icon = parcel.readInt() icon = parcel.readInt()
order = parcel.readInt()
} }
fun getColor(): Int? { fun getColor(): Int? {
@ -84,6 +88,7 @@ class TagData : Parcelable {
dest.writeInt(color!!) dest.writeInt(color!!)
dest.writeString(tagOrdering) dest.writeString(tagOrdering)
dest.writeInt(getIcon()!!) dest.writeInt(getIcon()!!)
dest.writeInt(order)
} }
override fun equals(other: Any?): Boolean { override fun equals(other: Any?): Boolean {
@ -96,6 +101,7 @@ class TagData : Parcelable {
if (color != other.color) return false if (color != other.color) return false
if (tagOrdering != other.tagOrdering) return false if (tagOrdering != other.tagOrdering) return false
if (icon != other.icon) return false if (icon != other.icon) return false
if (order != other.order) return false
return true return true
} }
@ -107,11 +113,12 @@ class TagData : Parcelable {
result = 31 * result + (color ?: 0) result = 31 * result + (color ?: 0)
result = 31 * result + (tagOrdering?.hashCode() ?: 0) result = 31 * result + (tagOrdering?.hashCode() ?: 0)
result = 31 * result + (icon ?: 0) result = 31 * result + (icon ?: 0)
result = 31 * result + order
return result return result
} }
override fun toString(): String { override fun toString(): String {
return "TagData(id=$id, remoteId=$remoteId, name=$name, color=$color, tagOrdering=$tagOrdering, icon=$icon)" return "TagData(id=$id, remoteId=$remoteId, name=$name, color=$color, tagOrdering=$tagOrdering, icon=$icon, order=$order)"
} }
companion object { companion object {

@ -347,6 +347,15 @@ object Migrations {
} }
} }
private val MIGRATION_75_76: Migration = object : Migration(75, 76) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("ALTER TABLE `tagdata` ADD COLUMN `td_order` INTEGER NOT NULL DEFAULT 0")
database.execSQL("ALTER TABLE `caldav_lists` ADD COLUMN `cdl_order` INTEGER NOT NULL DEFAULT 0")
database.execSQL("ALTER TABLE `filters` ADD COLUMN `f_order` INTEGER NOT NULL DEFAULT 0")
database.execSQL("ALTER TABLE `places` ADD COLUMN `place_order` INTEGER NOT NULL DEFAULT 0")
}
}
val MIGRATIONS = arrayOf( val MIGRATIONS = arrayOf(
MIGRATION_35_36, MIGRATION_35_36,
MIGRATION_36_37, MIGRATION_36_37,
@ -378,7 +387,8 @@ object Migrations {
MIGRATION_71_72, MIGRATION_71_72,
MIGRATION_72_73, MIGRATION_72_73,
MIGRATION_73_74, MIGRATION_73_74,
MIGRATION_74_75 MIGRATION_74_75,
MIGRATION_75_76
) )
private fun noop(from: Int, to: Int): Migration { private fun noop(from: Int, to: Int): Migration {

@ -61,6 +61,7 @@ public class PlaceFilter extends Filter {
this.place = place; this.place = place;
tint = place.getColor(); tint = place.getColor();
icon = place.getIcon(); icon = place.getIcon();
order = place.getOrder();
} }
public Place getPlace() { public Place getPlace() {

Loading…
Cancel
Save