Skip to content

Commit a88bd22

Browse files
committed
Fixes #556 - If currency exchange dialog is opened during transaction save, immediately resume the save operation after the dialog is closed.
Removes the need for the user to manually restart the save process
1 parent 56384db commit a88bd22

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

app/src/androidTest/java/org/gnucash/android/test/ui/TransactionsActivityTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,6 @@ public void testAddMultiCurrencyTransaction(){
309309
Espresso.closeSoftKeyboard();
310310
onView(withId(R.id.btn_save)).perform(click());
311311

312-
onView(withId(R.id.menu_save)).perform(click());
313-
314312
List<Transaction> allTransactions = mTransactionsDbAdapter.getAllTransactionsForAccount(TRANSACTIONS_ACCOUNT_UID);
315313
assertThat(allTransactions).hasSize(transactionCount+1);
316314
Transaction multiTrans = allTransactions.get(0);

app/src/main/java/org/gnucash/android/ui/transaction/TransactionFormFragment.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,13 @@ public class TransactionFormFragment extends Fragment implements
235235

236236
private boolean mEditMode = false;
237237

238+
/**
239+
* Flag which is set if another action is triggered during a transaction save (which interrrupts the save process).
240+
* Allows the fragment to check and resume the save operation.
241+
* Primarily used for multicurrency transactions when the currency transfer dialog is opened during save
242+
*/
243+
private boolean onSaveAttempt = false;
244+
238245
/**
239246
* Split quantity which will be set from the funds transfer dialog
240247
*/
@@ -828,6 +835,7 @@ private void saveNewTransaction() {
828835
//determine whether we need to do currency conversion
829836

830837
if (isMultiCurrencyTransaction() && !splitEditorUsed() && !mCurrencyConversionDone){
838+
onSaveAttempt = true;
831839
startTransferFunds();
832840
return;
833841
}
@@ -1034,6 +1042,11 @@ public static String stripCurrencyFormatting(String s){
10341042
public void transferComplete(Money amount) {
10351043
mCurrencyConversionDone = true;
10361044
mSplitQuantity = amount;
1045+
1046+
//The transfer dialog was called while attempting to save. So try saving again
1047+
if (onSaveAttempt)
1048+
saveNewTransaction();
1049+
onSaveAttempt = false;
10371050
}
10381051

10391052
@Override

0 commit comments

Comments
 (0)