Skip to content

Commit

Permalink
biometric
Browse files Browse the repository at this point in the history
  • Loading branch information
lucky committed Jul 10, 2022
1 parent e68d9ca commit 8ee1f31
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "me.lucky.sentry"
minSdk 23
targetSdk 32
versionCode 5
versionName "1.0.4"
versionCode 6
versionName "1.0.5"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
21 changes: 14 additions & 7 deletions app/src/main/java/me/lucky/sentry/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ class MainActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
init()
init1()
if (initBiometric()) return
init2()
setup()
}

Expand Down Expand Up @@ -70,22 +71,28 @@ class MainActivity : AppCompatActivity() {

override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
super.onAuthenticationSucceeded(result)
init2()
setup()
}
})
prompt.authenticate(BiometricPrompt.PromptInfo.Builder()
.setTitle(getString(R.string.biometric_title))
.setConfirmationRequired(false)
.setAllowedAuthenticators(authenticators)
.build())
try {
prompt.authenticate(BiometricPrompt.PromptInfo.Builder()
.setTitle(getString(R.string.authentication))
.setConfirmationRequired(false)
.setAllowedAuthenticators(authenticators)
.build())
} catch (exc: Exception) { return false }
return true
}

private fun init() {
private fun init1() {
prefs = Preferences(this)
prefsdb = Preferences(this, encrypted = false)
prefs.copyTo(prefsdb)
admin = DeviceAdminManager(this)
}

private fun init2() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S ||
!admin.canUsbDataSignalingBeDisabled() ||
!admin.isDeviceOwner())
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
tools:context=".MainActivity">

<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
<string name="usb_data_signaling_description">When disabled, USB data connections (except from charging functions) are prohibited.</string>
<string name="usb_data_signaling_change_failed_popup">Failed to change USB data signaling policy</string>
<string name="max_failed_password_attempts_description">Maximum number of failed password attempts.</string>
<string name="biometric_title">Biometric login</string>
<string name="authentication">Authentication</string>
</resources>
1 change: 1 addition & 0 deletions fastlane/metadata/android/en-US/changelogs/6.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
biometric

0 comments on commit 8ee1f31

Please sign in to comment.