Compare commits

..
12 Commits
Author SHA1 Message Date
Markus Fisch b9a6410959 Advance version number to 1.5.1 2019-04-12 20:46:26 +02:00
Markus Fisch 512f5e00dd Show content bytes instead of chars in hex dump 2019-04-12 20:42:21 +02:00
Markus Fisch 91c2364958 Advance version number to 1.5.0 2019-04-10 21:53:24 +02:00
Markus Fisch 1e3f1c553c Show a hex dump of decoded contents
And update character count when contents are edited too.
2019-04-10 21:48:33 +02:00
Markus Fisch 80c65a48a0 Make when() return the fragment
Instead of assigning a help variable.
2019-04-10 10:30:46 +02:00
Markus Fisch 4c04ffb7db Move string literal to the right side
Left-over from Java "".equals() pattern.
2019-04-10 10:30:16 +02:00
Markus Fisch cc3949fa71 Fix evaluating sent text from share menu 2019-04-10 10:29:55 +02:00
Markus Fisch 904a0ecbdd Update CameraView library to latest version 2019-04-08 20:56:29 +02:00
Balázs ÚrandMarkus Fisch 9155dd026d Update Hungarian translation 2019-03-26 09:53:39 +01:00
grenagitandMarkus Fisch 7286a06985 Add French translation 2019-03-22 15:25:34 +01:00
Markus Fisch a71552a406 Advance version number to 1.4.3 2019-03-21 10:27:09 +01:00
Markus Fisch 5857e8c394 Remove toStartOf/toLeftOf from time view
Circular dependency because "format" already specifies
toEndOf/toRightOf.
2019-03-21 10:20:49 +01:00
9 changed files with 177 additions and 54 deletions
+11
View File
@@ -1,5 +1,16 @@
# Change Log
## 1.5.1
* Fix generating hex dump
## 1.5.0
* Show a hex dump of decoded contents
* Fix processing text from share menu
* Add French translation
## 1.4.3
* Fix broken history listing
## 1.4.2
* Show barcode type and content length after decoding
+3 -3
View File
@@ -14,8 +14,8 @@ android {
minSdkVersion 9
targetSdkVersion sdk_version
versionCode 17
versionName '1.4.2'
versionCode 20
versionName '1.5.1'
// it's recommended to set this value to the lowest API level
// able to provide all the functionality
@@ -64,5 +64,5 @@ dependencies {
implementation "com.android.support:appcompat-v7:$support_version"
implementation "com.android.support:design:$support_version"
implementation 'com.google.zxing:core:3.3.3'
implementation 'com.github.markusfisch:CameraView:1.8.2'
implementation 'com.github.markusfisch:CameraView:1.8.3'
}
@@ -101,7 +101,7 @@ class CameraActivity : AppCompatActivity() {
restoreZoom()
if (intent?.action == Intent.ACTION_SEND) {
if ("text/plain" == intent.type) {
if (intent.type == "text/plain") {
handleSendText(intent)
} else if (intent.type?.startsWith("image/") == true) {
handleSendImage(intent)
@@ -205,7 +205,7 @@ class CameraActivity : AppCompatActivity() {
private fun handleSendText(intent: Intent) {
val text = intent.getStringExtra(Intent.EXTRA_TEXT)
if (text?.isEmpty() == true) {
if (text?.isEmpty() == false) {
startActivity(MainActivity.getEncodeIntent(this, text, true))
finish()
}
@@ -12,7 +12,6 @@ import de.markusfisch.android.binaryeye.R
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.Toolbar
@@ -36,21 +35,19 @@ class MainActivity : AppCompatActivity() {
supportActionBar?.setDisplayHomeAsUpEnabled(true)
if (state == null) {
val fragment: Fragment
when {
intent?.hasExtra(HISTORY) == true -> fragment = HistoryFragment()
intent?.hasExtra(ENCODE) == true -> fragment = EncodeFragment.newInstance(
setFragment(supportFragmentManager, when {
intent?.hasExtra(HISTORY) == true -> HistoryFragment()
intent?.hasExtra(ENCODE) == true -> EncodeFragment.newInstance(
intent.getStringExtra(ENCODE)
)
intent?.hasExtra(DECODE) == true -> fragment = DecodeFragment.newInstance(
intent?.hasExtra(DECODE) == true -> DecodeFragment.newInstance(
intent.getStringExtra(DECODE),
intent.getSerializableExtra(
DECODE_FORMAT
) as BarcodeFormat
)
else -> fragment = DecodeFragment()
}
setFragment(supportFragmentManager, fragment)
else -> DecodeFragment()
})
}
}
@@ -12,6 +12,8 @@ import android.os.Build
import android.os.Bundle
import android.support.v4.app.Fragment
import android.text.ClipboardManager
import android.text.Editable
import android.text.TextWatcher
import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuInflater
@@ -25,6 +27,7 @@ import android.widget.Toast
class DecodeFragment : Fragment() {
private lateinit var contentView: EditText
private lateinit var formatView: TextView
private lateinit var hexView: TextView
private lateinit var format: BarcodeFormat
override fun onCreate(state: Bundle?) {
@@ -50,19 +53,44 @@ class DecodeFragment : Fragment() {
contentView = view.findViewById(R.id.content)
contentView.setText(content)
contentView.addTextChangedListener(object : TextWatcher {
override fun afterTextChanged(s: Editable?) {
updateFormatAndHex(contentView.text.toString())
}
override fun beforeTextChanged(
s: CharSequence?,
start: Int,
count: Int,
after: Int
) {}
override fun onTextChanged(
s: CharSequence?,
start: Int,
before: Int,
count: Int
) {}
})
formatView = view.findViewById(R.id.format)
hexView = view.findViewById(R.id.hex)
view.findViewById<View>(R.id.share).setOnClickListener {
share(getContent())
}
updateFormatAndHex(content)
return view
}
private fun updateFormatAndHex(content: String) {
formatView.text = resources.getQuantityString(
R.plurals.barcode_info,
content.length,
format.toString(),
content.length
)
view.findViewById<View>(R.id.share).setOnClickListener {
share(getContent())
}
return view
hexView.text = hexDump(content, 33)
}
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
@@ -135,6 +163,48 @@ class DecodeFragment : Fragment() {
startActivity(intent)
}
private fun hexDump(content: String, charsPerLine: Int): String {
if (charsPerLine < 4 || content.isEmpty()) {
return ""
}
val dump = StringBuilder()
val hex = StringBuilder()
val ascii = StringBuilder()
val itemsPerLine = (charsPerLine - 1) / 4
val bytes = content.toByteArray()
val len = bytes.size
var i = 0
while (true) {
val ord = bytes[i]
hex.append(String.format("%02X ", ord))
ascii.append(if (ord > 31) ord.toChar() else " ")
++i
val posInLine = i % itemsPerLine
val atEnd = i >= len
var atLineEnd = posInLine == 0
if (atEnd && !atLineEnd) {
for (j in posInLine until itemsPerLine) {
hex.append(" ")
}
atLineEnd = true
}
if (atLineEnd) {
dump.append(hex.toString())
dump.append(" ")
dump.append(ascii.toString())
dump.append("\n")
hex.setLength(0)
ascii.setLength(0)
}
if (atEnd) {
break
}
}
return dump.toString()
}
companion object {
private const val CONTENT = "content"
private const val FORMAT = "format"
+43 -23
View File
@@ -4,30 +4,50 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
tools:targetApi="o"
android:id="@+id/content"
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:gravity="start|top"
android:imeOptions="flagNoExtractUi"
android:inputType="textMultiLine"
android:typeface="monospace"
android:hint="@string/content"
android:importantForAutofill="no"/>
<TextView
android:id="@+id/format"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/content"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
android:gravity="end|top"
android:textSize="14sp"/>
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
tools:targetApi="o"
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:gravity="start|top"
android:imeOptions="flagNoExtractUi"
android:inputType="textMultiLine"
android:typeface="monospace"
android:hint="@string/content"
android:importantForAutofill="no"/>
<TextView
android:id="@+id/format"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/content"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
android:gravity="end|top"
android:textSize="14sp"/>
<TextView
android:id="@+id/hex"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/format"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
android:typeface="monospace"
android:textSize="12sp"/>
</RelativeLayout>
</ScrollView>
<android.support.design.widget.FloatingActionButton
tools:ignore="UnusedAttribute"
android:id="@+id/share"
-2
View File
@@ -7,8 +7,6 @@
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/format"
android:layout_toStartOf="@+id/format"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"/>
+27
View File
@@ -0,0 +1,27 @@
<resources>
<string name="no_camera_no_fun">Cette application n\'a aucun sens sans accès possible à la caméra. Au revoir.</string>
<string name="camera_error">Impossible d\'accéder à la caméra, veuillez réessayer</string>
<string name="scan_code">Scanner le code</string>
<string name="compose_barcode">Créer un code-barres</string>
<string name="decode_barcode">Décoder le code-barres</string>
<string name="content">Contenu</string>
<string name="copy_to_clipboard">Copier dans le presse-papier</string>
<string name="put_into_clipboard">Mis dans le presse-papiers</string>
<string name="open_url">Ouvrir l\'url</string>
<string name="cannot_resolve_action">Aucune application ne peut ouvrir ça</string>
<string name="format">Format</string>
<string name="size">Taille en pixels</string>
<string name="width_by_height">%1$d×%2$d</string>
<string name="input_content_here">Entrez votre contenu ici</string>
<string name="encode">ENCODER</string>
<string name="error_no_content">Contenu manquant</string>
<string name="view_barcode">Voir le code barre</string>
<string name="info">Info</string>
<string name="switch_camera">Changer de camera</string>
<string name="history">Historique</string>
<string name="use_history">Sauvegarder l\'histoire des scans</string>
<string name="remove_scan">Supprimer le scan</string>
<string name="really_remove_scan">Supprimer le scan ?</string>
<string name="really_remove_all_scans">Supprimer tous les scans ?</string>
<string name="no_barcode_found">Aucun code-barres trouvé</string>
</resources>
+9 -9
View File
@@ -3,11 +3,11 @@
<string name="camera_error">Nem lehet hozzáférni a kamerához, próbálja meg újra</string>
<string name="scan_code">Kód beolvasása</string>
<string name="compose_barcode">Vonalkód létrehozása</string>
<string name="decode_barcode">Decode barcode</string>
<string name="decode_barcode">Vonalkód visszafejtése</string>
<string name="content">Tartalom</string>
<plurals name="barcode_info">
<item quantity="one">%1$s\n%2$d character</item>
<item quantity="other">%1$s\n%2$d characters</item>
<item quantity="one">%1$s\n%2$d karakter</item>
<item quantity="other">%1$s\n%2$d karakter</item>
</plurals>
<string name="copy_to_clipboard">Másolás a vágólapra</string>
<string name="put_into_clipboard">Vágólapra helyezés</string>
@@ -22,10 +22,10 @@
<string name="view_barcode">Vonalkód megtekintése</string>
<string name="info">Információ</string>
<string name="switch_camera">Kamera átkapcsolása</string>
<string name="history">History</string>
<string name="use_history">Save scan history</string>
<string name="remove_scan">Remove scan</string>
<string name="really_remove_scan">Really remove scan?</string>
<string name="really_remove_all_scans">Really remove all scans?</string>
<string name="no_barcode_found">No barcode found</string>
<string name="history">Előzmények</string>
<string name="use_history">Beolvasási előzmények mentése</string>
<string name="remove_scan">Beolvasás eltávolítása</string>
<string name="really_remove_scan">Valóban eltávolítja a beolvasást?</string>
<string name="really_remove_all_scans">Valóban eltávolítja az összes beolvasását?</string>
<string name="no_barcode_found">Nem található vonalkód</string>
</resources>