adding the storage tab at the viewpager

This commit is contained in:
tibbi 2021-10-11 21:08:31 +02:00
parent fdbd093ff6
commit f750539695
5 changed files with 35 additions and 5 deletions

View File

@ -30,6 +30,7 @@ import com.simplemobiletools.filemanager.pro.extensions.config
import com.simplemobiletools.filemanager.pro.extensions.tryOpenPathIntent import com.simplemobiletools.filemanager.pro.extensions.tryOpenPathIntent
import com.simplemobiletools.filemanager.pro.fragments.ItemsFragment import com.simplemobiletools.filemanager.pro.fragments.ItemsFragment
import com.simplemobiletools.filemanager.pro.fragments.MyViewPagerFragment import com.simplemobiletools.filemanager.pro.fragments.MyViewPagerFragment
import com.simplemobiletools.filemanager.pro.fragments.StorageFragment
import com.simplemobiletools.filemanager.pro.helpers.MAX_COLUMN_COUNT import com.simplemobiletools.filemanager.pro.helpers.MAX_COLUMN_COUNT
import com.simplemobiletools.filemanager.pro.helpers.RootHelpers import com.simplemobiletools.filemanager.pro.helpers.RootHelpers
import com.simplemobiletools.filemanager.pro.helpers.tabsList import com.simplemobiletools.filemanager.pro.helpers.tabsList
@ -39,6 +40,7 @@ import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.items_fragment.* import kotlinx.android.synthetic.main.items_fragment.*
import kotlinx.android.synthetic.main.items_fragment.view.* import kotlinx.android.synthetic.main.items_fragment.view.*
import kotlinx.android.synthetic.main.recents_fragment.* import kotlinx.android.synthetic.main.recents_fragment.*
import kotlinx.android.synthetic.main.storage_fragment.*
import java.io.File import java.io.File
import java.util.* import java.util.*
@ -151,6 +153,7 @@ class MainActivity : SimpleActivity() {
menu!!.apply { menu!!.apply {
findItem(R.id.search).isVisible = currentFragment is ItemsFragment findItem(R.id.search).isVisible = currentFragment is ItemsFragment
findItem(R.id.sort).isVisible = currentFragment is ItemsFragment findItem(R.id.sort).isVisible = currentFragment is ItemsFragment
findItem(R.id.change_view_type).isVisible = currentFragment !is StorageFragment
findItem(R.id.add_favorite).isVisible = currentFragment is ItemsFragment && !favorites.contains(currentFragment.currentPath) findItem(R.id.add_favorite).isVisible = currentFragment is ItemsFragment && !favorites.contains(currentFragment.currentPath)
findItem(R.id.remove_favorite).isVisible = currentFragment is ItemsFragment && favorites.contains(currentFragment.currentPath) findItem(R.id.remove_favorite).isVisible = currentFragment is ItemsFragment && favorites.contains(currentFragment.currentPath)
@ -160,7 +163,7 @@ class MainActivity : SimpleActivity() {
findItem(R.id.go_home).isVisible = currentFragment is ItemsFragment && currentFragment.currentPath != config.homeFolder 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.set_as_home).isVisible = currentFragment is ItemsFragment && currentFragment.currentPath != config.homeFolder
findItem(R.id.temporarily_show_hidden).isVisible = !config.shouldShowHidden findItem(R.id.temporarily_show_hidden).isVisible = !config.shouldShowHidden && currentFragment !is StorageFragment
findItem(R.id.stop_showing_hidden).isVisible = config.temporarilyShowHidden findItem(R.id.stop_showing_hidden).isVisible = config.temporarilyShowHidden
findItem(R.id.increase_column_count).isVisible = currentViewType == VIEW_TYPE_GRID && config.fileColumnCnt < MAX_COLUMN_COUNT findItem(R.id.increase_column_count).isVisible = currentViewType == VIEW_TYPE_GRID && config.fileColumnCnt < MAX_COLUMN_COUNT
@ -412,7 +415,8 @@ class MainActivity : SimpleActivity() {
private fun getTabIcon(position: Int): Drawable { private fun getTabIcon(position: Int): Drawable {
val drawableId = when (position) { val drawableId = when (position) {
0 -> R.drawable.ic_folder_vector 0 -> R.drawable.ic_folder_vector
else -> R.drawable.ic_clock_vector 1 -> R.drawable.ic_clock_vector
else -> R.drawable.ic_storage_vector
} }
return resources.getColoredDrawableWithColor(drawableId, config.textColor) return resources.getColoredDrawableWithColor(drawableId, config.textColor)
@ -638,7 +642,7 @@ class MainActivity : SimpleActivity() {
private fun getInactiveTabIndexes(activeIndex: Int) = (0 until tabsList.size).filter { it != activeIndex } private fun getInactiveTabIndexes(activeIndex: Int) = (0 until tabsList.size).filter { it != activeIndex }
private fun getAllFragments(): ArrayList<MyViewPagerFragment?> = arrayListOf(items_fragment, recents_fragment) private fun getAllFragments(): ArrayList<MyViewPagerFragment?> = arrayListOf(items_fragment, recents_fragment, storage_fragment)
private fun getCurrentFragment(): MyViewPagerFragment? { private fun getCurrentFragment(): MyViewPagerFragment? {
val showTabs = config.showTabs val showTabs = config.showTabs
@ -651,6 +655,10 @@ class MainActivity : SimpleActivity() {
fragments.add(recents_fragment) fragments.add(recents_fragment)
} }
if (showTabs and TAB_STORAGE_ANALYSIS != 0) {
fragments.add(storage_fragment)
}
return fragments.getOrNull(main_view_pager.currentItem) return fragments.getOrNull(main_view_pager.currentItem)
} }

View File

@ -5,6 +5,7 @@ import android.view.ViewGroup
import androidx.viewpager.widget.PagerAdapter import androidx.viewpager.widget.PagerAdapter
import com.simplemobiletools.commons.helpers.TAB_FILES import com.simplemobiletools.commons.helpers.TAB_FILES
import com.simplemobiletools.commons.helpers.TAB_RECENT_FILES import com.simplemobiletools.commons.helpers.TAB_RECENT_FILES
import com.simplemobiletools.commons.helpers.TAB_STORAGE_ANALYSIS
import com.simplemobiletools.filemanager.pro.R import com.simplemobiletools.filemanager.pro.R
import com.simplemobiletools.filemanager.pro.activities.SimpleActivity import com.simplemobiletools.filemanager.pro.activities.SimpleActivity
import com.simplemobiletools.filemanager.pro.extensions.config import com.simplemobiletools.filemanager.pro.extensions.config
@ -44,6 +45,10 @@ class ViewPagerAdapter(val activity: SimpleActivity) : PagerAdapter() {
fragments.add(R.layout.recents_fragment) fragments.add(R.layout.recents_fragment)
} }
if (showTabs and TAB_STORAGE_ANALYSIS != 0) {
fragments.add(R.layout.storage_fragment)
}
return fragments[position] return fragments[position]
} }
} }

View File

@ -2,6 +2,7 @@ package com.simplemobiletools.filemanager.pro.helpers
import com.simplemobiletools.commons.helpers.TAB_FILES import com.simplemobiletools.commons.helpers.TAB_FILES
import com.simplemobiletools.commons.helpers.TAB_RECENT_FILES import com.simplemobiletools.commons.helpers.TAB_RECENT_FILES
import com.simplemobiletools.commons.helpers.TAB_STORAGE_ANALYSIS
const val PATH = "path" const val PATH = "path"
const val MAX_COLUMN_COUNT = 20 const val MAX_COLUMN_COUNT = 20
@ -30,5 +31,5 @@ const val OPEN_AS_AUDIO = 3
const val OPEN_AS_VIDEO = 4 const val OPEN_AS_VIDEO = 4
const val OPEN_AS_OTHER = 5 const val OPEN_AS_OTHER = 5
const val ALL_TABS_MASK = TAB_FILES or TAB_RECENT_FILES const val ALL_TABS_MASK = TAB_FILES or TAB_RECENT_FILES or TAB_STORAGE_ANALYSIS
val tabsList = arrayListOf(TAB_FILES, TAB_RECENT_FILES) val tabsList = arrayListOf(TAB_FILES, TAB_RECENT_FILES, TAB_STORAGE_ANALYSIS)

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFF"
android:pathData="M2,20h20v-4L2,16v4zM4,17h2v2L4,19v-2zM2,4v4h20L22,4L2,4zM6,7L4,7L4,5h2v2zM2,14h20v-4L2,10v4zM4,11h2v2L4,13v-2z" />
</vector>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<com.simplemobiletools.filemanager.pro.fragments.StorageFragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/storage_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent">
</com.simplemobiletools.filemanager.pro.fragments.StorageFragment>