Small style stuff
[zxing.git] / android / src / com / google / zxing / client / android / result / TextResultHandler.java
index c60bd02..8315342 100644 (file)
 package com.google.zxing.client.android.result;
 
 import com.google.zxing.client.android.R;
-import com.google.zxing.client.android.PreferencesActivity;
 import com.google.zxing.client.result.ParsedResult;
 
 import android.app.Activity;
-import android.content.SharedPreferences;
-import android.preference.PreferenceManager;
 
 /**
  * This class handles TextParsedResult as well as unknown formats. It's the fallback handler.
@@ -38,18 +35,13 @@ public final class TextResultHandler extends ResultHandler {
       R.string.button_custom_product_search,
   };
 
-  private final String customProductSearch;
-
   public TextResultHandler(Activity activity, ParsedResult result) {
     super(activity, result);
-    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
-    customProductSearch = prefs.getString(PreferencesActivity.KEY_CUSTOM_PRODUCT_SEARCH, null);
   }
 
   @Override
   public int getButtonCount() {
-    return customProductSearch != null && customProductSearch.length() > 0 ?
-            buttons.length : buttons.length - 1;
+    return hasCustomProductSearch() ? buttons.length : buttons.length - 1;
   }
 
   @Override
@@ -71,8 +63,7 @@ public final class TextResultHandler extends ResultHandler {
         shareBySMS(text);
         break;
       case 3:
-        String url = customProductSearch.replace("%s", text);
-        openURL(url);
+        openURL(fillInCustomSearchURL(text));
         break;
     }
   }