@@ -209,7 +209,7 @@ public void onActivityCreated(Bundle savedInstanceState) {
209209 actionBar .setDisplayShowTitleEnabled (false );
210210
211211 SharedPreferences sharedPrefs = PreferenceManager .getDefaultSharedPreferences (getActivity ());
212- mUseDoubleEntry = sharedPrefs .getBoolean (getString (R .string .key_use_double_entry ), true );
212+ mUseDoubleEntry = sharedPrefs .getBoolean (getString (R .string .key_use_double_entry ), false );
213213 if (!mUseDoubleEntry ){
214214 getView ().findViewById (R .id .layout_double_entry ).setVisibility (View .GONE );
215215 mOpenSplitsButton .setVisibility (View .GONE );
@@ -306,7 +306,9 @@ public void onItemClick(AdapterView<?> adapterView, View view, int position, lon
306306 mSplitsList .clear ();
307307 setAmountEditViewVisible (View .VISIBLE );
308308 } else {
309- setAmountEditViewVisible (View .GONE );
309+ if (mUseDoubleEntry ) { //don't hide the view in single entry mode
310+ setAmountEditViewVisible (View .GONE );
311+ }
310312 }
311313 }
312314 mTransaction = null ; //we are creating a new transaction after all
@@ -346,7 +348,7 @@ private void initializeViewsWithTransaction(){
346348 } else {
347349 for (Split split : mTransaction .getSplits ()) {
348350 //two splits, one belongs to this account and the other to another account
349- if (!split .getAccountUID ().equals (accountUID )) {
351+ if (mUseDoubleEntry && !split .getAccountUID ().equals (accountUID )) {
350352 setSelectedTransferAccount (mAccountsDbAdapter .getAccountID (split .getAccountUID ()));
351353 }
352354 }
@@ -593,15 +595,30 @@ private void saveNewTransaction() {
593595
594596 if (mTransaction != null ){
595597 if (!mUseDoubleEntry ){
598+ //first remove old splits for this transaction, since there is only one split
599+ SplitsDbAdapter splitsDbAdapter = new SplitsDbAdapter (getActivity ());
600+ for (Split split : mTransaction .getSplits ()) {
601+ splitsDbAdapter .deleteSplit (split .getUID ());
602+ }
603+ splitsDbAdapter .close ();
604+
596605 Split split = new Split (amount , accountUID );
597606 split .setType (mTransactionTypeButton .getTransactionType ());
598607 mTransaction .getSplits ().clear ();
599608 mTransaction .addSplit (split );
600- } else
609+ } else {
601610 mTransaction .setSplits (mSplitsList );
611+ }
602612 mTransaction .setDescription (description );
603613 } else {
604614 mTransaction = new Transaction (description );
615+ if (!mUseDoubleEntry ){
616+ Split split = new Split (amount , accountUID );
617+ split .setType (mTransactionTypeButton .getTransactionType ());
618+ mSplitsList .clear ();
619+ mSplitsList .add (split );
620+ }
621+
605622 if (mSplitsList .isEmpty ()) { //amount entered in the simple interface (not using splits Editor)
606623 Split split = new Split (amount , accountUID );
607624 split .setType (mTransactionTypeButton .getTransactionType ());
@@ -707,8 +724,7 @@ public void setSplitList(List<Split> splitList, List<String> removedSplitUIDs){
707724 //once we set the split list, do not allow direct editing of the total
708725 if (mSplitsList .size () > 1 ){
709726 mAmountEditText .setEnabled (false );
710- mTransactionTypeButton .setVisibility (View .GONE );
711- getView ().findViewById (R .id .layout_double_entry ).setVisibility (View .GONE );
727+ setAmountEditViewVisible (View .GONE );
712728 }
713729
714730 SplitsDbAdapter splitsDbAdapter = new SplitsDbAdapter (getActivity ());
0 commit comments