avoid showing locked note content without password

This commit is contained in:
tibbi
2021-05-20 22:48:05 +02:00
parent ca32224071
commit 81c6da22d4
5 changed files with 166 additions and 36 deletions

View File

@ -116,9 +116,18 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
}
}
checkLockState()
setupAdapter()
}
override fun checkLockState() {
view.apply {
checklist_content_holder.beVisibleIf(!note!!.isLocked() || shouldShowLockedContent)
checklist_fab.beVisibleIf(!note!!.isLocked() || shouldShowLockedContent)
setupLockedViews(this, note!!)
}
}
private fun showNewItemDialog() {
NewChecklistItemDialog(activity as SimpleActivity) { titles ->
var currentMaxId = items.maxBy { item -> item.id }?.id ?: 0

View File

@ -1,5 +1,40 @@
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.notes.pro.extensions.config
import com.simplemobiletools.notes.pro.extensions.getPercentageFontSize
import com.simplemobiletools.notes.pro.models.Note
import kotlinx.android.synthetic.main.fragment_checklist.view.*
abstract class NoteFragment : Fragment()
abstract class NoteFragment : Fragment() {
protected var shouldShowLockedContent = false
protected fun setupLockedViews(view: ViewGroup, note: Note) {
view.apply {
note_locked_layout.beVisibleIf(note.isLocked() && !shouldShowLockedContent)
note_locked_image.applyColorFilter(config!!.textColor)
note_locked_label.setTextColor(context!!.config.textColor)
note_locked_label.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getPercentageFontSize())
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()
}
}
}
}
}
abstract fun checkLockState()
}

View File

@ -141,7 +141,7 @@ class TextFragment : NoteFragment() {
setSelection(if (config.placeCursorToEnd) text.length else 0)
}
if (config.showKeyboard && isMenuVisible) {
if (config.showKeyboard && isMenuVisible && (!note!!.isLocked() || shouldShowLockedContent)) {
onGlobalLayout {
if (activity?.isDestroyed == false) {
requestFocus()
@ -159,13 +159,11 @@ class TextFragment : NoteFragment() {
}
if (config.showWordCount) {
view.notes_counter.beVisible()
view.notes_counter.setTextColor(config.textColor)
setWordCounter(view.text_note_view.text.toString())
} else {
view.notes_counter.beGone()
}
checkLockState()
setTextWatcher()
}
@ -178,6 +176,14 @@ class TextFragment : NoteFragment() {
fun removeTextWatcher() = view.text_note_view.removeTextChangedListener(textWatcher)
override fun checkLockState() {
view.apply {
notes_counter.beVisibleIf((!note!!.isLocked() || shouldShowLockedContent) && config!!.showWordCount)
notes_scrollview.beVisibleIf(!note!!.isLocked() || shouldShowLockedContent)
setupLockedViews(this, note!!)
}
}
fun updateNoteValue(value: String) {
note?.value = value
}