mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-03-19 18:10:07 +01:00
Extracted requestUnlockNotes to an extension fun
This commit is contained in:
parent
437adefb03
commit
6b44179ae0
@ -4,12 +4,15 @@ import android.appwidget.AppWidgetManager
|
||||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||
import com.simplemobiletools.notes.pro.R
|
||||
import com.simplemobiletools.notes.pro.databases.NotesDatabase
|
||||
import com.simplemobiletools.notes.pro.dialogs.UnlockNotesDialog
|
||||
import com.simplemobiletools.notes.pro.helpers.Config
|
||||
import com.simplemobiletools.notes.pro.helpers.MyWidgetProvider
|
||||
import com.simplemobiletools.notes.pro.interfaces.NotesDao
|
||||
import com.simplemobiletools.notes.pro.interfaces.WidgetsDao
|
||||
import com.simplemobiletools.notes.pro.models.Note
|
||||
|
||||
val Context.config: Config get() = Config.newInstance(applicationContext)
|
||||
|
||||
@ -29,3 +32,14 @@ fun Context.updateWidgets() {
|
||||
}
|
||||
|
||||
fun Context.getPercentageFontSize() = resources.getDimension(R.dimen.middle_text_size) * (config.fontSizePercentage / 100f)
|
||||
|
||||
fun BaseSimpleActivity.requestUnlockNotes(notes: List<Note>, callback: (unlockedNotes: List<Note>) -> Unit) {
|
||||
val lockedNotes = notes.filter { it.isLocked() }
|
||||
if (lockedNotes.isNotEmpty()) {
|
||||
runOnUiThread {
|
||||
UnlockNotesDialog(this, lockedNotes, callback)
|
||||
}
|
||||
} else {
|
||||
callback(emptyList())
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user