mirror of
https://github.com/android-password-store/Android-Password-Store
synced 2025-08-29 05:17:43 +00:00
Declare and check for camera features (#1375)
* app: set feature requirements * Don't offer QR import option if no camera is present Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
e13a54f212
commit
023f03a227
@ -14,6 +14,13 @@
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
|
||||
<uses-feature
|
||||
android:name="android.hardware.touchscreen"
|
||||
android:required="false" />
|
||||
<uses-feature
|
||||
android:name="android.hardware.camera.any"
|
||||
android:required="false" />
|
||||
|
||||
<application
|
||||
android:name=".Application"
|
||||
android:allowBackup="false"
|
||||
|
@ -7,6 +7,7 @@ package dev.msfjarvis.aps.ui.crypto
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Bundle
|
||||
import android.text.InputType
|
||||
import android.view.Menu
|
||||
@ -158,22 +159,27 @@ class PasswordCreationActivity : BasePgpActivity(), OpenPgpServiceConnection.OnB
|
||||
else binding.extraContent.append(contents)
|
||||
}
|
||||
}
|
||||
val items = arrayOf(getString(R.string.otp_import_qr_code), getString(R.string.otp_import_manual_entry))
|
||||
MaterialAlertDialogBuilder(this@PasswordCreationActivity)
|
||||
.setItems(items) { _, index ->
|
||||
if (index == 0) {
|
||||
otpImportAction.launch(
|
||||
IntentIntegrator(this@PasswordCreationActivity)
|
||||
.setOrientationLocked(false)
|
||||
.setBeepEnabled(false)
|
||||
.setDesiredBarcodeFormats(QR_CODE)
|
||||
.createScanIntent()
|
||||
)
|
||||
} else if (index == 1) {
|
||||
OtpImportDialogFragment().show(supportFragmentManager, "OtpImport")
|
||||
val hasCamera = packageManager?.hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY) == true
|
||||
if (hasCamera) {
|
||||
val items = arrayOf(getString(R.string.otp_import_qr_code), getString(R.string.otp_import_manual_entry))
|
||||
MaterialAlertDialogBuilder(this@PasswordCreationActivity)
|
||||
.setItems(items) { _, index ->
|
||||
when (index) {
|
||||
0 ->
|
||||
otpImportAction.launch(
|
||||
IntentIntegrator(this@PasswordCreationActivity)
|
||||
.setOrientationLocked(false)
|
||||
.setBeepEnabled(false)
|
||||
.setDesiredBarcodeFormats(QR_CODE)
|
||||
.createScanIntent()
|
||||
)
|
||||
1 -> OtpImportDialogFragment().show(supportFragmentManager, "OtpImport")
|
||||
}
|
||||
}
|
||||
}
|
||||
.show()
|
||||
.show()
|
||||
} else {
|
||||
OtpImportDialogFragment().show(supportFragmentManager, "OtpImport")
|
||||
}
|
||||
}
|
||||
|
||||
directoryInputLayout.apply {
|
||||
|
Loading…
x
Reference in New Issue
Block a user