Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c18a32e
Refactor details screen - first batch
patrickunterwegs May 8, 2024
4066026
Location done
patrickunterwegs May 14, 2024
279a31e
removed Jtx20009ReleaseInfoDialog.kt obsolete release info dialog
patrickunterwegs May 14, 2024
398d3a5
Merge branch 'develop' into 1400-feature-refactor-details-screen-merg…
patrickunterwegs May 15, 2024
b263bfd
Refactored recurring element
patrickunterwegs May 18, 2024
50caffe
comments done
patrickunterwegs May 19, 2024
443f433
summary and description done
patrickunterwegs May 20, 2024
c0c396e
Merge branch 'develop' into 1400-feature-refactor-details-screen-merg…
patrickunterwegs May 24, 2024
39260a9
updated comments card
patrickunterwegs May 25, 2024
4088e6a
allways show showAllOptions button and last edited info
patrickunterwegs May 25, 2024
e24d8cc
minor adaption in description field
patrickunterwegs May 26, 2024
4a786c7
Merge branch 'develop' into 1400-feature-refactor-details-screen-merg…
patrickunterwegs May 26, 2024
c111d0e
status classification priority done
patrickunterwegs May 26, 2024
25199ef
removed edit mode variable from bottom app bar
patrickunterwegs May 26, 2024
986e3eb
Moved also revert option to menu
patrickunterwegs May 26, 2024
21e0a64
Categories and Resources done (moved to dialog)
patrickunterwegs May 26, 2024
e6a56b9
Merge branch 'develop' into 1400-feature-refactor-details-screen-merg…
patrickunterwegs Jun 2, 2024
6d7d31f
Merge branch 'develop' into 1400-feature-refactor-details-screen-merg…
patrickunterwegs Jun 5, 2024
1ca9be7
Update .gitignore
patrickunterwegs Jun 5, 2024
50b1f34
Merge branch 'develop' into 1400-feature-refactor-details-screen-merg…
patrickunterwegs Jun 8, 2024
86fce17
Merge branch 'develop' into 1400-feature-refactor-details-screen-merg…
patrickunterwegs Jun 8, 2024
8fede6d
Merge branch 'develop' into 1400-feature-refactor-details-screen-merg…
patrickunterwegs Jun 9, 2024
9aed94b
improved menu
patrickunterwegs Jun 9, 2024
9206eed
Removed more editMode conditions
patrickunterwegs Jun 9, 2024
ca7fadd
edit summary/description/recur when added
patrickunterwegs Jun 14, 2024
efbe239
Merge branch 'develop' into 1400-feature-refactor-details-screen-merg…
patrickunterwegs Jun 15, 2024
e94778d
refactored fetching collections to only observe in composable
patrickunterwegs Jun 15, 2024
4982097
refactored long-click to select instead of edit
patrickunterwegs Jun 15, 2024
99bc13d
removed unused variable
patrickunterwegs Jun 16, 2024
ce603b2
fetch count more efficiently
patrickunterwegs Jun 16, 2024
790e104
introduced iCalEntity4List
patrickunterwegs Jul 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 46 additions & 9 deletions app/src/main/java/at/techbee/jtx/database/ICalDatabaseDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import at.techbee.jtx.database.properties.TABLE_NAME_RESOURCE
import at.techbee.jtx.database.properties.Unknown
import at.techbee.jtx.database.relations.ICal4ListRel
import at.techbee.jtx.database.relations.ICalEntity
import at.techbee.jtx.database.relations.ICalEntity4List
import at.techbee.jtx.database.views.CollectionsView
import at.techbee.jtx.database.views.ICal4List
import at.techbee.jtx.database.views.VIEW_NAME_COLLECTIONS_VIEW
Expand All @@ -84,6 +85,7 @@ interface ICalDatabaseDao {
SELECTs (global selects without parameter)
*/


/**
* Retrieve an list of all DISTINCT Category names ([Category.text]) as a LiveData-List
* @return a list of [Category.text] as LiveData<List<String>>
Expand Down Expand Up @@ -126,17 +128,16 @@ interface ICalDatabaseDao {
*
* @return a list of [Collection] as LiveData<List<ICalCollection>>
*/
@Query("SELECT * FROM $TABLE_NAME_COLLECTION WHERE $COLUMN_COLLECTION_READONLY = 0 AND ($COLUMN_COLLECTION_SUPPORTSVJOURNAL = 1 OR $COLUMN_COLLECTION_SUPPORTSVTODO = 1) ORDER BY $COLUMN_COLLECTION_ACCOUNT_NAME ASC")
fun getAllWriteableCollections(): LiveData<List<ICalCollection>>
@Query("SELECT * FROM $TABLE_NAME_COLLECTION WHERE $COLUMN_COLLECTION_READONLY = 0 AND ($COLUMN_COLLECTION_SUPPORTSVJOURNAL = :supportsVJOURNAL OR $COLUMN_COLLECTION_SUPPORTSVTODO = :supportsVTODO) ORDER BY $COLUMN_COLLECTION_ACCOUNT_NAME ASC")
fun getAllWriteableCollections(supportsVTODO: Boolean, supportsVJOURNAL: Boolean): LiveData<List<ICalCollection>>

/**
* Retrieve an list of all Collections ([Collection]) that have entries for a given module as a LiveData-List
* @param module (Module.name) for which there are existing entries for a collection
* @return a list of [Collection] as LiveData<List<ICalCollection>>
*/
@Transaction
@Query("SELECT $TABLE_NAME_COLLECTION.* FROM $TABLE_NAME_COLLECTION WHERE $TABLE_NAME_COLLECTION.$COLUMN_COLLECTION_ID IN (SELECT $TABLE_NAME_ICALOBJECT.$COLUMN_ICALOBJECT_COLLECTIONID FROM $TABLE_NAME_ICALOBJECT WHERE $COLUMN_MODULE = :module) ORDER BY $COLUMN_COLLECTION_ACCOUNT_NAME ASC")
fun getAllCollections(module: String): LiveData<List<ICalCollection>>
@Query("SELECT * FROM $TABLE_NAME_COLLECTION WHERE $COLUMN_COLLECTION_SUPPORTSVTODO = :supportsVTODO OR $COLUMN_COLLECTION_SUPPORTSVJOURNAL = :supportsVJOURNAL ORDER BY $COLUMN_COLLECTION_ACCOUNT_NAME ASC")
fun getAllCollections(supportsVTODO: Boolean, supportsVJOURNAL: Boolean): LiveData<List<ICalCollection>>


/**
Expand Down Expand Up @@ -233,12 +234,15 @@ interface ICalDatabaseDao {
fun getCount(): Int

/**
* Retrieve the number of items in the table of [ICal4List] for a specific module as Int.
* @param
* Retrieve the number of iCalObjects that are not deleted,
* that don't have an RRULE
* and that are not present in related to (meaning they are not sub-entries)
* for a specific module
* @param [module]
* @return Int with the total number of [ICal4List] in the table for the given module.
*/
@Query("SELECT count(*) FROM $VIEW_NAME_ICAL4LIST WHERE $COLUMN_MODULE = :module AND $VIEW_NAME_ICAL4LIST.isChildOfTodo = 0 AND $VIEW_NAME_ICAL4LIST.isChildOfJournal = 0 AND $VIEW_NAME_ICAL4LIST.isChildOfNote = 0 ")
fun getICal4ListCount(module: String): LiveData<Int?>
@Query("SELECT count(*) FROM $TABLE_NAME_ICALOBJECT WHERE $COLUMN_MODULE = :module AND $COLUMN_RRULE IS NULL AND $COLUMN_DELETED = 0 AND $TABLE_NAME_ICALOBJECT.$COLUMN_ID NOT IN (SELECT $TABLE_NAME_RELATEDTO.$COLUMN_RELATEDTO_ICALOBJECT_ID FROM $TABLE_NAME_RELATEDTO)")
fun getCount4List(module: String): LiveData<Int?>

/**
* Retrieve an [ICalObject] by Id as LiveData
Expand Down Expand Up @@ -1554,6 +1558,34 @@ iCalObject.percent != 100
}
}


@Transaction
suspend fun updateCategories(iCalObjectId: Long, uid: String, categories: List<Category>) {

deleteCategories(iCalObjectId)
categories.forEach { it.icalObjectId = iCalObjectId }
upsertCategories(categories)
updateSetDirty(iCalObjectId)
makeSeriesDirty(uid)
}

@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun upsertCategories(categories: List<Category>)


@Transaction
suspend fun updateResources(iCalObjectId: Long, uid: String, resources: List<Resource>) {

deleteResources(iCalObjectId)
resources.forEach { it.icalObjectId = iCalObjectId }
upsertResources(resources)
updateSetDirty(iCalObjectId)
makeSeriesDirty(uid)
}

@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun upsertResources(resources: List<Resource>)

@Transaction
suspend fun saveAll(
icalObject: ICalObject,
Expand Down Expand Up @@ -1773,4 +1805,9 @@ iCalObject.percent != 100
@Query("SELECT $COLUMN_UID FROM $TABLE_NAME_ICALOBJECT WHERE $COLUMN_ID = :iCalObjectId")
fun getUid(iCalObjectId: Long): String?


@Transaction
@Query("SELECT * FROM $TABLE_NAME_ICALOBJECT")
fun getICalEntity4List(): List<ICalEntity4List>

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* Copyright (c) Techbee e.U.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*/

package at.techbee.jtx.database.relations

import android.os.Parcelable
import androidx.room.Embedded
import androidx.room.Relation
import at.techbee.jtx.database.COLUMN_COLLECTION_ID
import at.techbee.jtx.database.COLUMN_ICALOBJECT_COLLECTIONID
import at.techbee.jtx.database.COLUMN_ID
import at.techbee.jtx.database.COLUMN_UID
import at.techbee.jtx.database.ICalCollection
import at.techbee.jtx.database.ICalObject
import at.techbee.jtx.database.properties.Alarm
import at.techbee.jtx.database.properties.Attachment
import at.techbee.jtx.database.properties.Attendee
import at.techbee.jtx.database.properties.COLUMN_ALARM_ICALOBJECT_ID
import at.techbee.jtx.database.properties.COLUMN_ALARM_TRIGGER_TIME
import at.techbee.jtx.database.properties.COLUMN_ATTACHMENT_ICALOBJECT_ID
import at.techbee.jtx.database.properties.COLUMN_ATTENDEE_CALADDRESS
import at.techbee.jtx.database.properties.COLUMN_ATTENDEE_ICALOBJECT_ID
import at.techbee.jtx.database.properties.COLUMN_CATEGORY_ICALOBJECT_ID
import at.techbee.jtx.database.properties.COLUMN_CATEGORY_TEXT
import at.techbee.jtx.database.properties.COLUMN_COMMENT_ICALOBJECT_ID
import at.techbee.jtx.database.properties.COLUMN_COMMENT_TEXT
import at.techbee.jtx.database.properties.COLUMN_RELATEDTO_ICALOBJECT_ID
import at.techbee.jtx.database.properties.COLUMN_RELATEDTO_TEXT
import at.techbee.jtx.database.properties.COLUMN_RESOURCE_ICALOBJECT_ID
import at.techbee.jtx.database.properties.COLUMN_RESOURCE_TEXT
import at.techbee.jtx.database.properties.Category
import at.techbee.jtx.database.properties.Comment
import at.techbee.jtx.database.properties.Relatedto
import at.techbee.jtx.database.properties.Resource
import kotlinx.parcelize.Parcelize


@Parcelize
data class ICalEntity4List(
@Embedded
var property: ICalObject = ICalObject(),

@Relation(parentColumn = COLUMN_ID, entityColumn = COLUMN_COMMENT_ICALOBJECT_ID, entity = Comment::class, projection = [COLUMN_COMMENT_TEXT])
var comments: List<String> = emptyList(),

@Relation(parentColumn = COLUMN_ID, entityColumn = COLUMN_CATEGORY_ICALOBJECT_ID, entity = Category::class, projection = [COLUMN_CATEGORY_TEXT])
var categories: List<String> = emptyList(),

@Relation(parentColumn = COLUMN_ID, entityColumn = COLUMN_ATTENDEE_ICALOBJECT_ID, entity = Attendee::class, projection = [COLUMN_ATTENDEE_CALADDRESS])
var attendees: List<String> = emptyList(),

/*
@Relation(parentColumn = COLUMN_ID, entityColumn = COLUMN_ORGANIZER_ICALOBJECT_ID, entity = Organizer::class)
var organizer: String? = null,
*/

@Relation(parentColumn = COLUMN_ID, entityColumn = COLUMN_RELATEDTO_ICALOBJECT_ID, entity = Relatedto::class, projection = [COLUMN_RELATEDTO_TEXT])
var parents: List<String> = emptyList(),

@Relation(parentColumn = COLUMN_UID, entityColumn = COLUMN_RELATEDTO_TEXT, entity = Relatedto::class, projection = [COLUMN_RELATEDTO_ICALOBJECT_ID])
var children: List<Long> = emptyList(),

@Relation(parentColumn = COLUMN_ID, entityColumn = COLUMN_RESOURCE_ICALOBJECT_ID, entity = Resource::class, projection = [COLUMN_RESOURCE_TEXT])
var resources: List<String?> = emptyList(),

@Relation(parentColumn = COLUMN_ID, entityColumn = COLUMN_ATTACHMENT_ICALOBJECT_ID, entity = Attachment::class)
var attachments: List<Attachment> = emptyList(),

@Relation(parentColumn = COLUMN_ID, entityColumn = COLUMN_ALARM_ICALOBJECT_ID, entity = Alarm::class, projection = [COLUMN_ALARM_TRIGGER_TIME])
var alarms: List<Long> = emptyList(),


@Relation(
parentColumn = COLUMN_ICALOBJECT_COLLECTIONID,
entityColumn = COLUMN_COLLECTION_ID,
entity = ICalCollection::class
)
var iCalCollection: ICalCollection
/*
/*
@Relation(parentColumn = COLUMN_ID, entityColumn = "icalObjectId", entity = Contact::class)
var contact: Contact? = null,
*/

*/

): Parcelable
Loading