From 17221f59a2434c2a2cfb92bdec6bebc42b36929b Mon Sep 17 00:00:00 2001 From: Tim Su Date: Thu, 11 Nov 2010 18:28:27 -0800 Subject: [PATCH] Fix for crashes reported by astrid users --- .../producteev/ProducteevDetailExposer.java | 14 +++++-- .../todoroo/astrid/adapter/FilterAdapter.java | 6 ++- .../todoroo/astrid/adapter/TaskAdapter.java | 11 ++--- .../todoroo/astrid/service/AddOnService.java | 2 +- .../astrid/service/UpgradeService.java | 41 ++++--------------- 5 files changed, 28 insertions(+), 46 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevDetailExposer.java b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevDetailExposer.java index dc5260adf..e40d53f65 100644 --- a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevDetailExposer.java +++ b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevDetailExposer.java @@ -9,6 +9,7 @@ import android.content.Intent; import com.timsu.astrid.R; import com.todoroo.andlib.data.TodorooCursor; +import com.todoroo.andlib.utility.Preferences; import com.todoroo.astrid.adapter.TaskAdapter; import com.todoroo.astrid.api.AstridApiConstants; import com.todoroo.astrid.data.Metadata; @@ -17,7 +18,6 @@ import com.todoroo.astrid.producteev.sync.ProducteevDashboard; import com.todoroo.astrid.producteev.sync.ProducteevDataService; import com.todoroo.astrid.producteev.sync.ProducteevNote; import com.todoroo.astrid.producteev.sync.ProducteevTask; -import com.todoroo.andlib.utility.Preferences; /** * Exposes Task Details for Producteev: @@ -35,7 +35,12 @@ public class ProducteevDetailExposer extends BroadcastReceiver { return; boolean extended = intent.getBooleanExtra(AstridApiConstants.EXTRAS_EXTENDED, false); - String taskDetail = getTaskDetails(context, taskId, extended); + String taskDetail; + try { + taskDetail = getTaskDetails(context, taskId, extended); + } catch (Exception e) { + return; + } if(taskDetail == null) return; @@ -59,8 +64,9 @@ public class ProducteevDetailExposer extends BroadcastReceiver { return null; if(!extended) { - - long dashboardId = metadata.getValue(ProducteevTask.DASHBOARD_ID); + long dashboardId = -1; + if(metadata.containsNonNullValue(ProducteevTask.DASHBOARD_ID)) + dashboardId = metadata.getValue(ProducteevTask.DASHBOARD_ID); long responsibleId = -1; if(metadata.containsNonNullValue(ProducteevTask.RESPONSIBLE_ID)) responsibleId = metadata.getValue(ProducteevTask.RESPONSIBLE_ID); diff --git a/astrid/src/com/todoroo/astrid/adapter/FilterAdapter.java b/astrid/src/com/todoroo/astrid/adapter/FilterAdapter.java index 7f1145b2d..cb17a09d0 100644 --- a/astrid/src/com/todoroo/astrid/adapter/FilterAdapter.java +++ b/astrid/src/com/todoroo/astrid/adapter/FilterAdapter.java @@ -28,13 +28,13 @@ import android.widget.TextView; import com.timsu.astrid.R; import com.todoroo.andlib.service.Autowired; import com.todoroo.andlib.service.DependencyInjectionService; +import com.todoroo.andlib.utility.Preferences; import com.todoroo.astrid.api.AstridApiConstants; import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.api.FilterCategory; import com.todoroo.astrid.api.FilterListHeader; import com.todoroo.astrid.api.FilterListItem; import com.todoroo.astrid.service.TaskService; -import com.todoroo.andlib.utility.Preferences; public class FilterAdapter extends BaseExpandableListAdapter { @@ -80,7 +80,7 @@ public class FilterAdapter extends BaseExpandableListAdapter { // nothing to do (corePoolSize == 0, which makes it available for garbage collection), and will wake itself up // if new filters are queued (obviously it cannot be garbage collected if it is possible for new filters to // be added). - private ThreadPoolExecutor filterExecutor = new ThreadPoolExecutor(0, 1, 1, TimeUnit.SECONDS, new LinkedBlockingQueue()); + private final ThreadPoolExecutor filterExecutor = new ThreadPoolExecutor(0, 1, 1, TimeUnit.SECONDS, new LinkedBlockingQueue()); public FilterAdapter(Activity activity, ExpandableListView listView, int rowLayout, boolean skipIntentFilters) { @@ -210,6 +210,8 @@ public class FilterAdapter extends BaseExpandableListAdapter { * ====================================================================== */ public Object getGroup(int groupPosition) { + if(groupPosition >= items.size()) + return null; return items.get(groupPosition); } diff --git a/astrid/src/com/todoroo/astrid/adapter/TaskAdapter.java b/astrid/src/com/todoroo/astrid/adapter/TaskAdapter.java index a2a5b1a68..fe6460f4f 100644 --- a/astrid/src/com/todoroo/astrid/adapter/TaskAdapter.java +++ b/astrid/src/com/todoroo/astrid/adapter/TaskAdapter.java @@ -17,18 +17,18 @@ import android.database.Cursor; import android.graphics.Paint; import android.graphics.drawable.Drawable; import android.text.Html; -import android.text.Spanned; -import android.text.TextUtils; import android.text.Html.ImageGetter; import android.text.Html.TagHandler; +import android.text.Spanned; +import android.text.TextUtils; import android.text.util.Linkify; import android.view.ContextMenu; +import android.view.ContextMenu.ContextMenuInfo; import android.view.LayoutInflater; import android.view.View; -import android.view.ViewGroup; -import android.view.ContextMenu.ContextMenuInfo; import android.view.View.OnClickListener; import android.view.View.OnCreateContextMenuListener; +import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; import android.widget.Button; import android.widget.CheckBox; @@ -610,7 +610,8 @@ public class TaskAdapter extends CursorAdapter implements Filterable { @Override protected void reset(ViewHolder viewHolder, long taskId) { TextView view = viewHolder.extendedDetails; - view.setVisibility(View.GONE); + if(view != null) + view.setVisibility(View.GONE); } } diff --git a/astrid/src/com/todoroo/astrid/service/AddOnService.java b/astrid/src/com/todoroo/astrid/service/AddOnService.java index 9434da282..ccc237d00 100644 --- a/astrid/src/com/todoroo/astrid/service/AddOnService.java +++ b/astrid/src/com/todoroo/astrid/service/AddOnService.java @@ -220,7 +220,7 @@ public class AddOnService { // temporary temporary AddOn[] list = new AddOn[3]; list[0] = new AddOn(false, true, "Astrid Power Pack", null, - "Support Astrid and get more productive with the Astrid Power Pack. Backup, widgets, no ads, and calendar integration. Power up today!", + "Support Astrid and get more productive with the Astrid Power Pack. 4x2 and 4x4 widgets, timer, and voice integration. Power up today!", POWER_PACK_PACKAGE, "http://www.weloveastrid.com/store", ((BitmapDrawable)r.getDrawable(R.drawable.icon_pp)).getBitmap()); diff --git a/astrid/src/com/todoroo/astrid/service/UpgradeService.java b/astrid/src/com/todoroo/astrid/service/UpgradeService.java index 7ba568ff7..849a4e85a 100644 --- a/astrid/src/com/todoroo/astrid/service/UpgradeService.java +++ b/astrid/src/com/todoroo/astrid/service/UpgradeService.java @@ -1,7 +1,6 @@ package com.todoroo.astrid.service; import android.app.Activity; -import android.app.AlertDialog; import android.app.ProgressDialog; import android.content.Context; import android.content.SharedPreferences; @@ -101,7 +100,7 @@ public final class UpgradeService { StringBuilder changeLog = new StringBuilder(); if(from <= V2_14_4) { - newVersionString(changeLog, "3.6.0 (11/10/10)", new String[] { + newVersionString(changeLog, "3.6.0 (11/12/10)", new String[] { "Astrid is brand new inside and out! In addition to a new " + "look and feel, a new add-on system allows Astrid to become " + "more powerful, while other improvements have made it faster " + @@ -111,10 +110,12 @@ public final class UpgradeService { }); } else { // current message - newVersionString(changeLog, "3.6.0 (11/10/10)", new String[] { + newVersionString(changeLog, "3.6.0 (11/12/10)", new String[] { "Astrid Power Pack is now launched to the Android Market. " + - "Power Pack features include 4x2 and 4x4 widgets and voice " + + "New Power Pack features include 4x2 and 4x4 widgets and voice " + "task reminders and creation. Go to the add-ons page to find out more!", + "Fix for Google Tasks: due times got lost on sync", + "Fix for task alarms not always firing if multiple set" }); upgrade3To3_6(context); @@ -125,12 +126,13 @@ public final class UpgradeService { "Bug fix with RMilk & new tasks not getting synced", "Fixed Force Closes and other bugs", }); - if(from >= V3_0_0 && from < V3_4_0) + if(from >= V3_0_0 && from < V3_4_0) { newVersionString(changeLog, "3.4.0 (10/08/10)", new String[] { "End User License Agreement", "Option to disable usage statistics", "Bug fixes with Producteev", }); + } if(from >= V3_0_0 && from < V3_3_0) newVersionString(changeLog, "3.3.0 (9/17/10)", new String[] { "Fixed some RTM duplicated tasks issues", @@ -186,35 +188,6 @@ public final class UpgradeService { // --- upgrade functions - @SuppressWarnings({"nls", "unused"}) - private void upgrade3To3_4(final Context context) { - // if RTM, store RTM to secondary preferences - if(Preferences.getStringValue("rmilk_token") != null) { - SharedPreferences settings = context.getSharedPreferences("rtm", Context.MODE_WORLD_READABLE); - Editor editor = settings.edit(); - editor.putString("rmilk_token", Preferences.getStringValue("rmilk_token")); - editor.putLong("rmilk_last_sync", Preferences.getLong("rmilk_last_sync", 0)); - editor.commit(); - - final String message = "Hi, it looks like you are a Remember the Milk user! " + - "In this version of Astrid, RTM is now a community-supported " + - "add-on. Please go to the Android market to install it!"; - if(context instanceof Activity) { - ((Activity)context).runOnUiThread(new Runnable() { - @Override - public void run() { - new AlertDialog.Builder(context) - .setTitle(com.todoroo.astrid.api.R.string.DLG_information_title) - .setMessage(message) - .setPositiveButton("Go To Market", new AddOnService.MarketClickListener(context, "org.weloveastrid.rmilk")) - .setNegativeButton("Later", null) - .show(); - } - }); - } - } - } - /** * Moves sorting prefs to public pref store * @param context