Skip to content

Commit

Permalink
Merge pull request #436 from sora-xor/mwr-923
Browse files Browse the repository at this point in the history
MWR-923
  • Loading branch information
ZFRFM authored Oct 10, 2024
2 parents 8ef5079 + a41747a commit 6bb9def
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
1 change: 0 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<!-- <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />-->

<queries>
<package android:name="com.soracard.iban.wallet"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

package jp.co.soramitsu.feature_assets_impl.presentation.screens.scan

import android.app.Activity
import android.content.Intent
import android.graphics.Color
import android.net.Uri
import android.os.Bundle
import android.view.KeyEvent
import android.widget.Toast
import androidx.activity.result.ActivityResult
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.PickVisualMediaRequest
import androidx.activity.result.contract.ActivityResultContracts
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
Expand Down Expand Up @@ -68,12 +68,10 @@ class QRCodeScannerActivity : AppCompatActivity() {

private var capture: CaptureManager? = null

private val startForResultFromGallery: ActivityResultLauncher<Intent> =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result: ActivityResult ->
if (result.resultCode == Activity.RESULT_OK) {
result.data?.data?.let { selectedImageUri ->
viewModel.decodeScannedQrCodeUri(selectedImageUri)
}
private val startForResultFromGallery: ActivityResultLauncher<PickVisualMediaRequest> =
registerForActivityResult(ActivityResultContracts.PickVisualMedia()) { resultUri: Uri? ->
resultUri?.let { selectedImageUri ->
viewModel.decodeScannedQrCodeUri(selectedImageUri)
}
}

Expand Down Expand Up @@ -176,14 +174,8 @@ class QRCodeScannerActivity : AppCompatActivity() {
}

private fun selectQrFromGallery() {
val intent = Intent().apply {
type = QR_CODE_IMAGE_TYPE
action = Intent.ACTION_GET_CONTENT
}
startForResultFromGallery.launch(intent)
}

private companion object {
const val QR_CODE_IMAGE_TYPE = "image/*"
val pickVisualMediaRequest =
PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.ImageOnly)
startForResultFromGallery.launch(pickVisualMediaRequest)
}
}

0 comments on commit 6bb9def

Please sign in to comment.