mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-06-05 17:00:23 +02:00
Allow exporting locked notes
This commit is contained in:
@ -24,16 +24,16 @@ class NewNoteDialog(val activity: Activity, title: String? = null, val setCheckl
|
||||
new_note_type.check(defaultType)
|
||||
}
|
||||
|
||||
view.note_title.setText(title)
|
||||
view.locked_note_title.setText(title)
|
||||
|
||||
activity.getAlertDialogBuilder()
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this, R.string.new_note) { alertDialog ->
|
||||
alertDialog.showKeyboard(view.note_title)
|
||||
alertDialog.showKeyboard(view.locked_note_title)
|
||||
alertDialog.getButton(BUTTON_POSITIVE).setOnClickListener {
|
||||
val newTitle = view.note_title.value
|
||||
val newTitle = view.locked_note_title.value
|
||||
ensureBackgroundThread {
|
||||
when {
|
||||
newTitle.isEmpty() -> activity.toast(R.string.no_title)
|
||||
|
@ -18,16 +18,16 @@ class RenameNoteDialog(val activity: SimpleActivity, val note: Note, val current
|
||||
|
||||
init {
|
||||
val view = activity.layoutInflater.inflate(R.layout.dialog_rename_note, null)
|
||||
view.note_title.setText(note.title)
|
||||
view.locked_note_title.setText(note.title)
|
||||
|
||||
activity.getAlertDialogBuilder()
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this, R.string.rename_note) { alertDialog ->
|
||||
alertDialog.showKeyboard(view.note_title)
|
||||
alertDialog.showKeyboard(view.locked_note_title)
|
||||
alertDialog.getButton(BUTTON_POSITIVE).setOnClickListener {
|
||||
val title = view.note_title.value
|
||||
val title = view.locked_note_title.value
|
||||
ensureBackgroundThread {
|
||||
newTitleConfirmed(title, alertDialog)
|
||||
}
|
||||
|
@ -0,0 +1,64 @@
|
||||
package com.simplemobiletools.notes.pro.dialogs
|
||||
|
||||
import android.content.DialogInterface
|
||||
import android.view.ViewGroup
|
||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.notes.pro.R
|
||||
import com.simplemobiletools.notes.pro.models.Note
|
||||
import kotlinx.android.synthetic.main.dialog_unlock_notes.view.*
|
||||
import kotlinx.android.synthetic.main.item_locked_note.view.*
|
||||
|
||||
class UnlockNotesDialog(val activity: BaseSimpleActivity, notes: List<Note>, callback: (unlockedNoteIds: List<Long>) -> Unit) {
|
||||
private val view = activity.layoutInflater.inflate(R.layout.dialog_unlock_notes, null) as ViewGroup
|
||||
private val redColor = activity.getColor(R.color.md_red)
|
||||
private val greenColor = activity.getColor(R.color.md_green)
|
||||
private val unlockedNoteIds = mutableListOf<Long>()
|
||||
|
||||
init {
|
||||
for (note in notes) {
|
||||
addLockedNoteView(note)
|
||||
}
|
||||
activity.getAlertDialogBuilder()
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this, R.string.unlock_notes, cancelOnTouchOutside = false) { alertDialog ->
|
||||
alertDialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener {
|
||||
callback(unlockedNoteIds)
|
||||
alertDialog.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun addLockedNoteView(note: Note) {
|
||||
activity.layoutInflater.inflate(R.layout.item_locked_note, null).apply {
|
||||
view.notes_holder.addView(this)
|
||||
activity.updateTextColors(view.notes_holder)
|
||||
locked_note_title.text = note.title
|
||||
locked_unlocked_image.applyColorFilter(redColor)
|
||||
locked_note_holder.setOnClickListener {
|
||||
if (note.id !in unlockedNoteIds) {
|
||||
activity.performSecurityCheck(
|
||||
protectionType = note.protectionType,
|
||||
requiredHash = note.protectionHash,
|
||||
successCallback = { _, _ ->
|
||||
unlockedNoteIds.add(note.id!!)
|
||||
locked_unlocked_image.apply {
|
||||
setImageResource(R.drawable.ic_lock_open_vector)
|
||||
applyColorFilter(greenColor)
|
||||
}
|
||||
}
|
||||
)
|
||||
} else {
|
||||
unlockedNoteIds.remove(note.id)
|
||||
locked_unlocked_image.apply {
|
||||
setImageResource(R.drawable.ic_lock_vector)
|
||||
applyColorFilter(redColor)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user