Skip to content

Commit fadf9be

Browse files
author
Andrii Chubko
committed
Use updated security API
1 parent bd28e3e commit fadf9be

File tree

4 files changed

+37
-32
lines changed

4 files changed

+37
-32
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ android {
5757

5858
dependencies {
5959
// implementation 'com.github.SimpleMobileTools:Simple-Commons:c45f0d662a'
60-
implementation 'com.github.qwertyfinger:Simple-Commons:d61a1c0910'
60+
implementation 'com.github.qwertyfinger:Simple-Commons:615349768d'
6161
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
6262
implementation 'androidx.documentfile:documentfile:1.0.1'
6363

app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ class MainActivity : SimpleActivity() {
8383

8484
initViewPager(intent.getLongExtra(OPEN_NOTE_ID, -1L))
8585
pager_title_strip.setTextSize(TypedValue.COMPLEX_UNIT_PX, getPercentageFontSize())
86-
pager_title_strip.layoutParams.height = (pager_title_strip.height + resources.getDimension(R.dimen.activity_margin) * 2 * (config.fontSizePercentage / 100f)).toInt()
86+
pager_title_strip.layoutParams.height =
87+
(pager_title_strip.height + resources.getDimension(R.dimen.activity_margin) * 2 * (config.fontSizePercentage / 100f)).toInt()
8788
checkWhatsNewDialog()
8889
checkIntents(intent)
8990

@@ -1080,18 +1081,22 @@ class MainActivity : SimpleActivity() {
10801081
}
10811082

10821083
private fun unlockNote() {
1083-
SecurityDialog(this, mCurrentNote.protectionHash, mCurrentNote.protectionType) { hash, type, success ->
1084-
if (success) {
1085-
mCurrentNote.protectionHash = ""
1086-
mCurrentNote.protectionType = PROTECTION_NONE
1087-
NotesHelper(this).insertOrUpdateNote(mCurrentNote) {
1088-
getCurrentFragment()?.apply {
1089-
shouldShowLockedContent = true
1090-
checkLockState()
1091-
}
1092-
invalidateOptionsMenu()
1093-
}
1084+
performSecurityCheck(
1085+
protectionType = mCurrentNote.protectionType,
1086+
requiredHash = mCurrentNote.protectionHash,
1087+
successCallback = { _, _ -> removeProtection() }
1088+
)
1089+
}
1090+
1091+
private fun removeProtection() {
1092+
mCurrentNote.protectionHash = ""
1093+
mCurrentNote.protectionType = PROTECTION_NONE
1094+
NotesHelper(this).insertOrUpdateNote(mCurrentNote) {
1095+
getCurrentFragment()?.apply {
1096+
shouldShowLockedContent = true
1097+
checkLockState()
10941098
}
1099+
invalidateOptionsMenu()
10951100
}
10961101
}
10971102

app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/WidgetConfigureActivity.kt

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import com.google.gson.Gson
1313
import com.google.gson.reflect.TypeToken
1414
import com.simplemobiletools.commons.dialogs.ColorPickerDialog
1515
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
16-
import com.simplemobiletools.commons.dialogs.SecurityDialog
1716
import com.simplemobiletools.commons.extensions.*
1817
import com.simplemobiletools.commons.helpers.IS_CUSTOMIZING_COLORS
1918
import com.simplemobiletools.commons.helpers.PROTECTION_NONE
@@ -105,13 +104,12 @@ class WidgetConfigureActivity : SimpleActivity() {
105104

106105
if (mNotes.size == 1 && note == null) {
107106
note = mNotes.first()
108-
SecurityDialog(this, note.protectionHash, note.protectionType) { hash, type, success ->
109-
if (success) {
110-
updateCurrentNote(note)
111-
} else {
112-
finish()
113-
}
114-
}
107+
performSecurityCheck(
108+
protectionType = note.protectionType,
109+
requiredHash = note.protectionHash,
110+
successCallback = { _, _ -> updateCurrentNote(note) },
111+
failureCallback = { finish() }
112+
)
115113
} else {
116114
if (note != null) {
117115
updateCurrentNote(note)
@@ -132,11 +130,11 @@ class WidgetConfigureActivity : SimpleActivity() {
132130
if (note.protectionType == PROTECTION_NONE) {
133131
updateCurrentNote(note)
134132
} else {
135-
SecurityDialog(this, note.protectionHash, note.protectionType) { hash, type, success ->
136-
if (success) {
137-
updateCurrentNote(note)
138-
}
139-
}
133+
performSecurityCheck(
134+
protectionType = note.protectionType,
135+
requiredHash = note.protectionHash,
136+
successCallback = { _, _ -> updateCurrentNote(note) }
137+
)
140138
}
141139
}
142140
}

app/src/main/kotlin/com/simplemobiletools/notes/pro/fragments/NoteFragment.kt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package com.simplemobiletools.notes.pro.fragments
33
import android.util.TypedValue
44
import android.view.ViewGroup
55
import androidx.fragment.app.Fragment
6-
import com.simplemobiletools.commons.dialogs.SecurityDialog
76
import com.simplemobiletools.commons.extensions.applyColorFilter
87
import com.simplemobiletools.commons.extensions.beVisibleIf
98
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
9+
import com.simplemobiletools.commons.extensions.performSecurityCheck
1010
import com.simplemobiletools.commons.helpers.PROTECTION_NONE
1111
import com.simplemobiletools.notes.pro.extensions.config
1212
import com.simplemobiletools.notes.pro.extensions.getPercentageFontSize
@@ -22,10 +22,10 @@ abstract class NoteFragment : Fragment() {
2222
note_locked_layout.beVisibleIf(note.isLocked() && !shouldShowLockedContent)
2323
note_locked_image.applyColorFilter(config!!.textColor)
2424

25-
note_locked_label.setTextColor(context!!.config.textColor)
25+
note_locked_label.setTextColor(requireContext().config.textColor)
2626
note_locked_label.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getPercentageFontSize())
2727

28-
note_locked_show.setTextColor(context!!.getAdjustedPrimaryColor())
28+
note_locked_show.setTextColor(requireContext().getAdjustedPrimaryColor())
2929
note_locked_show.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getPercentageFontSize())
3030
note_locked_show.setOnClickListener {
3131
handleUnlocking()
@@ -39,13 +39,15 @@ abstract class NoteFragment : Fragment() {
3939
return
4040
}
4141

42-
SecurityDialog(activity!!, note!!.protectionHash, note!!.protectionType) { hash, type, success ->
43-
if (success) {
42+
activity?.performSecurityCheck(
43+
protectionType = note!!.protectionType,
44+
requiredHash = note!!.protectionHash,
45+
successCallback = { _, _ ->
4446
shouldShowLockedContent = true
4547
checkLockState()
4648
callback?.invoke()
4749
}
48-
}
50+
)
4951
}
5052

5153
abstract fun checkLockState()

0 commit comments

Comments
 (0)