Skip to content

Commit 33cbcdc

Browse files
committed
Merge branch 'develop'
2 parents 6311e55 + 7ac7865 commit 33cbcdc

File tree

16 files changed

+150
-81
lines changed

16 files changed

+150
-81
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
Change Log
22
===============================================================================
3+
Version 1.4.1 *(2014-08-25)*
4+
----------------------------
5+
* Fixed: Transaction edits not saved
6+
* Fixed: Crash during import due to template transactions
7+
* Fixed: Cursors potentially left unclosed
8+
* Fixed: Fatal crash when error occurs in importing/exporting transaction (instead of displaying error message)
9+
* Fixed: Editing a transfer transaction does not edit other side of the transaction
10+
* Removed progress dialog from database migration (seems to be cause of some crashes)
11+
* Updated German translation
12+
313
Version 1.4.0 *(2014-08-15)*
414
----------------------------
515
Since transactions are at the core of this app, this release touches almost all subsystems and is therefore huge.

app/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
1919
package="org.gnucash.android"
20-
android:versionCode="36"
20+
android:versionCode="37"
2121
android:versionName="@string/app_version_name" >
2222

2323
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16"/>

app/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<description>Gnucash Android companion application</description>
2323

2424
<parent>
25-
<version>1.4.0-SNAPSHOT</version>
25+
<version>1.4.1-SNAPSHOT</version>
2626
<groupId>org.gnucash.android</groupId>
2727
<artifactId>gnucash-android-parent</artifactId>
2828
</parent>

app/res/values-de/strings.xml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -391,29 +391,29 @@
391391
<item>MONATLICH</item>
392392
</string-array>
393393
<string name="title_scheduled_transactions">Eingeplante Buchungen</string>
394-
<string name="title_select_export_destination">Select destination for export</string>
395-
<string name="hint_split_memo">Memo</string>
396-
<string name="label_spend">Spend</string>
397-
<string name="label_receive">Receive</string>
398-
<string name="label_withdrawal">Withdrawal</string>
399-
<string name="label_deposit">Deposit</string>
400-
<string name="label_payment">Payment</string>
401-
<string name="label_charge">Charge</string>
402-
<string name="label_decrease">Decrease</string>
403-
<string name="label_increase">Increase</string>
404-
<string name="label_income">Income</string>
405-
<string name="label_rebate">Rebate</string>
406-
<string name="label_expense">Expense</string>
407-
<string name="label_bill">Bill</string>
408-
<string name="label_invoice">Invoice</string>
409-
<string name="label_buy">Buy</string>
410-
<string name="label_sell">Sell</string>
411-
<string name="label_repeats">Repeats</string>
412-
<string name="label_account_balance">Balance:</string>
413-
<string name="toast_no_recent_backup">No recent backup found</string>
394+
<string name="title_select_export_destination">Exportziel auswählen</string>
395+
<string name="hint_split_memo">Buchungstext</string>
396+
<string name="label_spend">Ausgabe</string>
397+
<string name="label_receive">Einnahme</string>
398+
<string name="label_withdrawal">Abhebung</string>
399+
<string name="label_deposit">Einzahlung</string>
400+
<string name="label_payment">Zahlung</string>
401+
<string name="label_charge">Gebühr</string>
402+
<string name="label_decrease">Abnahme</string>
403+
<string name="label_increase">Zunahme</string>
404+
<string name="label_income">Ertrag</string>
405+
<string name="label_rebate">Rabatt</string>
406+
<string name="label_expense">Aufwand</string>
407+
<string name="label_bill">Rechnung</string>
408+
<string name="label_invoice">Rechnung</string>
409+
<string name="label_buy">Kauf</string>
410+
<string name="label_sell">Verkauf</string>
411+
<string name="label_repeats">Wiederholungen</string>
412+
<string name="label_account_balance">Saldo:</string>
413+
<string name="toast_no_recent_backup">Keine Sicherheitskopie vorhanden</string>
414414
<string name="account_name_opening_balances">Anfangsbestand</string>
415415
<string name="account_name_equity"> </string> <!-- This is no error, the default German locale has no parent Equity account -->
416-
<string name="summary_save_opening_balances">Enable to save the current account balance (before deleting transactions) as new opening balance after deleting transactions
416+
<string name="summary_save_opening_balances">Möglichkeit aktivieren, den aktuellen Saldo als neuen Anfangsbestand nach dem Löschen der Buchungen zu übernehmen
417417
</string>
418-
<string name="title_save_opening_balances">Save account opening balances</string>
418+
<string name="title_save_opening_balances">Saldo als neuen Anfangsbestand übernehmen</string>
419419
</resources>

app/res/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
1919
<string name="app_name">GnuCash</string>
20-
<string name="app_version_name">1.4.0</string>
20+
<string name="app_version_name">1.4.1</string>
2121
<string name="title_add_account">Create Account</string>
2222
<string name="title_edit_account">Edit Account</string>
2323
<string name="info_details">Info</string>

