diff --git a/app/build.gradle b/app/build.gradle
index 67870bf0..ff0cb43f 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -56,7 +56,7 @@ android {
}
dependencies {
- implementation 'com.github.SimpleMobileTools:Simple-Commons:dc3f4b619e'
+ implementation 'com.github.SimpleMobileTools:Simple-Commons:8979ca8187'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
implementation 'androidx.documentfile:documentfile:1.0.1'
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 56d144c8..5242cbe4 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -11,8 +11,6 @@
android:name="android.hardware.faketouch"
android:required="false" />
-
-
+ notes.filter { it.shouldBeUnlocked(this) }
+ .forEach(::removeProtection)
+
+ mNotes = notes
invalidateOptionsMenu()
mCurrentNote = mNotes[0]
mAdapter = NotesPagerAdapter(supportFragmentManager, mNotes, this)
@@ -1084,19 +1087,21 @@ class MainActivity : SimpleActivity() {
performSecurityCheck(
protectionType = mCurrentNote.protectionType,
requiredHash = mCurrentNote.protectionHash,
- successCallback = { _, _ -> removeProtection() }
+ successCallback = { _, _ -> removeProtection(mCurrentNote) }
)
}
- private fun removeProtection() {
- mCurrentNote.protectionHash = ""
- mCurrentNote.protectionType = PROTECTION_NONE
- NotesHelper(this).insertOrUpdateNote(mCurrentNote) {
- getCurrentFragment()?.apply {
- shouldShowLockedContent = true
- checkLockState()
+ private fun removeProtection(note: Note) {
+ note.protectionHash = ""
+ note.protectionType = PROTECTION_NONE
+ NotesHelper(this).insertOrUpdateNote(note) {
+ if (note == mCurrentNote) {
+ getCurrentFragment()?.apply {
+ shouldShowLockedContent = true
+ checkLockState()
+ }
+ invalidateOptionsMenu()
}
- invalidateOptionsMenu()
}
}
diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/WidgetConfigureActivity.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/WidgetConfigureActivity.kt
index 3e88f15a..be3f203f 100644
--- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/WidgetConfigureActivity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/WidgetConfigureActivity.kt
@@ -104,16 +104,18 @@ class WidgetConfigureActivity : SimpleActivity() {
if (mNotes.size == 1 && note == null) {
note = mNotes.first()
- performSecurityCheck(
- protectionType = note.protectionType,
- requiredHash = note.protectionHash,
- successCallback = { _, _ -> updateCurrentNote(note) },
- failureCallback = { finish() }
- )
- } else {
- if (note != null) {
+ if (note.shouldBeUnlocked(this)) {
updateCurrentNote(note)
+ } else {
+ performSecurityCheck(
+ protectionType = note.protectionType,
+ requiredHash = note.protectionHash,
+ successCallback = { _, _ -> updateCurrentNote(note) },
+ failureCallback = { finish() }
+ )
}
+ } else if (note != null) {
+ updateCurrentNote(note)
}
}
}
@@ -127,7 +129,7 @@ class WidgetConfigureActivity : SimpleActivity() {
RadioGroupDialog(this, items, mCurrentNoteId.toInt()) {
val selectedId = it as Int
val note = mNotes.firstOrNull { it.id!!.toInt() == selectedId } ?: return@RadioGroupDialog
- if (note.protectionType == PROTECTION_NONE) {
+ if (note.protectionType == PROTECTION_NONE || note.shouldBeUnlocked(this)) {
updateCurrentNote(note)
} else {
performSecurityCheck(
diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/fragments/ChecklistFragment.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/fragments/ChecklistFragment.kt
index 86b7aed5..06248352 100644
--- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/fragments/ChecklistFragment.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/fragments/ChecklistFragment.kt
@@ -78,11 +78,13 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
items.clear()
note.value.split("\n").map { it.trim() }.filter { it.isNotBlank() }.forEachIndexed { index, value ->
- items.add(ChecklistItem(
- id = index,
- title = value,
- isDone = false
- ))
+ items.add(
+ ChecklistItem(
+ id = index,
+ title = value,
+ isDone = false
+ )
+ )
}
saveChecklist()
@@ -120,6 +122,10 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
}
override fun checkLockState() {
+ if (note == null) {
+ return
+ }
+
view.apply {
checklist_content_holder.beVisibleIf(!note!!.isLocked() || shouldShowLockedContent)
checklist_fab.beVisibleIf(!note!!.isLocked() || shouldShowLockedContent)
diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/fragments/TextFragment.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/fragments/TextFragment.kt
index 3cf5991f..a53b293d 100644
--- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/fragments/TextFragment.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/fragments/TextFragment.kt
@@ -176,6 +176,10 @@ class TextFragment : NoteFragment() {
fun removeTextWatcher() = view.text_note_view.removeTextChangedListener(textWatcher)
override fun checkLockState() {
+ if (note == null) {
+ return
+ }
+
view.apply {
notes_counter.beVisibleIf((!note!!.isLocked() || shouldShowLockedContent) && config!!.showWordCount)
notes_scrollview.beVisibleIf(!note!!.isLocked() || shouldShowLockedContent)
@@ -263,11 +267,13 @@ class TextFragment : NoteFragment() {
text.removeSpan(span)
}
- Selection.setSelection(text, if (edit.before == null) {
- start
- } else {
- start + edit.before.length
- })
+ Selection.setSelection(
+ text, if (edit.before == null) {
+ start
+ } else {
+ start + edit.before.length
+ }
+ )
}
fun redo() {
@@ -285,11 +291,13 @@ class TextFragment : NoteFragment() {
text.removeSpan(o)
}
- Selection.setSelection(text, if (edit.after == null) {
- start
- } else {
- start + edit.after.length
- })
+ Selection.setSelection(
+ text, if (edit.after == null) {
+ start
+ } else {
+ start + edit.after.length
+ }
+ )
}
fun isUndoAvailable() = textHistory.position > 0
diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/models/Note.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/models/Note.kt
index f9dae3dc..7a5170b7 100644
--- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/models/Note.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/models/Note.kt
@@ -6,6 +6,8 @@ import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.Index
import androidx.room.PrimaryKey
+import com.simplemobiletools.commons.extensions.isBiometricIdAvailable
+import com.simplemobiletools.commons.helpers.PROTECTION_FINGERPRINT
import com.simplemobiletools.commons.helpers.PROTECTION_NONE
import java.io.File
@@ -17,7 +19,8 @@ data class Note(
@ColumnInfo(name = "type") var type: Int,
@ColumnInfo(name = "path") var path: String,
@ColumnInfo(name = "protection_type") var protectionType: Int,
- @ColumnInfo(name = "protection_hash") var protectionHash: String) {
+ @ColumnInfo(name = "protection_hash") var protectionHash: String
+) {
fun getNoteStoredValue(context: Context): String? {
return if (path.isNotEmpty()) {
@@ -37,4 +40,8 @@ data class Note(
}
fun isLocked() = protectionType != PROTECTION_NONE
+
+ fun shouldBeUnlocked(context: Context): Boolean {
+ return protectionType == PROTECTION_FINGERPRINT && !context.isBiometricIdAvailable()
+ }
}