show file name at ReadTextActivity if available
This commit is contained in:
parent
376b521170
commit
e0802b72fe
|
@ -54,13 +54,32 @@ class ReadTextActivity : SimpleActivity() {
|
||||||
searchPrevBtn = findViewById(R.id.search_previous)
|
searchPrevBtn = findViewById(R.id.search_previous)
|
||||||
searchNextBtn = findViewById(R.id.search_next)
|
searchNextBtn = findViewById(R.id.search_next)
|
||||||
searchClearBtn = findViewById(R.id.search_clear)
|
searchClearBtn = findViewById(R.id.search_clear)
|
||||||
|
read_text_view.setTextColor(config.textColor)
|
||||||
|
|
||||||
if (checkAppSideloading()) {
|
if (checkAppSideloading()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val uri = if (intent.extras?.containsKey(REAL_FILE_PATH) == true) {
|
||||||
|
Uri.fromFile(File(intent.extras?.get(REAL_FILE_PATH).toString()))
|
||||||
|
} else {
|
||||||
|
intent.data
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uri == null) {
|
||||||
|
finish()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val filename = getFilenameFromUri(uri)
|
||||||
|
if (filename.isNotEmpty()) {
|
||||||
|
title = filename
|
||||||
|
}
|
||||||
|
|
||||||
read_text_view.onGlobalLayout {
|
read_text_view.onGlobalLayout {
|
||||||
checkIntent()
|
ensureBackgroundThread {
|
||||||
|
checkIntent(uri)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setupSearchButtons()
|
setupSearchButtons()
|
||||||
|
@ -213,20 +232,7 @@ class ReadTextActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkIntent() {
|
private fun checkIntent(uri: Uri) {
|
||||||
read_text_view.setTextColor(config.textColor)
|
|
||||||
val uri = if (intent.extras?.containsKey(REAL_FILE_PATH) == true) {
|
|
||||||
Uri.fromFile(File(intent.extras?.get(REAL_FILE_PATH).toString()))
|
|
||||||
} else {
|
|
||||||
intent.data
|
|
||||||
}
|
|
||||||
|
|
||||||
if (uri == null) {
|
|
||||||
finish()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
ensureBackgroundThread {
|
|
||||||
originalText = if (uri.scheme == "file") {
|
originalText = if (uri.scheme == "file") {
|
||||||
filePath = uri.path!!
|
filePath = uri.path!!
|
||||||
val file = File(filePath)
|
val file = File(filePath)
|
||||||
|
@ -246,11 +252,11 @@ class ReadTextActivity : SimpleActivity() {
|
||||||
contentResolver.openInputStream(uri)!!.bufferedReader().use { it.readText() }
|
contentResolver.openInputStream(uri)!!.bufferedReader().use { it.readText() }
|
||||||
} catch (e: OutOfMemoryError) {
|
} catch (e: OutOfMemoryError) {
|
||||||
showErrorToast(e.toString())
|
showErrorToast(e.toString())
|
||||||
return@ensureBackgroundThread
|
return
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
showErrorToast(e)
|
showErrorToast(e)
|
||||||
finish()
|
finish()
|
||||||
return@ensureBackgroundThread
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,7 +269,6 @@ class ReadTextActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private fun setupSearchButtons() {
|
private fun setupSearchButtons() {
|
||||||
searchQueryET.onTextChangeListener {
|
searchQueryET.onTextChangeListener {
|
||||||
|
|
Loading…
Reference in New Issue