From a29e5de53f66be7d851f70b3bbe728cb85d14fe1 Mon Sep 17 00:00:00 2001 From: Tim Su Date: Sat, 24 Apr 2010 00:41:53 -0700 Subject: [PATCH] Reverting change to .classpath, bumping version number and deleting the drop database call on unsupported migration. Instead we show a user popup indicating the database might be corrupted (which is really the most often case an end-user sees this message). Hopefully this is another step in preventing permanent data loss? Although if the database is corrupted it's unclear what we should do. --- .classpath | 9 +++------ AndroidManifest.xml | 2 +- src/com/timsu/astrid/data/alerts/Alert.java | 10 ++++++---- src/com/timsu/astrid/data/sync/SyncMapping.java | 10 ++++++---- src/com/timsu/astrid/data/tag/AbstractTagModel.java | 10 ++++++---- src/com/timsu/astrid/data/tag/TagToTaskMapping.java | 10 ++++++---- src/com/timsu/astrid/data/task/AbstractTaskModel.java | 10 ++++++---- 7 files changed, 34 insertions(+), 27 deletions(-) diff --git a/.classpath b/.classpath index 28dab5b65..528f1b336 100644 --- a/.classpath +++ b/.classpath @@ -1,13 +1,10 @@ - + + - - - - - + diff --git a/AndroidManifest.xml b/AndroidManifest.xml index ac3ac06b3..eda2c39f4 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,7 +1,7 @@ + android:versionCode="120" android:versionName="2.12.0"> diff --git a/src/com/timsu/astrid/data/alerts/Alert.java b/src/com/timsu/astrid/data/alerts/Alert.java index 784f631d2..247eaad24 100644 --- a/src/com/timsu/astrid/data/alerts/Alert.java +++ b/src/com/timsu/astrid/data/alerts/Alert.java @@ -31,6 +31,7 @@ import android.util.Log; import com.timsu.astrid.data.AbstractController; import com.timsu.astrid.data.AbstractModel; import com.timsu.astrid.data.task.TaskIdentifier; +import com.timsu.astrid.utilities.DialogUtilities; /** A single alert on a task */ @@ -63,10 +64,12 @@ public class Alert extends AbstractModel { /** Database Helper manages creating new tables and updating old ones */ static class AlertDatabaseHelper extends SQLiteOpenHelper { String tableName; + Context context; AlertDatabaseHelper(Context context, String databaseName, String tableName) { super(context, databaseName, null, VERSION); this.tableName = tableName; + this.context = context; } @Override @@ -88,10 +91,9 @@ public class Alert extends AbstractModel { switch(oldVersion) { default: - // we don't know how to handle it... do the unfortunate thing - Log.e(getClass().getSimpleName(), "Unsupported migration, table dropped!"); - db.execSQL("DROP TABLE IF EXISTS " + tableName); - onCreate(db); + // we don't know how to handle it... show an error + Log.e(getClass().getSimpleName(), "Unsupported migration from " + oldVersion + " to " + newVersion); + DialogUtilities.okDialog(context, "There was a database error reading from Alerts. Data may have been corrupted.", null); } } } diff --git a/src/com/timsu/astrid/data/sync/SyncMapping.java b/src/com/timsu/astrid/data/sync/SyncMapping.java index 09027116c..f0a47f6c5 100644 --- a/src/com/timsu/astrid/data/sync/SyncMapping.java +++ b/src/com/timsu/astrid/data/sync/SyncMapping.java @@ -30,6 +30,7 @@ import com.timsu.astrid.data.AbstractController; import com.timsu.astrid.data.AbstractModel; import com.timsu.astrid.data.task.TaskIdentifier; import com.timsu.astrid.sync.TaskProxy; +import com.timsu.astrid.utilities.DialogUtilities; /** A single tag on a task */ @@ -70,10 +71,12 @@ public class SyncMapping extends AbstractModel { /** Database Helper manages creating new tables and updating old ones */ static class SyncMappingDatabaseHelper extends SQLiteOpenHelper { String tableName; + Context context; SyncMappingDatabaseHelper(Context context, String databaseName, String tableName) { super(context, databaseName, null, VERSION); this.tableName = tableName; + this.context = context; } @Override @@ -97,10 +100,9 @@ public class SyncMapping extends AbstractModel { switch(oldVersion) { default: - // we don't know how to handle it... do the unfortunate thing - Log.e(getClass().getSimpleName(), "Unsupported migration, table dropped!"); - db.execSQL("DROP TABLE IF EXISTS " + tableName); - onCreate(db); + // we don't know how to handle it... show an error + Log.e(getClass().getSimpleName(), "Unsupported migration from " + oldVersion + " to " + newVersion); + DialogUtilities.okDialog(context, "There was a database error reading from Alerts. Data may have been corrupted.", null); } } } diff --git a/src/com/timsu/astrid/data/tag/AbstractTagModel.java b/src/com/timsu/astrid/data/tag/AbstractTagModel.java index 9bc1dd7a5..bd8a01bfc 100644 --- a/src/com/timsu/astrid/data/tag/AbstractTagModel.java +++ b/src/com/timsu/astrid/data/tag/AbstractTagModel.java @@ -30,6 +30,7 @@ import android.util.Log; import com.timsu.astrid.data.AbstractController; import com.timsu.astrid.data.AbstractModel; +import com.timsu.astrid.utilities.DialogUtilities; /** Abstract model of a task. Subclasses implement the getters and setters @@ -81,10 +82,12 @@ public abstract class AbstractTagModel extends AbstractModel { /** Database Helper manages creating new tables and updating old ones */ static class TagModelDatabaseHelper extends SQLiteOpenHelper { String tableName; + Context context; TagModelDatabaseHelper(Context context, String databaseName, String tableName) { super(context, databaseName, null, VERSION); this.tableName = tableName; + this.context = context; } @Override @@ -112,10 +115,9 @@ public abstract class AbstractTagModel extends AbstractModel { switch(oldVersion) { default: - // we don't know how to handle it... do the unfortunate thing - Log.e(getClass().getSimpleName(), "Unsupported migration, table dropped!"); - db.execSQL("DROP TABLE IF EXISTS " + tableName); - onCreate(db); + // we don't know how to handle it... show an error + Log.e(getClass().getSimpleName(), "Unsupported migration from " + oldVersion + " to " + newVersion); + DialogUtilities.okDialog(context, "There was a database error reading from Alerts. Data may have been corrupted.", null); } } } diff --git a/src/com/timsu/astrid/data/tag/TagToTaskMapping.java b/src/com/timsu/astrid/data/tag/TagToTaskMapping.java index fe4f87b49..033c8aa28 100644 --- a/src/com/timsu/astrid/data/tag/TagToTaskMapping.java +++ b/src/com/timsu/astrid/data/tag/TagToTaskMapping.java @@ -29,6 +29,7 @@ import android.util.Log; import com.timsu.astrid.data.AbstractController; import com.timsu.astrid.data.AbstractModel; import com.timsu.astrid.data.task.TaskIdentifier; +import com.timsu.astrid.utilities.DialogUtilities; /** A single tag on a task */ @@ -61,10 +62,12 @@ public class TagToTaskMapping extends AbstractModel { /** Database Helper manages creating new tables and updating old ones */ static class TagToTaskMappingDatabaseHelper extends SQLiteOpenHelper { String tableName; + Context context; TagToTaskMappingDatabaseHelper(Context context, String databaseName, String tableName) { super(context, databaseName, null, VERSION); this.tableName = tableName; + this.context = context; } @Override @@ -86,10 +89,9 @@ public class TagToTaskMapping extends AbstractModel { switch(oldVersion) { default: - // we don't know how to handle it... do the unfortunate thing - Log.e(getClass().getSimpleName(), "Unsupported migration, table dropped!"); - db.execSQL("DROP TABLE IF EXISTS " + tableName); - onCreate(db); + // we don't know how to handle it... show an error + Log.e(getClass().getSimpleName(), "Unsupported migration from " + oldVersion + " to " + newVersion); + DialogUtilities.okDialog(context, "There was a database error reading from Alerts. Data may have been corrupted.", null); } } } diff --git a/src/com/timsu/astrid/data/task/AbstractTaskModel.java b/src/com/timsu/astrid/data/task/AbstractTaskModel.java index 1afdf2aef..438c79009 100644 --- a/src/com/timsu/astrid/data/task/AbstractTaskModel.java +++ b/src/com/timsu/astrid/data/task/AbstractTaskModel.java @@ -33,6 +33,7 @@ import com.timsu.astrid.data.AbstractController; import com.timsu.astrid.data.AbstractModel; import com.timsu.astrid.data.enums.Importance; import com.timsu.astrid.data.enums.RepeatInterval; +import com.timsu.astrid.utilities.DialogUtilities; import com.timsu.astrid.utilities.Preferences; @@ -116,10 +117,12 @@ public abstract class AbstractTaskModel extends AbstractModel { /** Database Helper manages creating new tables and updating old ones */ public static class TaskModelDatabaseHelper extends SQLiteOpenHelper { String tableName; + Context context; public TaskModelDatabaseHelper(Context context, String databaseName, String tableName) { super(context, databaseName, null, VERSION); this.tableName = tableName; + this.context = context; } @Override @@ -253,10 +256,9 @@ public abstract class AbstractTaskModel extends AbstractModel { break; default: - // we don't know how to handle it... do the unfortunate thing - Log.e(getClass().getSimpleName(), "Unsupported migration, table dropped!"); - db.execSQL("DROP TABLE IF EXISTS " + tableName); - onCreate(db); + // we don't know how to handle it... show an error + Log.e(getClass().getSimpleName(), "Unsupported migration from " + oldVersion + " to " + newVersion); + DialogUtilities.okDialog(context, "There was a database error reading from Alerts. Data may have been corrupted.", null); } } }