diff --git a/app/src/main/kotlin/de/markusfisch/android/binaryeye/fragment/BarcodeFragment.kt b/app/src/main/kotlin/de/markusfisch/android/binaryeye/fragment/BarcodeFragment.kt index 9ff15622..bc24d098 100644 --- a/app/src/main/kotlin/de/markusfisch/android/binaryeye/fragment/BarcodeFragment.kt +++ b/app/src/main/kotlin/de/markusfisch/android/binaryeye/fragment/BarcodeFragment.kt @@ -10,10 +10,12 @@ import android.support.v4.app.Fragment import android.view.* import android.widget.EditText import de.markusfisch.android.binaryeye.R +import de.markusfisch.android.binaryeye.app.db import de.markusfisch.android.binaryeye.app.hasWritePermission import de.markusfisch.android.binaryeye.content.copyToClipboard import de.markusfisch.android.binaryeye.content.shareFile import de.markusfisch.android.binaryeye.content.shareText +import de.markusfisch.android.binaryeye.database.toScan import de.markusfisch.android.binaryeye.graphics.COLOR_BLACK import de.markusfisch.android.binaryeye.graphics.COLOR_WHITE import de.markusfisch.android.binaryeye.io.addSuffixIfNotGiven @@ -42,6 +44,7 @@ class BarcodeFragment : Fragment() { private val scope = CoroutineScope(Dispatchers.IO + parentJob) private lateinit var barcode: Barcode<*> + private lateinit var addToHistoryItem: MenuItem override fun onCreate(state: Bundle?) { super.onCreate(state) @@ -131,10 +134,18 @@ class BarcodeFragment : Fragment() { override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { inflater.inflate(R.menu.fragment_barcode, menu) + addToHistoryItem = menu.findItem(R.id.add_to_history) } override fun onOptionsItemSelected(item: MenuItem): Boolean { return when (item.itemId) { + R.id.add_to_history -> { + readAndAddToHistory(barcode.bitmap(), barcode.format) + addToHistoryItem.isVisible = false + context.toast(R.string.added_to_history) + true + } + R.id.copy_to_clipboard -> { context.apply { copyToClipboard(barcode.text()) @@ -373,5 +384,31 @@ private fun Bitmap.saveAsPng(outputStream: OutputStream, quality: Int = 90) = compress(Bitmap.CompressFormat.PNG, quality, outputStream) private val fileNameCharacters = "[^A-Za-z0-9]".toRegex() -private fun encodeFileName(name: String): String = - fileNameCharacters.replace(name, "_").take(16).trim('_').lowercase(Locale.getDefault()) +private fun encodeFileName(name: String): String = fileNameCharacters + .replace(name, "_") + .take(16) + .trim('_') + .lowercase(Locale.getDefault()) + +private fun readAndAddToHistory( + bitmap: Bitmap, + format: BarcodeFormat +) { + ZxingCpp.readBitmap( + bitmap, + 0, 0, + bitmap.width, bitmap.height, + 0, + ZxingCpp.ReaderOptions( + tryHarder = true, + tryRotate = true, + tryInvert = true, + tryDownscale = true, + maxNumberOfSymbols = 1, + formats = setOf(format) + ) + )?.first { + db.insertScan(it.toScan()) + true + } +} diff --git a/app/src/main/res/drawable/ic_action_history_add.xml b/app/src/main/res/drawable/ic_action_history_add.xml new file mode 100644 index 00000000..bd5808bf --- /dev/null +++ b/app/src/main/res/drawable/ic_action_history_add.xml @@ -0,0 +1,3 @@ + + + diff --git a/app/src/main/res/menu/fragment_barcode.xml b/app/src/main/res/menu/fragment_barcode.xml index ec7097ac..6a5b6144 100644 --- a/app/src/main/res/menu/fragment_barcode.xml +++ b/app/src/main/res/menu/fragment_barcode.xml @@ -1,6 +1,11 @@ + Добави 2FA Търси в мрежата Търсещо сканиране + Add to history + Added to history Извеждане в файл Извеждане като? CSV файл със запетаи diff --git a/app/src/main/res/values-bn/strings.xml b/app/src/main/res/values-bn/strings.xml index e131f700..98713758 100644 --- a/app/src/main/res/values-bn/strings.xml +++ b/app/src/main/res/values-bn/strings.xml @@ -166,6 +166,8 @@ ২এফএ যোগ করো ওয়েবে খুঁজো আগেরগুলোতে খুঁজো + Add to history + Added to history নথিতে রপ্তানি করো রপ্তানির ধরণ? কমাসহ সিএসভি(.csv) নথি diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 53d743ed..6d9b5082 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -168,6 +168,8 @@ Přidat 2FA Vyhledat na webu Vyhledat sken + Add to history + Added to history Exportovat do souboru Exportovat jako CSV oddělené čárkami diff --git a/app/src/main/res/values-da/strings.xml b/app/src/main/res/values-da/strings.xml index bff99e2d..b012ee69 100644 --- a/app/src/main/res/values-da/strings.xml +++ b/app/src/main/res/values-da/strings.xml @@ -166,6 +166,8 @@ Tilføj 2FA Søg på nettet Søg scanning + Add to history + Added to history Eksporter til fil Eksporter som? CSV-fil med kommaer diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index cdfab23e..f7c903e4 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -166,6 +166,8 @@ 2FA hinzufügen Suche im Internet Code suchen + Zu gespeicherten Codes hinzufügen + Zu den gespeicherten Codes hinzugefügt In Datei exportieren Exportieren als? CSV Datei mit Kommas diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index fca45125..5e075404 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -166,6 +166,8 @@ Añadir 2FA Buscar en la web Buscar escaneo + Add to history + Added to history Exportar a archivo ¿Exportar como? Archivo CSV con comas diff --git a/app/src/main/res/values-fa/strings.xml b/app/src/main/res/values-fa/strings.xml index 76d11c59..6088eb11 100644 --- a/app/src/main/res/values-fa/strings.xml +++ b/app/src/main/res/values-fa/strings.xml @@ -166,6 +166,8 @@ افزودن احراز هویت چندعاملی(2FA) جست‌وجوی وب جست‌وجوی پویش + Add to history + Added to history برون‌ریزی به پرونده برون‌ریزی به عنوان؟ پروندهٔ سی‌اس‌وی با ویرگول diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 17600634..2d2e7fb2 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -166,6 +166,8 @@ Ajouter l\'authentification à deux facteurs Rechercher sur internet Rechercher un scan + Add to history + Added to history Exporter en tant que fichier Exporter en tant que ? CSV avec virgules diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index d461c05f..87e972b6 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -166,6 +166,8 @@ Kétlépcsős hitelesítés hozzáadása Keresés a weben Beolvasás keresése + Add to history + Added to history Exportálás fájlba Exportálja másként? CSV-fájl vesszővel diff --git a/app/src/main/res/values-in/strings.xml b/app/src/main/res/values-in/strings.xml index d4b229ba..967d6b29 100644 --- a/app/src/main/res/values-in/strings.xml +++ b/app/src/main/res/values-in/strings.xml @@ -165,6 +165,8 @@ Tambahkan 2FA Cari secara daring Cari pindaian + Add to history + Added to history Ekspor ke berkas Ekspor sebagai? CSV dengan koma diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index b63c1118..dd824c45 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -166,6 +166,8 @@ Aggiungi 2FA Cerca nel web Cerca scansione + Add to history + Added to history Esporta su file Come esportare? CSV con virgole diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 9107ab1f..59005799 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -165,6 +165,8 @@ 二段階認証を追加 ウェブで検索 スキャン結果を検索 + Add to history + Added to history ファイルにエクスポート ファイル形式を選択 コンマ区切りのCSVファイル diff --git a/app/src/main/res/values-ka/strings.xml b/app/src/main/res/values-ka/strings.xml index 6e24bca3..8888f086 100644 --- a/app/src/main/res/values-ka/strings.xml +++ b/app/src/main/res/values-ka/strings.xml @@ -166,6 +166,8 @@ დავამატოთ 2FA ქსელში მოძებნა სკანირების ძიება + Add to history + Added to history ექსპორტი ფაილში შესანახი ფაილის ფორმატი CSV (გამყოფი - მძიმე) diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index 82b21a2f..cd25d4eb 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -165,6 +165,8 @@ Add 2FA Search the web Search scan + Add to history + Added to history Export to file Export as? CSV file with commas diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index aa748040..dc3a946a 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -166,6 +166,8 @@ 2FA toevoegen Zoeken op internet Scan op internet zoeken + Add to history + Added to history Uitvoer naar bestand Exporteren als? CSV bestand met komma\'s diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 62581a8d..a33d91d7 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -15,6 +15,8 @@ Utwórz kod kreskowy Historia Format + Add to history + Added to history Eksportuj do pliku Nazwa pliku Eksportuj jako JSON diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index af10d74c..11ae9ef6 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -166,6 +166,8 @@ Adicionar 2FA Buscar na internet Buscar nas digitalizações salvas + Add to history + Added to history Exportar para arquivo Exportar em qual formato? Arquivo CSV com vírgulas diff --git a/app/src/main/res/values-ru-rRU/strings.xml b/app/src/main/res/values-ru-rRU/strings.xml index c6f70583..2178240b 100644 --- a/app/src/main/res/values-ru-rRU/strings.xml +++ b/app/src/main/res/values-ru-rRU/strings.xml @@ -168,6 +168,8 @@ Добавить 2FA Поиск в сети Поиск сканирования + Add to history + Added to history Экспортировать в файл Формат файла экспорта CSV (разделитель – запятая) diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index fb3191c7..13d630ad 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -166,6 +166,8 @@ 2FA\'ya ekle Web\'i ara Taramayı ara + Add to history + Added to history Dosyaya dışa aktar Ne olarak dışa aktarılsın? Virgüller ile CSV diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index 618f9616..c6c98397 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -167,6 +167,8 @@ Додати 2FA Шукати в мережі Шукати сканування + Add to history + Added to history Експортувати в файл Експортувати як? CSV із комами diff --git a/app/src/main/res/values-vi/strings.xml b/app/src/main/res/values-vi/strings.xml index a035cfba..23b6a200 100644 --- a/app/src/main/res/values-vi/strings.xml +++ b/app/src/main/res/values-vi/strings.xml @@ -165,6 +165,8 @@ Thêm xác thực hai bước Tìm kiếm web Tìm kiếm lần quét + Add to history + Added to history Xuất thành tệp Xuất dưói dạng? Tệp CSV với dấu phẩy diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index b787d64b..174169d7 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -165,6 +165,8 @@ 添加两步验证 在互联网中搜索 搜索扫描记录 + Add to history + Added to history 导出为文件 另存为? 逗号分隔的 CSV diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index eaa591eb..45b231d0 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -165,6 +165,8 @@ 加入雙重驗證 (2FA) 在網路上搜尋 搜尋掃描記錄 + Add to history + Added to history 匯出檔案 另存為? 逗號分隔的 CSV 檔案 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b1318454..a6ae04e0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -166,6 +166,8 @@ Add 2FA Search the web Search scan + Add to history + Added to history Export to file Export as? CSV file with commas diff --git a/svg/ic_action_history_add.svg b/svg/ic_action_history_add.svg new file mode 100644 index 00000000..9d16b4c4 --- /dev/null +++ b/svg/ic_action_history_add.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file