From c9dd881eadf9f82a1acd6d8048e532004e209e64 Mon Sep 17 00:00:00 2001 From: Stefan Niedermann Date: Mon, 18 May 2020 07:51:01 +0200 Subject: [PATCH 01/14] version bump to 2.12.1 --- app/build.gradle | 4 ++-- .../owncloud/notes/persistence/AbstractNotesDatabase.java | 5 +---- fastlane/metadata/android/en-US/changelogs/2012001.txt | 1 + 3 files changed, 4 insertions(+), 6 deletions(-) create mode 100644 fastlane/metadata/android/en-US/changelogs/2012001.txt diff --git a/app/build.gradle b/app/build.gradle index 044dbefd..5b14e6cb 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -13,8 +13,8 @@ android { applicationId "it.niedermann.owncloud.notes" minSdkVersion 16 targetSdkVersion 29 - versionCode 2012000 - versionName "2.12.0" + versionCode 2012001 + versionName "2.12.1" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java index 3c45fdf9..8459cb78 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java @@ -166,10 +166,7 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper { key_username + " TEXT, " + key_account_name + " TEXT UNIQUE, " + key_etag + " TEXT, " + - key_modified + " INTEGER, " + - key_color + " VARCHAR(6) NOT NULL DEFAULT '000000', " + - key_text_color + " VARCHAR(6) NOT NULL DEFAULT '0082C9', " + - key_capabilities_etag + " TEXT)"); + key_modified + " INTEGER)"); createAccountIndexes(db); // Add accountId to notes table diff --git a/fastlane/metadata/android/en-US/changelogs/2012001.txt b/fastlane/metadata/android/en-US/changelogs/2012001.txt new file mode 100644 index 00000000..89f60dc7 --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/2012001.txt @@ -0,0 +1 @@ +- 🐞 Fix upgrading from version <= 1.0.1 to a current version From 56d6e53ebbb79dc84fcfb49282dca55fdad9b00b Mon Sep 17 00:00:00 2001 From: Nextcloud bot Date: Tue, 19 May 2020 03:30:52 +0000 Subject: [PATCH 02/14] [tx-robot] updated from transifex --- app/src/main/res/values-cs-rCZ/strings.xml | 4 ++++ app/src/main/res/values-de/strings.xml | 6 +++++- app/src/main/res/values-el/strings.xml | 4 ++++ app/src/main/res/values-es/strings.xml | 12 ++++++++---- app/src/main/res/values-eu/strings.xml | 4 ++++ app/src/main/res/values-fr/strings.xml | 4 ++++ app/src/main/res/values-gl/strings.xml | 4 ++++ app/src/main/res/values-he/strings.xml | 5 +++++ app/src/main/res/values-hr/strings.xml | 1 + app/src/main/res/values-it/strings.xml | 4 ++++ app/src/main/res/values-ja-rJP/strings.xml | 1 - app/src/main/res/values-nl/strings.xml | 4 ++++ app/src/main/res/values-pl/strings.xml | 4 ++++ app/src/main/res/values-pt-rBR/strings.xml | 4 ++++ app/src/main/res/values-ru/strings.xml | 4 ++++ app/src/main/res/values-sk-rSK/strings.xml | 4 ++++ app/src/main/res/values-sl/strings.xml | 2 ++ app/src/main/res/values-tr/strings.xml | 4 ++++ 18 files changed, 69 insertions(+), 6 deletions(-) diff --git a/app/src/main/res/values-cs-rCZ/strings.xml b/app/src/main/res/values-cs-rCZ/strings.xml index 6030289a..d3f01d24 100644 --- a/app/src/main/res/values-cs-rCZ/strings.xml +++ b/app/src/main/res/values-cs-rCZ/strings.xml @@ -145,7 +145,11 @@ Na vámi využívané instanci Nexcloud nezbývá žádné volné místo na úložišti. Aby bylo možné synchronizovat vaše místní změny do vámi využívaného cloudu, je třeba nejprve smazat nějaké soubory. Pokud problémy přetrvávají, neváhejte se na nás obrátit. Kontaktní údaje naleznete v sekci „O aplikaci“ v postranním panelu. Abychom vám mohli pomoci, potřebujeme následující technické údaje: + Ověřte, že na vámi využívaném serveru je nainstalovaná a zapnutá aplikace „Poznámky“. Vámi využívaný server odpověděl HTTP stavovým kódem 302, což ukazuje na to, že na serveru buď není nainstalovaná aplikace Poznámky, nebo je něco nesprávně nastavené. Toto může být způsobeno uživatelsky určenými přepsáními v souboru .htaccess nebo Nextcloud aplikacemi jako je OID klient. + Přidáno „%1$s“ + Sdílený text je prázdný + Připojit k poznámce diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 311eb4e9..1c595ab3 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -145,7 +145,11 @@ Ihre Nextcloud-Installation hat keinen freien Speicherplatz mehr. Bitte löschen Sie einige Dateien, um Ihre lokalen Änderungen mit Ihrer Cloud synchronisieren zu können. Bitte zögern Sie nicht, uns zu kontaktieren, wenn das Problem weiterhin besteht. Sie finden unsere Kontaktinformationen im Abschnitt \"Info\" in der Seitenleiste. Wir benötigen die folgenden technischen Informationen, um Ihnen helfen zu können: - Ihr Server hat mit einem HTTP 302-Statuscode geantwortet, was bedeutet, dass Sie die Notes-App nicht auf Ihrem Server installiert haben oder etwas falsch konfiguriert ist. Dies kann durch benutzerdefinierte Überschreibungen in einer .htaccess-Datei oder durch Nextcloud-Apps wie OID-Client verursacht werden. + Bitte stellen Sie sicher, dass die „Notes“-App auf Ihrem Server installiert und aktiviert ist. + Ihr Server antwortet mit HTTP Status-Code 302. Dies bedeutet, dass entweder die Notes App nicht auf Ihrem Server installiert ist, oder eine Fehlkonfiguration vorliegt. Die Ursache kann im Überschreiben von Variablen in der .htaccess-Datei liegen, oder an Nextcloud Apps wie OID Client. + „%1$s“ hinzugefügt + Der geteilte Text war ohne Inhalt + An Notiz anhängen diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index ff7d1e03..8206d88e 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -145,7 +145,11 @@ Δεν υπάρχει επαρκής χώρος αποθήκευσης στο Nextcloud. Διαγράψτε ορισμένα αρχεία για να συγχρονίσετε τις αλλαγές σας. Μην διστάσετε να επικοινωνήσετε μαζί μας εάν τα προβλήματα παραμένουν. Μπορείτε να βρείτε τα στοιχεία επικοινωνίας μας στην ενότητα σχετικά στην πλευρική στήλη. Χρειαζόμαστε τις ακόλουθες τεχνικές πληροφορίες για να σας βοηθήσουμε: + Παρακαλούμε βεβαιωθείτε ότι εγκαταστήσατε και ενεργοποιήσατε την εφαρμογή \"Notes\" στον διακομιστή σας. Ο διακομιστής απάντησε με κωδικό κατάστασης HTTP 302, που σημαίνει, πως δεν έχετε εγκατεστημένη την εφαρμογή Notes στον διακομιστή σας ή υπάρχει λάθος ρύθμιση. Αυτό μπορεί να προκλήθηκε από λάθος καταχώρηση στο αρχείο .htaccess-file ή σε εφαρμογές του Nextcloud όπως την OID Client. + Προστέθηκε \"%1$s\" + Το κοινόχρηστο κείμενο είναι κενό + Προσάρτηση στη σημείωση diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 9c03620d..3c55f9d5 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -55,7 +55,7 @@ Sin conexión de red ¿Ha instalado los archivos de la aplicación? No se puede conectar a la aplicación archivos. - lmacenamiento en el servidor está lleno. + Tu espacio en el servidor está lleno. Ha ocurrido un error desconocido. @@ -65,7 +65,7 @@ Desarrolladores Traductores Comunidad de Nextcloud en <a href=\"%1$s\">Transifex</a> - Probadores + Testers Código fuente Este proyecto está alojado en GitHub: <a href=\"%1$s\">%1$s</a> Problemas @@ -113,9 +113,9 @@ Películas Película Trabajo - La cuenta ha ha sido importada + La cuenta ha sido importada Aún no hay notas - rear una nota nueva + Pulsa el botón + para crear una nota nueva No se ha podido cargar la vista previa. Por favor, comprueba si hay un ítem de lista numerada de dos dígitos sin contenido. Más Mover @@ -145,7 +145,11 @@ Su instancia de Nextcloud no tiene espacio libre de almacenamiento. Por favor elimine algunos archivos para sincronizar sus cambios locales con su nube. Por favor, no dude en contactar con nosotros si el problema persiste. Puede encontrar nuestra información de contacto en la sección acerca de en la barra lateral. Necesitamos la siguiente información técnica para ayudarle: + Por favor, asegúrate de que has instalado y activado la app «Notas» en tu servidor. Tu servidor respondió con el código de estado HTTP 302, lo que implica que no está instalada la aplicación Deck en su servidor o que algo está mal configurado. Esto puede estar causado por anulaciones personalizadas en un archivo .htaccess o por aplicaciones de Nexcloud como OID Client. + Se ha añadido «%1$s» + El texto compartido estaba vacío + Añadir a la nota diff --git a/app/src/main/res/values-eu/strings.xml b/app/src/main/res/values-eu/strings.xml index b707e69a..ba7d89f6 100644 --- a/app/src/main/res/values-eu/strings.xml +++ b/app/src/main/res/values-eu/strings.xml @@ -145,7 +145,11 @@ Zure Nextcloud instantziak ez du biltegiratze leku libre gehiagorik. Ezabatu fitxategi batzuk, aldaketa lokalak hodeiarekin sinkroniza daitezen. Mesedez, arazoak jarraitzen baldin badu ez izan zalantzarik gurekin harremanetan jartzeko. Alboko barran aurki dezakezu gurekin kontaktatzeko informazioa. Zuri laguntzeko hurrengo informazio teknikoa behar dugu: + Mesedez egiaztatu \"Notak\" aplikazioa instalatu eta gaitu duzula zure zerbitzarian. Zure zerbitzariak HTTP 302 egoera kodearekin erantzun du, honek esan nahi du ez duzula Notak aplikazioa ez duzula zure zerbitzarian instalatu edo zerbait txarto konfiguratuta dagoela. Hau .htaccess fitxategi batean arau pertsonalizatuak daudelako edo OID Bezeroa izeneko aplikazioarengatik sortua izan daiteke. + \"%1$s\" gehituta + Partekatutako testua hutsik zegoen + Gehitu notara diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index fe5cd62a..e12c0c5d 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -145,7 +145,11 @@ Votre instance Nextcloud n\'a plus d\'espace disponible. Veuillez supprimer certains fichiers pour pouvoir synchroniser vos modifications locales dans votre cloud. N\'hésitez pas à nous contacter si les problèmes persistent. Vous trouverez nos coordonnées dans la section : À propos, de la barre latérale. Nous avons besoin des informations techniques suivantes pour pouvoir vous aider : + Veuillez vérifier que vous avez installé et activé l\'application \"Notes\" sur votre serveur. Votre serveur a répondu avec le code HTTP 302, ce qui implique que vous n\'avez pas installé l\'application Notes sur votre serveur or que quelque chose est mal configuré. Ça peut être dû par des modifications du fichier .htaccess or par une autre application Nextcloud comme OID Client. + \"%1$s\" ajouté + Le texte partagé est vide + Ajouter à la note diff --git a/app/src/main/res/values-gl/strings.xml b/app/src/main/res/values-gl/strings.xml index 072b1402..35d40362 100644 --- a/app/src/main/res/values-gl/strings.xml +++ b/app/src/main/res/values-gl/strings.xml @@ -145,7 +145,11 @@ A súa instancia Nextcloud non dispón de espazo de almacenamento libre. Elimine algúns ficheiros para sincronizar os seus cambios locais na súa nube. Non dubide en poñerse en contacto con nós se os problemas persisten. Pode atopar a nosa información de contacto na sección sobre na barra lateral. Necesitamos a seguinte información técnica para axudarlle: + Asegúrese de ter instalada e activada a aplicación «Notas» no seu servidor. O seu servidor respondeu cun código de estado HTTP 302, o que implica que non ten instalada a aplicación Notas no servidor ou que algo está mal configurado. Isto pode ser causado por substitucións personalizadas nun ficheiro .htaccess ou por aplicacións Nextcloud como Client OID. + Engadido «%1$s» + O texto compartido estaba baleiro + Anexo á nota diff --git a/app/src/main/res/values-he/strings.xml b/app/src/main/res/values-he/strings.xml index 5ac270de..995d5b0f 100644 --- a/app/src/main/res/values-he/strings.xml +++ b/app/src/main/res/values-he/strings.xml @@ -16,6 +16,8 @@ מודגש קישור נטוי + %1$s נמחק + %1$s שוחזר ביטול פתיחת ניווט סגירת ניווט @@ -130,6 +132,9 @@ לא ניתן להעתיק ללוח הגזירים שוד ושבר - מה עכשיו? 🙁 אנו זקוקים לפירוט הטכני הבא כדי לסייע לך: + הטקסט ששותף היה ריק + הוספה לסוף הפתק + פתיחה במצב עריכה diff --git a/app/src/main/res/values-hr/strings.xml b/app/src/main/res/values-hr/strings.xml index 379c194b..df30bb74 100644 --- a/app/src/main/res/values-hr/strings.xml +++ b/app/src/main/res/values-hr/strings.xml @@ -145,6 +145,7 @@ Nema slobodnog prostora za pohranu u vašoj instanci Nextclouda. Izbrišite dio datoteka kako biste sinkronizirali lokalne promjene u oblak. Obratite nam se bez odlaganja ako problemi i dalje postoje. Naše podatke za kontakt možete pronaći u odjeljku s informacijama na bočnoj traci. Potrebne su nam sljedeće tehničke informacije kako bismo vam pomogli: + Vaš je poslužitelj vratio šifru statusa HTTP 302, što znači da aplikacija Notes nije instalirana na poslužitelju ili postoji pogreška u konfiguraciji. To mogu uzrokovati prilagođena prepisivanja u datoteci .htaccess ili određene aplikacije u Nextcloudu, kao što je OID Client. Otvori u načinu uređivanja diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 41d73543..c12ee149 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -145,7 +145,11 @@ La tua istanza di Nextcloud non ha più spazio libero. Elimina alcuni file per sincronizzare le modifiche locali con il tuo cloud. Non esitare a contattarci se il problema persiste. Puoi trovare le nostre informazioni di contatto nella sezione Informazioni della barra laterale. Ci servono le seguenti informazioni tecniche per aiutarti: + Assicurati di aver installato e abilitato l\'applicazione \"Note\" sul tuo server. Il tuo server ha risposto con un codice di stato HTTP 302, che implica che non hai installato l\'applicazione Note sul tuo server o qualcosa non è configurato correttamente. Questo può essere causato da configurazioni personalizzate nel file .htaccess o da applicazioni di Nextcloud come OID Client. + Aggiunto \"%1$s\" + Il testo condiviso era vuoto + Aggiungi a nota diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml index 5073df8b..557b5b10 100644 --- a/app/src/main/res/values-ja-rJP/strings.xml +++ b/app/src/main/res/values-ja-rJP/strings.xml @@ -146,7 +146,6 @@ 問題が継続する場合はお問い合わせください。我々の連絡先はサイドバーのaboutセクションにかかれています。 サポートには下記技術情報が必要です: サーバがHTTPステータスコード 302を返しました。これはNotesアプリがインストールされていないか、構成が誤っていることを意味します。.htaccessファイルのカスタムオーバーライドやOIDクライアントのようなNextcloudアプリが原因の可能性があります。 - 編集モードで開く diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 81088255..1a0f2cc8 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -146,7 +146,11 @@ Je Nextcloud instantie heeft geen vrije ruimte meer. Verwijder alstublieft enkele bestanden om je lokale gegevens te kunnen synchroniseren. Schroom alstublieft niet om contact met ons op te nemen als het probleem blijft aanhouden. Onze contactgegevens zijn te vinden in de About sectie in de zijbalk. We hebben de volgende technische informatie nodig om je te kunnen helpen: + Zorg er alstublieft voor dat je de \"Notes\" app hebt geïnstalleerd en aangezet op jouw server. Je server heeft gereageerd met een HTTP 302-statuscode, wat inhoudt dat je de Deck-app niet op je server hebt geïnstalleerd of dat er iets verkeerd is geconfigureerd. Dit kan worden veroorzaakt door maatwerk aanpassingen in een .htaccess-bestand of door Nextcloud-apps zoals de OID Client. + \"%1$s\" toegevoegd + Gedeelde tekst was leeg + Achteraan toevoegen aan notitie diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 6fa5a2a8..f278d403 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -145,7 +145,11 @@ W Twojej instancji Nextcloud nie ma już wolnego miejsca. Usuń niektóre pliki, aby zsynchronizować lokalne zmiany w chmurze. Jeśli problem będzie się powtarzał, skontaktuj się z nami. Nasze informacje kontaktowe można znaleźć w sekcji \"Informacje\" na pasku bocznym. Potrzebujemy następujących informacji technicznych, aby Ci pomóc: + Upewnij się, że zainstalowałeś i włączyłeś aplikację \"Notes\" na swoim serwerze. Twój serwer odpowiedział kodem stanu HTTP 302, co oznacza, że nie masz zainstalowanej aplikacji Notes na serwerze lub coś jest źle skonfigurowane. Może to być spowodowane niestandardowymi przekierowaniami pliku .htaccess lub aplikacjami Nextcloud, takimi jak OID Client. + Dodano \"%1$s\" + Udostępniony tekst był pusty + Dołącz do notatki diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index d7573be5..02beb388 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -145,7 +145,11 @@ Sua instância do Nextcloud não possui mais espaço livre. Exclua alguns arquivos para sincronizar suas alterações locais com a nuvem. Não hesite em nos contactar se os problemas persistirem. Você pode encontrar informações de contato na seção \"sobre\" na barra lateral. Precisamos das seguintes informações técnicas para ajudá-lo: + Verifique se você instalou e ativou o aplicativo \"Notes\" no seu servidor. Seu servidor respondeu com um código de status HTTP 302, o que implica que você não instalou o aplicativo Notes no servidor ou que algo está configurado incorretamente. Isso pode ser causado por alterações no arquivo .htaccess ou por aplicativos como o Client OID. + \"%1$s\" adicionado + O texto compartilhado estava vazio + Anexar à nota diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 469a6795..d060902e 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -145,7 +145,11 @@ На вашем экземпляре Nextcloud нет свободного места. Удалите ненужные файлы для синхронизации изменений в облако. Не стесняйтесь сообщать разработчикам о повторяющихся ошибках. Контактная информация приведена в боковой панели в разделе «О программе». Требуется следующая техническая информация от вас: + Проверьте, установлено ли на сервере приложение Заметки. На запрос сервер вернул код состояния HTTP 302, что означает, что приложение Заметки либо не установлено, либо сервер настроен неверно. Такое поведение может являться следствием замены стандартного файла .htaccess администратором сервера или приложением Nextcloud, таким как OID Client. + Добавлена заметка «%1$s» + Публикуемый текст пустой + Добавить в заметку diff --git a/app/src/main/res/values-sk-rSK/strings.xml b/app/src/main/res/values-sk-rSK/strings.xml index eb0a3a9a..93953d9d 100644 --- a/app/src/main/res/values-sk-rSK/strings.xml +++ b/app/src/main/res/values-sk-rSK/strings.xml @@ -145,7 +145,11 @@ Vo vašej inštancii Nexcloudu nie je na úložisku voľné miesto. Aby bolo možné synchronizovať vaše miestne zmeny s vaším cloudom, je potrebné najprv zmazať niektoré súbory. Ak problémy pretrvávajú, neváhajte nás kontaktovať. Kontaktné informácie nájdete v časti \"O nás\" v bočnom paneli. Aby sme vám pomohli, potrebujeme následovné technické informácie: + Uistite sa, že ste na serveri nainštalovali a povolili aplikáciu Poznámky. Váš server odpovedal stavovým kódom HTTP 302, čo znamená, že na svojom serveri nemáte nainštalovanú aplikáciu Notes alebo je niečo nesprávne nastavené. Môže to byť spôsobené vlastnými zmenami v súbore .htaccess alebo aplikáciami Nextcloud, ako je OID Client. + Pridané \"%1$s\" + Zdieľaný text bol prázdny + Pripojiť k poznámke diff --git a/app/src/main/res/values-sl/strings.xml b/app/src/main/res/values-sl/strings.xml index 764391b0..41c08c33 100644 --- a/app/src/main/res/values-sl/strings.xml +++ b/app/src/main/res/values-sl/strings.xml @@ -129,6 +129,8 @@ Odkleni zabeležke Preizkusno Predmeta ni mogoče kopirati v odložišče + Poskusite vsiliti končanje programa in ga ponovno zagnati. Morda je težava v neustrezni povezavi z okoljem Nextcloud + Program Nextcloud je očitno starejše različice. Posodobite jo prek Trgovine Play ali s posodabljalnikom F-Droid. Zabeležka se odpre v urejevalnem načinu diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index f1b6313d..f4a8aa6e 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -145,7 +145,11 @@ Nextcloud kopyanızda boş depolama alanı kalmamış. Lütfen yerel değişikliklerinizi bulut ile eşitlemek için bazı dosyaları silerek yer açın. Sorun sürerse lütfen bize sormaktan çekinmeyin. İletişim bilgilerimizi yan çubuktaki hakkında bölümünde bulabilirsiniz. Size yardımcı olabilmemiz için şu teknik bilgilere gerek duyacağız: + Lütfen sunucunuzda \"Notlar\" uygulamasının kurulu ve etkinleştirilmiş olduğundan emin olun. Sunucunuz, üzerine Notlar uygulamasının kurulmadığı ya da bir şeyin yanlış yapılandırıldığı anlamına gelen HTTP 302 durum kodu ile yanıt verdi. Bu durum, bir .htaccess dosyasındaki özel kısıtlamalardan ya da OID İstemcisi gibi Nextcloud uygulamalarından kaynaklanabilir. + \"%1$s\" eklendi + Paylaşılan metin boş + Nota ekle From ed621c58af556d3560b745b819f3a4376a5ff52b Mon Sep 17 00:00:00 2001 From: Stefan Niedermann Date: Wed, 20 May 2020 08:37:07 +0200 Subject: [PATCH 03/14] Remove SSO Announcment --- SSO Announcment.md | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 SSO Announcment.md diff --git a/SSO Announcment.md b/SSO Announcment.md deleted file mode 100644 index e5590039..00000000 --- a/SSO Announcment.md +++ /dev/null @@ -1,20 +0,0 @@ -# SSO Announcment - -Beginning with version `v2.0.0`, Notes for android will depend on Nextcloud Single-Sign-On. - -## What do you need to do? - -It is recommended, to perform a full synchronisation with the old version of the Notes app, before you upgrade. - -You have likely installed an up-to-date version of the [Files app](https://play.google.com/store/apps/details?id=com.nextcloud.client). In this case, you will have nothing more to do. -In case you do not have it installed yet, you can get it for free from Play Store or F-Droid. - -When you upgrade the Notes app, you will be asked to select an account (which you previously configured at the files app). - -It is important that you **select** at the first run **the same account which you already were using** in the Notes app. This will make the first run smooth and make sure, that local edited, but not synced notes won't get lost. - -## Benefits for you - -- **:lock: Security benefits:** The notes app does no longer have to store a password itself. -- **:electric_plug: Reliability:** The complete network stack could be removed because all network activities are lead through the files app. This allows us to use e. g. the same stack for self signed certificates. -- **:bulb: Comfort:** You won't have to enter a server address, nor a username or a password. Just pick an existing account from the list. From 963b245f85640a58bafa0ef0c75755e1d6307bd5 Mon Sep 17 00:00:00 2001 From: Stefan Niedermann Date: Wed, 20 May 2020 09:09:16 +0200 Subject: [PATCH 04/14] Fix migration paths using hardcoded strings instead of variables (which might change) --- .../persistence/AbstractNotesDatabase.java | 140 ++++++++---------- 1 file changed, 64 insertions(+), 76 deletions(-) diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java index 8459cb78..f7c6a7bd 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java @@ -97,7 +97,7 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper { key_etag + " TEXT," + key_excerpt + " TEXT NOT NULL DEFAULT '', " + "FOREIGN KEY(" + key_account_id + ") REFERENCES " + table_accounts + "(" + key_id + "))"); - createNotesIndexes(db); + DatabaseIndexUtil.createIndex(db, table_notes, key_remote_id, key_account_id, key_status, key_favorite, key_category, key_modified); } private void createAccountTable(@NonNull SQLiteDatabase db) { @@ -112,66 +112,62 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper { key_color + " VARCHAR(6) NOT NULL DEFAULT '000000', " + key_text_color + " VARCHAR(6) NOT NULL DEFAULT '0082C9', " + key_capabilities_etag + " TEXT)"); - createAccountIndexes(db); + DatabaseIndexUtil.createIndex(db, table_accounts, key_url, key_username, key_account_name, key_etag, key_modified); } @SuppressWarnings("deprecation") @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { - if (oldVersion < 3) { + if (oldVersion < 4) { recreateDatabase(db); return; } - if (oldVersion < 4) { - db.delete(table_notes, null, null); - db.delete(table_accounts, null, null); - } if (oldVersion < 5) { - db.execSQL("ALTER TABLE " + table_notes + " ADD COLUMN " + key_remote_id + " INTEGER"); - db.execSQL("UPDATE " + table_notes + " SET " + key_remote_id + "=" + key_id + " WHERE (" + key_remote_id + " IS NULL OR " + key_remote_id + "=0) AND " + key_status + "!=?", new String[]{DBStatus.LOCAL_CREATED.getTitle()}); - db.execSQL("UPDATE " + table_notes + " SET " + key_remote_id + "=0, " + key_status + "=? WHERE " + key_status + "=?", new String[]{DBStatus.LOCAL_EDITED.getTitle(), DBStatus.LOCAL_CREATED.getTitle()}); + db.execSQL("ALTER TABLE NOTES ADD COLUMN REMOTEID INTEGER"); + db.execSQL("UPDATE NOTES SET REMOTEID=ID WHERE (REMOTEID IS NULL OR REMOTEID=0) AND STATUS!=?", new String[]{DBStatus.LOCAL_CREATED.getTitle()}); + db.execSQL("UPDATE NOTES SET REMOTEID=0, STATUS=? WHERE STATUS=?", new String[]{DBStatus.LOCAL_EDITED.getTitle(), DBStatus.LOCAL_CREATED.getTitle()}); } if (oldVersion < 6) { - db.execSQL("ALTER TABLE " + table_notes + " ADD COLUMN " + key_favorite + " INTEGER DEFAULT 0"); + db.execSQL("ALTER TABLE NOTES ADD COLUMN FAVORITE INTEGER DEFAULT 0"); } if (oldVersion < 7) { DatabaseIndexUtil.dropIndexes(db); - db.execSQL("ALTER TABLE " + table_notes + " ADD COLUMN " + key_category + " TEXT NOT NULL DEFAULT ''"); - db.execSQL("ALTER TABLE " + table_notes + " ADD COLUMN " + key_etag + " TEXT"); - DatabaseIndexUtil.createIndex(db, table_notes, key_remote_id, key_status, key_favorite, key_category, key_modified); + db.execSQL("ALTER TABLE NOTES ADD COLUMN CATEGORY TEXT NOT NULL DEFAULT ''"); + db.execSQL("ALTER TABLE NOTES ADD COLUMN ETAG TEXT"); + DatabaseIndexUtil.createIndex(db, "NOTES", "REMOTEID", "STATUS", "FAVORITE", "CATEGORY", "MODIFIED"); } if (oldVersion < 8) { final String table_temp = "NOTES_TEMP"; db.execSQL("CREATE TABLE " + table_temp + " ( " + - key_id + " INTEGER PRIMARY KEY AUTOINCREMENT, " + - key_remote_id + " INTEGER, " + - key_status + " VARCHAR(50), " + - key_title + " TEXT, " + - key_modified + " INTEGER DEFAULT 0, " + - key_content + " TEXT, " + - key_favorite + " INTEGER DEFAULT 0, " + - key_category + " TEXT NOT NULL DEFAULT '', " + - key_etag + " TEXT)"); - DatabaseIndexUtil.createIndex(db, table_temp, key_remote_id, key_status, key_favorite, key_category, key_modified); - db.execSQL(String.format("INSERT INTO %s(%s,%s,%s,%s,%s,%s,%s,%s,%s) ", table_temp, key_id, key_remote_id, key_status, key_title, key_modified, key_content, key_favorite, key_category, key_etag) - + String.format("SELECT %s,%s,%s,%s,strftime('%%s',%s),%s,%s,%s,%s FROM %s", key_id, key_remote_id, key_status, key_title, key_modified, key_content, key_favorite, key_category, key_etag, table_notes)); - db.execSQL(String.format("DROP TABLE %s", table_notes)); - db.execSQL(String.format("ALTER TABLE %s RENAME TO %s", table_temp, table_notes)); + "ID INTEGER PRIMARY KEY AUTOINCREMENT, " + + "REMOTEID INTEGER, " + + "STATUS VARCHAR(50), " + + "TITLE TEXT, " + + "MODIFIED INTEGER DEFAULT 0, " + + "CONTENT TEXT, " + + "FAVORITE INTEGER DEFAULT 0, " + + "CATEGORY TEXT NOT NULL DEFAULT '', " + + "ETAG TEXT)"); + DatabaseIndexUtil.createIndex(db, table_temp, "REMOTEID", "STATUS", "FAVORITE", "CATEGORY", "MODIFIED"); + db.execSQL(String.format("INSERT INTO %s(%s,%s,%s,%s,%s,%s,%s,%s,%s) ", table_temp, "ID", "REMOTEID", "STATUS", "TITLE", "MODIFIED", "CONTENT", "FAVORITE", "CATEGORY", "ETAG") + + String.format("SELECT %s,%s,%s,%s,strftime('%%s',%s),%s,%s,%s,%s FROM %s", "ID", "REMOTEID", "STATUS", "TITLE", "MODIFIED", "CONTENT", "FAVORITE", "CATEGORY", "ETAG", "NOTES")); + db.execSQL("DROP TABLE NOTES"); + db.execSQL(String.format("ALTER TABLE %s RENAME TO %s", table_temp, "NOTES")); } if (oldVersion < 9) { // Create accounts table - db.execSQL("CREATE TABLE " + table_accounts + " ( " + - key_id + " INTEGER PRIMARY KEY AUTOINCREMENT, " + - key_url + " TEXT, " + - key_username + " TEXT, " + - key_account_name + " TEXT UNIQUE, " + - key_etag + " TEXT, " + - key_modified + " INTEGER)"); - createAccountIndexes(db); + db.execSQL("CREATE TABLE ACCOUNTS ( " + + "ID INTEGER PRIMARY KEY AUTOINCREMENT, " + + "URL TEXT, " + + "USERNAME TEXT, " + + "ACCOUNT_NAME TEXT UNIQUE, " + + "ETAG TEXT, " + + "MODIFIED INTEGER)"); + DatabaseIndexUtil.createIndex(db, "ACCOUNTS", "URL", "USERNAME", "ACCOUNT_NAME", "ETAG", "MODIFIED"); // Add accountId to notes table - db.execSQL("ALTER TABLE " + table_notes + " ADD COLUMN " + key_account_id + " INTEGER NOT NULL DEFAULT 0"); - DatabaseIndexUtil.createIndex(db, table_notes, key_account_id); + db.execSQL("ALTER TABLE NOTES ADD COLUMN ACCOUNT_ID INTEGER NOT NULL DEFAULT 0"); + DatabaseIndexUtil.createIndex(db, "NOTES", "ACCOUNT_ID"); // Migrate existing account from SharedPreferences SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); @@ -183,36 +179,36 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper { String accountName = username + "@" + new URL(url).getHost(); ContentValues migratedAccountValues = new ContentValues(); - migratedAccountValues.put(key_url, url); - migratedAccountValues.put(key_username, username); - migratedAccountValues.put(key_account_name, accountName); - db.insert(table_accounts, null, migratedAccountValues); + migratedAccountValues.put("URL", url); + migratedAccountValues.put("USERNAME", username); + migratedAccountValues.put("ACCOUNT_NAME", accountName); + db.insert("ACCOUNTS", null, migratedAccountValues); // After successful insertion of migrated account, set accountId to 1 in each note ContentValues values = new ContentValues(); - values.put(key_account_id, 1); - db.update(table_notes, values, key_account_id + " = ?", new String[]{"NULL"}); + values.put("ACCOUNT_ID", 1); + db.update("NOTES", values, "ACCOUNT_ID = ?", new String[]{"NULL"}); // Add FOREIGN_KEY constraint final String table_temp = "NOTES_TEMP"; - db.execSQL(String.format("ALTER TABLE %s RENAME TO %s", table_notes, table_temp)); + db.execSQL(String.format("ALTER TABLE %s RENAME TO %s", "NOTES", table_temp)); - db.execSQL("CREATE TABLE " + table_notes + " ( " + - key_id + " INTEGER PRIMARY KEY AUTOINCREMENT, " + - key_remote_id + " INTEGER, " + - key_account_id + " INTEGER, " + - key_status + " VARCHAR(50), " + - key_title + " TEXT, " + - key_modified + " INTEGER DEFAULT 0, " + - key_content + " TEXT, " + - key_favorite + " INTEGER DEFAULT 0, " + - key_category + " TEXT NOT NULL DEFAULT '', " + - key_etag + " TEXT," + - "FOREIGN KEY(" + key_account_id + ") REFERENCES " + table_accounts + "(" + key_id + "))"); - DatabaseIndexUtil.createIndex(db, table_notes, key_remote_id, key_account_id, key_status, key_favorite, key_category, key_modified); + db.execSQL("CREATE TABLE NOTES ( " + + "ID INTEGER PRIMARY KEY AUTOINCREMENT, " + + "REMOTE_ID INTEGER, " + + "ACCOUNT_ID INTEGER, " + + "STATUS VARCHAR(50), " + + "TITLE TEXT, " + + "MODIFIED INTEGER DEFAULT 0, " + + "CONTENT TEXT, " + + "FAVORITE INTEGER DEFAULT 0, " + + "CATEGORY TEXT NOT NULL DEFAULT '', " + + "ETAG TEXT," + + "FOREIGN KEY(ACCOUNT_ID) REFERENCES ACCOUNTS(ID))"); + DatabaseIndexUtil.createIndex(db, "NOTES", "REMOTE_ID", "ACCOUNT_ID", "STATUS", "FAVORITE", "CATEGORY", "MODIFIED"); - db.execSQL(String.format("INSERT INTO %s(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s) ", table_notes, key_id, key_account_id, key_remote_id, key_status, key_title, key_modified, key_content, key_favorite, key_category, key_etag) - + String.format("SELECT %s,%s,%s,%s,%s,%s,%s,%s,%s,%s FROM %s", key_id, values.get(key_account_id), key_remote_id, key_status, key_title, key_modified, key_content, key_favorite, key_category, key_etag, table_temp)); + db.execSQL(String.format("INSERT INTO %s(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s) ", "NOTES", "ID", "ACCOUNT_ID", "REMOTE_ID", "STATUS", "TITLE", "MODIFIED", "CONTENT", "FAVORITE", "CATEGORY", "ETAG") + + String.format("SELECT %s,%s,%s,%s,%s,%s,%s,%s,%s,%s FROM %s", "ID", values.get("ACCOUNT_ID"), "REMOTE_ID", "STATUS", "TITLE", "MODIFIED", "CONTENT", "FAVORITE", "CATEGORY", "ETAG", table_temp)); db.execSQL(String.format("DROP TABLE %s;", table_temp)); AppWidgetManager awm = AppWidgetManager.getInstance(context); @@ -256,12 +252,12 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper { } } if (oldVersion < 10) { - db.execSQL("ALTER TABLE " + table_notes + " ADD COLUMN " + key_excerpt + " INTEGER NOT NULL DEFAULT ''"); - Cursor cursor = db.query(table_notes, new String[]{key_id, key_content}, null, null, null, null, null, null); + db.execSQL("ALTER TABLE NOTES ADD COLUMN EXCERPT INTEGER NOT NULL DEFAULT ''"); + Cursor cursor = db.query("NOTES", new String[]{"ID", "CONTENT"}, null, null, null, null, null, null); while (cursor.moveToNext()) { ContentValues values = new ContentValues(); - values.put(key_excerpt, NoteUtil.generateNoteExcerpt(cursor.getString(1))); - db.update(table_notes, values, key_id + " = ? ", new String[]{cursor.getString(0)}); + values.put("EXCERPT", NoteUtil.generateNoteExcerpt(cursor.getString(1))); + db.update("NOTES", values, "ID" + " = ? ", new String[]{cursor.getString(0)}); } cursor.close(); } @@ -279,13 +275,13 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper { editor.apply(); } if (oldVersion < 12) { - db.execSQL("ALTER TABLE " + table_accounts + " ADD COLUMN " + key_api_version + " TEXT"); - db.execSQL("ALTER TABLE " + table_accounts + " ADD COLUMN " + key_color + " VARCHAR(6) NOT NULL DEFAULT '000000'"); - db.execSQL("ALTER TABLE " + table_accounts + " ADD COLUMN " + key_text_color + " VARCHAR(6) NOT NULL DEFAULT '0082C9'"); + db.execSQL("ALTER TABLE ACCOUNTS ADD COLUMN API_VERSION TEXT"); + db.execSQL("ALTER TABLE ACCOUNTS ADD COLUMN COLOR VARCHAR(6) NOT NULL DEFAULT '000000'"); + db.execSQL("ALTER TABLE ACCOUNTS ADD COLUMN TEXT_COLOR VARCHAR(6) NOT NULL DEFAULT '0082C9'"); CapabilitiesWorker.update(context); } if (oldVersion < 13) { - db.execSQL("ALTER TABLE " + table_accounts + " ADD COLUMN " + key_capabilities_etag + " TEXT"); + db.execSQL("ALTER TABLE ACCOUNTS ADD COLUMN CAPABILITIES_ETAG TEXT"); WorkManager.getInstance(context.getApplicationContext()).cancelUniqueWork("it.niedermann.owncloud.notes.persistence.SyncWorker"); WorkManager.getInstance(context.getApplicationContext()).cancelUniqueWork("SyncWorker"); } @@ -303,13 +299,5 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper { onCreate(db); } - private static void createNotesIndexes(@NonNull SQLiteDatabase db) { - DatabaseIndexUtil.createIndex(db, table_notes, key_remote_id, key_account_id, key_status, key_favorite, key_category, key_modified); - } - - private static void createAccountIndexes(@NonNull SQLiteDatabase db) { - DatabaseIndexUtil.createIndex(db, table_accounts, key_url, key_username, key_account_name, key_etag, key_modified); - } - protected abstract void notifyNotesChanged(); } From d9cceb96c8b2179b2dae89447275d03be829cda9 Mon Sep 17 00:00:00 2001 From: Stefan Niedermann Date: Wed, 20 May 2020 09:31:49 +0200 Subject: [PATCH 05/14] Remove deprecated DBStatus --- .../niedermann/owncloud/notes/model/DBStatus.java | 6 ------ .../notes/persistence/AbstractNotesDatabase.java | 13 ++++++------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/DBStatus.java b/app/src/main/java/it/niedermann/owncloud/notes/model/DBStatus.java index 2ba6d8dc..f98b887e 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/model/DBStatus.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/model/DBStatus.java @@ -11,12 +11,6 @@ public enum DBStatus { */ VOID(""), - /** - * LOCAL_CREATED is not used anymore, since a newly created note has REMOTE_ID=0 - */ - @Deprecated - LOCAL_CREATED("LOCAL_CREATED"), - /** * LOCAL_EDITED means that a Note was created and/or changed since the last successful synchronization. * If it was newly created, then REMOTE_ID is 0 diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java index f7c6a7bd..4afcc70a 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java @@ -115,7 +115,6 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper { DatabaseIndexUtil.createIndex(db, table_accounts, key_url, key_username, key_account_name, key_etag, key_modified); } - @SuppressWarnings("deprecation") @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { if (oldVersion < 4) { @@ -124,8 +123,8 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper { } if (oldVersion < 5) { db.execSQL("ALTER TABLE NOTES ADD COLUMN REMOTEID INTEGER"); - db.execSQL("UPDATE NOTES SET REMOTEID=ID WHERE (REMOTEID IS NULL OR REMOTEID=0) AND STATUS!=?", new String[]{DBStatus.LOCAL_CREATED.getTitle()}); - db.execSQL("UPDATE NOTES SET REMOTEID=0, STATUS=? WHERE STATUS=?", new String[]{DBStatus.LOCAL_EDITED.getTitle(), DBStatus.LOCAL_CREATED.getTitle()}); + db.execSQL("UPDATE NOTES SET REMOTEID=ID WHERE (REMOTEID IS NULL OR REMOTEID=0) AND STATUS!=?", new String[]{"LOCAL_CREATED"}); + db.execSQL("UPDATE NOTES SET REMOTEID=0, STATUS=? WHERE STATUS=?", new String[]{DBStatus.LOCAL_EDITED.getTitle(), "LOCAL_CREATED"}); } if (oldVersion < 6) { db.execSQL("ALTER TABLE NOTES ADD COLUMN FAVORITE INTEGER DEFAULT 0"); @@ -195,7 +194,7 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper { db.execSQL("CREATE TABLE NOTES ( " + "ID INTEGER PRIMARY KEY AUTOINCREMENT, " + - "REMOTE_ID INTEGER, " + + "REMOTEID INTEGER, " + "ACCOUNT_ID INTEGER, " + "STATUS VARCHAR(50), " + "TITLE TEXT, " + @@ -205,10 +204,10 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper { "CATEGORY TEXT NOT NULL DEFAULT '', " + "ETAG TEXT," + "FOREIGN KEY(ACCOUNT_ID) REFERENCES ACCOUNTS(ID))"); - DatabaseIndexUtil.createIndex(db, "NOTES", "REMOTE_ID", "ACCOUNT_ID", "STATUS", "FAVORITE", "CATEGORY", "MODIFIED"); + DatabaseIndexUtil.createIndex(db, "NOTES", "REMOTEID", "ACCOUNT_ID", "STATUS", "FAVORITE", "CATEGORY", "MODIFIED"); - db.execSQL(String.format("INSERT INTO %s(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s) ", "NOTES", "ID", "ACCOUNT_ID", "REMOTE_ID", "STATUS", "TITLE", "MODIFIED", "CONTENT", "FAVORITE", "CATEGORY", "ETAG") - + String.format("SELECT %s,%s,%s,%s,%s,%s,%s,%s,%s,%s FROM %s", "ID", values.get("ACCOUNT_ID"), "REMOTE_ID", "STATUS", "TITLE", "MODIFIED", "CONTENT", "FAVORITE", "CATEGORY", "ETAG", table_temp)); + db.execSQL(String.format("INSERT INTO %s(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s) ", "NOTES", "ID", "ACCOUNT_ID", "REMOTEID", "STATUS", "TITLE", "MODIFIED", "CONTENT", "FAVORITE", "CATEGORY", "ETAG") + + String.format("SELECT %s,%s,%s,%s,%s,%s,%s,%s,%s,%s FROM %s", "ID", values.get("ACCOUNT_ID"), "REMOTEID", "STATUS", "TITLE", "MODIFIED", "CONTENT", "FAVORITE", "CATEGORY", "ETAG", table_temp)); db.execSQL(String.format("DROP TABLE %s;", table_temp)); AppWidgetManager awm = AppWidgetManager.getInstance(context); From 2c78acd984dfcdd3b9a6b46488fd207615ae01f8 Mon Sep 17 00:00:00 2001 From: Stefan Niedermann Date: Wed, 20 May 2020 16:19:18 +0200 Subject: [PATCH 06/14] Fix #754 Move single note widget preferences to database --- .../activity/SelectSingleNoteActivity.java | 39 +++++---- .../android/appwidget/SingleNoteWidget.java | 79 +++++++++--------- .../appwidget/SingleNoteWidgetFactory.java | 40 +++++----- .../notes/model/SingleNoteWidgetData.java | 51 ++++++++++++ .../persistence/AbstractNotesDatabase.java | 80 +++++++++++++++++-- .../notes/persistence/NotesDatabase.java | 41 ++++++++++ 6 files changed, 251 insertions(+), 79 deletions(-) create mode 100644 app/src/main/java/it/niedermann/owncloud/notes/model/SingleNoteWidgetData.java diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/SelectSingleNoteActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/android/activity/SelectSingleNoteActivity.java index e02fd67b..0ad1fa5a 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/SelectSingleNoteActivity.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/android/activity/SelectSingleNoteActivity.java @@ -3,20 +3,20 @@ package it.niedermann.owncloud.notes.android.activity; import android.app.Activity; import android.appwidget.AppWidgetManager; import android.content.Intent; -import android.content.SharedPreferences; +import android.database.SQLException; import android.os.Bundle; import android.view.Menu; import android.view.View; +import android.widget.Toast; import androidx.appcompat.widget.Toolbar; -import androidx.preference.PreferenceManager; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import it.niedermann.owncloud.notes.ExceptionHandler; import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.android.appwidget.SingleNoteWidget; import it.niedermann.owncloud.notes.model.DBNote; -import it.niedermann.owncloud.notes.model.Item; +import it.niedermann.owncloud.notes.model.SingleNoteWidgetData; import it.niedermann.owncloud.notes.util.Notes; public class SelectSingleNoteActivity extends NotesListViewActivity { @@ -43,29 +43,34 @@ public class SelectSingleNoteActivity extends NotesListViewActivity { @Override public void onNoteClick(int position, View v) { - Item item = adapter.getItem(position); - DBNote note = (DBNote) item; - long noteID = note.getId(); + final DBNote note = (DBNote) adapter.getItem(position); final Bundle extras = getIntent().getExtras(); if (extras == null) { finish(); + return; } - assert extras != null; int appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); - SharedPreferences.Editor sp = PreferenceManager.getDefaultSharedPreferences(this).edit(); - sp.putLong(SingleNoteWidget.WIDGET_KEY + appWidgetId, noteID); - sp.putLong(SingleNoteWidget.ACCOUNT_ID_KEY + appWidgetId, note.getAccountId()); - sp.putString(SingleNoteWidget.DARK_THEME_KEY + appWidgetId, Notes.getAppTheme(getApplicationContext()).name()); - sp.apply(); + try { + db.createOrUpdateSingleNoteWidgetData( + new SingleNoteWidgetData( + appWidgetId, + note.getAccountId(), + note.getId(), + Notes.getAppTheme(this).getModeId() + ) + ); + final Intent updateIntent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE, null, + getApplicationContext(), SingleNoteWidget.class) + .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); + setResult(RESULT_OK, updateIntent); + getApplicationContext().sendBroadcast(updateIntent); + } catch (SQLException e) { + Toast.makeText(this, e.getLocalizedMessage(), Toast.LENGTH_LONG).show(); + } - Intent updateIntent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE, null, - getApplicationContext(), SingleNoteWidget.class); - updateIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); - setResult(RESULT_OK, updateIntent); - getApplicationContext().sendBroadcast(updateIntent); finish(); } } diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/appwidget/SingleNoteWidget.java b/app/src/main/java/it/niedermann/owncloud/notes/android/appwidget/SingleNoteWidget.java index 632a7022..28408099 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/appwidget/SingleNoteWidget.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/android/appwidget/SingleNoteWidget.java @@ -8,58 +8,61 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.net.Uri; +import android.util.Log; import android.widget.RemoteViews; import androidx.preference.PreferenceManager; +import java.util.NoSuchElementException; + import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.android.DarkModeSetting; import it.niedermann.owncloud.notes.android.activity.EditNoteActivity; import it.niedermann.owncloud.notes.android.fragment.BaseNoteFragment; +import it.niedermann.owncloud.notes.model.SingleNoteWidgetData; +import it.niedermann.owncloud.notes.persistence.NotesDatabase; import it.niedermann.owncloud.notes.util.Notes; public class SingleNoteWidget extends AppWidgetProvider { - public static final String DARK_THEME_KEY = "SNW_darkTheme"; - public static final String WIDGET_KEY = "single_note_widget"; - public static final String ACCOUNT_ID_KEY = "SNW_accountId"; + private static final String TAG = SingleNoteWidget.class.getSimpleName(); static void updateAppWidget(Context context, AppWidgetManager awm, int[] appWidgetIds) { - SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); - Intent templateIntent = new Intent(context, EditNoteActivity.class); + final Intent templateIntent = new Intent(context, EditNoteActivity.class); + final NotesDatabase db = NotesDatabase.getInstance(context); for (int appWidgetId : appWidgetIds) { - // onUpdate has been triggered before the user finished configuring the widget - if ((sp.getLong(WIDGET_KEY + appWidgetId, -1)) == -1) { - return; + try { + final SingleNoteWidgetData data = db.getSingleNoteWidgetData(appWidgetId); + + templateIntent.putExtra(BaseNoteFragment.PARAM_ACCOUNT_ID, data.getAccountId()); + + final PendingIntent templatePendingIntent = PendingIntent.getActivity(context, appWidgetId, templateIntent, + PendingIntent.FLAG_UPDATE_CURRENT); + + Intent serviceIntent = new Intent(context, SingleNoteWidgetService.class); + serviceIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); + serviceIntent.setData(Uri.parse(serviceIntent.toUri(Intent.URI_INTENT_SCHEME))); + + RemoteViews views; + + if (Notes.isDarkThemeActive(context, DarkModeSetting.fromModeID(data.getThemeMode()))) { + views = new RemoteViews(context.getPackageName(), R.layout.widget_single_note_dark); + views.setPendingIntentTemplate(R.id.single_note_widget_lv_dark, templatePendingIntent); + views.setRemoteAdapter(R.id.single_note_widget_lv_dark, serviceIntent); + views.setEmptyView(R.id.single_note_widget_lv_dark, R.id.widget_single_note_placeholder_tv_dark); + awm.notifyAppWidgetViewDataChanged(appWidgetId, R.id.single_note_widget_lv_dark); + } else { + views = new RemoteViews(context.getPackageName(), R.layout.widget_single_note); + views.setPendingIntentTemplate(R.id.single_note_widget_lv, templatePendingIntent); + views.setRemoteAdapter(R.id.single_note_widget_lv, serviceIntent); + views.setEmptyView(R.id.single_note_widget_lv, R.id.widget_single_note_placeholder_tv); + awm.notifyAppWidgetViewDataChanged(appWidgetId, R.id.single_note_widget_lv); + } + awm.updateAppWidget(appWidgetId, views); + } catch (NoSuchElementException e) { + Log.i(TAG, "onUpdate has been triggered before the user finished configuring the widget"); } - - DarkModeSetting darkTheme = NoteWidgetHelper.getDarkThemeSetting(sp, DARK_THEME_KEY, appWidgetId); - templateIntent.putExtra(BaseNoteFragment.PARAM_ACCOUNT_ID, sp.getLong(ACCOUNT_ID_KEY + appWidgetId, -1)); - - PendingIntent templatePendingIntent = PendingIntent.getActivity(context, appWidgetId, templateIntent, - PendingIntent.FLAG_UPDATE_CURRENT); - - Intent serviceIntent = new Intent(context, SingleNoteWidgetService.class); - serviceIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); - serviceIntent.setData(Uri.parse(serviceIntent.toUri(Intent.URI_INTENT_SCHEME))); - - RemoteViews views; - - if (Notes.isDarkThemeActive(context, darkTheme)) { - views = new RemoteViews(context.getPackageName(), R.layout.widget_single_note_dark); - views.setPendingIntentTemplate(R.id.single_note_widget_lv_dark, templatePendingIntent); - views.setRemoteAdapter(R.id.single_note_widget_lv_dark, serviceIntent); - views.setEmptyView(R.id.single_note_widget_lv_dark, R.id.widget_single_note_placeholder_tv_dark); - awm.notifyAppWidgetViewDataChanged(appWidgetId, R.id.single_note_widget_lv_dark); - } else { - views = new RemoteViews(context.getPackageName(), R.layout.widget_single_note); - views.setPendingIntentTemplate(R.id.single_note_widget_lv, templatePendingIntent); - views.setRemoteAdapter(R.id.single_note_widget_lv, serviceIntent); - views.setEmptyView(R.id.single_note_widget_lv, R.id.widget_single_note_placeholder_tv); - awm.notifyAppWidgetViewDataChanged(appWidgetId, R.id.single_note_widget_lv); - } - awm.updateAppWidget(appWidgetId, views); } } @@ -83,10 +86,10 @@ public class SingleNoteWidget extends AppWidgetProvider { SharedPreferences.Editor editor = PreferenceManager .getDefaultSharedPreferences(context).edit(); + final NotesDatabase db = NotesDatabase.getInstance(context); + for (int appWidgetId : appWidgetIds) { - editor.remove(WIDGET_KEY + appWidgetId); - editor.remove(DARK_THEME_KEY + appWidgetId); - editor.remove(ACCOUNT_ID_KEY + appWidgetId); + db.removeSingleNoteWidget(appWidgetId); } editor.apply(); diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/appwidget/SingleNoteWidgetFactory.java b/app/src/main/java/it/niedermann/owncloud/notes/android/appwidget/SingleNoteWidgetFactory.java index 54b2f2e7..b7eee1cc 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/appwidget/SingleNoteWidgetFactory.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/android/appwidget/SingleNoteWidgetFactory.java @@ -3,25 +3,25 @@ package it.niedermann.owncloud.notes.android.appwidget; import android.appwidget.AppWidgetManager; import android.content.Context; import android.content.Intent; -import android.content.SharedPreferences; import android.os.Bundle; import android.util.Log; import android.widget.RemoteViews; import android.widget.RemoteViewsService; -import androidx.preference.PreferenceManager; - import com.yydcdut.markdown.MarkdownProcessor; import com.yydcdut.markdown.syntax.text.TextFactory; +import java.util.NoSuchElementException; + import it.niedermann.owncloud.notes.R; +import it.niedermann.owncloud.notes.android.DarkModeSetting; import it.niedermann.owncloud.notes.android.activity.EditNoteActivity; import it.niedermann.owncloud.notes.model.DBNote; +import it.niedermann.owncloud.notes.model.SingleNoteWidgetData; import it.niedermann.owncloud.notes.persistence.NotesDatabase; import it.niedermann.owncloud.notes.util.MarkDownUtil; import it.niedermann.owncloud.notes.util.Notes; -import static it.niedermann.owncloud.notes.android.appwidget.SingleNoteWidget.DARK_THEME_KEY; import static it.niedermann.owncloud.notes.util.MarkDownUtil.parseCompat; public class SingleNoteWidgetFactory implements RemoteViewsService.RemoteViewsFactory { @@ -32,8 +32,7 @@ public class SingleNoteWidgetFactory implements RemoteViewsService.RemoteViewsFa private NotesDatabase db; private DBNote note; - private final SharedPreferences sp; - private boolean darkModeActive; + private boolean darkModeActive = false; private static final String TAG = SingleNoteWidget.class.getSimpleName(); @@ -41,32 +40,37 @@ public class SingleNoteWidgetFactory implements RemoteViewsService.RemoteViewsFa this.context = context; appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); - sp = PreferenceManager.getDefaultSharedPreferences(this.context); - darkModeActive = Notes.isDarkThemeActive(context, NoteWidgetHelper.getDarkThemeSetting(sp, DARK_THEME_KEY, appWidgetId)); + db = NotesDatabase.getInstance(context); markdownProcessor = new MarkdownProcessor(this.context); markdownProcessor.factory(TextFactory.create()); - markdownProcessor.config(MarkDownUtil.getMarkDownConfiguration(this.context, darkModeActive).build()); + try { + SingleNoteWidgetData data = db.getSingleNoteWidgetData(appWidgetId); + darkModeActive = Notes.isDarkThemeActive(context, DarkModeSetting.fromModeID(data.getThemeMode())); + } catch (NoSuchElementException e) { + Log.w(TAG, "Widget with ID " + appWidgetId + " seems to be not configured yet."); + } finally { + markdownProcessor.config(MarkDownUtil.getMarkDownConfiguration(this.context, darkModeActive).build()); + } } @Override public void onCreate() { - db = NotesDatabase.getInstance(context); - } + } @Override public void onDataSetChanged() { - long noteID = sp.getLong(SingleNoteWidget.WIDGET_KEY + appWidgetId, -1); - - if (noteID >= 0) { - Log.v(TAG, "Fetch note for account " + SingleNoteWidget.ACCOUNT_ID_KEY + appWidgetId); - Log.v(TAG, "Fetch note for account " + sp.getLong(SingleNoteWidget.ACCOUNT_ID_KEY + appWidgetId, -1)); - Log.v(TAG, "Fetch note with id " + noteID); - note = db.getNote(sp.getLong(SingleNoteWidget.ACCOUNT_ID_KEY + appWidgetId, -1), noteID); + try { + final SingleNoteWidgetData data = db.getSingleNoteWidgetData(appWidgetId); + final long noteId = data.getNoteId(); + Log.v(TAG, "Fetch note with id " + noteId); + note = db.getNote(data.getAccountId(), noteId); if (note == null) { Log.e(TAG, "Error: note not found"); } + } catch (NoSuchElementException e) { + Log.w(TAG, "Widget with ID " + appWidgetId + " seems to be not configured yet."); } } diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/SingleNoteWidgetData.java b/app/src/main/java/it/niedermann/owncloud/notes/model/SingleNoteWidgetData.java new file mode 100644 index 00000000..8cb4bace --- /dev/null +++ b/app/src/main/java/it/niedermann/owncloud/notes/model/SingleNoteWidgetData.java @@ -0,0 +1,51 @@ +package it.niedermann.owncloud.notes.model; + +public class SingleNoteWidgetData { + private int appWidgetId; + private long accountId; + private long noteId; + private int themeMode; + + public SingleNoteWidgetData() { + + } + + public SingleNoteWidgetData(int appWidgetId, long accountId, long noteId, int themeMode) { + this.appWidgetId = appWidgetId; + this.accountId = accountId; + this.noteId = noteId; + this.themeMode = themeMode; + } + + public int getAppWidgetId() { + return appWidgetId; + } + + public void setAppWidgetId(int appWidgetId) { + this.appWidgetId = appWidgetId; + } + + public long getAccountId() { + return accountId; + } + + public void setAccountId(long accountId) { + this.accountId = accountId; + } + + public long getNoteId() { + return noteId; + } + + public void setNoteId(long noteId) { + this.noteId = noteId; + } + + public int getThemeMode() { + return themeMode; + } + + public void setThemeMode(int themeMode) { + this.themeMode = themeMode; + } +} diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java index 4afcc70a..add0b847 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java @@ -32,21 +32,22 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper { private static final String TAG = AbstractNotesDatabase.class.getSimpleName(); - private static final int database_version = 13; + private static final int database_version = 14; @NonNull private final Context context; protected static final String database_name = "OWNCLOUD_NOTES"; protected static final String table_notes = "NOTES"; protected static final String table_accounts = "ACCOUNTS"; + protected static final String table_widget_single_notes = "WIDGET_SINGLE_NOTES"; protected static final String key_id = "ID"; protected static final String key_url = "URL"; protected static final String key_account_name = "ACCOUNT_NAME"; protected static final String key_username = "USERNAME"; - protected static final String key_account_id = "ACCOUNT_ID"; + protected static final String key_note_id = "NOTE_ID"; protected static final String key_remote_id = "REMOTEID"; protected static final String key_status = "STATUS"; protected static final String key_title = "TITLE"; @@ -60,6 +61,7 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper { protected static final String key_color = "COLOR"; protected static final String key_text_color = "TEXT_COLOR"; protected static final String key_api_version = "API_VERSION"; + protected static final String key_theme_mode = "THEME_MODE"; protected AbstractNotesDatabase(@NonNull Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory) { super(context, name, factory, database_version); @@ -81,13 +83,14 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper { public void onCreate(SQLiteDatabase db) { createAccountTable(db); createNotesTable(db); + createWidgetSingleNoteTable(db); } private void createNotesTable(@NonNull SQLiteDatabase db) { db.execSQL("CREATE TABLE " + table_notes + " ( " + key_id + " INTEGER PRIMARY KEY AUTOINCREMENT, " + key_remote_id + " INTEGER, " + - key_account_id + " INTEGER, " + + key_account_id + " INTEGER, " + // TODO NOT NULL key_status + " VARCHAR(50), " + key_title + " TEXT, " + key_modified + " INTEGER DEFAULT 0, " + @@ -115,6 +118,16 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper { DatabaseIndexUtil.createIndex(db, table_accounts, key_url, key_username, key_account_name, key_etag, key_modified); } + private void createWidgetSingleNoteTable(@NonNull SQLiteDatabase db) { + db.execSQL("CREATE TABLE " + table_widget_single_notes + " ( " + + key_id + " INTEGER PRIMARY KEY, " + + key_account_id + " INTEGER, " + + key_note_id + " INTEGER, " + + key_theme_mode + " INTEGER NOT NULL, " + + "FOREIGN KEY(" + key_account_id + ") REFERENCES " + table_accounts + "(" + key_id + "), " + + "FOREIGN KEY(" + key_note_id + ") REFERENCES " + table_notes + "(" + key_id + "))"); + } + @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { if (oldVersion < 4) { @@ -224,8 +237,8 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper { } for (int appWidgetId : appWidgetIdsSNW) { - if (sharedPreferences.getLong(SingleNoteWidget.WIDGET_KEY + appWidgetId, -1) >= 0) { - editor.putLong(SingleNoteWidget.ACCOUNT_ID_KEY + appWidgetId, 1); + if (sharedPreferences.getLong("single_note_widget" + appWidgetId, -1) >= 0) { + editor.putLong("SNW_accountId" + appWidgetId, 1); } } @@ -266,7 +279,7 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper { Map prefs = sharedPreferences.getAll(); for (Map.Entry pref : prefs.entrySet()) { String key = pref.getKey(); - if ("darkTheme".equals(key) || key.startsWith(NoteListWidget.DARK_THEME_KEY) || key.startsWith(SingleNoteWidget.DARK_THEME_KEY)) { + if ("darkTheme".equals(key) || key.startsWith(NoteListWidget.DARK_THEME_KEY) || key.startsWith("SNW_darkTheme")) { Boolean darkTheme = (Boolean) pref.getValue(); editor.putString(pref.getKey(), darkTheme ? DarkModeSetting.DARK.name() : DarkModeSetting.LIGHT.name()); } @@ -284,6 +297,61 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper { WorkManager.getInstance(context.getApplicationContext()).cancelUniqueWork("it.niedermann.owncloud.notes.persistence.SyncWorker"); WorkManager.getInstance(context.getApplicationContext()).cancelUniqueWork("SyncWorker"); } + if (oldVersion < 14) { + // #754 Move single note widget preferences to database + db.execSQL("CREATE TABLE WIDGET_SINGLE_NOTES ( " + + "ID INTEGER PRIMARY KEY, " + + "ACCOUNT_ID INTEGER, " + + "NOTE_ID INTEGER, " + + "THEME_MODE INTEGER NOT NULL, " + + "FOREIGN KEY(ACCOUNT_ID) REFERENCES ACCOUNTS(ID), " + + "FOREIGN KEY(NOTE_ID) REFERENCES NOTES(ID))"); + + final String SP_WIDGET_KEY = "single_note_widget"; + final String SP_ACCOUNT_ID_KEY = "SNW_accountId"; + final String SP_DARK_THEME_KEY = "SNW_darkTheme"; + SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); + SharedPreferences.Editor editor = sharedPreferences.edit(); + Map prefs = sharedPreferences.getAll(); + for (Map.Entry pref : prefs.entrySet()) { + final String key = pref.getKey(); + Integer widgetId = null; + Long noteId = null; + Long accountId = null; + Integer themeMode = null; + if (key != null && key.startsWith(SP_WIDGET_KEY)) { + try { + widgetId = Integer.parseInt(key.substring(SP_WIDGET_KEY.length())); + noteId = (Long) pref.getValue(); + accountId = sharedPreferences.getLong(SP_ACCOUNT_ID_KEY + widgetId, -1); + + try { + themeMode = DarkModeSetting.valueOf(sharedPreferences.getString(SP_DARK_THEME_KEY + widgetId, DarkModeSetting.SYSTEM_DEFAULT.name())).getModeId(); + } catch (ClassCastException e) { + //DARK_THEME was a boolean in older versions of the app. We thereofre have to still support the old setting. + themeMode = sharedPreferences.getBoolean(SP_DARK_THEME_KEY + widgetId, false) ? DarkModeSetting.DARK.getModeId() : DarkModeSetting.LIGHT.getModeId(); + } + + ContentValues migratedWidgetValues = new ContentValues(); + migratedWidgetValues.put("ID", widgetId); + migratedWidgetValues.put("ACCOUNT_ID", accountId); + migratedWidgetValues.put("NOTE_ID", noteId); + migratedWidgetValues.put("THEME_MODE", themeMode); + db.insert("WIDGET_SINGLE_NOTES", null, migratedWidgetValues); + } catch (Throwable t) { + Log.e(TAG, "Could not migrate widget {widgetId: " + widgetId + ", accountId: " + accountId + ", noteId: " + noteId + ", themeMode: " + themeMode + "}"); + t.printStackTrace(); + } finally { + // Clean up old shared preferences + editor.remove(SP_WIDGET_KEY + widgetId); + editor.remove(SP_DARK_THEME_KEY + widgetId); + editor.remove(SP_ACCOUNT_ID_KEY + widgetId); + } + } + } + editor.apply(); + notifyNotesChanged(); + } } @Override diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesDatabase.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesDatabase.java index eb095056..bca7dc32 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesDatabase.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesDatabase.java @@ -8,6 +8,7 @@ import android.content.pm.ShortcutManager; import android.content.res.Resources; import android.database.Cursor; import android.database.DatabaseUtils; +import android.database.SQLException; import android.database.sqlite.SQLiteConstraintException; import android.database.sqlite.SQLiteDatabase; import android.graphics.Color; @@ -34,6 +35,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.NoSuchElementException; import java.util.Set; import it.niedermann.owncloud.notes.R; @@ -48,6 +50,7 @@ import it.niedermann.owncloud.notes.model.DBStatus; import it.niedermann.owncloud.notes.model.ISyncCallback; import it.niedermann.owncloud.notes.model.LocalAccount; import it.niedermann.owncloud.notes.model.NavigationAdapter; +import it.niedermann.owncloud.notes.model.SingleNoteWidgetData; import it.niedermann.owncloud.notes.util.NoteUtil; import static it.niedermann.owncloud.notes.android.activity.EditNoteActivity.ACTION_SHORTCUT; @@ -865,6 +868,44 @@ public class NotesDatabase extends AbstractNotesDatabase { } } + /** + * @param appWidgetId the id of the widget + * @return {@link SingleNoteWidgetData} + * @throws NoSuchElementException in case there is no {@link SingleNoteWidgetData} for the given appWidgetId + */ + @NonNull + public SingleNoteWidgetData getSingleNoteWidgetData(int appWidgetId) throws NoSuchElementException { + SingleNoteWidgetData data = new SingleNoteWidgetData(); + final SQLiteDatabase db = getReadableDatabase(); + final Cursor cursor = db.query(table_widget_single_notes, new String[]{key_account_id, key_note_id, key_theme_mode}, key_id + " = ?", new String[]{String.valueOf(appWidgetId)}, null, null, null, null); + if (cursor.moveToNext()) { + data.setAppWidgetId(appWidgetId); + data.setAccountId(cursor.getLong(0)); + data.setNoteId(cursor.getLong(1)); + data.setThemeMode(cursor.getInt(2)); + } else { + throw new NoSuchElementException(); + } + cursor.close(); + return data; + } + + public void removeSingleNoteWidget(int appWidgetId) { + final SQLiteDatabase db = getWritableDatabase(); + db.delete(table_widget_single_notes, key_id + " = ?", new String[]{String.valueOf(appWidgetId)}); + } + + public void createOrUpdateSingleNoteWidgetData(@NonNull SingleNoteWidgetData data) throws SQLException { + validateAccountId(data.getAccountId()); + final SQLiteDatabase db = getWritableDatabase(); + final ContentValues values = new ContentValues(); + values.put(key_id, data.getAppWidgetId()); + values.put(key_account_id, data.getAccountId()); + values.put(key_note_id, data.getNoteId()); + values.put(key_theme_mode, data.getThemeMode()); + db.replaceOrThrow(table_widget_single_notes, null, values); + } + private static void validateAccountId(long accountId) { if (accountId < 1) { throw new IllegalArgumentException("accountId must be greater than 0"); From 4000abd733989fa1bbd7e9e9fe197f7fc7da59e6 Mon Sep 17 00:00:00 2001 From: Stefan Niedermann Date: Wed, 20 May 2020 17:23:39 +0200 Subject: [PATCH 07/14] Fix #817 Note list widget should create a note in it's respective category --- .../owncloud/notes/android/activity/EditNoteActivity.java | 1 + .../owncloud/notes/android/appwidget/NoteListWidget.java | 7 +++++-- fastlane/metadata/android/en-US/changelogs/2013000.txt | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 fastlane/metadata/android/en-US/changelogs/2013000.txt diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/EditNoteActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/android/activity/EditNoteActivity.java index 2e651cdc..d9e9fb7d 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/EditNoteActivity.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/android/activity/EditNoteActivity.java @@ -42,6 +42,7 @@ public class EditNoteActivity extends LockedActivity implements BaseNoteFragment public static final String PARAM_ACCOUNT_ID = "accountId"; public static final String PARAM_CATEGORY = "category"; public static final String PARAM_CONTENT = "content"; + public static final String PARAM_FAVORITE = "favorite"; private ActivityEditBinding binding; diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/appwidget/NoteListWidget.java b/app/src/main/java/it/niedermann/owncloud/notes/android/appwidget/NoteListWidget.java index 86840f88..8ba41331 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/appwidget/NoteListWidget.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/android/appwidget/NoteListWidget.java @@ -17,8 +17,11 @@ import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.android.DarkModeSetting; import it.niedermann.owncloud.notes.android.activity.EditNoteActivity; import it.niedermann.owncloud.notes.android.activity.NotesListViewActivity; +import it.niedermann.owncloud.notes.model.Category; import it.niedermann.owncloud.notes.util.Notes; +import static it.niedermann.owncloud.notes.android.activity.EditNoteActivity.PARAM_CATEGORY; + public class NoteListWidget extends AppWidgetProvider { private static final String TAG = NoteListWidget.class.getSimpleName(); public static final String WIDGET_MODE_KEY = "NLW_mode"; @@ -66,11 +69,11 @@ public class NoteListWidget extends AppWidgetProvider { // Launch create note activity if user taps "+" icon on header PendingIntent newNoteI = PendingIntent.getActivity(context, 0, - (new Intent(context, EditNoteActivity.class)), + (new Intent(context, EditNoteActivity.class).putExtra(PARAM_CATEGORY, new Category(category, displayMode == NLW_DISPLAY_STARRED))), PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent templatePI = PendingIntent.getActivity(context, 0, - (new Intent(context, EditNoteActivity.class)), + (new Intent(context, EditNoteActivity.class).putExtra(PARAM_CATEGORY, new Category(category, displayMode == NLW_DISPLAY_STARRED))), PendingIntent.FLAG_UPDATE_CURRENT); if (Notes.isDarkThemeActive(context, darkTheme)) { diff --git a/fastlane/metadata/android/en-US/changelogs/2013000.txt b/fastlane/metadata/android/en-US/changelogs/2013000.txt new file mode 100644 index 00000000..47842366 --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/2013000.txt @@ -0,0 +1 @@ +- Note list widget should create a note in it's respective category (#817) \ No newline at end of file From b2d07fd520aee6c8d08913de5f353cdd52996b3a Mon Sep 17 00:00:00 2001 From: Stefan Niedermann Date: Sat, 23 May 2020 09:49:25 +0200 Subject: [PATCH 08/14] Migrate excerpt --- .../persistence/AbstractNotesDatabase.java | 61 ++++++++++++------- 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java index fe573b81..ede9711d 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java @@ -373,10 +373,29 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper { } if (oldVersion < 15) { // Rename a tmp_NOTES table. - String tmpTableNotes = String.format("tmp_%s", table_notes); - db.execSQL("ALTER TABLE " + table_notes + " RENAME TO " + tmpTableNotes); - createNotesTable(db); - createCategoryTable(db); + String tmpTableNotes = String.format("tmp_%s", "NOTES"); + db.execSQL("ALTER TABLE NOTES RENAME TO " + tmpTableNotes); + db.execSQL("CREATE TABLE " + table_notes + " ( " + + "ID INTEGER PRIMARY KEY AUTOINCREMENT, " + + "REMOTEID INTEGER, " + + "ACCOUNT_ID INTEGER, " + + "STATUS VARCHAR(50), " + + "TITLE TEXT, " + + "MODIFIED INTEGER DEFAULT 0, " + + "CONTENT TEXT, " + + "FAVORITE INTEGER DEFAULT 0, " + + "CATEGORY INTEGER, " + + "ETAG TEXT," + + "EXCERPT TEXT NOT NULL DEFAULT '', " + + "FOREIGN KEY(CATEGORY) REFERENCES CATEGORIES(CATEGORY_ID), " + + "FOREIGN KEY(ACCOUNT_ID) REFERENCES ACCOUNTS(ID))"); + DatabaseIndexUtil.createIndex(db, "NOTES", "REMOTEID", "ACCOUNT_ID", "STATUS", "FAVORITE", "CATEGORY", "MODIFIED"); + db.execSQL("CREATE TABLE CATEGORIES(" + + "CATEGORY_ID INTEGER PRIMARY KEY AUTOINCREMENT, " + + "CATEGORY_ACCOUNT_ID INTEGER, " + + "CATEGORY_TITLE TEXT, " + + " UNIQUE( CATEGORY_ACCOUNT_ID , CATEGORY_TITLE))"); + DatabaseIndexUtil.createIndex(db, "CATEGORIES", "CATEGORY_ID", "CATEGORY_ACCOUNT_ID", "CATEGORY_TITLE"); // A hashtable storing categoryTitle - categoryId Mapping // This is used to prevent too many searches in database Hashtable categoryTitleIdMap = new Hashtable<>(); @@ -385,33 +404,33 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper { while (tmpNotesCursor.moveToNext()) { String categoryTitle = tmpNotesCursor.getString(8); int accountId = tmpNotesCursor.getInt(2); - int categoryId = 0; + Integer categoryId; if (categoryTitleIdMap.containsKey(categoryTitle) && categoryTitleIdMap.get(categoryTitle) != null) { categoryId = categoryTitleIdMap.get(categoryTitle); } else { // The category does not exists in the database, create it. categoryId = id++; ContentValues values = new ContentValues(); - values.put(key_category_id, categoryId); - values.put(key_category_account_id, accountId); - values.put(key_category_title, categoryTitle); - db.insert(table_category, null, values); + values.put("CATEGORY_ID", categoryId); + values.put("CATEGORY_ACCOUNT_ID", accountId); + values.put("CATEGORY_TITLE", categoryTitle); + db.insert("CATEGORIES", null, values); categoryTitleIdMap.put(categoryTitle, categoryId); } // Move the data in tmp_NOTES to NOTES ContentValues values = new ContentValues(); - values.put(key_id, tmpNotesCursor.getInt(0)); - values.put(key_remote_id, tmpNotesCursor.getInt(1)); - values.put(key_account_id, tmpNotesCursor.getInt(2)); - values.put(key_status, tmpNotesCursor.getString(3)); - values.put(key_title, tmpNotesCursor.getString(4)); - values.put(key_modified, tmpNotesCursor.getLong(5)); - values.put(key_content, tmpNotesCursor.getString(6)); - values.put(key_favorite, tmpNotesCursor.getInt(7)); - values.put(key_category, categoryId); - values.put(key_etag, tmpNotesCursor.getString(9)); - values.put(key_etag, tmpNotesCursor.getString(10)); - db.insert(table_notes, null, values); + values.put("ID", tmpNotesCursor.getInt(0)); + values.put("REMOTEID", tmpNotesCursor.getInt(1)); + values.put("ACCOUNT_ID", tmpNotesCursor.getInt(2)); + values.put("STATUS", tmpNotesCursor.getString(3)); + values.put("TITLE", tmpNotesCursor.getString(4)); + values.put("MODIFIED", tmpNotesCursor.getLong(5)); + values.put("CONTENT", tmpNotesCursor.getString(6)); + values.put("FAVORITE", tmpNotesCursor.getInt(7)); + values.put("CATEGORY", categoryId); + values.put("ETAG", tmpNotesCursor.getString(9)); + values.put("EXCERPT", tmpNotesCursor.getString(10)); + db.insert("NOTES", null, values); } tmpNotesCursor.close(); db.execSQL("DROP TABLE IF EXISTS " + tmpTableNotes); From 012800e0282bb8dadd268873d1765792693b08d3 Mon Sep 17 00:00:00 2001 From: Stefan Niedermann Date: Sat, 23 May 2020 10:41:58 +0200 Subject: [PATCH 09/14] Add FOREIGN KEY constraint to CATEGORY_ACCOUNT_ID --- .../persistence/AbstractNotesDatabase.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java index ede9711d..ad7ceb74 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java @@ -128,9 +128,10 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper { private void createCategoryTable(@NonNull SQLiteDatabase db) { db.execSQL("CREATE TABLE " + table_category + "(" + key_category_id + " INTEGER PRIMARY KEY AUTOINCREMENT, " + - key_category_account_id + " INTEGER, " + - key_category_title + " TEXT, " + - " UNIQUE( " + key_category_account_id + " , " + key_category_title + "))"); + key_category_account_id + " INTEGER NOT NULL, " + + key_category_title + " TEXT NOT NULL, " + + " UNIQUE( " + key_category_account_id + " , " + key_category_title + "), " + + " FOREIGN KEY(" + key_id + ") REFERENCES " + table_category + "(" + key_category_account_id + "));"); DatabaseIndexUtil.createIndex(db, table_category, key_category_id, key_category_account_id, key_category_title); } @@ -146,7 +147,6 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper { } - @SuppressWarnings("deprecation") @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { if (oldVersion < 4) { @@ -220,7 +220,7 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper { values.put("ACCOUNT_ID", 1); db.update("NOTES", values, "ACCOUNT_ID = ?", new String[]{"NULL"}); -// Add FOREIGN_KEY constraint + // Add FOREIGN_KEY constraint final String table_temp = "NOTES_TEMP"; db.execSQL(String.format("ALTER TABLE %s RENAME TO %s", "NOTES", table_temp)); @@ -375,7 +375,7 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper { // Rename a tmp_NOTES table. String tmpTableNotes = String.format("tmp_%s", "NOTES"); db.execSQL("ALTER TABLE NOTES RENAME TO " + tmpTableNotes); - db.execSQL("CREATE TABLE " + table_notes + " ( " + + db.execSQL("CREATE TABLE NOTES ( " + "ID INTEGER PRIMARY KEY AUTOINCREMENT, " + "REMOTEID INTEGER, " + "ACCOUNT_ID INTEGER, " + @@ -392,9 +392,10 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper { DatabaseIndexUtil.createIndex(db, "NOTES", "REMOTEID", "ACCOUNT_ID", "STATUS", "FAVORITE", "CATEGORY", "MODIFIED"); db.execSQL("CREATE TABLE CATEGORIES(" + "CATEGORY_ID INTEGER PRIMARY KEY AUTOINCREMENT, " + - "CATEGORY_ACCOUNT_ID INTEGER, " + - "CATEGORY_TITLE TEXT, " + - " UNIQUE( CATEGORY_ACCOUNT_ID , CATEGORY_TITLE))"); + "CATEGORY_ACCOUNT_ID INTEGER NOT NULL, " + + "CATEGORY_TITLE TEXT NOT NULL, " + + "UNIQUE( CATEGORY_ACCOUNT_ID , CATEGORY_TITLE), " + + "FOREIGN KEY(CATEGORY_ACCOUNT_ID) REFERENCES ACCOUNTS(ID))"); DatabaseIndexUtil.createIndex(db, "CATEGORIES", "CATEGORY_ID", "CATEGORY_ACCOUNT_ID", "CATEGORY_TITLE"); // A hashtable storing categoryTitle - categoryId Mapping // This is used to prevent too many searches in database From 625ca9ca5f1252cb83772c1fe334b44de579ed14 Mon Sep 17 00:00:00 2001 From: Stefan Niedermann Date: Sat, 23 May 2020 11:29:16 +0200 Subject: [PATCH 10/14] Fix table creation --- .../owncloud/notes/persistence/AbstractNotesDatabase.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java index ad7ceb74..819b0d1d 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java @@ -121,7 +121,7 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper { key_color + " VARCHAR(6) NOT NULL DEFAULT '000000', " + key_text_color + " VARCHAR(6) NOT NULL DEFAULT '0082C9', " + key_capabilities_etag + " TEXT, " + - " FOREIGN KEY(" + key_id + ") REFERENCES " + table_category + "(" + key_category_account_id + "));"); + "FOREIGN KEY(" + key_id + ") REFERENCES " + table_category + "(" + key_category_account_id + "));"); DatabaseIndexUtil.createIndex(db, table_accounts, key_url, key_username, key_account_name, key_etag, key_modified); } @@ -130,8 +130,8 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper { key_category_id + " INTEGER PRIMARY KEY AUTOINCREMENT, " + key_category_account_id + " INTEGER NOT NULL, " + key_category_title + " TEXT NOT NULL, " + - " UNIQUE( " + key_category_account_id + " , " + key_category_title + "), " + - " FOREIGN KEY(" + key_id + ") REFERENCES " + table_category + "(" + key_category_account_id + "));"); + "UNIQUE( " + key_category_account_id + " , " + key_category_title + "), " + + "FOREIGN KEY(" + key_category_account_id + ") REFERENCES " + table_category + "(" + key_id + "));"); DatabaseIndexUtil.createIndex(db, table_category, key_category_id, key_category_account_id, key_category_title); } From e0e0033efae6879fff33458762a4977cbe488d09 Mon Sep 17 00:00:00 2001 From: Stefan Niedermann Date: Sat, 23 May 2020 11:30:45 +0200 Subject: [PATCH 11/14] Fix table creation --- .../owncloud/notes/persistence/AbstractNotesDatabase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java index 819b0d1d..19ea288b 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java @@ -131,7 +131,7 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper { key_category_account_id + " INTEGER NOT NULL, " + key_category_title + " TEXT NOT NULL, " + "UNIQUE( " + key_category_account_id + " , " + key_category_title + "), " + - "FOREIGN KEY(" + key_category_account_id + ") REFERENCES " + table_category + "(" + key_id + "));"); + "FOREIGN KEY(" + key_category_account_id + ") REFERENCES " + table_accounts + "(" + key_id + "));"); DatabaseIndexUtil.createIndex(db, table_category, key_category_id, key_category_account_id, key_category_title); } From 16aabd862902d3ff1b3fa21f1b56110d437895c9 Mon Sep 17 00:00:00 2001 From: Isc Date: Sat, 23 May 2020 17:32:27 +0800 Subject: [PATCH 12/14] Merge --- .../owncloud/notes/persistence/AbstractNotesDatabase.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java index ad7ceb74..13fd9421 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java @@ -131,7 +131,7 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper { key_category_account_id + " INTEGER NOT NULL, " + key_category_title + " TEXT NOT NULL, " + " UNIQUE( " + key_category_account_id + " , " + key_category_title + "), " + - " FOREIGN KEY(" + key_id + ") REFERENCES " + table_category + "(" + key_category_account_id + "));"); + " FOREIGN KEY(" + key_category_account_id + ") REFERENCES " + table_accounts + "(" + key_id + "));"); DatabaseIndexUtil.createIndex(db, table_category, key_category_id, key_category_account_id, key_category_title); } @@ -405,6 +405,7 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper { while (tmpNotesCursor.moveToNext()) { String categoryTitle = tmpNotesCursor.getString(8); int accountId = tmpNotesCursor.getInt(2); + Log.e("###", accountId + ""); Integer categoryId; if (categoryTitleIdMap.containsKey(categoryTitle) && categoryTitleIdMap.get(categoryTitle) != null) { categoryId = categoryTitleIdMap.get(categoryTitle); From 910f465fc8925e6f94da952e58c4d5ba8bb597c1 Mon Sep 17 00:00:00 2001 From: Isc Date: Sat, 23 May 2020 18:28:29 +0800 Subject: [PATCH 13/14] Bug fixed: incorrect accountID in category table --- .../it/niedermann/owncloud/notes/persistence/NotesDatabase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesDatabase.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesDatabase.java index 250c264d..b57ca8d0 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesDatabase.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesDatabase.java @@ -545,7 +545,7 @@ public class NotesDatabase extends AbstractNotesDatabase { values.put(key_modified, remoteNote.getModified().getTimeInMillis() / 1000); values.put(key_content, remoteNote.getContent()); values.put(key_favorite, remoteNote.isFavorite()); - values.put(key_category, getCategoryIdByTitle(id, remoteNote.getCategory())); + values.put(key_category, getCategoryIdByTitle(localAccount.getId(), remoteNote.getCategory())); values.put(key_etag, remoteNote.getEtag()); values.put(key_excerpt, NoteUtil.generateNoteExcerpt(remoteNote.getContent())); String whereClause; From 116ce2a49afa2266c018c0656a62a71c76d600a4 Mon Sep 17 00:00:00 2001 From: Isc Date: Sat, 23 May 2020 18:29:40 +0800 Subject: [PATCH 14/14] Remove useless foreign key --- .../owncloud/notes/persistence/AbstractNotesDatabase.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java index 3b1f169e..2320d9c1 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/AbstractNotesDatabase.java @@ -120,8 +120,7 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper { key_api_version + " TEXT, " + key_color + " VARCHAR(6) NOT NULL DEFAULT '000000', " + key_text_color + " VARCHAR(6) NOT NULL DEFAULT '0082C9', " + - key_capabilities_etag + " TEXT, " + - "FOREIGN KEY(" + key_id + ") REFERENCES " + table_category + "(" + key_category_account_id + "));"); + key_capabilities_etag + " TEXT);"); DatabaseIndexUtil.createIndex(db, table_accounts, key_url, key_username, key_account_name, key_etag, key_modified); }