@@ -39,7 +39,6 @@ import com.simplemobiletools.filemanager.pro.fragments.MyViewPagerFragment
3939import com.simplemobiletools.filemanager.pro.fragments.StorageFragment
4040import com.simplemobiletools.filemanager.pro.helpers.MAX_COLUMN_COUNT
4141import com.simplemobiletools.filemanager.pro.helpers.RootHelpers
42- import com.simplemobiletools.filemanager.pro.helpers.tabsList
4342import com.simplemobiletools.filemanager.pro.interfaces.ItemOperationsListener
4443import com.stericson.RootTools.RootTools
4544import kotlinx.android.synthetic.main.activity_main.*
@@ -58,6 +57,7 @@ class MainActivity : SimpleActivity() {
5857 private var wasBackJustPressed = false
5958 private var mIsPasswordProtectionPending = false
6059 private var mWasProtectionHandled = false
60+ private var mTabsToShow = ArrayList <Int >()
6161 private var searchMenuItem: MenuItem ? = null
6262
6363 private var storedFontSize = 0
@@ -69,6 +69,7 @@ class MainActivity : SimpleActivity() {
6969 super .onCreate(savedInstanceState)
7070 setContentView(R .layout.activity_main)
7171 appLaunched(BuildConfig .APPLICATION_ID )
72+ mTabsToShow = getTabsList()
7273
7374 if (! config.wasStorageAnalysisTabAdded && isOreoPlus()) {
7475 config.wasStorageAnalysisTabAdded = true
@@ -381,7 +382,7 @@ class MainActivity : SimpleActivity() {
381382 }
382383
383384 private fun initFragments () {
384- main_view_pager.adapter = ViewPagerAdapter (this )
385+ main_view_pager.adapter = ViewPagerAdapter (this , mTabsToShow )
385386 main_view_pager.offscreenPageLimit = 2
386387
387388 main_view_pager.addOnPageChangeListener(object : ViewPager .OnPageChangeListener {
@@ -406,7 +407,17 @@ class MainActivity : SimpleActivity() {
406407
407408 private fun setupTabs () {
408409 main_tabs_holder.removeAllTabs()
409- tabsList.forEachIndexed { index, value ->
410+ val isPickFileIntent = intent.action == RingtoneManager .ACTION_RINGTONE_PICKER || intent.action == Intent .ACTION_GET_CONTENT
411+ if (isPickFileIntent) {
412+ mTabsToShow.remove(TAB_STORAGE_ANALYSIS )
413+ if (mTabsToShow.none { it and config.showTabs != 0 }) {
414+ config.showTabs = TAB_FILES
415+ storedShowTabs = TAB_FILES
416+ mTabsToShow = arrayListOf (TAB_FILES )
417+ }
418+ }
419+
420+ mTabsToShow.forEachIndexed { index, value ->
410421 if (config.showTabs and value != 0 ) {
411422 main_tabs_holder.newTab().setCustomView(R .layout.bottom_tablayout_item).apply {
412423 customView?.findViewById<ImageView >(R .id.tab_item_icon)?.setImageDrawable(getTabIcon(index))
@@ -702,7 +713,7 @@ class MainActivity : SimpleActivity() {
702713 }
703714 }
704715
705- private fun getInactiveTabIndexes (activeIndex : Int ) = (0 until tabsList .size).filter { it != activeIndex }
716+ private fun getInactiveTabIndexes (activeIndex : Int ) = (0 until getTabsList() .size).filter { it != activeIndex }
706717
707718 private fun getAllFragments (): ArrayList <MyViewPagerFragment ?> = arrayListOf (items_fragment, recents_fragment, storage_fragment)
708719
@@ -724,6 +735,8 @@ class MainActivity : SimpleActivity() {
724735 return fragments.getOrNull(main_view_pager.currentItem)
725736 }
726737
738+ private fun getTabsList () = arrayListOf (TAB_FILES , TAB_RECENT_FILES , TAB_STORAGE_ANALYSIS )
739+
727740 private fun checkWhatsNewDialog () {
728741 arrayListOf<Release >().apply {
729742 add(Release (26 , R .string.release_26))
0 commit comments