list the proper files at mimetype activity
This commit is contained in:
parent
8fb2f56506
commit
b42680508f
|
@ -54,7 +54,9 @@
|
|||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".activities.MimeTypesActivity" />
|
||||
<activity
|
||||
android:name=".activities.MimeTypesActivity"
|
||||
android:parentActivityName=".activities.MainActivity" />
|
||||
|
||||
<activity
|
||||
android:name=".activities.ReadTextActivity"
|
||||
|
|
|
@ -13,14 +13,18 @@ import com.simplemobiletools.commons.helpers.VIEW_TYPE_GRID
|
|||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.commons.models.FileDirItem
|
||||
import com.simplemobiletools.filemanager.pro.R
|
||||
import com.simplemobiletools.filemanager.pro.adapters.ItemsAdapter
|
||||
import com.simplemobiletools.filemanager.pro.dialogs.ChangeSortingDialog
|
||||
import com.simplemobiletools.filemanager.pro.dialogs.ChangeViewTypeDialog
|
||||
import com.simplemobiletools.filemanager.pro.extensions.config
|
||||
import com.simplemobiletools.filemanager.pro.helpers.*
|
||||
import com.simplemobiletools.filemanager.pro.interfaces.ItemOperationsListener
|
||||
import com.simplemobiletools.filemanager.pro.models.ListItem
|
||||
import kotlinx.android.synthetic.main.activity_mimetypes.*
|
||||
import kotlinx.android.synthetic.main.items_fragment.view.*
|
||||
import java.util.*
|
||||
|
||||
class MimeTypesActivity : SimpleActivity() {
|
||||
class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
|
||||
private var isSearchOpen = false
|
||||
private var searchMenuItem: MenuItem? = null
|
||||
private var currentMimeType = ""
|
||||
|
@ -50,14 +54,30 @@ class MimeTypesActivity : SimpleActivity() {
|
|||
FileDirItem.sorting = config.getFolderSorting(currentMimeType)
|
||||
fileDirItems.sort()
|
||||
val listItems = getListItemsFromFileDirItems(fileDirItems)
|
||||
|
||||
runOnUiThread {
|
||||
ItemsAdapter(this as SimpleActivity, listItems, this, mimetypes_list, false, items_fastscroller, null) {
|
||||
|
||||
}.apply {
|
||||
mimetypes_list.adapter = this
|
||||
}
|
||||
|
||||
if (areSystemAnimationsEnabled) {
|
||||
mimetypes_list.scheduleLayoutAnimation()
|
||||
}
|
||||
|
||||
val dateFormat = config.dateFormat
|
||||
val timeFormat = getTimeFormat()
|
||||
items_fastscroller.setViews(mimetypes_list) {
|
||||
val listItem = getRecyclerAdapter()?.listItems?.getOrNull(it)
|
||||
items_fastscroller.updateBubbleText(listItem?.getBubbleText(this, dateFormat, timeFormat) ?: "")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getRecyclerAdapter() = mimetypes_list.adapter as? ItemsAdapter
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.menu, menu)
|
||||
setupSearch(menu)
|
||||
|
@ -105,6 +125,7 @@ class MimeTypesActivity : SimpleActivity() {
|
|||
|
||||
private fun getProperFileDirItems(callback: (ArrayList<FileDirItem>) -> Unit) {
|
||||
val fileDirItems = ArrayList<FileDirItem>()
|
||||
val showHidden = config.shouldShowHidden
|
||||
val uri = MediaStore.Files.getContentUri("external")
|
||||
val projection = arrayOf(
|
||||
MediaStore.Files.FileColumns.MIME_TYPE,
|
||||
|
@ -118,8 +139,12 @@ class MimeTypesActivity : SimpleActivity() {
|
|||
queryCursor(uri, projection) { cursor ->
|
||||
try {
|
||||
val fullMimetype = cursor.getStringValue(MediaStore.Files.FileColumns.MIME_TYPE)?.lowercase(Locale.getDefault()) ?: return@queryCursor
|
||||
val path = cursor.getStringValue(MediaStore.Files.FileColumns.DATA)
|
||||
val name = cursor.getStringValue(MediaStore.Files.FileColumns.DISPLAY_NAME)
|
||||
if (!showHidden && name.startsWith(".")) {
|
||||
return@queryCursor
|
||||
}
|
||||
|
||||
val path = cursor.getStringValue(MediaStore.Files.FileColumns.DATA)
|
||||
val size = cursor.getLongValue(MediaStore.Files.FileColumns.SIZE)
|
||||
val lastModified = cursor.getLongValue(MediaStore.Files.FileColumns.DATE_MODIFIED) * 1000
|
||||
|
||||
|
@ -206,13 +231,27 @@ class MimeTypesActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun toggleFilenameVisibility() {
|
||||
override fun refreshFragment() {}
|
||||
|
||||
override fun deleteFiles(files: ArrayList<FileDirItem>) {}
|
||||
|
||||
override fun selectedPaths(paths: ArrayList<String>) {}
|
||||
|
||||
override fun searchQueryChanged(text: String) {}
|
||||
|
||||
override fun setupDateTimeFormat() {}
|
||||
|
||||
override fun setupFontSize() {}
|
||||
|
||||
override fun toggleFilenameVisibility() {
|
||||
config.displayFilenames = !config.displayFilenames
|
||||
}
|
||||
|
||||
private fun increaseColumnCount() {}
|
||||
override fun increaseColumnCount() {}
|
||||
|
||||
private fun reduceColumnCount() {}
|
||||
override fun reduceColumnCount() {}
|
||||
|
||||
override fun finishActMode() {}
|
||||
|
||||
private fun changeViewType() {
|
||||
ChangeViewTypeDialog(this, currentMimeType, true) { }
|
||||
|
|
|
@ -55,8 +55,10 @@ import java.util.zip.ZipEntry
|
|||
import java.util.zip.ZipFile
|
||||
import java.util.zip.ZipOutputStream
|
||||
|
||||
class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem>, val listener: ItemOperationsListener?, recyclerView: MyRecyclerView,
|
||||
val isPickMultipleIntent: Boolean, fastScroller: FastScroller?, val swipeRefreshLayout: SwipeRefreshLayout, itemClick: (Any) -> Unit) :
|
||||
class ItemsAdapter(
|
||||
activity: SimpleActivity, var listItems: MutableList<ListItem>, val listener: ItemOperationsListener?, recyclerView: MyRecyclerView,
|
||||
val isPickMultipleIntent: Boolean, fastScroller: FastScroller?, val swipeRefreshLayout: SwipeRefreshLayout?, itemClick: (Any) -> Unit
|
||||
) :
|
||||
MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) {
|
||||
|
||||
private val TYPE_FILE_DIR = 1
|
||||
|
@ -136,12 +138,12 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
|
|||
override fun getItemKeyPosition(key: Int) = listItems.indexOfFirst { it.path.hashCode() == key }
|
||||
|
||||
override fun onActionModeCreated() {
|
||||
swipeRefreshLayout.isRefreshing = false
|
||||
swipeRefreshLayout.isEnabled = false
|
||||
swipeRefreshLayout?.isRefreshing = false
|
||||
swipeRefreshLayout?.isEnabled = false
|
||||
}
|
||||
|
||||
override fun onActionModeDestroyed() {
|
||||
swipeRefreshLayout.isEnabled = true
|
||||
swipeRefreshLayout?.isEnabled = true
|
||||
}
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
|
@ -363,7 +365,8 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
|
|||
RadioItem(OPEN_AS_IMAGE, res.getString(R.string.image_file)),
|
||||
RadioItem(OPEN_AS_AUDIO, res.getString(R.string.audio_file)),
|
||||
RadioItem(OPEN_AS_VIDEO, res.getString(R.string.video_file)),
|
||||
RadioItem(OPEN_AS_OTHER, res.getString(R.string.other_file)))
|
||||
RadioItem(OPEN_AS_OTHER, res.getString(R.string.other_file))
|
||||
)
|
||||
|
||||
RadioGroupDialog(activity, items) {
|
||||
activity.tryOpenPathIntent(getFirstSelectedItemPath(), false, it as Int)
|
||||
|
@ -389,7 +392,8 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
|
|||
files.forEach { sourceFileDir ->
|
||||
val sourceFile = File(sourceFileDir.path)
|
||||
if (activity.getDoesFilePathExist(source) && activity.getIsPathDirectory(source) &&
|
||||
sourceFile.list()?.isEmpty() == true && sourceFile.getProperSize(true) == 0L && sourceFile.getFileCount(true) == 0) {
|
||||
sourceFile.list()?.isEmpty() == true && sourceFile.getProperSize(true) == 0L && sourceFile.getFileCount(true) == 0
|
||||
) {
|
||||
val sourceFolder = sourceFile.toFileDirItem(activity)
|
||||
activity.deleteFile(sourceFolder, true) {
|
||||
listener?.refreshFragment()
|
||||
|
@ -811,7 +815,8 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
|
|||
return activity.resources.getQuantityString(R.plurals.items, children, children)
|
||||
}
|
||||
|
||||
private fun getOTGPublicPath(itemToLoad: String) = "${baseConfig.OTGTreeUri}/document/${baseConfig.OTGPartition}%3A${itemToLoad.substring(baseConfig.OTGPath.length).replace("/", "%2F")}"
|
||||
private fun getOTGPublicPath(itemToLoad: String) =
|
||||
"${baseConfig.OTGTreeUri}/document/${baseConfig.OTGPartition}%3A${itemToLoad.substring(baseConfig.OTGPath.length).replace("/", "%2F")}"
|
||||
|
||||
private fun getImagePathToLoad(path: String): Any {
|
||||
var itemToLoad = if (path.endsWith(".apk", true)) {
|
||||
|
|
|
@ -1,10 +1,27 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.simplemobiletools.commons.views.MyRecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/mimetypes_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:layoutAnimation="@anim/layout_animation"
|
||||
android:scrollbars="none"
|
||||
app:layoutManager="com.simplemobiletools.commons.views.MyGridLayoutManager" />
|
||||
android:id="@+id/mimetypes_holder"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||
android:id="@+id/mimetypes_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:layoutAnimation="@anim/layout_animation"
|
||||
android:scrollbars="none"
|
||||
app:layoutManager="com.simplemobiletools.commons.views.MyGridLayoutManager" />
|
||||
|
||||
<com.simplemobiletools.commons.views.FastScroller
|
||||
android:id="@+id/items_fastscroller"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:paddingStart="@dimen/normal_margin">
|
||||
|
||||
<include layout="@layout/fastscroller_handle_vertical" />
|
||||
|
||||
</com.simplemobiletools.commons.views.FastScroller>
|
||||
</RelativeLayout>
|
||||
|
|
Loading…
Reference in New Issue