Skip to content

Commit

Permalink
resources: show only filename (fixes #3499) (#3503)
Browse files Browse the repository at this point in the history
Co-authored-by: dogi <[email protected]>
  • Loading branch information
rlam20 and dogi authored May 27, 2024
1 parent 220d9bf commit 1403b51
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 16 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "org.ole.planet.myplanet"
minSdkVersion 21
targetSdkVersion 34
versionCode 1542
versionName "0.15.42"
versionCode 1543
versionName "0.15.43"
ndkVersion '21.3.6528147'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ class CSVViewerActivity : AppCompatActivity() {
if (!fileName.isNullOrEmpty()) {
val regex = Regex(".+/(.+\\.csv)")
val matchResult = regex.find(fileName)
val name = matchResult?.groupValues?.get(1)

activityCsvviewerBinding.csvFileName.text = name
val nameWithExtension = matchResult?.groupValues?.get(1)
val nameWithoutExtension = nameWithExtension?.substringBeforeLast(".")
activityCsvviewerBinding.csvFileName.text = nameWithoutExtension
activityCsvviewerBinding.csvFileName.visibility = View.VISIBLE


}
try {
val csvFile: File = if (fileName!!.startsWith("/")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ class ImageViewerActivity : AppCompatActivity() {
val regex = Regex(".+/([^/]+\\.(jpg|jpeg|png|gif|bmp))")

val matchResult = regex.find(fileName ?: "")
val name = matchResult?.groupValues?.get(1)
activityImageViewerBinding.imageFileName.text = name
val nameWithExtension = matchResult?.groupValues?.get(1)
val nameWithoutExtension = nameWithExtension?.substringBefore(".")
activityImageViewerBinding.imageFileName.text = nameWithoutExtension
activityImageViewerBinding.imageFileName.visibility = View.VISIBLE
}
if (fileName?.matches(".*[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}.*".toRegex()) == true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ class MarkdownViewerActivity : AppCompatActivity() {
val markdownOpenIntent = intent
fileName = markdownOpenIntent.getStringExtra("TOUCHED_FILE")
if (!fileName.isNullOrEmpty()) {

val regex = Regex(".+/(.+\\.md)")
val matchResult = regex.find(fileName ?: "")
val name = matchResult?.groupValues?.get(1)

activityMarkdownViewerBinding.markdownFileName.text = name
val nameWithExtension = matchResult?.groupValues?.get(1)
val nameWithoutExtension = nameWithExtension?.substringBeforeLast(".")
activityMarkdownViewerBinding.markdownFileName.text = nameWithoutExtension
activityMarkdownViewerBinding.markdownFileName.visibility = View.VISIBLE
}
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ class PDFReaderActivity : AppCompatActivity(), OnPageChangeListener, OnLoadCompl
if (fileName != null && fileName?.isNotEmpty() == true) {
val regex = Regex(".+/(.+\\.pdf)")
val matchResult = regex.find(fileName ?: "")
val name = matchResult?.groupValues?.get(1)

activityPdfreaderBinding.pdfFileName.text = name
val nameWithExtension = matchResult?.groupValues?.get(1)
val nameWithoutExtension = nameWithExtension?.substringBeforeLast(".")
activityPdfreaderBinding.pdfFileName.text = nameWithoutExtension
activityPdfreaderBinding.pdfFileName.visibility = View.VISIBLE
}
val file = File(getExternalFilesDir(null), "ole/$fileName")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ class TextFileViewerActivity : AppCompatActivity() {
val textFileOpenIntent = intent
fileName = textFileOpenIntent.getStringExtra("TOUCHED_FILE")
if (fileName != null && fileName?.isNotEmpty() == true) {

val regex = Regex(".+/(.+\\.txt)")
val matchResult = regex.find(fileName ?: "")
val name = matchResult?.groupValues?.get(1)

activityTextfileViewerBinding.textFileName.text = name
val nameWithExtension = matchResult?.groupValues?.get(1)
val nameWithoutExtension = nameWithExtension?.substringBeforeLast(".")
activityTextfileViewerBinding.textFileName.text = nameWithoutExtension
activityTextfileViewerBinding.textFileName.visibility = View.VISIBLE
}
renderTextFileThread()
Expand Down

0 comments on commit 1403b51

Please sign in to comment.