Fixed a bug in shortcut handling, which incidentally solves our most common crash

pull/14/head
Sam Bosley 13 years ago
parent 34e2e5f658
commit ea322ea941

@ -14,11 +14,9 @@ import java.lang.reflect.Method;
import java.math.BigInteger; import java.math.BigInteger;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.net.URLEncoder;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
@ -174,6 +172,34 @@ public class AndroidUtilities {
value.getClass()); value.getClass());
} }
/**
* Put an arbitrary object into a {@link ContentValues}
* @param target
* @param key
* @param value
*/
public static void putInto(Bundle target, String key, Object value, boolean errorOnFail) {
if (value instanceof Boolean)
target.putBoolean(key, (Boolean) value);
else if (value instanceof Byte)
target.putByte(key, (Byte) value);
else if (value instanceof Double)
target.putDouble(key, (Double) value);
else if (value instanceof Float)
target.putFloat(key, (Float) value);
else if (value instanceof Integer)
target.putInt(key, (Integer) value);
else if (value instanceof Long)
target.putLong(key, (Long) value);
else if (value instanceof Short)
target.putShort(key, (Short) value);
else if (value instanceof String)
target.putString(key, (String) value);
else if (errorOnFail)
throw new UnsupportedOperationException("Could not handle type " + //$NON-NLS-1$
value.getClass());
}
// --- serialization // --- serialization
/** /**

@ -20,6 +20,7 @@
package com.todoroo.astrid.activity; package com.todoroo.astrid.activity;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set;
import android.app.Activity; import android.app.Activity;
import android.content.ComponentName; import android.content.ComponentName;
@ -69,6 +70,17 @@ public class ShortcutActivity extends Activity {
/** token for passing a image url*/ /** token for passing a image url*/
public static final String TOKEN_IMAGE_URL = "imageUrl"; //$NON-NLS-1$ public static final String TOKEN_IMAGE_URL = "imageUrl"; //$NON-NLS-1$
/** List of the above constants for searching */
private static final String[] CUSTOM_EXTRAS = {
TOKEN_SINGLE_TASK,
TOKEN_FILTER_TITLE,
TOKEN_FILTER_SQL,
TOKEN_FILTER_VALUES,
TOKEN_FILTER_VALUES_ITEM,
TOKEN_CUSTOM_CLASS,
TOKEN_IMAGE_URL
};
// --- implementation // --- implementation
@Override @Override
@ -136,6 +148,15 @@ public class ShortcutActivity extends Activity {
} }
else else
filter = new FilterWithCustomIntent(title, title, sql, values); filter = new FilterWithCustomIntent(title, title, sql, values);
Bundle customExtras = new Bundle();
Set<String> keys = extras.keySet();
for (String key : keys) {
if (AndroidUtilities.indexOf(CUSTOM_EXTRAS, key) < 0)
AndroidUtilities.putInto(customExtras, key, extras.get(key), false);
}
((FilterWithCustomIntent) filter).customExtras = customExtras; // Something
ComponentName customTaskList = ComponentName.unflattenFromString(extras.getString(TOKEN_CUSTOM_CLASS)); ComponentName customTaskList = ComponentName.unflattenFromString(extras.getString(TOKEN_CUSTOM_CLASS));
((FilterWithCustomIntent) filter).customTaskList = customTaskList; ((FilterWithCustomIntent) filter).customTaskList = customTaskList;
} else { } else {

Loading…
Cancel
Save