Skip to content

Commit

Permalink
remove extensions icons, other reconfiguration
Browse files Browse the repository at this point in the history
  • Loading branch information
WirelessAlien committed Dec 21, 2024
1 parent 408cb86 commit e137a97
Show file tree
Hide file tree
Showing 37 changed files with 223 additions and 474 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -555,12 +555,6 @@ class MainActivity : AppCompatActivity(), FileAdapter.OnItemClickListener, FileA
actionMode?.finish() // Destroy the action mode
true
}

R.id.m_extract_multipart -> {
actionMode?.finish()
true
}

else -> false
}
}
Expand Down Expand Up @@ -779,6 +773,9 @@ class MainActivity : AppCompatActivity(), FileAdapter.OnItemClickListener, FileA
val btnGzip = view.findViewById<MaterialButton>(R.id.btnGzip)
val extractBtn = view.findViewById<MaterialButton>(R.id.btnExtract)
val btnOpenWith = view.findViewById<MaterialButton>(R.id.btnOpenWith)
val fileNameTv = view.findViewById<TextView>(R.id.fileName)

fileNameTv.text = File(file).name

btnLzma.setOnClickListener {
startCompressService(file, CompressorStreamFactory.LZMA)
Expand Down Expand Up @@ -811,7 +808,7 @@ class MainActivity : AppCompatActivity(), FileAdapter.OnItemClickListener, FileA
setDataAndType(uri, getMimeType(File(file)))
flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
}
startActivity(Intent.createChooser(intent, "Open with"))
startActivity(Intent.createChooser(intent, getString(R.string.open_with)))
bottomSheetDialog.dismiss()
}

Expand Down Expand Up @@ -845,13 +842,15 @@ class MainActivity : AppCompatActivity(), FileAdapter.OnItemClickListener, FileA
val btnMultiExtract = bottomSheetView.findViewById<Button>(R.id.btnMultiExtract)
val btnMulti7zExtract = bottomSheetView.findViewById<Button>(R.id.btnMulti7zExtract)
val btnFileInfo = bottomSheetView.findViewById<Button>(R.id.btnFileInfo)
val btnCompress7z = bottomSheetView.findViewById<Button>(R.id.btnCompress7z)
val btnMultiZipExtract = bottomSheetView.findViewById<Button>(R.id.btnMultiZipExtract)
val btnOpenWith = bottomSheetView.findViewById<Button>(R.id.btnOpenWith)
val fileNameTv = bottomSheetView.findViewById<TextView>(R.id.fileName)


val filePath = file.absolutePath

fileNameTv.text = file.name

btnExtract.setOnClickListener {
val fileExtension = file.name.split('.').takeLast(2).joinToString(".").lowercase()
Log.d("FileExtension", fileExtension)
Expand Down Expand Up @@ -885,22 +884,16 @@ class MainActivity : AppCompatActivity(), FileAdapter.OnItemClickListener, FileA
bottomSheetDialog.dismiss()
}

btnCompress7z.setOnClickListener {
// Compression logic here
bottomSheetDialog.dismiss()
}

btnOpenWith.setOnClickListener {
val uri = FileProvider.getUriForFile(this, "${BuildConfig.APPLICATION_ID}.fileprovider", file)
val intent = Intent(Intent.ACTION_VIEW).apply {
setDataAndType(uri, getMimeType(file))
flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
}
startActivity(Intent.createChooser(intent, "Open with"))
startActivity(Intent.createChooser(intent, getString(R.string.open_with)))
bottomSheetDialog.dismiss()
}


