-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added scanning QR code * Added scanning of QRs fetched from taking photo * Extracted request keys for adding qrs
- Loading branch information
1 parent
ea6266c
commit 89002fd
Showing
39 changed files
with
749 additions
and
226 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Empty file.
File renamed without changes.
Empty file.
Empty file.
2 changes: 2 additions & 0 deletions
2
.idea/sonarlint/issuestore/8/4/84fd4a110b9403a94c2f799ccd3300b2d0794a92
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
.idea/sonarlint/issuestore/8/e/8e9a51b6a9336159830daf66bb6f8b920a025fce
This file was deleted.
Oops, something went wrong.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
File renamed without changes.
Empty file.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
app/src/main/java/dgca/wallet/app/android/certificate/add/AddConstants.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* ---license-start | ||
* eu-digital-green-certificates / dgca-wallet-app-android | ||
* --- | ||
* Copyright (C) 2021 T-Systems International GmbH and all other contributors | ||
* --- | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* ---license-end | ||
* | ||
* Created by osarapulov on 8/26/21 12:24 PM | ||
*/ | ||
|
||
package dgca.wallet.app.android.certificate.add | ||
|
||
const val ADD_REQUEST_KEY = "ADD_REQUEST" | ||
const val ADD_QR_STRING_KEY = "ADD_QR_STRING" | ||
|
32 changes: 32 additions & 0 deletions
32
app/src/main/java/dgca/wallet/app/android/certificate/add/BitmapFetcher.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* ---license-start | ||
* eu-digital-green-certificates / dgca-wallet-app-android | ||
* --- | ||
* Copyright (C) 2021 T-Systems International GmbH and all other contributors | ||
* --- | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* ---license-end | ||
* | ||
* Created by osarapulov on 8/25/21 3:24 PM | ||
*/ | ||
|
||
package dgca.wallet.app.android.certificate.add | ||
|
||
import android.graphics.Bitmap | ||
import android.net.Uri | ||
|
||
interface BitmapFetcher { | ||
fun loadBitmapByImageUri(uri: Uri): Bitmap | ||
|
||
fun loadBitmapByPdfUri(uri: Uri): Bitmap | ||
} |
54 changes: 54 additions & 0 deletions
54
app/src/main/java/dgca/wallet/app/android/certificate/add/DefaultBitmapFetcher.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* ---license-start | ||
* eu-digital-green-certificates / dgca-wallet-app-android | ||
* --- | ||
* Copyright (C) 2021 T-Systems International GmbH and all other contributors | ||
* --- | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* ---license-end | ||
* | ||
* Created by osarapulov on 8/25/21 3:25 PM | ||
*/ | ||
|
||
package dgca.wallet.app.android.certificate.add | ||
|
||
import android.content.Context | ||
import android.graphics.Bitmap | ||
import android.graphics.ImageDecoder | ||
import android.graphics.pdf.PdfRenderer | ||
import android.net.Uri | ||
import android.os.Build | ||
import android.provider.MediaStore | ||
|
||
class DefaultBitmapFetcher(context: Context) : BitmapFetcher { | ||
private val appContext = context.applicationContext | ||
|
||
override fun loadBitmapByImageUri(uri: Uri): Bitmap { | ||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { | ||
ImageDecoder.decodeBitmap(ImageDecoder.createSource(appContext.contentResolver, uri)) | ||
} else { | ||
MediaStore.Images.Media.getBitmap(appContext.contentResolver, uri) | ||
}.copy(Bitmap.Config.ARGB_8888, true) | ||
} | ||
|
||
override fun loadBitmapByPdfUri(uri: Uri): Bitmap = | ||
appContext.contentResolver.openFileDescriptor(uri, "r")!!.use { fileDescriptor -> | ||
PdfRenderer(fileDescriptor).use { pdfRenderer -> | ||
pdfRenderer.openPage(0).use { page -> | ||
val bitmap = Bitmap.createBitmap(page.width, page.height, Bitmap.Config.ARGB_8888) | ||
page.render(bitmap, null, null, PdfRenderer.Page.RENDER_MODE_FOR_DISPLAY) | ||
bitmap | ||
} | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
app/src/main/java/dgca/wallet/app/android/certificate/add/DefaultFileSaver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* ---license-start | ||
* eu-digital-green-certificates / dgca-wallet-app-android | ||
* --- | ||
* Copyright (C) 2021 T-Systems International GmbH and all other contributors | ||
* --- | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* ---license-end | ||
* | ||
* Created by osarapulov on 8/25/21 12:36 PM | ||
*/ | ||
|
||
package dgca.wallet.app.android.certificate.add | ||
|
||
import android.content.Context | ||
import android.net.Uri | ||
import java.io.File | ||
import java.io.FileOutputStream | ||
|
||
class DefaultFileSaver(context: Context) : FileSaver { | ||
private val appContext = context.applicationContext | ||
|
||
override fun saveFileFromUri(uri: Uri, targetDirectoryName: String, targetFileName: String): File { | ||
val directory = File(appContext.filesDir, targetDirectoryName).apply { if (!isDirectory || !exists()) mkdirs() } | ||
val file = File(directory, targetFileName) | ||
|
||
appContext.contentResolver.openInputStream(uri)?.use { inputStream -> | ||
FileOutputStream(file).use { outputStream -> | ||
val buffer = ByteArray(8 * 1024) | ||
var bytesRead: Int | ||
while (inputStream.read(buffer).also { bytesRead = it } != -1) { | ||
outputStream.write(buffer, 0, bytesRead) | ||
} | ||
} | ||
} | ||
|
||
return file | ||
} | ||
} |
Oops, something went wrong.