Enhanced book support

git-svn-id: https://zxing.googlecode.com/svn/trunk@1068 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2009-09-29 22:33:55 +00:00
parent 85fc102cb9
commit 762bb70046
5 changed files with 24 additions and 5 deletions

View file

@ -34,6 +34,7 @@
<string name="button_open_browser">ブラウザ起動</string>
<string name="button_product_search">商品検索</string>
<string name="button_search_book_contents">書籍の内容を検索する</string>
<string name="button_read_book">閲覧図書</string>
<string name="button_share_bookmark">ブックマークを送信する</string>
<string name="button_share_by_email">メールで送信する</string>
<string name="button_share_by_sms">SMSで送信する</string>

View file

@ -32,6 +32,7 @@
<string name="button_open_browser">打开浏览器</string>
<string name="button_product_search">打开产品搜索</string>
<string name="button_search_book_contents">搜索图书内容</string>
<string name="button_read_book">浏览本书</string>
<string name="button_share_bookmark">分享书签</string>
<string name="button_share_by_email">通过email分享</string>
<string name="button_share_by_sms">通过短信分享</string>

View file

@ -32,6 +32,7 @@
<string name="button_open_browser">打開瀏覽器</string>
<string name="button_product_search">打開產品搜索</string>
<string name="button_search_book_contents">搜索圖書內容</string>
<string name="button_read_book">瀏覽本書</string>
<string name="button_share_bookmark">分享書簽</string>
<string name="button_share_by_email">通過email分享</string>
<string name="button_share_by_sms">通過短信分享</string>

View file

@ -34,6 +34,7 @@
<string name="button_open_browser">Open browser</string>
<string name="button_product_search">Product Search</string>
<string name="button_search_book_contents">Search book contents</string>
<string name="button_read_book">Browse book</string>
<string name="button_share_bookmark">Share bookmark</string>
<string name="button_share_by_email">Share via email</string>
<string name="button_share_by_sms">Share via SMS</string>

View file

@ -17,6 +17,7 @@
package com.google.zxing.client.android.result;
import com.google.zxing.client.android.R;
import com.google.zxing.client.android.LocaleManager;
import com.google.zxing.client.result.ParsedResult;
import com.google.zxing.client.result.URIParsedResult;
@ -31,7 +32,8 @@ public final class URIResultHandler extends ResultHandler {
private static final int[] buttons = {
R.string.button_open_browser,
R.string.button_share_by_email,
R.string.button_share_by_sms
R.string.button_share_by_sms,
R.string.button_read_book,
};
public URIResultHandler(Activity activity, ParsedResult result) {
@ -40,7 +42,7 @@ public final class URIResultHandler extends ResultHandler {
@Override
public int getButtonCount() {
return buttons.length;
return isGoogleBooksURI() ? buttons.length : buttons.length - 1;
}
@Override
@ -51,15 +53,23 @@ public final class URIResultHandler extends ResultHandler {
@Override
public void handleButtonPress(int index) {
URIParsedResult uriResult = (URIParsedResult) getResult();
String uri = uriResult.getURI();
switch (index) {
case 0:
openURL(uriResult.getURI());
openURL(uri);
break;
case 1:
shareByEmail(uriResult.getURI());
shareByEmail(uri);
break;
case 2:
shareBySMS(uriResult.getURI());
shareBySMS(uri);
break;
case 3:
int equals = uri.indexOf('=');
String id = uri.substring(equals + 1);
String readBookURI = "http://books.google." +
LocaleManager.getBookSearchCountryTLD() + "/m#Read?id=" + id;
openURL(readBookURI);
break;
}
}
@ -68,4 +78,9 @@ public final class URIResultHandler extends ResultHandler {
public int getDisplayTitle() {
return R.string.result_uri;
}
private boolean isGoogleBooksURI() {
return ((URIParsedResult) getResult()).getURI().startsWith("http://google.com/books?id=");
}
}