mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-18 03:45:33 -04:00
added readText() method in writeNote()
This commit is contained in:
parent
e6e9e4efe8
commit
4cf6ddb3d7
@ -50,9 +50,7 @@ import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
|
|||||||
import org.kiwix.kiwixmobile.core.utils.dialog.AlertDialogShower
|
import org.kiwix.kiwixmobile.core.utils.dialog.AlertDialogShower
|
||||||
import org.kiwix.kiwixmobile.core.utils.dialog.KiwixDialog
|
import org.kiwix.kiwixmobile.core.utils.dialog.KiwixDialog
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileOutputStream
|
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.lang.StringBuilder
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -389,20 +387,8 @@ class AddNoteDialog : DialogFragment() {
|
|||||||
|
|
||||||
private fun writeNote(noteFile: File) {
|
private fun writeNote(noteFile: File) {
|
||||||
noteFileExists = true
|
noteFileExists = true
|
||||||
val contents = StringBuilder()
|
val contents = noteFile.readText()
|
||||||
try {
|
add_note_edit_text.setText(contents) // Display the note content
|
||||||
noteFile.bufferedReader().use { bufferReader ->
|
|
||||||
var line: String?
|
|
||||||
while (bufferReader.readLine().also { line = it } != null) {
|
|
||||||
contents.append(line)
|
|
||||||
contents.append(System.getProperty("line.separator"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (e: IOException) {
|
|
||||||
e.printStackTrace()
|
|
||||||
Log.d(TAG, "Error reading line with BufferedReader")
|
|
||||||
}
|
|
||||||
add_note_edit_text.setText("$contents") // Display the note content
|
|
||||||
add_note_edit_text.setSelection(add_note_edit_text.text.length - 1)
|
add_note_edit_text.setSelection(add_note_edit_text.text.length - 1)
|
||||||
enableShareNoteMenuItem() // As note content exists which can be shared
|
enableShareNoteMenuItem() // As note content exists which can be shared
|
||||||
enableDeleteNoteMenuItem()
|
enableDeleteNoteMenuItem()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user