diff --git a/CHANGELOG.md b/CHANGELOG.md index 44d39ce21..97d30e73f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,11 @@ Change Log =============================================================================== -Version 2.4.0 *(2018-06-15)* +Version 2.4.1 *(2019-11-30)* ---------------------------- * Fixes #809: Crash when exporting CSV * Fixes #811: Add button in schedule action disappears after rotation * Fixes #790: Missing transaction description margin +* Fixes crash if during database upgrade triggered by scheduled action * Improve performance of CSV export * Improved: Add book name to accounts listing view * Improved: Update translations diff --git a/app/build.gradle b/app/build.gradle index 433fd721b..ee6d05082 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,7 +6,7 @@ apply plugin: 'io.fabric' def versionMajor = 2 def versionMinor = 4 def versionPatch = 1 -def versionBuild = 1 +def versionBuild = 2 static def buildTime() { def df = new SimpleDateFormat("yyyyMMdd HH:mm 'UTC'") diff --git a/app/src/main/java/org/gnucash/android/db/DatabaseHelper.java b/app/src/main/java/org/gnucash/android/db/DatabaseHelper.java index b8ef6c41f..9d4762ef3 100644 --- a/app/src/main/java/org/gnucash/android/db/DatabaseHelper.java +++ b/app/src/main/java/org/gnucash/android/db/DatabaseHelper.java @@ -20,11 +20,9 @@ import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; -import android.widget.Toast; import com.crashlytics.android.Crashlytics; -import org.gnucash.android.app.GnuCashApplication; import org.gnucash.android.model.Commodity; import org.xml.sax.SAXException; @@ -264,7 +262,7 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){ Log.i(LOG_TAG, "Upgrading database from version " + oldVersion + " to " + newVersion); - Toast.makeText(GnuCashApplication.getAppContext(), "Upgrading GnuCash database", Toast.LENGTH_SHORT).show(); + //TODO: Find way to show a progress dialog for long running db upgrades /* * NOTE: In order to modify the database, create a new static method in the MigrationHelper class * called upgradeDbToVersion<#>, e.g. int upgradeDbToVersion10(SQLiteDatabase) in order to upgrade to version 10. @@ -354,7 +352,7 @@ private void createDatabaseTables(SQLiteDatabase db) { db.execSQL(createBudgetAmountUidIndex); try { - MigrationHelper.importCommodities(db); + MigrationHelper.importCommodities(db, true); } catch (SAXException | ParserConfigurationException | IOException e) { Log.e(LOG_TAG, "Error loading currencies into the database"); e.printStackTrace(); diff --git a/app/src/main/java/org/gnucash/android/db/MigrationHelper.java b/app/src/main/java/org/gnucash/android/db/MigrationHelper.java index a5717671b..dbad1acb9 100644 --- a/app/src/main/java/org/gnucash/android/db/MigrationHelper.java +++ b/app/src/main/java/org/gnucash/android/db/MigrationHelper.java @@ -235,7 +235,7 @@ public void run() { /** * Imports commodities into the database from XML resource file */ - static void importCommodities(SQLiteDatabase db) throws SAXException, ParserConfigurationException, IOException { + static void importCommodities(SQLiteDatabase db, boolean deleteExisting) throws SAXException, ParserConfigurationException, IOException { SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); XMLReader xr = sp.getXMLReader(); @@ -246,7 +246,7 @@ static void importCommodities(SQLiteDatabase db) throws SAXException, ParserConf /** Create handler to handle XML Tags ( extends DefaultHandler ) */ - CommoditiesXmlHandler handler = new CommoditiesXmlHandler(db); + CommoditiesXmlHandler handler = new CommoditiesXmlHandler(db, deleteExisting); xr.setContentHandler(handler); xr.parse(new InputSource(bos)); @@ -883,7 +883,7 @@ static int upgradeDbToVersion9(SQLiteDatabase db){ + "' ON " + CommodityEntry.TABLE_NAME + "(" + CommodityEntry.COLUMN_UID + ")"); try { - importCommodities(db); + importCommodities(db, true); } catch (SAXException | ParserConfigurationException | IOException e) { Log.e(LOG_TAG, "Error loading currencies into the database", e); Crashlytics.logException(e); @@ -1633,7 +1633,7 @@ static int upgradeDbToVersion15(SQLiteDatabase db) { * Upgrades the database to version 16. *
This migration makes the following changes to the database: *