adding the core of a new Storage fragment
This commit is contained in:
parent
095e1781a8
commit
1af8303bbb
|
@ -138,6 +138,7 @@ class MainActivity : SimpleActivity() {
|
|||
|
||||
override fun onPrepareOptionsMenu(menu: Menu?): Boolean {
|
||||
val currentFragment = getCurrentFragment() ?: return true
|
||||
val currentViewType = config.getFolderViewType(currentFragment.currentPath)
|
||||
val favorites = config.favorites
|
||||
|
||||
menu!!.apply {
|
||||
|
@ -148,15 +149,15 @@ class MainActivity : SimpleActivity() {
|
|||
findItem(R.id.remove_favorite).isVisible = currentFragment is ItemsFragment && favorites.contains(currentFragment.currentPath)
|
||||
findItem(R.id.go_to_favorite).isVisible = currentFragment is ItemsFragment && favorites.isNotEmpty()
|
||||
|
||||
findItem(R.id.toggle_filename).isVisible = config.getFolderViewType(currentFragment.currentPath) == VIEW_TYPE_GRID
|
||||
findItem(R.id.toggle_filename).isVisible = currentViewType == VIEW_TYPE_GRID
|
||||
findItem(R.id.go_home).isVisible = currentFragment is ItemsFragment && currentFragment.currentPath != config.homeFolder
|
||||
findItem(R.id.set_as_home).isVisible = currentFragment is ItemsFragment && currentFragment.currentPath != config.homeFolder
|
||||
|
||||
findItem(R.id.temporarily_show_hidden).isVisible = !config.shouldShowHidden
|
||||
findItem(R.id.stop_showing_hidden).isVisible = config.temporarilyShowHidden
|
||||
|
||||
findItem(R.id.increase_column_count).isVisible = config.getFolderViewType(currentFragment.currentPath) == VIEW_TYPE_GRID && config.fileColumnCnt < MAX_COLUMN_COUNT
|
||||
findItem(R.id.reduce_column_count).isVisible = config.getFolderViewType(currentFragment.currentPath) == VIEW_TYPE_GRID && config.fileColumnCnt > 1
|
||||
findItem(R.id.increase_column_count).isVisible = currentViewType == VIEW_TYPE_GRID && config.fileColumnCnt < MAX_COLUMN_COUNT
|
||||
findItem(R.id.reduce_column_count).isVisible = currentViewType == VIEW_TYPE_GRID && config.fileColumnCnt > 1
|
||||
}
|
||||
|
||||
return true
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
package com.simplemobiletools.filemanager.pro.fragments
|
||||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.provider.MediaStore
|
||||
import android.util.AttributeSet
|
||||
import com.simplemobiletools.commons.extensions.getLongValue
|
||||
import com.simplemobiletools.commons.extensions.queryCursor
|
||||
import com.simplemobiletools.filemanager.pro.activities.SimpleActivity
|
||||
|
||||
class StorageFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet) {
|
||||
override fun setupFragment(activity: SimpleActivity) {}
|
||||
|
||||
override fun refreshItems() {}
|
||||
|
||||
override fun setupColors(textColor: Int, primaryColor: Int) {}
|
||||
|
||||
override fun toggleFilenameVisibility() {}
|
||||
|
||||
override fun increaseColumnCount() {}
|
||||
|
||||
override fun reduceColumnCount() {}
|
||||
|
||||
override fun setupFontSize() {}
|
||||
|
||||
override fun setupDateTimeFormat() {}
|
||||
|
||||
override fun searchQueryChanged(text: String) {}
|
||||
|
||||
override fun finishActMode() {}
|
||||
|
||||
private fun getFileTypeSize(uri: Uri): Long {
|
||||
val projection = arrayOf(
|
||||
MediaStore.Files.FileColumns.SIZE
|
||||
)
|
||||
|
||||
var totalSize = 0L
|
||||
try {
|
||||
context.queryCursor(uri, projection) { cursor ->
|
||||
try {
|
||||
val size = cursor.getLongValue(MediaStore.Files.FileColumns.SIZE)
|
||||
totalSize += size
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
|
||||
return totalSize
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue