package com.google.zxing.client.android.result;
+import com.google.zxing.Result;
import com.google.zxing.client.android.Contents;
import com.google.zxing.client.android.Intents;
import com.google.zxing.client.android.LocaleManager;
private final ParsedResult result;
private final Activity activity;
+ private final Result rawResult;
+ private final String customProductSearch;
private final DialogInterface.OnClickListener shopperMarketListener =
new DialogInterface.OnClickListener() {
};
ResultHandler(Activity activity, ParsedResult result) {
+ this(activity, result, null);
+ }
+
+ ResultHandler(Activity activity, ParsedResult result, Result rawResult) {
this.result = result;
this.activity = activity;
+ this.rawResult = rawResult;
+ this.customProductSearch = parseCustomSearchURL();
}
ParsedResult getResult() {
return result;
}
+ boolean hasCustomProductSearch() {
+ return customProductSearch != null;
+ }
+
/**
* Indicates how many buttons the derived class wants shown.
*
}
}
- protected String parseCustomSearchURL() {
+ private String parseCustomSearchURL() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
String customProductSearch = prefs.getString(PreferencesActivity.KEY_CUSTOM_PRODUCT_SEARCH, null);
if (customProductSearch != null && customProductSearch.trim().length() == 0) {
}
return customProductSearch;
}
+
+ String fillInCustomSearchURL(String text) {
+ String url = customProductSearch.replace("%s", text);
+ if (rawResult != null) {
+ url = url.replace("%f", rawResult.getBarcodeFormat().toString());
+ }
+ return url;
+ }
+
}
\ No newline at end of file