Compare commits

...
7 Commits
Author SHA1 Message Date
Markus Fisch fd54bc604e Advance version number to 1.68.5 2026-03-02 19:07:06 +01:00
Markus Fisch 59b62ecbc4 Revert ZXingC++ to v2.3.0.4
Because 3.x requires C++20, what requires minSdk 21.

While ZXingC++ 3.x compiles and runs on some devices (with the
current minSdk), the library does crash on other devices.

So updating to ZXingC++ 3.x requires more work, unfortunately.

This reverts commit
a90bdad117
4b2eb80612
7a59126312
2026-03-02 18:59:41 +01:00
Markus Fisch de6a2863f3 Advance version number to 1.68.4 2026-02-24 23:57:27 +01:00
Markus Fisch 4b2eb80612 Fix margin for 1D barcodes
Since ZXingCpp v3.0.0+ changed the default from -1 to 0.

Using -1 results in an exception in `BitMatrix::setRegion()`
because of invalid top/left coordinates.
2026-02-24 23:52:04 +01:00
Markus Fisch 2de40d2277 Advance version number to 1.68.3 2026-02-23 23:13:10 +01:00
Markus Fisch 7673b7cb0d Fallback to getParcelableExtra(name)
When getting the DECODE extra.

`getParcelableExtra(name, Class)` can throw on some versions
of Android when the ClassLoader associated with the Bundle's
lazy-decoded value is null in certain scenarios (e.g., after
an activity restart where the system re-delivers the intent).
Simply fallback to the "deprecated" `getParcelableExtra(name)`
which works in this case, because it doesn't verify the
parcelable's class against Scan::class.java.
2026-02-23 21:00:30 +01:00
Markus Fisch 097c5e4453 Improve getting fragment for MainActivity
And properly finish the MainActivity for malformed intents.
2026-02-23 17:21:30 +01:00
9 changed files with 64 additions and 38 deletions
+9
View File
@@ -1,5 +1,14 @@
# Change Log
## 1.68.5
* Downgrade ZXingCpp for compatibilty
## 1.68.4
* Fix generating 1D barcodes
## 1.68.3
* Stability improvement
## 1.68.2
* Fix barcode regeneration
+4 -4
View File
@@ -8,8 +8,8 @@ android {
minSdk 9
targetSdk sdk_version
versionCode 156
versionName '1.68.2'
versionCode 159
versionName '1.68.5'
}
signingConfigs {
@@ -77,8 +77,8 @@ dependencies {
// External
implementation 'com.github.markusfisch:CameraView:1.10.0'
implementation 'com.github.markusfisch:ScalingImageView:1.4.1'
implementation 'com.github.markusfisch:zxing-cpp:v3.0.2.0'
implementation 'com.github.markusfisch:ScalingImageView:1.4.3'
implementation 'com.github.markusfisch:zxing-cpp:v2.3.0.4'
// Testing
testImplementation 'junit:junit:4.13.2'
@@ -604,6 +604,7 @@ class CameraActivity : AppCompatActivity() {
tryRotate = prefs.autoRotate,
tryInvert = true,
tryDownscale = true,
returnCodabarStartEnd = true,
maxNumberOfSymbols = 1,
textMode = TextMode.PLAIN
)
@@ -68,7 +68,12 @@ class MainActivity : AppCompatActivity() {
}
if (state == null) {
supportFragmentManager?.setFragment(getFragmentForIntent(intent))
val fragment = intent?.getFragmentForIntent()
if (fragment == null) {
finish()
return
}
supportFragmentManager?.setFragment(fragment)
}
}
@@ -78,32 +83,29 @@ class MainActivity : AppCompatActivity() {
private const val ENCODE = "encode"
const val DECODED = "decoded"
private fun getFragmentForIntent(intent: Intent?): Fragment {
intent ?: return PreferencesFragment()
return when {
intent.hasExtra(PREFERENCES) -> PreferencesFragment()
intent.hasExtra(HISTORY) -> HistoryFragment()
private fun Intent.getFragmentForIntent(): Fragment? = when {
hasExtra(PREFERENCES) -> PreferencesFragment()
hasExtra(HISTORY) -> HistoryFragment()
intent.dataString?.let(::isEncodeDeeplink) == true -> {
val uri = Uri.parse(intent.dataString)
EncodeFragment.newInstance(
content = uri.getQueryParameter("content"),
format = uri.getQueryParameter("format")?.uppercase(),
execute = uri.getQueryParameter("execute")
.let { it == "" || it.toBoolean() }
)
}
intent.hasExtra(ENCODE) -> EncodeFragment.newInstance(
intent.getStringExtra(ENCODE)
dataString?.let(::isEncodeDeeplink) == true -> {
val uri = Uri.parse(dataString)
EncodeFragment.newInstance(
content = uri.getQueryParameter("content"),
format = uri.getQueryParameter("format")?.uppercase(),
execute = uri.getQueryParameter("execute")
.let { it == "" || it.toBoolean() }
)
intent.hasExtra(DECODED) -> intent.getScanExtra(DECODED)?.let {
DecodeFragment.newInstance(it)
} ?: DecodeFragment()
else -> PreferencesFragment()
}
hasExtra(ENCODE) -> EncodeFragment.newInstance(
getStringExtra(ENCODE)
)
hasExtra(DECODED) -> getScanExtra(DECODED)?.let {
DecodeFragment.newInstance(it)
}
else -> PreferencesFragment()
}
fun getPreferencesIntent(context: Context): Intent {
@@ -148,15 +150,22 @@ class MainActivity : AppCompatActivity() {
}
}
private fun Intent.getScanExtra(name: String): Scan? = try {
if (
Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU
) {
@Suppress("DEPRECATION")
getParcelableExtra(name)
} else {
@Suppress("DEPRECATION")
private fun Intent.getScanExtra(name: String): Scan? = if (
Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU
) {
try {
getParcelableExtra(name, Scan::class.java)
} catch (_: Throwable) {
// `getParcelableExtra(name, Class)` can throw on some versions
// of Android when the ClassLoader associated with the Bundle's
// lazy-decoded value is null in certain scenarios (e.g., after
// an activity restart where the system re-delivers the intent).
// Simply fallback to the "deprecated" `getParcelableExtra(name)`
// which works in this case, because it doesn't verify the
// parcelable's class against Scan::class.java.
null
}
} catch (_: Throwable) {
} else {
null
}
} ?: getParcelableExtra(name)
@@ -49,6 +49,7 @@ class PickActivity : AppCompatActivity() {
tryRotate = true,
tryInvert = true,
tryDownscale = true,
returnCodabarStartEnd = true,
maxNumberOfSymbols = 1,
formats = prefs.barcodeFormats.toFormatSet()
)
@@ -108,7 +108,7 @@ class ContentBarcode<T>(
content: T,
format: BarcodeFormat,
val ecLevel: Int = -1,
val margin: Int = 1,
val margin: Int = -1,
colors: BarcodeColors = BarcodeColors.BLACK_ON_WHITE
) : Barcode<T>(content, format, colors) {
override fun toBitmap(size: Int) = ZxingCpp.encodeAsBitmap(
@@ -0,0 +1,2 @@
* Stability improvement
@@ -0,0 +1,2 @@
* Fix generating 1D barcodes
@@ -0,0 +1,2 @@
* Downgrade ZXingCpp for compatibilty