Continued making upgrade a more pleasant process - now the task list auto refreshes after update, etc.

pull/14/head 3.0.4
Tim Su 16 years ago
parent 581cdacbfd
commit f96963c2a1

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.timsu.astrid" package="com.timsu.astrid"
android:versionName="3.0.3" android:versionCode="142" android:versionName="3.0.4" android:versionCode="143"
android:installLocation="auto"> android:installLocation="auto">
<!-- ================================================== Used Permissions = --> <!-- ================================================== Used Permissions = -->

@ -123,6 +123,9 @@
<!-- Progress dialog shown when doing something slow --> <!-- Progress dialog shown when doing something slow -->
<string name="DLG_wait">Please wait...</string> <string name="DLG_wait">Please wait...</string>
<!-- Progress dialog shown when upgrading -->
<string name="DLG_upgrading">Upgrading your tasks...</string>
<!-- Title for dialog selecting a time (hours and minutes) --> <!-- Title for dialog selecting a time (hours and minutes) -->
<string name="DLG_hour_minutes">Time (hours : minutes)</string> <string name="DLG_hour_minutes">Time (hours : minutes)</string>

@ -31,6 +31,7 @@ import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.service.ExceptionService; import com.todoroo.andlib.service.ExceptionService;
import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.andlib.utility.DialogUtilities; import com.todoroo.andlib.utility.DialogUtilities;
import com.todoroo.astrid.activity.TaskListActivity;
import com.todoroo.astrid.alarms.Alarm; import com.todoroo.astrid.alarms.Alarm;
import com.todoroo.astrid.alarms.AlarmDatabase; import com.todoroo.astrid.alarms.AlarmDatabase;
import com.todoroo.astrid.backup.TasksXmlImporter; import com.todoroo.astrid.backup.TasksXmlImporter;
@ -112,9 +113,9 @@ public class Astrid2To3UpgradeHelper {
/** /**
* Perform the upgrade from Astrid 2 to Astrid 3 * Perform the upgrade from Astrid 2 to Astrid 3
* @param context2
*/ */
public void upgrade2To3(final UpgradeService upgradeService, final int from) { public void upgrade2To3(final Context context, final UpgradeService upgradeService, final int from) {
final Context context = ContextManager.getContext();
// if from < 1 (we don't know what version, and database exists, leave it alone) // if from < 1 (we don't know what version, and database exists, leave it alone)
if(from < 1 && Arrays.asList(context.databaseList()).contains(database.getName())) if(from < 1 && Arrays.asList(context.databaseList()).contains(database.getName()))
@ -123,11 +124,13 @@ public class Astrid2To3UpgradeHelper {
// else, if there's already a database table, clear it out (!!!) // else, if there's already a database table, clear it out (!!!)
if(Arrays.asList(context.databaseList()).contains(database.getName())) if(Arrays.asList(context.databaseList()).contains(database.getName()))
context.deleteDatabase(database.getName()); context.deleteDatabase(database.getName());
database.openForWriting();
// pop up a progress dialog // pop up a progress dialog
final ProgressDialog dialog; final ProgressDialog dialog;
if(context instanceof Activity) if(context instanceof Activity)
dialog = dialogUtilities.progressDialog(context, context.getString(R.string.DLG_wait)); dialog = dialogUtilities.progressDialog(context,
context.getString(R.string.DLG_upgrading));
else else
dialog = null; dialog = null;
@ -136,7 +139,6 @@ public class Astrid2To3UpgradeHelper {
public void run() { public void run() {
// initiate a backup // initiate a backup
String backupFile = legacyBackup(); String backupFile = legacyBackup();
database.openForWriting();
try { try {
@ -201,13 +203,14 @@ public class Astrid2To3UpgradeHelper {
TasksXmlImporter.importTasks(context, backupFile, null); TasksXmlImporter.importTasks(context, backupFile, null);
} }
} finally { } finally {
database.close();
if(context instanceof Activity) { if(context instanceof Activity) {
((Activity)context).runOnUiThread(new Runnable() { ((Activity)context).runOnUiThread(new Runnable() {
public void run() { public void run() {
if(dialog != null) if(dialog != null)
dialog.dismiss(); dialog.dismiss();
upgradeService.showChangeLog(from); upgradeService.showChangeLog(context, from);
if(context instanceof TaskListActivity)
((TaskListActivity)context).loadTaskListContent(true);
} }
}); });
} }

@ -90,7 +90,7 @@ public class StartupService {
// invoke upgrade service // invoke upgrade service
boolean justUpgraded = latestSetVersion != version; boolean justUpgraded = latestSetVersion != version;
if(justUpgraded && version > 0) { if(justUpgraded && version > 0) {
upgradeService.performUpgrade(latestSetVersion); upgradeService.performUpgrade(context, latestSetVersion);
Preferences.setCurrentVersion(version); Preferences.setCurrentVersion(version);
} }

@ -2,10 +2,10 @@ package com.todoroo.astrid.service;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context;
import android.webkit.WebView; import android.webkit.WebView;
import com.timsu.astrid.R; import com.timsu.astrid.R;
import com.todoroo.andlib.service.ContextManager;
public final class UpgradeService { public final class UpgradeService {
@ -18,15 +18,15 @@ public final class UpgradeService {
* @param from * @param from
* @param to * @param to
*/ */
public void performUpgrade(int from) { public void performUpgrade(Context context, int from) {
if(from == 135) if(from == 135)
AddOnService.recordOem(); AddOnService.recordOem();
if(from < 136) { if(from < 136) {
new Astrid2To3UpgradeHelper().upgrade2To3(this, from); new Astrid2To3UpgradeHelper().upgrade2To3(context, this, from);
} else { } else {
// display changelog // display changelog
showChangeLog(from); showChangeLog(context, from);
} }
} }
@ -39,8 +39,8 @@ public final class UpgradeService {
* @return * @return
*/ */
@SuppressWarnings("nls") @SuppressWarnings("nls")
public void showChangeLog(int from) { public void showChangeLog(Context context, int from) {
if(!(ContextManager.getContext() instanceof Activity) || from == 0) if(!(context instanceof Activity) || from == 0)
return; return;
StringBuilder changeLog = new StringBuilder(); StringBuilder changeLog = new StringBuilder();
@ -52,7 +52,7 @@ public final class UpgradeService {
"more powerful, while other improvements have made it faster " + "more powerful, while other improvements have made it faster " +
"and easier to use. Hope you like it!", "and easier to use. Hope you like it!",
}); });
if(from > 135 && from <= 140) else if(from > 135 && from <= 140)
newVersionString(changeLog, "3.0.2 (8/4/10)", new String[] { newVersionString(changeLog, "3.0.2 (8/4/10)", new String[] {
"Upgrade note: if you are missing old repeating tasks, " + "Upgrade note: if you are missing old repeating tasks, " +
"search for them, there was a bug where they were marked " + "search for them, there was a bug where they were marked " +
@ -60,6 +60,12 @@ public final class UpgradeService {
"This update also fixes widget issues with Android 1.5. ", "This update also fixes widget issues with Android 1.5. ",
"Thanks for your patience!", "Thanks for your patience!",
}); });
else if(from > 140 && from <= 142)
newVersionString(changeLog, "3.0.4 (8/4/10)", new String[] {
"Making upgrade easier for new Astrid 3 users.",
"Fixed some user-reported crashes",
"We love you!!",
});
if(changeLog.length() == 0) if(changeLog.length() == 0)
return; return;
@ -67,11 +73,11 @@ public final class UpgradeService {
changeLog.append("</body></html>"); changeLog.append("</body></html>");
String changeLogHtml = "<html><body style='color: white'>" + changeLog; String changeLogHtml = "<html><body style='color: white'>" + changeLog;
WebView webView = new WebView(ContextManager.getContext()); WebView webView = new WebView(context);
webView.loadData(changeLogHtml, "text/html", "utf-8"); webView.loadData(changeLogHtml, "text/html", "utf-8");
webView.setBackgroundColor(0); webView.setBackgroundColor(0);
new AlertDialog.Builder(ContextManager.getContext()) new AlertDialog.Builder(context)
.setTitle(R.string.UpS_changelog_title) .setTitle(R.string.UpS_changelog_title)
.setView(webView) .setView(webView)
.setIcon(android.R.drawable.ic_dialog_info) .setIcon(android.R.drawable.ic_dialog_info)

Loading…
Cancel
Save