Merge pull request #441 from qwertyfinger/feature/biometric-lock-api30

Add support for locking with biometric ID
This commit is contained in:
Tibor Kaputa 2021-08-24 19:23:48 +02:00 committed by GitHub
commit 63f9af4c60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 93 additions and 92 deletions

View File

@ -56,7 +56,7 @@ android {
}
dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:c45f0d662a'
implementation 'com.github.SimpleMobileTools:Simple-Commons:79c625cbe0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
implementation 'androidx.documentfile:documentfile:1.0.1'

View File

@ -1,7 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.simplemobiletools.notes.pro"
android:installLocation="auto">
@ -9,8 +7,6 @@
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="28" />
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
<uses-feature
android:name="android.hardware.faketouch"
android:required="false" />

View File

@ -83,7 +83,8 @@ class MainActivity : SimpleActivity() {
initViewPager(intent.getLongExtra(OPEN_NOTE_ID, -1L))
pager_title_strip.setTextSize(TypedValue.COMPLEX_UNIT_PX, getPercentageFontSize())
pager_title_strip.layoutParams.height = (pager_title_strip.height + resources.getDimension(R.dimen.activity_margin) * 2 * (config.fontSizePercentage / 100f)).toInt()
pager_title_strip.layoutParams.height =
(pager_title_strip.height + resources.getDimension(R.dimen.activity_margin) * 2 * (config.fontSizePercentage / 100f)).toInt()
checkWhatsNewDialog()
checkIntents(intent)
@ -1080,8 +1081,14 @@ class MainActivity : SimpleActivity() {
}
private fun unlockNote() {
SecurityDialog(this, mCurrentNote.protectionHash, mCurrentNote.protectionType) { hash, type, success ->
if (success) {
performSecurityCheck(
protectionType = mCurrentNote.protectionType,
requiredHash = mCurrentNote.protectionHash,
successCallback = { _, _ -> removeProtection() }
)
}
private fun removeProtection() {
mCurrentNote.protectionHash = ""
mCurrentNote.protectionType = PROTECTION_NONE
NotesHelper(this).insertOrUpdateNote(mCurrentNote) {
@ -1092,8 +1099,6 @@ class MainActivity : SimpleActivity() {
invalidateOptionsMenu()
}
}
}
}
fun currentNoteTextChanged(newText: String, showUndo: Boolean, showRedo: Boolean) {
if (!isSearchActive) {

View File

@ -13,7 +13,6 @@ import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.simplemobiletools.commons.dialogs.ColorPickerDialog
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
import com.simplemobiletools.commons.dialogs.SecurityDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.IS_CUSTOMIZING_COLORS
import com.simplemobiletools.commons.helpers.PROTECTION_NONE
@ -105,13 +104,12 @@ class WidgetConfigureActivity : SimpleActivity() {
if (mNotes.size == 1 && note == null) {
note = mNotes.first()
SecurityDialog(this, note.protectionHash, note.protectionType) { hash, type, success ->
if (success) {
updateCurrentNote(note)
} else {
finish()
}
}
performSecurityCheck(
protectionType = note.protectionType,
requiredHash = note.protectionHash,
successCallback = { _, _ -> updateCurrentNote(note) },
failureCallback = { finish() }
)
} else {
if (note != null) {
updateCurrentNote(note)
@ -132,11 +130,11 @@ class WidgetConfigureActivity : SimpleActivity() {
if (note.protectionType == PROTECTION_NONE) {
updateCurrentNote(note)
} else {
SecurityDialog(this, note.protectionHash, note.protectionType) { hash, type, success ->
if (success) {
updateCurrentNote(note)
}
}
performSecurityCheck(
protectionType = note.protectionType,
requiredHash = note.protectionHash,
successCallback = { _, _ -> updateCurrentNote(note) }
)
}
}
}

View File

@ -3,10 +3,10 @@ package com.simplemobiletools.notes.pro.fragments
import android.util.TypedValue
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.simplemobiletools.commons.dialogs.SecurityDialog
import com.simplemobiletools.commons.extensions.applyColorFilter
import com.simplemobiletools.commons.extensions.beVisibleIf
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
import com.simplemobiletools.commons.extensions.performSecurityCheck
import com.simplemobiletools.commons.helpers.PROTECTION_NONE
import com.simplemobiletools.notes.pro.extensions.config
import com.simplemobiletools.notes.pro.extensions.getPercentageFontSize
@ -22,10 +22,10 @@ abstract class NoteFragment : Fragment() {
note_locked_layout.beVisibleIf(note.isLocked() && !shouldShowLockedContent)
note_locked_image.applyColorFilter(config!!.textColor)
note_locked_label.setTextColor(context!!.config.textColor)
note_locked_label.setTextColor(requireContext().config.textColor)
note_locked_label.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getPercentageFontSize())
note_locked_show.setTextColor(context!!.getAdjustedPrimaryColor())
note_locked_show.setTextColor(requireContext().getAdjustedPrimaryColor())
note_locked_show.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getPercentageFontSize())
note_locked_show.setOnClickListener {
handleUnlocking()
@ -39,13 +39,15 @@ abstract class NoteFragment : Fragment() {
return
}
SecurityDialog(activity!!, note!!.protectionHash, note!!.protectionType) { hash, type, success ->
if (success) {
activity?.performSecurityCheck(
protectionType = note!!.protectionType,
requiredHash = note!!.protectionHash,
successCallback = { _, _ ->
shouldShowLockedContent = true
checkLockState()
callback?.invoke()
}
}
)
}
abstract fun checkLockState()