From c71d18dc2a8afc4f784c8581c6d1bcbd41f08064 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Mon, 17 Feb 2014 10:54:57 +0100 Subject: [PATCH 01/16] Improved Dutch translation Translate new strings (except for currenties) Fix some typos Account should be translated as 'rekening' instead of 'dagboek' --- app/res/values-nl/strings.xml | 142 +++++++++++++++++----------------- 1 file changed, 71 insertions(+), 71 deletions(-) diff --git a/app/res/values-nl/strings.xml b/app/res/values-nl/strings.xml index be088a288..c8f6b76e2 100644 --- a/app/res/values-nl/strings.xml +++ b/app/res/values-nl/strings.xml @@ -18,13 +18,13 @@ GnuCash - Nieuw dagboek - Dagboek bewerken + Nieuw rekening + Rekening bewerken Info OFX exporteren - Nieuwe transactie in een dagboek - Geen dagboeken beschikbaar - Dagboeknaam + Nieuwe transactie in een rekening + Geen rekeningen beschikbaar + Rekeningnaam Annuleren Bewaren Geen transacties beschikbaar @@ -33,17 +33,17 @@ Nieuwe transactie Geen transacties beschikbaar Datum & Tijd - Dagboek + Rekening Debet Credit - Dagboeken + Rekeningen Transacties Verwijderen Verwijderen Annuleren - Het dagboek werd verwijderd + De rekening werd verwijderd Verwijderen bevestigen - Alle transacties in dit dagboek zullen ook verwijderd worden + Alle transacties in deze rekening zullen ook verwijderd worden Transactie bewerken Opmerking Verplaatsen @@ -64,24 +64,24 @@ Verplaatsen %1$d transactie(s) verplaatsen - Bestemmingsdagboek + Bestemmingsrekening SD kaart benaderen OFX data verzenden via… - Transacties kunnen niet verplaatst worden.\nHet munteenheid van het dagboeken is niet compatibel + Transacties kunnen niet verplaatst worden.\nDe munteenheden van de rekeningen zijn niet compatibel Algemeen Over Standaard munteenheid kiezen Standaard munteenheid - Standaard munteenheid voor nieuwe dagboeken + Standaard munteenheid voor nieuwe rekeningen Staat het bewaren van transacties in GnuCash for Android toe - Staat het aanmaken van dagboeken in GnuCash for Android toe + Staat het aanmaken van rekeningen in GnuCash for Android toe Uw GnuCash data GnuCash data lezen en bewerken Transacties bewaren - Dagboeken aanmaken - Dagboek tonen - Dagboeken aanmaken - Aan te maken dagboeken selecteren + Rekeningen aanmaken + Rekening tonen + Rekeningen aanmaken + Aan te maken rekeningen selecteren Afghani Algerian Dinar @@ -266,7 +266,7 @@ Eigen Vermogen Passiva - Geen dagboeken beschikbaar.\nU moet een dagboek aanmaken alvorens een widget toe te voegen + Geen rekeningen beschikbaar.\nU moet een rekening aanmaken alvorens een widget toe te voegen Versie License Apache License v2.0. Klik voor details @@ -276,7 +276,7 @@ Over GnuCash GnucashMobile is een mobiele uitgavebeheerstoepassing voor Android.\nHet laat onderweg een snelle en flexibele registratie van uitgaven toe, die als OFX gegevens geëxporteerd kunnen worden om in de GnuCash-toepassing op een desktop-computer te importeren. Over - Fout bij het schrijven van de OFX data naar bestand :\n + Fout bij het schrijven van de OFX data naar bestand:\n OFX data geëexporteerd naar:\n GnuCash OFX export GnuCash OFX Export van @@ -284,10 +284,10 @@ Transactie voorkeuren Account voorkeuren Standaard Transactietype - Het standaard transactietype, CREDIT or DEBIT + Het standaard transactietype, CREDIT or DEBET CREDIT - DEBIT + DEBET Weet u zeker dat u alle transacties wil verwijderen? Weet u zeker dat u deze transactie wil verwijderen? @@ -298,12 +298,12 @@ Het standaard emailaddress om geëxporteerde data heen te sturen. U kan dit emailadres nog wijzigen als u exporteerd. Draag Account over Alle transacties zullen worden overgedragen van het ene account naar de andere - Schake Double Entry in + Schakel dubbel boekhouden in Saldo Vul een accountnaam in Munteenheid - Parent account - Gebruik XML OFX header + Hoofdrekening + Gebruik XML OFX hoofding Schakel deze optie in als u naar een applicatie anders dan GnuCash wil exporteren Nieuw sinds de vorige versie @@ -318,45 +318,45 @@ Wijs af Vul een bedrag in om de transactie op te slaan. - Import GnuCash Accounts - Import Accounts - An error occurred while importing the GnuCash accounts - GnuCash accounts successfully imported - Import account structure exported from GnuCash desktop - Import GnuCash accounts - Delete all accounts in the database. All transactions will be deleted as - well. + GnuCash rekeningen importeren + Rekeningen importeren + Fout bij het importeren van de GnuCash rekeningen + GnuCash rekeningen met succes geïmporteerd + Rekeningstructuur uit desktop-GnuCash importeren + GnuCash rekeningen importeren + Alle rekeningen uit de database verwijderen. Alle transacties zullen ook + verwijderd worden. - Delete all accounts - Accounts - All accounts have been successfully deleted - Are you sure you want to delete all accounts and transactions? \nThis - operation cannot be undone! + Alle rekeningen verwijderen + Rekeningen + Alle rekeningen werden met succes verwijderd + Weet je zeker dat je alle rekeningen en transacties wil verwijderen? \nDeze + verrichting kan niet ongedaan gemaakt worden! - Account Type - All transactions in all accounts will be deleted! - Delete all transactions - All transactions successfully deleted! - Importing accounts - Tap again to confirm. ALL entries will be deleted!! - Transactions - Sub-Accounts - Search - Default Export Format - File format to use by default when exporting transactions - Export transactions… - Recurrence + Rekening Type + Alle transacties in alle rekeningen zullen verwijderd worden! + Alle transacties verwijderen + Alle transacties werden met succes verwijderd! + Rekeningen importeren + Tap opnieuw op te bevestigen. ALLE regels zullen verwijderd worden!! + Transacties + Subrekeningen + Zoeken + Standaard Export Formaat + Bestandsformaat om standaard te gebruiken bij het experteren van transacties + Transacties exporteren… + Herhaling Imbalance - Exporting transactions - No recurring transactions to display. - Successfully deleted recurring transaction - Placeholder account - Default Transfer Account - Account Color & Type + Transactions exporteren + Geen repetitieve transacties gevonden. + Repetitieve transactie met succes verwijderd + Aggregatie rekening + Standard tegenrekening + Rekening kleur & type - %d sub-account - %d sub-accounts + %d subrekening + %d subrekeningen CASH @@ -378,19 +378,19 @@ OFX - Select a Color - Delete sub-accounts + Kies een kleur + Subrekeningen verwijderen Recent - Favorites - All - Creates default GnuCash commonly-used account structure - Create default accounts - New accounts will be created in addition to the existing - account structure.\n\nIf you wish to replace currently existing accounts, delete them first before proceeding! + Favorieten + Alle + Creëert standaard GnuCash veelgebruikte rekeningstructuur + Standaard rekeningen creëren + Nieuwe rekeningen zullen toegevoegd worden aan de bestaande + rekeningstructuur.\n\nAls je de bestaande rekeningen wil vervangen, verwijder ze dan eerst voor verder te gaan! - Welcome to GnuCash Android! \nYou can either create - a hierarchy of commonly-used accounts, or import your own GnuCash account structure. \n\nBoth options are also - available in app Settings so you can decide later. + Welkom in GnuCash Android! \nJe kan een nieuwe structuur van + veel gebruikte rekeningen creëren, of je eigen GnuCash rekeningstructuur importeren. \n\nBeide opties zijn ook + beschikbaar in app Instellingen zodat je later kan beslissen. GEEN @@ -398,6 +398,6 @@ WEKELIJKSE MAANDELIJKS - Scheduled Transactions - Scheduled Transactions + Vaste journaalposten + Vaste journaalposten From 218e837e9239bec1dbfc485189da43e3ff0629e4 Mon Sep 17 00:00:00 2001 From: jesseshieh Date: Wed, 5 Mar 2014 11:54:33 -0800 Subject: [PATCH 02/16] In double-entry accounting, all transactions should have a double-entry. If the transaction is a credit, then the double-entry is a debit and vice versa. Also, the transaction amount is positive or negative depending on if the account the transaction is in is a debit account or a credit account. Example: If you create a salary transaction in the income account, that should be a credit which is a positive number. If the double-entry account is the checking account, that is a debit account so it's entry should also be a positive number. --- .../gnucash/android/db/AccountsDbAdapter.java | 2 +- .../android/db/TransactionsDbAdapter.java | 9 +++++++-- app/src/org/gnucash/android/model/Account.java | 17 +++++++++++++++-- .../org/gnucash/android/model/Transaction.java | 17 ++++++++++++++++- 4 files changed, 39 insertions(+), 6 deletions(-) diff --git a/app/src/org/gnucash/android/db/AccountsDbAdapter.java b/app/src/org/gnucash/android/db/AccountsDbAdapter.java index d99fd6631..0e83043d6 100644 --- a/app/src/org/gnucash/android/db/AccountsDbAdapter.java +++ b/app/src/org/gnucash/android/db/AccountsDbAdapter.java @@ -526,7 +526,7 @@ public Money getAccountBalance(long accountId){ balance = balance.add(subBalance); } } - return balance.add(mTransactionsAdapter.getTransactionsSum(accountId)); + return balance.add(getAccount(accountId).getBalance()); } /** diff --git a/app/src/org/gnucash/android/db/TransactionsDbAdapter.java b/app/src/org/gnucash/android/db/TransactionsDbAdapter.java index f2c530473..5bfc881c8 100644 --- a/app/src/org/gnucash/android/db/TransactionsDbAdapter.java +++ b/app/src/org/gnucash/android/db/TransactionsDbAdapter.java @@ -24,6 +24,7 @@ import org.gnucash.android.model.Account; import org.gnucash.android.model.Money; import org.gnucash.android.model.Transaction; +import org.gnucash.android.model.Transaction.TransactionType; import java.math.BigDecimal; import java.util.ArrayList; @@ -179,9 +180,13 @@ public List getAllTransactionsForAccount(String accountUID){ while (c.moveToNext()) { Transaction transaction = buildTransactionInstance(c); String doubleEntryAccountUID = transaction.getDoubleEntryAccountUID(); - //negate double entry transactions for the transfer account + // Negate double entry transactions for the transfer account if (doubleEntryAccountUID != null && doubleEntryAccountUID.equals(accountUID)){ - transaction.setAmount(transaction.getAmount().negate()); + if (transaction.getType() == TransactionType.DEBIT) { + transaction.setType(TransactionType.CREDIT); + } else { + transaction.setType(TransactionType.DEBIT); + } } transactionsList.add(transaction); } diff --git a/app/src/org/gnucash/android/model/Account.java b/app/src/org/gnucash/android/model/Account.java index f5c409aed..bb003df4e 100644 --- a/app/src/org/gnucash/android/model/Account.java +++ b/app/src/org/gnucash/android/model/Account.java @@ -369,10 +369,23 @@ public boolean hasUnexportedTransactions(){ * @return {@link Money} aggregate amount of all transactions in account. */ public Money getBalance(){ - //TODO: Consider double entry transactions Money balance = new Money(new BigDecimal(0), this.mCurrency); for (Transaction transaction : mTransactionsList) { - balance = balance.add(transaction.getAmount()); + boolean isDebitAccount = getAccountType().hasDebitNormalBalance(); + boolean isDebitTransaction = transaction.getType() == TransactionType.DEBIT; + if (isDebitAccount) { + if (isDebitTransaction) { + balance = balance.add(transaction.getAmount()); + } else { + balance = balance.subtract(transaction.getAmount()); + } + } else { + if (isDebitTransaction) { + balance = balance.subtract(transaction.getAmount()); + } else { + balance = balance.add(transaction.getAmount()); + } + } } return balance; } diff --git a/app/src/org/gnucash/android/model/Transaction.java b/app/src/org/gnucash/android/model/Transaction.java index 0456b75bf..98a30b425 100644 --- a/app/src/org/gnucash/android/model/Transaction.java +++ b/app/src/org/gnucash/android/model/Transaction.java @@ -366,7 +366,22 @@ public String getDoubleEntryAccountUID() { public void setDoubleEntryAccountUID(String doubleEntryAccountUID) { this.mDoubleEntryAccountUID = doubleEntryAccountUID; } - + + /** + * Returns type of this transaction + * @return Type of this transaction + */ + public TransactionType getType() { + return mType; + } + + /** + * Sets the type of this transaction + * @param Type of this transaction + */ + public void setType(TransactionType type) { + mType = type; + } /** * Returns UID of account to which this transaction belongs From 05d5d88f1e2b20877e6e6f20afe50b31cb203a9e Mon Sep 17 00:00:00 2001 From: Menelaos Maglis Date: Sat, 22 Feb 2014 22:55:12 +0100 Subject: [PATCH 03/16] Greek translation update --- app/res/values-el/strings.xml | 66 +++++++++++++++++------------------ 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/app/res/values-el/strings.xml b/app/res/values-el/strings.xml index 8c415781d..cf8f8295a 100644 --- a/app/res/values-el/strings.xml +++ b/app/res/values-el/strings.xml @@ -351,23 +351,23 @@ Διαγραφή όλων των κινήσεων Όλες οι κινήσεις διαγράφηκαν με επιτυχία! - Importing accounts - Tap again to confirm. ALL entries will be deleted!! - Transactions - Sub-Accounts - Search - Default Export Format - File format to use by default when exporting transactions - Export transactions… - Recurrence + Εισαγωγή λογαριασμών + Πατήστε ξανά για επιβεβαίωση. ΌΛΕΣ οι καταχωρήσεις θα διαγραφούν!! + Κινήσεις + Υπο-Λογαριασμοί + Αναζήτηση + Προεπιλεγμένη Μορφή Εξόδου + Μορφή αρχείου για προεπιλεγμένη χρήση κατά την εξαγωγή κινήσεων. + Εξαγωγή κινήσεων… + Επαναλαμβανόμενη Imbalance - Exporting transactions - No recurring transactions to display. - Successfully deleted recurring transaction - Placeholder account - Default Transfer Account - Account Color & Type + Εξαγωγή κινήσεων + Δεν υπάρχουν επαναλαμβανόμενες κινήσεις για εμφάνιση. + Επιτυχία διαγραφής επαναλαμβανόμενης κίνησης + Λογαριασμός κράτησης θέσης + Προεπιλεγμένος Λογαριασμός Μεταφοράς + Χρώμα Λογαριασμού & Τύπος %d υπο-λογαριασμός %d υπο-λογαριασμοί @@ -392,26 +392,26 @@ OFX - Select a Color - Delete sub-accounts - Recent - Favorites - All - Creates default GnuCash commonly-used account structure - Create default accounts - New accounts will be created in addition to the existing - account structure.\n\nIf you wish to replace currently existing accounts, delete them first before proceeding! + Επιλογή χρώματος + Διαγραφή υπο-λογαριασμών + Πρόσφατοι + Αγαπημένοι + Όλοι + Δημιουργία προεπιλεγμένης συχνά χρησιμοποιούμενης δομής λογαριασμών GnuCash + Δημιουργία προεπιλεγμένων λογαριασμών + Νέοι λογαριασμοί θα δημιουργηθούν επιπλέον της υπάρχουσας + δομής λογαριασμών.\n\nΕάν επιθυμείτε να αντικαταστήσετε υπάρχοντες λογαριασμούς, διαγράψτε τους πριν προχωρήσετε! - Scheduled Transactions - Welcome to GnuCash Android! \nYou can either create - a hierarchy of commonly-used accounts, or import your own GnuCash account structure. \n\nBoth options are also - available in app Settings so you can decide later. + Προγραμματισμένες Κινήσεις + GnuCash Android. Καλώς ήρθατε! \nΜπορείτε είτε να δημιουργήσετε + μια ιεραρχία συνηθισμένων λογαριασμών, ή να εισάγετε τη δική σας δομή λογαριασμών GnuCash. \n\nΚαι οι δύο επιλογές είναι επίσης + διαθέσιμες στις Επιλογές της εφαρμογής γι' αυτό μπορείτε να αποφασίσετε αργότερα. - NONE - DAILY - WEEKLY - MONTHLY + ΚΑΜΙΑ + ΗΜΕΡΗΣΙΑ + ΕΒΔΟΜΑΔΙΑΙΑ + ΜΗΝΙΑΙΑ - Scheduled Transactions + Προγραμματισμένες Κινήσεις From 054954c87c33238077f0d967f5c57ce37c7d96e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20Windm=C3=BCller?= Date: Thu, 13 Mar 2014 11:30:38 +0100 Subject: [PATCH 04/16] Improved German translation --- app/res/values-de/strings.xml | 83 +++++++++++++++++------------------ 1 file changed, 40 insertions(+), 43 deletions(-) diff --git a/app/res/values-de/strings.xml b/app/res/values-de/strings.xml index d73bab8d3..a03ac04f2 100644 --- a/app/res/values-de/strings.xml +++ b/app/res/values-de/strings.xml @@ -49,12 +49,12 @@ %1$d ausgewählt Summe: Exportziel - Buchungen Exportieren + Buchungen exportieren Alle Buchungen exportieren Auswählen, um alle Buchungen zu exportieren. Andernfalls werden nur die neuen Buchungen seit letztem Export exportiert. Fehler beim Exportieren der OFX-Datei Export - Löschen nach dem exportieren + Löschen nach dem Exportieren Alle exportierten Buchungen werden nach dem Export gelöscht. Einstellungen @@ -69,16 +69,16 @@ Buchungen könnten nicht verschoben werden.\Die Währung des Zielkontos ist inkompatibel Allgemein Über Gnucash - Standard Währung auswählen - Standard Währung - Standard Währung für neuen Konten + Standardwährung auswählen + Standardwährung + Standardwährung für neuen Konten Ermöglicht das Speichern von Buchungen in Gnucash Ermöglicht das Erstellen von Konten in Gnucash - Ihre Gnucash Daten - Lesen und Bearbeiten von Gnucash Daten + Ihre Gnucash-Daten + Lesen und Bearbeiten von Gnucash-Daten Buchungen speichern Konten erstellen - Konto Anzeigen + Konto anzeigen Konten erstellen Zu erstellende Konten auswählen @@ -271,7 +271,7 @@ Apache License v2.0. Klicken für Details Allgemein Konto auswählen - Keine Buchungen zum exportieren + Keine Buchungen zum Exportieren Über Gnucash GnucashMobile ist eine mobile Datenaufzeichungs-App für Android. \nEs ermöglicht die schnelle und flexible Registrierung von Zahlungsvorgängen unterwegs, die dann als Datei im OFX-Format exportiert und von der GnuCash-Anwendung an einem Desktop-PC importiert werden können. Über @@ -279,7 +279,7 @@ Fehler beim Exportieren der OFX-Datei:\n OFX-Datei erfolgreich exportiert nach:\n Gnucash exportierte OFX-Datei - Gnucash accounts export from + Gnucash-Konten-Export von Buchungen Einstellungen Buchungen Einstellungen Konten @@ -295,16 +295,16 @@ Alle Buchungen exportieren Alle exportierten Buchungen löschen Standard Export E-mail - Die Standard Email an die exportierte OFX Dateien geschickt werden. Sie können diese immer noch beim exportieren ändern + Die Standard-E-Mail, an die exportierte OFX Dateien geschickt werden. Sie können diese immer noch beim Exportieren ändern. Überweisungskonto Alle Buchungen stellen eine Überweisung von einem Konto zu einem anderen dar Doppelte Buchführung aktivieren Kontostand - Geben Sie einen Kontonamen ein um das Konto zu erstellen + Geben Sie einen Kontonamen ein, um das Konto zu erstellen Währung Hauptkonto - XML OFX header verwenden - Dieses Option aktivieren wenn Sie die OFX Dateien für ein anderes Programm als GnuCash auf dem Desktop exportieren + XML-OFX-Header verwenden + Diese Option aktivieren, wenn Sie die OFX-Dateien für ein anderes Programm als GnuCash auf dem Desktop exportieren Neuigkeiten in dieser Version - Mark favorite accounts and quickly access them\n @@ -317,13 +317,13 @@ - Numerous bug fixes and improvements\n Schließen - Geben Sie einen Betrag ein um die Buchung speichern zu können - GnuCash Konten importieren + Geben Sie einen Betrag ein, um die Buchung speichern zu können + GnuCash-Konten importieren Konten importieren - Beim importieren von den GnuCash Konten ist einen Fehler aufgetreten! - GnuCash Konten wurden erfolgreich importiert - Import account structure exported from GnuCash desktop - GnuCash Konten importieren + Beim Importieren der GnuCash-Konten ist ein Fehler aufgetreten! + GnuCash-Konten wurden erfolgreich importiert + Importiere Kontenstruktur, welche von der Desktop-Version von GnuCash exportiert wurde + GnuCash-Konten importieren Alle Konten löschen. Alle Buchungen werden ebenfalls gelöscht! Alle Konten löschen Konten @@ -332,16 +332,16 @@ \n\nDiese Operation kann nicht rückgängig gemacht werden! Kontoart - Alle Buchungen in alle Konten werden gelöscht + Alle Buchungen in allen Konten werden gelöscht Alle Buchungen löschen Alle Buchungen wurden erfolgreich gelöscht Konten werden importiert - Tap again to confirm. ALL entries will be deleted!! + Erneut Tippen zum Bestätigen. ALLE Einträge werden gelöscht! Buchungen Unterkonten Suchen - Standard Export Format - File format to use by default when exporting transactions + Standard-Export-Format + Dateiformat, welches standardmäßig verwendet wird, wenn Buchungen exportiert werden Buchungen exportieren… Wiederkehr @@ -357,19 +357,19 @@ %d Unterkonten - CASH + BARGELD BANK - CREDIT CARD - ASSET - LIABILITY - INCOME - EXPENSE + KREDITKARTE + AKTIVA + PASSIVA + EINKOMMEN + AUFWENDUNGEN PAYABLE - RECEIVABLE - EQUITY - CURRENCY - STOCK - MUTUAL FUND + FORDERUNGEN + EIGENKAPITAL + WÄHRUNG + AKTIENKONTO + INVESTMENTFONDS QIF @@ -381,15 +381,12 @@ Kürzlich Favoriten Alle - Erstellt die häufig verwendete standard GnuCash Konten - Standard Konten erstellen - New accounts will be created in addition to the existing - account structure.\n\nIf you wish to replace currently existing accounts, delete them first before proceeding! + Erstellt die häufig verwendeten Standard-GnuCash-Konten + Standard-Konten erstellen + Neue Konten werden zusätzlich zur existierenden Kontenstruktur erstellt.\n\nWenn Sie die derzeitig existierenden Konten ersetzen wollen, löschen Sie diese bitte, bevor Sie fortfahren! Eingeplante Buchungen - Welcome to GnuCash Android! \nYou can either create - a hierarchy of commonly-used accounts, or import your own GnuCash account structure. \n\nBoth options are also - available in app Settings so you can decide later. + Willkommen bei GnuCash Android!\nSie können entweder eine Hierarchie der für gewöhnlich verwendeten Konten erstellen oder Ihre eigene GnuCash-Kontenstruktur importieren\n\nBeide Optionen sind auch in den Einstellungen verfügbar, sodass Sie dies später entscheiden können. KEINE @@ -398,4 +395,4 @@ MONATLICH Eingeplante Buchungen - \ No newline at end of file + From 80de0325dbd48878731d9f8d67eb0069afb5eefb Mon Sep 17 00:00:00 2001 From: Ngewi Fet Date: Fri, 21 Mar 2014 00:35:08 +0100 Subject: [PATCH 05/16] - Fixed: Editing account modifies the transaction type of transfer transactions - fixes #145 - Fixed: Bug causing double entry transactions not to be considered equal - Fixed: Computation of account balance did not properly consider double entries - Improved: Double entry accounting is now activated by default - Improved: Restricted parent/child account hierarchies relationships to those defined by GnuCash accounting (see: http://code.gnucash.org/docs/C/gnucash-help/acct-types.html ) Some code refactoring --- CHANGELOG.md | 10 + app/AndroidManifest.xml | 2 +- app/pom.xml | 2 +- app/res/values-el/strings.xml | 2 +- app/res/values/strings.xml | 2 +- app/res/xml/fragment_account_preferences.xml | 3 +- .../xml/fragment_transaction_preferences.xml | 1 + .../gnucash/android/db/AccountsDbAdapter.java | 40 ++-- .../org/gnucash/android/model/Account.java | 4 +- .../gnucash/android/model/Transaction.java | 9 +- .../ui/account/AccountFormFragment.java | 216 +++++++++++++----- .../android/ui/account/AccountsActivity.java | 26 ++- .../ui/account/AccountsListFragment.java | 5 +- .../transaction/TransactionFormFragment.java | 4 +- integration-tests/pom.xml | 2 +- pom.xml | 2 +- 16 files changed, 233 insertions(+), 97 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f152f304b..a2850321f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ Change Log =============================================================================== +Version 1.3.2 *(2014-03-28)* +---------------------------- +* Fixed: Editing account modifies the transaction type of transfer transactions +* Fixed: Bug causing double entry transactions not to be considered equal +* Fixed: Computation of account balance did not properly consider double entries +* Improved: Double-entry accounting is now activated by default +* Improved: Restricted parent/child account hierarchies relationships to those defined by GnuCash accounting +* Improved: Dutch translation +* Improved: German translation + Version 1.3.1 *(2014-02-14)* ---------------------------- * Fixed: Crash when bulk moving transactions diff --git a/app/AndroidManifest.xml b/app/AndroidManifest.xml index 9df9d16ad..5dbebd33a 100644 --- a/app/AndroidManifest.xml +++ b/app/AndroidManifest.xml @@ -17,7 +17,7 @@ diff --git a/app/pom.xml b/app/pom.xml index d52dd205f..18da0ae5e 100644 --- a/app/pom.xml +++ b/app/pom.xml @@ -22,7 +22,7 @@ Gnucash Android companion application - 1.3.0-SNAPSHOT + 1.3.2-SNAPSHOT org.gnucash.android gnucash-android-parent diff --git a/app/res/values-el/strings.xml b/app/res/values-el/strings.xml index cf8f8295a..f08e2dea5 100644 --- a/app/res/values-el/strings.xml +++ b/app/res/values-el/strings.xml @@ -405,7 +405,7 @@ Προγραμματισμένες Κινήσεις GnuCash Android. Καλώς ήρθατε! \nΜπορείτε είτε να δημιουργήσετε μια ιεραρχία συνηθισμένων λογαριασμών, ή να εισάγετε τη δική σας δομή λογαριασμών GnuCash. \n\nΚαι οι δύο επιλογές είναι επίσης - διαθέσιμες στις Επιλογές της εφαρμογής γι' αυτό μπορείτε να αποφασίσετε αργότερα. + διαθέσιμες στις Επιλογές της εφαρμογής γι\' αυτό μπορείτε να αποφασίσετε αργότερα. ΚΑΜΙΑ diff --git a/app/res/values/strings.xml b/app/res/values/strings.xml index 57dc1fd87..43a8fbd7a 100644 --- a/app/res/values/strings.xml +++ b/app/res/values/strings.xml @@ -17,7 +17,7 @@ GnuCash - 1.3.1 + 1.3.2 Create Account Edit Account Info diff --git a/app/res/xml/fragment_account_preferences.xml b/app/res/xml/fragment_account_preferences.xml index 6272ebb2c..d74b59eb9 100644 --- a/app/res/xml/fragment_account_preferences.xml +++ b/app/res/xml/fragment_account_preferences.xml @@ -7,7 +7,8 @@ android:dialogTitle="@string/title_choose_currency" android:title="@string/title_default_currency" android:entries="@array/currency_names" - android:entryValues="@array/currency_codes"/> + android:entryValues="@array/currency_codes" + android:defaultValue="USD"/> diff --git a/app/res/xml/fragment_transaction_preferences.xml b/app/res/xml/fragment_transaction_preferences.xml index e1670ccd1..f8c7f19b3 100644 --- a/app/res/xml/fragment_transaction_preferences.xml +++ b/app/res/xml/fragment_transaction_preferences.xml @@ -23,6 +23,7 @@ android:summary="@string/summary_default_transaction_type"/> 0){ //if account already exists, then just update Log.d(TAG, "Updating existing account"); - int rowsAffected = mDb.update(DatabaseHelper.ACCOUNTS_TABLE_NAME, contentValues, + mDb.update(DatabaseHelper.ACCOUNTS_TABLE_NAME, contentValues, DatabaseHelper.KEY_ROW_ID + " = " + rowId, null); - if (rowsAffected == 1){ - updateAccount(rowId, DatabaseHelper.KEY_FULL_NAME, getFullyQualifiedAccountName(rowId)); - } } else { Log.d(TAG, "Adding new account to db"); rowId = mDb.insert(DatabaseHelper.ACCOUNTS_TABLE_NAME, null, contentValues); @@ -99,7 +97,20 @@ public long addAccount(Account account){ //update the fully qualified account name updateAccount(rowId, DatabaseHelper.KEY_FULL_NAME, getFullyQualifiedAccountName(rowId)); for (Transaction t : account.getTransactions()) { - mTransactionsAdapter.addTransaction(t); + //FIXME: This is a hack until actual splits are implemented + if (t.getDoubleEntryAccountUID().equals(account.getUID())){ + Transaction trx = new Transaction(t,false); +// trx.setAmount(trx.getAmount().negate()); + if (trx.getType() == TransactionType.DEBIT) { + trx.setType(TransactionType.CREDIT); + } else { + trx.setType(TransactionType.DEBIT); + } + + mTransactionsAdapter.addTransaction(trx); + } + else + mTransactionsAdapter.addTransaction(t); } } return rowId; @@ -147,7 +158,7 @@ public boolean destructiveDeleteAccount(long rowId){ //first remove all transactions for the account Cursor c = mTransactionsAdapter.fetchAllTransactionsForAccount(rowId); if (c == null) - return result; + return false; while (c.moveToNext()){ long id = c.getLong(DatabaseAdapter.COLUMN_ROW_ID); @@ -210,7 +221,7 @@ public boolean transactionPreservingDelete(long accountId, long accountReassignI */ public boolean recursiveDestructiveDelete(long accountId){ Log.d(TAG, "Delete account with rowId with its transactions and sub-accounts: " + accountId); - boolean result = true; + boolean result = false; List subAccountIds = getSubAccountIds(accountId); for (long subAccountId : subAccountIds) { @@ -425,7 +436,7 @@ public List getExportableAccounts(){ while (it.hasNext()){ Account account = it.next(); - if (account.hasUnexportedTransactions() == false) + if (!account.hasUnexportedTransactions()) it.remove(); } return accountsList; @@ -440,13 +451,12 @@ public List getExportableAccounts(){ public Cursor fetchAllRecords(){ Log.v(TAG, "Fetching all accounts from db"); String selection = DatabaseHelper.KEY_TYPE + " != ?" ; - Cursor cursor = mDb.query(DatabaseHelper.ACCOUNTS_TABLE_NAME, + return mDb.query(DatabaseHelper.ACCOUNTS_TABLE_NAME, null, selection, new String[]{AccountType.ROOT.name()}, null, null, DatabaseHelper.KEY_NAME + " ASC"); - return cursor; } /** @@ -489,10 +499,9 @@ public boolean deleteRecord(long rowId) { */ public Cursor fetchAccounts(String condition){ Log.v(TAG, "Fetching all accounts from db where " + condition); - Cursor cursor = mDb.query(DatabaseHelper.ACCOUNTS_TABLE_NAME, - null, condition, null, null, null, - DatabaseHelper.KEY_NAME + " ASC"); - return cursor; + return mDb.query(DatabaseHelper.ACCOUNTS_TABLE_NAME, + null, condition, null, null, null, + DatabaseHelper.KEY_NAME + " ASC"); } /** @@ -612,10 +621,9 @@ public Cursor fetchRecentAccounts(int numberOfRecents){ public Cursor fetchFavoriteAccounts(){ Log.v(TAG, "Fetching favorite accounts from db"); String condition = DatabaseHelper.KEY_FAVORITE + " = 1"; - Cursor cursor = mDb.query(DatabaseHelper.ACCOUNTS_TABLE_NAME, + return mDb.query(DatabaseHelper.ACCOUNTS_TABLE_NAME, null, condition, null, null, null, DatabaseHelper.KEY_NAME + " ASC"); - return cursor; } /** diff --git a/app/src/org/gnucash/android/model/Account.java b/app/src/org/gnucash/android/model/Account.java index bb003df4e..4a854cf42 100644 --- a/app/src/org/gnucash/android/model/Account.java +++ b/app/src/org/gnucash/android/model/Account.java @@ -51,7 +51,7 @@ public class Account { ^ anchor for start of string # the literal # ( start of group - ?: indicate a non-capturing group that doesn't generate backreferences + ?: indicate a non-capturing group that doesn't generate back-references [0-9a-fA-F] hexadecimal digit {3} three times ) end of group @@ -357,7 +357,7 @@ public int getTransactionCount(){ */ public boolean hasUnexportedTransactions(){ for (Transaction transaction : mTransactionsList) { - if (transaction.isExported() == false) + if (!transaction.isExported()) return true; } return false; diff --git a/app/src/org/gnucash/android/model/Transaction.java b/app/src/org/gnucash/android/model/Transaction.java index 98a30b425..68bbe7252 100644 --- a/app/src/org/gnucash/android/model/Transaction.java +++ b/app/src/org/gnucash/android/model/Transaction.java @@ -169,10 +169,12 @@ public Transaction(Money amount, String name, TransactionType type){ /** * Copy constructor. * Creates a new transaction object which is a clone of the parameter. - *

