Minor tweaks to ad service

pull/14/head
Tim Su 13 years ago
parent c3514ea2d0
commit 79fd775084

@ -117,6 +117,9 @@
<replaceregexp file="${source.dir}/com/todoroo/astrid/gtasks/api/GtasksInvoker.java"
match="API_KEY = .*"
replace="API_KEY = &quot;${apikey.gtasks}&quot;;" />
<replaceregexp file="${source.dir}/com/todoroo/astrid/utility/Constants.java"
match="AWS_SECRET_KEY_ID = .*"
replace="AWS_SECRET_KEY_ID = &quot;${apikey.amazon.secret}&quot;;" />
</target>
<!-- update api keys that require release signing -->

@ -3,6 +3,7 @@ package com.todoroo.astrid.ui;
import greendroid.widget.AsyncImageView;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
@ -145,7 +146,6 @@ public class WebServicesView extends LinearLayout {
String requestUrl = helper.sign(params);
String result = restClient.get(requestUrl);
System.err.println(requestUrl);
activity.runOnUiThread(new AmazonSearchResultsProcessor(body,
result));
@ -216,9 +216,10 @@ public class WebServicesView extends LinearLayout {
else if("TotalUsed".equals(xpp.getName()))
attributes.put("totalUsed", xpp.nextText());
else if("Error".equals(xpp.getName())) {
while(!"Message".equals(xpp.getName()))
xpp.next();
throw new AmazonException(xpp.nextText());
xpp.next();
String code = xpp.nextText();
String message = xpp.nextText();
throw new AmazonException(code, message);
}
} else if(eventType == XmlPullParser.END_TAG) {
if("Item".equals(xpp.getName())) {
@ -230,15 +231,22 @@ public class WebServicesView extends LinearLayout {
eventType = xpp.next();
}
} catch (AmazonException e) {
if(!"AWS.ECommerceService.NoExactMatches".equals(e.getCode()))
exceptionService.reportError("amazon-error", e);
} catch (Exception e) {
exceptionService.reportError("amazon-other-error", e);
}
try {
String moreLabel = "Show all results";
String url = String.format("http://www.amazon.com/s/?field-keywords=%s&tag=%s",
URLEncoder.encode(task.getValue(Task.TITLE), "UTF-8"), ASSOCIATE_TAG);
View view = inflateRow(body, null, moreLabel, "", url);
view.setBackgroundColor(Color.rgb(200, 200, 200));
} catch (Exception e) {
displayError(e, body);
view.setBackgroundColor(Color.argb(128, 128, 128, 128));
} catch (UnsupportedEncodingException e) {
//
}
}
@ -306,10 +314,16 @@ public class WebServicesView extends LinearLayout {
private class AmazonException extends Exception {
private static final long serialVersionUID = -3759207030258905605L;
private static final long serialVersionUID = -6974618119363113454L;
private final String code;
public AmazonException(String code, String message) {
super(message);
this.code = code;
}
public AmazonException(String arg0) {
super(arg0);
public String getCode() {
return code;
}
}
@ -367,10 +381,12 @@ public class WebServicesView extends LinearLayout {
JSONObject cursor = searchResults.getJSONObject("cursor");
String moreLabel = "Show more results";
if(results.length() == 0)
moreLabel = "Search Google";
String url = cursor.getString("moreResultsUrl");
View view = inflateRow(body, null, moreLabel, "", url);
view.setBackgroundColor(Color.rgb(200, 200, 200));
view.setBackgroundColor(Color.argb(128, 128, 128, 128));
} catch (JSONException e) {
displayError(e, body);

@ -77,7 +77,7 @@ public final class Constants {
// --- amazon
public static final String AWS_ACCESS_KEY_ID = "";
public static final String AWS_ACCESS_KEY_ID = "AKIAJTVL4FOF4PRBKBNA";
public static final String AWS_SECRET_KEY_ID = "";

Loading…
Cancel
Save