Skip to content

Commit 16d0b2e

Browse files
committed
do not show the Storage Analysis tab at file picker intent
1 parent 83c25dd commit 16d0b2e

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ import com.simplemobiletools.filemanager.pro.fragments.MyViewPagerFragment
3939
import com.simplemobiletools.filemanager.pro.fragments.StorageFragment
4040
import com.simplemobiletools.filemanager.pro.helpers.MAX_COLUMN_COUNT
4141
import com.simplemobiletools.filemanager.pro.helpers.RootHelpers
42-
import com.simplemobiletools.filemanager.pro.helpers.tabsList
4342
import com.simplemobiletools.filemanager.pro.interfaces.ItemOperationsListener
4443
import com.stericson.RootTools.RootTools
4544
import 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))

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/adapters/ViewPagerAdapter.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ import com.simplemobiletools.filemanager.pro.R
1111
import com.simplemobiletools.filemanager.pro.activities.SimpleActivity
1212
import com.simplemobiletools.filemanager.pro.extensions.config
1313
import com.simplemobiletools.filemanager.pro.fragments.MyViewPagerFragment
14-
import com.simplemobiletools.filemanager.pro.helpers.tabsList
1514

16-
class ViewPagerAdapter(val activity: SimpleActivity) : PagerAdapter() {
15+
class ViewPagerAdapter(val activity: SimpleActivity, val tabsToShow: ArrayList<Int>) : PagerAdapter() {
1716
override fun instantiateItem(container: ViewGroup, position: Int): Any {
1817
val layout = getFragment(position)
1918
val view = activity.layoutInflater.inflate(layout, container, false)
@@ -31,7 +30,7 @@ class ViewPagerAdapter(val activity: SimpleActivity) : PagerAdapter() {
3130
container.removeView(item as View)
3231
}
3332

34-
override fun getCount() = tabsList.filter { it and activity.config.showTabs != 0 }.size
33+
override fun getCount() = tabsToShow.filter { it and activity.config.showTabs != 0 }.size
3534

3635
override fun isViewFromObject(view: View, item: Any) = view == item
3736

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/helpers/Constants.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ const val OPEN_AS_VIDEO = 4
3232
const val OPEN_AS_OTHER = 5
3333

3434
const val ALL_TABS_MASK = TAB_FILES or TAB_RECENT_FILES or TAB_STORAGE_ANALYSIS
35-
val tabsList = arrayListOf(TAB_FILES, TAB_RECENT_FILES, TAB_STORAGE_ANALYSIS)
3635

3736
const val IMAGES = "images"
3837
const val VIDEOS = "videos"

0 commit comments

Comments
 (0)