mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-06-05 17:00:23 +02:00
properly handle password protection of menu items
This commit is contained in:
@ -25,7 +25,6 @@ import kotlinx.android.synthetic.main.fragment_checklist.view.*
|
||||
class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
|
||||
|
||||
private var noteId = 0L
|
||||
private var note: Note? = null
|
||||
|
||||
lateinit var view: ViewGroup
|
||||
|
||||
|
@ -7,6 +7,7 @@ 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.helpers.PROTECTION_NONE
|
||||
import com.simplemobiletools.notes.pro.extensions.config
|
||||
import com.simplemobiletools.notes.pro.extensions.getPercentageFontSize
|
||||
import com.simplemobiletools.notes.pro.models.Note
|
||||
@ -14,6 +15,7 @@ import kotlinx.android.synthetic.main.fragment_checklist.view.*
|
||||
|
||||
abstract class NoteFragment : Fragment() {
|
||||
protected var shouldShowLockedContent = false
|
||||
protected var note: Note? = null
|
||||
|
||||
protected fun setupLockedViews(view: ViewGroup, note: Note) {
|
||||
view.apply {
|
||||
@ -26,12 +28,22 @@ abstract class NoteFragment : Fragment() {
|
||||
note_locked_show.setTextColor(context!!.getAdjustedPrimaryColor())
|
||||
note_locked_show.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getPercentageFontSize())
|
||||
note_locked_show.setOnClickListener {
|
||||
SecurityDialog(activity!!, note.protectionHash, note.protectionType) { hash, type, success ->
|
||||
if (success) {
|
||||
shouldShowLockedContent = true
|
||||
checkLockState()
|
||||
}
|
||||
}
|
||||
handleUnlocking()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun handleUnlocking(callback: (() -> Unit)? = null) {
|
||||
if (callback != null && (note!!.protectionType == PROTECTION_NONE || shouldShowLockedContent)) {
|
||||
callback()
|
||||
return
|
||||
}
|
||||
|
||||
SecurityDialog(activity!!, note!!.protectionHash, note!!.protectionType) { hash, type, success ->
|
||||
if (success) {
|
||||
shouldShowLockedContent = true
|
||||
checkLockState()
|
||||
callback?.invoke()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,6 @@ class TextFragment : NoteFragment() {
|
||||
private var isUndoOrRedo = false
|
||||
private var skipTextUpdating = false
|
||||
private var noteId = 0L
|
||||
private var note: Note? = null
|
||||
|
||||
lateinit var view: ViewGroup
|
||||
|
||||
|
Reference in New Issue
Block a user