Add option to remember duplicate scans
authorsrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Wed, 22 Sep 2010 13:25:29 +0000 (13:25 +0000)
committersrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Wed, 22 Sep 2010 13:25:29 +0000 (13:25 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@1603 59b500cc-1b3d-0410-9834-0bbf25fbcc57

23 files changed:
android/res/values-ar/strings.xml
android/res/values-cs/strings.xml
android/res/values-da/strings.xml
android/res/values-de/strings.xml
android/res/values-es/strings.xml
android/res/values-fi/strings.xml
android/res/values-fr/strings.xml
android/res/values-hu/strings.xml
android/res/values-it/strings.xml
android/res/values-ja-rJP/strings.xml
android/res/values-nl/strings.xml
android/res/values-pl/strings.xml
android/res/values-pt/strings.xml
android/res/values-ru/strings.xml
android/res/values-sl/strings.xml
android/res/values-sv/strings.xml
android/res/values-tr/strings.xml
android/res/values-zh-rCN/strings.xml
android/res/values-zh-rTW/strings.xml
android/res/values/strings.xml
android/res/xml/preferences.xml
android/src/com/google/zxing/client/android/PreferencesActivity.java
android/src/com/google/zxing/client/android/history/HistoryManager.java

index 4089785..8ad391f 100644 (file)
   <string name="preferences_general_title">إعدادات عامة</string>
   <string name="preferences_name">إعدادات</string>
   <string name="preferences_play_beep_title">صوت تنبيه</string>
+  <string name="preferences_remember_duplicates_summary">بفحص مخزن متعددة من نفس الباركود في التاريخ</string>
+  <string name="preferences_remember_duplicates_title">تذكر التكرارات</string>
   <string name="preferences_result_title">إعدادات النتائج</string>
   <string name="preferences_scanning_title">عندما لمسح الباركود</string>
   <string name="preferences_vibrate_title">اهتزاز</string>
index 0751791..0039699 100644 (file)
   <string name="preferences_general_title">Hlavní nastavení</string>
   <string name="preferences_name">Nastavení</string>
   <string name="preferences_play_beep_title">Zvuky</string>
+  <string name="preferences_remember_duplicates_summary">Uložit více skenuje stejného čárového kódu v dějinách</string>
+  <string name="preferences_remember_duplicates_title">Pamatujte duplikáty</string>
   <string name="preferences_result_title">Výsledek nastavení</string>
   <string name="preferences_scanning_title">Při skenování pro čárové kódy\u2026</string>
   <string name="preferences_vibrate_title">Vibrace</string>
index 9be2065..59fa015 100644 (file)
   <string name="preferences_general_title">Generelle indstillinger</string>
   <string name="preferences_name">Indstillinger</string>
   <string name="preferences_play_beep_title">Bip</string>
+  <string name="preferences_remember_duplicates_summary">Gemme flere scanninger af den samme stregkode i Historie</string>
+  <string name="preferences_remember_duplicates_title">Husk dubletter</string>
   <string name="preferences_result_title">Resultatindstillinger</string>
   <string name="preferences_scanning_title">Når der scannes efter stregkoder\u2026</string>
   <string name="preferences_vibrate_title">Vibrér</string>
index 5e6cd39..90f46a7 100644 (file)
   <string name="preferences_general_title">Allgemeine Einstellungen</string>
   <string name="preferences_name">Einstellungen</string>
   <string name="preferences_play_beep_title">Piepsen</string>
+  <string name="preferences_remember_duplicates_summary">Speichern mehrerer Scans der gleichen Barcode in Historie</string>
+  <string name="preferences_remember_duplicates_title">Denken Sie daran, Duplikate</string>
   <string name="preferences_result_title">Ergebnis-Einstellungen</string>
   <string name="preferences_scanning_title">Beim Scannen von Barcodes\u2026</string>
   <string name="preferences_vibrate_title">Vibrieren</string>
index 433ec45..8b99814 100644 (file)
   <string name="preferences_general_title">Configuración general</string>
   <string name="preferences_name">Configuración</string>
   <string name="preferences_play_beep_title">Bip</string>
+  <string name="preferences_remember_duplicates_summary">Guarde varios escáneres del mismo código de barras en la historia</string>
+  <string name="preferences_remember_duplicates_title">Recuerde duplicados</string>
   <string name="preferences_result_title">Configuración de resultados</string>
   <string name="preferences_scanning_title">Cuando escanea códigos de barras\u2026</string>
   <string name="preferences_vibrate_title">Vibrar</string>
index b8d2749..6139dda 100644 (file)
   <string name="preferences_general_title">Yleiset asetukset</string>
   <string name="preferences_name">Asetukset</string>
   <string name="preferences_play_beep_title">Piip</string>
+  <string name="preferences_remember_duplicates_summary">Tallentaa useita kopioita samaa viivakoodia historiassa</string>
+  <string name="preferences_remember_duplicates_title">Muista kaksoiskappaleet</string>
   <string name="preferences_result_title">Tuloksien asetukset</string>
   <string name="preferences_scanning_title">Kun skannaus viivakoodia\u2026</string>
   <string name="preferences_vibrate_title">Värinä</string>
index dd770a2..e707375 100644 (file)
   <string name="preferences_general_title">Paramètres généraux</string>
   <string name="preferences_name">Paramètres</string>
   <string name="preferences_play_beep_title">Bip</string>
+  <string name="preferences_remember_duplicates_summary">Enregistrer scans multiples de la même code à barres dans l\'histoire</string>
+  <string name="preferences_remember_duplicates_title">N\'oubliez pas les doublons</string>
   <string name="preferences_result_title">Paramètres de résultat</string>
   <string name="preferences_scanning_title">Pendant la lecture de codes-barres\u2026</string>
   <string name="preferences_vibrate_title">Vibrer</string>
index 470de67..2e120e1 100644 (file)
   <string name="preferences_general_title">Általános beállítások</string>
   <string name="preferences_name">Beállítások</string>
   <string name="preferences_play_beep_title">Sípolás</string>
+  <string name="preferences_remember_duplicates_summary">Tárolni több vizsgál az azonos vonalkód történelem</string>
+  <string name="preferences_remember_duplicates_title">Emlékezzen duplázik</string>
   <string name="preferences_result_title">Találati beállítások</string>
   <string name="preferences_scanning_title">Ha a lapolvasó a vonalkód\u2026</string>
   <string name="preferences_vibrate_title">Rezgés</string>
index f61f4aa..baa132d 100644 (file)
   <string name="preferences_general_title">Impostazioni generali</string>
   <string name="preferences_name">Impostazioni</string>
   <string name="preferences_play_beep_title">Suona</string>
+  <string name="preferences_remember_duplicates_summary">Conservare scansioni multiple del codice a barre stesso nella Cronologia</string>
+  <string name="preferences_remember_duplicates_title">Ricordate i duplicati</string>
   <string name="preferences_result_title">Impostazioni risultato</string>
   <string name="preferences_scanning_title">Durante la scansione di codici a barre\u2026</string>
   <string name="preferences_vibrate_title">Vibra</string>
index 8974cd4..ea795a0 100644 (file)
   <string name="preferences_general_title">一般設定</string>
   <string name="preferences_name">設定</string>
   <string name="preferences_play_beep_title">通知音</string>
+  <string name="preferences_remember_duplicates_summary">歴史の中で、同じバーコードのストア複数のスキャン</string>
+  <string name="preferences_remember_duplicates_title">覚えておいて重複</string>
   <string name="preferences_result_title">検索結果の設定</string>
   <string name="preferences_scanning_title">時バーコードスキャン</string>
   <string name="preferences_vibrate_title">バイブ</string>
index f33550a..9004613 100644 (file)
   <string name="preferences_general_title">Basisinstellingen</string>
   <string name="preferences_name">Instellingen</string>
   <string name="preferences_play_beep_title">Piepen</string>
+  <string name="preferences_remember_duplicates_summary">Onthoud meerdere scans van dezelfde barcode in de geschiedenis</string>
+  <string name="preferences_remember_duplicates_title">Onthoud duplicaten</string>
   <string name="preferences_result_title">Instellingen voor resultaat</string>
   <string name="preferences_scanning_title">Bij het scannen van barcodes voor de\u2026</string>
   <string name="preferences_vibrate_title">Trillen</string>
index dab1966..645259e 100644 (file)
   <string name="preferences_general_title">Ustawienia ogólne</string>
   <string name="preferences_name">Ustawienia</string>
   <string name="preferences_play_beep_title">Piszcz</string>
+  <string name="preferences_remember_duplicates_summary">Przechowywanie wielu skanowanie kodów kreskowych w tej samej historii</string>
+  <string name="preferences_remember_duplicates_title">Pamiętaj, duplikaty</string>
   <string name="preferences_result_title">Ustawienia rezultatów</string>
   <string name="preferences_scanning_title">Podczas skanowania kodów kreskowych\u2026</string>
   <string name="preferences_vibrate_title">Wibruj</string>
index 90fc3a8..9f7e95c 100644 (file)
   <string name="preferences_general_title">Definições Gerais</string>
   <string name="preferences_name">Definições</string>
   <string name="preferences_play_beep_title">Bip</string>
+  <string name="preferences_remember_duplicates_summary">Armazenar vários scans do mesmo código de barras em História</string>
+  <string name="preferences_remember_duplicates_title">Lembre-se de duplicatas</string>
   <string name="preferences_result_title">Definições de resultados</string>
   <string name="preferences_scanning_title">Quando a digitalização de códigos de barras\u2026</string>
   <string name="preferences_vibrate_title">Vibrar</string>
index 24dfd9e..a1e6225 100644 (file)
   <string name="preferences_general_title">Общие настройки</string>
   <string name="preferences_name">Настройки</string>
   <string name="preferences_play_beep_title">Пищать</string>
+  <string name="preferences_remember_duplicates_summary">Магазин нескольких сканирование одного и того же штрих-код в истории</string>
+  <string name="preferences_remember_duplicates_title">Помните дубликатов</string>
   <string name="preferences_result_title">Настройки результата</string>
   <string name="preferences_scanning_title">При сканировании штрих-кодов\u2026</string>
   <string name="preferences_vibrate_title">Вибрировать</string>
index 7723f3c..78e8aaa 100644 (file)
   <string name="preferences_general_title">Splošne nastavitve</string>
   <string name="preferences_name">Nastavitve</string>
   <string name="preferences_play_beep_title">Pisk</string>
+  <string name="preferences_remember_duplicates_summary">Shranjevanje več skandiranje iste črtne kode v zgodovini</string>
+  <string name="preferences_remember_duplicates_title">Zapomni si dvojnikov</string>
   <string name="preferences_result_title">Nastavitve rezultatov branja</string>
   <string name="preferences_scanning_title">Ko berete črtne kode\u2026</string>
   <string name="preferences_vibrate_title">Vibriraj</string>
index 872a94d..44adbf2 100644 (file)
   <string name="preferences_general_title">Grundläggande installningar</string>
   <string name="preferences_name">Inställningar</string>
   <string name="preferences_play_beep_title">Pip</string>
+  <string name="preferences_remember_duplicates_summary">Lagra flera skanningar av samma streckkod i historia</string>
+  <string name="preferences_remember_duplicates_title">Kom ihåg dubbletter</string>
   <string name="preferences_result_title">Resultatinställningar</string>
   <string name="preferences_scanning_title">När du skannar för streckkoder\u2026</string>
   <string name="preferences_vibrate_title">Vibrera</string>
index f8cee0d..612f0d4 100644 (file)
   <string name="preferences_general_title">Genel ayarlar</string>
   <string name="preferences_name">Ayarlar</string>
   <string name="preferences_play_beep_title">Bip</string>
+  <string name="preferences_remember_duplicates_summary">Tarih aynı barkod saklayın çoklu tarama</string>
+  <string name="preferences_remember_duplicates_title">Hatırla çiftleri</string>
   <string name="preferences_result_title">Sonuç ayarları</string>
   <string name="preferences_scanning_title">Ne zaman barkodlar \u2026 için tarama</string>
   <string name="preferences_vibrate_title">Titret</string>
index 790f25d..7161201 100644 (file)
   <string name="preferences_general_title">一般设置</string>
   <string name="preferences_name">设置</string>
   <string name="preferences_play_beep_title">提示音</string>
+  <string name="preferences_remember_duplicates_summary">在历史上同条码扫描店多</string>
+  <string name="preferences_remember_duplicates_title">记住重复</string>
   <string name="preferences_result_title">结果设置</string>
   <string name="preferences_scanning_title">当扫描条形码</string>
   <string name="preferences_vibrate_title">振动</string>
index 43a5443..eb77761 100644 (file)
   <string name="preferences_general_title">一般設置</string>
   <string name="preferences_name">設置</string>
   <string name="preferences_play_beep_title">提示音</string>
+  <string name="preferences_remember_duplicates_summary">存儲多個條碼掃描相同的歷史</string>
+  <string name="preferences_remember_duplicates_title">記住重複</string>
   <string name="preferences_result_title">結果設定</string>
   <string name="preferences_scanning_title">當掃描條形碼</string>
   <string name="preferences_vibrate_title">振動</string>
index b261c7b..f26b3b5 100755 (executable)
   <string name="preferences_general_title">General settings</string>
   <string name="preferences_name">Settings</string>
   <string name="preferences_play_beep_title">Beep</string>
+  <string name="preferences_remember_duplicates_summary">Store multiple scans of the same barcode in History</string>
+  <string name="preferences_remember_duplicates_title">Remember duplicates</string>
   <string name="preferences_result_title">Result settings</string>
   <string name="preferences_scanning_title">When scanning for barcodes\u2026</string>
   <string name="preferences_vibrate_title">Vibrate</string>
index 8ef9a1e..c408fb7 100755 (executable)
         android:key="preferences_copy_to_clipboard"
         android:defaultValue="true"
         android:title="@string/preferences_copy_to_clipboard_title"/>
+    <CheckBoxPreference
+        android:key="preferences_remember_duplicates"
+        android:defaultValue="false"
+        android:title="@string/preferences_remember_duplicates_title"
+        android:summary="@string/preferences_remember_duplicates_summary"/>
   </PreferenceCategory>
   <PreferenceCategory android:title="@string/preferences_result_title">
     <EditTextPreference
index 480a1d3..d3c7488 100755 (executable)
@@ -44,6 +44,7 @@ public final class PreferencesActivity extends PreferenceActivity
   public static final String KEY_COPY_TO_CLIPBOARD = "preferences_copy_to_clipboard";
   public static final String KEY_FRONT_LIGHT = "preferences_front_light";
   public static final String KEY_BULK_MODE = "preferences_bulk_mode";
+  public static final String KEY_REMEMBER_DUPLICATES = "preferences_remember_duplicates";
 
   public static final String KEY_HELP_VERSION_SHOWN = "preferences_help_version_shown";
   public static final String KEY_NOT_OUR_RESULTS_SHOWN = "preferences_not_out_results_shown";
index f57726c..af22f87 100644 (file)
@@ -19,6 +19,7 @@ package com.google.zxing.client.android.history;
 import android.app.AlertDialog;
 import android.content.ContentValues;
 import android.content.DialogInterface;
+import android.content.SharedPreferences;
 import android.content.res.Resources;
 import android.database.sqlite.SQLiteDatabase;
 import android.database.sqlite.SQLiteOpenHelper;
@@ -36,9 +37,11 @@ import java.util.Date;
 import java.util.List;
 import java.util.ArrayList;
 
+import android.preference.PreferenceManager;
 import android.util.Log;
 import com.google.zxing.BarcodeFormat;
 import com.google.zxing.client.android.Intents;
+import com.google.zxing.client.android.PreferencesActivity;
 import com.google.zxing.client.android.R;
 import com.google.zxing.client.android.CaptureActivity;
 import com.google.zxing.Result;
@@ -53,7 +56,7 @@ public final class HistoryManager {
   private static final String TAG = HistoryManager.class.getSimpleName();
 
   private static final int MAX_ITEMS = 50;
-  private static final String[] TEXT_COL_PROJECTION = { DBHelper.TEXT_COL };
+  //private static final String[] TEXT_COL_PROJECTION = { DBHelper.TEXT_COL };
   private static final String[] GET_ITEM_COL_PROJECTION = {
       DBHelper.TEXT_COL,
       DBHelper.FORMAT_COL,
@@ -124,11 +127,16 @@ public final class HistoryManager {
       return; // Do not save this item to the history.
     }
 
+    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
+    boolean rememberDuplicates = prefs.getBoolean(PreferencesActivity.KEY_REMEMBER_DUPLICATES, false);
+
+    if (!rememberDuplicates) {
+      deletePrevious(result.getText());
+    }
+
     SQLiteOpenHelper helper = new DBHelper(activity);
     SQLiteDatabase db = helper.getWritableDatabase();
     try {
-      // Delete if already exists
-      db.delete(DBHelper.TABLE_NAME, DBHelper.TEXT_COL + "=?", new String[] { result.getText() });
       // Insert
       ContentValues values = new ContentValues();
       values.put(DBHelper.TEXT_COL, result.getText());
@@ -141,6 +149,16 @@ public final class HistoryManager {
     }
   }
 
+  private void deletePrevious(String text) {
+    SQLiteOpenHelper helper = new DBHelper(activity);
+    SQLiteDatabase db = helper.getWritableDatabase();
+    try {
+      db.delete(DBHelper.TABLE_NAME, DBHelper.TEXT_COL + "=?", new String[] { text });
+    } finally {
+      db.close();
+    }
+  }
+
   public void trimHistory() {
     SQLiteOpenHelper helper = new DBHelper(activity);
     SQLiteDatabase db = helper.getWritableDatabase();