Skip to content

Commit

Permalink
Fixed: unable to edit transactions in double entry mode
Browse files Browse the repository at this point in the history
Improved: Long press on transactions now triggers context menu
  • Loading branch information
codinguser committed Jan 29, 2015
1 parent 13dd668 commit ccf6cb8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,10 @@ private void initializeViewsWithTransaction(){
cal.setTimeInMillis(mTransaction.getTimeMillis());
mDate = mTime = cal;

//TODO: deep copy the split list. We need a copy so we can modify with impunity
mSplitsList = new ArrayList<Split>(mTransaction.getSplits());
mAmountEditText.setEnabled(mSplitsList.size() <= 2);

//if there are more than two splits (which is the default for one entry), then
//disable editing of the transfer account. User should open editor
if (mSplitsList.size() == 2 && mSplitsList.get(0).isPairOf(mSplitsList.get(1))) {
Expand All @@ -364,8 +368,6 @@ private void initializeViewsWithTransaction(){
setAmountEditViewVisible(View.GONE);
}
}
mSplitsList = new ArrayList<Split>(mTransaction.getSplits()); //we need a copy so we can modify with impunity
mAmountEditText.setEnabled(mSplitsList.size() <= 2);

String currencyCode = mTransactionsDbAdapter.getCurrencyCode(mAccountUID);
Currency accountCurrency = Currency.getInstance(currencyCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,8 @@
import android.view.TouchDelegate;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.*;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ListView;
import android.widget.TextView;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockListFragment;
import com.actionbarsherlock.view.ActionMode;
Expand All @@ -65,7 +62,7 @@
*
*/
public class TransactionsListFragment extends SherlockListFragment implements
Refreshable, LoaderCallbacks<Cursor> {
Refreshable, LoaderCallbacks<Cursor>, AdapterView.OnItemLongClickListener{

/**
* Logging tag
Expand All @@ -76,7 +73,6 @@ public class TransactionsListFragment extends SherlockListFragment implements
private SimpleCursorAdapter mCursorAdapter;
private ActionMode mActionMode = null;
private boolean mInEditMode = false;
// private long mAccountID;
private String mAccountUID;

/**
Expand Down Expand Up @@ -162,6 +158,7 @@ public void onActivityCreated(Bundle savedInstanceState) {
aBar.setDisplayHomeAsUpEnabled(true);

getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
getListView().setOnItemLongClickListener(this);
setHasOptionsMenu(true);
}

Expand Down Expand Up @@ -223,7 +220,16 @@ public void onListItemClick(ListView l, View v, int position, long id) {
}
mTransactionEditListener.editTransaction(mTransactionsDbAdapter.getUID(id));
}


@Override
public boolean onItemLongClick(AdapterView<?> adapterView, View view, int position, long id) {
getListView().setItemChecked(position, true);
CheckBox checkbox = (CheckBox) view.findViewById(R.id.checkbox_parent_account);
checkbox.setChecked(true);
startActionMode();
return true;
}

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.transactions_list_actions, menu);
Expand Down

0 comments on commit ccf6cb8

Please sign in to comment.