Skip to content

Commit

Permalink
Fixed export test
Browse files Browse the repository at this point in the history
Remove export flag requirement for transactions
  • Loading branch information
codinguser committed Jul 9, 2012
1 parent 3ee0d65 commit 3afa05c
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion GnucashMobile/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<string name="label_export_choice">By default, only new transactions since last export will be exported. Check this option to export all transactions</string>
<string name="error_exporting">Error exporting OFX data</string>
<string-array name="export_destinations">
<item >Email&#8230;</item>
<item >Share file&#8230;</item>
<item >SD Card</item>
</string-array>
<string name="btn_export">Export</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
+ KEY_DESCRIPTION + " text, "
+ KEY_TIMESTAMP + " integer not null, "
+ KEY_ACCOUNT_UID + " varchar(255) not null, "
+ KEY_EXPORTED + " tinyint not null default 0, "
+ KEY_EXPORTED + " tinyint default 0, "
+ "FOREIGN KEY (" + KEY_ACCOUNT_UID + ") REFERENCES " + ACCOUNTS_TABLE_NAME + " (" + KEY_UID + ")"
+ ");";

Expand Down
29 changes: 15 additions & 14 deletions GnucashMobile/src/org/gnucash/android/ui/ExportDialogFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.support.v4.app.DialogFragment;
import android.util.Log;
import android.view.LayoutInflater;
Expand Down Expand Up @@ -134,22 +135,22 @@ public void onClick(View v) {
break;

case 1:
//
// File src = new File(mFilePath);
// File dst = new File(Environment.getExternalStorageDirectory() + "/" + buildExportFilename());
// try {
// copyFile(src, dst);
// } catch (IOException e) {
// Toast.makeText(getActivity(),
// "Could not write OFX file to :\n" + dst.getAbsolutePath(),
// Toast.LENGTH_LONG).show();
// e.printStackTrace();
// break;
// }
//

File src = new File(mFilePath);
File dst = new File(Environment.getExternalStorageDirectory() + "/" + buildExportFilename());
try {
copyFile(src, dst);
} catch (IOException e) {
Toast.makeText(getActivity(),
"Could not write OFX file to :\n" + dst.getAbsolutePath(),
Toast.LENGTH_LONG).show();
e.printStackTrace();
break;
}

//file already exists, just let the user know
Toast.makeText(getActivity(),
"OFX file exported to:\n" + mFilePath,
"OFX file exported to:\n" + dst.getAbsolutePath(),
Toast.LENGTH_LONG).show();
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private void initializeViewsWithTransaction(){
mNameEditText.setText(mTransaction.getName());
mTransactionTypeButton.setChecked(mTransaction.getTransactionType() == TransactionType.DEBIT);
//multiply to balance out division by the TextWatcher attached to this view
mAmountEditText.setText(Double.toString(mTransaction.getAmount() * 10));
mAmountEditText.setText(Double.toString(mTransaction.getAmount()));
mDescriptionEditText.setText(mTransaction.getDescription());
mDateTextView.setText(DATE_FORMATTER.format(mTransaction.getTimeMillis()));
mTimeTextView.setText(TIME_FORMATTER.format(mTransaction.getTimeMillis()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.gnucash.android.ui.AccountsActivity;
import org.gnucash.android.ui.ExportDialogFragment;

import android.os.Environment;
import android.test.ActivityInstrumentationTestCase2;
import android.widget.Spinner;

Expand Down Expand Up @@ -62,7 +63,7 @@ public void testOfxExport(){
String filename = ExportDialogFragment.buildExportFilename();

// File file = new File(getActivity().getExternalFilesDir(null), filename);
File file = new File(getActivity().getExternalFilesDir(null) + "/" + filename);
File file = new File(Environment.getExternalStorageDirectory() + "/" + filename);
assertNotNull(file);
assertTrue(file.exists());
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ project into your workspace and run it as "Android JUnit Test".
Gnucash for Android is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
the License, or (at your option) any later version.

0 comments on commit 3afa05c

Please sign in to comment.