@@ -163,8 +163,16 @@ public class NewTransactionFragment extends SherlockFragment implements
163163 */
164164 private Spinner mDoubleAccountSpinner ;
165165
166+ /**
167+ * Flag to note if double entry accounting is in use or not
168+ */
166169 private boolean mUseDoubleEntry ;
167170
171+ /**
172+ * Flag to note if the user has manually edited the amount of the transaction
173+ */
174+ boolean mAmountManuallyEdited = false ;
175+
168176 /**
169177 * Create the view and retrieve references to the UI elements
170178 */
@@ -252,6 +260,8 @@ public Cursor runQuery(CharSequence name) {
252260 public void onItemClick (AdapterView <?> adapterView , View view , int position , long id ) {
253261 mTransaction = mTransactionsDbAdapter .getTransaction (id );
254262 mTransaction .setUID (UUID .randomUUID ().toString ());
263+ mTransaction .setExported (false );
264+ mTransaction .setTime (System .currentTimeMillis ());
255265 long accountId = ((TransactionsActivity )getSherlockActivity ()).getCurrentAccountID ();
256266 mTransaction .setAccountUID (mTransactionsDbAdapter .getAccountUID (accountId ));
257267 initializeViewsWithTransaction ();
@@ -269,7 +279,10 @@ private void initializeViewsWithTransaction(){
269279
270280 mNameEditText .setText (mTransaction .getName ());
271281 mTransactionTypeButton .setChecked (mTransaction .getTransactionType () == TransactionType .DEBIT );
272- mAmountEditText .setText (mTransaction .getAmount ().toPlainString ());
282+ if (!mAmountManuallyEdited ){
283+ //when autocompleting, only change the amount if the user has not manually changed it already
284+ mAmountEditText .setText (mTransaction .getAmount ().toPlainString ());
285+ }
273286 mCurrencyTextView .setText (mTransaction .getAmount ().getCurrency ().getSymbol (Locale .getDefault ()));
274287 mDescriptionEditText .setText (mTransaction .getDescription ());
275288 mDateTextView .setText (DATE_FORMATTER .format (mTransaction .getTimeMillis ()));
@@ -643,7 +656,7 @@ public void beforeTextChanged(CharSequence s, int start, int count,
643656 public void onTextChanged (CharSequence s , int start , int before ,
644657 int count ) {
645658 // nothing to see here, move along
646-
659+ mAmountManuallyEdited = true ;
647660 }
648661
649662 }
0 commit comments