Repo created

This commit is contained in:
Fr4nz D13trich 2025-11-23 08:51:57 +01:00
parent 61d62cabdf
commit ad3df69bdb
872 changed files with 65976 additions and 2 deletions

67
.gitignore vendored Normal file
View file

@ -0,0 +1,67 @@
# Built application files
*.apk
*.ap_
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
out/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Android Studio Navigation editor temp files
.navigation/
# Android Studio captures folder
captures/
# IntelliJ
*.iml
.idea
.kotlin
# Keystore files
# Uncomment the following line if you do not want to check your keystore files in.
#*.jks
# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
# Google Services (e.g. APIs or Firebase)
google-services.json
# Freeline
freeline.py
freeline/
freeline_project_description.json
# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md
app/build
app/play
app/fdroid
app/dev
app/mdm
app/pfungstadt

10
.tx/config Normal file
View file

@ -0,0 +1,10 @@
[main]
host = https://www.transifex.com
[o:nextcloud:p:nextcloud:r:android-deck]
file_filter = app/src/main/res/values-<lang>/strings.xml
source_file = app/src/main/res/values/strings.xml
source_lang = en
type = ANDROID
lang_map = mt_MT: mt-rMT, de_LI: de-rLI, es_BO: es-rBO, es_419: b+es+419, eu_ES: eu-rES, ka_GE: ka-rGE, mr_IN: mr-rIN, ar_TN: ar-rTN, fo_FO: fo-rFO, mk_MK: mk-rMK, sms_FI: sms-rFI, sr_ME: sr-rME, sr@latin: sr-rSP, ar_LB: ar-rLB, ar_SY: ar-rSY, es_PY: es-rPY, es_UY: es-rUY, ky_KG: ky-rKG, pa_IN: pa-rIN, uk_UA: uk-rUA, es_MX: es-rMX, fr_MC: fr-rMC, tr_TR: tr-rTR, sr_BA: sr-rBA, ne_NP: ne-rNP, or_IN: or-rIN, ps_AF: ps-rAF, ru_RU: ru-rRU, rw_RW: rw-rRW, sq_AL: sq-rAL, bg_BG: bg-rBG, en_TT: en-rTT, en_ZW: en-rZW, gsw_FR: gsw-rFR, ms_MY: ms-rMY, ar_MA: ar-rMA, ar_OM: ar-rOM, kl_GL: kl-rGL, tk_TM: tk-rTM, ar_EG: ar-rEG, is_IS: is-rIS, zh_MO: zh-rMO, id_ID: id-rID, mi_NZ: mi-rNZ, ar_DZ: ar-rDZ, bn_BD: bn-rBD, dsb_DE: dsb-rDE, es_AR: es-rAR, es_VE: es-rVE, hr_HR: hr-rHR, qut_GT: qut-rGT, smn_FI: smn-rFI, ar_YE: ar-rYE, en_ZA: en-rZA, lb_LU: lb-rLU, ms_BN: ms-rBN, my_MM: my, uz_UZ: uz-rUZ, wo_SN: wo-rSN, ar_JO: ar-rJO, en_BZ: en-rBZ, en_MY: en-rMY, he_IL: he-rIL, se_FI: se-rFI, sr_CS: sr-rCS, gd_GB: gd-rGB, gl_ES: gl-rES, af_ZA: af-rZA, am_ET: am-rET, es_ES: es-rES, es_NI: es-rNI, fr_CH: fr-rCH, ga_IE: ga-rIE, ar_QA: ar-rQA, gu_IN: gu-rIN, lv_LV: lv-rLV, ca_ES: ca-rES, cs_CZ: cs-rCZ, de_CH: de-rCH, en_AU: en-rAU, kok_IN: kok-rIN, lo_LA: lo-rLA, hy_AM: hy-rAM, kk_KZ: kk-rKZ, ar_LY: ar-rLY, de_AT: de-rAT, en_IE: en-rIE, es_PE: es-rPE, es_PR: es-rPR, fr_LU: fr-rLU, ml_IN: ml-rIN, sa_IN: sa-rIN, tzm_DZ: tzm-rDZ, tt_RU: tt-rRU, dv_MV: dv-rMV, en_GB: b+en+001, en_NZ: en-rNZ, es_SV: es-rSV, pl_PL: pl-rPL, quz_PE: quz-rPE, da_DK: da-rDK, es_DO: es-rDO, hi_IN: hi-rIN, quz_EC: quz-rEC, ro_RO: ro-rRO, es_PA: es-rPA, fi_FI: fi-rFI, hsb_DE: hsb-rDE, ja_JP: ja-rJP, nn_NO: nn-rNO, pt_PT: pt-rPT, ta_IN: ta-rIN, en_SG: en-rSG, ko_KR: ko-rKR, nso_ZA: nso-rZA, sma_SE: sma-rSE, sv_FI: sv-rFI, tg_TJ: tg-rTJ, en@pirate: en-rpirate, es_CL: es-rCL, ha_NG: ha-rNG, iu_CA: iu-rCA, kn_IN: kn-rIN, nb_NO: nb-rNO, ku_IQ: ku-rIQ, mn_MN: mn-rMN, ba_RU: ba-rRU, en_CA: en-rCA, es_HN: es-rHN, fr_CA: fr-rCA, fy_NL: fy-rNL, it_IT: it-rIT, nl_BE: nl-rBE, ta_LK: ta-rLK, xh_ZA: xh-rZA, zh_HK: zh-rHK, yo_NG: yo-rNG, ar_SA: ar-rSA, el_GR: el-rGR, en_PH: en-rPH, fa_IR: fa-rIR, se_SE: se-rSE, sk_SK: sk-rSK, sah_RU: sah-rRU, sw_KE: sw-rKE, bo_CN: bo-rCN, co_FR: co-rFR, de_DE: de-rDE, km_KH: km-rKH, nl_NL: nl-rNL, oc_FR: oc-rFR, zu_ZA: zu-rZA, ar_IQ: ar-rIQ, sr_RS: sr-rRS, syr_SY: syr-rSY, en_JM: en-rJM, es_EC: es-rEC, hr_BA: hr-rBA, lt_LT: lt-rLT, se_NO: se-rNO, si_LK: si-rLK, sl_SI: sl-rSI, be_BY: be-rBY, cy_GB: cy-rGB, de_LU: de-rLU, mn_CN: mn-rCN, prs_AF: prs-rAF, pt_BR: pt-rBR, smj_SE: smj-rSE, vi_VN: vi-rVN, rm_CH: rm-rCH, te_IN: te-rIN, ar_KW: ar-rKW, az_AZ: az-rAZ, bn_IN: bn-rIN, br_FR: br-rFR, et_EE: et-rEE, fr_BE: fr-rBE, th_TH: th-rTH, zh_SG: zh-rSG, zh_TW: zh-rTW, fil_PH: fil-rPH, ug_CN: ug-rCN, ur_PK: ur-rPK, zh_CN.GB2312: zh-rBG, arn_CL: arn-rCL, en_US: en-rUS, es_CO: es-rCO, sma_NO: sma-rNO, smj_NO: smj-rNO, sv_SE: sv-rSE, zh_CN: zh-rCN, ar_AE: ar-rAE, bs_BA: bs-rBA, es_CR: es-rCR, fr_FR: fr-rFR, hu_HU: hu-rHU, tn_ZA: tn-rZA, it_CH: it-rCH, moh_CA: moh-rCA, ar_BH: ar-rBH, as_IN: as-rIN, en_IN: en-rIN, es_GT: es-rGT, ig_NG: ig-rNG, ii_CN: ii-rCN, quz_BO: quz-rBO

138
FAQ.md Normal file
View file

