Skip to content

Commit ccf6cb8

Browse files
committed
Fixed: unable to edit transactions in double entry mode
Improved: Long press on transactions now triggers context menu
1 parent 13dd668 commit ccf6cb8

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,10 @@ private void initializeViewsWithTransaction(){
350350
cal.setTimeInMillis(mTransaction.getTimeMillis());
351351
mDate = mTime = cal;
352352

353+
//TODO: deep copy the split list. We need a copy so we can modify with impunity
354+
mSplitsList = new ArrayList<Split>(mTransaction.getSplits());
355+
mAmountEditText.setEnabled(mSplitsList.size() <= 2);
356+
353357
//if there are more than two splits (which is the default for one entry), then
354358
//disable editing of the transfer account. User should open editor
355359
if (mSplitsList.size() == 2 && mSplitsList.get(0).isPairOf(mSplitsList.get(1))) {
@@ -364,8 +368,6 @@ private void initializeViewsWithTransaction(){
364368
setAmountEditViewVisible(View.GONE);
365369
}
366370
}
367-
mSplitsList = new ArrayList<Split>(mTransaction.getSplits()); //we need a copy so we can modify with impunity
368-
mAmountEditText.setEnabled(mSplitsList.size() <= 2);
369371

370372
String currencyCode = mTransactionsDbAdapter.getCurrencyCode(mAccountUID);
371373
Currency accountCurrency = Currency.getInstance(currencyCode);

app/src/org/gnucash/android/ui/transaction/TransactionsListFragment.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,8 @@
3535
import android.view.TouchDelegate;
3636
import android.view.View;
3737
import android.view.ViewGroup;
38-
import android.widget.CheckBox;
39-
import android.widget.CompoundButton;
38+
import android.widget.*;
4039
import android.widget.CompoundButton.OnCheckedChangeListener;
41-
import android.widget.ListView;
42-
import android.widget.TextView;
4340
import com.actionbarsherlock.app.ActionBar;
4441
import com.actionbarsherlock.app.SherlockListFragment;
4542
import com.actionbarsherlock.view.ActionMode;
@@ -65,7 +62,7 @@
6562
*
6663
*/
6764
public class TransactionsListFragment extends SherlockListFragment implements
68-
Refreshable, LoaderCallbacks<Cursor> {
65+
Refreshable, LoaderCallbacks<Cursor>, AdapterView.OnItemLongClickListener{
6966

7067
/**
7168
* Logging tag
@@ -76,7 +73,6 @@ public class TransactionsListFragment extends SherlockListFragment implements
7673
private SimpleCursorAdapter mCursorAdapter;
7774
private ActionMode mActionMode = null;
7875
private boolean mInEditMode = false;
79-
// private long mAccountID;
8076
private String mAccountUID;
8177

8278
/**
@@ -162,6 +158,7 @@ public void onActivityCreated(Bundle savedInstanceState) {
162158
aBar.setDisplayHomeAsUpEnabled(true);
163159

164160
getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
161+
getListView().setOnItemLongClickListener(this);
165162
setHasOptionsMenu(true);
166163
}
167164

@@ -223,7 +220,16 @@ public void onListItemClick(ListView l, View v, int position, long id) {
223220
}
224221
mTransactionEditListener.editTransaction(mTransactionsDbAdapter.getUID(id));
225222
}
226-
223+
224+
@Override
225+
public boolean onItemLongClick(AdapterView<?> adapterView, View view, int position, long id) {
226+
getListView().setItemChecked(position, true);
227+
CheckBox checkbox = (CheckBox) view.findViewById(R.id.checkbox_parent_account);
228+
checkbox.setChecked(true);
229+
startActionMode();
230+
return true;
231+
}
232+
227233
@Override
228234
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
229235
inflater.inflate(R.menu.transactions_list_actions, menu);

0 commit comments

Comments
 (0)