X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=android%2Fsrc%2Fcom%2Fgoogle%2Fzxing%2Fclient%2Fandroid%2Fresult%2FISBNResultHandler.java;h=11f30920268b646f8802c6eeddf8f1306ed7f6ce;hb=ea022b1db67d156bf38b4018d85219a379a28227;hp=bd80a2607dcc3b235acab6f212b56db790bb9cda;hpb=cb6c759a78fbf5e6a8796872273372780a8a517e;p=zxing.git diff --git a/android/src/com/google/zxing/client/android/result/ISBNResultHandler.java b/android/src/com/google/zxing/client/android/result/ISBNResultHandler.java index bd80a260..11f30920 100644 --- a/android/src/com/google/zxing/client/android/result/ISBNResultHandler.java +++ b/android/src/com/google/zxing/client/android/result/ISBNResultHandler.java @@ -16,15 +16,16 @@ package com.google.zxing.client.android.result; +import com.google.zxing.client.android.PreferencesActivity; +import com.google.zxing.client.android.R; +import com.google.zxing.client.result.ISBNParsedResult; +import com.google.zxing.client.result.ParsedResult; + import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.SharedPreferences; import android.preference.PreferenceManager; -import com.google.zxing.client.android.PreferencesActivity; -import com.google.zxing.client.android.R; -import com.google.zxing.client.result.ISBNParsedResult; -import com.google.zxing.client.result.ParsedResult; /** * Handles books encoded by their ISBN values. @@ -36,25 +37,31 @@ public final class ISBNResultHandler extends ResultHandler { R.string.button_product_search, R.string.button_book_search, R.string.button_search_book_contents, - R.string.button_custom_product_search, + R.string.button_google_shopper }; - private final String customProductSearch; + private String customProductSearch; public ISBNResultHandler(Activity activity, ParsedResult result) { super(activity, result); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity); customProductSearch = prefs.getString(PreferencesActivity.KEY_CUSTOM_PRODUCT_SEARCH, null); + if (customProductSearch != null && customProductSearch.length() == 0) { + customProductSearch = null; + } } @Override public int getButtonCount() { - return customProductSearch != null && customProductSearch.length() > 0 ? buttons.length : buttons - .length - 1; + // Always show four buttons - Shopper and Custom Search are mutually exclusive. + return buttons.length; } @Override public int getButtonText(int index) { + if (index == buttons.length - 1 && customProductSearch != null) { + return R.string.button_custom_product_search; + } return buttons[index]; } @@ -74,8 +81,12 @@ public final class ISBNResultHandler extends ResultHandler { searchBookContents(isbnResult.getISBN()); break; case 3: - String url = customProductSearch.replace("%s", isbnResult.getISBN()); - openURL(url); + if (customProductSearch != null) { + String url = customProductSearch.replace("%s", isbnResult.getISBN()); + openURL(url); + } else { + openGoogleShopper(isbnResult.getISBN()); + } break; } }