fix #121, handle Select Ringtone intent
This commit is contained in:
parent
27da8b4841
commit
b1c7c6f9b1
20 changed files with 48 additions and 10 deletions
|
@ -33,6 +33,11 @@
|
|||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.RINGTONE_PICKER"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.simplemobiletools.filemanager.activities
|
|||
import android.app.Activity
|
||||
import android.content.ClipData
|
||||
import android.content.Intent
|
||||
import android.media.RingtoneManager
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.view.Menu
|
||||
|
@ -37,11 +38,11 @@ class MainActivity : SimpleActivity() {
|
|||
setContentView(R.layout.activity_main)
|
||||
storeStoragePaths()
|
||||
|
||||
fragment = fragment_holder as ItemsFragment
|
||||
val isGetContentIntent = intent.action == Intent.ACTION_GET_CONTENT
|
||||
val allowPickingMultiple = intent.getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE, false)
|
||||
fragment.isGetContentIntent = isGetContentIntent
|
||||
fragment.isPickMultipleIntent = allowPickingMultiple
|
||||
fragment = (fragment_holder as ItemsFragment).apply {
|
||||
isGetRingtonePicker = intent.action == RingtoneManager.ACTION_RINGTONE_PICKER
|
||||
isGetContentIntent = intent.action == Intent.ACTION_GET_CONTENT
|
||||
isPickMultipleIntent = intent.getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE, false)
|
||||
}
|
||||
|
||||
tryInitFileManager()
|
||||
checkWhatsNewDialog()
|
||||
|
@ -241,12 +242,23 @@ class MainActivity : SimpleActivity() {
|
|||
val resultIntent = Intent()
|
||||
val uri = getFilePublicUri(File(path), BuildConfig.APPLICATION_ID)
|
||||
val type = path.getMimeTypeFromPath()
|
||||
resultIntent.setDataAndTypeAndNormalize(uri, type)
|
||||
resultIntent.setDataAndType(uri, type)
|
||||
resultIntent.flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
|
||||
setResult(Activity.RESULT_OK, resultIntent)
|
||||
finish()
|
||||
}
|
||||
|
||||
fun pickedRingtone(path: String) {
|
||||
val resultIntent = Intent()
|
||||
val uri = getFilePublicUri(File(path), BuildConfig.APPLICATION_ID)
|
||||
val type = path.getMimeTypeFromPath()
|
||||
resultIntent.setDataAndType(uri, type)
|
||||
resultIntent.flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
|
||||
resultIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI, uri)
|
||||
setResult(Activity.RESULT_OK, resultIntent)
|
||||
finish()
|
||||
}
|
||||
|
||||
fun pickedPaths(paths: ArrayList<String>) {
|
||||
val uris = paths.map { getFilePublicUri(File(it), BuildConfig.APPLICATION_ID) } as ArrayList
|
||||
val clipData = ClipData("Attachment", arrayOf(uris.getMimeType()), ClipData.Item(uris.removeAt(0)))
|
||||
|
|
|
@ -10,10 +10,7 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.simplemobiletools.commons.dialogs.StoragePickerDialog
|
||||
import com.simplemobiletools.commons.extensions.deleteFiles
|
||||
import com.simplemobiletools.commons.extensions.getFilenameFromPath
|
||||
import com.simplemobiletools.commons.extensions.toast
|
||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.models.FileDirItem
|
||||
import com.simplemobiletools.commons.views.Breadcrumbs
|
||||
import com.simplemobiletools.commons.views.MyScalableRecyclerView
|
||||
|
@ -36,6 +33,7 @@ import kotlin.collections.ArrayList
|
|||
class ItemsFragment : Fragment(), ItemsAdapter.ItemOperationsListener, Breadcrumbs.BreadcrumbsListener {
|
||||
var currentPath = ""
|
||||
var isGetContentIntent = false
|
||||
var isGetRingtonePicker = false
|
||||
var isPickMultipleIntent = false
|
||||
|
||||
private var storedTextColor = 0
|
||||
|
@ -223,6 +221,12 @@ class ItemsFragment : Fragment(), ItemsAdapter.ItemOperationsListener, Breadcrum
|
|||
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 {
|
||||
val file = File(path)
|
||||
activity!!.openFile(Uri.fromFile(file), false)
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<string name="home_folder_updated">Domovská složka aktualizována</string>
|
||||
<string name="copy_path">Copy path to clipboard</string>
|
||||
<string name="path_copied">Path copied</string>
|
||||
<string name="select_audio_file">Please select an audio file</string>
|
||||
|
||||
<!-- Compression -->
|
||||
<string name="compress">Compress</string>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<string name="home_folder_updated">Home-Ordner aktualisiert</string>
|
||||
<string name="copy_path">Kopiere Pfad in die Zwischenablage</string>
|
||||
<string name="path_copied">Pfad kopiert</string>
|
||||
<string name="select_audio_file">Please select an audio file</string>
|
||||
|
||||
<!-- Compression -->
|
||||
<string name="compress">Komprimieren</string>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<string name="home_folder_updated">Carpeta principal actualizada</string>
|
||||
<string name="copy_path">Copy path to clipboard</string>
|
||||
<string name="path_copied">Path copied</string>
|
||||
<string name="select_audio_file">Please select an audio file</string>
|
||||
|
||||
<!-- Compression -->
|
||||
<string name="compress">Compress</string>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<string name="home_folder_updated">Dossier par défaut mis à jour</string>
|
||||
<string name="copy_path">Copy path to clipboard</string>
|
||||
<string name="path_copied">Path copied</string>
|
||||
<string name="select_audio_file">Please select an audio file</string>
|
||||
|
||||
<!-- Compression -->
|
||||
<string name="compress">Compresser</string>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<string name="home_folder_updated">Kezdőmappa frissítve</string>
|
||||
<string name="copy_path">Copy path to clipboard</string>
|
||||
<string name="path_copied">Path copied</string>
|
||||
<string name="select_audio_file">Please select an audio file</string>
|
||||
|
||||
<!-- Compression -->
|
||||
<string name="compress">Compress</string>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<string name="home_folder_updated">Cartella home aggiornata</string>
|
||||
<string name="copy_path">Copia percorso negli appunti</string>
|
||||
<string name="path_copied">Percorso copiato</string>
|
||||
<string name="select_audio_file">Please select an audio file</string>
|
||||
|
||||
<!-- Compression -->
|
||||
<string name="compress">Comprimi</string>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<string name="home_folder_updated">Home folder updated</string>
|
||||
<string name="copy_path">Copy path to clipboard</string>
|
||||
<string name="path_copied">Path copied</string>
|
||||
<string name="select_audio_file">Please select an audio file</string>
|
||||
|
||||
<!-- Compression -->
|
||||
<string name="compress">Compress</string>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<string name="home_folder_updated">홈 폴더 설정완료</string>
|
||||
<string name="copy_path">Copy path to clipboard</string>
|
||||
<string name="path_copied">Path copied</string>
|
||||
<string name="select_audio_file">Please select an audio file</string>
|
||||
|
||||
<!-- Compression -->
|
||||
<string name="compress">Compress</string>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<string name="home_folder_updated">Beginmap ingesteld</string>
|
||||
<string name="copy_path">Pad naar klembord kopiëren</string>
|
||||
<string name="path_copied">Pad gekopieerd</string>
|
||||
<string name="select_audio_file">Please select an audio file</string>
|
||||
|
||||
<!-- Compression -->
|
||||
<string name="compress">Inpakken</string>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<string name="home_folder_updated">Folder główny został zaktulizowany</string>
|
||||
<string name="copy_path">Copy path to clipboard</string>
|
||||
<string name="path_copied">Path copied</string>
|
||||
<string name="select_audio_file">Please select an audio file</string>
|
||||
|
||||
<!-- Compression -->
|
||||
<string name="compress">Compress</string>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<string name="home_folder_updated">Pasta pessoal atualizada</string>
|
||||
<string name="copy_path">Copy path to clipboard</string>
|
||||
<string name="path_copied">Path copied</string>
|
||||
<string name="select_audio_file">Please select an audio file</string>
|
||||
|
||||
<!-- Compression -->
|
||||
<string name="compress">Compress</string>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<string name="home_folder_updated">Pasta pessoal atualizada</string>
|
||||
<string name="copy_path">Copiar caminho para a área de transferência</string>
|
||||
<string name="path_copied">Caminho copiado</string>
|
||||
<string name="select_audio_file">Please select an audio file</string>
|
||||
|
||||
<!-- Compression -->
|
||||
<string name="compress">Comprimir</string>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<string name="home_folder_updated">Домашняя папка установлена</string>
|
||||
<string name="copy_path">Copy path to clipboard</string>
|
||||
<string name="path_copied">Path copied</string>
|
||||
<string name="select_audio_file">Please select an audio file</string>
|
||||
|
||||
<!-- Compression -->
|
||||
<string name="compress">Сжать</string>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<string name="home_folder_updated">Domovský priečinok bol nastavený</string>
|
||||
<string name="copy_path">Kopírovať cestu do schránky</string>
|
||||
<string name="path_copied">Cesta skopírovaná</string>
|
||||
<string name="select_audio_file">Prosím zvoľte audio súbor</string>
|
||||
|
||||
<!-- Compression -->
|
||||
<string name="compress">Komprimovať</string>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<string name="home_folder_updated">Hemmappen har uppdaterats</string>
|
||||
<string name="copy_path">Copy path to clipboard</string>
|
||||
<string name="path_copied">Path copied</string>
|
||||
<string name="select_audio_file">Please select an audio file</string>
|
||||
|
||||
<!-- Compression -->
|
||||
<string name="compress">Komprimera</string>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<string name="home_folder_updated">Home folder updated</string>
|
||||
<string name="copy_path">Copy path to clipboard</string>
|
||||
<string name="path_copied">Path copied</string>
|
||||
<string name="select_audio_file">Please select an audio file</string>
|
||||
|
||||
<!-- Compression -->
|
||||
<string name="compress">Compress</string>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<string name="home_folder_updated">Home folder updated</string>
|
||||
<string name="copy_path">Copy path to clipboard</string>
|
||||
<string name="path_copied">Path copied</string>
|
||||
<string name="select_audio_file">Please select an audio file</string>
|
||||
|
||||
<!-- Compression -->
|
||||
<string name="compress">Compress</string>
|
||||
|
|
Loading…
Reference in a new issue