properly handle third party intents in the Recents tab
This commit is contained in:
parent
9143e07949
commit
39eb160f6b
|
@ -19,7 +19,6 @@ import com.simplemobiletools.filemanager.pro.adapters.ItemsAdapter
|
|||
import com.simplemobiletools.filemanager.pro.dialogs.CreateNewItemDialog
|
||||
import com.simplemobiletools.filemanager.pro.extensions.config
|
||||
import com.simplemobiletools.filemanager.pro.extensions.isPathOnRoot
|
||||
import com.simplemobiletools.filemanager.pro.extensions.tryOpenPathIntent
|
||||
import com.simplemobiletools.filemanager.pro.helpers.MAX_COLUMN_COUNT
|
||||
import com.simplemobiletools.filemanager.pro.helpers.RootHelpers
|
||||
import com.simplemobiletools.filemanager.pro.interfaces.ItemOperationsListener
|
||||
|
@ -30,7 +29,6 @@ import java.util.*
|
|||
import kotlin.collections.ArrayList
|
||||
|
||||
class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet), ItemOperationsListener, Breadcrumbs.BreadcrumbsListener {
|
||||
private var activity: SimpleActivity? = null
|
||||
private var showHidden = false
|
||||
private var skipItemUpdating = false
|
||||
private var isSearchOpen = false
|
||||
|
@ -248,18 +246,7 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||
if (item.isDirectory) {
|
||||
openDirectory(item.path)
|
||||
} else {
|
||||
val path = item.path
|
||||
if (isGetContentIntent) {
|
||||
(activity as MainActivity).pickedPath(path)
|
||||
} else if (isGetRingtonePicker) {
|
||||
if (path.isAudioFast()) {
|
||||
(activity as MainActivity).pickedRingtone(path)
|
||||
} else {
|
||||
activity?.toast(R.string.select_audio_file)
|
||||
}
|
||||
} else {
|
||||
activity?.tryOpenPathIntent(path, false)
|
||||
}
|
||||
clickedPath(item.path)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,14 +3,35 @@ package com.simplemobiletools.filemanager.pro.fragments
|
|||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.widget.RelativeLayout
|
||||
import com.simplemobiletools.commons.extensions.isAudioFast
|
||||
import com.simplemobiletools.commons.extensions.toast
|
||||
import com.simplemobiletools.filemanager.pro.R
|
||||
import com.simplemobiletools.filemanager.pro.activities.MainActivity
|
||||
import com.simplemobiletools.filemanager.pro.activities.SimpleActivity
|
||||
import com.simplemobiletools.filemanager.pro.extensions.tryOpenPathIntent
|
||||
|
||||
abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) : RelativeLayout(context, attributeSet) {
|
||||
protected var activity: SimpleActivity? = null
|
||||
|
||||
var currentPath = ""
|
||||
var isGetContentIntent = false
|
||||
var isGetRingtonePicker = false
|
||||
var isPickMultipleIntent = false
|
||||
|
||||
protected fun clickedPath(path: String) {
|
||||
if (isGetContentIntent) {
|
||||
(activity as MainActivity).pickedPath(path)
|
||||
} else if (isGetRingtonePicker) {
|
||||
if (path.isAudioFast()) {
|
||||
(activity as MainActivity).pickedRingtone(path)
|
||||
} else {
|
||||
activity?.toast(R.string.select_audio_file)
|
||||
}
|
||||
} else {
|
||||
activity?.tryOpenPathIntent(path, false)
|
||||
}
|
||||
}
|
||||
|
||||
abstract fun setupFragment(activity: SimpleActivity)
|
||||
|
||||
abstract fun setupColors(textColor: Int, adjustedPrimaryColor: Int)
|
||||
|
|
|
@ -11,15 +11,12 @@ import com.simplemobiletools.commons.views.MyGridLayoutManager
|
|||
import com.simplemobiletools.filemanager.pro.activities.SimpleActivity
|
||||
import com.simplemobiletools.filemanager.pro.adapters.ItemsAdapter
|
||||
import com.simplemobiletools.filemanager.pro.extensions.config
|
||||
import com.simplemobiletools.filemanager.pro.extensions.tryOpenPathIntent
|
||||
import com.simplemobiletools.filemanager.pro.interfaces.ItemOperationsListener
|
||||
import com.simplemobiletools.filemanager.pro.models.ListItem
|
||||
import kotlinx.android.synthetic.main.recents_fragment.view.*
|
||||
import java.util.*
|
||||
|
||||
class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet), ItemOperationsListener {
|
||||
private var activity: SimpleActivity? = null
|
||||
|
||||
override fun setupFragment(activity: SimpleActivity) {
|
||||
if (this.activity == null) {
|
||||
this.activity = activity
|
||||
|
@ -33,8 +30,8 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
|||
ensureBackgroundThread {
|
||||
getRecents { recents ->
|
||||
recents_swipe_refresh?.isRefreshing = false
|
||||
ItemsAdapter(activity as SimpleActivity, recents, this, recents_list, false, null, recents_swipe_refresh) {
|
||||
activity?.tryOpenPathIntent((it as FileDirItem).path, false)
|
||||
ItemsAdapter(activity as SimpleActivity, recents, this, recents_list, isPickMultipleIntent, null, recents_swipe_refresh) {
|
||||
clickedPath((it as FileDirItem).path)
|
||||
}.apply {
|
||||
recents_list.adapter = this
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue