Issue 325, 327
authorsrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Thu, 21 Jan 2010 19:11:28 +0000 (19:11 +0000)
committersrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Thu, 21 Jan 2010 19:11:28 +0000 (19:11 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@1189 59b500cc-1b3d-0410-9834-0bbf25fbcc57

android/res/values-de/strings.xml
android/res/values-es/strings.xml
android/res/values-fr/strings.xml
android/res/values-it/strings.xml
android/res/values-ja-rJP/strings.xml
android/res/values-ru/strings.xml
android/res/values-zh-rCN/strings.xml
android/res/values-zh-rTW/strings.xml
android/res/values/strings.xml
android/src/com/google/zxing/client/android/Intents.java
android/src/com/google/zxing/client/android/history/HistoryManager.java

index 3355789..1d2662c 100644 (file)
@@ -99,6 +99,8 @@
   <string name="result_uri">URL gefunden</string>\r
   <string name="history_title">Historie</string>\r
   <string name="history_clear_text">Historie löschen</string>\r
+  <string name="history_send">Historie senden</string>\r
+  <string name="history_email_title">Barcode Scanner Historie</string> \r
   <string name="sbc_name">Google Book Search</string>\r
   <string name="share_name">Weitergabe mittels Barcode</string>\r
   <string name="title_about">Barcode Scanner v</string>\r
index 872bf63..671f4da 100644 (file)
@@ -99,6 +99,8 @@
   <string name="result_uri">URL encontrado</string>
   <string name="history_title">Historia</string>
   <string name="history_clear_text">Borrar historial</string>
+  <string name="history_send">Enviar historia</string>
+  <string name="history_email_title">Historia de Escáner de código de barras</string> 
   <string name="sbc_name">Búsqueda de libros de Google</string>
   <string name="share_name">Compartir por códigos de barras</string>
   <string name="title_about">Escáner de código de barras v</string>
index 6e8248c..a328c0a 100644 (file)
@@ -99,6 +99,8 @@
   <string name="result_uri">URL trouvée</string>
   <string name="history_title">Historique</string>
   <string name="history_clear_text">Vider l\'historique</string>
+  <string name="history_send">Envoyer historique</string>  
+  <string name="history_email_title">Historique de Barcode Scanner</string>
   <string name="sbc_name">Recherche Google Livres</string>
   <string name="share_name">Partager par code barre</string>
   <string name="title_about">Barcode Scanner v</string>
index bbf108f..3cefaac 100644 (file)
@@ -99,6 +99,8 @@
   <string name="result_uri">URL trovato</string>
   <string name="history_title">Cronologia</string>
   <string name="history_clear_text">Cancella cronologia</string>
+  <string name="history_send">Invia cronologia</string>  
+  <string name="history_email_title">Scansione codice a barre cronologia</string>
   <string name="sbc_name">Ricerca Google Book</string>
   <string name="share_name">Condividi tramite codice a barre</string>
   <string name="title_about">Scansione codice a barre v</string>
index c90eb3e..12b415f 100644 (file)
@@ -99,6 +99,8 @@
   <string name="result_uri">URL がヒットしました</string>
   <string name="history_title">歴史</string>
   <string name="history_clear_text">削除履歴</string>
+  <string name="history_send">歴史を送信</string>
+  <string name="history_email_title">QRコードスキャナー歴史</string>
   <string name="sbc_name">Google ブックス</string>
   <string name="share_name">バーコードで共有する</string>
   <string name="title_about">>QRコードスキャナー v</string>
index 96ce1b1..a686d6a 100644 (file)
@@ -99,6 +99,8 @@
   <string name="result_uri">Найден URL</string>
   <string name="history_title">История</string>
   <string name="history_clear_text">Очистить историю</string>
+  <string name="history_send">Отправить историю</string>
+  <string name="history_email_title">Сканер штрих-кодов История</string>
   <string name="sbc_name">Поиск книг Google</string>
   <string name="share_name">Поделиться через штрих-код</string>
   <string name="title_about">Сканер штрих-кодов версии </string>
index 1e2287b..fddad76 100644 (file)
@@ -99,6 +99,8 @@
   <string name="result_uri">找到URL</string>\r
   <string name="history_title">历史</string>\r
   <string name="history_clear_text">删除历史</string>\r
+  <string name="history_send">发送历史</string>\r
+  <string name="history_email_title">条码扫描器历史</string>\r
   <string name="sbc_name">Google图书搜索</string>\r
   <string name="share_name">通过条码分享</string>\r
   <string name="title_about">条码扫描器</string>\r
index 8bdf4b7..89a73de 100644 (file)
@@ -99,6 +99,8 @@
   <string name="result_uri">找到URL</string>\r
   <string name="history_title">歷史</string>\r
   <string name="history_clear_text">刪除歷史</string>\r
+  <string name="history_send">發送歷史</string>\r
+  <string name="history_email_title">條碼掃描器歷史</string>\r
   <string name="sbc_name">Google圖書搜索</string>\r
   <string name="share_name">通過條碼分享</string>\r
   <string name="title_about">條碼掃描器</string>\r
index 64d7c54..e099a31 100755 (executable)
   <string name="result_uri">Found URL</string>
   <string name="history_title">History</string>
   <string name="history_clear_text">Clear history</string>
+  <string name="history_send">Send history</string>  
+  <string name="history_email_title">Barcode Scanner history</string>
   <string name="sbc_name">Google Book Search</string>
   <string name="share_name">Share via barcode</string>
   <string name="title_about">Barcode Scanner v</string>
index bea5306..10e088a 100755 (executable)
@@ -70,6 +70,11 @@ public final class Intents {
      */
     public static final String RESULT_FORMAT = "SCAN_RESULT_FORMAT";
 
+    /**
+     * Setting this to false will not save scanned codes in the history.
+     */
+    public static final String SAVE_HISTORY = "SAVE_HISTORY";
+
     private Scan() {
     }
   }
index 0b06152..5bc5c33 100644 (file)
@@ -19,15 +19,19 @@ package com.google.zxing.client.android.history;
 import android.app.AlertDialog;
 import android.content.ContentValues;
 import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.res.Resources;
 import android.database.sqlite.SQLiteDatabase;
 import android.database.sqlite.SQLiteOpenHelper;
 import android.database.Cursor;
+import android.net.Uri;
 import android.os.Message;
 
 import java.util.List;
 import java.util.ArrayList;
 
 import com.google.zxing.BarcodeFormat;
+import com.google.zxing.client.android.Intents;
 import com.google.zxing.client.android.R;
 import com.google.zxing.client.android.CaptureActivity;
 import com.google.zxing.Result;
@@ -39,7 +43,7 @@ import com.google.zxing.Result;
  */
 public final class HistoryManager {
 
-  private static final int MAX_ITEMS = 20;
+  private static final int MAX_ITEMS = 50;
   private static final String[] TEXT_COL_PROJECTION = { DBHelper.TEXT_COL };
   private static final String[] TEXT_FORMAT_COL_PROJECTION = { DBHelper.TEXT_COL, DBHelper.FORMAT_COL };
   private static final String[] ID_COL_PROJECTION = { DBHelper.ID_COL };
@@ -75,15 +79,24 @@ public final class HistoryManager {
 
   public AlertDialog buildAlert() {
     final List<Result> items = getHistoryItems();
-    final String[] dialogItems = new String[items.size() + 1];
+    final String[] dialogItems = new String[items.size() + 2];
     for (int i = 0; i < items.size(); i++) {
       dialogItems[i] = items.get(i).getText();
     }
-    dialogItems[dialogItems.length - 1] = activity.getResources().getString(R.string.history_clear_text);
+    final Resources res = activity.getResources();
+    dialogItems[dialogItems.length - 2] = res.getString(R.string.history_send);
+    dialogItems[dialogItems.length - 1] = res.getString(R.string.history_clear_text);
     DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() {
       public void onClick(DialogInterface dialogInterface, int i) {
         if (i == dialogItems.length - 1) {
           clearHistory();
+        } else if (i == dialogItems.length - 2) {
+          String history = buildHistory();
+          Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse("mailto:"));
+          intent.putExtra(Intent.EXTRA_SUBJECT, res.getString(R.string.history_email_title));
+          intent.putExtra(Intent.EXTRA_TEXT, history);
+          intent.setType("text/plain");
+          activity.startActivity(intent);
         } else {
           Result result = items.get(i);
           Message message = Message.obtain(activity.getHandler(), R.id.decode_succeeded, result);
@@ -99,6 +112,10 @@ public final class HistoryManager {
 
   public void addHistoryItem(Result result) {
 
+    if (!activity.getIntent().getBooleanExtra(Intents.Scan.SAVE_HISTORY, true)) {
+      return; // Do not save this item to the history.
+    }
+
     SQLiteOpenHelper helper = new DBHelper(activity);
     SQLiteDatabase db = helper.getWritableDatabase();
     Cursor cursor = null;
@@ -149,6 +166,28 @@ public final class HistoryManager {
     }
   }
 
+  private String buildHistory() {
+    StringBuilder historyText = new StringBuilder();
+    SQLiteOpenHelper helper = new DBHelper(activity);
+    SQLiteDatabase db = helper.getReadableDatabase();
+    Cursor cursor = null;
+    try {
+      cursor = db.query(DBHelper.TABLE_NAME,
+                        TEXT_COL_PROJECTION,
+                        null, null, null, null,
+                        DBHelper.TIMESTAMP_COL + " DESC");
+      while (cursor.moveToNext()) {
+        historyText.append(cursor.getString(0)).append('\n');
+      }
+    } finally {
+      if (cursor != null) {
+        cursor.close();
+      }
+      db.close();
+    }
+    return historyText.toString();
+  }
+
   void clearHistory() {
     SQLiteOpenHelper helper = new DBHelper(activity);
     SQLiteDatabase db = helper.getWritableDatabase();