Skip to content

Commit

Permalink
Merge pull request #211 from SecUSo/development
Browse files Browse the repository at this point in the history
Update to version 4.5.8
  • Loading branch information
udenr authored Jan 19, 2024
2 parents d69af2b + 68e429d commit a530d30
Show file tree
Hide file tree
Showing 6 changed files with 173 additions and 235 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
compileSdk 34
targetSdkVersion 34
multiDexEnabled true
versionCode 38
versionName "4.5.7"
versionCode 39
versionName "4.5.8"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
buildFeatures.dataBinding = true
vectorDrawables.useSupportLibrary = true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.secuso.privacyfriendlycodescanner.qrscanner

import android.app.PendingIntent
import android.content.Intent
import android.os.Build
import android.service.quicksettings.TileService
Expand All @@ -13,7 +14,12 @@ class QuickTileService : TileService() {

val intent = Intent(this, ScannerActivity::class.java)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP)
val pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_IMMUTABLE)

startActivityAndCollapse(intent)
if (Build.VERSION.SDK_INT >= 34) {
startActivityAndCollapse(pendingIntent)
} else {
startActivityAndCollapse(intent)
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package com.secuso.privacyfriendlycodescanner.qrscanner.database

import android.content.Context
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.util.Base64
import androidx.room.TypeConverter
import com.google.gson.Gson
import com.google.zxing.BarcodeFormat
import com.google.zxing.ResultPoint
import java.io.ByteArrayOutputStream

/**
* This class offers type converters for the room database.
*
* @author Christopher Beckmann
* @see AppDatabase
*/
object Converters {
@JvmStatic
@TypeConverter
fun encodeImage(bitmap: Bitmap?): String? {
if (bitmap == null) return null
val byteArrayOutputStream = ByteArrayOutputStream()
bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream)
val byteArray = byteArrayOutputStream.toByteArray()
return Base64.encodeToString(byteArray, Base64.NO_WRAP)
}

@JvmStatic
@TypeConverter
fun decodeImage(encodedImage: String?): Bitmap? {
if (encodedImage == null) return null
val decodedBytes = Base64.decode(encodedImage, Base64.NO_WRAP)
return BitmapFactory.decodeByteArray(decodedBytes, 0, decodedBytes.size)
}

@JvmStatic
@TypeConverter
fun fromText(text: String?): BarcodeFormat? {
return try {
BarcodeFormat.valueOf(text!!)
} catch (e: IllegalArgumentException) {
null
} catch (e: NullPointerException) {
null
}
}

@JvmStatic
@TypeConverter
fun fromBarcodeFormat(bcf: BarcodeFormat): String {
return bcf.name
}

@JvmStatic
@TypeConverter
fun fromResultPoints(rp: Array<ResultPoint?>?): String? {
val gson = Gson()
return gson.toJson(rp)
}

@JvmStatic
@TypeConverter
fun convertResultPointFromJson(jsonString: String?): Array<ResultPoint?>? {
val gson = Gson()
return gson.fromJson(jsonString, Array<ResultPoint?>::class.java)
}

fun dpFromPx(context: Context, px: Float): Float {
return px / context.resources.displayMetrics.density
}

fun pxFromDp(context: Context, dp: Float): Float {
return dp * context.resources.displayMetrics.density
}
}

This file was deleted.

Loading

0 comments on commit a530d30

Please sign in to comment.