1919import android .content .Context ;
2020import android .database .sqlite .SQLiteDatabase ;
2121import android .util .Log ;
22- import android .widget .Toast ;
23- import org .gnucash .android .R ;
2422import org .gnucash .android .app .GnuCashApplication ;
2523import org .gnucash .android .db .TransactionsDbAdapter ;
2624import org .gnucash .android .export .xml .GncXmlHelper ;
2725import org .gnucash .android .model .*;
2826import org .gnucash .android .db .AccountsDbAdapter ;
2927import org .xml .sax .Attributes ;
30- import org .xml .sax .InputSource ;
3128import org .xml .sax .SAXException ;
32- import org .xml .sax .XMLReader ;
3329import org .xml .sax .helpers .DefaultHandler ;
3430
35- import javax .xml .parsers .ParserConfigurationException ;
36- import javax .xml .parsers .SAXParser ;
37- import javax .xml .parsers .SAXParserFactory ;
38- import java .io .*;
3931import java .text .ParseException ;
4032import java .util .Currency ;
4133import java .util .regex .Pattern ;
@@ -59,20 +51,8 @@ public class GncXmlHandler extends DefaultHandler {
5951 private static final String LOG_TAG = "GnuCashAccountImporter" ;
6052
6153 /**
62- * Value for placeholder slots in GnuCash account structure file
54+ * Adapter for saving the imported accounts
6355 */
64- private static final String PLACEHOLDER_KEY = "placeholder" ;
65-
66- /**
67- * Value of color slots in GnuCash account structure file
68- */
69- private static final String COLOR_KEY = "color" ;
70-
71- /**
72- * Value of favorite slots in GnuCash account structure file
73- */
74- private static final String FAVORITE_KEY = "favorite" ;
75-
7656 AccountsDbAdapter mAccountsDbAdapter ;
7757
7858 /**
@@ -100,6 +80,7 @@ public class GncXmlHandler extends DefaultHandler {
10080 boolean mInFavoriteSlot = false ;
10181 boolean mISO4217Currency = false ;
10282 boolean mIsDatePosted = false ;
83+ boolean mIsNote = false ;
10384
10485 private Context mContext ;
10586 private TransactionsDbAdapter mTransactionsDbAdapter ;
@@ -133,7 +114,7 @@ public void startElement(String uri, String localName,
133114 mTransaction = new Transaction ("" ); //dummy name will be replaced
134115 }
135116
136- if (qualifiedName .equalsIgnoreCase (GncXmlHelper .TAG_TRX_SPLIT )){
117+ if (qualifiedName .equalsIgnoreCase (GncXmlHelper .TAG_TRN_SPLIT )){
137118 mSplit = new Split (Money .getZeroInstance (),"" );
138119 }
139120
@@ -190,16 +171,20 @@ public void endElement(String uri, String localName, String qualifiedName) throw
190171 }
191172
192173 if (qualifiedName .equalsIgnoreCase (GncXmlHelper .TAG_SLOT_KEY )){
193- if (characterString .equals (PLACEHOLDER_KEY )){
174+ if (characterString .equals (GncXmlHelper . KEY_PLACEHOLDER )){
194175 mInPlaceHolderSlot = true ;
195176 }
196- if (characterString .equals (COLOR_KEY )){
177+ if (characterString .equals (GncXmlHelper . KEY_COLOR )){
197178 mInColorSlot = true ;
198179 }
199180
200- if (characterString .equals (FAVORITE_KEY )){
181+ if (characterString .equals (GncXmlHelper . KEY_FAVORITE )){
201182 mInFavoriteSlot = true ;
202183 }
184+
185+ if (characterString .equals (GncXmlHelper .KEY_NOTES )){
186+ mIsNote = true ;
187+ }
203188 }
204189
205190 if (qualifiedName .equalsIgnoreCase (GncXmlHelper .TAG_SLOT_VALUE )){
@@ -231,6 +216,13 @@ public void endElement(String uri, String localName, String qualifiedName) throw
231216 mAccount .setFavorite (Boolean .parseBoolean (characterString ));
232217 mInFavoriteSlot = false ;
233218 }
219+
220+ if (mIsNote ){
221+ if (mTransaction != null ){
222+ mTransaction .setNote (characterString );
223+ mIsNote = false ;
224+ }
225+ }
234226 }
235227
236228
@@ -239,8 +231,8 @@ public void endElement(String uri, String localName, String qualifiedName) throw
239231 mTransaction .setUID (characterString );
240232 }
241233
242- if (qualifiedName .equalsIgnoreCase (GncXmlHelper .TAG_TRX_DESCRIPTION )){
243- mTransaction .setName (characterString );
234+ if (qualifiedName .equalsIgnoreCase (GncXmlHelper .TAG_TRN_DESCRIPTION )){
235+ mTransaction .setDescription (characterString );
244236 }
245237
246238 if (qualifiedName .equalsIgnoreCase (GncXmlHelper .TAG_DATE )){
@@ -277,7 +269,7 @@ public void endElement(String uri, String localName, String qualifiedName) throw
277269 mSplit .setAccountUID (characterString );
278270 }
279271
280- if (qualifiedName .equals (GncXmlHelper .TAG_TRX_SPLIT )){
272+ if (qualifiedName .equals (GncXmlHelper .TAG_TRN_SPLIT )){
281273 mTransaction .addSplit (mSplit );
282274 }
283275
0 commit comments