bottomSheetDialog.show()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class FileAdapter(private val context: Context, private val mainActivity: MainAc
val fileName: TextView = itemView.findViewById(R.id.file_name)
val fileSize: TextView = itemView.findViewById(R.id.file_size)
val fileDate: TextView = itemView.findViewById(R.id.file_date)
val fileExtension: TextView = itemView.findViewById(R.id.file_extension)

init {
itemView.isClickable = true
Expand Down Expand Up @@ -146,40 +147,16 @@ class FileAdapter(private val context: Context, private val mainActivity: MainAc
}
holder.fileDate.text = dateFormat.format(Date(getFileTimeOfCreation(file)))


if (file.isDirectory) {
holder.fileIcon.setImageResource(R.drawable.ic_folder)
holder.fileSize.text = context.getString(R.string.folder)
holder.fileIcon.visibility = View.VISIBLE
holder.fileExtension.visibility = View.GONE
} else {
holder.fileSize.text = bytesToString(file.length())

when (file.extension) {
"avi" -> holder.fileIcon.setImageResource(R.drawable.ic_avi)
"doc", "docx" -> holder.fileIcon.setImageResource(R.drawable.ic_doc)
"exe" -> holder.fileIcon.setImageResource(R.drawable.ic_exe)
"mkv" -> holder.fileIcon.setImageResource(R.drawable.ic_mkv)
"mov" -> holder.fileIcon.setImageResource(R.drawable.ic_mov)
"mp3" -> holder.fileIcon.setImageResource(R.drawable.ic_mp3)
"mp4" -> holder.fileIcon.setImageResource(R.drawable.ic_mp4)
"pdf" -> holder.fileIcon.setImageResource(R.drawable.ic_pdf)
"ppt" -> holder.fileIcon.setImageResource(R.drawable.ic_ppt)
"txt" -> holder.fileIcon.setImageResource(R.drawable.ic_txt)
"xls", "xlsx" -> holder.fileIcon.setImageResource(R.drawable.ic_xls)
"rar" -> holder.fileIcon.setImageResource(R.drawable.ic_rar)
"zip" -> holder.fileIcon.setImageResource(R.drawable.ic_zip)
"apk" -> holder.fileIcon.setImageResource(R.drawable.ic_apk)
"jar" -> holder.fileIcon.setImageResource(R.drawable.ic_jar)
"java" -> holder.fileIcon.setImageResource(R.drawable.ic_java)
"m4a" -> holder.fileIcon.setImageResource(R.drawable.ic_m4a)
"mpeg", "mpg" -> holder.fileIcon.setImageResource(R.drawable.ic_mpeg)
"svg" -> holder.fileIcon.setImageResource(R.drawable.ic_svg)
"wav" -> holder.fileIcon.setImageResource(R.drawable.ic_wav)
"webm" -> holder.fileIcon.setImageResource(R.drawable.ic_webm)
"xml" -> holder.fileIcon.setImageResource(R.drawable.ic_xml)
"tar" -> holder.fileIcon.setImageResource(R.drawable.ic_tar)
"db" -> holder.fileIcon.setImageResource(R.drawable.ic_db)
"7z" -> holder.fileIcon.setImageResource(R.drawable.ic_7z)
"png", "jpg", "bmp", "jpeg", "gif"-> {
when (file.extension.lowercase(Locale.getDefault())) {
"png", "jpg", "bmp", "jpeg", "gif" -> {
val requestBuilder = Glide.with(context)
.asDrawable()
.sizeMultiplier(0.25f)
Expand All @@ -188,16 +165,35 @@ class FileAdapter(private val context: Context, private val mainActivity: MainAc
.load(file)
.thumbnail(requestBuilder)
.into(holder.fileIcon)
holder.fileIcon.visibility = View.VISIBLE
holder.fileExtension.visibility = View.GONE
}
else -> {
holder.fileIcon.visibility = View.GONE
holder.fileExtension.visibility = View.VISIBLE
holder.fileExtension.text = if (file.extension.isNotEmpty()) {
if (file.extension.length > 4) {
"FILE"
} else {
if (file.extension.length == 4) {
holder.fileExtension.textSize = 12f
} else {
holder.fileExtension.textSize = 14f
}
file.extension.uppercase(Locale.getDefault())
}
} else {
"..."
}
}
else -> holder.fileIcon.setImageResource(R.drawable.ic_unknown)
}
}

if (selectedItems.get(position, false)) {
holder.itemView.setBackgroundColor(ContextCompat.getColor(context, R.color.md_theme_outline))
} else {
holder.itemView.setBackgroundColor(Color.TRANSPARENT)
}

}

private fun truncateFileName(fileName: String, maxLength: Int): String {
Expand Down
10 changes: 0 additions & 10 deletions app/src/main/res/drawable/ic_apk.xml

This file was deleted.

10 changes: 0 additions & 10 deletions app/src/main/res/drawable/ic_avi.xml

This file was deleted.

10 changes: 0 additions & 10 deletions app/src/main/res/drawable/ic_db.xml

This file was deleted.

10 changes: 0 additions & 10 deletions app/src/main/res/drawable/ic_doc.xml

This file was deleted.

10 changes: 0 additions & 10 deletions app/src/main/res/drawable/ic_exe.xml

This file was deleted.

Loading

0 comments on commit e137a97

Please sign in to comment.