@ -0,0 +1,138 @@
# Frequently asked questions
- [I have experienced an error](#i-have-experienced-an-error)
- [Why has my bug report been closed?](#why-has-my-bug-report-been-closed)
- [Why is my card not visible in the upcoming cards view?](#why-is-my-card-not-visible-in-the-upcoming-cards-view)
- [Why does the browser open when clicking on an attachment?](#why-does-the-browser-open-when-clicking-on-an-attachment)
- [Known issues](#known-issues)
- [Why don't you make an option for…?](#why-dont-you-make-an-option-for)
- [Why don't you make an iOS app?](#why-dont-you-make-an-ios-app)
- [How to receive notifications when a due date is reached?](#how-to-receive-notifications-when-a-due-date-is-reached)
- [Using the DEV App](#using-the-dev-app)
## I have experienced an error
Sorry. There are so many different environments, that it is impossible for us to test each and every constellation.
First of all make sure you have updated to and tried with the latest available versions of both, this app and the [Deck server app](https://apps.nextcloud.com/apps/deck).
In case you receive a `NextcloudApiNotRespondingException`, try to disable the battery optimization for both apps.
In all other cases please try to clear the storage of **both** apps, Nextcloud Android **and** Nextcloud Deck Android.
You can achieve this by navigating to
```
Android settings
Apps
Nextcloud / Deck
Storage
Clear storage
```
Often there is an issue with the state of the server app. Try to create a new test account at your Nextcloud instance and connect to it.
If there are no errors, share the boards of your actual account one by one with your test account to find the defect one.
If the issue persists, [open a bug report in our issue tracker](https://github.com/stefan-niedermann/nextcloud-deck/issues/new?assignees=&labels=bug&template=bug_report.md&title=).
## Why has my bug report been closed?
As stated in the bug templates, we reserve to close issues which do not fill the **complete** issue template. The information we ask for is urgently needed, even if it might not seem to be important or relevant to you.
We have very limited resources and capacity and we really want to help you fixing different bugs, but we can impossibly know your environment, your different software versions, the store you used.
Therefore it is extremely important for you to describe the **exact steps to reproduce**. This includes information about your environment.
Example for a bad description:
> 1. The app crashes when i save a card
Example for a good description:
> 1. Open any existing card\
> 2. Add text to the description\
> 3. Click on the ✕ in the top left\
> 4. Answer "Save" when asking to discard or save the changes\
> 5. See app crash
We also preserve to close issues where the original reporter does not answer within a certain time frame. We usually answer issues within a hour and expect you to respond to our questions within a week.
This is necessary for two reasons:
1. We have a rapid development cycle - bugs which have been reported weeks ago might no longer relevant
2. We are loosing the context of a report or a question over the time. We have many things to care about and digging into an issue deep and then relying on an response which is not coming is a waste of our limited free time
## Why is my card not visible in the upcoming cards view?
Checkout the [Upcoming Analyzer](https://upcoming-analyzer.niedermann.it/) to check out the criterias your card needs to match to be shown in the upcoming cards view.
## Why does the browser open when clicking on an attachment?
The Deck server app supports two different type of attachments:
- Attachments added prior to Deck server 1.3 have been added as `deck_file` attachments
- Attachments added with Deck server 1.3 or later are added as `file` attachments
The latter are stored as usual files in your Nextcloud, usually in the `/Deck` folder of your account.
Only `file` attachments are able show preview images and to get opened directly, while `deck_file` attachments are effectively only available via the Web UI.
We opened a [feature request](https://github.com/nextcloud/deck/issues/3101) to implement an `occ` migration command, but the current state of implementation is unclear.
## Known issues
Here is a collection of issues which are caused by the (not by us developed) Deck server app and can not be fixed within Deck Android. Please [contact the Nextcloud GmbH](https://nextcloud.com/contact/) if you want them to be fixed.
- Viewing archived cards is not possible: https://github.com/nextcloud/deck/issues/2613
- Renaming a list in the web UI does not update in Deck Android: https://github.com/nextcloud/deck/issues/2866
## Why don't you make an option for…?
We prefer good defaults over providing an option for each edge case. Our resources are quite limited, so we have to consider introducing new options very carefully.
1. A feature is implemented quickly, but who will maintain it for the next 5 years?
2. Each option increases the test matrix exponentially and leads to huge efforts to test every combination
3. Each option increases the possible constellations, making it hard to track down issues
4. Each option increases the visual noise for people who will *not* use the options
5. Each option increases the maintenance efforts, making it harder over the time to work on actual features
6. Each option introduces new side effects, which might lead to undiscovered bugs or break existing features
7. The Android app aims to mirror feature parity with the corresponding server app
## Why don't you make an iOS app?
We¹ believe, that the idea of Nextcloud - own your data - does not match the mindset of Apple and its products. We believe, that protecting your data is not possible on closed source operation systems like iOS. Yes, also Android often is not fully open source and distributed with proprietary stuff, but you have the choice and the possibility to use the app on the Android Open Source Project because the app does not depend on any proprietary libraries.
Also licenses for SDKs, Hardware and distributing is ridiculous expensive for an FLOSS project.
The API of the Deck server app is well documented and everyone is free to start an iOS client. Of course we appreciate a growing ecosystem even if we will not contribute to this part personally.
¹ Disclaimer: "We" are not working for nor related to Nextcloud Inc. in any way. We are just a few volunteers which contribute to this app in our free time.
## How to receive notifications when a due date is reached?
When a card reaches its due date, users usually want to get notified. The Deck app can send push notifications to you, which are displayed in the browser, via the [Nextcloud Desktop sync client](https://nextcloud.com/install/#install-clients) and with the [Nextcloud Android app](https://apps.nextcloud.com/apps/android_nextcloud_app). While you won't even need the Deck Android app, it will provide an enhanced integration starting with the Nextcloud Android app `3.14.2` and Deck Android `1.10.x`: Clicking on an notification will directly open the affected card in the Deck Android app.
In order to make this all work, you will need two things:
1. Make sure that your Nextcloud Android app is able to receive push notifications (You will need Google Play services for that)
2. Configure in your user settings, that you *want* to receive push notifications:
- Click in the top right of your browser on your avatar
- Choose "settings" and then "activities" in the left sidebar.
- Enable the checkbox `Changes in the Deck app`
![Enable push notifications for Deck](https://user-images.githubusercontent.com/4741199/125485987-398f3ee8-f59c-4234-8453-1da679d4d7c5.png)
## Using the DEV app
Sometimes we provide a DEV app for testing purposes, mostly related to an issue. Here's some further information:
- We provide a link to an Artifact built by GitHub
- The link should look something like this: https://github.com/stefan-niedermann/nextcloud-deck/actions/runs/[NUMBER]/artifacts/[NUMBER]
- Please make sure you download the APK from trusted sources only.
- Download the APK file and install it
- In most cases your phone will refuse to install the APK right away, unless you explicitly trust the source
- We recommend to allow APK installations by unknown sources **temporarily only**, it's best to remove the permission afterwards
- To do so, just follow the instructions of the dialog that came up
- The app will install **beside** your actual app
- You end up with two Deck apps
- The DEV app will have a "DEV" label on its icon
- Open the DEV app
- As it is a fresh installation, you will need to import your boards
- To do so, select the account you want to test on and let the app do the initial sync
- Test whatever you want to test
- And maybe provide some feedback ;)

674
LICENSE Normal file
View file

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

58
PRIVACY.md Normal file
View file

@ -0,0 +1,58 @@
# Nextcloud Deck Android Privacy Policy
The "Nextcloud Deck Android" Android-App (in the following referred to as "App") does not collect or send any data from you or your device to a server of the developers or the [Nextcloud GmbH](https://nextcloud.com/). The App sends all data exclusively to the server configured by you with the intention to synchronize the contents of the App with those of the server. This data can contain IP-addresses, timestamps and further information as meta data.
It is important to mention that all contents of the App may also be transmitted to the configured server. This contents can also contain personal information depending on the use. The servers you configured are technically outside the access area of this App developers, so that we neither know nor can prevent what happens to your data there. Please consult the privacy policy of the respective server operator.
The license of this project allows you to verify that no data is collected by the creators by reading the source code or asking someone else to do it.
## Permissions
This is a list of permissions required and asked by the App in order to properly work on your device:
- `android.permission.CAMERA`
Used for the preview of the camera in the attachments picker and to capture photos to attach them directly to a card
- `android.permission.READ_MEDIA_IMAGES`, `android.permission.READ_EXTERNAL_STORAGE`
Used for the attachments picker
- `android.permission.READ_CONTACTS`
Used to display and choose contacts directly within the attachment picker without the need of opening an external app
- `WRITE_EXTERNAL_STORAGE`
Used for caching selected local attachments to upload them
- `android.permission.ACCESS_NETWORK_STATE`
Used to provide offline support and make the "Sync only on Wi-Fi" option possible.
- `android.permission.INTERNET`
Used by [Nextcloud Single Sign On library](https://github.com/nextcloud/Android-SingleSignOn/) to communicate with your Nextcloud instance and synchronize contents.
- `android.permission.GET_ACCOUNTS`
Used by [Nextcloud Single Sign On library](https://github.com/nextcloud/Android-SingleSignOn/) to read available accounts to import.
- `android.permission.VIBRATE`
Used by [Material DateTime Picker](https://github.com/wdullaer/MaterialDateTimePicker).
- `android.permission.WAKE_LOCK`
Used by [AndroidX WorkManager](https://developer.android.com/jetpack/androidx/releases/work) for background synchronization.
- `android.permission.RECEIVE_BOOT_COMPLETED`
Used by [AndroidX WorkManager](https://developer.android.com/jetpack/androidx/releases/work) for background synchronization.
- `android.permission.FOREGROUND_SERVICE`
Used by [AndroidX WorkManager](https://developer.android.com/jetpack/androidx/releases/work) for background synchronization.
## Nextcloud privacy policy
You can get more information on Nextcloud general privacy policy which is accessible at [nextcloud.com/privacy](https://nextcloud.com/privacy/).

View file

@ -1,3 +1,64 @@
# c2c-deck
# Nextcloud Deck for Android
Nextcloud Deck App for Android
[![Android CI](https://github.com/stefan-niedermann/nextcloud-deck/workflows/Android%20CI/badge.svg)](https://github.com/stefan-niedermann/nextcloud-deck/actions)
[![GitHub issues](https://img.shields.io/github/issues/stefan-niedermann/nextcloud-deck.svg)](https://github.com/stefan-niedermann/nextcloud-deck/issues)
[![GitHub stars](https://img.shields.io/github/stars/stefan-niedermann/nextcloud-deck.svg)](https://github.com/stefan-niedermann/nextcloud-deck/stargazers)
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
An Android client for [Nextcloud Deck App](https://github.com/nextcloud/deck/).
## ▶️ Access
[![Latest Release](https://img.shields.io/github/v/tag/stefan-niedermann/nextcloud-deck?label=latest+release&sort=semver)](https://github.com/stefan-niedermann/nextcloud-deck/releases)
[![F-Droid Release](https://img.shields.io/f-droid/v/it.niedermann.nextcloud.deck)](https://f-droid.org/de/packages/it.niedermann.nextcloud.deck/)
[<img src="https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png"
alt="Get it on Play Store"
height="80">](https://play.google.com/store/apps/details?id=it.niedermann.nextcloud.deck.play)
[<img src="https://f-droid.org/badge/get-it-on.png"
alt="Get it on F-Droid"
height="80">](https://f-droid.org/repository/browse/?fdid=it.niedermann.nextcloud.deck)
[<img src="https://raw.githubusercontent.com/stefan-niedermann/paypal-donate-button/master/paypal-donate-button.png"
alt="Donate with PayPal"
height="80">](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZD39ZE7MGEGBL&source=url)
[<img src="https://raw.githubusercontent.com/stefan-niedermann/DonateButtons/master/LiberaPay.png"
alt="Donate using Liberapay"
height="80">](https://liberapay.com/stefan-niedermann/donate)
## 👀 Screenshots
| List View | Card View |
| --- | --- |
| ![Screenshot of list view](/fastlane/metadata/android/en-US/images/phoneScreenshots/2.png) | ![Screenshot of card](/fastlane/metadata/android/en-US/images/phoneScreenshots/5.png) |
## 🚀 Features
* Multiple accounts 👥
* Works offline 🔌
* Manage cards, lists and boards 📝
* Manage tags 🏷
* Supports attachments 📎, activities ⚡ & comments 💬
* Dark mode 🌙
* Translated in many languages 🌎
## 👪 Join the team
* Test the app with different devices
* Report issues in the [issue tracker](https://github.com/stefan-niedermann/nextcloud-deck/issues)
* [Pick a good first issue](https://github.com/stefan-niedermann/nextcloud-deck/labels/good%20first%20issue) :notebook:
* Create a [Pull Request](https://opensource.guide/how-to-contribute/#opening-a-pull-request)
* Help increasing the test coverage by contributing unit tests
* Translate the app on [Transifex](https://app.transifex.com/nextcloud/nextcloud/android-deck/)
* Send me a bottle of your favorite beer :beers: :wink:
## 🔗 Requirements
* [Nextcloud](https://nextcloud.com/) instance running
* [Nextcloud Android](https://github.com/nextcloud/android) app installed (≥ 3.9.0)
* [Nextcloud Deck](https://github.com/nextcloud/deck) app enabled (≥ 0.6.4)
## 📓 License
All contributions to this repository are considered to be licensed under the [GNU GENERAL PUBLIC LICENSE 3+](/LICENSE).
Contributors to the Deck Android app retain their copyright. Therefore we recommend to add following line to the header of a file, if you changed it substantially:
```
@copyright Copyright (c) <year>, <your name> (<your email address>)
```

145
app/build.gradle Normal file
View file

@ -0,0 +1,145 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
compileSdk 35
namespace 'it.niedermann.nextcloud.deck'
defaultConfig {
applicationId "it.niedermann.nextcloud.deck"
minSdk 24
targetSdk 35
versionCode 1024005
versionName "1.24.5"
vectorDrawables.useSupportLibrary true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
}
}
}
buildFeatures {
viewBinding true
buildConfig true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '17'
}
flavorDimensions = ["version"]
productFlavors {
fdroid {
dimension "version"
}
dev {
dimension "version"
applicationIdSuffix ".dev"
}
play {
dimension "version"
applicationIdSuffix ".play"
}
pfungstadt {
dimension "version"
applicationIdSuffix ".pfungstadt"
}
mdm {
dimension "version"
applicationIdSuffix ".mdm"
}
}
testOptions {
unitTests {
includeAndroidResources true
}
}
lint {
abortOnError false
disable 'MissingTranslation'
}
}
dependencies {
def cameraVersion = "1.4.1"
def lifecycleVersion = "2.8.7"
def roomVersion = "2.6.1"
def glideVersion = "4.16.0"
def nextcloudCommonsVersion = "2.3.5"
def androidCommonsVersion = "1.0.4"
implementation project(path: ':cross-tab-drag-and-drop')
implementation project(path: ':tab-layout-helper')
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.4'
// Android X
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation "androidx.camera:camera-camera2:$cameraVersion"
implementation "androidx.camera:camera-lifecycle:$cameraVersion"
implementation "androidx.camera:camera-view:$cameraVersion"
implementation 'androidx.constraintlayout:constraintlayout:2.2.0'
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleVersion"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion"
implementation 'androidx.preference:preference-ktx:1.2.1'
implementation "androidx.room:room-runtime:$roomVersion"
annotationProcessor "androidx.room:room-compiler:$roomVersion"
implementation 'androidx.core:core-splashscreen:1.0.1'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'androidx.work:work-runtime:2.10.0'
implementation "com.google.android.material:material:$rootProject.materialVersion"
// Glide
implementation "com.github.bumptech.glide:glide:$glideVersion"
annotationProcessor "com.github.bumptech.glide:compiler:$glideVersion"
// Image compression
implementation 'id.zelory:compressor:3.0.1'
// Single-Sign-On
implementation 'com.github.nextcloud:Android-SingleSignOn:1.3.2'
implementation 'com.github.nextcloud:android-common:0.24.0'
implementation "com.github.stefan-niedermann.nextcloud-commons:sso-glide:$nextcloudCommonsVersion"
implementation "com.github.stefan-niedermann.nextcloud-commons:exception:$nextcloudCommonsVersion"
implementation("com.github.stefan-niedermann.nextcloud-commons:markdown:$nextcloudCommonsVersion") {
exclude group: 'org.jetbrains', module: 'annotations-java5'
}
implementation "com.github.stefan-niedermann.android-commons:util:$androidCommonsVersion"
implementation "com.github.stefan-niedermann.android-commons:shared-preferences:$androidCommonsVersion"
implementation "com.github.stefan-niedermann.android-commons:reactive-livedata:$androidCommonsVersion"
// Custom Date / Time Picker for branding support
implementation 'com.wdullaer:materialdatetimepicker:4.2.3'
// Flexbox
implementation 'com.google.android.flexbox:flexbox:3.0.0'
// Custom Color Picker
implementation 'com.github.skydoves:colorpickerview:2.3.0'
// Gson
implementation 'com.google.code.gson:gson:2.11.0'
// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.11.0'
// Zoom Layout
implementation("com.otaliastudios:zoomlayout:1.9.0")
// Tests
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.robolectric:robolectric:4.14.1'
testImplementation 'org.mockito:mockito-core:5.15.2'
testImplementation 'androidx.test:core:1.6.1'
testImplementation 'androidx.arch.core:core-testing:2.2.0'
}

View file

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="38.268356"
android:viewportHeight="38.268356">
<group android:translateX="-2.4874432"
android:translateY="-2.4874432">
<group
android:translateX="13.621622"
android:translateY="13.621622">
<path
android:pathData="M2,7L14,7A1,1 0,0 1,15 8L15,14A1,1 0,0 1,14 15L2,15A1,1 0,0 1,1 14L1,8A1,1 0,0 1,2 7z"
android:fillColor="#fff" />
<path
android:pathData="M2.5,5L13.5,5A0.5,0.5 0,0 1,14 5.5L14,5.5A0.5,0.5 0,0 1,13.5 6L2.5,6A0.5,0.5 0,0 1,2 5.5L2,5.5A0.5,0.5 0,0 1,2.5 5z"
android:fillColor="#fff" />
<path
android:pathData="M3.5,3L12.5,3A0.5,0.5 0,0 1,13 3.5L13,3.5A0.5,0.5 0,0 1,12.5 4L3.5,4A0.5,0.5 0,0 1,3 3.5L3,3.5A0.5,0.5 0,0 1,3.5 3z"
android:fillColor="#fff" />
<path
android:pathData="M4.5,1L11.5,1A0.5,0.5 0,0 1,12 1.5L12,1.5A0.5,0.5 0,0 1,11.5 2L4.5,2A0.5,0.5 0,0 1,4 1.5L4,1.5A0.5,0.5 0,0 1,4.5 1z"
android:fillColor="#fff" />
</group>
</group>
<group
android:translateX="14.3"
android:translateY="26.2"
android:scaleX=".1"
android:scaleY=".1">
<path
android:pathData="M11.908125 40h11.4c4.44 0 7.24 -1.04 9.2 -3.4 2.32 -2.72 3.56 -6.68 3.56 -11.2 0 -4.48 -1.24 -8.44 -3.56 -11.2 -1.96 -2.36 -4.72 -3.36 -9.2 -3.36h-11.4zm6 -5V15.84h5.4c4.52 0 6.76 3.16 6.76 9.6 0 6.4 -2.24 9.56 -6.76 9.56z"
android:fillColor="#fff"/>
<path
android:pathData="M46.894375 27.44h13.96v-5h-13.96v-6.6h15.08v-5h-21.08V40h21.8v-5h-15.8z"
android:fillColor="#fff"/>
<path
android:pathData="M80.333125 40l10 -29.16h-6.04l-6.36 21.96 -6.48 -21.96h-6.04l9.84 29.16z"
android:fillColor="#fff"/>
</group>
</vector>

View file

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
<shortcut
android:enabled="true"
android:icon="@drawable/ic_add_24dp"
android:shortcutId="it.niedermann.nextcloud.deck"
android:shortcutLongLabel="@string/add_card"
android:shortcutShortLabel="@string/simple_add">
<intent
android:action="android.intent.action.VIEW"
android:targetClass="it.niedermann.nextcloud.deck.ui.preparecreate.PrepareCreateActivity"
android:targetPackage="it.niedermann.nextcloud.deck.dev" />
<categories android:name="android.shortcut.conversation" />
</shortcut>
</shortcuts>

View file

@ -0,0 +1,264 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera.any" android:required="false" />
<uses-sdk tools:overrideLibrary="androidx.camera.core, androidx.camera.camera2, androidx.camera.lifecycle, androidx.camera.view" />
<queries>
<package android:name="com.nextcloud.client" />
<package android:name="com.nextcloud.android.qa" />
<package android:name="com.nextcloud.android.beta" />
</queries>
<application
android:name="it.niedermann.nextcloud.deck.DeckApplication"
android:allowBackup="false"
android:fullBackupContent="false"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:enableOnBackInvokedCallback="true"
tools:ignore="GoogleAppIndexingWarning"
tools:targetApi="tiramisu">
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>
<activity
android:name=".ui.main.MainActivity"
android:label="@string/app_name_short"
android:theme="@style/SplashTheme"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
<meta-data
android:name="android.app.searchable"
android:resource="@xml/searchable" />
<meta-data
android:name="android.app.default_searchable"
android:value=".ui.MainActivity" />
</activity>
<activity
android:name=".ui.manageaccounts.ManageAccountsActivity"
android:label="@string/manage_accounts"
android:parentActivityName=".ui.main.MainActivity"
android:windowSoftInputMode="stateHidden" />
<activity
android:name=".ui.takephoto.TakePhotoActivity"
android:theme="@style/TakePhotoTheme"
android:windowSoftInputMode="stateHidden" />
<activity
android:name=".ui.sharetarget.ShareTargetActivity"
android:label="@string/share_add_to_card"
android:theme="@style/SplashTheme"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
</activity>
<activity
android:name=".ui.archivedboards.ArchivedBoardsActivity"
android:label="@string/archived_boards"
android:parentActivityName="it.niedermann.nextcloud.deck.ui.main.MainActivity" />
<activity
android:name=".ui.upcomingcards.UpcomingCardsActivity"
android:label="@string/widget_upcoming_title"
android:parentActivityName="it.niedermann.nextcloud.deck.ui.main.MainActivity" />
<activity
android:name=".ui.card.EditActivity"
android:label="@string/edit"
android:parentActivityName="it.niedermann.nextcloud.deck.ui.main.MainActivity" />
<activity
android:name=".ui.attachments.AttachmentsActivity"
android:label="@string/attachments"
android:parentActivityName="it.niedermann.nextcloud.deck.ui.card.EditActivity"
android:theme="@style/TransparentTheme" />
<activity
android:name=".ui.settings.SettingsActivity"
android:label="@string/simple_settings"
android:parentActivityName="it.niedermann.nextcloud.deck.ui.main.MainActivity" />
<activity
android:name=".ui.ImportAccountActivity"
android:label="@string/app_name" />
<activity
android:name=".ui.preparecreate.PrepareCreateActivity"
android:description="@string/add_a_new_card_using_the_button"
android:label="@string/add_card"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/*" />
</intent-filter>
</activity>
<activity
android:name=".ui.about.AboutActivity"
android:label="@string/about"
android:parentActivityName="it.niedermann.nextcloud.deck.ui.main.MainActivity" />
<activity
android:name=".ui.PushNotificationActivity"
android:label="@string/app_name"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity
android:name=".ui.exception.ExceptionActivity"
android:process=":error_activity" />
<!-- <receiver-->
<!-- android:name="it.niedermann.nextcloud.deck.ui.widget.filter.FilterWidget"-->
<!-- android:label="@string/widget_filter_title">-->
<!-- <intent-filter>-->
<!-- <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />-->
<!-- </intent-filter>-->
<!-- <meta-data-->
<!-- android:name="android.appwidget.provider"-->
<!-- android:resource="@xml/filter_widget_provider" />-->
<!-- </receiver>-->
<service
android:name=".ui.widget.upcoming.UpcomingWidgetService"
android:permission="android.permission.BIND_REMOTEVIEWS" />
<receiver
android:name="it.niedermann.nextcloud.deck.ui.widget.upcoming.UpcomingWidget"
android:label="@string/widget_upcoming_title"
android:exported="true">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/upcoming_widget_provider" />
</receiver>
<activity android:name=".ui.widget.stack.StackWidgetConfigurationActivity"
android:exported="true">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
</activity>
<receiver
android:name="it.niedermann.nextcloud.deck.ui.widget.stack.StackWidget"
android:label="@string/widget_stack_title"
android:exported="true">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/stack_widget_provider" />
</receiver>
<service
android:name=".ui.tiles.EditCardTileService"
android:description="@string/add_a_new_card_using_the_button"
android:icon="@drawable/ic_app_logo"
android:label="@string/add_card"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
android:exported="true">
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
</service>
<service
android:name=".ui.widget.stack.StackWidgetService"
android:permission="android.permission.BIND_REMOTEVIEWS" />
<activity
android:name=".ui.widget.singlecard.SelectCardForWidgetActivity"
android:label="@string/share_add_to_card"
android:theme="@style/SplashTheme"
android:exported="true">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
</activity>
<service
android:name=".ui.widget.singlecard.SingleCardWidgetService"
android:permission="android.permission.BIND_REMOTEVIEWS" />
<receiver
android:name=".ui.widget.singlecard.SingleCardWidget"
android:label="@string/single_card"
android:exported="true">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget_single_card_info" />
</receiver>
<!-- Trigger Google Play services to install the backported photo picker module. -->
<!-- https://developer.android.com/training/data-storage/shared/photopicker#device-availability -->
<!--suppress AndroidDomInspection -->
<service android:name="com.google.android.gms.metadata.ModuleDependencies"
android:enabled="false" android:exported="false" tools:ignore="MissingClass">
<intent-filter>
<action android:name="com.google.android.gms.metadata.MODULE_DEPENDENCIES" />
</intent-filter>
<meta-data android:name="photopicker_activity:0:required" android:value="" />
</service>
</application>
</manifest>

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

View file

@ -0,0 +1,52 @@
package it.niedermann.nextcloud.deck;
import android.app.Application;
import android.os.StrictMode;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import it.niedermann.nextcloud.deck.repository.PreferencesRepository;
import it.niedermann.nextcloud.deck.util.CustomAppGlideModule;
public class DeckApplication extends Application {
private final ExecutorService executor = new ThreadPoolExecutor(0, 2, 0L, TimeUnit.SECONDS, new SynchronousQueue<>());
@Override
public void onCreate() {
final var repo = new PreferencesRepository(this);
if (BuildConfig.DEBUG) {
enableStrictModeLogging();
}
repo.getAppThemeSetting().thenAcceptAsync(repo::setAppTheme, executor);
repo.isDebugModeEnabled().thenAcceptAsync(DeckLog::enablePersistentLogs, executor);
super.onCreate();
}
@Override
public void onLowMemory() {
super.onLowMemory();
DeckLog.error("--- Low memory: Clear Glide cache ---");
CustomAppGlideModule.clearCache(this);
DeckLog.error("--- Low memory: Clear debug log ---");
DeckLog.clearDebugLog();
}
private void enableStrictModeLogging() {
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectAll()
.permitDiskReads()
.penaltyLog()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectAll()
.penaltyLog()
.build());
}
}

View file

@ -0,0 +1,148 @@
package it.niedermann.nextcloud.deck;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.FileProvider;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import it.niedermann.nextcloud.deck.util.MimeTypeUtil;
public class DeckLog {
private DeckLog() {
throw new UnsupportedOperationException("This class must not get instantiated");
}
private static final StringBuffer DEBUG_LOG = new StringBuffer();
private static boolean PERSIST_LOGS = false;
private static final String TAG = DeckLog.class.getSimpleName();
private static final DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
public static void enablePersistentLogs(boolean persistLogs) {
PERSIST_LOGS = persistLogs;
if (!persistLogs) {
clearDebugLog();
}
}
public static String getStacktraceAsString(Throwable e) {
final var sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
return sw.toString();
}
public enum Severity {
VERBOSE, DEBUG, LOG, INFO, WARN, ERROR, WTF
}
public static void verbose(Object... message) {
log(Severity.VERBOSE, 4, message);
}
public static void log(Object... message) {
log(Severity.DEBUG, 4, message);
}
public static void info(Object... message) {
log(Severity.INFO, 4, message);
}
public static void warn(Object... message) {
log(Severity.WARN, 4, message);
}
public static void error(Object... message) {
log(Severity.ERROR, 4, message);
}
public static void wtf(Object... message) {
log(Severity.WTF, 4, message);
}
public static void log(@NonNull Severity severity, Object... message) {
log(severity, 3, message);
}
private static void log(@NonNull Severity severity, int stackTracePosition, Object... messages) {
if (!(PERSIST_LOGS || BuildConfig.DEBUG)) {
return;
}
final StackTraceElement caller = Thread.currentThread().getStackTrace()[stackTracePosition];
final String print = "(" + caller.getFileName() + ":" + caller.getLineNumber() + ") " + caller.getMethodName() + "() → " + TextUtils.join(" ", messages);
if (PERSIST_LOGS) {
DEBUG_LOG
.append(dtf.format(Instant.now().atZone(ZoneId.systemDefault())))
.append(" ")
.append(severity.name())
.append(" ")
.append(print)
.append("\n");
}
switch (severity) {
case DEBUG -> Log.d(TAG, print);
case INFO -> Log.i(TAG, print);
case WARN -> Log.w(TAG, print);
case ERROR -> Log.e(TAG, print);
case WTF -> Log.wtf(TAG, print);
default -> Log.v(TAG, print);
}
}
public static void logError(@Nullable Throwable e) {
if (!(PERSIST_LOGS || BuildConfig.DEBUG)) {
return;
}
if (e == null) {
error("Could not log error because given error was null");
return;
}
final StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
final String stacktrace = sw.toString();
final StackTraceElement caller = Thread.currentThread().getStackTrace()[3];
final String print = "(" + caller.getFileName() + ":" + caller.getLineNumber() + ") " + caller.getMethodName() + "() → " + stacktrace;
if (PERSIST_LOGS) {
DEBUG_LOG.append(print).append("\n");
}
Log.e(TAG, print);
}
@NonNull
public static String getDebugLog() {
return DEBUG_LOG.toString();
}
public static void clearDebugLog() {
DEBUG_LOG.setLength(0);
}
/**
* Writes the current log to a temporary file and starts a share intent.
*/
public static void shareLogAsFile(@NonNull Context context) throws IOException {
Toast.makeText(context, R.string.copying_logs_to_file, Toast.LENGTH_LONG).show();
final File logFile = new File(context.getCacheDir().getAbsolutePath() + "/log.txt");
final FileWriter writer = new FileWriter(logFile);
writer.write(DeckLog.getDebugLog());
writer.close();
context.startActivity(new Intent(Intent.ACTION_SEND)
.putExtra(Intent.EXTRA_TITLE, context.getString(R.string.log_file))
.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".provider", logFile))
.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
.setType(MimeTypeUtil.TEXT_PLAIN));
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,262 @@
package it.niedermann.nextcloud.deck.database;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;
import androidx.room.TypeConverters;
import androidx.sqlite.db.SupportSQLiteDatabase;
import it.niedermann.nextcloud.deck.DeckLog;
import it.niedermann.nextcloud.deck.database.converter.DateTypeConverter;
import it.niedermann.nextcloud.deck.database.converter.EnumConverter;
import it.niedermann.nextcloud.deck.database.dao.AccessControlDao;
import it.niedermann.nextcloud.deck.database.dao.AccountDao;
import it.niedermann.nextcloud.deck.database.dao.ActivityDao;
import it.niedermann.nextcloud.deck.database.dao.AttachmentDao;
import it.niedermann.nextcloud.deck.database.dao.BoardDao;
import it.niedermann.nextcloud.deck.database.dao.CardDao;
import it.niedermann.nextcloud.deck.database.dao.CommentDao;
import it.niedermann.nextcloud.deck.database.dao.JoinBoardWithLabelDao;
import it.niedermann.nextcloud.deck.database.dao.JoinBoardWithPermissionDao;
import it.niedermann.nextcloud.deck.database.dao.JoinBoardWithUserDao;
import it.niedermann.nextcloud.deck.database.dao.JoinCardWithLabelDao;
import it.niedermann.nextcloud.deck.database.dao.JoinCardWithUserDao;
import it.niedermann.nextcloud.deck.database.dao.LabelDao;
import it.niedermann.nextcloud.deck.database.dao.MentionDao;
import it.niedermann.nextcloud.deck.database.dao.PermissionDao;
import it.niedermann.nextcloud.deck.database.dao.StackDao;
import it.niedermann.nextcloud.deck.database.dao.UserDao;
import it.niedermann.nextcloud.deck.database.dao.UserInBoardDao;
import it.niedermann.nextcloud.deck.database.dao.UserInGroupDao;
import it.niedermann.nextcloud.deck.database.dao.projects.JoinCardWithOcsProjectDao;
import it.niedermann.nextcloud.deck.database.dao.projects.OcsProjectDao;
import it.niedermann.nextcloud.deck.database.dao.projects.OcsProjectResourceDao;
import it.niedermann.nextcloud.deck.database.dao.widgets.SingleCardWidgetModelDao;
import it.niedermann.nextcloud.deck.database.dao.widgets.filter.FilterWidgetAccountDao;
import it.niedermann.nextcloud.deck.database.dao.widgets.filter.FilterWidgetBoardDao;
import it.niedermann.nextcloud.deck.database.dao.widgets.filter.FilterWidgetDao;
import it.niedermann.nextcloud.deck.database.dao.widgets.filter.FilterWidgetLabelDao;
import it.niedermann.nextcloud.deck.database.dao.widgets.filter.FilterWidgetProjectDao;
import it.niedermann.nextcloud.deck.database.dao.widgets.filter.FilterWidgetSortDao;
import it.niedermann.nextcloud.deck.database.dao.widgets.filter.FilterWidgetStackDao;
import it.niedermann.nextcloud.deck.database.dao.widgets.filter.FilterWidgetUserDao;
import it.niedermann.nextcloud.deck.database.migration.Migration_10_11;
import it.niedermann.nextcloud.deck.database.migration.Migration_11_12;
import it.niedermann.nextcloud.deck.database.migration.Migration_12_13;
import it.niedermann.nextcloud.deck.database.migration.Migration_13_14;
import it.niedermann.nextcloud.deck.database.migration.Migration_14_15;
import it.niedermann.nextcloud.deck.database.migration.Migration_15_16;
import it.niedermann.nextcloud.deck.database.migration.Migration_16_17;
import it.niedermann.nextcloud.deck.database.migration.Migration_17_18;
import it.niedermann.nextcloud.deck.database.migration.Migration_18_19;
import it.niedermann.nextcloud.deck.database.migration.Migration_19_20;
import it.niedermann.nextcloud.deck.database.migration.Migration_20_21;
import it.niedermann.nextcloud.deck.database.migration.Migration_21_22;
import it.niedermann.nextcloud.deck.database.migration.Migration_22_23;
import it.niedermann.nextcloud.deck.database.migration.Migration_23_24;
import it.niedermann.nextcloud.deck.database.migration.Migration_24_25;
import it.niedermann.nextcloud.deck.database.migration.Migration_25_26;
import it.niedermann.nextcloud.deck.database.migration.Migration_26_27;
import it.niedermann.nextcloud.deck.database.migration.Migration_27_28;
import it.niedermann.nextcloud.deck.database.migration.Migration_28_29;
import it.niedermann.nextcloud.deck.database.migration.Migration_29_30;
import it.niedermann.nextcloud.deck.database.migration.Migration_30_31;
import it.niedermann.nextcloud.deck.database.migration.Migration_31_32;
import it.niedermann.nextcloud.deck.database.migration.Migration_32_33;
import it.niedermann.nextcloud.deck.database.migration.Migration_33_34;
import it.niedermann.nextcloud.deck.database.migration.Migration_8_9;
import it.niedermann.nextcloud.deck.database.migration.Migration_9_10;
import it.niedermann.nextcloud.deck.model.AccessControl;
import it.niedermann.nextcloud.deck.model.Account;
import it.niedermann.nextcloud.deck.model.Attachment;
import it.niedermann.nextcloud.deck.model.Board;
import it.niedermann.nextcloud.deck.model.Card;
import it.niedermann.nextcloud.deck.model.JoinBoardWithLabel;
import it.niedermann.nextcloud.deck.model.JoinBoardWithPermission;
import it.niedermann.nextcloud.deck.model.JoinBoardWithUser;
import it.niedermann.nextcloud.deck.model.JoinCardWithLabel;
import it.niedermann.nextcloud.deck.model.JoinCardWithUser;
import it.niedermann.nextcloud.deck.model.Label;
import it.niedermann.nextcloud.deck.model.Permission;
import it.niedermann.nextcloud.deck.model.Stack;
import it.niedermann.nextcloud.deck.model.User;
import it.niedermann.nextcloud.deck.model.ocs.Activity;
import it.niedermann.nextcloud.deck.model.ocs.comment.DeckComment;
import it.niedermann.nextcloud.deck.model.ocs.comment.Mention;
import it.niedermann.nextcloud.deck.model.ocs.projects.JoinCardWithProject;
import it.niedermann.nextcloud.deck.model.ocs.projects.OcsProject;
import it.niedermann.nextcloud.deck.model.ocs.projects.OcsProjectResource;
import it.niedermann.nextcloud.deck.model.relations.UserInBoard;
import it.niedermann.nextcloud.deck.model.relations.UserInGroup;
import it.niedermann.nextcloud.deck.model.widget.filter.FilterWidget;
import it.niedermann.nextcloud.deck.model.widget.filter.FilterWidgetAccount;
import it.niedermann.nextcloud.deck.model.widget.filter.FilterWidgetBoard;
import it.niedermann.nextcloud.deck.model.widget.filter.FilterWidgetLabel;
import it.niedermann.nextcloud.deck.model.widget.filter.FilterWidgetProject;
import it.niedermann.nextcloud.deck.model.widget.filter.FilterWidgetSort;
import it.niedermann.nextcloud.deck.model.widget.filter.FilterWidgetStack;
import it.niedermann.nextcloud.deck.model.widget.filter.FilterWidgetUser;
import it.niedermann.nextcloud.deck.model.widget.singlecard.SingleCardWidgetModel;
import it.niedermann.nextcloud.deck.remote.api.LastSyncUtil;
@Database(
entities = {
Account.class,
Attachment.class,
AccessControl.class,
Board.class,
Card.class,
JoinBoardWithLabel.class,
JoinBoardWithPermission.class,
JoinBoardWithUser.class,
JoinCardWithLabel.class,
JoinCardWithUser.class,
Label.class,
Permission.class,
Stack.class,
User.class,
Activity.class,
DeckComment.class,
Mention.class,
SingleCardWidgetModel.class,
OcsProject.class,
OcsProjectResource.class,
JoinCardWithProject.class,
UserInGroup.class,
UserInBoard.class,
FilterWidget.class,
FilterWidgetAccount.class,
FilterWidgetBoard.class,
FilterWidgetStack.class,
FilterWidgetLabel.class,
FilterWidgetUser.class,
FilterWidgetProject.class,
FilterWidgetSort.class,
},
exportSchema = false,
version = 34
)
@TypeConverters({DateTypeConverter.class, EnumConverter.class})
public abstract class DeckDatabase extends RoomDatabase {
private static final String DECK_DB_NAME = "NC_DECK_DB.db";
private static volatile DeckDatabase instance;
public static final RoomDatabase.Callback ON_CREATE_CALLBACK = new RoomDatabase.Callback() {
@Override
public void onCreate(@NonNull SupportSQLiteDatabase db) {
super.onCreate(db);
DeckLog.info("Database", DECK_DB_NAME, "created.");
LastSyncUtil.resetAll();
}
};
public static synchronized DeckDatabase getInstance(Context context) {
if (instance == null) {
instance = create(context);
}
return instance;
}
private static DeckDatabase create(final Context context) {
return Room.databaseBuilder(
context,
DeckDatabase.class,
DECK_DB_NAME)
.addMigrations(new Migration_8_9())
.addMigrations(new Migration_9_10())
.addMigrations(new Migration_10_11())
.addMigrations(new Migration_11_12())
.addMigrations(new Migration_12_13())
.addMigrations(new Migration_13_14())
.addMigrations(new Migration_14_15(context))
.addMigrations(new Migration_15_16())
.addMigrations(new Migration_16_17())
.addMigrations(new Migration_17_18())
.addMigrations(new Migration_18_19())
.addMigrations(new Migration_19_20())
.addMigrations(new Migration_20_21())
.addMigrations(new Migration_21_22(context))
.addMigrations(new Migration_22_23())
.addMigrations(new Migration_23_24(context))
.addMigrations(new Migration_24_25())
.addMigrations(new Migration_25_26())
.addMigrations(new Migration_26_27())
.addMigrations(new Migration_27_28())
.addMigrations(new Migration_28_29())
.addMigrations(new Migration_29_30(context))
.addMigrations(new Migration_30_31())
.addMigrations(new Migration_31_32(context))
.addMigrations(new Migration_32_33())
.addMigrations(new Migration_33_34())
.fallbackToDestructiveMigration()
.addCallback(ON_CREATE_CALLBACK)
.build();
}
public abstract AccountDao getAccountDao();
public abstract AccessControlDao getAccessControlDao();
public abstract BoardDao getBoardDao();
public abstract CardDao getCardDao();
public abstract JoinBoardWithLabelDao getJoinBoardWithLabelDao();
public abstract JoinBoardWithPermissionDao getJoinBoardWithPermissionDao();
public abstract JoinBoardWithUserDao getJoinBoardWithUserDao();
public abstract JoinCardWithLabelDao getJoinCardWithLabelDao();
public abstract JoinCardWithUserDao getJoinCardWithUserDao();
public abstract LabelDao getLabelDao();
public abstract ActivityDao getActivityDao();
public abstract PermissionDao getPermissionDao();
public abstract StackDao getStackDao();
public abstract UserDao getUserDao();
public abstract AttachmentDao getAttachmentDao();
public abstract CommentDao getCommentDao();
public abstract MentionDao getMentionDao();
public abstract SingleCardWidgetModelDao getSingleCardWidgetModelDao();
public abstract OcsProjectDao getOcsProjectDao();
public abstract OcsProjectResourceDao getOcsProjectResourceDao();
public abstract JoinCardWithOcsProjectDao getJoinCardWithOcsProjectDao();
public abstract UserInGroupDao getUserInGroupDao();
public abstract UserInBoardDao getUserInBoardDao();
public abstract FilterWidgetDao getFilterWidgetDao();
public abstract FilterWidgetAccountDao getFilterWidgetAccountDao();
public abstract FilterWidgetBoardDao getFilterWidgetBoardDao();
public abstract FilterWidgetStackDao getFilterWidgetStackDao();
public abstract FilterWidgetLabelDao getFilterWidgetLabelDao();
public abstract FilterWidgetUserDao getFilterWidgetUserDao();
public abstract FilterWidgetProjectDao getFilterWidgetProjectDao();
public abstract FilterWidgetSortDao getFilterWidgetSortDao();
}

View file

@ -0,0 +1,18 @@
package it.niedermann.nextcloud.deck.database.converter;
import androidx.room.TypeConverter;
import java.time.Instant;
public class DateTypeConverter {
@TypeConverter
public static Instant toInstant(Long value) {
return value == null ? null : Instant.ofEpochMilli(value);
}
@TypeConverter
public static Long fromInstant(Instant value) {
return value == null ? null : value.toEpochMilli();
}
}

View file

@ -0,0 +1,67 @@
package it.niedermann.nextcloud.deck.database.converter;
import androidx.annotation.Nullable;
import androidx.room.TypeConverter;
import it.niedermann.nextcloud.deck.DeckLog;
import it.niedermann.nextcloud.deck.model.enums.EAttachmentType;
import it.niedermann.nextcloud.deck.model.enums.EDueType;
import it.niedermann.nextcloud.deck.model.enums.ESortCriteria;
import it.niedermann.nextcloud.deck.model.widget.filter.EWidgetType;
public class EnumConverter {
// #### EWidgetType
@TypeConverter
public static EWidgetType toWidgetTypeEnum(Integer value) {
try {
return value == null ? null : EWidgetType.findById(value);
} catch (IllegalArgumentException e) {
DeckLog.error(EWidgetType.class.getSimpleName(), value, "not found. Falling back to generic", EWidgetType.FILTER_WIDGET);
return EWidgetType.FILTER_WIDGET;
}
}
@TypeConverter
public static Integer fromWidgetTypeEnum(EWidgetType value) {
return value == null ? null : value.getId();
}
// #### EDueType
@TypeConverter
@Nullable
public static EDueType toDueTypeEnum(@Nullable Integer value) {
return value == null ? null : EDueType.findById(value);
}
@TypeConverter
@Nullable
public static Integer fromDueTypeEnum(@Nullable EDueType value) {
return value == null ? null : value.getId();
}
// #### ESortCriteria
@TypeConverter
@Nullable
public static ESortCriteria toSortCriteriaEnum(@Nullable Integer value) {
return value == null ? null : ESortCriteria.findById(value);
}
@TypeConverter
@Nullable
public static Integer fromSortCriteriaEnum(@Nullable ESortCriteria value) {
return value == null ? null : value.getId();
}
// #### EAttachmentType
@TypeConverter
@Nullable
public static EAttachmentType toEAttachmentType(@Nullable String value) {
return value == null ? null : EAttachmentType.findByValue(value);
}
@TypeConverter
@Nullable
public static String fromEAttachmentType(@Nullable EAttachmentType value) {
return value == null ? null : value.getValue();
}
}

View file

@ -0,0 +1,35 @@
package it.niedermann.nextcloud.deck.database.dao;
import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Query;
import java.util.List;
import java.util.Set;
import it.niedermann.nextcloud.deck.model.AccessControl;
@Dao
public interface AccessControlDao extends GenericDao<AccessControl> {
@Query("SELECT * FROM AccessControl WHERE accountId = :accountId and id = :remoteId")
LiveData<AccessControl> getAccessControlByRemoteId(final long accountId, final long remoteId);
@Query("SELECT * FROM AccessControl WHERE accountId = :accountId and boardId = :localBoardId and status <> 3")
LiveData<List<AccessControl>> getAccessControlByLocalBoardId(final long accountId, final long localBoardId);
@Query("SELECT * FROM AccessControl WHERE accountId = :accountId and boardId = :localBoardId and status <> 3")
List<AccessControl> getAccessControlByLocalBoardIdDirectly(final long accountId, final long localBoardId);
@Query("SELECT * FROM AccessControl WHERE accountId = :accountId and id = :remoteId")
AccessControl getAccessControlByRemoteIdDirectly(final long accountId, final long remoteId);
@Query("SELECT * FROM AccessControl WHERE accountId = :accountId and boardId = :boardId and (status<>1 or id is null or lastModified <> lastModifiedLocal)")
List<AccessControl> getLocallyChangedAccessControl(long accountId, long boardId);
@Query("SELECT distinct boardId FROM AccessControl WHERE accountId = :accountId and (status<>1 or id is null or lastModified <> lastModifiedLocal)")
List<Long> getBoardIDsOfLocallyChangedAccessControl(long accountId);
@Query("DELETE FROM AccessControl WHERE boardId = :localBoardId and localId not in (:idsToKeep)")
void deleteAccessControlsForBoardWhereLocalIdsNotInDirectly(long localBoardId, Set<Long> idsToKeep);
}

View file

@ -0,0 +1,51 @@
package it.niedermann.nextcloud.deck.database.dao;
import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Query;
import java.util.List;
import it.niedermann.nextcloud.deck.model.Account;
@Dao
public interface AccountDao extends GenericDao<Account> {
@Query("SELECT count(*) FROM account")
int countAccountsDirectly();
@Query("SELECT count(*) FROM account")
LiveData<Integer> countAccounts();
@Query("DELETE from account where id = :id")
void deleteById(long id);
@Query("SELECT * from account where id = :id")
Account getAccountByIdDirectly(long id);
@Query("SELECT * from account where id = :id")
LiveData<Account> getAccountById(long id);
@Query("SELECT * from account where name = :name")
LiveData<Account> getAccountByName(String name);
@Query("SELECT * from account where name = :name")
Account getAccountByNameDirectly(String name);
@Query("SELECT * from account")
LiveData<List<Account>> getAllAccounts();
@Query("SELECT * from account")
List<Account> getAllAccountsDirectly();
@Query("SELECT * from account a where a.url like :hostLike and exists (select 1 from board b where b.id = :boardRemoteId and a.id = b.accountId)")
LiveData<List<Account>> readAccountsForHostWithReadAccessToBoard(String hostLike, long boardRemoteId);
@Query("SELECT * from account a where a.url like :hostLike and exists (select 1 from board b where b.id = :boardRemoteId and a.id = b.accountId)")
List<Account> readAccountsForHostWithReadAccessToBoardDirectly(String hostLike, long boardRemoteId);
@Query("SELECT a.color FROM account a where a.id = :accountId")
LiveData<Integer> getAccountColor(long accountId);
@Query("SELECT a.color FROM account a where a.id = :accountId")
Integer getAccountColorDirectly(long accountId);
}

View file

@ -0,0 +1,19 @@
package it.niedermann.nextcloud.deck.database.dao;
import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Query;
import java.util.List;
import it.niedermann.nextcloud.deck.model.ocs.Activity;
@Dao
public interface ActivityDao extends GenericDao<Activity> {
@Query("SELECT * FROM activity WHERE cardId = :localCardId order by lastModified desc")
LiveData<List<Activity>> getActivitiesForCard(final long localCardId);
@Query("SELECT * FROM activity WHERE accountId = :accountId and id = :remoteActivityId")
Activity getActivityByRemoteIdDirectly(long accountId, long remoteActivityId);
}

View file

@ -0,0 +1,34 @@
package it.niedermann.nextcloud.deck.database.dao;
import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Query;
import java.util.List;
import it.niedermann.nextcloud.deck.model.Attachment;
@Dao
public interface AttachmentDao extends GenericDao<Attachment> {
@Query("SELECT * FROM attachment where cardId = :cardId")
LiveData<List<Attachment>> getAttachmentsForCard(long cardId);
@Query("SELECT * FROM attachment where accountId = :accountId and id = :remoteId")
Attachment getAttachmentByRemoteIdDirectly(long accountId, Long remoteId);
@Query("SELECT * FROM attachment where accountId = :accountId and localId = :id")
Attachment getAttachmentByLocalIdDirectly(long accountId, Long id);
@Query("SELECT * FROM attachment WHERE accountId = :accountId and cardId = :localCardId and (status<>1 or id is null or lastModified <> lastModifiedLocal)")
List<Attachment> getLocallyChangedAttachmentsByLocalCardIdDirectly(long accountId, long localCardId);
@Query("SELECT * FROM attachment WHERE accountId = :accountId and (status<>1 or id is null or lastModified <> lastModifiedLocal)")
List<Attachment> getLocallyChangedAttachmentsDirectly(long accountId);
@Query("SELECT a.* FROM attachment a inner join card c on c.localId = a.cardId " +
"WHERE c.stackId = :localStackId and (a.status<>1 or a.id is null or a.lastModified <> a.lastModifiedLocal)")
List<Attachment> getLocallyChangedAttachmentsForStackDirectly(long localStackId);
@Query("SELECT * FROM attachment WHERE accountId = :accountId and cardId = :localCardId")
List<Attachment> getAttachmentsForLocalCardIdDirectly(long accountId, Long localCardId);
}

View file

@ -0,0 +1,93 @@
package it.niedermann.nextcloud.deck.database.dao;
import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Query;
import androidx.room.Transaction;
import java.util.List;
import it.niedermann.nextcloud.deck.model.Board;
import it.niedermann.nextcloud.deck.model.full.FullBoard;
@Dao
public interface BoardDao extends GenericDao<Board> {
@Transaction
@Query("SELECT * FROM board WHERE accountId = :accountId and archived = :archived and (deletedAt = 0 or deletedAt is null) and status <> 3 order by title asc")
LiveData<List<Board>> getNotDeletedBoards(long accountId, int archived);
@Transaction
@Query("SELECT * FROM board WHERE accountId = :accountId and archived = :archived and (deletedAt = 0 or deletedAt is null) and status <> 3 order by title asc")
List<Board> getNotDeletedBoardsDirectly(long accountId, int archived);
@Transaction
@Query("SELECT * FROM board WHERE accountId = :accountId and archived = :archived and (deletedAt = 0 or deletedAt is null) and status <> 3 order by title asc")
LiveData<List<FullBoard>> getNotDeletedFullBoards(long accountId, int archived);
@Query("SELECT * FROM board WHERE accountId = :accountId and id = :remoteId")
LiveData<Board> getBoardByRemoteId(final long accountId, final long remoteId);
@Query("SELECT * FROM board WHERE accountId = :accountId and id = :remoteId")
Board getBoardByRemoteIdDirectly(long accountId, long remoteId);
@Query("SELECT * FROM board WHERE localId = :localId")
Board getBoardByLocalIdDirectly(long localId);
@Transaction
@Query("SELECT * FROM board WHERE accountId = :accountId and id = :remoteId")
FullBoard getFullBoardByRemoteIdDirectly(long accountId, long remoteId);
@Transaction
@Query("SELECT * FROM board WHERE accountId = :accountId and localId = :localId")
FullBoard getFullBoardByLocalIdDirectly(long accountId, long localId);
@Transaction
@Query("SELECT * FROM board WHERE accountId = :accountId and (status<>1 or id is null or lastModified <> lastModifiedLocal)")
List<FullBoard> getLocallyChangedBoardsDirectly(long accountId);
@Transaction
@Query("SELECT * FROM board WHERE accountId = :accountId and localId = :localId")
LiveData<FullBoard> getFullBoardById(final long accountId, final long localId);
@Query("SELECT b.* FROM board b JOIN stack s ON s.boardId = b.localId JOIN card c ON s.localId = c.stackId where c.localId = :localCardId")
Board getBoardByLocalCardIdDirectly(long localCardId);
@Query("SELECT b.localId FROM board b JOIN stack s ON s.boardId = b.localId JOIN card c ON s.localId = c.stackId where c.localId = :localCardId")
Long getBoardLocalIdByLocalCardIdDirectly(long localCardId);
@Transaction
@Query("SELECT b.* FROM board b JOIN stack s ON s.boardId = b.localId JOIN card c ON c.localId = :localCardId and c.stackId = s.localId")
FullBoard getFullBoardByLocalCardIdDirectly(long localCardId);
@Transaction
@Query("SELECT * FROM board WHERE accountId = :accountId")
List<FullBoard> getAllFullBoards(long accountId);
@Query("SELECT * FROM board WHERE accountId = :accountId and archived = 0 and permissionEdit = 1 and (deletedAt = 0 or deletedAt is null) and status <> 3 order by title asc")
LiveData<List<Board>> getBoardsWithEditPermissionsForAccount(long accountId);
@Query("SELECT s.boardId " +
"FROM card c " +
"inner join stack s on s.localId = c.stackId " +
"WHERE c.id = :cardRemoteId and c.accountId = :accountId")
LiveData<Long> getLocalBoardIdByCardRemoteIdAndAccountId(long cardRemoteId, long accountId);
@Query("SELECT s.boardId " +
"FROM card c " +
"inner join stack s on s.localId = c.stackId " +
"WHERE c.id = :cardRemoteId and c.accountId = :accountId")
Long getBoardLocalIdByAccountAndCardRemoteIdDirectly(long accountId, long cardRemoteId);
@Query("SELECT count(*) FROM board WHERE accountId = :accountId and archived = 1 and (deletedAt = 0 or deletedAt is null) and status <> 3")
LiveData<Integer> countArchivedBoards(long accountId);
@Query("SELECT * FROM board WHERE accountId = :accountId and title = :title")
Board getBoardForAccountByNameDirectly(long accountId, String title);
@Query("SELECT b.color FROM board b where b.localId = :localBoardId and b.accountId = :accountId")
Integer getBoardColorByLocalIdDirectly(long accountId, long localBoardId);
@Query("SELECT b.color FROM board b where b.localId = :localBoardId and b.accountId = :accountId")
LiveData<Integer> getBoardColor(long accountId, long localBoardId);
}

View file

@ -0,0 +1,145 @@
package it.niedermann.nextcloud.deck.database.dao;
import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Query;
import androidx.room.RawQuery;
import androidx.room.Transaction;
import androidx.sqlite.db.SupportSQLiteQuery;
import java.util.List;
import it.niedermann.nextcloud.deck.model.Card;
import it.niedermann.nextcloud.deck.model.full.FullCard;
import it.niedermann.nextcloud.deck.model.full.FullCardWithProjects;
@Dao
public interface CardDao extends GenericDao<Card> {
String QUERY_UPCOMING_CARDS = "SELECT c.* FROM card c " +
"join stack s on s.localId = c.stackId " +
"join board b on b.localId = s.boardId " +
"WHERE b.archived = 0 and c.archived = 0 and b.status <> 3 and s.status <> 3 and c.status <> 3 " +
"and (c.deletedAt is null or c.deletedAt = 0) " +
"and (s.deletedAt is null or s.deletedAt = 0) " +
"and (b.deletedAt is null or b.deletedAt = 0) " +
"and (c.done is null or c.done = 0) " +
// Full Logic: (hasDueDate AND isIn_PRIVATE_Board) OR (isInSharedBoard AND (assignedToMe OR (hasDueDate AND noAssignees)))
"and (" +
"(c.dueDate is not null AND NOT exists(select 1 from AccessControl ac where ac.boardId = b.localId and ac.status <> 3))" + //(hasDueDate AND isInPrivateBoard)
"OR (" +
"exists(select 1 from AccessControl ac where ac.boardId = b.localId and ac.status <> 3) " + //OR (isInSharedBoard AND
"AND (" +
"(c.dueDate is not null AND not exists(select 1 from JoinCardWithUser j where j.cardId = c.localId)) " + // hasDueDate AND noAssignees OR
"OR exists(select 1 from JoinCardWithUser j where j.cardId = c.localId and j.userId in (select u.localId from user u where u.uid in (select a.userName from Account a)))" + //(assignedToMe
")" +
")" +
")" +
"ORDER BY c.dueDate asc";
@Query("SELECT * FROM card WHERE stackId = :localStackId order by `order`, createdAt asc")
LiveData<List<Card>> getCardsForStack(final long localStackId);
@Query("SELECT * FROM card WHERE accountId = :accountId and id = :remoteId")
LiveData<Card> getCardByRemoteId(final long accountId, final long remoteId);
@Transaction
@Query("SELECT * FROM card WHERE accountId = :accountId and id = :remoteId")
FullCard getFullCardByRemoteIdDirectly(final long accountId, final long remoteId);
@Query("SELECT * FROM card WHERE accountId = :accountId and localId = :localId")
Card getCardByLocalIdDirectly(final long accountId, final long localId);
@Transaction
@Query("SELECT * FROM card WHERE accountId = :accountId and localId = :localId")
FullCard getFullCardByLocalIdDirectly(final long accountId, final long localId);
@Transaction
// v not deleted!
@Query("SELECT * FROM card WHERE accountId = :accountId AND archived = 0 AND stackId = :localStackId and status<>3 order by `order`, createdAt asc")
LiveData<List<FullCard>> getFullCardsForStack(final long accountId, final long localStackId);
@Transaction
@RawQuery(observedEntities = Card.class)
LiveData<List<FullCard>> getFilteredFullCardsForStack(SupportSQLiteQuery query);
@Transaction
@RawQuery(observedEntities = Card.class)
List<FullCard> getFilteredFullCardsForStackDirectly(SupportSQLiteQuery query);
@Transaction
@Query("SELECT * FROM card WHERE accountId = :accountId AND stackId = :localStackId order by `order`, createdAt asc")
List<FullCard> getFullCardsForStackDirectly(final long accountId, final long localStackId);
@Transaction
@Query("SELECT * FROM card WHERE accountId = :accountId and localId = :localCardId")
LiveData<FullCard> getFullCardByLocalId(final long accountId, final long localCardId);
@Transaction
@Query("SELECT * FROM card WHERE accountId = :accountId and localId = :localCardId")
LiveData<FullCardWithProjects> getFullCardWithProjectsByLocalId(final long accountId, final long localCardId);
@Transaction
@Query("SELECT * FROM card WHERE accountId = :accountId and id = :remoteId")
LiveData<FullCard> getFullCardByRemoteId(final long accountId, final long remoteId);
@Query("SELECT * FROM card WHERE accountId = :accountId and id = :remoteId")
Card getCardByRemoteIdDirectly(long accountId, long remoteId);
@Transaction
@Query("SELECT * FROM card WHERE accountId = :accountId and (status<>1 or id is null or lastModified <> lastModifiedLocal)")
List<FullCard> getLocallyChangedCardsDirectly(long accountId);
@Transaction
@Query("SELECT * FROM card WHERE accountId = :accountId and stackId = :localStackId and (status<>1 or id is null or lastModified <> lastModifiedLocal)")
List<FullCard> getLocallyChangedCardsByLocalStackIdDirectly(long accountId, long localStackId);
@Query("SELECT * FROM card c WHERE accountId = :accountId and exists ( select 1 from DeckComment dc where dc.objectId = c.localId and dc.status<>1)")
List<Card> getCardsWithLocallyChangedCommentsDirectly(Long accountId);
@Query("SELECT * FROM card c WHERE stackId = :localStackId and exists ( select 1 from DeckComment dc where dc.objectId = c.localId and dc.status<>1)")
List<Card> getCardsWithLocallyChangedCommentsForStackDirectly(Long localStackId);
@Query("SELECT count(*) FROM card c WHERE accountId = :accountId and stackId = :localStackId and status <> 3")
int countCardsInStackDirectly(long accountId, long localStackId);
@Query("SELECT coalesce(MAX(`order`), -1) FROM card c WHERE stackId = :localStackId and status <> 3")
Integer getHighestOrderInStack(Long localStackId);
@Query("SELECT c.stackId FROM card c WHERE localId = :localCardId")
Long getLocalStackIdByLocalCardId(Long localCardId);
@Transaction
@Query("SELECT * FROM card c WHERE " +
"exists(select 1 from Stack s join Board b on s.boardId = b.localId where s.localId = c.stackId " +
"and b.archived = 0 " +
"and not exists(select 1 from AccessControl ac where ac.boardId = b.localId and status <> 3)) " +
"and dueDate is not null " +
"and (coalesce(:accountIds, null) is null or accountId in (:accountIds)) " +
"and status <> 3 " +
"and archived = 0")
List<FullCard> getFullCardsForNonSharedBoardsWithDueDateForUpcomingCardsWidgetDirectly(List<Long> accountIds);
@Transaction
@Query(QUERY_UPCOMING_CARDS)
LiveData<List<FullCard>> getUpcomingCards();
@Transaction
@Query(QUERY_UPCOMING_CARDS)
List<FullCard> getUpcomingCardsDirectly();
@Transaction
@Query("SELECT c.* FROM card c " +
"inner join Stack s on c.stackId = s.localId " +
"WHERE s.boardId = :localBoardId " +
"and (c.title like :term or c.description like :term) " +
"and c.accountId = :accountId " +
"and s.accountId = :accountId " +
"and c.status <> 3 " +
"and s.status <> 3 " +
"and c.archived = 0 " +
"order by s.`order`, c.`order`")
LiveData<List<FullCard>> searchCard(long accountId, long localBoardId, String term);
@Query("SELECT s.localId FROM card s")
List<Long> getAllIDs();
}

View file

@ -0,0 +1,47 @@
package it.niedermann.nextcloud.deck.database.dao;
import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Query;
import androidx.room.Transaction;
import java.util.List;
import it.niedermann.nextcloud.deck.model.ocs.comment.DeckComment;
import it.niedermann.nextcloud.deck.model.ocs.comment.full.FullDeckComment;
@Dao
public interface CommentDao extends GenericDao<DeckComment> {
@Query("SELECT * FROM DeckComment where accountId = :accountId and id = :remoteId")
DeckComment getCommentByRemoteIdDirectly(long accountId, Long remoteId);
@Query("SELECT * FROM DeckComment where accountId = :accountId and localId = :id")
DeckComment getCommentByLocalIdDirectly(long accountId, Long id);
@Query("SELECT * FROM DeckComment WHERE accountId = :accountId and objectId = :localCardId " +
"and (status<>1 or id is null or lastModified <> lastModifiedLocal) order by localId asc")
List<DeckComment> getLocallyChangedCommentsByLocalCardIdDirectly(long accountId, long localCardId);
@Query("SELECT * FROM DeckComment WHERE accountId = :accountId and (status<>1 or id is null or lastModified <> lastModifiedLocal)")
List<DeckComment> getLocallyChangedCommentsDirectly(long accountId);
@Query("SELECT * FROM DeckComment WHERE accountId = :accountId and objectId = :localCardId")
List<DeckComment> getCommentsForLocalCardIdDirectly(long accountId, Long localCardId);
@Query("SELECT * FROM DeckComment where objectId = :localCardId")
List<DeckComment> getCommentByLocalCardIdDirectly(Long localCardId);
@Query("SELECT * FROM DeckComment where objectId = :localCardId order by creationDateTime desc")
LiveData<List<DeckComment>> getCommentByLocalCardId(Long localCardId);
@Transaction
@Query("SELECT * FROM DeckComment where objectId = :localCardId order by creationDateTime desc, localId desc")
LiveData<List<FullDeckComment>> getFullCommentByLocalCardId(Long localCardId);
@Query("SELECT id FROM DeckComment where localId = :localId")
Long getRemoteCommentIdForLocalIdDirectly(Long localId);
@Query("SELECT localId FROM DeckComment where id = :remoteId and accountId = :accountId")
Long getLocalCommentIdForRemoteIdDirectly(long accountId, Long remoteId);
}

View file

@ -0,0 +1,23 @@
package it.niedermann.nextcloud.deck.database.dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Update;
public interface GenericDao<T> {
@Insert
long insert(T entity);
@SuppressWarnings("unchecked")
@Insert
long[] insert(T... entity);
@SuppressWarnings("unchecked")
@Update
void update(T... entity);
@SuppressWarnings("unchecked")
@Delete
void delete(T... entity);
}

View file

@ -0,0 +1,12 @@
package it.niedermann.nextcloud.deck.database.dao;
import androidx.room.Dao;
import androidx.room.Query;
import it.niedermann.nextcloud.deck.model.JoinBoardWithLabel;
@Dao
public interface JoinBoardWithLabelDao extends GenericDao<JoinBoardWithLabel> {
@Query("DELETE FROM joinboardwithlabel WHERE boardId = :localId")
void deleteByBoardId(long localId);
}

View file

@ -0,0 +1,13 @@
package it.niedermann.nextcloud.deck.database.dao;
import androidx.room.Dao;
import androidx.room.Query;
import it.niedermann.nextcloud.deck.model.JoinBoardWithPermission;
@Dao
public interface JoinBoardWithPermissionDao extends GenericDao<JoinBoardWithPermission> {
@Query("DELETE FROM joinboardwithpermission WHERE boardId = :localId")
void deleteByBoardId(long localId);
}

View file

@ -0,0 +1,13 @@
package it.niedermann.nextcloud.deck.database.dao;
import androidx.room.Dao;
import androidx.room.Query;
import it.niedermann.nextcloud.deck.model.JoinBoardWithUser;
@Dao
public interface JoinBoardWithUserDao extends GenericDao<JoinBoardWithUser> {
@Query("DELETE FROM joinboardwithuser WHERE boardId = :localId")
void deleteByBoardId(long localId);
}

View file

@ -0,0 +1,52 @@
package it.niedermann.nextcloud.deck.database.dao;
import androidx.room.Dao;
import androidx.room.Query;
import java.util.List;
import it.niedermann.nextcloud.deck.model.JoinCardWithLabel;
@Dao
public interface JoinCardWithLabelDao extends GenericDao<JoinCardWithLabel> {
@Query("DELETE FROM joincardwithlabel WHERE cardId = :localCardId and status == 1") // only if UP_TO_DATE
void deleteByCardId(long localCardId);
@Query("DELETE FROM joincardwithlabel WHERE cardId = :localCardId and labelId = :labelId")
void deleteByCardIdAndLabelId(long localCardId, long labelId);
@Query("Update joincardwithlabel set status = :status WHERE cardId = :localCardId and labelId = :localLabelId")
void setDbStatus(long localCardId, long localLabelId, int status);
@Query("select labelId from joincardwithlabel WHERE cardId = :localCardId and labelId IN (:localLabelIds) and status <> 3") // not LOCAL_DELETED
List<Long> filterDeleted(long localCardId, List<Long> localLabelIds);
@Query("select * from joincardwithlabel WHERE cardId = :localCardId and labelId = :localLabelId")
JoinCardWithLabel getJoin(Long localLabelId, Long localCardId);
@Query("select l.id as labelId, c.id as cardId, j.status from joincardwithlabel j " +
"inner join card c on j.cardId = c.localId " +
"inner join label l on j.labelId = l.localId " +
"WHERE j.status <> 1") // not UP_TO_DATE
List<JoinCardWithLabel> getAllDeletedJoinsWithRemoteIDs();
@Query("select l.id as labelId, c.id as cardId, j.status from joincardwithlabel j " +
"inner join card c on j.cardId = c.localId " +
"inner join label l on j.labelId = l.localId " +
"WHERE j.cardId = :localCardId and j.labelId = :localLabelId") // not UP_TO_DATE
JoinCardWithLabel getRemoteIdsForJoin(long localCardId, long localLabelId);
@Query("select * from joincardwithlabel WHERE status <> 1") // not UP_TO_DATE
List<JoinCardWithLabel> getAllChangedJoins();
@Query("select j.* from joincardwithlabel j inner join card c on j.cardId = c.localId WHERE c.stackId = :localStackId and j.status <> 1") // not UP_TO_DATE
List<JoinCardWithLabel> getAllChangedJoinsForStack(Long localStackId);
@Query("delete from joincardwithlabel " +
"where cardId = (select c.localId from card c where c.accountId = :accountId and c.id = :remoteCardId) " +
"and labelId = (select l.localId from label l where l.accountId = :accountId and l.id = :remoteLabelId)")
void deleteJoinedLabelForCardPhysicallyByRemoteIDs(Long accountId, Long remoteCardId, Long remoteLabelId);
@Query("select count(*) from joincardwithlabel WHERE labelId = :localLabelId and status <> 3") // not locally deleted
int countCardsWithLabelDirectly(long localLabelId);
}

View file

@ -0,0 +1,49 @@
package it.niedermann.nextcloud.deck.database.dao;
import androidx.room.Dao;
import androidx.room.Query;
import java.util.List;
import it.niedermann.nextcloud.deck.model.JoinCardWithUser;
@Dao
public interface JoinCardWithUserDao extends GenericDao<JoinCardWithUser> {
@Query("DELETE FROM joincardwithuser WHERE cardId = :localId and status=1") // 1 = UP_TO_DATE
void deleteByCardId(long localId);
@Query("Update joincardwithuser set status = :status WHERE cardId = :localCardId and userId = :localUserId")
void setDbStatus(long localCardId, long localUserId, int status);
@Query("DELETE FROM joincardwithuser WHERE cardId = :localCardId and userId = :localUserId")
void deleteByCardIdAndUserIdPhysically(long localCardId, long localUserId);
@Query("DELETE FROM joincardwithuser " +
"WHERE cardid in (select c.localId from Card c join Stack s on c.stackId = s.localId and s.boardId = :localBoardId) " +
"and userId not in (select userId from UserInBoard where boardId = :localBoardId)")
void deleteJoinedUsersForCardsInBoardWithoutPermissionPhysically(long localBoardId);
@Query("select * FROM joincardwithuser WHERE cardId = :localCardId and userId = :localUserId")
JoinCardWithUser getJoin(Long localUserId, Long localCardId);
@Query("select u.localId as userId, c.id as cardId, j.status from joincardwithuser j " +
"inner join card c on j.cardId = c.localId " +
"inner join user u on j.userId = u.localId " +
"WHERE j.status <> 1") // not UP_TO_DATE
List<JoinCardWithUser> getChangedJoinsWithRemoteIDs();
@Query("select u.localId as userId, c.id as cardId, j.status from joincardwithuser j " +
"inner join card c on j.cardId = c.localId " +
"inner join user u on j.userId = u.localId " +
"WHERE c.stackId = :localStackId " +
"AND j.status <> 1") // not UP_TO_DATE
List<JoinCardWithUser> getChangedJoinsWithRemoteIDsForStack(Long localStackId);
@Query("delete from joincardwithuser " +
"where cardId = (select c.localId from card c where c.accountId = :accountId and c.id = :remoteCardId) " +
"and userId = (select u.localId from user u where u.accountId = :accountId and u.uid = :userUid)")
void deleteJoinedUserForCardPhysicallyByRemoteIDs(Long accountId, Long remoteCardId, String userUid);
@Query("select userId from joincardwithuser WHERE cardId = :localCardId and userId IN (:assignedUserIDs) and status <> 3") // not LOCAL_DELETED
List<Long> filterDeleted(long localCardId, List<Long> assignedUserIDs);
}

View file

@ -0,0 +1,57 @@
package it.niedermann.nextcloud.deck.database.dao;
import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Query;
import java.util.List;
import it.niedermann.nextcloud.deck.model.Label;
@Dao
public interface LabelDao extends GenericDao<Label> {
// @Query("SELECT * FROM label WHERE stackId = :localStackId")
// LiveData<List<Label>> getLabelsForStack(final long localStackId);
@Query("SELECT * FROM label WHERE accountId = :accountId and id = :remoteId")
LiveData<Label> getLabelByRemoteId(final long accountId, final long remoteId);
@Query("SELECT * FROM label WHERE localId = :localId")
LiveData<Label> getLabelByLocalId(final long localId);
@Query("SELECT * FROM label WHERE accountId = :accountId and id = :remoteId")
Label getLabelByRemoteIdDirectly(final long accountId, final long remoteId);
@Query("SELECT * FROM label WHERE localId IN (:labelIDs) and status <> 3 order by title asc") // not LOCAL_DELETED
List<Label> getLabelsByIdsDirectly(List<Long> labelIDs);
@Query("SELECT * FROM label WHERE localId = :localLabelID")
Label getLabelsByIdDirectly(final long localLabelID);
@Query("SELECT l.* FROM label l WHERE accountId = :accountId" +
" AND NOT EXISTS (" +
"select 1 from joincardwithlabel jl where jl.labelId = l.localId " +
"and jl.cardId = :notYetAssignedToLocalCardId AND status <> 3" + // not LOCAL_DELETED
") " +
" AND boardId = :boardId and title LIKE :searchTerm")
LiveData<List<Label>> searchNotYetAssignedLabelsByTitle(final long accountId, final long boardId, final long notYetAssignedToLocalCardId, String searchTerm);
@Query("SELECT * FROM label WHERE accountId = :accountId and (status<>1 or id is null or lastModified <> lastModifiedLocal)")
List<Label> getLocallyChangedLabelsDirectly(long accountId);
@Query("SELECT l.* " +
"FROM label l LEFT JOIN joincardwithlabel j ON j.labelId = l.localId " +
"WHERE l.accountId = :accountId AND l.boardId = :boardId " +
"AND NOT EXISTS (" +
"select 1 from joincardwithlabel jl where jl.labelId = l.localId " +
"and jl.cardId = :notAssignedToLocalCardId AND status <> 3" + // not LOCAL_DELETED
") " +
"GROUP BY l.localId ORDER BY count(*) DESC")
LiveData<List<Label>> findProposalsForLabelsToAssign(long accountId, long boardId, long notAssignedToLocalCardId);
@Query("select * from label WHERE boardId = :boardId and title = :title")
Label getLabelByBoardIdAndTitleDirectly(long boardId, String title);
}

View file

@ -0,0 +1,18 @@
package it.niedermann.nextcloud.deck.database.dao;
import androidx.room.Dao;
import androidx.room.Query;
import java.util.List;
import it.niedermann.nextcloud.deck.model.ocs.comment.Mention;
@Dao
public interface MentionDao extends GenericDao<Mention> {
@Query("delete from mention WHERE commentId = :commentID")
void clearMentionsForCommentId(long commentID);
@Query("select * from mention WHERE commentId = :commentID")
List<Mention> getMentionsForCommentIdDirectly(long commentID);
}

View file

@ -0,0 +1,10 @@
package it.niedermann.nextcloud.deck.database.dao;
import androidx.room.Dao;
import it.niedermann.nextcloud.deck.model.Permission;
@Dao
public interface PermissionDao extends GenericDao<Permission> {
}

View file

@ -0,0 +1,73 @@
package it.niedermann.nextcloud.deck.database.dao;
import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Query;
import androidx.room.Transaction;
import java.util.List;
import it.niedermann.nextcloud.deck.model.Stack;
import it.niedermann.nextcloud.deck.model.full.FullStack;
@Dao
public interface StackDao extends GenericDao<Stack> {
@Query("SELECT * FROM stack WHERE accountId = :accountId AND boardId = :localBoardId and status<>3 and (deletedAt is null or deletedAt = 0) order by `order` asc")
LiveData<List<Stack>> getStacksForBoard(final long accountId, final long localBoardId);
@Query("SELECT * FROM stack WHERE accountId = :accountId and boardId = :localBoardId and id = :remoteId")
LiveData<Stack> getStackByRemoteId(final long accountId, final long localBoardId, final long remoteId);
@Query("SELECT * FROM stack WHERE localId = :localStackId")
Stack getStackByLocalIdDirectly(final long localStackId);
@Transaction
@Query("SELECT * FROM stack WHERE localId = :localStackId")
FullStack getFullStackByLocalIdDirectly(final long localStackId);
@Transaction
@Query("SELECT * FROM stack WHERE accountId = :accountId and boardId = :localBoardId and id = :remoteId")
FullStack getFullStackByRemoteIdDirectly(final long accountId, final long localBoardId, final long remoteId);
@Transaction
@Query("SELECT * FROM stack WHERE accountId = :accountId and boardId = :localBoardId and id = :remoteId")
LiveData<FullStack> getFullStackByRemoteId(final long accountId, final long localBoardId, final long remoteId);
@Transaction
@Query("SELECT * FROM stack WHERE accountId = :accountId and localId = :localId")
LiveData<FullStack> getFullStack(long accountId, long localId);
@Query("SELECT localId FROM stack WHERE accountId = :accountId")
List<Long> getLocalStackIdsByAccountIdDirectly(long accountId);
@Query("SELECT localId FROM stack WHERE boardId = :localBoardId")
List<Long> getLocalStackIdsByLocalBoardIdDirectly(long localBoardId);
@Transaction
@Query("SELECT * FROM stack WHERE accountId = :accountId and boardId = :localBoardId and (status<>1 or id is null or lastModified <> lastModifiedLocal)")
List<FullStack> getLocallyChangedStacksForBoardDirectly(long accountId, long localBoardId);
@Transaction
@Query("SELECT * FROM stack WHERE accountId = :accountId and (status<>1 or id is null or lastModified <> lastModifiedLocal)")
List<FullStack> getLocallyChangedStacksDirectly(long accountId);
@Transaction
@Query("SELECT * FROM stack WHERE accountId = :accountId AND boardId = :localBoardId and status<>3 and (deletedAt is null or deletedAt = 0) order by `order` asc")
List<FullStack> getFullStacksForBoardDirectly(long accountId, long localBoardId);
@Query("SELECT localId FROM stack s WHERE accountId = :accountId and id = :stackId")
Long getLocalStackIdByRemoteStackIdDirectly(long accountId, Long stackId);
@Query("SELECT coalesce(MAX(`order`), -1) FROM stack s WHERE boardId = :localBoardId")
Integer getHighestStackOrderInBoard(long localBoardId);
@Query("SELECT exists(select 1 from Stack s join Board b on s.boardId = b.localId where s.localId = :localStackId and exists(select 1 from AccessControl ac where ac.boardId = b.localId and status <> 3))")
boolean isStackOnSharedBoardDirectly(Long localStackId);
@Query("SELECT s.localId FROM stack s join Board b on s.boardId = b.localId where b.archived <> 0 and b.accountId in (:accountIds)")
List<Long> getLocalStackIdsInArchivedBoardsByAccountIdsDirectly(List<Long> accountIds);
@Query("SELECT s.localId FROM stack s")
List<Long> getAllIDs();
}

View file

@ -0,0 +1,112 @@
package it.niedermann.nextcloud.deck.database.dao;
import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Query;
import java.util.List;
import it.niedermann.nextcloud.deck.model.User;
@Dao
public interface UserDao extends GenericDao<User> {
@Query("SELECT * FROM user WHERE accountId = :accountId")
LiveData<List<User>> getUsersForAccount(final long accountId);
@Query("SELECT * FROM user WHERE accountId = :accountId and localId = :localId")
LiveData<User> getUserByLocalId(final long accountId, final long localId);
@Query("SELECT * FROM user WHERE accountId = :accountId and uid = :uid")
LiveData<User> getUserByUid(final long accountId, final String uid);
@Query("SELECT u.displayname FROM user u WHERE accountId = :accountId and uid = :uid")
String getUserNameByUidDirectly(final long accountId, final String uid);
@Query("SELECT u.* FROM user u WHERE accountId = :accountId " +
" AND NOT EXISTS (" +
" select 1 from joincardwithuser ju" +
" where ju.userId = u.localId" +
" and ju.cardId = :notYetAssignedToLocalCardId AND status <> 3" + // not LOCAL_DELETED
" )" +
" AND ( " +
" EXISTS (" +
" select 1 from userinboard where boardId = :boardId AND userId = u.localId" +
" )" +
" OR" +
" EXISTS (" +
" select 1 from accesscontrol" + // v GROUP!
" where (userId = u.localId OR (type = 1 and exists(select 1 from UserInGroup uig where uig.memberId = u.localId and uig.groupId = userId))) " +
" and boardId = :boardId and status <> 3" +
" )" +
" OR" +
" EXISTS (" +
" select 1 from board where localId = :boardId AND ownerId = u.localId" +
" )" +
")" +
"and ( uid LIKE :searchTerm or displayname LIKE :searchTerm or primaryKey LIKE :searchTerm )")
LiveData<List<User>> searchUserByUidOrDisplayName(final long accountId, final long boardId, final long notYetAssignedToLocalCardId, final String searchTerm);
@Query("SELECT u.* FROM user u WHERE accountId = :accountId " +
" AND NOT EXISTS (" +
" select 1 from accesscontrol ju" +
" where ju.userId = u.localId and ju.boardId = :boardId and status <> 3" + // not LOCAL_DELETED
" ) " +
"and ( uid LIKE :searchTerm or displayname LIKE :searchTerm or primaryKey LIKE :searchTerm ) " +
"and u.localId <> (select b.ownerId from board b where localId = :boardId)" +
"ORDER BY u.displayname")
LiveData<List<User>> searchUserByUidOrDisplayNameForACL(final long accountId, final long boardId, final String searchTerm);
@Query("SELECT * FROM user WHERE accountId = :accountId and uid = :uid")
User getUserByUidDirectly(final long accountId, final String uid);
@Query("SELECT * FROM user WHERE localId IN (:assignedUserIDs) and status <> 3") // not LOCAL_DELETED
List<User> getUsersByIdDirectly(List<Long> assignedUserIDs);
@Query("SELECT * FROM user WHERE localId = :localUserId")
User getUserByLocalIdDirectly(long localUserId);
@Query(" SELECT u.* FROM user u" +
" WHERE u.accountId = :accountId" +
" AND NOT EXISTS (" +
" select 1 from joincardwithuser ju" +
" where ju.userId = u.localId" +
" and ju.cardId = :notAssignedToLocalCardId AND status <> 3" + // not LOCAL_DELETED
" )" +
" AND ( " +
" EXISTS (" +
" select 1 from userinboard where boardId = :boardId AND userId = u.localId" +
" )" +
" OR" +
" EXISTS (" +
" select 1 from accesscontrol" + // v GROUP!
" where (userId = u.localId OR (type = 1 and exists(select 1 from UserInGroup uig where uig.memberId = u.localId and uig.groupId = userId))) " +
" and boardId = :boardId and status <> 3" +
" )" +
" OR" +
" EXISTS (" +
" select 1 from board where localId = :boardId AND ownerId = u.localId" +
" )" +
")" +
" ORDER BY (" +
" select count(*) from joincardwithuser j" +
" where userId = u.localId and cardId in (select c.localId from card c inner join stack s on s.localId = c.stackId where s.boardId = :boardId)" +
") DESC" +
" LIMIT :topX")
LiveData<List<User>> findProposalsForUsersToAssign(long accountId, long boardId, long notAssignedToLocalCardId, int topX);
@Query("SELECT u.* FROM user u WHERE accountId = :accountId " +
" AND NOT EXISTS (" +
" select 1 from accesscontrol ju" +
" where ju.userId = u.localId and ju.boardId = :boardId and status <> 3" + // not LOCAL_DELETED
" ) " +
"and u.localId <> (select b.ownerId from board b where localId = :boardId)" +
"ORDER BY u.displayname " +
"LIMIT :topX")
LiveData<List<User>> findProposalsForUsersToAssignForACL(long accountId, long boardId, int topX);
@Query("SELECT * FROM user WHERE localId IN (:userIDs) and status <> 3") // not LOCAL_DELETED
List<User> getUsersByIdsDirectly(List<Long> userIDs);
}

View file

@ -0,0 +1,12 @@
package it.niedermann.nextcloud.deck.database.dao;
import androidx.room.Dao;
import androidx.room.Query;
import it.niedermann.nextcloud.deck.model.relations.UserInBoard;
@Dao
public interface UserInBoardDao extends GenericDao<UserInBoard> {
@Query("DELETE FROM userinboard WHERE boardId = :localId")
void deleteByBoardId(long localId);
}

View file

@ -0,0 +1,18 @@
package it.niedermann.nextcloud.deck.database.dao;
import androidx.room.Dao;
import androidx.room.Query;
import androidx.room.RawQuery;
import androidx.sqlite.db.SupportSQLiteQuery;
import it.niedermann.nextcloud.deck.model.ocs.user.UserForAssignment;
import it.niedermann.nextcloud.deck.model.relations.UserInGroup;
@Dao
public interface UserInGroupDao extends GenericDao<UserInGroup> {
@Query("DELETE FROM useringroup WHERE groupId = :localId")
void deleteByGroupId(long localId);
@RawQuery
UserForAssignment getUserForAssignment(SupportSQLiteQuery query);
}

View file

@ -0,0 +1,21 @@
package it.niedermann.nextcloud.deck.database.dao.projects;
import androidx.room.Dao;
import androidx.room.Query;
import java.util.List;
import it.niedermann.nextcloud.deck.database.dao.GenericDao;
import it.niedermann.nextcloud.deck.model.ocs.projects.JoinCardWithProject;
@Dao
public interface JoinCardWithOcsProjectDao extends GenericDao<JoinCardWithProject> {
@Query("select * from JoinCardWithProject where projectId = :localProjectId and cardId = :localCardId")
JoinCardWithProject getAssignmentByCardIdAndProjectIdDirectly(Long localCardId, Long localProjectId);
@Query("delete from JoinCardWithProject where cardId = :localCardId and projectId NOT in (select p.localId from OcsProject p where p.accountId = :accountId and p.id in (:remoteProjectIDs))")
void deleteProjectResourcesByCardIdExceptGivenProjectIdsDirectly(long accountId, Long localCardId, List<Long> remoteProjectIDs);
@Query("delete from JoinCardWithProject where cardId = :localCardId")
void deleteProjectResourcesByCardIdDirectly(Long localCardId);
}

View file

@ -0,0 +1,13 @@
package it.niedermann.nextcloud.deck.database.dao.projects;
import androidx.room.Dao;
import androidx.room.Query;
import it.niedermann.nextcloud.deck.database.dao.GenericDao;
import it.niedermann.nextcloud.deck.model.ocs.projects.OcsProject;
@Dao
public interface OcsProjectDao extends GenericDao<OcsProject> {
@Query("select * from OcsProject where accountId = :accountId and id = :remoteId")
OcsProject getProjectByRemoteIdDirectly(long accountId, Long remoteId);
}

View file

@ -0,0 +1,25 @@
package it.niedermann.nextcloud.deck.database.dao.projects;
import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Query;
import java.util.List;
import it.niedermann.nextcloud.deck.database.dao.GenericDao;
import it.niedermann.nextcloud.deck.model.ocs.projects.OcsProjectResource;
@Dao
public interface OcsProjectResourceDao extends GenericDao<OcsProjectResource> {
@Query("delete from OcsProjectResource where projectId = :localProjectId")
void deleteByProjectId(Long localProjectId);
@Query("select * from OcsProjectResource where projectId = :localProjectId")
LiveData<List<OcsProjectResource>> getResourcesByLocalProjectId(Long localProjectId);
@Query("select count(id) from OcsProjectResource where projectId = :localProjectId")
int countProjectResourcesInProjectDirectly(Long localProjectId);
@Query("select count(id) from OcsProjectResource where projectId = :localProjectId")
LiveData<Integer> countProjectResourcesInProject(Long localProjectId);
}

View file

@ -0,0 +1,21 @@
package it.niedermann.nextcloud.deck.database.dao.widgets;
import androidx.room.Dao;
import androidx.room.Query;
import androidx.room.Transaction;
import it.niedermann.nextcloud.deck.database.dao.GenericDao;
import it.niedermann.nextcloud.deck.model.full.FullSingleCardWidgetModel;
import it.niedermann.nextcloud.deck.model.widget.singlecard.SingleCardWidgetModel;
@Dao
public interface SingleCardWidgetModelDao extends GenericDao<SingleCardWidgetModel> {
@Transaction
@Query("SELECT * FROM singlecardwidgetmodel WHERE widgetId = :widgetId")
FullSingleCardWidgetModel getFullCardByRemoteIdDirectly(final int widgetId);
@Transaction
@Query("SELECT EXISTS (SELECT 1 FROM singlecardwidgetmodel WHERE cardId = :cardLocalId)")
boolean containsCardLocalId(final Long cardLocalId);
}

View file

@ -0,0 +1,19 @@
package it.niedermann.nextcloud.deck.database.dao.widgets;
import androidx.room.Dao;
import androidx.room.Query;
import androidx.room.Transaction;
import it.niedermann.nextcloud.deck.database.dao.GenericDao;
import it.niedermann.nextcloud.deck.model.appwidgets.StackWidgetModel;
@Dao
public interface StackWidgetModelDao extends GenericDao<StackWidgetModel> {
@Query("SELECT * FROM stackwidgetmodel WHERE appwidgetid = :appWidgetId")
StackWidgetModel getStackWidgetByAppWidgetIdDirectly(final int appWidgetId);
@Transaction
@Query("SELECT EXISTS (SELECT 1 FROM stackwidgetmodel WHERE stackId in (:stackLocalIds))")
boolean containsStackLocalId(final long... stackLocalIds);
}

View file

@ -0,0 +1,18 @@
package it.niedermann.nextcloud.deck.database.dao.widgets.filter;
import androidx.room.Dao;
import androidx.room.Query;
import java.util.List;
import it.niedermann.nextcloud.deck.database.dao.GenericDao;
import it.niedermann.nextcloud.deck.model.widget.filter.FilterWidgetAccount;
@Dao
public interface FilterWidgetAccountDao extends GenericDao<FilterWidgetAccount> {
@Query("DELETE FROM FilterWidgetAccount WHERE filterWidgetId = :filterWidgetId")
void deleteByFilterWidgetId (Integer filterWidgetId);
@Query("select * FROM FilterWidgetAccount WHERE filterWidgetId = :filterWidgetId")
List<FilterWidgetAccount> getFilterWidgetAccountsByFilterWidgetIdDirectly(Integer filterWidgetId);
}

View file

@ -0,0 +1,15 @@
package it.niedermann.nextcloud.deck.database.dao.widgets.filter;
import androidx.room.Dao;
import androidx.room.Query;
import java.util.List;
import it.niedermann.nextcloud.deck.database.dao.GenericDao;
import it.niedermann.nextcloud.deck.model.widget.filter.FilterWidgetBoard;
@Dao
public interface FilterWidgetBoardDao extends GenericDao<FilterWidgetBoard> {
@Query("SELECT * FROM FilterWidgetBoard where filterAccountId = :filterWidgetAccountId")
List<FilterWidgetBoard> getFilterWidgetBoardsByFilterWidgetAccountIdDirectly(Long filterWidgetAccountId);
}

View file

@ -0,0 +1,44 @@
package it.niedermann.nextcloud.deck.database.dao.widgets.filter;
import androidx.room.Dao;
import androidx.room.Query;
import androidx.room.Transaction;
import java.util.List;
import it.niedermann.nextcloud.deck.database.dao.GenericDao;
import it.niedermann.nextcloud.deck.model.widget.filter.EWidgetType;
import it.niedermann.nextcloud.deck.model.widget.filter.FilterWidget;
@Dao
public interface FilterWidgetDao extends GenericDao<FilterWidget> {
@Query("DELETE FROM filterwidget WHERE id = :filterWidgetId")
void delete (Integer filterWidgetId);
@Query("SELECT * FROM FilterWidget where id = :filterWidgetId")
FilterWidget getFilterWidgetByIdDirectly(Integer filterWidgetId);
@Query("SELECT EXISTS (SELECT 1 FROM FilterWidget WHERE id = :filterWidgetId)")
boolean filterWidgetExists(int filterWidgetId);
@Query("SELECT id FROM FilterWidget WHERE widgetType = :type")
List<Integer> getFilterWidgetIdsByType(int type);
@Transaction
@Query("SELECT DISTINCT w.widgetType " +
"FROM FilterWidget w " +
"LEFT JOIN FilterWidgetAccount a ON w.id = a.filterWidgetId " +
"LEFT JOIN FilterWidgetBoard b ON a.id = b.filterAccountId " +
"LEFT JOIN FilterWidgetStack s ON b.id = s.filterBoardId " +
"LEFT JOIN FilterWidgetUser u ON a.id = u.filterAccountId " +
"LEFT JOIN FilterWidgetProject p ON a.id = p.filterAccountId " +
"LEFT JOIN FilterWidgetLabel l ON b.id = l.filterBoardId " +
"WHERE (:changedEntityType = 'ACCOUNT' AND (a.accountId = :localIdOfChangedEntity OR a.accountId IS NULL)) " +
"OR (:changedEntityType = 'BOARD' AND (b.boardId = :localIdOfChangedEntity OR b.boardId IS NULL)) " +
"OR (:changedEntityType = 'STACK' AND (s.stackId = :localIdOfChangedEntity OR s.stackId IS NULL)) " +
"OR (:changedEntityType = 'USER' AND (u.userId = :localIdOfChangedEntity OR u.userId IS NULL)) " +
"OR (:changedEntityType = 'PROJECT' AND (p.projectId = :localIdOfChangedEntity OR p.projectId IS NULL)) " +
"OR (:changedEntityType = 'LABEL' AND (l.labelId = :localIdOfChangedEntity OR l.labelId IS NULL)) "
)
List<EWidgetType> getChangedListTypesByEntity(String changedEntityType, Long localIdOfChangedEntity);
}

View file

@ -0,0 +1,15 @@
package it.niedermann.nextcloud.deck.database.dao.widgets.filter;
import androidx.room.Dao;
import androidx.room.Query;
import java.util.List;
import it.niedermann.nextcloud.deck.database.dao.GenericDao;
import it.niedermann.nextcloud.deck.model.widget.filter.FilterWidgetLabel;
@Dao
public interface FilterWidgetLabelDao extends GenericDao<FilterWidgetLabel> {
@Query("SELECT * FROM FilterWidgetLabel where filterBoardId = :filterWidgetBoardId")
List<FilterWidgetLabel> getFilterWidgetLabelsByFilterWidgetBoardIdDirectly(Long filterWidgetBoardId);
}

View file

@ -0,0 +1,15 @@
package it.niedermann.nextcloud.deck.database.dao.widgets.filter;
import androidx.room.Dao;
import androidx.room.Query;
import java.util.List;
import it.niedermann.nextcloud.deck.database.dao.GenericDao;
import it.niedermann.nextcloud.deck.model.widget.filter.FilterWidgetProject;
@Dao
public interface FilterWidgetProjectDao extends GenericDao<FilterWidgetProject> {
@Query("SELECT * FROM FilterWidgetProject where filterAccountId = :filterWidgetAccountId")
List<FilterWidgetProject> getFilterWidgetProjectsByFilterWidgetAccountIdDirectly(Long filterWidgetAccountId);
}

View file

@ -0,0 +1,18 @@
package it.niedermann.nextcloud.deck.database.dao.widgets.filter;
import androidx.room.Dao;
import androidx.room.Query;
import java.util.List;
import it.niedermann.nextcloud.deck.database.dao.GenericDao;
import it.niedermann.nextcloud.deck.model.widget.filter.FilterWidgetSort;
@Dao
public interface FilterWidgetSortDao extends GenericDao<FilterWidgetSort> {
@Query("DELETE FROM FilterWidgetSort WHERE filterWidgetId = :filterWidgetId")
void deleteByFilterWidgetId (Integer filterWidgetId);
@Query("select * FROM FilterWidgetSort WHERE filterWidgetId = :filterWidgetId order by ruleOrder asc")
List<FilterWidgetSort> getFilterWidgetSortByFilterWidgetIdDirectly(Integer filterWidgetId);
}

View file

@ -0,0 +1,15 @@
package it.niedermann.nextcloud.deck.database.dao.widgets.filter;
import androidx.room.Dao;
import androidx.room.Query;
import java.util.List;
import it.niedermann.nextcloud.deck.database.dao.GenericDao;
import it.niedermann.nextcloud.deck.model.widget.filter.FilterWidgetStack;
@Dao
public interface FilterWidgetStackDao extends GenericDao<FilterWidgetStack> {
@Query("SELECT * FROM FilterWidgetStack where filterBoardId = :filterWidgetBoardId")
List<FilterWidgetStack> getFilterWidgetStacksByFilterWidgetBoardIdDirectly(Long filterWidgetBoardId);
}

View file

@ -0,0 +1,15 @@
package it.niedermann.nextcloud.deck.database.dao.widgets.filter;
import androidx.room.Dao;
import androidx.room.Query;
import java.util.List;
import it.niedermann.nextcloud.deck.database.dao.GenericDao;
import it.niedermann.nextcloud.deck.model.widget.filter.FilterWidgetUser;
@Dao
public interface FilterWidgetUserDao extends GenericDao<FilterWidgetUser> {
@Query("SELECT * FROM FilterWidgetUser where filterAccountId = :filterWidgetAccountId")
List<FilterWidgetUser> getFilterWidgetUsersByFilterWidgetAccountIdDirectly(Long filterWidgetAccountId);
}

View file

@ -0,0 +1,59 @@
package it.niedermann.nextcloud.deck.database.migration;
import android.database.Cursor;
import androidx.annotation.NonNull;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
import it.niedermann.nextcloud.deck.model.enums.DBStatus;
/**
* Removes duplicate labels and ensures uniqueness
*/
public class Migration_10_11 extends Migration {
public Migration_10_11() {
super(10, 11);
}
@Override
public void migrate(@NonNull SupportSQLiteDatabase database) {
// replace duplicates with the server-known ones
Cursor duplucatesCursor = database.query("SELECT boardId, title, count(*) FROM Label group by boardid, title having count(*) > 1");
if (duplucatesCursor != null && duplucatesCursor.moveToFirst()) {
do {
long boardId = duplucatesCursor.getLong(0);
String title = duplucatesCursor.getString(1);
Cursor singleDuplicateCursor = database.query("select localId from Label where boardId = ? and title = ? order by id desc", new Object[]{boardId, title});
if (singleDuplicateCursor != null && singleDuplicateCursor.moveToFirst()) {
long idToUse = -1;
do {
if (idToUse < 0) {
// desc order -> first one is the one with remote ID or a random one. keep this one.
idToUse = singleDuplicateCursor.getLong(0);
continue;
}
long idToReplace = singleDuplicateCursor.getLong(0);
Cursor cardsAssignedToDuplicateCursor = database.query("select cardId, exists(select 1 from JoinCardWithLabel ij where ij.labelId = ? and ij.cardId = cardId) " +
"from JoinCardWithLabel where labelId = ?", new Object[]{idToUse, idToReplace});
if (cardsAssignedToDuplicateCursor != null && cardsAssignedToDuplicateCursor.moveToFirst()) {
do {
long cardId = cardsAssignedToDuplicateCursor.getLong(0);
boolean hasDestinationLabelAssigned = cardsAssignedToDuplicateCursor.getInt(1) > 0;
database.execSQL("DELETE FROM JoinCardWithLabel where labelId = ? and cardId = ?", new Object[]{idToReplace, cardId});
if (!hasDestinationLabelAssigned) {
database.execSQL("INSERT INTO JoinCardWithLabel (status,labelId,cardId) VALUES (?, ?, ?)", new Object[]{DBStatus.LOCAL_EDITED.getId(), idToUse, cardId});
}
} while (cardsAssignedToDuplicateCursor.moveToNext());
}
database.execSQL("DELETE FROM Label where localId = ?", new Object[]{idToReplace});
} while (singleDuplicateCursor.moveToNext());
}
} while (duplucatesCursor.moveToNext());
}
// database.execSQL("DELETE FROM Label WHERE id IS NULL AND EXISTS(SELECT 1 FROM Label il WHERE il.boardId = boardId AND il.title = title AND id IS NOT NULL)");
database.execSQL("CREATE UNIQUE INDEX idx_label_title_unique ON Label(boardId, title)");
}
}

View file

@ -0,0 +1,20 @@
package it.niedermann.nextcloud.deck.database.migration;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
/**
* Adds support for the Single note widget
*/
public class Migration_11_12 extends Migration {
public Migration_11_12() {
super(11, 12);
}
@Override
public void migrate(SupportSQLiteDatabase database) {
database.execSQL("CREATE TABLE `SingleCardWidgetModel` (`widgetId` INTEGER PRIMARY KEY, `accountId` INTEGER, `boardId` INTEGER, `cardId` INTEGER, FOREIGN KEY(`accountId`) REFERENCES `Account`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE, FOREIGN KEY(`boardId`) REFERENCES `Board`(`localId`) ON UPDATE NO ACTION ON DELETE CASCADE, FOREIGN KEY(`cardId`) REFERENCES `Card`(`localId`) ON UPDATE NO ACTION ON DELETE CASCADE )");
database.execSQL("CREATE INDEX `index_SingleCardWidgetModel_cardId` ON `SingleCardWidgetModel` (`cardId`)");
}
}

View file

@ -0,0 +1,17 @@
package it.niedermann.nextcloud.deck.database.migration;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
public class Migration_12_13 extends Migration {
public Migration_12_13() {
super(12, 13);
}
@Override
public void migrate(SupportSQLiteDatabase database) {
database.execSQL("CREATE INDEX `idx_cardWidgetModel_accountId` ON `SingleCardWidgetModel` (`accountId`)");
database.execSQL("CREATE INDEX `idx_cardWidgetModel_boardId` ON `SingleCardWidgetModel` (`boardId`)");
}
}

View file

@ -0,0 +1,20 @@
package it.niedermann.nextcloud.deck.database.migration;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
/**
* Adds support for comment responses
*/
public class Migration_13_14 extends Migration {
public Migration_13_14() {
super(13, 14);
}
@Override
public void migrate(SupportSQLiteDatabase database) {
database.execSQL("ALTER TABLE `DeckComment` ADD `parentId` INTEGER REFERENCES DeckComment(localId) ON DELETE CASCADE");
database.execSQL("CREATE INDEX `idx_comment_parentID` ON DeckComment(parentId)");
}
}

View file

@ -0,0 +1,35 @@
package it.niedermann.nextcloud.deck.database.migration;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.preference.PreferenceManager;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
import it.niedermann.nextcloud.deck.remote.SyncWorker;
/**
* @see <a href="https://github.com/stefan-niedermann/nextcloud-deck/issues/570">Reinitializes the background synchronization</a> and
* <a href="https://github.com/stefan-niedermann/nextcloud-deck/issues/525">cleans up old shared preferences</a>
*/
public class Migration_14_15 extends Migration {
@NonNull
private final Context context;
public Migration_14_15(@NonNull Context context) {
super(14, 15);
this.context = context;
}
@Override
public void migrate(@NonNull SupportSQLiteDatabase database) {
SyncWorker.update(context);
PreferenceManager
.getDefaultSharedPreferences(context)
.edit()
.remove("it.niedermann.nextcloud.deck.theme_text")
.apply();
}
}

View file

@ -0,0 +1,23 @@
package it.niedermann.nextcloud.deck.database.migration;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
/**
* Adds support for Stack widget
*/
public class Migration_15_16 extends Migration {
public Migration_15_16() {
super(15, 16);
}
@Override
public void migrate(SupportSQLiteDatabase database) {
database.execSQL("CREATE TABLE `StackWidgetModel` (`appWidgetId` INTEGER PRIMARY KEY, `accountId` INTEGER, `stackId` INTEGER, `darkTheme` INTEGER CHECK (`darkTheme` IN (0,1)) NOT NULL, " +
"FOREIGN KEY(`accountId`) REFERENCES `Account`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE, " +
"FOREIGN KEY(`stackId`) REFERENCES `Stack`(`localId`) ON UPDATE NO ACTION ON DELETE CASCADE )");
database.execSQL("CREATE INDEX `index_StackWidgetModel_stackId` ON `StackWidgetModel` (`stackId`)");
database.execSQL("CREATE INDEX `index_StackWidgetModel_accountId` ON `StackWidgetModel` (`accountId`)");
}
}

View file

@ -0,0 +1,34 @@
package it.niedermann.nextcloud.deck.database.migration;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
/**
* @see <a href="https://github.com/stefan-niedermann/nextcloud-deck/issues/573">Adds support for projects</a>
*/
public class Migration_16_17 extends Migration {
public Migration_16_17() {
super(16, 17);
}
@Override
public void migrate(SupportSQLiteDatabase database) {
database.execSQL("CREATE TABLE `OcsProject` (`localId` INTEGER PRIMARY KEY AUTOINCREMENT, `accountId` INTEGER NOT NULL, `id` INTEGER, `name` TEXT NOT NULL, `status` INTEGER NOT NULL, `lastModified` INTEGER, `lastModifiedLocal` INTEGER)");
database.execSQL("CREATE UNIQUE INDEX `index_OcsProject_accountId_id` ON `OcsProject` (`accountId`, `id`)");
database.execSQL("CREATE INDEX `index_project_accID` ON `OcsProject` (`accountId`)");
database.execSQL("CREATE INDEX `index_OcsProject_id` ON `OcsProject` (`id`)");
database.execSQL("CREATE INDEX `index_OcsProject_lastModifiedLocal` ON `OcsProject` (`lastModifiedLocal`)");
database.execSQL("CREATE TABLE `OcsProjectResource` (`localId` INTEGER PRIMARY KEY AUTOINCREMENT, `accountId` INTEGER NOT NULL, `id` INTEGER, `name` TEXT, `status` INTEGER NOT NULL, `lastModified` INTEGER, `lastModifiedLocal` INTEGER, `projectId` INTEGER NOT NULL, `type` TEXT , `link` TEXT , `path` TEXT, `iconUrl` TEXT , `previewAvailable` INTEGER, `mimetype` TEXT, FOREIGN KEY(`projectId`) REFERENCES `OcsProject`(`localId`) ON UPDATE NO ACTION ON DELETE CASCADE)");
database.execSQL("CREATE INDEX `index_projectResource_accID` ON `OcsProjectResource` (`accountId`)");
database.execSQL("CREATE INDEX `index_projectResource_projectId` ON `OcsProjectResource` (`projectId`)");
database.execSQL("CREATE UNIQUE INDEX `index_OcsProjectResource_accountId_id` ON `OcsProjectResource` (`accountId`, `id`, `projectId`)");
database.execSQL("CREATE INDEX `index_OcsProjectResource_id` ON `OcsProjectResource` (`id`)");
database.execSQL("CREATE INDEX `index_OcsProjectResource_lastModifiedLocal` ON `OcsProjectResource` (`lastModifiedLocal`)");
database.execSQL("CREATE TABLE `JoinCardWithProject` (`status` INTEGER NOT NULL, `projectId` INTEGER NOT NULL, `cardId` INTEGER NOT NULL, PRIMARY KEY (`projectId`, `cardId`), FOREIGN KEY(`cardId`) REFERENCES `Card`(`localId`) ON UPDATE NO ACTION ON DELETE CASCADE, FOREIGN KEY(`projectId`) REFERENCES `OcsProject`(`localId`) ON UPDATE NO ACTION ON DELETE CASCADE)");
database.execSQL("CREATE INDEX `index_JoinCardWithProject_projectId` ON `JoinCardWithProject` (`projectId`)");
database.execSQL("CREATE INDEX `index_JoinCardWithProject_cardId` ON `JoinCardWithProject` (`cardId`)");
}
}

View file

@ -0,0 +1,19 @@
package it.niedermann.nextcloud.deck.database.migration;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
/**
* <a href="https://github.com/stefan-niedermann/nextcloud-deck/issues/435">Implement ETags for Capabilities endpoint</a>
*/
public class Migration_17_18 extends Migration {
public Migration_17_18() {
super(17, 18);
}
@Override
public void migrate(SupportSQLiteDatabase database) {
database.execSQL("ALTER TABLE `Account` ADD `etag` TEXT");
}
}

View file

@ -0,0 +1,21 @@
package it.niedermann.nextcloud.deck.database.migration;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
/**
* @see <a href="https://github.com/stefan-niedermann/nextcloud-deck/issues/619">Handle unknown project types</a>
*/
public class Migration_18_19 extends Migration {
public Migration_18_19() {
super(18, 19);
}
@Override
public void migrate(SupportSQLiteDatabase database) {
database.execSQL("DROP INDEX `index_OcsProjectResource_accountId_id`");
database.execSQL("ALTER TABLE `OcsProjectResource` ADD `idString` TEXT");
database.execSQL("CREATE UNIQUE INDEX `index_OcsProjectResource_accountId_id` ON `OcsProjectResource` (`accountId`, `id`, `idString`, `projectId`)");
}
}

View file

@ -0,0 +1,35 @@
package it.niedermann.nextcloud.deck.database.migration;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
/**
* Fixes issues with LDAP users when filtering
* https://github.com/stefan-niedermann/nextcloud-deck/issues/492
* https://github.com/stefan-niedermann/nextcloud-deck/issues/631
*/
public class Migration_19_20 extends Migration {
public Migration_19_20() {
super(19, 20);
}
@Override
public void migrate(SupportSQLiteDatabase database) {
database.execSQL("CREATE TABLE `UserInGroup` (`groupId` INTEGER NOT NULL, `memberId` INTEGER NOT NULL, " +
"primary KEY(`groupId`, `memberId`), " +
"FOREIGN KEY(`groupId`) REFERENCES `User`(`localId`) ON UPDATE NO ACTION ON DELETE CASCADE, " +
"FOREIGN KEY(`memberId`) REFERENCES `User`(`localId`) ON UPDATE NO ACTION ON DELETE CASCADE)");
database.execSQL("CREATE UNIQUE INDEX `unique_idx_group_member` ON `UserInGroup` (`groupId`, `memberId`)");
database.execSQL("CREATE INDEX `index_UserInGroup_groupId` ON `UserInGroup` (`groupId`)");
database.execSQL("CREATE INDEX `index_UserInGroup_memberId` ON `UserInGroup` (`memberId`)");
database.execSQL("CREATE TABLE `UserInBoard` (`userId` INTEGER NOT NULL, `boardId` INTEGER NOT NULL, " +
"primary KEY(`userId`, `boardId`), " +
"FOREIGN KEY(`userId`) REFERENCES `User`(`localId`) ON UPDATE NO ACTION ON DELETE CASCADE, " +
"FOREIGN KEY(`boardId`) REFERENCES `Board`(`localId`) ON UPDATE NO ACTION ON DELETE CASCADE)");
database.execSQL("CREATE UNIQUE INDEX `unique_idx_user_board` ON `UserInBoard` (`userId`, `boardId`)");
database.execSQL("CREATE INDEX `index_UserInBoard_userId` ON `UserInBoard` (`userId`)");
database.execSQL("CREATE INDEX `index_UserInBoard_boardId` ON `UserInBoard` (`boardId`)");
}
}

View file

@ -0,0 +1,123 @@
package it.niedermann.nextcloud.deck.database.migration;
import android.database.Cursor;
import android.graphics.Color;
import androidx.annotation.ColorInt;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
import it.niedermann.android.util.ColorUtil;
/**
* @see <a href="https://github.com/stefan-niedermann/nextcloud-deck/issues/556">Store colors as integer in database</a>
*/
public class Migration_20_21 extends Migration {
public Migration_20_21() {
super(20, 21);
}
@Override
public void migrate(SupportSQLiteDatabase database) {
String suffix = "_new";
{
String tableName = "Account";
database.execSQL("CREATE TABLE `" + tableName + suffix + "` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `name` TEXT NOT NULL, `userName` TEXT NOT NULL, `url` TEXT NOT NULL, " +
"`color` INTEGER NOT NULL DEFAULT 0, `textColor` INTEGER NOT NULL DEFAULT 0, `serverDeckVersion` TEXT NOT NULL DEFAULT '0.6.4', `maintenanceEnabled` INTEGER NOT NULL DEFAULT 0, `etag` TEXT)");
Cursor cursor = database.query("select * from `" + tableName + "`");
while (cursor.moveToNext()) {
String colorAsString1 = cursor.getString(4); // color
String colorAsString2 = cursor.getString(5); // textColor
@ColorInt int color1;
@ColorInt int color2;
try {
color1 = Color.parseColor(ColorUtil.formatColorToParsableHexString(colorAsString1));
color2 = Color.parseColor(ColorUtil.formatColorToParsableHexString(colorAsString2));
} catch (Exception e) {
color1 = Color.GRAY;
color2 = Color.GRAY;
}
database.execSQL("Insert into `" + tableName + suffix + "` VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", new Object[]{
cursor.getLong(0), cursor.getString(1), cursor.getString(2), cursor.getString(3),
color1, color2, cursor.getString(6), cursor.getInt(7), cursor.getString(8)});
}
database.execSQL("DROP TABLE `" + tableName + "`");
database.execSQL("ALTER TABLE `" + tableName + suffix + "` RENAME TO `" + tableName + "`");
database.execSQL("CREATE UNIQUE INDEX `index_Account_name` ON `" + tableName + "` (`name`)");
database.execSQL("UPDATE SQLITE_SEQUENCE SET seq = (select max(id) from " + tableName + ") WHERE name = ?", new Object[]{tableName});
}
{
String tableName = "Board";
database.execSQL("CREATE TABLE `" + tableName + suffix + "` (`localId` INTEGER PRIMARY KEY AUTOINCREMENT, `accountId` INTEGER NOT NULL, `id` INTEGER, `status` INTEGER NOT NULL, " +
"`lastModified` INTEGER, `lastModifiedLocal` INTEGER, `title` TEXT, `ownerId` INTEGER NOT NULL, `color` INTEGER, " +
"`archived` INTEGER NOT NULL, `shared` INTEGER NOT NULL, `deletedAt` INTEGER, `permissionRead` INTEGER NOT NULL, " +
"`permissionEdit` INTEGER NOT NULL, `permissionManage` INTEGER NOT NULL, `permissionShare` INTEGER NOT NULL, " +
"FOREIGN KEY(`ownerId`) REFERENCES `User`(`localId`) ON UPDATE NO ACTION ON DELETE SET NULL )");
Cursor cursor = database.query("select * from `" + tableName + "`");
while (cursor.moveToNext()) {
String colorAsString1 = cursor.getString(8); // color
@ColorInt int color1;
try {
color1 = Color.parseColor(ColorUtil.formatColorToParsableHexString(colorAsString1));
} catch (Exception e) {
color1 = Color.GRAY;
}
database.execSQL("Insert into `" + tableName + suffix + "` VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", new Object[]{
cursor.getLong(0), cursor.getLong(1), cursor.getLong(2), cursor.getInt(3),
cursor.getLong(4), cursor.getLong(5), cursor.getString(6), cursor.getLong(7), color1,
cursor.getInt(9), cursor.getInt(10), cursor.getInt(11), cursor.getInt(12),
cursor.getInt(13), cursor.getInt(14), cursor.getInt(15)
});
}
database.execSQL("DROP TABLE `" + tableName + "`");
database.execSQL("ALTER TABLE `" + tableName + suffix + "` RENAME TO `" + tableName + "`");
database.execSQL("CREATE INDEX `index_Board_accountId` ON `" + tableName + "` (`accountId`)");
database.execSQL("CREATE UNIQUE INDEX `index_Board_accountId_id` ON `" + tableName + "` (`accountId`, `id`)");
database.execSQL("CREATE INDEX `index_Board_id` ON `" + tableName + "` (`id`)");
database.execSQL("CREATE INDEX `index_Board_ownerId` ON `" + tableName + "` (`ownerId`)");
database.execSQL("CREATE INDEX `index_Board_lastModifiedLocal` ON `" + tableName + "` (`lastModifiedLocal`)");
database.execSQL("UPDATE SQLITE_SEQUENCE SET seq = (select max(id) from " + tableName + ") WHERE name = ?", new Object[]{tableName});
}
{
String tableName = "Label";
database.execSQL("CREATE TABLE `" + tableName + suffix + "` (`localId` INTEGER PRIMARY KEY AUTOINCREMENT, `accountId` INTEGER NOT NULL, `id` INTEGER, `status` INTEGER NOT NULL, " +
"`lastModified` INTEGER, `lastModifiedLocal` INTEGER, `title` TEXT, `color` INTEGER NOT NULL DEFAULT 0, `boardId` INTEGER NOT NULL, " +
"FOREIGN KEY(`boardId`) REFERENCES `Board`(`localId`) ON UPDATE NO ACTION ON DELETE CASCADE )");
Cursor cursor = database.query("select * from `" + tableName + "`");
while (cursor.moveToNext()) {
String colorAsString1 = cursor.getString(7); // color
@ColorInt int color1;
try {
color1 = Color.parseColor(ColorUtil.formatColorToParsableHexString(colorAsString1));
} catch (Exception e) {
color1 = Color.GRAY;
}
database.execSQL("Insert into `" + tableName + suffix + "` VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", new Object[]{
cursor.getLong(0), cursor.getLong(1), cursor.getLong(2), cursor.getInt(3),
cursor.getLong(4), cursor.getLong(5), cursor.getString(6), color1, cursor.getLong(8)});
}
database.execSQL("DROP TABLE `" + tableName + "`");
database.execSQL("ALTER TABLE `" + tableName + suffix + "` RENAME TO `" + tableName + "`");
database.execSQL("CREATE UNIQUE INDEX `index_Label_accountId_id` ON `" + tableName + "` (`accountId`, `id`)");
database.execSQL("CREATE INDEX `index_Label_boardId` ON `" + tableName + "` (`boardId`)");
database.execSQL("CREATE INDEX `index_Label_accountId` ON `" + tableName + "` (`accountId`)");
database.execSQL("CREATE UNIQUE INDEX `idx_label_title_unique` ON `" + tableName + "` (`boardId`, `title`)");
database.execSQL("CREATE INDEX `index_Label_id` ON `" + tableName + "` (`id`)");
database.execSQL("CREATE INDEX `index_Label_lastModifiedLocal` ON `" + tableName + "` (`lastModifiedLocal`)");
database.execSQL("UPDATE SQLITE_SEQUENCE SET seq = (select max(id) from " + tableName + ") WHERE name = ?", new Object[]{tableName});
}
}
}

View file

@ -0,0 +1,34 @@
package it.niedermann.nextcloud.deck.database.migration;
import android.content.Context;
import android.content.SharedPreferences;
import android.database.Cursor;
import androidx.annotation.NonNull;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
/**
* @see <a href="https://github.com/stefan-niedermann/nextcloud-deck/issues/715">Migrate from java.util.Date and java.util.Calendar to java.time.*</a>
*/
public class Migration_21_22 extends Migration {
@NonNull
private final Context context;
public Migration_21_22(@NonNull Context context) {
super(21, 22);
this.context = context;
}
@Override
public void migrate(@NonNull SupportSQLiteDatabase database) {
final SharedPreferences.Editor lastSyncPref = context.getApplicationContext().getSharedPreferences("it.niedermann.nextcloud.deck.last_sync", Context.MODE_PRIVATE).edit();
final Cursor cursor = database.query("select id from `Account`");
while (cursor.moveToNext()) {
lastSyncPref.remove("lS_" + cursor.getLong(0));
}
cursor.close();
lastSyncPref.apply();
}
}

View file

@ -0,0 +1,30 @@
package it.niedermann.nextcloud.deck.database.migration;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
/**
* @see <a href="https://github.com/stefan-niedermann/nextcloud-deck/issues/359">Implement ETags for synchronization Speed-Up</a>
*/
public class Migration_22_23 extends Migration {
public Migration_22_23() {
super(22, 23);
}
@Override
public void migrate(SupportSQLiteDatabase database) {
database.execSQL("ALTER TABLE `Account` ADD `boardsEtag` TEXT");
database.execSQL("ALTER TABLE `Board` ADD `etag` TEXT");
database.execSQL("ALTER TABLE `Stack` ADD `etag` TEXT");
database.execSQL("ALTER TABLE `Card` ADD `etag` TEXT");
database.execSQL("ALTER TABLE `Label` ADD `etag` TEXT");
database.execSQL("ALTER TABLE `AccessControl` ADD `etag` TEXT");
database.execSQL("ALTER TABLE `Attachment` ADD `etag` TEXT");
database.execSQL("ALTER TABLE `User` ADD `etag` TEXT");
database.execSQL("ALTER TABLE `DeckComment` ADD `etag` TEXT");
database.execSQL("ALTER TABLE `Activity` ADD `etag` TEXT");
database.execSQL("ALTER TABLE `OcsProject` ADD `etag` TEXT");
database.execSQL("ALTER TABLE `OcsProjectResource` ADD `etag` TEXT");
}
}

View file

@ -0,0 +1,39 @@
package it.niedermann.nextcloud.deck.database.migration;
import android.content.Context;
import android.content.SharedPreferences;
import androidx.annotation.NonNull;
import androidx.preference.PreferenceManager;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
import it.niedermann.nextcloud.deck.R;
/**
* <a href="https://github.com/stefan-niedermann/nextcloud-deck/issues/392">Dark mode following system default</a>
*/
public class Migration_23_24 extends Migration {
@NonNull
private final Context context;
public Migration_23_24(@NonNull Context context) {
super(23, 24);
this.context = context;
}
@Override
public void migrate(@NonNull SupportSQLiteDatabase database) {
final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
final String themePref = context.getString(R.string.pref_key_dark_theme);
if (sharedPreferences.contains(themePref)) {
SharedPreferences.Editor editor = sharedPreferences.edit();
final boolean darkTheme = sharedPreferences.getBoolean(themePref, false);
editor.remove(themePref);
editor.putString(themePref, darkTheme ? context.getString(R.string.pref_value_theme_dark) : context.getString(R.string.pref_value_theme_light));
editor.apply();
}
}
}

View file

@ -0,0 +1,22 @@
package it.niedermann.nextcloud.deck.database.migration;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
/**
* Reset ETags (comments weren't loading due to bug)
*/
public class Migration_24_25 extends Migration {
public Migration_24_25() {
super(24, 25);
}
@Override
public void migrate(SupportSQLiteDatabase database) {
database.execSQL("UPDATE `Account` SET `boardsEtag` = NULL");
database.execSQL("UPDATE `Board` SET `etag` = NULL");
database.execSQL("UPDATE `Stack` SET `etag` = NULL");
database.execSQL("UPDATE `Card` SET `etag` = NULL");
}
}

View file

@ -0,0 +1,42 @@
package it.niedermann.nextcloud.deck.database.migration;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
/**
* Implement <a href="https://github.com/stefan-niedermann/nextcloud-deck/issues/597">Filter widget</a>
*/
public class Migration_25_26 extends Migration {
public Migration_25_26() {
super(25, 26);
}
@Override
public void migrate(SupportSQLiteDatabase database) {
database.execSQL("CREATE TABLE `FilterWidget` (`id` INTEGER PRIMARY KEY NOT NULL, `title` TEXT, `dueType` INTEGER, `widgetType` INTEGER NOT NULL)");
database.execSQL("CREATE TABLE `FilterWidgetAccount` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `filterWidgetId` INTEGER, `accountId` INTEGER, `includeNoUser` INTEGER NOT NULL, `includeNoProject` INTEGER NOT NULL, FOREIGN KEY(`accountId`) REFERENCES `Account`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`filterWidgetId`) REFERENCES `FilterWidget`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )");
database.execSQL("CREATE TABLE `FilterWidgetBoard` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `filterAccountId` INTEGER, `boardId` INTEGER, `includeNoLabel` INTEGER NOT NULL, FOREIGN KEY(`boardId`) REFERENCES `Board`(`localId`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`filterAccountId`) REFERENCES `FilterWidgetAccount`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )");
database.execSQL("CREATE TABLE `FilterWidgetLabel` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `filterBoardId` INTEGER, `labelId` INTEGER, FOREIGN KEY(`labelId`) REFERENCES `Label`(`localId`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`filterBoardId`) REFERENCES `FilterWidgetBoard`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )");
database.execSQL("CREATE TABLE `FilterWidgetSort` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `filterWidgetId` INTEGER, `direction` INTEGER NOT NULL, `criteria` INTEGER NOT NULL, `ruleOrder` INTEGER NOT NULL, FOREIGN KEY(`filterWidgetId`) REFERENCES `FilterWidget`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )");
database.execSQL("CREATE TABLE `FilterWidgetStack` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `filterBoardId` INTEGER, `stackId` INTEGER, FOREIGN KEY(`stackId`) REFERENCES `Stack`(`localId`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`filterBoardId`) REFERENCES `FilterWidgetBoard`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )");
database.execSQL("CREATE TABLE `FilterWidgetUser` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `filterAccountId` INTEGER, `userId` INTEGER, FOREIGN KEY(`userId`) REFERENCES `User`(`localId`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`filterAccountId`) REFERENCES `FilterWidgetAccount`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )");
database.execSQL("CREATE TABLE `FilterWidgetProject` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `filterAccountId` INTEGER, `projectId` INTEGER, FOREIGN KEY(`projectId`) REFERENCES `OcsProject`(`localId`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`filterAccountId`) REFERENCES `FilterWidgetAccount`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )");
database.execSQL("CREATE INDEX `index_FilterWidgetAccount_filterWidgetId` ON `FilterWidgetAccount` (`filterWidgetId`)");
database.execSQL("CREATE INDEX `idx_FilterWidgetAccount_accountId` ON `FilterWidgetAccount` (`accountId`)");
database.execSQL("CREATE INDEX `idx_FilterWidgetBoard_boardId` ON `FilterWidgetBoard` (`boardId`)");
database.execSQL("CREATE INDEX `idx_FilterWidgetBoard_filterAccountId` ON `FilterWidgetBoard` (`filterAccountId`)");
database.execSQL("CREATE INDEX `idx_FilterWidgetLabel_filterBoardId` ON `FilterWidgetLabel` (`filterBoardId`)");
database.execSQL("CREATE INDEX `idx_FilterWidgetLabel_labelId` ON `FilterWidgetLabel` (`labelId`)");
database.execSQL("CREATE INDEX `idx_FilterWidgetSort_filterWidgetId` ON `FilterWidgetSort` (`filterWidgetId`)");
database.execSQL("CREATE INDEX `idx_FilterWidgetStack_filterBoardId` ON `FilterWidgetStack` (`filterBoardId`)");
database.execSQL("CREATE INDEX `idx_FilterWidgetStack_stackId` ON `FilterWidgetStack` (`stackId`)");
database.execSQL("CREATE INDEX `idx_FilterWidgetUser_filterAccountId` ON `FilterWidgetUser` (`filterAccountId`)");
database.execSQL("CREATE INDEX `idx_FilterWidgetUser_userId` ON `FilterWidgetUser` (`userId`)");
database.execSQL("CREATE INDEX `idx_FilterWidgetProject_filterAccountId` ON `FilterWidgetProject` (`filterAccountId`)");
database.execSQL("CREATE INDEX `idx_FilterWidgetProject_projectId` ON `FilterWidgetProject` (`projectId`)");
database.execSQL("CREATE INDEX `unique_idx_FilterWidgetSort_filterWidgetId_criteria` ON `FilterWidgetSort` (`filterWidgetId`, `criteria`)");
database.execSQL("CREATE INDEX `unique_idx_FilterWidgetSort_filterWidgetId_ruleOrder` ON `FilterWidgetSort` (`filterWidgetId`, `ruleOrder`)");
}
}

View file

@ -0,0 +1,62 @@
package it.niedermann.nextcloud.deck.database.migration;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
import it.niedermann.nextcloud.deck.model.widget.filter.EWidgetType;
/**
* @see <a href="https://github.com/stefan-niedermann/nextcloud-deck/issues/767">Migrate Stack Widget to Filter Widget infrastructure</a>
*/
public class Migration_26_27 extends Migration {
public Migration_26_27() {
super(26, 27);
}
@Override
public void migrate(SupportSQLiteDatabase database) {
Cursor cursor = database.query("select s.localId, s.boardId, s.accountId, w.appWidgetId from `StackWidgetModel` w inner join `Stack` s on s.localId = w.stackId");
while (cursor.moveToNext()) {
Long localStackId = cursor.getLong(0);
Long localBoardId = cursor.getLong(1);
Long accountId = cursor.getLong(2);
Long filterWidgetId = cursor.getLong(3);
// widget
ContentValues values = new ContentValues();
values.put("widgetType", EWidgetType.STACK_WIDGET.getId());
values.put("id", filterWidgetId);
database.insert("FilterWidget", SQLiteDatabase.CONFLICT_NONE, values);
// account
values = new ContentValues();
values.put("filterWidgetId", filterWidgetId);
values.put("accountId", accountId);
values.put("includeNoUser", false);
values.put("includeNoProject", false);
long filterWidgetAccountId = database.insert("FilterWidgetAccount", SQLiteDatabase.CONFLICT_NONE, values);
// board
values = new ContentValues();
values.put("filterAccountId", filterWidgetAccountId);
values.put("boardId", localBoardId);
values.put("includeNoLabel", false);
long filterWidgetBoardId = database.insert("FilterWidgetBoard", SQLiteDatabase.CONFLICT_NONE, values);
// stack
values = new ContentValues();
values.put("filterBoardId", filterWidgetBoardId);
values.put("stackId", localStackId);
database.insert("FilterWidgetStack", SQLiteDatabase.CONFLICT_NONE, values);
}
// cleanup
database.execSQL("DROP TABLE `StackWidgetModel`");
}
}

View file

@ -0,0 +1,19 @@
package it.niedermann.nextcloud.deck.database.migration;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
/**
* Adds support for new attachment types with Deck server <code>1.3.0</code>
*/
public class Migration_27_28 extends Migration {
public Migration_27_28() {
super(27, 28);
}
@Override
public void migrate(SupportSQLiteDatabase database) {
database.execSQL("ALTER TABLE `Attachment` ADD COLUMN `fileId` INTEGER");
}
}

View file

@ -0,0 +1,22 @@
package it.niedermann.nextcloud.deck.database.migration;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
/**
* Reset ETags for cards because <a href="https://github.com/nextcloud/deck/issues/2874">the attachments for this card might not be complete</a>.
*/
public class Migration_28_29 extends Migration {
public Migration_28_29() {
super(28, 29);
}
@Override
public void migrate(SupportSQLiteDatabase database) {
database.execSQL("UPDATE `Account` SET `boardsEtag` = NULL");
database.execSQL("UPDATE `Board` SET `etag` = NULL");
database.execSQL("UPDATE `Stack` SET `etag` = NULL");
database.execSQL("UPDATE `Card` SET `etag` = NULL");
}
}

View file

@ -0,0 +1,30 @@
package it.niedermann.nextcloud.deck.database.migration;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.preference.PreferenceManager;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
/**
* <a href="https://github.com/stefan-niedermann/nextcloud-deck/issues/392">Dark mode following system default</a>
*/
public class Migration_29_30 extends Migration {
@NonNull
private final Context context;
public Migration_29_30(@NonNull Context context) {
super(29, 30);
this.context = context;
}
@Override
public void migrate(@NonNull SupportSQLiteDatabase database) {
PreferenceManager.getDefaultSharedPreferences(context)
.edit()
.remove("branding")
.apply();
}
}

View file

@ -0,0 +1,182 @@
package it.niedermann.nextcloud.deck.database.migration;
import androidx.annotation.NonNull;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
/**
* <strong><a href="https://github.com/stefan-niedermann/nextcloud-deck/issues/923">Foreign keys don't cascade (Cards stay in the database after deleting an Account)</a></strong>
* <p>
* This migration had two issues in the past:
* <ul>
* <li>
* <a href="https://github.com/stefan-niedermann/nextcloud-deck/issues/936">1. Issue: SQLiteException</a>
* <p>
* <code>SQLiteException: table "Board" already exists (code 1): , while compiling: CREATE TABLE "Board" []</code><br />
* Caused by directly selecting the <code>CREATE</code> statements of the tables and executing them again.<br />
* The problem with this approach was that various different Android environments had different String quotes
* (<code>"</code>, <code>'</code>, <code>`</code>) which messed up table name replacement logic.<br />
* Fixed by explicitly creating each table manually.
* <p>
* Affected app versions: <code>1017000 (1.17.0)</code> - <code>1017002 (1.17.2)</code>
* </li>
* <li>
* <a href="https://github.com/stefan-niedermann/nextcloud-deck/issues/935">2. issue: SQLiteConstraintException</a>
* <p>
* <code>SQLiteConstraintException: NOT NULL constraint failed: Activity_tmp.type (code 1299 SQLITE_CONSTRAINT_NOTNULL[1299])</code><br />
* Fixed by explicitly selecting the values of each column manually instead of using a wildcard
* <p>
* To fix states where the migration was partially successful, the <code>*_tmp</code> tables will be dropped, so a half migration can successfully continue.
* <p>
* Affected app versions: <code>1017000 (1.17.3)</code> - <code>1017002 (1.17.6)</code>
* </li>
* </ul>
*/
public class Migration_30_31 extends Migration {
public Migration_30_31() {
super(30, 31);
}
@Override
public void migrate(@NonNull SupportSQLiteDatabase database) {
database.execSQL("DROP TABLE IF EXISTS `AccessControl_tmp`");
database.execSQL("CREATE TABLE `AccessControl_tmp` (`localId` INTEGER PRIMARY KEY AUTOINCREMENT, `accountId` INTEGER NOT NULL, `id` INTEGER, `status` INTEGER NOT NULL, `lastModified` INTEGER, `lastModifiedLocal` INTEGER, `etag` TEXT, `type` INTEGER, `boardId` INTEGER, `owner` INTEGER NOT NULL, `permissionEdit` INTEGER NOT NULL, `permissionShare` INTEGER NOT NULL, `permissionManage` INTEGER NOT NULL, `userId` INTEGER, FOREIGN KEY(`boardId`) REFERENCES `Board`(`localId`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`accountId`) REFERENCES `Account`(`id`) ON DELETE CASCADE )");
database.execSQL("DELETE FROM `AccessControl` where accountId not in (select id from `Account`)");
database.execSQL("INSERT INTO `AccessControl_tmp` (`localId`, `accountId`, `id`, `status`, `lastModified`, `lastModifiedLocal`, `etag`, `type`, `boardId`, `owner`, `permissionEdit`, `permissionShare`, `permissionManage`, `userId`) select `localId`, `accountId`, `id`, `status`, `lastModified`, `lastModifiedLocal`, `etag`, `type`, `boardId`, `owner`, `permissionEdit`, `permissionShare`, `permissionManage`, `userId` from `AccessControl`");
database.execSQL("DROP TABLE `AccessControl`");
database.execSQL("ALTER TABLE `AccessControl_tmp` RENAME TO `AccessControl`");
database.execSQL("CREATE INDEX `acl_accId` ON `AccessControl` (`accountId`)");
database.execSQL("CREATE INDEX `index_AccessControl_boardId` ON `AccessControl` (`boardId`)");
database.execSQL("CREATE INDEX `index_AccessControl_accountId` ON `AccessControl` (`accountId`)");
database.execSQL("CREATE INDEX `index_AccessControl_id` ON `AccessControl` (`id`)");
database.execSQL("CREATE INDEX `index_AccessControl_lastModifiedLocal` ON `AccessControl` (`lastModifiedLocal`)");
database.execSQL("CREATE UNIQUE INDEX `index_AccessControl_accountId_id` ON `AccessControl` (`accountId`, `id`)");
database.execSQL("DROP TABLE IF EXISTS `Activity_tmp`");
database.execSQL("CREATE TABLE `Activity_tmp` (`localId` INTEGER PRIMARY KEY AUTOINCREMENT, `accountId` INTEGER NOT NULL, `id` INTEGER, `status` INTEGER NOT NULL, `lastModified` INTEGER, `lastModifiedLocal` INTEGER, `etag` TEXT, `cardId` INTEGER NOT NULL, `subject` TEXT, `type` INTEGER NOT NULL, FOREIGN KEY(`cardId`) REFERENCES `Card`(`localId`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`accountId`) REFERENCES `Account`(`id`) ON DELETE CASCADE )");
database.execSQL("DELETE FROM `Activity` where accountId not in (select id from `Account`)");
database.execSQL("UPDATE `Activity` SET `type` = 2 WHERE `type` IS NULL");
database.execSQL("INSERT INTO `Activity_tmp` (`localId`, `accountId`, `id`, `status`, `lastModified`, `lastModifiedLocal`, `etag`, `cardId`, `subject`, `type`) select `localId`, `accountId`, `id`, `status`, `lastModified`, `lastModifiedLocal`, `etag`, `cardId`, `subject`, COALESCE(`type`, 2) from `Activity`");
database.execSQL("DROP TABLE `Activity`");
database.execSQL("ALTER TABLE `Activity_tmp` RENAME TO `Activity`");
database.execSQL("CREATE INDEX `activity_accID` ON `Activity` (`accountId`)");
database.execSQL("CREATE INDEX `activity_cardID` ON `Activity` (`cardId`)");
database.execSQL("CREATE INDEX `index_Activity_accountId` ON `Activity` (`accountId`)");
database.execSQL("CREATE INDEX `index_Activity_id` ON `Activity` (`id`)");
database.execSQL("CREATE INDEX `index_Activity_lastModifiedLocal` ON `Activity` (`lastModifiedLocal`)");
database.execSQL("CREATE UNIQUE INDEX `index_Activity_accountId_id` ON `Activity` (`accountId`, `id`)");
database.execSQL("DROP TABLE IF EXISTS `Attachment_tmp`");
database.execSQL("CREATE TABLE `Attachment_tmp` (`localId` INTEGER PRIMARY KEY AUTOINCREMENT, `accountId` INTEGER NOT NULL, `id` INTEGER, `status` INTEGER NOT NULL, `lastModified` INTEGER, `lastModifiedLocal` INTEGER, `etag` TEXT, `cardId` INTEGER NOT NULL, `type` TEXT, `data` TEXT, `createdAt` INTEGER, `createdBy` TEXT, `deletedAt` INTEGER, `filesize` INTEGER NOT NULL, `mimetype` TEXT, `dirname` TEXT, `basename` TEXT, `extension` TEXT, `filename` TEXT, `localPath` TEXT, `fileId` INTEGER, FOREIGN KEY(`cardId`) REFERENCES `Card`(`localId`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`accountId`) REFERENCES `Account`(`id`) ON DELETE CASCADE )");
database.execSQL("DELETE FROM `Attachment` where accountId not in (select id from `Account`)");
database.execSQL("INSERT INTO `Attachment_tmp` (`localId`, `accountId`, `id`, `status`, `lastModified`, `lastModifiedLocal`, `etag`, `cardId`, `type`, `data`, `createdAt`, `createdBy`, `deletedAt`, `filesize`, `mimetype`, `dirname`, `basename`, `extension`, `filename`, `localPath`, `fileId`) select `localId`, `accountId`, `id`, `status`, `lastModified`, `lastModifiedLocal`, `etag`, `cardId`, `type`, `data`, `createdAt`, `createdBy`, `deletedAt`, `filesize`, `mimetype`, `dirname`, `basename`, `extension`, `filename`, `localPath`, `fileId` from `Attachment`");
database.execSQL("DROP TABLE `Attachment`");
database.execSQL("ALTER TABLE `Attachment_tmp` RENAME TO `Attachment`");
database.execSQL("CREATE INDEX `index_Attachment_cardId` ON `Attachment` (`cardId`)");
database.execSQL("CREATE INDEX `index_Attachment_accountId` ON `Attachment` (`accountId`)");
database.execSQL("CREATE INDEX `index_Attachment_id` ON `Attachment` (`id`)");
database.execSQL("CREATE INDEX `index_Attachment_lastModifiedLocal` ON `Attachment` (`lastModifiedLocal`)");
database.execSQL("CREATE UNIQUE INDEX `index_Attachment_accountId_id` ON `Attachment` (`accountId`, `id`)");
database.execSQL("DROP TABLE IF EXISTS `Board_tmp`");
database.execSQL("CREATE TABLE `Board_tmp` (`localId` INTEGER PRIMARY KEY AUTOINCREMENT, `accountId` INTEGER NOT NULL, `id` INTEGER, `status` INTEGER NOT NULL, `lastModified` INTEGER, `lastModifiedLocal` INTEGER, `etag` TEXT, `title` TEXT, `ownerId` INTEGER NOT NULL, `color` INTEGER, `archived` INTEGER NOT NULL, `shared` INTEGER NOT NULL, `deletedAt` INTEGER, `permissionRead` INTEGER NOT NULL, `permissionEdit` INTEGER NOT NULL, `permissionManage` INTEGER NOT NULL, `permissionShare` INTEGER NOT NULL, FOREIGN KEY(`ownerId`) REFERENCES `User`(`localId`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`accountId`) REFERENCES `Account`(`id`) ON DELETE CASCADE )");
database.execSQL("DELETE FROM `Board` where accountId not in (select id from `Account`)");
database.execSQL("INSERT INTO `Board_tmp` (`localId`, `accountId`, `id`, `status`, `lastModified`, `lastModifiedLocal`, `etag`, `title`, `ownerId`, `color`, `archived`, `shared`, `deletedAt`, `permissionRead`, `permissionEdit`, `permissionManage`, `permissionShare`) select `localId`, `accountId`, `id`, `status`, `lastModified`, `lastModifiedLocal`, `etag`, `title`, `ownerId`, `color`, `archived`, `shared`, `deletedAt`, `permissionRead`, `permissionEdit`, `permissionManage`, `permissionShare` from `Board`");
database.execSQL("DROP TABLE `Board`");
database.execSQL("ALTER TABLE `Board_tmp` RENAME TO `Board`");
database.execSQL("CREATE INDEX `index_Board_ownerId` ON `Board` (`ownerId`)");
database.execSQL("CREATE INDEX `index_Board_accountId` ON `Board` (`accountId`)");
database.execSQL("CREATE INDEX `index_Board_id` ON `Board` (`id`)");
database.execSQL("CREATE INDEX `index_Board_lastModifiedLocal` ON `Board` (`lastModifiedLocal`)");
database.execSQL("CREATE UNIQUE INDEX `index_Board_accountId_id` ON `Board` (`accountId`, `id`)");
database.execSQL("DROP TABLE IF EXISTS `Card_tmp`");
database.execSQL("CREATE TABLE `Card_tmp` (`localId` INTEGER PRIMARY KEY AUTOINCREMENT, `accountId` INTEGER NOT NULL, `id` INTEGER, `status` INTEGER NOT NULL, `lastModified` INTEGER, `lastModifiedLocal` INTEGER, `etag` TEXT, `title` TEXT, `description` TEXT, `stackId` INTEGER NOT NULL, `type` TEXT, `createdAt` INTEGER, `deletedAt` INTEGER, `attachmentCount` INTEGER NOT NULL, `userId` INTEGER, `order` INTEGER NOT NULL, `archived` INTEGER NOT NULL, `dueDate` INTEGER, `notified` INTEGER NOT NULL, `overdue` INTEGER NOT NULL, `commentsUnread` INTEGER NOT NULL, FOREIGN KEY(`stackId`) REFERENCES `Stack`(`localId`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`accountId`) REFERENCES `Account`(`id`) ON DELETE CASCADE )");
database.execSQL("DELETE FROM `Card` where accountId not in (select id from `Account`)");
database.execSQL("INSERT INTO `Card_tmp` (`localId`, `accountId`, `id`, `status`, `lastModified`, `lastModifiedLocal`, `etag`, `title`, `description`, `stackId`, `type`, `createdAt`, `deletedAt`, `attachmentCount`, `userId`, `order`, `archived`, `dueDate`, `notified`, `overdue`, `commentsUnread`) select `localId`, `accountId`, `id`, `status`, `lastModified`, `lastModifiedLocal`, `etag`, `title`, `description`, `stackId`, `type`, `createdAt`, `deletedAt`, `attachmentCount`, `userId`, `order`, `archived`, `dueDate`, `notified`, `overdue`, `commentsUnread` from `Card`");
database.execSQL("DROP TABLE `Card`");
database.execSQL("ALTER TABLE `Card_tmp` RENAME TO `Card`");
database.execSQL("CREATE INDEX `card_accID` ON `Card` (`accountId`)");
database.execSQL("CREATE INDEX `index_Card_stackId` ON `Card` (`stackId`)");
database.execSQL("CREATE INDEX `index_Card_accountId` ON `Card` (`accountId`)");
database.execSQL("CREATE INDEX `index_Card_id` ON `Card` (`id`)");
database.execSQL("CREATE INDEX `index_Card_lastModifiedLocal` ON `Card` (`lastModifiedLocal`)");
database.execSQL("CREATE UNIQUE INDEX `index_Card_accountId_id` ON `Card` (`accountId`, `id`)");
database.execSQL("DROP TABLE IF EXISTS `DeckComment_tmp`");
database.execSQL("CREATE TABLE `DeckComment_tmp` (`localId` INTEGER PRIMARY KEY AUTOINCREMENT, `accountId` INTEGER NOT NULL, `id` INTEGER, `status` INTEGER NOT NULL, `lastModified` INTEGER, `lastModifiedLocal` INTEGER, `etag` TEXT, `objectId` INTEGER, `actorType` TEXT, `creationDateTime` INTEGER, `actorId` TEXT, `actorDisplayName` TEXT, `message` TEXT, `parentId` INTEGER, FOREIGN KEY(`objectId`) REFERENCES `Card`(`localId`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`parentId`) REFERENCES `DeckComment`(`localId`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`accountId`) REFERENCES `Account`(`id`) ON DELETE CASCADE )");
database.execSQL("DELETE FROM `DeckComment` where accountId not in (select id from `Account`)");
database.execSQL("INSERT INTO `DeckComment_tmp` (`localId`, `accountId`, `id`, `status`, `lastModified`, `lastModifiedLocal`, `etag`, `objectId`, `actorType`, `creationDateTime`, `actorId`, `actorDisplayName`, `message`, `parentId`) select `localId`, `accountId`, `id`, `status`, `lastModified`, `lastModifiedLocal`, `etag`, `objectId`, `actorType`, `creationDateTime`, `actorId`, `actorDisplayName`, `message`, `parentId` from `DeckComment`");
database.execSQL("DROP TABLE `DeckComment`");
database.execSQL("ALTER TABLE `DeckComment_tmp` RENAME TO `DeckComment`");
database.execSQL("CREATE INDEX `comment_accID` ON `DeckComment` (`accountId`)");
database.execSQL("CREATE INDEX `index_DeckComment_objectId` ON `DeckComment` (`objectId`)");
database.execSQL("CREATE INDEX `idx_comment_parentID` ON `DeckComment` (`parentId`)");
database.execSQL("CREATE INDEX `index_DeckComment_accountId` ON `DeckComment` (`accountId`)");
database.execSQL("CREATE INDEX `index_DeckComment_id` ON `DeckComment` (`id`)");
database.execSQL("CREATE INDEX `index_DeckComment_lastModifiedLocal` ON `DeckComment` (`lastModifiedLocal`)");
database.execSQL("CREATE UNIQUE INDEX `index_DeckComment_accountId_id` ON `DeckComment` (`accountId`, `id`)");
database.execSQL("DROP TABLE IF EXISTS `Label_tmp`");
database.execSQL("CREATE TABLE `Label_tmp` (`localId` INTEGER PRIMARY KEY AUTOINCREMENT, `accountId` INTEGER NOT NULL, `id` INTEGER, `status` INTEGER NOT NULL, `lastModified` INTEGER, `lastModifiedLocal` INTEGER, `etag` TEXT, `title` TEXT, `color` INTEGER NOT NULL DEFAULT 0, `boardId` INTEGER NOT NULL, FOREIGN KEY(`boardId`) REFERENCES `Board`(`localId`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`accountId`) REFERENCES `Account`(`id`) ON DELETE CASCADE )");
database.execSQL("DELETE FROM `Label` where accountId not in (select id from `Account`)");
database.execSQL("INSERT INTO `Label_tmp` (`localId`, `accountId`, `id`, `status`, `lastModified`, `lastModifiedLocal`, `etag`, `title`, `color`, `boardId`) select `localId`, `accountId`, `id`, `status`, `lastModified`, `lastModifiedLocal`, `etag`, `title`, `color`, `boardId` from `Label`");
database.execSQL("DROP TABLE `Label`");
database.execSQL("ALTER TABLE `Label_tmp` RENAME TO `Label`");
database.execSQL("CREATE INDEX `index_Label_boardId` ON `Label` (`boardId`)");
database.execSQL("CREATE UNIQUE INDEX `idx_label_title_unique` ON `Label` (`boardId`, `title`)");
database.execSQL("CREATE INDEX `index_Label_accountId` ON `Label` (`accountId`)");
database.execSQL("CREATE INDEX `index_Label_id` ON `Label` (`id`)");
database.execSQL("CREATE INDEX `index_Label_lastModifiedLocal` ON `Label` (`lastModifiedLocal`)");
database.execSQL("CREATE UNIQUE INDEX `index_Label_accountId_id` ON `Label` (`accountId`, `id`)");
database.execSQL("DROP TABLE IF EXISTS `OcsProject_tmp`");
database.execSQL("CREATE TABLE `OcsProject_tmp` (`localId` INTEGER PRIMARY KEY AUTOINCREMENT, `accountId` INTEGER NOT NULL, `id` INTEGER, `status` INTEGER NOT NULL, `lastModified` INTEGER, `lastModifiedLocal` INTEGER, `etag` TEXT, `name` TEXT NOT NULL, FOREIGN KEY(`accountId`) REFERENCES `Account`(`id`) ON DELETE CASCADE )");
database.execSQL("DELETE FROM `OcsProject` where accountId not in (select id from `Account`)");
database.execSQL("INSERT INTO `OcsProject_tmp` (`localId`, `accountId`, `id`, `status`, `lastModified`, `lastModifiedLocal`, `etag`, `name`) select `localId`, `accountId`, `id`, `status`, `lastModified`, `lastModifiedLocal`, `etag`, `name` from `OcsProject`");
database.execSQL("DROP TABLE `OcsProject`");
database.execSQL("ALTER TABLE `OcsProject_tmp` RENAME TO `OcsProject`");
database.execSQL("CREATE INDEX `index_project_accID` ON `OcsProject` (`accountId`)");
database.execSQL("CREATE INDEX `index_OcsProject_accountId` ON `OcsProject` (`accountId`)");
database.execSQL("CREATE INDEX `index_OcsProject_id` ON `OcsProject` (`id`)");
database.execSQL("CREATE INDEX `index_OcsProject_lastModifiedLocal` ON `OcsProject` (`lastModifiedLocal`)");
database.execSQL("CREATE UNIQUE INDEX `index_OcsProject_accountId_id` ON `OcsProject` (`accountId`, `id`)");
database.execSQL("DROP TABLE IF EXISTS `OcsProjectResource_tmp`");
database.execSQL("CREATE TABLE `OcsProjectResource_tmp` (`localId` INTEGER PRIMARY KEY AUTOINCREMENT, `accountId` INTEGER NOT NULL, `id` INTEGER, `status` INTEGER NOT NULL, `lastModified` INTEGER, `lastModifiedLocal` INTEGER, `etag` TEXT, `type` TEXT, `name` TEXT, `link` TEXT, `path` TEXT, `iconUrl` TEXT, `mimetype` TEXT, `previewAvailable` INTEGER, `idString` TEXT, `projectId` INTEGER NOT NULL, FOREIGN KEY(`projectId`) REFERENCES `OcsProject`(`localId`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`accountId`) REFERENCES `Account`(`id`) ON DELETE CASCADE )");
database.execSQL("DELETE FROM `OcsProjectResource` where accountId not in (select id from `Account`)");
database.execSQL("INSERT INTO `OcsProjectResource_tmp` (`localId`, `accountId`, `id`, `status`, `lastModified`, `lastModifiedLocal`, `etag`, `type`, `name`, `link`, `path`, `iconUrl`, `mimetype`, `previewAvailable`, `idString`, `projectId`) select `localId`, `accountId`, `id`, `status`, `lastModified`, `lastModifiedLocal`, `etag`, `type`, `name`, `link`, `path`, `iconUrl`, `mimetype`, `previewAvailable`, `idString`, `projectId` from `OcsProjectResource`");
database.execSQL("DROP TABLE `OcsProjectResource`");
database.execSQL("ALTER TABLE `OcsProjectResource_tmp` RENAME TO `OcsProjectResource`");
database.execSQL("CREATE INDEX `index_OcsProjectResource_id` ON `OcsProjectResource` (`id`)");
database.execSQL("CREATE INDEX `index_OcsProjectResource_lastModifiedLocal` ON `OcsProjectResource` (`lastModifiedLocal`)");
database.execSQL("CREATE UNIQUE INDEX `index_OcsProjectResource_accountId_id` ON `OcsProjectResource` (`accountId`, `id`, `idString`, `projectId`)");
database.execSQL("CREATE INDEX `index_projectResource_accID` ON `OcsProjectResource` (`accountId`)");
database.execSQL("CREATE INDEX `index_projectResource_projectId` ON `OcsProjectResource` (`projectId`)");
database.execSQL("DROP TABLE IF EXISTS `Stack_tmp`");
database.execSQL("CREATE TABLE `Stack_tmp` (`localId` INTEGER PRIMARY KEY AUTOINCREMENT, `accountId` INTEGER NOT NULL, `id` INTEGER, `status` INTEGER NOT NULL, `lastModified` INTEGER, `lastModifiedLocal` INTEGER, `etag` TEXT, `title` TEXT, `boardId` INTEGER NOT NULL, `deletedAt` INTEGER, `order` INTEGER NOT NULL, FOREIGN KEY(`boardId`) REFERENCES `Board`(`localId`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`accountId`) REFERENCES `Account`(`id`) ON DELETE CASCADE )");
database.execSQL("DELETE FROM `Stack` where accountId not in (select id from `Account`)");
database.execSQL("INSERT INTO `Stack_tmp` (`localId`, `accountId`, `id`, `status`, `lastModified`, `lastModifiedLocal`, `etag`, `title`, `boardId`, `deletedAt`, `order`) select `localId`, `accountId`, `id`, `status`, `lastModified`, `lastModifiedLocal`, `etag`, `title`, `boardId`, `deletedAt`, `order` from `Stack`");
database.execSQL("DROP TABLE `Stack`");
database.execSQL("ALTER TABLE `Stack_tmp` RENAME TO `Stack`");
database.execSQL("CREATE INDEX `index_Stack_boardId` ON `Stack` (`boardId`)");
database.execSQL("CREATE INDEX `index_Stack_accountId` ON `Stack` (`accountId`)");
database.execSQL("CREATE INDEX `index_Stack_id` ON `Stack` (`id`)");
database.execSQL("CREATE INDEX `index_Stack_lastModifiedLocal` ON `Stack` (`lastModifiedLocal`)");
database.execSQL("CREATE UNIQUE INDEX `index_Stack_accountId_id` ON `Stack` (`accountId`, `id`)");
database.execSQL("DROP TABLE IF EXISTS `User_tmp`");
database.execSQL("CREATE TABLE `User_tmp` (`localId` INTEGER PRIMARY KEY AUTOINCREMENT, `accountId` INTEGER NOT NULL, `id` INTEGER, `status` INTEGER NOT NULL, `lastModified` INTEGER, `lastModifiedLocal` INTEGER, `etag` TEXT, `primaryKey` TEXT, `uid` TEXT, `displayname` TEXT, FOREIGN KEY(`accountId`) REFERENCES `Account`(`id`) ON DELETE CASCADE )");
database.execSQL("DELETE FROM `User` where accountId not in (select id from `Account`)");
database.execSQL("INSERT INTO `User_tmp` (`localId`, `accountId`, `id`, `status`, `lastModified`, `lastModifiedLocal`, `etag`, `primaryKey`, `uid`, `displayname`) select `localId`, `accountId`, `id`, `status`, `lastModified`, `lastModifiedLocal`, `etag`, `primaryKey`, `uid`, `displayname` from `User`");
database.execSQL("DROP TABLE `User`");
database.execSQL("ALTER TABLE `User_tmp` RENAME TO `User`");
database.execSQL("CREATE INDEX `user_uid` ON `User` (`uid`)");
database.execSQL("CREATE INDEX `index_User_accountId` ON `User` (`accountId`)");
database.execSQL("CREATE INDEX `index_User_id` ON `User` (`id`)");
database.execSQL("CREATE INDEX `index_User_lastModifiedLocal` ON `User` (`lastModifiedLocal`)");
database.execSQL("CREATE UNIQUE INDEX `index_User_accountId_id` ON `User` (`accountId`, `id`)");
}
}

View file

@ -0,0 +1,29 @@
package it.niedermann.nextcloud.deck.database.migration;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.preference.PreferenceManager;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
/**
*/
public class Migration_31_32 extends Migration {
@NonNull
private final Context context;
public Migration_31_32(@NonNull Context context) {
super(31, 32);
this.context = context;
}
@Override
public void migrate(@NonNull SupportSQLiteDatabase database) {
PreferenceManager.getDefaultSharedPreferences(context)
.edit()
.remove("it.niedermann.nextcloud.deck.theme_main")
.remove("it.niedermann.nextcloud.deck.last_account_color")
.apply();
}
}

View file

@ -0,0 +1,25 @@
package it.niedermann.nextcloud.deck.database.migration;
import androidx.annotation.NonNull;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
/**
* Adds support for marking a card as done: https://github.com/stefan-niedermann/nextcloud-deck/issues/1556
*/
public class Migration_32_33 extends Migration {
public Migration_32_33() {
super(32, 33);
}
@Override
public void migrate(@NonNull SupportSQLiteDatabase database) {
database.execSQL("ALTER TABLE `Card` add column done INTEGER");
// Reset ETags: Refetch all cards to support Done state which did not change ETags
database.execSQL("UPDATE `Account` SET `boardsEtag` = NULL");
database.execSQL("UPDATE `Board` SET `etag` = NULL");
database.execSQL("UPDATE `Stack` SET `etag` = NULL");
database.execSQL("UPDATE `Card` SET `etag` = NULL");
}
}

View file

@ -0,0 +1,22 @@
package it.niedermann.nextcloud.deck.database.migration;
import androidx.annotation.NonNull;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
/**
* Adds support for marking a card as done: https://github.com/stefan-niedermann/nextcloud-deck/issues/1556
*/
public class Migration_33_34 extends Migration {
public Migration_33_34() {
super(33, 34);
}
@Override
public void migrate(@NonNull SupportSQLiteDatabase database) {
database.execSQL("ALTER TABLE `User` add column type INTEGER not null default 0");
// Reset ETags to refetch Users
database.execSQL("UPDATE `Account` SET `boardsEtag` = NULL");
}
}

View file

@ -0,0 +1,27 @@
package it.niedermann.nextcloud.deck.database.migration;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
/**
* Adds support for comments
*/
public class Migration_8_9 extends Migration {
public Migration_8_9() {
super(8, 9);
}
@Override
public void migrate(SupportSQLiteDatabase database) {
database.execSQL("CREATE TABLE `DeckComment` (`localId` INTEGER PRIMARY KEY AUTOINCREMENT, `accountId` INTEGER NOT NULL, `id` INTEGER, `status` INTEGER NOT NULL, `lastModified` INTEGER, `lastModifiedLocal` INTEGER, `objectId` INTEGER, `actorType` TEXT, `creationDateTime` INTEGER, `actorId` TEXT, `actorDisplayName` TEXT, `message` TEXT, FOREIGN KEY(`objectId`) REFERENCES `Card`(`localId`) ON UPDATE NO ACTION ON DELETE CASCADE )");
database.execSQL("CREATE TABLE `Mention` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `commentId` INTEGER, `mentionId` TEXT, `mentionType` TEXT, `mentionDisplayName` TEXT, FOREIGN KEY(`commentId`) REFERENCES `DeckComment`(`localId`) ON UPDATE NO ACTION ON DELETE CASCADE )");
database.execSQL("CREATE INDEX `index_DeckComment_accountId` ON `DeckComment` (`accountId`)");
database.execSQL("CREATE INDEX `comment_accID` ON `DeckComment` (`accountId`)");
database.execSQL("CREATE UNIQUE INDEX `index_DeckComment_accountId_id` ON `DeckComment` (`accountId`, `id`)");
database.execSQL("CREATE INDEX `index_DeckComment_id` ON `DeckComment` (`id`)");
database.execSQL("CREATE INDEX `index_DeckComment_lastModifiedLocal` ON `DeckComment` (`lastModifiedLocal`)");
database.execSQL("CREATE INDEX `index_DeckComment_objectId` ON `DeckComment` (`objectId`)");
database.execSQL("CREATE INDEX `index_Mention_commentId` ON `Mention` (`commentId`)");
}
}

View file

@ -0,0 +1,22 @@
package it.niedermann.nextcloud.deck.database.migration;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
/**
* Adds support for account colors, deck server versions and Nextcloud maintenance mode
*/
public class Migration_9_10 extends Migration {
public Migration_9_10() {
super(9, 10);
}
@Override
public void migrate(SupportSQLiteDatabase database) {
database.execSQL("ALTER TABLE `Account` ADD `color` TEXT NOT NULL DEFAULT '#0082c9'");
database.execSQL("ALTER TABLE `Account` ADD `textColor` TEXT NOT NULL DEFAULT '#ffffff'");
database.execSQL("ALTER TABLE `Account` ADD `serverDeckVersion` TEXT NOT NULL DEFAULT '0.6.4'");
database.execSQL("ALTER TABLE `Account` ADD `maintenanceEnabled` INTEGER NOT NULL DEFAULT 0");
}
}

View file

@ -0,0 +1,22 @@
package it.niedermann.nextcloud.deck.exceptions;
public class DeckException extends IllegalArgumentException {
public enum Hint {
CAPABILITIES_NOT_PARSABLE,
CAPABILITIES_VERSION_NOT_PARSABLE,
UNKNOWN_ACCOUNT_USER_ID,
DEPENDENCY_NOT_SYNCED_YET
}
private final Hint hint;
public DeckException(Hint hint, String message) {
super(message);
this.hint = hint;
}
public Hint getHint() {
return hint;
}
}

View file

@ -0,0 +1,67 @@
package it.niedermann.nextcloud.deck.exceptions;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonSyntaxException;
import com.nextcloud.android.sso.exceptions.NextcloudHttpRequestFailedException;
public enum HandledServerErrors {
UNKNOWN(1337, "hopefully won't occur"),
LABELS_TITLE_MUST_BE_UNIQUE(400, "Title must be unique"),
ATTACHMENTS_FILE_ALREADY_EXISTS(409, "File already exists."),
;
private final int status;
private final String message;
HandledServerErrors(int status, String message) {
this.status = status;
this.message = message;
}
public static HandledServerErrors fromThrowable(Throwable throwable) {
if (throwable instanceof NextcloudHttpRequestFailedException requestFailedException) {
if (requestFailedException.getCause() != null) {
String errorString = requestFailedException.getCause().getMessage();
try {
JsonElement jsonElement = JsonParser.parseString(errorString);
if (jsonElement.isJsonObject()){
ServerError error = new ServerError();
error.status = requestFailedException.getStatusCode();
JsonObject errorObj = jsonElement.getAsJsonObject();
if (errorObj.has("message")){
error.message = errorObj.get("message").getAsString();
}
return findByServerError(error);
}
} catch (JsonSyntaxException e){
return HandledServerErrors.UNKNOWN;
}
}
}
return HandledServerErrors.UNKNOWN;
}
private static HandledServerErrors findByServerError(ServerError error) {
for (HandledServerErrors value : HandledServerErrors.values()) {
if (value.status == error.status && value.message.equals(error.message)){
return value;
}
}
return HandledServerErrors.UNKNOWN;
}
public String getMessage() {
return message;
}
public int getStatus() {
return status;
}
private static class ServerError {
private int status;
private String message;
}
}

View file

@ -0,0 +1,51 @@
package it.niedermann.nextcloud.deck.exceptions;
import androidx.annotation.NonNull;
import androidx.annotation.StringRes;
import it.niedermann.nextcloud.deck.R;
public class OfflineException extends IllegalStateException {
private final Reason reason;
public OfflineException() {
this(Reason.OFFLINE);
}
public OfflineException(@NonNull Reason reason) {
super(reason.getKey());
this.reason = reason;
}
@NonNull
public Reason getReason() {
return reason;
}
public enum Reason {
OFFLINE("Device is currently offline", R.string.error_dialog_tip_offline_no_internet),
CONNECTION_REFUSED("Connection refused", R.string.error_dialog_tip_offline_connection_refused),
CONNECTION_TIMEOUT("Connection timeout", R.string.error_dialog_tip_offline_connection_timeout),
CONNECTION_REJECTED("Connection rejected", R.string.error_dialog_tip_connection_rejected),
;
private final String key;
@StringRes
private final int message;
Reason(@NonNull String key, @StringRes int message) {
this.key = key;
this.message = message;
}
public String getKey() {
return key;
}
@StringRes
public int getMessage() {
return message;
}
}
}

View file

@ -0,0 +1,36 @@
package it.niedermann.nextcloud.deck.exceptions;
import it.niedermann.nextcloud.deck.DeckLog;
public class TraceableException extends RuntimeException {
private TraceableException(String message, Throwable cause) {
super(message, cause);
}
public static void makeTraceableIfFails(Runnable runnable, Object... args) {
try {
runnable.run();
} catch (TraceableException t) {
throw t;
} catch (Throwable t) {
final StringBuilder message = new StringBuilder("Sorry, a wild error appeared!\n\n" +
"⚠️ If you want to tell us about the following issue, " +
"please make sure to censor sensitive data beforehand! ⚠️\n\n" +
"Failed to run traceable code");
if (args != null && args.length > 0) {
message.append(" with arguments:\n");
for (Object arg : args) {
message.append(arg == null ? "null" : arg.toString()).append("\n");
}
} else {
message.append(":\n");
}
message.append("Cause: ").append(t.getLocalizedMessage());
TraceableException ex = new TraceableException(message.toString(), t);
DeckLog.logError(ex);
throw ex;
}
}
}

View file

@ -0,0 +1,12 @@
package it.niedermann.nextcloud.deck.exceptions;
public class UploadAttachmentFailedException extends Exception {
public UploadAttachmentFailedException(String message) {
super(message);
}
public UploadAttachmentFailedException(String message, Throwable cause) {
super(message, cause);
}
}

View file

@ -0,0 +1,188 @@
package it.niedermann.nextcloud.deck.model;
import androidx.room.Entity;
import androidx.room.ForeignKey;
import androidx.room.Ignore;
import androidx.room.Index;
import com.google.gson.annotations.SerializedName;
import java.util.Objects;
import it.niedermann.nextcloud.deck.model.interfaces.AbstractRemoteEntity;
import it.niedermann.nextcloud.deck.model.ocs.user.GroupMemberUIDs;
@Entity(inheritSuperIndices = true,
indices = {
@Index(value = "accountId", name = "acl_accId"),
@Index("boardId")
},
foreignKeys = {
@ForeignKey(
entity = Board.class,
parentColumns = "localId",
childColumns = "boardId", onDelete = ForeignKey.CASCADE
),
@ForeignKey(
entity = Account.class,
parentColumns = "id",
childColumns = "accountId", onDelete = ForeignKey.CASCADE
)
}
)
public class AccessControl extends AbstractRemoteEntity {
private Long type;
private Long boardId;
private boolean owner;
private boolean permissionEdit;
private boolean permissionShare;
private boolean permissionManage;
private Long userId;
@Ignore
@SerializedName("participant")
private User user;
@Ignore
private GroupMemberUIDs groupMemberUIDs;
public AccessControl() {
super();
}
public AccessControl(AccessControl accessControl) {
this.type = accessControl.getType();
this.boardId = accessControl.getBoardId();
this.owner = accessControl.isOwner();
this.permissionEdit = accessControl.isPermissionEdit();
this.permissionShare = accessControl.isPermissionShare();
this.permissionManage = accessControl.isPermissionManage();
this.userId = accessControl.getUserId();
this.user = accessControl.getUser();
}
public Long getType() {
return type;
}
public void setType(Long type) {
this.type = type;
}
public Long getBoardId() {
return boardId;
}
public void setBoardId(Long boardId) {
this.boardId = boardId;
}
public boolean isOwner() {
return owner;
}
public void setOwner(boolean owner) {
this.owner = owner;
}
public boolean isPermissionEdit() {
return permissionEdit;
}
public void setPermissionEdit(boolean permissionEdit) {
this.permissionEdit = permissionEdit;
}
public boolean isPermissionShare() {
return permissionShare;
}
public void setPermissionShare(boolean permissionShare) {
this.permissionShare = permissionShare;
}
public boolean isPermissionManage() {
return permissionManage;
}
public void setPermissionManage(boolean permissionManage) {
this.permissionManage = permissionManage;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public GroupMemberUIDs getGroupMemberUIDs() {
return groupMemberUIDs;
}
public void setGroupMemberUIDs(GroupMemberUIDs groupMemberUIDs) {
this.groupMemberUIDs = groupMemberUIDs;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
AccessControl that = (AccessControl) o;
if (owner != that.owner) return false;
if (permissionEdit != that.permissionEdit) return false;
if (permissionShare != that.permissionShare) return false;
if (permissionManage != that.permissionManage) return false;
if (!Objects.equals(type, that.type)) return false;
if (!Objects.equals(boardId, that.boardId)) return false;
if (!Objects.equals(userId, that.userId)) return false;
return Objects.equals(user, that.user);
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (type != null ? type.hashCode() : 0);
result = 31 * result + (boardId != null ? boardId.hashCode() : 0);
result = 31 * result + (owner ? 1 : 0);
result = 31 * result + (permissionEdit ? 1 : 0);
result = 31 * result + (permissionShare ? 1 : 0);
result = 31 * result + (permissionManage ? 1 : 0);
result = 31 * result + (userId != null ? userId.hashCode() : 0);
result = 31 * result + (user != null ? user.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "AccessControl{" +
"type=" + type +
", boardId=" + boardId +
", owner=" + owner +
", permissionEdit=" + permissionEdit +
", permissionShare=" + permissionShare +
", permissionManage=" + permissionManage +
", userId=" + userId +
", user=" + user +
", localId=" + localId +
", accountId=" + accountId +
", id=" + id +
", status=" + status +
", lastModified=" + lastModified +
", lastModifiedLocal=" + lastModifiedLocal +
"} " + super.toString();
}
}

View file

@ -0,0 +1,284 @@
package it.niedermann.nextcloud.deck.model;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.Px;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.Index;
import androidx.room.PrimaryKey;
import com.bumptech.glide.Glide;
import com.nextcloud.android.sso.AccountImporter;
import com.nextcloud.android.sso.exceptions.NextcloudFilesAppAccountNotFoundException;
import com.nextcloud.android.sso.model.SingleSignOnAccount;
import java.io.Serializable;
import java.util.Objects;
import java.util.Optional;
import it.niedermann.nextcloud.deck.DeckLog;
import it.niedermann.nextcloud.deck.model.ocs.Capabilities;
import it.niedermann.nextcloud.deck.model.ocs.Version;
import it.niedermann.nextcloud.sso.glide.SingleSignOnUrl;
@Entity(indices = {@Index(value = "name", unique = true)})
public class Account implements Serializable {
@Ignore
private static final long serialVersionUID = 0;
@PrimaryKey(autoGenerate = true)
protected Long id;
@NonNull
private String name;
@NonNull
private String userName;
@Ignore
@Nullable
private String userDisplayName;
@NonNull
private String url;
/**
* See {@link Capabilities#DEFAULT_COLOR}
*/
@NonNull
@ColumnInfo(defaultValue = "0")
private Integer color = Capabilities.DEFAULT_COLOR;
@NonNull
@ColumnInfo(defaultValue = "0")
private Integer textColor = Capabilities.DEFAULT_TEXT_COLOR;
@NonNull
@ColumnInfo(defaultValue = "0.6.4")
private String serverDeckVersion = "0.6.4";
@NonNull
@ColumnInfo(defaultValue = "0")
private boolean maintenanceEnabled = false;
private String etag;
private String boardsEtag;
@Ignore
public Account(Long id, @NonNull String name, @NonNull String userName, @NonNull String url) {
this(name, userName, url);
this.id = id;
}
@Ignore
public Account(@NonNull String name, @NonNull String userName, @NonNull String url) {
this.name = name;
this.userName = userName;
this.url = url;
}
@Ignore
public Account(Long id) {
this.id = id;
}
public Account() {
}
public void applyCapabilities(Capabilities capabilities, String eTag) {
if (capabilities == null) {
maintenanceEnabled = true;
return;
}
maintenanceEnabled = capabilities.isMaintenanceEnabled();
if (!isMaintenanceEnabled()) {
try {
// Nextcloud might return color format #000 which cannot be parsed by Color.parseColor()
// https://github.com/stefan-niedermann/nextcloud-deck/issues/466
color = capabilities.getColor();
textColor = capabilities.getTextColor();
} catch (Exception e) {
DeckLog.logError(e);
color = Capabilities.DEFAULT_COLOR;
textColor = Capabilities.DEFAULT_TEXT_COLOR;
}
if (capabilities.getDeckVersion() != null) {
serverDeckVersion = capabilities.getDeckVersion().getOriginalVersion();
}
if (eTag != null) {
this.etag = eTag;
}
}
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@NonNull
public String getName() {
return name;
}
public void setName(@NonNull String name) {
this.name = name;
}
@NonNull
public String getUserName() {
return userName;
}
public void setUserName(@NonNull String userName) {
this.userName = userName;
}
@NonNull
public String getUrl() {
return url;
}
public void setUrl(@NonNull String url) {
this.url = url;
}
public static long getSerialVersionUID() {
return serialVersionUID;
}
@ColorInt
@NonNull
public Integer getColor() {
return color;
}
public void setColor(@NonNull Integer color) {
this.color = color;
}
@NonNull
public Integer getTextColor() {
return textColor;
}
@Deprecated
public void setTextColor(@NonNull Integer textColor) {
this.textColor = textColor;
}
public Version getServerDeckVersionAsObject() {
return Version.of(serverDeckVersion);
}
@NonNull
public String getServerDeckVersion() {
return serverDeckVersion;
}
public void setServerDeckVersion(@NonNull String serverDeckVersion) {
this.serverDeckVersion = serverDeckVersion;
}
public boolean isMaintenanceEnabled() {
return maintenanceEnabled;
}
public void setMaintenanceEnabled(boolean maintenanceEnabled) {
this.maintenanceEnabled = maintenanceEnabled;
}
@Nullable
public String getUserDisplayName() {
return userDisplayName;
}
public void setUserDisplayName(@Nullable String userDisplayName) {
this.userDisplayName = userDisplayName;
}
public String getEtag() {
return etag;
}
public void setEtag(String etag) {
this.etag = etag;
}
public String getBoardsEtag() {
return boardsEtag;
}
public void setBoardsEtag(String boardsEtag) {
this.boardsEtag = boardsEtag;
}
/**
* @return The {@link #getAvatarUrl(int, String)} of this {@link Account}
*/
public SingleSignOnUrl getAvatarUrl(@Px int size) {
return getAvatarUrl(size, getUserName());
}
/**
* @return a {@link SingleSignOnUrl} to fetch the avatar of the given <code>userName</code> from the instance of this {@link Account} via {@link Glide}.
*/
public SingleSignOnUrl getAvatarUrl(@Px int size, @NonNull String userName) {
return new SingleSignOnUrl(getName(), getUrl() + "/index.php/avatar/" + Uri.encode(userName) + "/" + size);
}
@NonNull
public Optional<SingleSignOnAccount> getSingleSignOnAccount(@NonNull Context context) {
try {
return Optional.of(AccountImporter.getSingleSignOnAccount(context, getName()));
} catch (NextcloudFilesAppAccountNotFoundException e) {
return Optional.empty();
}
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Account account = (Account) o;
return maintenanceEnabled == account.maintenanceEnabled &&
Objects.equals(id, account.id) &&
name.equals(account.name) &&
userName.equals(account.userName) &&
Objects.equals(userDisplayName, account.userDisplayName) &&
url.equals(account.url) &&
color.equals(account.color) &&
textColor.equals(account.textColor) &&
serverDeckVersion.equals(account.serverDeckVersion);
}
@Override
public int hashCode() {
return Objects.hash(id, name, userName, userDisplayName, url, color, textColor, serverDeckVersion, maintenanceEnabled, etag, boardsEtag);
}
@NonNull
@Override
public String toString() {
return "Account{" +
"id=" + id +
", name='" + name + '\'' +
", userName='" + userName + '\'' +
", url='" + url + '\'' +
", color='" + color + '\'' +
", textColor='" + textColor + '\'' +
", serverDeckVersion='" + serverDeckVersion + '\'' +
", maintenanceEnabled=" + maintenanceEnabled +
", eTag='" + etag + '\'' +
'}';
}
}

View file

@ -0,0 +1,247 @@
package it.niedermann.nextcloud.deck.model;
import androidx.annotation.Nullable;
import androidx.room.Entity;
import androidx.room.ForeignKey;
import androidx.room.Index;
import java.io.Serializable;
import java.time.Instant;
import java.util.Objects;
import it.niedermann.nextcloud.deck.model.enums.EAttachmentType;
import it.niedermann.nextcloud.deck.model.interfaces.AbstractRemoteEntity;
@Entity(inheritSuperIndices = true,
indices = {@Index("cardId")},
foreignKeys = {
@ForeignKey(
entity = Card.class,
parentColumns = "localId",
childColumns = "cardId",
onDelete = ForeignKey.CASCADE
),
@ForeignKey(
entity = Account.class,
parentColumns = "id",
childColumns = "accountId", onDelete = ForeignKey.CASCADE
)
}
)
public class Attachment extends AbstractRemoteEntity implements Comparable<Attachment>, Serializable {
private long cardId;
// TODO use EAttachmentType
private EAttachmentType type = EAttachmentType.DECK_FILE;
private String data;
private Instant createdAt;
private String createdBy;
private Instant deletedAt;
private long filesize;
private String mimetype;
private String dirname;
private String basename;
private String extension;
private String filename;
private String localPath;
@Nullable
private Long fileId;
public long getCardId() {
return cardId;
}
public void setCardId(long cardId) {
this.cardId = cardId;
}
public EAttachmentType getType() {
return type;
}
public void setType(EAttachmentType type) {
this.type = type;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
public Instant getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Instant createdAt) {
this.createdAt = createdAt;
}
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public Instant getDeletedAt() {
return deletedAt;
}
public void setDeletedAt(Instant deletedAt) {
this.deletedAt = deletedAt;
}
public long getFilesize() {
return filesize;
}
public void setFilesize(long filesize) {
this.filesize = filesize;
}
public String getMimetype() {
return mimetype;
}
public void setMimetype(String mimetype) {
this.mimetype = mimetype;
}
public String getDirname() {
return dirname;
}
public void setDirname(String dirname) {
this.dirname = dirname;
}
public String getBasename() {
return basename;
}
public void setBasename(String basename) {
this.basename = basename;
}
public String getExtension() {
return extension;
}
public void setExtension(String extension) {
this.extension = extension;
}
public String getFilename() {
return filename;
}
public void setFilename(String filename) {
this.filename = filename;
}
public String getLocalPath() {
return localPath;
}
public void setLocalPath(String localPath) {
this.localPath = localPath;
}
@Nullable
public Long getFileId() {
return this.fileId;
}
public void setFileId(@Nullable Long fileId) {
this.fileId = fileId;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
Attachment that = (Attachment) o;
if (cardId != that.cardId) return false;
if (filesize != that.filesize) return false;
if (!Objects.equals(type, that.type)) return false;
if (!Objects.equals(data, that.data)) return false;
if (!Objects.equals(createdAt, that.createdAt))
return false;
if (!Objects.equals(createdBy, that.createdBy))
return false;
if (!Objects.equals(deletedAt, that.deletedAt))
return false;
if (!Objects.equals(mimetype, that.mimetype))
return false;
if (!Objects.equals(dirname, that.dirname)) return false;
if (!Objects.equals(basename, that.basename))
return false;
if (!Objects.equals(extension, that.extension))
return false;
if (!Objects.equals(filename, that.filename))
return false;
return Objects.equals(localPath, that.localPath);
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (int) (cardId ^ (cardId >>> 32));
result = 31 * result + (type != null ? type.hashCode() : 0);
result = 31 * result + (data != null ? data.hashCode() : 0);
result = 31 * result + (createdAt != null ? createdAt.hashCode() : 0);
result = 31 * result + (createdBy != null ? createdBy.hashCode() : 0);
result = 31 * result + (deletedAt != null ? deletedAt.hashCode() : 0);
result = 31 * result + (int) (filesize ^ (filesize >>> 32));
result = 31 * result + (mimetype != null ? mimetype.hashCode() : 0);
result = 31 * result + (dirname != null ? dirname.hashCode() : 0);
result = 31 * result + (basename != null ? basename.hashCode() : 0);
result = 31 * result + (extension != null ? extension.hashCode() : 0);
result = 31 * result + (filename != null ? filename.hashCode() : 0);
result = 31 * result + (localPath != null ? localPath.hashCode() : 0);
return result;
}
@Override
public int compareTo(Attachment other) {
// DESC order
long res = other.getModificationTimeForComparsion() - getModificationTimeForComparsion();
if (res == 0) {
return longToComparsionResult(other.getCreationTimeForComparsion() - getCreationTimeForComparsion());
}
return longToComparsionResult(res);
}
private static int longToComparsionResult(long diff) {
if (diff > 0) {
return 1;
} else if (diff < 0) {
return -1;
}
return 0;
}
public long getModificationTimeForComparsion() {
if (lastModifiedLocal != null) {
return lastModifiedLocal.toEpochMilli();
}
if (lastModified != null) {
return lastModified.toEpochMilli();
}
return Instant.now().toEpochMilli();
}
public long getCreationTimeForComparsion() {
if (createdAt != null) {
return createdAt.toEpochMilli();
}
return Instant.now().toEpochMilli();
}
}

View file

@ -0,0 +1,242 @@
package it.niedermann.nextcloud.deck.model;
import android.graphics.Color;
import androidx.annotation.ColorInt;
import androidx.room.Entity;
import androidx.room.ForeignKey;
import androidx.room.Ignore;
import androidx.room.Index;
import com.google.gson.annotations.JsonAdapter;
import java.io.Serializable;
import java.time.Instant;
import java.util.Objects;
import it.niedermann.android.util.ColorUtil;
import it.niedermann.nextcloud.deck.DeckLog;
import it.niedermann.nextcloud.deck.model.enums.DBStatus;
import it.niedermann.nextcloud.deck.model.interfaces.AbstractRemoteEntity;
import it.niedermann.nextcloud.deck.remote.api.json.JsonColorSerializer;
@Entity(
inheritSuperIndices = true,
indices = {@Index("ownerId")},
foreignKeys = {
@ForeignKey(
entity = User.class,
parentColumns = "localId",
childColumns = "ownerId", onDelete = ForeignKey.CASCADE
),
@ForeignKey(
entity = Account.class,
parentColumns = "id",
childColumns = "accountId", onDelete = ForeignKey.CASCADE
)
}
)
public class Board extends AbstractRemoteEntity implements Serializable {
public Board() {
}
@Ignore
public Board(String title, @ColorInt int color) {
setTitle(title);
setColor(color);
}
private String title;
private long ownerId;
@JsonAdapter(JsonColorSerializer.class)
private Integer color;
private boolean archived;
private int shared;
private Instant deletedAt;
private boolean permissionRead = false;
private boolean permissionEdit = false;
private boolean permissionManage = false;
private boolean permissionShare = false;
@Override
public Instant getLastModified() {
return lastModified;
}
@Override
public void setLastModified(Instant lastModified) {
this.lastModified = lastModified;
}
@Override
public Instant getLastModifiedLocal() {
return lastModifiedLocal;
}
@Override
public void setLastModifiedLocal(Instant lastModifiedLocal) {
this.lastModifiedLocal = lastModifiedLocal;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@ColorInt
public Integer getColor() {
return color;
}
public void setColor(String color) {
try {
setColor(Color.parseColor(ColorUtil.formatColorToParsableHexString(color)));
} catch (Exception e) {
DeckLog.logError(e);
setColor(Color.GRAY);
}
}
public void setColor(@ColorInt Integer color) {
this.color = color;
}
public boolean isArchived() {
return archived;
}
//
// public String getAcl() {
// return acl;
// }
//
// public void setAcl(String acl) {
// this.acl = acl;
// }
public int getShared() {
return shared;
}
public void setShared(int shared) {
this.shared = shared;
}
public Instant getDeletedAt() {
return deletedAt;
}
public void setDeletedAt(Instant deletedAt) {
this.deletedAt = deletedAt;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public DBStatus getStatusEnum() {
return DBStatus.findById(status);
}
public void setStatusEnum(DBStatus status) {
this.status = status.getId();
}
public void setStatus(int status) {
this.status = status;
}
public int getStatus() {
return this.status;
}
public long getOwnerId() {
return this.ownerId;
}
public void setOwnerId(long ownerId) {
this.ownerId = ownerId;
}
public void setArchived(boolean archived) {
this.archived = archived;
}
public boolean isPermissionRead() {
return permissionRead;
}
public void setPermissionRead(boolean permissionRead) {
this.permissionRead = permissionRead;
}
public boolean isPermissionEdit() {
return permissionEdit;
}
public void setPermissionEdit(boolean permissionEdit) {
this.permissionEdit = permissionEdit;
}
public boolean isPermissionManage() {
return permissionManage;
}
public void setPermissionManage(boolean permissionManage) {
this.permissionManage = permissionManage;
}
public boolean isPermissionShare() {
return permissionShare;
}
public void setPermissionShare(boolean permissionShare) {
this.permissionShare = permissionShare;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
Board board = (Board) o;
if (ownerId != board.ownerId) return false;
if (archived != board.archived) return false;
if (shared != board.shared) return false;
if (permissionRead != board.permissionRead) return false;
if (permissionEdit != board.permissionEdit) return false;
if (permissionManage != board.permissionManage) return false;
if (permissionShare != board.permissionShare) return false;
if (!Objects.equals(title, board.title)) return false;
if (!Objects.equals(color, board.color)) return false;
return Objects.equals(deletedAt, board.deletedAt);
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (title != null ? title.hashCode() : 0);
result = 31 * result + (int) (ownerId ^ (ownerId >>> 32));
result = 31 * result + (color != null ? color.hashCode() : 0);
result = 31 * result + (archived ? 1 : 0);
result = 31 * result + shared;
result = 31 * result + (deletedAt != null ? deletedAt.hashCode() : 0);
result = 31 * result + (permissionRead ? 1 : 0);
result = 31 * result + (permissionEdit ? 1 : 0);
result = 31 * result + (permissionManage ? 1 : 0);
result = 31 * result + (permissionShare ? 1 : 0);
return result;
}
}

View file

@ -0,0 +1,340 @@
package it.niedermann.nextcloud.deck.model;
import androidx.annotation.NonNull;
import androidx.room.Entity;
import androidx.room.ForeignKey;
import androidx.room.Ignore;
import androidx.room.Index;
import com.google.gson.annotations.SerializedName;
import java.time.Instant;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import it.niedermann.nextcloud.deck.model.enums.DBStatus;
import it.niedermann.nextcloud.deck.model.interfaces.AbstractRemoteEntity;
@Entity(inheritSuperIndices = true,
indices = {
@Index(value = "accountId", name = "card_accID"),
@Index("stackId")
},
foreignKeys = {
@ForeignKey(
entity = Stack.class,
parentColumns = "localId",
childColumns = "stackId", onDelete = ForeignKey.CASCADE
),
@ForeignKey(
entity = Account.class,
parentColumns = "id",
childColumns = "accountId", onDelete = ForeignKey.CASCADE
)
}
)
public class Card extends AbstractRemoteEntity {
private static Pattern PATTERN_MD_TASK = Pattern.compile("\\[([xX ])]");
public static class TaskStatus {
public int taskCount;
public int doneCount;
public TaskStatus(int taskCount, int doneCount) {
this.taskCount = taskCount;
this.doneCount = doneCount;
}
}
@Ignore
private TaskStatus taskStatus = null;
private String title;
private String description;
@NonNull
private Long stackId;
private String type;
private Instant createdAt;
private Instant deletedAt;
private Instant done;
private int attachmentCount;
private Long userId;
private int order;
private boolean archived;
@SerializedName("duedate")
private Instant dueDate;
private boolean notified;
private int overdue;
private int commentsUnread;
public Card() {
}
@Ignore
public Card(String title, String description, long stackId) {
this.title = title;
this.description = description;
this.stackId = stackId;
}
public Card(Card card) {
super(card);
this.title = card.getTitle();
this.description = card.getDescription();
this.stackId = card.getStackId();
this.type = card.getType();
this.createdAt = card.getCreatedAt();
this.deletedAt = card.getDeletedAt();
this.attachmentCount = card.getAttachmentCount();
this.userId = card.getUserId();
this.order = card.getOrder();
this.archived = card.isArchived();
this.dueDate = card.getDueDate();
this.done = card.getDone();
this.notified = card.isNotified();
this.overdue = card.getOverdue();
this.commentsUnread = card.getCommentsUnread();
}
@NonNull
public TaskStatus getTaskStatus() {
if (taskStatus == null) {
int count = 0, done = 0;
if (description != null) {
final Matcher matcher = PATTERN_MD_TASK.matcher(description);
while (matcher.find()) {
count++;
char c = matcher.group().charAt(1);
if (c == 'x' || c == 'X') {
done++;
}
}
}
taskStatus = new TaskStatus(count, done);
}
return taskStatus;
}
public boolean isNotified() {
return notified;
}
public void setNotified(boolean notified) {
this.notified = notified;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public DBStatus getStatusEnum() {
return DBStatus.findById(status);
}
public void setStatusEnum(DBStatus status) {
this.status = status.getId();
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
this.taskStatus = null;
}
public Long getStackId() {
return stackId;
}
public void setStackId(Long stackId) {
this.stackId = stackId;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Instant getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Instant createdAt) {
this.createdAt = createdAt;
}
public Instant getDeletedAt() {
return deletedAt;
}
public void setDeletedAt(Instant deletedAt) {
this.deletedAt = deletedAt;
}
public int getAttachmentCount() {
return attachmentCount;
}
public void setAttachmentCount(int attachmentCount) {
this.attachmentCount = attachmentCount;
}
public void setOrder(int order) {
this.order = order;
}
public boolean isArchived() {
return archived;
}
public void setArchived(boolean archived) {
this.archived = archived;
}
public Instant getDueDate() {
return dueDate;
}
public void setDueDate(Instant dateTime) {
this.dueDate = dateTime;
}
public int getOverdue() {
return overdue;
}
public void setOverdue(int overdue) {
this.overdue = overdue;
}
public int getCommentsUnread() {
return commentsUnread;
}
public void setCommentsUnread(int commentsUnread) {
this.commentsUnread = commentsUnread;
}
public void setStatus(int status) {
this.status = status;
}
public int getStatus() {
return this.status;
}
public Long getUserId() {
return this.userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public int getOrder() {
return this.order;
}
public Instant getDone() {
return done;
}
public void setDone(Instant done) {
this.done = done;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
Card card = (Card) o;
if (stackId != card.stackId) return false;
if (attachmentCount != card.attachmentCount) return false;
if (order != card.order) return false;
if (archived != card.archived) return false;
if (notified != card.notified) return false;
if (overdue != card.overdue) return false;
if (commentsUnread != card.commentsUnread) return false;
if (!Objects.equals(title, card.title)) return false;
if (!Objects.equals(description, card.description))
return false;
if (!Objects.equals(type, card.type)) return false;
if (!Objects.equals(createdAt, card.createdAt))
return false;
if (!Objects.equals(deletedAt, card.deletedAt))
return false;
if (!Objects.equals(done, card.done))
return false;
if (!Objects.equals(userId, card.userId)) return false;
return Objects.equals(dueDate, card.dueDate);
}
@Override
public int hashCode() {
int result = title != null ? title.hashCode() : 0;
result = 31 * result + (description != null ? description.hashCode() : 0);
result = 31 * result + (int) (stackId ^ (stackId >>> 32));
result = 31 * result + (type != null ? type.hashCode() : 0);
result = 31 * result + (createdAt != null ? createdAt.hashCode() : 0);
result = 31 * result + (deletedAt != null ? deletedAt.hashCode() : 0);
result = 31 * result + (done != null ? done.hashCode() : 0);
result = 31 * result + attachmentCount;
result = 31 * result + (userId != null ? userId.hashCode() : 0);
result = 31 * result + order;
result = 31 * result + (archived ? 1 : 0);
result = 31 * result + (dueDate != null ? dueDate.hashCode() : 0);
result = 31 * result + (notified ? 1 : 0);
result = 31 * result + overdue;
result = 31 * result + commentsUnread;
return result;
}
@Override
public String toString() {
return "Card{" +
"title='" + title + '\'' +
", description='" + description + '\'' +
", stackId=" + stackId +
", type='" + type + '\'' +
", createdAt=" + createdAt +
", deletedAt=" + deletedAt +
", done=" + done +
", attachmentCount=" + attachmentCount +
", userId=" + userId +
", order=" + order +
", archived=" + archived +
", dueDate=" + dueDate +
", notified=" + notified +
", overdue=" + overdue +
", commentsUnread=" + commentsUnread +
", localId=" + localId +
", accountId=" + accountId +
", id=" + id +
", status=" + status +
", lastModified=" + lastModified +
", lastModifiedLocal=" + lastModifiedLocal +
'}';
}
}

View file

@ -0,0 +1,60 @@
package it.niedermann.nextcloud.deck.model;
import androidx.annotation.NonNull;
import androidx.room.Entity;
import androidx.room.ForeignKey;
import androidx.room.Index;
import it.niedermann.nextcloud.deck.model.interfaces.AbstractJoinEntity;
@Entity(
primaryKeys = {"labelId", "boardId"},
indices = {@Index("boardId"), @Index("labelId")},
foreignKeys = {
@ForeignKey(entity = Board.class,
parentColumns = "localId",
childColumns = "boardId", onDelete = ForeignKey.CASCADE),
@ForeignKey(entity = Label.class,
parentColumns = "localId",
childColumns = "labelId", onDelete = ForeignKey.CASCADE)
})
public class JoinBoardWithLabel extends AbstractJoinEntity {
@NonNull
private Long boardId;
@NonNull
private Long labelId;
public Long getLabelId() {
return labelId;
}
public void setLabelId(Long labelId) {
this.labelId = labelId;
}
public Long getBoardId() {
return boardId;
}
public void setBoardId(Long boardId) {
this.boardId = boardId;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
JoinBoardWithLabel that = (JoinBoardWithLabel) o;
if (!boardId.equals(that.boardId)) return false;
return labelId.equals(that.labelId);
}
@Override
public int hashCode() {
int result = boardId.hashCode();
result = 31 * result + labelId.hashCode();
return result;
}
}

View file

@ -0,0 +1,59 @@
package it.niedermann.nextcloud.deck.model;
import androidx.annotation.NonNull;
import androidx.room.Entity;
import androidx.room.ForeignKey;
import androidx.room.Index;
import it.niedermann.nextcloud.deck.model.interfaces.AbstractJoinEntity;
@Entity(
primaryKeys = {"permissionId", "boardId"},
indices = {@Index("boardId"), @Index("permissionId")},
foreignKeys = {
@ForeignKey(entity = Board.class,
parentColumns = "localId",
childColumns = "boardId", onDelete = ForeignKey.CASCADE),
@ForeignKey(entity = Permission.class,
parentColumns = "id",
childColumns = "permissionId", onDelete = ForeignKey.CASCADE)
})
public class JoinBoardWithPermission extends AbstractJoinEntity {
@NonNull
private Long permissionId;
@NonNull
private Long boardId;
public Long getPermissionId() {
return permissionId;
}
public void setPermissionId(Long permissionId) {
this.permissionId = permissionId;
}
public Long getBoardId() {
return boardId;
}
public void setBoardId(Long boardId) {
this.boardId = boardId;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
JoinBoardWithPermission that = (JoinBoardWithPermission) o;
if (!permissionId.equals(that.permissionId)) return false;
return boardId.equals(that.boardId);
}
@Override
public int hashCode() {
int result = permissionId.hashCode();
result = 31 * result + boardId.hashCode();
return result;
}
}

View file

@ -0,0 +1,59 @@
package it.niedermann.nextcloud.deck.model;
import androidx.annotation.NonNull;
import androidx.room.Entity;
import androidx.room.ForeignKey;
import androidx.room.Index;
import it.niedermann.nextcloud.deck.model.interfaces.AbstractJoinEntity;
@Entity(
primaryKeys = {"userId", "boardId"},
indices = {@Index("boardId"), @Index("userId")},
foreignKeys = {
@ForeignKey(entity = Board.class,
parentColumns = "localId",
childColumns = "boardId", onDelete = ForeignKey.CASCADE),
@ForeignKey(entity = User.class,
parentColumns = "localId",
childColumns = "userId", onDelete = ForeignKey.CASCADE)
})
public class JoinBoardWithUser extends AbstractJoinEntity {
@NonNull
private Long userId;
@NonNull
private Long boardId;
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Long getBoardId() {
return boardId;
}
public void setBoardId(Long boardId) {
this.boardId = boardId;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
JoinBoardWithUser that = (JoinBoardWithUser) o;
if (!userId.equals(that.userId)) return false;
return boardId.equals(that.boardId);
}
@Override
public int hashCode() {
int result = userId.hashCode();
result = 31 * result + boardId.hashCode();
return result;
}
}

View file

@ -0,0 +1,63 @@
package it.niedermann.nextcloud.deck.model;
import androidx.room.Entity;
import androidx.room.ForeignKey;
import androidx.room.Index;
import androidx.annotation.NonNull;
import it.niedermann.nextcloud.deck.model.interfaces.AbstractJoinEntity;
@Entity(
primaryKeys = {"labelId", "cardId"},
indices = {@Index("cardId"), @Index("labelId")},
foreignKeys = {
@ForeignKey(entity = Label.class,
parentColumns = "localId",
childColumns = "labelId",
onDelete = ForeignKey.CASCADE
),
@ForeignKey(entity = Card.class,
parentColumns = "localId",
childColumns = "cardId",
onDelete = ForeignKey.CASCADE
)
})
public class JoinCardWithLabel extends AbstractJoinEntity {
@NonNull
private Long labelId;
@NonNull
private Long cardId;
public Long getLabelId() {
return labelId;
}
public void setLabelId(Long labelId) {
this.labelId = labelId;
}
public Long getCardId() {
return cardId;
}
public void setCardId(Long cardId) {
this.cardId = cardId;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
JoinCardWithLabel that = (JoinCardWithLabel) o;
if (!labelId.equals(that.labelId)) return false;
return cardId.equals(that.cardId);
}
@Override
public int hashCode() {
int result = labelId.hashCode();
result = 31 * result + cardId.hashCode();
return result;
}
}

View file

@ -0,0 +1,59 @@
package it.niedermann.nextcloud.deck.model;
import androidx.annotation.NonNull;
import androidx.room.Entity;
import androidx.room.ForeignKey;
import androidx.room.Index;
import it.niedermann.nextcloud.deck.model.interfaces.AbstractJoinEntity;
@Entity(
primaryKeys = {"userId", "cardId"},
indices = {@Index("cardId"), @Index("userId")},
foreignKeys = {
@ForeignKey(entity = User.class,
parentColumns = "localId",
childColumns = "userId", onDelete = ForeignKey.CASCADE),
@ForeignKey(entity = Card.class,
parentColumns = "localId",
childColumns = "cardId", onDelete = ForeignKey.CASCADE)
})
public class JoinCardWithUser extends AbstractJoinEntity {
@NonNull
private Long userId;
@NonNull
private Long cardId;
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Long getCardId() {
return cardId;
}
public void setCardId(Long cardId) {
this.cardId = cardId;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
JoinCardWithUser that = (JoinCardWithUser) o;
if (!userId.equals(that.userId)) return false;
return cardId.equals(that.cardId);
}
@Override
public int hashCode() {
int result = userId.hashCode();
result = 31 * result + cardId.hashCode();
return result;
}
}

View file

@ -0,0 +1,128 @@
package it.niedermann.nextcloud.deck.model;
import android.graphics.Color;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.ForeignKey;
import androidx.room.Index;
import com.google.gson.annotations.JsonAdapter;
import java.io.Serializable;
import java.util.Objects;
import it.niedermann.android.util.ColorUtil;
import it.niedermann.nextcloud.deck.DeckLog;
import it.niedermann.nextcloud.deck.model.interfaces.AbstractRemoteEntity;
import it.niedermann.nextcloud.deck.remote.api.json.JsonColorSerializer;
@Entity(inheritSuperIndices = true,
indices = {@Index("boardId"), @Index(value = {"boardId", "title"}, unique = true, name = "idx_label_title_unique")},
foreignKeys = {
@ForeignKey(
entity = Board.class,
parentColumns = "localId",
childColumns = "boardId",
onDelete = ForeignKey.CASCADE
),
@ForeignKey(
entity = Account.class,
parentColumns = "id",
childColumns = "accountId", onDelete = ForeignKey.CASCADE
)
}
)
public class Label extends AbstractRemoteEntity implements Serializable {
private String title;
@JsonAdapter(JsonColorSerializer.class)
@NonNull
@ColumnInfo(defaultValue = "0")
private Integer color;
private long boardId;
public Label() {
}
public Label(Label labelToCopy) {
super(labelToCopy);
this.title = labelToCopy.getTitle();
this.color = labelToCopy.getColor();
this.boardId = labelToCopy.getBoardId();
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
@NonNull
@ColorInt
public Integer getColor() {
return color;
}
public void setColor(@NonNull @ColorInt Integer color) {
this.color = color;
}
public void setColor(String color) {
try {
setColor(Color.parseColor(ColorUtil.formatColorToParsableHexString(color)));
} catch (Exception e) {
DeckLog.logError(e);
setColor(Color.GRAY);
}
}
public long getBoardId() {
return boardId;
}
public void setBoardId(long boardId) {
this.boardId = boardId;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
Label label = (Label) o;
if (boardId != label.boardId) return false;
if (!Objects.equals(title, label.title)) return false;
return color.equals(label.color);
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (title != null ? title.hashCode() : 0);
result = 31 * result + color.hashCode();
result = 31 * result + (int) (boardId ^ (boardId >>> 32));
return result;
}
@Override
public String toString() {
return "Label{" +
"title='" + title + '\'' +
", color='" + color + '\'' +
", boardId=" + boardId +
", localId=" + localId +
", accountId=" + accountId +
", id=" + id +
", status=" + status +
", lastModified=" + lastModified +
", lastModifiedLocal=" + lastModifiedLocal +
'}';
}
}

View file

@ -0,0 +1,44 @@
package it.niedermann.nextcloud.deck.model;
import androidx.room.Entity;
import androidx.room.PrimaryKey;
import it.niedermann.nextcloud.deck.model.enums.PermissionType;
@Entity(inheritSuperIndices = true)
public class Permission {
@PrimaryKey(autoGenerate = true)
private long id;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public PermissionType getType() {
return PermissionType.findById(id);
}
public void setType(PermissionType type) {
this.id = type.getId();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Permission that = (Permission) o;
return id == that.id;
}
@Override
public int hashCode() {
return (int) (id ^ (id >>> 32));
}
}

View file

@ -0,0 +1,123 @@
package it.niedermann.nextcloud.deck.model;
import androidx.room.Entity;
import androidx.room.ForeignKey;
import androidx.room.Ignore;
import androidx.room.Index;
import java.time.Instant;
import java.util.Objects;
import it.niedermann.nextcloud.deck.model.interfaces.AbstractRemoteEntity;
@Entity(
inheritSuperIndices = true,
indices = {@Index("boardId")},
foreignKeys = {
@ForeignKey(
entity = Board.class,
parentColumns = "localId",
childColumns = "boardId", onDelete = ForeignKey.CASCADE
),
@ForeignKey(
entity = Account.class,
parentColumns = "id",
childColumns = "accountId", onDelete = ForeignKey.CASCADE
)
}
)
public class Stack extends AbstractRemoteEntity {
public Stack() {
}
@Ignore
public Stack(String title, long boardId) {
this.title = title;
this.boardId = boardId;
}
private String title;
private long boardId;
private Instant deletedAt;
private int order;
//
// @ToMany
// @JoinEntity(entity = JoinStackWithCard.class, sourceProperty = "stackId", targetProperty = "cardId")
// private List<Card> cards;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public long getBoardId() {
return boardId;
}
public void setBoardId(long boardId) {
this.boardId = boardId;
}
public Instant getDeletedAt() {
return deletedAt;
}
public void setDeletedAt(Instant deletedAt) {
this.deletedAt = deletedAt;
}
public int getOrder() {
return order;
}
public void setOrder(int order) {
this.order = order;
}
public void setStatus(int status) {
this.status = status;
}
public int getStatus() {
return this.status;
}
public long getAccountId() {
return this.accountId;
}
public void setAccountId(long accountId) {
this.accountId = accountId;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Stack stack = (Stack) o;
if (boardId != stack.boardId) return false;
if (order != stack.order) return false;
if (!Objects.equals(title, stack.title)) return false;
return Objects.equals(deletedAt, stack.deletedAt);
}
@Override
public int hashCode() {
int result = title != null ? title.hashCode() : 0;
result = 31 * result + (int) (boardId ^ (boardId >>> 32));
result = 31 * result + (deletedAt != null ? deletedAt.hashCode() : 0);
result = 31 * result + order;
return result;
}
}

View file

@ -0,0 +1,122 @@
package it.niedermann.nextcloud.deck.model;
import androidx.room.Entity;
import androidx.room.ForeignKey;
import androidx.room.Ignore;
import androidx.room.Index;
import java.io.Serializable;
import it.niedermann.nextcloud.deck.model.interfaces.AbstractRemoteEntity;
@Entity(inheritSuperIndices = true,
indices = {
@Index(value = "uid", name = "user_uid")
},
foreignKeys = {
@ForeignKey(
entity = Account.class,
parentColumns = "id",
childColumns = "accountId", onDelete = ForeignKey.CASCADE
)
}
)
public class User extends AbstractRemoteEntity implements Serializable {
public static final long TYPE_USER = 0L;
public static final long TYPE_GROUP = 1L;
private String primaryKey;
private String uid;
private String displayname;
private long type;
public User() {
super();
}
@Ignore
public User(String primaryKey, String uid, String displayname) {
this.primaryKey = primaryKey;
this.uid = uid;
this.displayname = displayname;
}
public User(User user) {
super(user);
this.primaryKey = user.getPrimaryKey();
this.uid = user.getUid();
this.type = user.getType();
this.displayname = user.getDisplayname();
}
public String getPrimaryKey() {
return primaryKey;
}
public void setPrimaryKey(String primaryKey) {
this.primaryKey = primaryKey;
}
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public String getDisplayname() {
return displayname;
}
public void setDisplayname(String displayname) {
this.displayname = displayname;
}
public long getType() {
return type;
}
public void setType(long type) {
this.type = type;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
User user = (User) o;
return type == user.type && primaryKey.equals(user.primaryKey) &&
uid.equals(user.uid) && displayname.equals(user.displayname);
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + primaryKey.hashCode();
result = 31 * result + uid.hashCode();
result = 31 * result + displayname.hashCode();
result = 31 * result + Long.hashCode(type);
return result;
}
@Override
public String toString() {
return "User{" +
"primaryKey='" + primaryKey + '\'' +
", uid='" + uid + '\'' +
", displayname='" + displayname + '\'' +
", type=" + type +
", localId=" + localId +
", accountId=" + accountId +
", id=" + id +
", status=" + status +
", lastModified=" + lastModified +
", lastModifiedLocal=" + lastModifiedLocal +
", etag='" + etag + '\'' +
"} " + super.toString();
}
}

View file

@ -0,0 +1,68 @@
package it.niedermann.nextcloud.deck.model.appwidgets;
import androidx.room.Entity;
import androidx.room.ForeignKey;
import androidx.room.Index;
import androidx.room.PrimaryKey;
import it.niedermann.nextcloud.deck.model.Account;
import it.niedermann.nextcloud.deck.model.Stack;
@Entity(
indices = {
@Index("stackId"),
@Index("accountId")
},
foreignKeys = {
@ForeignKey(
entity = Account.class,
parentColumns = "id",
childColumns = "accountId", onDelete = ForeignKey.CASCADE
),
@ForeignKey(
entity = Stack.class,
parentColumns = "localId",
childColumns = "stackId", onDelete = ForeignKey.CASCADE
)
}
)
public class StackWidgetModel {
@PrimaryKey()
private Integer appWidgetId;
private Long accountId;
private Long stackId;
private boolean darkTheme;
public Integer getAppWidgetId() {
return appWidgetId;
}
public void setAppWidgetId(Integer appWidgetId) {
this.appWidgetId = appWidgetId;
}
public Long getAccountId() {
return accountId;
}
public void setAccountId(Long accountId) {
this.accountId = accountId;
}
public Long getStackId() {
return stackId;
}
public void setStackId(Long stackId) {
this.stackId = stackId;
}
public boolean getDarkTheme() {
return darkTheme;
}
public void setDarkTheme(boolean darkTheme) {
this.darkTheme = darkTheme;
}
}

View file

@ -0,0 +1,62 @@
package it.niedermann.nextcloud.deck.model.enums;
import it.niedermann.nextcloud.deck.DeckLog;
public enum ActivityType {
DECK (1, "deck-dark.svg"),
CHANGE (2, "change.svg"),
ADD (3, "add-color.svg"),
DELETE (4, "delete-color.svg"),
ARCHIVE (5, "archive.svg"),
HISTORY (6, "actions/history.svg"),
FILES (7, "places/files.svg"),
COMMENT (8, "actions/comment.svg"),
TAGGED_WITH_LABEL (9, "actions/tag.svg")
;
int id;
String name;
ActivityType(int id, String name) {
this.id = id;
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public static ActivityType findById(int id) {
for (ActivityType s : ActivityType.values()) {
if (s.getId() == id) {
return s;
}
}
DeckLog.error("unknown ActivityType path:", id);
return CHANGE;
}
public static ActivityType findByPath(String path) {
if (path == null) {
throw new IllegalArgumentException("path is null");
}
for (ActivityType s : ActivityType.values()) {
if (path.trim().endsWith(s.getName())) {
return s;
}
}
DeckLog.error("unknown ActivityType path:", path);
return CHANGE;
}
}

View file

@ -0,0 +1,56 @@
package it.niedermann.nextcloud.deck.model.enums;
/**
* Helps to distinguish between different local change types for Server Synchronization.
* Created by stefan on 19.09.15.
*/
public enum DBStatus {
/**
* UP_TO_DATE means, that the Entity was not modified locally
*/
UP_TO_DATE(1),
/**
* LOCAL_EDITED means that a Entity was changed since the last successful synchronization.
* If it was newly created, then REMOTE_ID is 0
*/
LOCAL_EDITED(2),
/**
* LOCAL_DELETED means that the Entity was deleted locally, but this information was not yet synchronized.
* Therefore, the Entity has to be kept locally until the synchronization has succeeded.
* However, Entitys with this status should not be displayed in the UI.
*/
LOCAL_DELETED(3),
/**
* LOCAL_MOVED means that the Entity was moved locally, but this information was not yet synchronized.
* Therefore, the Entity has to be kept locally until the synchronization has succeeded.
*/
LOCAL_MOVED(4),
/**
* LOCAL_EDITED_SILENT means the same as LOCAL_EDITED, but doesn't need to be shown as changed in the UI
*/
LOCAL_EDITED_SILENT(5);
private final int id;
public int getId() {
return id;
}
DBStatus(int id) {
this.id = id;
}
public static DBStatus findById(int id) {
for (DBStatus s : DBStatus.values()) {
if (s.getId() == id) {
return s;
}
}
throw new IllegalArgumentException("unknown DBStatus key");
}
}

View file

@ -0,0 +1,33 @@
package it.niedermann.nextcloud.deck.model.enums;
public enum EAttachmentType {
// Do not change values. They match the Deck server apps values.
DECK_FILE(1, "deck_file"),
FILE(2, "file"),
UNKNOWN(1337, "unknown");
private final int id;
private final String value;
EAttachmentType(int id, String value) {
this.id = id;
this.value = value;
}
public int getId() {
return id;
}
public static EAttachmentType findByValue(String value) {
for (EAttachmentType s : EAttachmentType.values()) {
if (s.value.equals(value)) {
return s;
}
}
return UNKNOWN;
}
public String getValue() {
return value;
}
}

View file

@ -0,0 +1,40 @@
package it.niedermann.nextcloud.deck.model.enums;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.annotation.StringRes;
import it.niedermann.nextcloud.deck.R;
public enum EDoneType {
NO_FILTER(1, R.string.filter_done_no_filter),
DONE(2, R.string.filter_done_done),
UNDONE(3, R.string.filter_done_undone);
private final int value;
private final int id;
EDoneType(int id, @StringRes int value) {
this.value = value;
this.id = id;
}
public int getId() {
return id;
}
public static EDoneType findById(int id) {
for (EDoneType s : EDoneType.values()) {
if (s.getId() == id) {
return s;
}
}
throw new IllegalArgumentException("unknown " + EDoneType.class.getSimpleName() + " key: " + id);
}
@NonNull
public String toString(Context context) {
return context.getString(this.value);
}
}

Some files were not shown because too many files have changed in this diff Show more