Note: The unique ID of the transaction is not cloned, but a new one is generated.

+ *

Note: The unique ID of the transaction is not cloned if the parameter generateNewUID, + * is set to false. Otherwise, a new one is generated.

* @param transaction Transaction to be cloned + * @param generateNewUID Flag to determine if new UID should be assigned or not */ - public Transaction(Transaction transaction){ + public Transaction(Transaction transaction, boolean generateNewUID){ initDefaults(); setName(transaction.getName()); setDescription(transaction.getDescription()); @@ -182,6 +184,9 @@ public Transaction(Transaction transaction){ setDoubleEntryAccountUID(transaction.getDoubleEntryAccountUID()); setExported(transaction.isExported()); setTime(transaction.getTimeMillis()); + if (!generateNewUID){ + setUID(transaction.getUID()); + } } /** diff --git a/app/src/org/gnucash/android/ui/account/AccountFormFragment.java b/app/src/org/gnucash/android/ui/account/AccountFormFragment.java index 3551a85cb..f8a7aaee3 100644 --- a/app/src/org/gnucash/android/ui/account/AccountFormFragment.java +++ b/app/src/org/gnucash/android/ui/account/AccountFormFragment.java @@ -16,50 +16,44 @@ package org.gnucash.android.ui.account; -import java.util.Arrays; -import java.util.Currency; -import java.util.List; - import android.app.Activity; +import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.res.Resources; import android.content.res.TypedArray; +import android.database.Cursor; import android.graphics.Color; +import android.os.Bundle; import android.preference.PreferenceManager; import android.support.v4.app.FragmentManager; -import org.gnucash.android.R; -import org.gnucash.android.model.Account; -import org.gnucash.android.model.Money; -import org.gnucash.android.db.AccountsDbAdapter; -import org.gnucash.android.db.DatabaseHelper; -import org.gnucash.android.ui.UxArgument; -import org.gnucash.android.ui.colorpicker.ColorPickerDialog; -import org.gnucash.android.ui.colorpicker.ColorPickerSwatch; -import org.gnucash.android.ui.colorpicker.ColorSquare; - -import android.content.Context; -import android.database.Cursor; -import android.os.Bundle; import android.support.v4.widget.SimpleCursorAdapter; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.inputmethod.InputMethodManager; -import android.widget.ArrayAdapter; -import android.widget.CheckBox; -import android.widget.CompoundButton; +import android.widget.*; import android.widget.CompoundButton.OnCheckedChangeListener; -import android.widget.EditText; -import android.widget.Spinner; -import android.widget.Toast; - import com.actionbarsherlock.app.SherlockFragment; import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.MenuInflater; import com.actionbarsherlock.view.MenuItem; +import org.gnucash.android.R; +import org.gnucash.android.db.AccountsDbAdapter; +import org.gnucash.android.db.DatabaseHelper; +import org.gnucash.android.model.Account; +import org.gnucash.android.model.Money; +import org.gnucash.android.ui.UxArgument; +import org.gnucash.android.ui.colorpicker.ColorPickerDialog; +import org.gnucash.android.ui.colorpicker.ColorPickerSwatch; +import org.gnucash.android.ui.colorpicker.ColorSquare; import org.gnucash.android.util.QualifiedAccountNameCursorAdapter; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Currency; +import java.util.List; + /** * Fragment used for creating and editing accounts * @author Ngewi Fet @@ -97,7 +91,14 @@ public class AccountFormFragment extends SherlockFragment { * This is used if we are editing an account instead of creating one */ private long mSelectedAccountId = 0; - + + /** + * Database ID of the parent account + * This value is set to the parent account of the transaction being edited or + * the account in which a new sub-account is being created + */ + private long mParentAccountId = -1; + /** * Reference to account object which will be created at end of dialog */ @@ -202,7 +203,7 @@ public void onCreate(Bundle savedInstanceState) { } SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); - mUseDoubleEntry = sharedPrefs.getBoolean(getString(R.string.key_use_double_entry), false); + mUseDoubleEntry = sharedPrefs.getBoolean(getString(R.string.key_use_double_entry), true); } /** @@ -218,6 +219,19 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, mNameEditText.requestFocus(); mAccountTypeSpinner = (Spinner) view.findViewById(R.id.input_account_type_spinner); + mAccountTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parentView, View selectedItemView, int position, long id) { + loadParentAccountList(getSelectedAccountType()); + setParentAccountSelection(mParentAccountId); + } + + @Override + public void onNothingSelected(AdapterView adapterView) { + //nothing to see here, move along + } + }); + mPlaceholderCheckBox = (CheckBox) view.findViewById(R.id.checkbox_placeholder_account); mParentAccountSpinner = (Spinner) view.findViewById(R.id.input_parent_account); @@ -276,9 +290,8 @@ public void onActivityCreated(Bundle savedInstanceState) { } //need to load the cursor adapters for the spinners before initializing the views - loadParentAccountList(); loadAccountTypesList(); - loadDefaultTransferAccoutList(); + loadDefaultTransferAccountList(); setDefaultTransferAccountInputsVisible(mUseDoubleEntry); if (mAccount != null){ @@ -286,6 +299,8 @@ public void onActivityCreated(Bundle savedInstanceState) { } else { initializeViews(); } + + } /** @@ -297,12 +312,14 @@ private void initializeViewsWithAccount(Account account){ if (account == null) throw new IllegalArgumentException("Account cannot be null"); + loadParentAccountList(account.getAccountType()); + mParentAccountId = mAccountsDbAdapter.getAccountID(account.getParentUID()); + setParentAccountSelection(mParentAccountId); + String currencyCode = account.getCurrency().getCurrencyCode(); setSelectedCurrency(currencyCode); mNameEditText.setText(account.getName()); - long parentAccountId = mAccountsDbAdapter.getAccountID(account.getParentUID()); - setParentAccountSelection(parentAccountId); if (mUseDoubleEntry) { long doubleDefaultAccountId = mAccountsDbAdapter.getAccountID(account.getDefaultTransferAccountUID()); @@ -321,19 +338,23 @@ private void initializeViewsWithAccount(Account account){ private void initializeViews(){ setSelectedCurrency(Money.DEFAULT_CURRENCY_CODE); mColorSquare.setBackgroundColor(Color.LTGRAY); - long parentAccountId = getArguments().getLong(UxArgument.PARENT_ACCOUNT_ID); - setParentAccountSelection(parentAccountId); + mParentAccountId = getArguments().getLong(UxArgument.PARENT_ACCOUNT_ID); - /* This snippet causes the child account to default to same color as parent. Not sure if we want that - if (parentAccountId > 0) { - //child accounts by default have same type as the parent - setAccountTypeSelection(mAccountsDbAdapter.getAccountType(parentAccountId)); - String colorHex = mAccountsDbAdapter.getAccountColorCode(parentAccountId); - initializeColorSquarePreview(colorHex); - mSelectedColor = colorHex; + if (mParentAccountId > 0) { + Account.AccountType parentAccountType = mAccountsDbAdapter.getAccountType(mParentAccountId); + setAccountTypeSelection(parentAccountType); + loadParentAccountList(parentAccountType); + setParentAccountSelection(mParentAccountId); +// String colorHex = mAccountsDbAdapter.getAccountColorCode(parentAccountId); +// initializeColorSquarePreview(colorHex); +// mSelectedColor = colorHex; } - */ + + //this must be called after changing account type + //because changing account type reloads list of eligible parent accounts + + } /** @@ -392,7 +413,14 @@ private void setParentAccountSelection(long parentAccountId){ for (int pos = 0; pos < mParentAccountCursorAdapter.getCount(); pos++) { if (mParentAccountCursorAdapter.getItemId(pos) == parentAccountId){ - mParentAccountSpinner.setSelection(pos); + final int position = pos; + mParentAccountSpinner.postDelayed(new Runnable() { + @Override + public void run() { + mParentAccountSpinner.setSelection(position); + } + }, 100); +// mParentAccountSpinner.setSelection(pos, true); break; } } @@ -477,7 +505,7 @@ public boolean onOptionsItemSelected(MenuItem item) { /** * Initializes the default transfer account spinner with eligible accounts */ - private void loadDefaultTransferAccoutList(){ + private void loadDefaultTransferAccountList(){ String condition = DatabaseHelper.KEY_ROW_ID + " != " + mSelectedAccountId + " AND " + DatabaseHelper.KEY_PLACEHOLDER + "=0" + " AND " + DatabaseHelper.KEY_UID + " != '" + mAccountsDbAdapter.getGnuCashRootAccountUID() + "'"; @@ -493,23 +521,32 @@ private void loadDefaultTransferAccoutList(){ mDefaultTransferAccountCursorAdapter = new QualifiedAccountNameCursorAdapter(getActivity(), android.R.layout.simple_spinner_item, defaultTransferAccountCursor); - mParentAccountCursorAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - mDefaulTransferAccountSpinner.setAdapter(mParentAccountCursorAdapter); + mDefaultTransferAccountCursorAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + mDefaulTransferAccountSpinner.setAdapter(mDefaultTransferAccountCursorAdapter); } /** - * Loads the list of possible accounts which can be set as a parent account and initializes the spinner + * Loads the list of possible accounts which can be set as a parent account and initializes the spinner. + * The allowed parent accounts depends on the account type + * @param accountType AccountType of account whose allowed parent list is to be loaded */ - private void loadParentAccountList(){ - String condition = null; + private void loadParentAccountList(Account.AccountType accountType){ + String condition = DatabaseHelper.KEY_TYPE + " IN (" + + getAllowedParentAccountTypes(accountType) + ") "; + if (mAccount != null){ //if editing an account // limit cyclic account hierarchies. Still technically possible since we don't forbid descendant accounts - condition = "(" + DatabaseHelper.KEY_PARENT_ACCOUNT_UID + " IS NULL " + condition += " AND (" + DatabaseHelper.KEY_PARENT_ACCOUNT_UID + " IS NULL " + " OR " + DatabaseHelper.KEY_PARENT_ACCOUNT_UID + " != '" + mAccount.getUID() + "')" - + " AND " + DatabaseHelper.KEY_ROW_ID + "!=" + mSelectedAccountId; + + " AND " + DatabaseHelper.KEY_ROW_ID + " != " + mSelectedAccountId; + //TODO: Limit all descendants of the account to eliminate the possibility of cyclic hierarchy } + //if we are reloading the list, close the previous cursor first + if (mParentAccountCursor != null) + mParentAccountCursor.close(); + mParentAccountCursor = mAccountsDbAdapter.fetchAccountsOrderedByFullName(condition); if (mParentAccountCursor == null || mParentAccountCursor.getCount() <= 0){ final View view = getView(); @@ -525,6 +562,68 @@ private void loadParentAccountList(){ mParentAccountSpinner.setAdapter(mParentAccountCursorAdapter); } + /** + * Returns a comma separated list of account types which can be parent accounts for the specified type. + * The strings in the list are the {@link org.gnucash.android.model.Account.AccountType#name()}s of the different types. + * @param type {@link org.gnucash.android.model.Account.AccountType} + * @return String comma separated list of account types + */ + private String getAllowedParentAccountTypes(Account.AccountType type){ + + switch (type){ + case EQUITY: + return "'" + Account.AccountType.EQUITY.name() + "'"; + + case INCOME: + case EXPENSE: + return "'" + Account.AccountType.EXPENSE + "', '" + Account.AccountType.INCOME + "', '" + + Account.AccountType.ROOT + "'"; + + case CASH: + case BANK: + case CREDIT: + case ASSET: + case LIABILITY: + case PAYABLE: + case RECEIVABLE: + case CURRENCY: + case STOCK: + case MUTUAL: { + List accountTypeStrings = getAccountTypeStringList(); + + accountTypeStrings.remove(Account.AccountType.EQUITY.name()); + accountTypeStrings.remove(Account.AccountType.EXPENSE.name()); + accountTypeStrings.remove(Account.AccountType.INCOME.name()); + + String result = ""; + for (String accountTypeString : accountTypeStrings) { + result += "'" + accountTypeString + "',"; + } + + //remove the last comma + return result.substring(0, result.length() - 1); + + } + + case ROOT: + default: + return Arrays.toString(Account.AccountType.values()).replaceAll("\\[|]", ""); + } + } + + /** + * Returns a list of all the available {@link org.gnucash.android.model.Account.AccountType}s as strings + * @return String list of all account types + */ + private List getAccountTypeStringList(){ + String[] accountTypes = Arrays.toString(Account.AccountType.values()).replaceAll("\\[|]", "").split(","); + List accountTypesList = new ArrayList(); + for (String accountType : accountTypes) { + accountTypesList.add(accountType.trim()); + } + + return accountTypesList; + } /** * Loads the list of account types into the account type selector spinner */ @@ -583,9 +682,8 @@ private void saveAccount() { .getSelectedItemPosition()); mAccount.setCurrency(Currency.getInstance(curCode)); - int selectedAccountType = mAccountTypeSpinner.getSelectedItemPosition(); - String[] accountTypeEntries = getResources().getStringArray(R.array.account_type_entries); - mAccount.setAccountType(Account.AccountType.valueOf(accountTypeEntries[selectedAccountType])); + Account.AccountType selectedAccountType = getSelectedAccountType(); + mAccount.setAccountType(selectedAccountType); mAccount.setPlaceHolderFlag(mPlaceholderCheckBox.isChecked()); mAccount.setColorCode(mSelectedColor); @@ -612,8 +710,18 @@ private void saveAccount() { finishFragment(); } - - /** + + /** + * Returns the currently selected account type in the spinner + * @return {@link org.gnucash.android.model.Account.AccountType} currently selected + */ + private Account.AccountType getSelectedAccountType() { + int selectedAccountTypeIndex = mAccountTypeSpinner.getSelectedItemPosition(); + String[] accountTypeEntries = getResources().getStringArray(R.array.account_type_entries); + return Account.AccountType.valueOf(accountTypeEntries[selectedAccountTypeIndex]); + } + + /** * Retrieves the name of the account which has been entered in the EditText * @return */ diff --git a/app/src/org/gnucash/android/ui/account/AccountsActivity.java b/app/src/org/gnucash/android/ui/account/AccountsActivity.java index 9570b8525..c83147fc4 100644 --- a/app/src/org/gnucash/android/ui/account/AccountsActivity.java +++ b/app/src/org/gnucash/android/ui/account/AccountsActivity.java @@ -37,6 +37,7 @@ import android.support.v4.view.ViewPager; import android.util.Log; import android.util.SparseArray; +import android.util.SparseIntArray; import android.view.View; import android.view.ViewGroup; import android.widget.Toast; @@ -133,7 +134,7 @@ public class AccountsActivity extends SherlockFragmentActivity implements OnAcco /** * Map containing fragments for the different tabs */ - private Map mFragmentPageReferenceMap = new HashMap(); + private SparseArray mFragmentPageReferenceMap = new SparseArray(); /** * ViewPager which manages the different tabs @@ -238,7 +239,10 @@ public void onCreate(Bundle savedInstanceState) { PagerAdapter mPagerAdapter = new AccountViewPagerAdapter(getSupportFragmentManager()); mPager.setAdapter(mPagerAdapter); titlePageIndicator.setViewPager(mPager); - mPager.setCurrentItem(INDEX_TOP_LEVEL_ACCOUNTS_FRAGMENT); + + SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); + int lastTabIndex = preferences.getInt(LAST_OPEN_TAB_INDEX, INDEX_TOP_LEVEL_ACCOUNTS_FRAGMENT); + mPager.setCurrentItem(lastTabIndex); } } @@ -247,19 +251,22 @@ public void onCreate(Bundle savedInstanceState) { * Loads default setting for currency and performs app first-run initialization */ private void init() { - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); + PreferenceManager.setDefaultValues(this, R.xml.fragment_transaction_preferences, false); + Locale locale = Locale.getDefault(); //sometimes the locale en_UK is returned which causes a crash with Currency if (locale.getCountry().equals("UK")) { locale = new Locale(locale.getLanguage(), "GB"); } + String currencyCode; + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); try { //there are some strange locales out there currencyCode = prefs.getString(getString(R.string.key_default_currency), Currency.getInstance(locale).getCurrencyCode()); } catch (Exception e) { Log.e(LOG_TAG, e.getMessage()); - currencyCode = "USD"; //just use USD and let the user choose + currencyCode = "USD"; } Money.DEFAULT_CURRENCY_CODE = currencyCode; @@ -275,18 +282,15 @@ private void init() { } - @Override + @Override protected void onResume() { super.onResume(); TransactionsActivity.sLastTitleColor = -1; - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); - int lastTabIndex = preferences.getInt(LAST_OPEN_TAB_INDEX, INDEX_TOP_LEVEL_ACCOUNTS_FRAGMENT); - mPager.setCurrentItem(lastTabIndex); } @Override - protected void onStop() { - super.onPause(); + protected void onDestroy() { + super.onDestroy(); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); preferences.edit().putInt(LAST_OPEN_TAB_INDEX, mPager.getCurrentItem()).commit(); } @@ -471,7 +475,7 @@ public void onClick(DialogInterface dialogInterface, int i) { }); mDefaultAccountsDialog = builder.create(); - mDefaultAccountsDialog.show(); + mDefaultAccountsDialog.show(); } /** diff --git a/app/src/org/gnucash/android/ui/account/AccountsListFragment.java b/app/src/org/gnucash/android/ui/account/AccountsListFragment.java index 5863897ed..2e6fd37a0 100644 --- a/app/src/org/gnucash/android/ui/account/AccountsListFragment.java +++ b/app/src/org/gnucash/android/ui/account/AccountsListFragment.java @@ -633,9 +633,8 @@ public Cursor loadInBackground() { Cursor cursor; if (mFilter != null){ - StringBuffer queryBuffer = new StringBuffer(DatabaseHelper.KEY_NAME) - .append(" LIKE '%").append(mFilter).append("%'"); - cursor = ((AccountsDbAdapter)mDatabaseAdapter).fetchAccounts(queryBuffer.toString()); + cursor = ((AccountsDbAdapter)mDatabaseAdapter) + .fetchAccounts(DatabaseHelper.KEY_NAME + " LIKE '%" + mFilter + "%'"); } else { if (mParentAccountId > 0) cursor = ((AccountsDbAdapter) mDatabaseAdapter).fetchSubAccounts(mParentAccountId); diff --git a/app/src/org/gnucash/android/ui/transaction/TransactionFormFragment.java b/app/src/org/gnucash/android/ui/transaction/TransactionFormFragment.java index 251a920ea..0c02bc20f 100644 --- a/app/src/org/gnucash/android/ui/transaction/TransactionFormFragment.java +++ b/app/src/org/gnucash/android/ui/transaction/TransactionFormFragment.java @@ -213,7 +213,7 @@ public void onActivityCreated(Bundle savedInstanceState) { actionBar.setDisplayShowTitleEnabled(false); SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); - mUseDoubleEntry = sharedPrefs.getBoolean(getString(R.string.key_use_double_entry), false); + mUseDoubleEntry = sharedPrefs.getBoolean(getString(R.string.key_use_double_entry), true); if (!mUseDoubleEntry){ getView().findViewById(R.id.layout_double_entry).setVisibility(View.GONE); } @@ -604,7 +604,7 @@ private void saveNewTransaction() { long recurrencePeriodMillis = Long.parseLong(recurrenceOptions[recurrenceIndex]); long firstRunMillis = System.currentTimeMillis() + recurrencePeriodMillis; - Transaction recurringTransaction = new Transaction(mTransaction); + Transaction recurringTransaction = new Transaction(mTransaction, true); recurringTransaction.setRecurrencePeriod(recurrencePeriodMillis); long recurringTransactionId = mTransactionsDbAdapter.addTransaction(recurringTransaction); diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index 274c36a75..6c32e8fee 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -17,7 +17,7 @@ 4.0.0 - 1.3.0-SNAPSHOT + 1.3.2-SNAPSHOT org.gnucash.android gnucash-android-parent diff --git a/pom.xml b/pom.xml index 3752af570..3bb0faacd 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,7 @@ 4.0.0 - 1.3.0-SNAPSHOT + 1.3.2-SNAPSHOT org.gnucash.android gnucash-android-parent GnuCash Android parent From acd715f1279ab9d70cd9eac39bddcece5472dfd8 Mon Sep 17 00:00:00 2001 From: aerkefiende Date: Sun, 23 Mar 2014 12:37:09 +0100 Subject: [PATCH 06/16] Replacing Gnucash with GnuCash --- app/res/values-de/strings.xml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/res/values-de/strings.xml b/app/res/values-de/strings.xml index a03ac04f2..9bdf50e35 100644 --- a/app/res/values-de/strings.xml +++ b/app/res/values-de/strings.xml @@ -68,14 +68,14 @@ OFX-Datei senden mit… Buchungen könnten nicht verschoben werden.\Die Währung des Zielkontos ist inkompatibel Allgemein - Über Gnucash + Über GnuCash Standardwährung auswählen Standardwährung Standardwährung für neuen Konten - Ermöglicht das Speichern von Buchungen in Gnucash - Ermöglicht das Erstellen von Konten in Gnucash - Ihre Gnucash-Daten - Lesen und Bearbeiten von Gnucash-Daten + Ermöglicht das Speichern von Buchungen in GnuCash + Ermöglicht das Erstellen von Konten in GnuCash + Ihre GnuCash-Daten + Lesen und Bearbeiten von GnuCash-Daten Buchungen speichern Konten erstellen Konto anzeigen @@ -272,14 +272,14 @@ Allgemein Konto auswählen Keine Buchungen zum Exportieren - Über Gnucash - GnucashMobile ist eine mobile Datenaufzeichungs-App für Android. \nEs ermöglicht die schnelle und flexible Registrierung von Zahlungsvorgängen unterwegs, die dann als Datei im OFX-Format exportiert und von der GnuCash-Anwendung an einem Desktop-PC importiert werden können. + Über GnuCash + GnuCashMobile ist eine mobile Datenaufzeichungs-App für Android. \nEs ermöglicht die schnelle und flexible Registrierung von Zahlungsvorgängen unterwegs, die dann als Datei im OFX-Format exportiert und von der GnuCash-Anwendung an einem Desktop-PC importiert werden können. Über OFX-Datei exportiert nach: Fehler beim Exportieren der OFX-Datei:\n OFX-Datei erfolgreich exportiert nach:\n - Gnucash exportierte OFX-Datei - Gnucash-Konten-Export von + GnuCash exportierte OFX-Datei + GnuCash-Konten-Export von Buchungen Einstellungen Buchungen Einstellungen Konten From c38d54bcc2422fc83a91ff286460070016a774ae Mon Sep 17 00:00:00 2001 From: aerkefiende Date: Sun, 23 Mar 2014 12:57:05 +0100 Subject: [PATCH 07/16] Fixed small typos --- app/res/values-de/strings.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/res/values-de/strings.xml b/app/res/values-de/strings.xml index 9bdf50e35..3856c7566 100644 --- a/app/res/values-de/strings.xml +++ b/app/res/values-de/strings.xml @@ -71,7 +71,7 @@ Über GnuCash Standardwährung auswählen Standardwährung - Standardwährung für neuen Konten + Standardwährung für neue Konten Ermöglicht das Speichern von Buchungen in GnuCash Ermöglicht das Erstellen von Konten in GnuCash Ihre GnuCash-Daten @@ -265,7 +265,7 @@ KapitalKonto Passiva
- Keine Konten vorhanden.\nSie müssen einen Konto erstellen um Widgets zu anzufügen + Keine Konten vorhanden.\nSie müssen ein Konto erstellen um Widgets anfügen zu können. Version Lizenz Apache License v2.0. Klicken für Details @@ -294,7 +294,7 @@ Exportieren Alle Buchungen exportieren Alle exportierten Buchungen löschen - Standard Export E-mail + Standard Export E-Mail Die Standard-E-Mail, an die exportierte OFX Dateien geschickt werden. Sie können diese immer noch beim Exportieren ändern. Überweisungskonto Alle Buchungen stellen eine Überweisung von einem Konto zu einem anderen dar @@ -386,7 +386,7 @@ Neue Konten werden zusätzlich zur existierenden Kontenstruktur erstellt.\n\nWenn Sie die derzeitig existierenden Konten ersetzen wollen, löschen Sie diese bitte, bevor Sie fortfahren! Eingeplante Buchungen - Willkommen bei GnuCash Android!\nSie können entweder eine Hierarchie der für gewöhnlich verwendeten Konten erstellen oder Ihre eigene GnuCash-Kontenstruktur importieren\n\nBeide Optionen sind auch in den Einstellungen verfügbar, sodass Sie dies später entscheiden können. + Willkommen bei GnuCash Android!\nSie können entweder eine Hierarchie der für gewöhnlich verwendeten Konten erstellen oder Ihre eigene GnuCash-Kontenstruktur importieren.\n\nBeide Optionen sind auch in den Einstellungen verfügbar, sodass Sie dies später entscheiden können. KEINE From 7b2db061fba8e5f2dd9313231b94b474fe32bb40 Mon Sep 17 00:00:00 2001 From: aerkefiende Date: Sun, 23 Mar 2014 14:27:19 +0100 Subject: [PATCH 08/16] Android Studio gets error if same string is defined more than once Introduced in commit 3616eff03f81de2b1ff271de810388f446bcde0e --- app/res/values-el/strings.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/res/values-el/strings.xml b/app/res/values-el/strings.xml index f08e2dea5..39a35470b 100644 --- a/app/res/values-el/strings.xml +++ b/app/res/values-el/strings.xml @@ -285,7 +285,6 @@ Αρχείο OFX εξήχθη σε:\n Εξαγωγή GnuCash OFX Εξαγωγή GnuCash OFX προς - Συναλλαγές Κινήσεις Προτιμήσεις Κινήσεων Προτιμήσεις Λογαριασμών From b4699006d33250bbdf4cc2d456a5cd81b6fa7cbd Mon Sep 17 00:00:00 2001 From: Spanti Nicola Date: Fri, 11 Apr 2014 20:35:14 -0400 Subject: [PATCH 09/16] An improve french translation --- app/res/values-fr/strings.xml | 84 +++++++++++++++++------------------ app/res/values/strings.xml | 2 +- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/app/res/values-fr/strings.xml b/app/res/values-fr/strings.xml index 94887e1d6..088c51a61 100644 --- a/app/res/values-fr/strings.xml +++ b/app/res/values-fr/strings.xml @@ -19,23 +19,23 @@ GnuCash Créer un compte - Editer le compte + Éditer le compte Informations Exporter en OFX Ajoute une nouvelle transaction à un compte - Aucun comptes à afficher + Aucun compte à afficher Nom de compte Annuler - Sauvgarder - Aucune transactions à afficher + Sauvegarder + Aucune transaction à afficher Description Montant Nouvelle transaction Aucune transaction à afficher DATE & HEURE Compte - DEBIT - CREDIT + DÉBIT + CRÉDIT Comptes Transactions SUPPRIMER @@ -44,13 +44,13 @@ Compte supprimé Confirmer la suppression Toutes les transactions dans ce compte seront aussi supprimées - Editer la transaction + Éditer la transaction Note - DEPLACER + DÉPLACER %1$d sélectionné(s) - Total: + Total : Destination d\'export - Exporter les Transactions + Exporter les transactions Exporter toutes les transactions Par défaut, seul les nouvelles transactions depuis le dernier export seront exportées. Cochez cette option pour exporter toutes les transactions Erreur lors de l\'export des données en OFX @@ -67,14 +67,14 @@ Compte de destination Accés carte SD Partager l\'export en OFX avec… - Impposible de déplacer les transactions.\nLe compte de destination utilise une monnaie différente du compte d\'origine + Impossible de déplacer les transactions.\nLe compte de destination utilise une monnaie différente du compte d\'origine Général - A propos + À propos Choisisez une monnaie par défaut Monnaie par défaut Monnaie par défaut à assignée aux nouveau comptes - Permettre l\'enregistrement des transactions dans Gnucash pour Android - Permettre la création de comptes dans Gnucash pour Android + Permettre l\'enregistrement des transactions dans GnuCash pour Android + Permettre la création de comptes dans GnuCash pour Android Vos données GnuCash Lire et modifier les données GnuCash enregistrer les transactions @@ -266,31 +266,31 @@ Capitaux propres Charges - Aucun compte éxistant dans Gnucash.\nCréez un compte avant d\'ajouter un widget + Aucun compte éxistant dans GnuCash.\nCréez un compte avant d\'ajouter un widget Version logiciel Licence - Apache License v2.0. Clickez pour plus de détails + Apache License v2.0. Cliquez pour plus de détails Général Sélectionner un compte - Il n\'existe pas de transactions disponible pour l\'exportation - A propos de Gnucash - GnucashMobile est une application mobile de suivis de finance pour Android.\nElle permet un suivi simple des dépenses qui peut être exporté vers le format Open Financial eXchange (OFX) et importé dans Gnucash pour PC. + Il n\'existe pas de transaction disponible pour l\'exportation + À propos de GnuCash + GnucashMobile est une application mobile de suivis de finance pour Android.\nElle permet un suivi simple des dépenses qui peut être exporté vers le format Open Financial eXchange (OFX) et importé dans GnuCash pour PC. A propos - Impossible d\'écrire un fichier OFX en:\n - Fichier OFX exporté en:\n - Gnucash OFX export - Gnucash OFX Export de + Impossible d\'écrire un fichier OFX en :\n + Fichier OFX exporté en :\n + GnuCash OFX export + GnuCash OFX export de Transactions Préférences des transactions Préférences du compte Type de transaction par défaut - Le type de transaction à utiliser par défaut, CREDIT ou DEBIT + Le type de transaction à utiliser par défaut, CRÉDIT ou DÉBIT - CREDIT - DEBIT + CRÉDIT + DÉBIT - Etes vous sûre de vouloir supprimer TOUTES les transactions? - Etes vous sûre de vouloir supprimer cette transaction? + Êtes vous sûre de vouloir supprimer TOUTES les transactions ? + Êtes vous sûre de vouloir supprimer cette transaction ? Export Exporter toutes les transactions Supprimer les transactions exportées @@ -317,7 +317,7 @@ - Nombreuses corrections de bogues et améliorations\n Passer - Entrez un montant pour sauvgarder la transaction + Entrez un montant pour sauvegarder la transaction Importer des comptes GnuCash Import de comptes Une érreur s\'est produite pendant l\'import de vos comptes GnuCash @@ -328,19 +328,19 @@ Supprimer tous les comptes Comptes Tous les comptes ont été supprimés avec succès - Etes-vous sûr de vouloir supprimer tous les comptes et toutes les transactions?\n Cette opération est définitive! + Êtes-vous sûr de vouloir supprimer tous les comptes et toutes les transactions?\nCette opération est définitive ! Type de compte - Toutes les transactions sur tous les comptes seront supprimées! + Toutes les transactions sur tous les comptes seront supprimées ! Supprimer toutes les transactions - Toutes les transactions ont été supprimées avec succès! + Toutes les transactions ont été supprimées avec succès ! Importation de comptes - Taper de nouveau pour confirmer. TOUTES les entrées seront supprimées!! + Taper de nouveau pour confirmer. TOUTES les entrées seront supprimées ! Transactions - Sous-Comptes + Sous-comptes Rechercher Format d\'export par défaut Format de fichier à utiliser par défaut pour l\'export des transactions - Export transactions… + Exporter les transactions… Récurrence Déséquilibre @@ -382,17 +382,17 @@ Crée une structure de compte GnuCash par défaut couramment utilisé Crée comptes par défaut Les nouveaux comptes seront créés en plus de l\'existante - structure de compte.\n\n Si vous souhaitez remplacer des comptes existants, supprimez-les d\'abord avant de commencer! + structure de compte.\n\n Si vous souhaitez remplacer des comptes existants, supprimez-les d\'abord avant de commencer ! - Bienvenue à GnuCash Android!\n Vous pouvez soit créer - une hiérarchie de comptes couramment utilisés, importer votre propre structure de compte GnuCash.\n\n Les deux options sont également - disponible dans les paramètres d\'applications de sorte que vous puissiez décider plus tard. + Bienvenue sur GnuCash Android!\nVous pouvez soit créer + une hiérarchie de comptes couramment utilisés, importer votre propre structure de compte GnuCash.\n\nLes deux options sont également + disponibles dans les paramètres de l\'application de sorte que vous puissiez décider plus tard. AUCUN QUOTIDIEN SEMAINE MENSUEL - Scheduled Transactions - Scheduled Transactions - + Transactions planifiées + Transactions planifiées + \ No newline at end of file diff --git a/app/res/values/strings.xml b/app/res/values/strings.xml index 43a8fbd7a..a75ee62cd 100644 --- a/app/res/values/strings.xml +++ b/app/res/values/strings.xml @@ -526,7 +526,7 @@ Delete all accounts Accounts All accounts have been successfully deleted - Are you sure you want to delete all accounts and transactions? \n\nThis + Are you sure you want to delete all accounts and transactions?\n\nThis operation cannot be undone! Account Type From 19a346bfd4886d7b4c252eb773aa307cb4256990 Mon Sep 17 00:00:00 2001 From: Yongxin Wang Date: Wed, 7 May 2014 23:18:08 +0800 Subject: [PATCH 10/16] close cursors --- .../gnucash/android/db/AccountsDbAdapter.java | 30 +++++-- .../android/db/TransactionsDbAdapter.java | 90 ++++++++++++------- 2 files changed, 79 insertions(+), 41 deletions(-) diff --git a/app/src/org/gnucash/android/db/AccountsDbAdapter.java b/app/src/org/gnucash/android/db/AccountsDbAdapter.java index bb91f66c0..894b576d7 100644 --- a/app/src/org/gnucash/android/db/AccountsDbAdapter.java +++ b/app/src/org/gnucash/android/db/AccountsDbAdapter.java @@ -699,10 +699,12 @@ public long getId(String accountUID){ new String[]{DatabaseHelper.KEY_ROW_ID, DatabaseHelper.KEY_UID}, DatabaseHelper.KEY_UID + "='" + accountUID + "'", null, null, null, null); - if (c != null && c.moveToFirst()){ - id = c.getLong(DatabaseAdapter.COLUMN_ROW_ID); - c.close(); - } + if (c != null) { + if (c.moveToFirst()) { + id = c.getLong(DatabaseAdapter.COLUMN_ROW_ID); + } + c.close(); + } return id; } @@ -740,7 +742,10 @@ public String getAccountName(String accountUID){ DatabaseHelper.KEY_UID + " = ?", new String[]{accountUID}, null, null, null); - if (cursor == null || cursor.getCount() < 1){ + if (cursor == null) { + return null; + } else if ( cursor.getCount() < 1) { + cursor.close(); return null; } else { //account UIDs should be unique cursor.moveToFirst(); @@ -763,7 +768,10 @@ public long getDefaultTransferAccountID(long accountID){ DatabaseHelper.KEY_ROW_ID + " = " + accountID, null, null, null, null); - if (cursor == null || cursor.getCount() < 1){ + if (cursor == null) { + return 0; + } else if (cursor.getCount() < 1) { + cursor.close(); return 0; } else { cursor.moveToFirst(); @@ -818,7 +826,10 @@ public boolean isPlaceholderAccount(String accountUID){ DatabaseHelper.KEY_UID + " = ?", new String[]{accountUID}, null, null, null); - if (cursor == null || !cursor.moveToFirst()){ + if (cursor == null) + return false; + if (!cursor.moveToFirst()) { + cursor.close(); return false; } boolean isPlaceholder = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseHelper.KEY_PLACEHOLDER)) == 1; @@ -847,7 +858,10 @@ public boolean isFavoriteAccount(long accountId){ DatabaseHelper.KEY_ROW_ID + " = " + accountId, null, null, null, null); - if (cursor == null || !cursor.moveToFirst()){ + if (cursor == null) + return false; + if (!cursor.moveToFirst()){ + cursor.close(); return false; } boolean isFavorite = cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseHelper.KEY_FAVORITE)) == 1; diff --git a/app/src/org/gnucash/android/db/TransactionsDbAdapter.java b/app/src/org/gnucash/android/db/TransactionsDbAdapter.java index 5bfc881c8..f6a845644 100644 --- a/app/src/org/gnucash/android/db/TransactionsDbAdapter.java +++ b/app/src/org/gnucash/android/db/TransactionsDbAdapter.java @@ -92,12 +92,13 @@ public long fetchTransactionWithUID(String uid){ DatabaseHelper.KEY_UID + " = '" + uid + "'", null, null, null, null); long result = -1; - if (cursor != null && cursor.moveToFirst()){ - Log.d(TAG, "Transaction already exists. Returning existing id"); - result = cursor.getLong(0); //0 because only one row was requested - - cursor.close(); - } + if (cursor != null) { + if (cursor.moveToFirst()) { + Log.d(TAG, "Transaction already exists. Returning existing id"); + result = cursor.getLong(0); //0 because only one row was requested + } + cursor.close(); + } return result; } @@ -113,10 +114,12 @@ public Transaction getTransaction(long rowId){ Log.v(TAG, "Fetching transaction with id " + rowId); Transaction transaction = null; Cursor c = fetchRecord(DatabaseHelper.TRANSACTIONS_TABLE_NAME, rowId); - if (c != null && c.moveToFirst()){ - transaction = buildTransactionInstance(c); - c.close(); - } + if (c != null) { + if (c.moveToFirst()) { + transaction = buildTransactionInstance(c); + } + c.close(); + } return transaction; } @@ -173,9 +176,12 @@ public Cursor fetchAllTransactionsForAccount(long accountID){ public List getAllTransactionsForAccount(String accountUID){ Cursor c = fetchAllTransactionsForAccount(accountUID); ArrayList transactionsList = new ArrayList(); - - if (c == null || (c.getCount() <= 0)) + if (c == null) return transactionsList; + if (c.getCount() <= 0) { + c.close(); + return transactionsList; + } while (c.moveToNext()) { Transaction transaction = buildTransactionInstance(c); @@ -235,8 +241,12 @@ public String getCurrencyCode(String accountUID) { DatabaseHelper.KEY_UID + "= '" + accountUID + "'", null, null, null, null); - if (cursor == null || cursor.getCount() <= 0) + if (cursor == null) return null; + if (cursor.getCount() <= 0) { + cursor.close(); + return null; + } cursor.moveToFirst(); String currencyCode = cursor.getString(0); @@ -338,7 +348,7 @@ public long getAllTransactionsCount(){ * @param accountId Record ID of the account * @return Sum of transactions belonging to the account */ - public Money getTransactionsSum(long accountId){ + public Money getTransactionsSum(long accountId) { //FIXME: Properly compute the balance while considering normal account balance String accountUID = getAccountUID(accountId); @@ -350,8 +360,10 @@ public Money getTransactionsSum(long accountId){ Cursor sumCursor = mDb.rawQuery(querySum, new String[]{accountUID}); double sum = 0d; - if (sumCursor != null && sumCursor.moveToFirst()){ - sum += sumCursor.getFloat(0); + if (sumCursor != null) { + if (sumCursor.moveToFirst()) { + sum += sumCursor.getFloat(0); + } sumCursor.close(); } @@ -362,8 +374,10 @@ public Money getTransactionsSum(long accountId){ sumCursor = mDb.rawQuery(querySum, new String[]{accountUID}); - if (sumCursor != null && sumCursor.moveToFirst()){ - sum -= sumCursor.getFloat(0); + if (sumCursor != null) { + if (sumCursor.moveToFirst()) { + sum -= sumCursor.getFloat(0); + } sumCursor.close(); } @@ -393,8 +407,10 @@ public Account.AccountType getAccountType(String accountUID){ new String[]{DatabaseHelper.KEY_TYPE}, DatabaseHelper.KEY_UID + "='" + accountUID + "'", null, null, null, null); - if (c != null && c.moveToFirst()){ - type = c.getString(c.getColumnIndexOrThrow(DatabaseHelper.KEY_TYPE)); + if (c != null) { + if (c.moveToFirst()) { + type = c.getString(c.getColumnIndexOrThrow(DatabaseHelper.KEY_TYPE)); + } c.close(); } return Account.AccountType.valueOf(type); @@ -432,6 +448,7 @@ public List getNonExportedTransactionsForAccount(String accountUID) while (c.moveToNext()){ transactionsList.add(buildTransactionInstance(c)); } + c.close(); return transactionsList; } @@ -446,10 +463,12 @@ public String getAccountUID(long accountRowID){ new String[]{DatabaseHelper.KEY_UID}, DatabaseHelper.KEY_ROW_ID + "=" + accountRowID, null, null, null, null); - if (c != null && c.moveToFirst()){ - uid = c.getString(0); - c.close(); - } + if (c != null) { + if (c.moveToFirst()) { + uid = c.getString(0); + } + c.close(); + } return uid; } @@ -464,11 +483,12 @@ public String getAccountUidFromTransaction(long transactionID){ DatabaseHelper.KEY_ROW_ID + "=" + transactionID, null, null, null, null); String accountUID = null; - if (c != null && c.moveToFirst()){ - accountUID = c.getString(0); + if (c != null) { + if (c.moveToFirst()) { + accountUID = c.getString(0); + } c.close(); } - return accountUID; } @@ -483,10 +503,12 @@ public long getAccountID(String accountUID){ new String[]{DatabaseHelper.KEY_ROW_ID}, DatabaseHelper.KEY_UID + "='" + accountUID + "'", null, null, null, null); - if (c != null && c.moveToFirst()){ - id = c.getLong(0); - c.close(); - } + if (c != null) { + if (c.moveToFirst()) { + id = c.getLong(0); + } + c.close(); + } return id; } @@ -501,8 +523,10 @@ public long getID(String transactionUID){ new String[]{DatabaseHelper.KEY_ROW_ID}, DatabaseHelper.KEY_UID + "='" + transactionUID + "'", null, null, null, null); - if (c != null && c.moveToFirst()){ - id = c.getLong(0); + if (c != null) { + if (c.moveToFirst()) { + id = c.getLong(0); + } c.close(); } return id; From f6ae9103383349d5d21f2552eb54bd2e571adf30 Mon Sep 17 00:00:00 2001 From: Yongxin Wang Date: Thu, 8 May 2014 22:59:55 +0800 Subject: [PATCH 11/16] More db resource leaks --- .../gnucash/android/db/AccountsDbAdapter.java | 62 +++++++++++-------- .../ui/transaction/TransactionsActivity.java | 15 ++++- .../util/GnucashAccountXmlHandler.java | 2 +- 3 files changed, 49 insertions(+), 30 deletions(-) diff --git a/app/src/org/gnucash/android/db/AccountsDbAdapter.java b/app/src/org/gnucash/android/db/AccountsDbAdapter.java index 894b576d7..6a24938dd 100644 --- a/app/src/org/gnucash/android/db/AccountsDbAdapter.java +++ b/app/src/org/gnucash/android/db/AccountsDbAdapter.java @@ -269,12 +269,13 @@ public long getAccountID(String uid){ new String[] {DatabaseHelper.KEY_ROW_ID, DatabaseHelper.KEY_UID}, DatabaseHelper.KEY_UID + " = '" + uid + "'", null, null, null, null); long result = -1; - if (cursor != null && cursor.moveToFirst()){ - Log.v(TAG, "Returning account id"); - result = cursor.getLong(DatabaseAdapter.COLUMN_ROW_ID); - - cursor.close(); - } + if (cursor != null) { + if (cursor.moveToFirst()) { + Log.v(TAG, "Returning account id"); + result = cursor.getLong(DatabaseAdapter.COLUMN_ROW_ID); + } + cursor.close(); + } return result; } @@ -291,12 +292,13 @@ public String getParentAccountUID(String uid){ new String[]{uid}, null, null, null, null); String result = null; - if (cursor != null && cursor.moveToFirst()){ - Log.d(TAG, "Account already exists. Returning existing id"); - result = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseHelper.KEY_PARENT_ACCOUNT_UID)); - - cursor.close(); - } + if (cursor != null) { + if (cursor.moveToFirst()) { + Log.d(TAG, "Account already exists. Returning existing id"); + result = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseHelper.KEY_PARENT_ACCOUNT_UID)); + } + cursor.close(); + } return result; } @@ -320,10 +322,12 @@ public Account getAccount(long rowId){ Account account = null; Log.v(TAG, "Fetching account with id " + rowId); Cursor c = fetchRecord(DatabaseHelper.ACCOUNTS_TABLE_NAME, rowId); - if (c != null && c.moveToFirst()){ - account = buildAccountInstance(c); - c.close(); - } + if (c != null) { + if (c.moveToFirst()) { + account = buildAccountInstance(c); + } + c.close(); + } return account; } @@ -348,10 +352,12 @@ public String getAccountUID(long id){ new String[]{DatabaseHelper.KEY_ROW_ID, DatabaseHelper.KEY_UID}, DatabaseHelper.KEY_ROW_ID + "=" + id, null, null, null, null); - if (c != null && c.moveToFirst()){ - uid = c.getString(c.getColumnIndexOrThrow(DatabaseHelper.KEY_UID)); - c.close(); - } + if (c != null) { + if (c.moveToFirst()) { + uid = c.getString(c.getColumnIndexOrThrow(DatabaseHelper.KEY_UID)); + } + c.close(); + } return uid; } @@ -366,8 +372,10 @@ public String getAccountColorCode(long accountId){ new String[]{DatabaseHelper.KEY_ROW_ID, DatabaseHelper.KEY_COLOR_CODE}, DatabaseHelper.KEY_ROW_ID + "=" + accountId, null, null, null, null); - if (c != null && c.moveToFirst()){ - colorCode = c.getString(c.getColumnIndexOrThrow(DatabaseHelper.KEY_COLOR_CODE)); + if (c != null) { + if (c.moveToFirst()) { + colorCode = c.getString(c.getColumnIndexOrThrow(DatabaseHelper.KEY_COLOR_CODE)); + } c.close(); } return colorCode; @@ -399,10 +407,12 @@ public AccountType getAccountType(long accountId){ public String getName(long accountID) { String name = null; Cursor c = fetchRecord(DatabaseHelper.ACCOUNTS_TABLE_NAME, accountID); - if (c != null && c.moveToFirst()){ - name = c.getString(DatabaseAdapter.COLUMN_NAME); - c.close(); - } + if (c != null) { + if (c.moveToFirst()) { + name = c.getString(DatabaseAdapter.COLUMN_NAME); + } + c.close(); + } return name; } diff --git a/app/src/org/gnucash/android/ui/transaction/TransactionsActivity.java b/app/src/org/gnucash/android/ui/transaction/TransactionsActivity.java index fa16cd9b2..5b33acfa0 100644 --- a/app/src/org/gnucash/android/ui/transaction/TransactionsActivity.java +++ b/app/src/org/gnucash/android/ui/transaction/TransactionsActivity.java @@ -116,6 +116,11 @@ public class TransactionsActivity extends SherlockFragmentActivity implements */ private AccountsDbAdapter mAccountsDbAdapter; + /** + * Hold the accounts cursor that will be used in the Navigation + */ + private Cursor mAccountsCursor = null; + /** * This is the last known color for the title indicator. * This is used to remember the color of the top level account if the child account doesn't have one. @@ -348,11 +353,14 @@ private void setTitleIndicatorColor() { */ private void setupActionBarNavigation() { // set up spinner adapter for navigation list - Cursor accountsCursor = mAccountsDbAdapter.fetchAllRecordsOrderedByFullName(); + if (mAccountsCursor != null) { + mAccountsCursor.close(); + } + mAccountsCursor = mAccountsDbAdapter.fetchAllRecordsOrderedByFullName(); SpinnerAdapter mSpinnerAdapter = new QualifiedAccountNameCursorAdapter( getSupportActionBar().getThemedContext(), - R.layout.sherlock_spinner_item, accountsCursor); + R.layout.sherlock_spinner_item, mAccountsCursor); ((ResourceCursorAdapter) mSpinnerAdapter) .setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item); ActionBar actionBar = getSupportActionBar(); @@ -360,7 +368,7 @@ private void setupActionBarNavigation() { actionBar.setListNavigationCallbacks(mSpinnerAdapter, mTransactionListNavigationListener); actionBar.setDisplayHomeAsUpEnabled(true); - + updateNavigationSelection(); } @@ -449,6 +457,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { @Override protected void onDestroy() { super.onDestroy(); + mAccountsCursor.close(); mAccountsDbAdapter.close(); } diff --git a/app/src/org/gnucash/android/util/GnucashAccountXmlHandler.java b/app/src/org/gnucash/android/util/GnucashAccountXmlHandler.java index d82ed3b93..ed1e129a3 100644 --- a/app/src/org/gnucash/android/util/GnucashAccountXmlHandler.java +++ b/app/src/org/gnucash/android/util/GnucashAccountXmlHandler.java @@ -202,7 +202,7 @@ public static void parse(Context context, InputStream accountsInputStream){ GnucashAccountXmlHandler handler = new GnucashAccountXmlHandler(context); xr.setContentHandler(handler); xr.parse(new InputSource(bos)); - + handler.mDatabaseAdapter.close(); } catch (Exception e) { e.printStackTrace(); Toast.makeText(context, R.string.toast_error_importing_accounts, Toast.LENGTH_LONG).show(); From aa8cb4adc2666aad2b03db21764ee9d31312f720 Mon Sep 17 00:00:00 2001 From: Yongxin Wang Date: Sat, 10 May 2014 20:05:33 +0800 Subject: [PATCH 12/16] More resource leaks. One zh translation error. --- app/res/values-zh/strings.xml | 3 +-- .../org/gnucash/android/db/AccountsDbAdapter.java | 1 + .../org/gnucash/android/export/ExporterTask.java | 2 ++ .../gnucash/android/export/ofx/OfxExporter.java | 1 + .../android/ui/account/AccountFormFragment.java | 15 +++++++++++++-- .../ui/transaction/TransactionFormFragment.java | 5 +++++ 6 files changed, 23 insertions(+), 4 deletions(-) diff --git a/app/res/values-zh/strings.xml b/app/res/values-zh/strings.xml index b70d4f7f2..9dd96f6e5 100644 --- a/app/res/values-zh/strings.xml +++ b/app/res/values-zh/strings.xml @@ -46,7 +46,7 @@ 修改交易 备注 移动 - %1$d 已删除 + %1$d 已选中 合计: 导出到 导出交易资料 @@ -352,7 +352,6 @@ 默认的转账帐户 科目颜色和类型 - %d 子科目 %d 子科目 diff --git a/app/src/org/gnucash/android/db/AccountsDbAdapter.java b/app/src/org/gnucash/android/db/AccountsDbAdapter.java index 6a24938dd..db144a071 100644 --- a/app/src/org/gnucash/android/db/AccountsDbAdapter.java +++ b/app/src/org/gnucash/android/db/AccountsDbAdapter.java @@ -165,6 +165,7 @@ public boolean destructiveDeleteAccount(long rowId){ result &= mTransactionsAdapter.deleteRecord(id); } result &= deleteRecord(DatabaseHelper.ACCOUNTS_TABLE_NAME, rowId); + c.close(); return result; } diff --git a/app/src/org/gnucash/android/export/ExporterTask.java b/app/src/org/gnucash/android/export/ExporterTask.java index b322ee679..c8edf194a 100644 --- a/app/src/org/gnucash/android/export/ExporterTask.java +++ b/app/src/org/gnucash/android/export/ExporterTask.java @@ -169,6 +169,7 @@ protected void onPostExecute(Boolean exportResult) { android.support.v4.app.FragmentManager fragmentManager = ((FragmentActivity)mContext).getSupportFragmentManager(); Fragment currentFragment = fragmentManager .findFragmentByTag(AccountsActivity.FRAGMENT_ACCOUNTS_LIST); + TransactionsDeleteConfirmationDialogFragment alertFragment = TransactionsDeleteConfirmationDialogFragment.newInstance(R.string.title_confirm_delete, 0); alertFragment.setTargetFragment(currentFragment, 0); @@ -218,6 +219,7 @@ private void writeQifExternalStorage(String qif) throws IOException { writer.write(qif); writer.flush(); + writer.close(); } /** diff --git a/app/src/org/gnucash/android/export/ofx/OfxExporter.java b/app/src/org/gnucash/android/export/ofx/OfxExporter.java index 878c0c162..029ae6dc7 100644 --- a/app/src/org/gnucash/android/export/ofx/OfxExporter.java +++ b/app/src/org/gnucash/android/export/ofx/OfxExporter.java @@ -59,6 +59,7 @@ public OfxExporter(Context context, boolean exportAll) { mAccountsList = exportAll ? dbAdapter.getAllAccounts() : dbAdapter.getExportableAccounts(); mExportAll = exportAll; mContext = context; + dbAdapter.close(); } /** diff --git a/app/src/org/gnucash/android/ui/account/AccountFormFragment.java b/app/src/org/gnucash/android/ui/account/AccountFormFragment.java index f8a7aaee3..736ac0f56 100644 --- a/app/src/org/gnucash/android/ui/account/AccountFormFragment.java +++ b/app/src/org/gnucash/android/ui/account/AccountFormFragment.java @@ -80,6 +80,12 @@ public class AccountFormFragment extends SherlockFragment { * Accounts database adapter */ private AccountsDbAdapter mAccountsDbAdapter; + + /** + * Whether the AccountsDbAdapter is created inside this class. + * If so, it should be also closed by this class + */ + private boolean mReleaseDbAdapter = false; /** * List of all currency codes (ISO 4217) supported by the app @@ -191,6 +197,7 @@ public AccountFormFragment() { static public AccountFormFragment newInstance(AccountsDbAdapter dbAdapter){ AccountFormFragment f = new AccountFormFragment(); f.mAccountsDbAdapter = dbAdapter; + f.mReleaseDbAdapter = false; return f; } @@ -199,6 +206,7 @@ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true); if (mAccountsDbAdapter == null){ + mReleaseDbAdapter = true; mAccountsDbAdapter = new AccountsDbAdapter(getSherlockActivity()); } @@ -660,8 +668,11 @@ public void onDestroy() { super.onDestroyView(); if (mParentAccountCursor != null) mParentAccountCursor.close(); - //do not close the database adapter. We got it from the activity, - //the activity will take care of it. + // The mAccountsDbAdapter should only be closed when it is not passed in + // by other Activities. + if (mReleaseDbAdapter == true && mAccountsDbAdapter != null) { + mAccountsDbAdapter.close(); + } } private void saveAccount() { diff --git a/app/src/org/gnucash/android/ui/transaction/TransactionFormFragment.java b/app/src/org/gnucash/android/ui/transaction/TransactionFormFragment.java index 0c02bc20f..f777bba62 100644 --- a/app/src/org/gnucash/android/ui/transaction/TransactionFormFragment.java +++ b/app/src/org/gnucash/android/ui/transaction/TransactionFormFragment.java @@ -420,6 +420,9 @@ private void updateTransferAccountsList(){ + "' AND " + DatabaseHelper.KEY_PLACEHOLDER + " = 0" + ")"; + if (mCursor != null) { + mCursor.close(); + } mCursor = mAccountsDbAdapter.fetchAccountsOrderedByFullName(conditions); mCursorAdapter = new QualifiedAccountNameCursorAdapter(getActivity(), @@ -543,6 +546,8 @@ public void onAccountChanged(long newAccountId){ } updateTransferAccountsList(); + + accountsDbAdapter.close(); } /** From 9efeaa2028582260682c3ff89bc273ba34403072 Mon Sep 17 00:00:00 2001 From: Ngewi Fet Date: Sat, 10 May 2014 23:14:02 +0200 Subject: [PATCH 13/16] Fixed: Wrong caption for export dialog. --- app/res/values-de/strings.xml | 2 +- app/res/values-el/strings.xml | 2 +- app/res/values-es-rMX/strings.xml | 2 +- app/res/values-es/strings.xml | 2 +- app/res/values-fr/strings.xml | 2 +- app/res/values-hu/strings.xml | 2 +- app/res/values-it/strings.xml | 2 +- app/res/values-nb/strings.xml | 2 +- app/res/values-nl/strings.xml | 2 +- app/res/values-pt-rBR/strings.xml | 2 +- app/res/values-ru/strings.xml | 2 +- app/res/values-zh/strings.xml | 2 +- app/res/values/strings.xml | 2 +- app/src/org/gnucash/android/export/ExporterTask.java | 3 ++- 14 files changed, 15 insertions(+), 14 deletions(-) diff --git a/app/res/values-de/strings.xml b/app/res/values-de/strings.xml index 3856c7566..920efe757 100644 --- a/app/res/values-de/strings.xml +++ b/app/res/values-de/strings.xml @@ -65,7 +65,6 @@ %1$d Buchung(en) verschieben Zielkonto Zugriff auf SD-Kartenspeicher - OFX-Datei senden mit… Buchungen könnten nicht verschoben werden.\Die Währung des Zielkontos ist inkompatibel Allgemein Über GnuCash @@ -395,4 +394,5 @@ MONATLICH Eingeplante Buchungen + Select destination for export diff --git a/app/res/values-el/strings.xml b/app/res/values-el/strings.xml index 39a35470b..762d8e5a0 100644 --- a/app/res/values-el/strings.xml +++ b/app/res/values-el/strings.xml @@ -66,7 +66,6 @@ Μετακίνησε %1$d συναλλαγή(ες) Λογιαριασμός Προορισμού Πρόσβαση κάρτας SD - Μοίρασμα εξαγωγής OFX με… Αδυναμία μετακίνησης συναλλαγών.\nΟ λογαριασμός προορισμού χρησιμοποιεί διαφορετικό νόμισμα από το λογαριασμό προέλευσης Γενικές Πληροφορίες @@ -413,4 +412,5 @@ ΜΗΝΙΑΙΑ
Προγραμματισμένες Κινήσεις + Select destination for export diff --git a/app/res/values-es-rMX/strings.xml b/app/res/values-es-rMX/strings.xml index 600c4cb82..67f48e752 100644 --- a/app/res/values-es-rMX/strings.xml +++ b/app/res/values-es-rMX/strings.xml @@ -66,7 +66,6 @@ Mover %1$d transaccion(es) Cuenta destino Acceder tarjeta SD - Share OFX export with… No se pueden mover las transacciones.\nLa cuenta destino usa una moneda diferente a la cuenta de origen General Acerca de @@ -398,4 +397,5 @@ Scheduled Transactions Scheduled Transactions + Select destination for export diff --git a/app/res/values-es/strings.xml b/app/res/values-es/strings.xml index d6c754b94..45c2d80f1 100644 --- a/app/res/values-es/strings.xml +++ b/app/res/values-es/strings.xml @@ -66,7 +66,6 @@ Mover %1$d transacción(es) Cuenta Destino Acceder a la tarjeta SD - Compartir exportación OFX con… No se pueden mover las transacciones.\nLa cuenta destino utiliza una divisa distinta a la de la cuenta de origen General Acerca de @@ -395,4 +394,5 @@ Scheduled Transactions Scheduled Transactions + Select destination for export diff --git a/app/res/values-fr/strings.xml b/app/res/values-fr/strings.xml index 088c51a61..725607fdf 100644 --- a/app/res/values-fr/strings.xml +++ b/app/res/values-fr/strings.xml @@ -66,7 +66,6 @@ Déplacer %1$d transaction(s) Compte de destination Accés carte SD - Partager l\'export en OFX avec… Impossible de déplacer les transactions.\nLe compte de destination utilise une monnaie différente du compte d\'origine Général À propos @@ -395,4 +394,5 @@ Transactions planifiées Transactions planifiées + Select destination for export \ No newline at end of file diff --git a/app/res/values-hu/strings.xml b/app/res/values-hu/strings.xml index 2205af8c5..ea1be4102 100644 --- a/app/res/values-hu/strings.xml +++ b/app/res/values-hu/strings.xml @@ -65,7 +65,6 @@ Move %1$d transaction(s) Destination Account Access SD Card - Share OFX export with… Cannot move transactions.\nThe destination account uses a different currency from origin account General About @@ -397,4 +396,5 @@ MONTHLY Scheduled Transactions + Select destination for export \ No newline at end of file diff --git a/app/res/values-it/strings.xml b/app/res/values-it/strings.xml index 82aa4c51f..280cd67b4 100644 --- a/app/res/values-it/strings.xml +++ b/app/res/values-it/strings.xml @@ -66,7 +66,6 @@ Sposta %1$d transazioni Conto di destinazione Accedi alla scheda SD - Condividi l\'esportazione OFX con… Impossibile spostare le transazioni.\nIl conto di destinazione ha una valuta diversa dal conto di origine Generali Informazioni @@ -399,4 +398,5 @@ Scheduled Transactions Scheduled Transactions + Select destination for export diff --git a/app/res/values-nb/strings.xml b/app/res/values-nb/strings.xml index 4db72c565..98cffaff6 100644 --- a/app/res/values-nb/strings.xml +++ b/app/res/values-nb/strings.xml @@ -67,7 +67,6 @@ Flytt %1$d transaksjoner Til konto Aksesser minnekort - Del OFX-eksport med… Kan ikke flytte transaksjonen(e).\nMottakerkonto har en annen valuta Generelt Om @@ -398,4 +397,5 @@ format og importeres i regnskapsprogrammet GnuCash for PC. Scheduled Transactions Scheduled Transactions + Select destination for export diff --git a/app/res/values-nl/strings.xml b/app/res/values-nl/strings.xml index c8f6b76e2..dc7711a5d 100644 --- a/app/res/values-nl/strings.xml +++ b/app/res/values-nl/strings.xml @@ -66,7 +66,6 @@ %1$d transactie(s) verplaatsen Bestemmingsrekening SD kaart benaderen - OFX data verzenden via… Transacties kunnen niet verplaatst worden.\nDe munteenheden van de rekeningen zijn niet compatibel Algemeen Over @@ -400,4 +399,5 @@ Vaste journaalposten Vaste journaalposten + Select destination for export diff --git a/app/res/values-pt-rBR/strings.xml b/app/res/values-pt-rBR/strings.xml index a4e73d03c..54b9a1efa 100644 --- a/app/res/values-pt-rBR/strings.xml +++ b/app/res/values-pt-rBR/strings.xml @@ -65,7 +65,6 @@ Mover %1$d transação(ões) Conta de destino Acessar cartão SD - Compartilhar OFX exportado com… Não é possível mover as transações. \nA conta de destino usa uma moeda padrão diferente da moeda usada pela conta de origem. Geral Sobre @@ -398,4 +397,5 @@ Scheduled Transactions Scheduled Transactions + Select destination for export diff --git a/app/res/values-ru/strings.xml b/app/res/values-ru/strings.xml index 531eab1a7..023d9fc64 100644 --- a/app/res/values-ru/strings.xml +++ b/app/res/values-ru/strings.xml @@ -66,7 +66,6 @@ Перенести %1$d проводк(у,и,ок) Счёт-получатель Доступ к карте памяти - Отправить OFX… Невозможно перенести проводки.\nСчёт-получатель использует другую валюту. Общие О программе @@ -399,4 +398,5 @@ Scheduled Transactions Scheduled Transactions + Select destination for export diff --git a/app/res/values-zh/strings.xml b/app/res/values-zh/strings.xml index b70d4f7f2..e1ec099fa 100644 --- a/app/res/values-zh/strings.xml +++ b/app/res/values-zh/strings.xml @@ -65,7 +65,6 @@ 移动 %1$d 交易 目的科目 访问 SD Card - 发送OFX到 不能移动交易。\n两个科目的货币设置不一样。 常规 关于 @@ -394,4 +393,5 @@ 每月 计划的交易 + Select destination for export diff --git a/app/res/values/strings.xml b/app/res/values/strings.xml index a75ee62cd..704ef1037 100644 --- a/app/res/values/strings.xml +++ b/app/res/values/strings.xml @@ -66,7 +66,6 @@ Move %1$d transaction(s) Destination Account Access SD Card - Share OFX export with… default_currency Cannot move transactions.\nThe destination account uses a different currency from origin account General @@ -629,4 +628,5 @@ available in app Settings so you can decide later. Scheduled Transactions + Select destination for export diff --git a/app/src/org/gnucash/android/export/ExporterTask.java b/app/src/org/gnucash/android/export/ExporterTask.java index b322ee679..dcd1b32fb 100644 --- a/app/src/org/gnucash/android/export/ExporterTask.java +++ b/app/src/org/gnucash/android/export/ExporterTask.java @@ -268,7 +268,8 @@ private void shareFile(String path){ shareIntent.putExtra(Intent.EXTRA_TEXT, mContext.getString(R.string.description_export_email) + " " + formatter.format(new Date(System.currentTimeMillis()))); - mContext.startActivity(Intent.createChooser(shareIntent, mContext.getString(R.string.title_share_ofx_with))); + + mContext.startActivity(Intent.createChooser(shareIntent, mContext.getString(R.string.title_select_export_destination))); } /** From 8c95f3b764d406fe79b4f7d89fcf336e73f1913a Mon Sep 17 00:00:00 2001 From: Ngewi Fet Date: Sat, 10 May 2014 23:42:17 +0200 Subject: [PATCH 14/16] Updated version numbers for next minor release (1.3.2-beta2) --- CHANGELOG.md | 3 ++- app/AndroidManifest.xml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2850321f..d00a7e331 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,12 @@ Change Log =============================================================================== -Version 1.3.2 *(2014-03-28)* +Version 1.3.2 *(2014-05-15)* ---------------------------- * Fixed: Editing account modifies the transaction type of transfer transactions * Fixed: Bug causing double entry transactions not to be considered equal * Fixed: Computation of account balance did not properly consider double entries * Improved: Double-entry accounting is now activated by default +* Improved: Reliability of account structure import * Improved: Restricted parent/child account hierarchies relationships to those defined by GnuCash accounting * Improved: Dutch translation * Improved: German translation diff --git a/app/AndroidManifest.xml b/app/AndroidManifest.xml index 5dbebd33a..45184fdb4 100644 --- a/app/AndroidManifest.xml +++ b/app/AndroidManifest.xml @@ -17,7 +17,7 @@ From 5827d61e7b13babf0ea39cf3095aa7fecf25e675 Mon Sep 17 00:00:00 2001 From: Yongxin Wang Date: Sun, 11 May 2014 22:35:58 +0800 Subject: [PATCH 15/16] Refresh after transactions are exported and deleted. --- app/src/org/gnucash/android/export/ExporterTask.java | 3 +-- .../org/gnucash/android/ui/account/AccountFormFragment.java | 3 +++ app/src/org/gnucash/android/ui/account/AccountsActivity.java | 5 +++++ .../dialog/TransactionsDeleteConfirmationDialogFragment.java | 1 + 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/org/gnucash/android/export/ExporterTask.java b/app/src/org/gnucash/android/export/ExporterTask.java index 7a60466c3..3008e6034 100644 --- a/app/src/org/gnucash/android/export/ExporterTask.java +++ b/app/src/org/gnucash/android/export/ExporterTask.java @@ -167,8 +167,7 @@ protected void onPostExecute(Boolean exportResult) { if (mExportParams.shouldDeleteTransactionsAfterExport()){ android.support.v4.app.FragmentManager fragmentManager = ((FragmentActivity)mContext).getSupportFragmentManager(); - Fragment currentFragment = fragmentManager - .findFragmentByTag(AccountsActivity.FRAGMENT_ACCOUNTS_LIST); + Fragment currentFragment = ((AccountsActivity)mContext).getCurrentAccountListFragment(); TransactionsDeleteConfirmationDialogFragment alertFragment = TransactionsDeleteConfirmationDialogFragment.newInstance(R.string.title_confirm_delete, 0); diff --git a/app/src/org/gnucash/android/ui/account/AccountFormFragment.java b/app/src/org/gnucash/android/ui/account/AccountFormFragment.java index 736ac0f56..ea2accc9d 100644 --- a/app/src/org/gnucash/android/ui/account/AccountFormFragment.java +++ b/app/src/org/gnucash/android/ui/account/AccountFormFragment.java @@ -673,6 +673,9 @@ public void onDestroy() { if (mReleaseDbAdapter == true && mAccountsDbAdapter != null) { mAccountsDbAdapter.close(); } + if (mDefaultTransferAccountCursorAdapter != null) { + mDefaultTransferAccountCursorAdapter.getCursor().close(); + } } private void saveAccount() { diff --git a/app/src/org/gnucash/android/ui/account/AccountsActivity.java b/app/src/org/gnucash/android/ui/account/AccountsActivity.java index c83147fc4..471dcbb26 100644 --- a/app/src/org/gnucash/android/ui/account/AccountsActivity.java +++ b/app/src/org/gnucash/android/ui/account/AccountsActivity.java @@ -205,6 +205,11 @@ public int getCount() { } } + public AccountsListFragment getCurrentAccountListFragment(){ + int index = mPager.getCurrentItem(); + return (AccountsListFragment)(mFragmentPageReferenceMap.get(index)); + } + @Override public void onCreate(Bundle savedInstanceState) { diff --git a/app/src/org/gnucash/android/ui/transaction/dialog/TransactionsDeleteConfirmationDialogFragment.java b/app/src/org/gnucash/android/ui/transaction/dialog/TransactionsDeleteConfirmationDialogFragment.java index e80b184a3..4c1d154e3 100644 --- a/app/src/org/gnucash/android/ui/transaction/dialog/TransactionsDeleteConfirmationDialogFragment.java +++ b/app/src/org/gnucash/android/ui/transaction/dialog/TransactionsDeleteConfirmationDialogFragment.java @@ -62,6 +62,7 @@ public void onClick(DialogInterface dialog, int whichButton) { } else { adapter.deleteRecord(rowId); } + adapter.close(); if (getTargetFragment() instanceof AccountsListFragment){ ((AccountsListFragment)getTargetFragment()).refresh(); } From b24e520f55e1469cc6f3d520eff638b225f5f72f Mon Sep 17 00:00:00 2001 From: Ngewi Fet Date: Fri, 23 May 2014 22:58:43 +0200 Subject: [PATCH 16/16] Updated release date in CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d00a7e331..40122bae3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ Change Log =============================================================================== -Version 1.3.2 *(2014-05-15)* +Version 1.3.2 *(2014-05-23)* ---------------------------- * Fixed: Editing account modifies the transaction type of transfer transactions * Fixed: Bug causing double entry transactions not to be considered equal