app/src/org/gnucash/android/db/AccountsDbAdapter.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -651,11 +651,11 @@ public List<Long> getSubAccountIds(long accountId){
651651
*/
652652
public Cursor fetchSubAccounts(long accountId){
653653
Log.v(TAG, "Fetching sub accounts for account id " + accountId);
654+
String accountUID = getAccountUID(accountId);
654655
return mDb.query(AccountEntry.TABLE_NAME,
655656
null,
656-
AccountEntry.COLUMN_PARENT_ACCOUNT_UID + " = ?",
657-
new String[]{getAccountUID(accountId)},
658-
null, null, AccountEntry.COLUMN_NAME + " ASC");
657+
AccountEntry.COLUMN_PARENT_ACCOUNT_UID + " = '" + accountUID + "'",
658+
null, null, null, AccountEntry.COLUMN_NAME + " ASC");
659659
}
660660

661661
/**
@@ -736,8 +736,10 @@ public String getGnuCashRootAccountUID(){
736736
String condition = AccountEntry.COLUMN_TYPE + "= '" + AccountType.ROOT.name() + "'";
737737
Cursor cursor = fetchAccounts(condition);
738738
String rootUID = null;
739-
if (cursor != null && cursor.moveToFirst()){
740-
rootUID = cursor.getString(cursor.getColumnIndexOrThrow(AccountEntry.COLUMN_UID));
739+
if (cursor != null) {
740+
if (cursor.moveToFirst()) {
741+
rootUID = cursor.getString(cursor.getColumnIndexOrThrow(AccountEntry.COLUMN_UID));
742+
}
741743
cursor.close();
742744
}
743745
return rootUID;

app/src/org/gnucash/android/db/DatabaseHelper.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,6 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
127127
Log.i(LOG_TAG, "Upgrading database from version "
128128
+ oldVersion + " to " + newVersion);
129129

130-
ProgressDialog progressDialog = ProgressDialog.show(mContext, "Upgrading database", "Processing...", true);
131-
132130
if (oldVersion < newVersion){
133131
//introducing double entry accounting
134132
Log.i(LOG_TAG, "Upgrading database to version " + newVersion);
@@ -194,7 +192,6 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
194192

195193
if (oldVersion == 5 && newVersion >= 6){
196194
Log.i(LOG_TAG, "Upgrading database to version 6");
197-
progressDialog.setMessage("Upgrading database to version 6");
198195

199196
String addFullAccountNameQuery = " ALTER TABLE " + AccountEntry.TABLE_NAME
200197
+ " ADD COLUMN " + AccountEntry.COLUMN_FULL_NAME + " varchar(255) ";
@@ -227,7 +224,6 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
227224

228225
if (oldVersion == 6 && newVersion >= DatabaseSchema.SPLITS_DB_VERSION){
229226
Log.i(LOG_TAG, "Upgrading database to version 7");
230-
progressDialog.setMessage("Upgrading to version " + SPLITS_DB_VERSION);
231227

232228
//for users who do not have double-entry activated, we create imbalance accounts for their splits
233229
//TODO: Enable when we can hide imbalance accounts from user
@@ -237,17 +233,12 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
237233
// accountsDbAdapter.getOrCreateImbalanceAccountUID(currency);
238234
// }
239235

240-
progressDialog.setMessage("Backing up database");
241236
try {
242237
String filepath = MigrationHelper.exportDatabase(db, ExportFormat.GNC_XML);
243238

244-
progressDialog.setMessage("Upgrading database schema");
245-
246239
dropAllDatabaseTables(db);
247240
createDatabaseTables(db);
248241

249-
progressDialog.setMessage("Restoring database");
250-
251242
MigrationHelper.importGnucashXML(db, filepath);
252243
} catch (Exception e){
253244
Toast.makeText(mContext, "Error upgrading database.\n" + e.getMessage(), Toast.LENGTH_LONG).show();
@@ -257,7 +248,6 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
257248
}
258249
}
259250

260-
progressDialog.dismiss();
261251
if (oldVersion != newVersion) {
262252
Log.w(LOG_TAG, "Upgrade for the database failed. The Database is currently at version " + oldVersion);
263253
}

app/src/org/gnucash/android/db/SplitsDbAdapter.java

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,22 @@ public Split buildSplitInstance(Cursor cursor){
114114
* @return {@link org.gnucash.android.model.Split} instance
115115
*/
116116
public Split getSplit(String uid){
117-
long id = getID(uid);
117+
return getSplit(getID(uid));
118+
}
119+
120+
/**
121+
* Returns the Split instance given the database id
122+
* @param id Database record ID of the split
123+
* @return {@link org.gnucash.android.model.Split} instance
124+
*/
125+
public Split getSplit(long id){
118126
Cursor cursor = fetchRecord(id);
119127

120128
Split split = null;
121-
if (cursor != null && cursor.moveToFirst()){
122-
split = buildSplitInstance(cursor);
129+
if (cursor != null) {
130+
if (cursor.moveToFirst()) {
131+
split = buildSplitInstance(cursor);
132+
}
123133
cursor.close();
124134
}
125135
return split;
@@ -233,14 +243,18 @@ public Cursor fetchSplits(String condition, String sortOrder){
233243
* @return Database record ID of split
234244
*/
235245
public long getID(String uid){
246+
if (uid == null)
247+
return 0;
248+
236249
Cursor cursor = mDb.query(SplitEntry.TABLE_NAME,
237250
new String[] {SplitEntry._ID},
238251
SplitEntry.COLUMN_UID + " = ?", new String[]{uid}, null, null, null);
239252
long result = -1;
240-
if (cursor != null && cursor.moveToFirst()){
241-
Log.d(TAG, "Transaction already exists. Returning existing id");
242-
result = cursor.getLong(cursor.getColumnIndexOrThrow(SplitEntry._ID));
243-
253+
if (cursor != null){
254+
if (cursor.moveToFirst()) {
255+
Log.d(TAG, "Transaction already exists. Returning existing id");
256+
result = cursor.getLong(cursor.getColumnIndexOrThrow(SplitEntry._ID));
257+
}
244258
cursor.close();
245259
}
246260
return result;
@@ -336,8 +350,11 @@ public String getTransactionUID(long transactionId){
336350
null, null, null, null);
337351

338352
String trxUID = null;
339-
if (cursor != null && cursor.moveToFirst()){
340-
trxUID = cursor.getString(cursor.getColumnIndexOrThrow(TransactionEntry.COLUMN_UID));
353+
if (cursor != null) {
354+
if (cursor.moveToFirst()) {
355+
trxUID = cursor.getString(cursor.getColumnIndexOrThrow(TransactionEntry.COLUMN_UID));
356+
}
357+
cursor.close();
341358
}
342359

343360
return trxUID;
@@ -355,9 +372,13 @@ public Cursor fetchAllRecords() {
355372

356373
@Override
357374
public boolean deleteRecord(long rowId) {
358-
String transactionUID = getSplit(getUID(rowId)).getTransactionUID();
375+
Split split = getSplit(rowId);
376+
String transactionUID = split == null ? null : split.getTransactionUID();
359377
boolean result = deleteRecord(SplitEntry.TABLE_NAME, rowId);
360378

379+
if (!result) //we didn't delete for whatever reason, invalid rowId etc
380+
return false;
381+
361382
//if we just deleted the last split, then remove the transaction from db
362383
Cursor cursor = fetchSplitsForTransaction(transactionUID);
363384
if (cursor != null){
@@ -376,6 +397,9 @@ public boolean deleteRecord(long rowId) {
376397
*/
377398
public long getTransactionID(String transactionUID){
378399
long id = -1;
400+
if (transactionUID == null)
401+
return id;
402+
379403
Cursor c = mDb.query(TransactionEntry.TABLE_NAME,
380404
new String[]{TransactionEntry._ID},
381405
TransactionEntry.COLUMN_UID + "=?",

app/src/org/gnucash/android/export/ExporterAsyncTask.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.gnucash.android.export;
1818

19+
import android.app.Activity;
1920
import android.app.ProgressDialog;
2021
import android.content.Context;
2122
import android.content.Intent;
@@ -48,7 +49,7 @@ public class ExporterAsyncTask extends AsyncTask<ExportParams, Void, Boolean> {
4849
/**
4950
* App context
5051
*/
51-
private final Context mContext;
52+
private final Activity mContext;
5253

5354
private ProgressDialog mProgressDialog;
5455

@@ -62,7 +63,7 @@ public class ExporterAsyncTask extends AsyncTask<ExportParams, Void, Boolean> {
6263
*/
6364
private ExportParams mExportParams;
6465

65-
public ExporterAsyncTask(Context context){
66+
public ExporterAsyncTask(Activity context){
6667
this.mContext = context;
6768
}
6869

@@ -110,9 +111,15 @@ protected Boolean doInBackground(ExportParams... params) {
110111
} catch (Exception e) {
111112
e.printStackTrace();
112113
Log.e(TAG, e.getMessage());
113-
Toast.makeText(mContext, R.string.toast_export_error,
114-
Toast.LENGTH_SHORT).show();
115-
Toast.makeText(mContext, e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
114+
final String err_msg = e.getLocalizedMessage();
115+
mContext.runOnUiThread(new Runnable() {
116+
@Override
117+
public void run() {
118+
Toast.makeText(mContext, R.string.toast_export_error,
119+
Toast.LENGTH_SHORT).show();
120+
Toast.makeText(mContext, err_msg, Toast.LENGTH_LONG).show();
121+
}
122+
});
116123
return false;
117124
}
118125
return true;

app/src/org/gnucash/android/export/xml/GncXmlHelper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public abstract class GncXmlHelper {
6060
public static final String TAG_TRN_SPLITS = "trn:splits";
6161
public static final String TAG_TRN_SPLIT = "trn:split";
6262
public static final String TAG_TRN_SLOTS = "trn:slots";
63+
public static final String TAG_TEMPLATE_TRANSACTION = "gnc:template-transactions";
6364

6465
public static final String TAG_SPLIT_ID = "split:id";
6566
public static final String TAG_SPLIT_MEMO = "split:memo";

0 commit comments

Comments
 (0)