limit some file operations to rooted devices only

This commit is contained in:
tibbi 2018-04-17 19:25:22 +02:00
parent c13bedbfa8
commit 4cdb5e1624
25 changed files with 72 additions and 26 deletions

View file

@ -30,6 +30,7 @@ import com.simplemobiletools.filemanager.dialogs.CompressAsDialog
import com.simplemobiletools.filemanager.extensions.*
import com.simplemobiletools.filemanager.helpers.RootHelpers
import com.simplemobiletools.filemanager.interfaces.ItemOperationsListener
import com.stericson.RootTools.RootTools
import kotlinx.android.synthetic.main.list_item.view.*
import java.io.Closeable
import java.io.File
@ -433,6 +434,11 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
val removeFiles = ArrayList<FileDirItem>(selectedPositions.size)
val SAFPath = fileDirItems[selectedPositions.first()].path
if (activity.isPathOnRoot(SAFPath) && !RootTools.isRootAvailable()) {
activity.toast(R.string.rooted_device_only)
return
}
activity.handleSAFDialog(SAFPath) {
selectedPositions.sortedDescending().forEach {
val file = fileDirItems[it]

View file

@ -3,8 +3,10 @@ package com.simplemobiletools.filemanager.helpers
import android.app.Activity
import com.simplemobiletools.commons.extensions.areDigitsOnly
import com.simplemobiletools.commons.extensions.showErrorToast
import com.simplemobiletools.commons.extensions.toast
import com.simplemobiletools.commons.helpers.SORT_BY_SIZE
import com.simplemobiletools.commons.models.FileDirItem
import com.simplemobiletools.filemanager.R
import com.simplemobiletools.filemanager.extensions.config
import com.stericson.RootShell.execution.Command
import com.stericson.RootTools.RootTools
@ -160,6 +162,11 @@ class RootHelpers(val activity: Activity) {
}
fun createFileFolder(path: String, isFile: Boolean, callback: (success: Boolean) -> Unit) {
if (!RootTools.isRootAvailable()) {
activity.toast(R.string.rooted_device_only)
return
}
tryMountAsRW(path) {
val mountPoint = it
val targetPath = path.trim('/')
@ -239,6 +246,11 @@ class RootHelpers(val activity: Activity) {
}
fun deleteFiles(fileDirItems: ArrayList<FileDirItem>) {
if (!RootTools.isRootAvailable()) {
activity.toast(R.string.rooted_device_only)
return
}
tryMountAsRW(fileDirItems.first().path) {
fileDirItems.forEach {
val targetPath = it.path.trim('/')
@ -256,6 +268,11 @@ class RootHelpers(val activity: Activity) {
}
fun copyMoveFiles(fileDirItems: ArrayList<FileDirItem>, destination: String, isCopyOperation: Boolean, successes: Int = 0, callback: (Int) -> Unit) {
if (!RootTools.isRootAvailable()) {
activity.toast(R.string.rooted_device_only)
return
}
val fileDirItem = fileDirItems.first()
val mainCommand = if (isCopyOperation) {
if (fileDirItem.isDirectory) "cp -R" else "cp"

View file

@ -11,13 +11,14 @@
<string name="path_copied">تم نسخ المسار</string>
<string name="select_audio_file">الرجاء تحديد ملف صوتي</string>
<string name="search_folder">Search folder</string>
<string name="rooted_device_only">This operation works only on rooted devices</string>
<!-- Compression -->
<string name="compress">ضغط</string>
<string name="decompress">فك الضغط</string>
<string name="compress_as">ضغط كا</string>
<string name="compressing">ضغط…</string>
<string name="decompressing">فك الضغط...</string>
<string name="decompressing">فك الضغط</string>
<string name="compression_successful">نجح الضغط</string>
<string name="decompression_successful">نجح التفكيك</string>
<string name="compressing_failed">أخفق الضغط</string>
@ -44,7 +45,7 @@
<string name="app_long_description">ويمكن أيضا أن يستخدم لتصفح ملفات الجذر ومحتوى بطاقة الذاكرة. يمكنك بسهولة إعادة تسمية، نسخ، نقل وحذف ومشاركة أي شيء تريده. \n
لا يحتوي على إعلانات أو أذونات لا حاجة لها. مفتوح المصدر بشكل كامل ، ويوفر الألوان للتخصيص. هذا التطبيق هو مجرد قطعة واحدة من سلسلة أكبر من التطبيقات. \n
يمكنك العثور عليها هنا\n
http://www.simplemobiletools.com</string>
https://www.simplemobiletools.com</string>
<!--
Haven't found some strings? There's more at

View file

@ -11,6 +11,7 @@
<string name="path_copied">Path copied</string>
<string name="select_audio_file">Please select an audio file</string>
<string name="search_folder">Search folder</string>
<string name="rooted_device_only">This operation works only on rooted devices</string>
<!-- Compression -->
<string name="compress">Compress</string>
@ -48,7 +49,7 @@
Neobsahuje žádné reklamy a nepotřebná oprávnění. Aplikace je plně opensource a mimo jiné obsahuje také Tmavé téma.
Tato aplikace je pouze jedna část větší série aplikací. Zbytek aplikací můžete nalézt na http://www.simplemobiletools.com
Tato aplikace je pouze jedna část větší série aplikací. Zbytek aplikací můžete nalézt na https://www.simplemobiletools.com
</string>
<!--

View file

@ -11,6 +11,7 @@
<string name="path_copied">Sti kopieret</string>
<string name="select_audio_file">Vælg en lydfil</string>
<string name="search_folder">Søg mappe</string>
<string name="rooted_device_only">This operation works only on rooted devices</string>
<!-- Compression -->
<string name="compress">Komprimer</string>
@ -48,7 +49,7 @@
Uden reklamer og unødvendige tilladelser. Den er helt igennem open source, og du kan selv bestemme farverne.
Denne app er en enkelt del af en større serie apps. Du finder dem alle på siden http://www.simplemobiletools.com
Denne app er en enkelt del af en større serie apps. Du finder dem alle på siden https://www.simplemobiletools.com
</string>
<!--

View file

@ -11,6 +11,7 @@
<string name="path_copied">Pfad kopiert</string>
<string name="select_audio_file">Bitte wähle eine Audiodatei aus</string>
<string name="search_folder">Ordner suchen</string>
<string name="rooted_device_only">This operation works only on rooted devices</string>
<!-- Compression -->
<string name="compress">Komprimieren</string>
@ -48,7 +49,7 @@
Beinhaltet keine Werbung oder unnötige Berechtigungen. Sie ist komplett Open Source, alle verwendeten Farben sind anpassbar.
Diese App ist nur eine aus einer größeren Serie von schlichten Apps. Der Rest davon findet sich auf http://www.simplemobiletools.com
Diese App ist nur eine aus einer größeren Serie von schlichten Apps. Der Rest davon findet sich auf https://www.simplemobiletools.com
</string>
<!--

View file

@ -11,6 +11,7 @@
<string name="path_copied">Path copied</string>
<string name="select_audio_file">Please select an audio file</string>
<string name="search_folder">Search folder</string>
<string name="rooted_device_only">This operation works only on rooted devices</string>
<!-- Compression -->
<string name="compress">Compress</string>
@ -48,7 +49,7 @@
No contiene anuncios ni permisos innecesarios. Es completamente OpenSource y además provee un tema oscuro.
Esta aplicación es tan solo una pequeña parte de una serie de aplicaciones. Puede encontrar el resto en http://www.simplemobiletools.com
Esta aplicación es tan solo una pequeña parte de una serie de aplicaciones. Puede encontrar el resto en https://www.simplemobiletools.com
</string>
<!--

View file

@ -11,6 +11,7 @@
<string name="path_copied">Chemin du fichier copié</string>
<string name="select_audio_file">Veuillez sélectionner un fichier audio</string>
<string name="search_folder">Chercher dans le dossier</string>
<string name="rooted_device_only">This operation works only on rooted devices</string>
<!-- Compression -->
<string name="compress">Compresser</string>
@ -48,7 +49,7 @@
Ne contient pas de pubs ou de permissions inutiles. C\'est un logiciel libre et open-source. Il y a un thème sombre.
Cette app est juste une pièce d\'une plus grande série d\'apps. Vous pouvez trouver le reste à http://www.simplemobiletools.com
Cette app est juste une pièce d\'une plus grande série d\'apps. Vous pouvez trouver le reste à https://www.simplemobiletools.com
</string>
<!--

View file

@ -11,13 +11,14 @@
<string name="path_copied">Putanja kopirana</string>
<string name="select_audio_file">Odaberite audio datoteku</string>
<string name="search_folder">Pretraži mapu</string>
<string name="rooted_device_only">This operation works only on rooted devices</string>
<!-- Compression -->
<string name="compress">Sažmi</string>
<string name="decompress">Otpakiraj</string>
<string name="compress_as">Sažmi kao</string>
<string name="compressing">Sažimanje...</string>
<string name="decompressing">Otpakiravanje...</string>
<string name="compressing">Sažimanje</string>
<string name="decompressing">Otpakiravanje</string>
<string name="compression_successful">Sažimanje uspješno</string>
<string name="decompression_successful">Otpakiravanje uspješno</string>
<string name="compressing_failed">Sažimanje neuspješno</string>
@ -48,7 +49,7 @@
Ne sadrži oglase ili nepotrebne dozvole. Aplikacije je otvorenog koda, pruža prilagodljive boje.
Ova je aplikacija samo dio većeg broja aplikacija. Možete pronaći ostatak na http://www.simplemobiletools.com
Ova je aplikacija samo dio većeg broja aplikacija. Možete pronaći ostatak na https://www.simplemobiletools.com
</string>
<!--

View file

@ -11,6 +11,7 @@
<string name="path_copied">Path copied</string>
<string name="select_audio_file">Please select an audio file</string>
<string name="search_folder">Search folder</string>
<string name="rooted_device_only">This operation works only on rooted devices</string>
<!-- Compression -->
<string name="compress">Compress</string>
@ -48,7 +49,7 @@
Nincsenek reklámok, sem felesleges engedélykérések. Teljesen nyílt forráskódú. Sötét téma is elérhető.
Ez az alkalmazás egy nagyobb sorozat egyik darabja. A többit is megtalálod itt: http://www.simplemobiletools.com
Ez az alkalmazás egy nagyobb sorozat egyik darabja. A többit is megtalálod itt: https://www.simplemobiletools.com
</string>
<!--

View file

@ -11,6 +11,7 @@
<string name="path_copied">Path Di Copy</string>
<string name="select_audio_file">Pilih File Audio</string>
<string name="search_folder">Cari Folder</string>
<string name="rooted_device_only">This operation works only on rooted devices</string>
<!-- Compression -->
<string name="compress">Compress</string>
@ -48,7 +49,7 @@
Tidak berisi iklan atau izin yang tidak perlu. Ini sepenuhnya opensource, menyediakan warna yang dapat disesuaikan.
Aplikasi ini hanyalah salah satu rangkaian aplikasi yang lebih besar. Anda bisa menemukannya di http://www.simplemobiletools.com
Aplikasi ini hanyalah salah satu rangkaian aplikasi yang lebih besar. Anda bisa menemukannya di https://www.simplemobiletools.com
</string>
<!--

View file

@ -11,6 +11,7 @@
<string name="path_copied">Percorso copiato</string>
<string name="select_audio_file">Seleziona un file audio</string>
<string name="search_folder">Cerca cartella</string>
<string name="rooted_device_only">This operation works only on rooted devices</string>
<!-- Compression -->
<string name="compress">Comprimi</string>
@ -48,7 +49,7 @@
Non contiene pubblicità e non chiede autorizzazioni non necessarie. È completamente opensource, offre anche un tema scuro.
Questa app è solo una piccola parte di una grande serie di altre app. Puoi trovarle tutte su http://www.simplemobiletools.com
Questa app è solo una piccola parte di una grande serie di altre app. Puoi trovarle tutte su https://www.simplemobiletools.com
</string>
<!--

View file

@ -11,6 +11,7 @@
<string name="path_copied">パスをコピーしました</string>
<string name="select_audio_file">オーディオファイルを選択してください</string>
<string name="search_folder">フォルダーを検索</string>
<string name="rooted_device_only">This operation works only on rooted devices</string>
<!-- Compression -->
<string name="compress">圧縮</string>
@ -48,7 +49,7 @@
広告や不要なアクセス許可は含まれていません。 完全にオープンソースで、ダークテーマも提供しています。
このアプリは、大きな一連のアプリの一つです。 他のアプリは http://www.simplemobiletools.com で見つけることができます
このアプリは、大きな一連のアプリの一つです。 他のアプリは https://www.simplemobiletools.com で見つけることができます
</string>
<!--

View file

@ -11,6 +11,7 @@
<string name="path_copied">클립보드에 복사됨</string>
<string name="select_audio_file">오디도 파일을 선택하세요.</string>
<string name="search_folder">폴더 및 파일검색</string>
<string name="rooted_device_only">This operation works only on rooted devices</string>
<!-- Compression -->
<string name="compress">압축</string>
@ -48,7 +49,7 @@
광고가 포함되어 있거나, 불필요한 권한을 요청하지 않습니다. 이 앱의 모든 소스는 오픈소스이며, 사용자가 직접 애플리케이션의 컬러를 설정 할 수 있습니다.
이 앱은 다양한 시리즈의 모바일앱 중 하나입니다. 나머지는 http://www.simplemobiletools.com 에서 찾아 보실 수 있습니다.
이 앱은 다양한 시리즈의 모바일앱 중 하나입니다. 나머지는 https://www.simplemobiletools.com 에서 찾아 보실 수 있습니다.
</string>
<!--

View file

@ -11,6 +11,7 @@
<string name="path_copied">Kelias nukopijuotas</string>
<string name="select_audio_file">Prašome pasirinkti garso bylą</string>
<string name="search_folder">Ieškoti aplanke</string>
<string name="rooted_device_only">This operation works only on rooted devices</string>
<!-- Compression -->
<string name="compress">Suspausti</string>
@ -48,7 +49,7 @@
Neturi reklamų ar nereikalingų leidimų. Programėlė visiškai atviro kodo, yra galimybė keisti spalvas.
Ši programėle yra viena iš keletos mūsų programėlių. Likusias Jūs galite rasti čia http://www.simplemobiletools.com
Ši programėle yra viena iš keletos mūsų programėlių. Likusias Jūs galite rasti čia https://www.simplemobiletools.com
</string>
<!--

View file

@ -11,6 +11,7 @@
<string name="path_copied">Pad gekopieerd</string>
<string name="select_audio_file">Selecteer een geluidsbestand</string>
<string name="search_folder">Search folder</string>
<string name="rooted_device_only">This operation works only on rooted devices</string>
<!-- Compression -->
<string name="compress">Inpakken</string>
@ -48,7 +49,7 @@
Bevat geen advertenties of onnodige permissies. Volledig open-source. Kleuren van de app kunnen worden aangepast.
Deze app is onderdeel van een grotere verzameling. Vind de andere apps op http://www.simplemobiletools.com
Deze app is onderdeel van een grotere verzameling. Vind de andere apps op https://www.simplemobiletools.com
</string>
<!--

View file

@ -11,6 +11,7 @@
<string name="path_copied">Ścieżka została skopiowana</string>
   <string name="select_audio_file">Wybierz plik audio</string>
   <string name="search_folder">Przeszukaj folder</string>
<string name="rooted_device_only">This operation works only on rooted devices</string>
<!-- Compression -->
   <string name="compress">Kompresuj</string>
@ -48,7 +49,7 @@
      Aplikacja nie zawiera żadnych żadnych reklam, nie potrzebuje masy uprawnień, jest w pełni otwartoźródłowa, posiada ciemny motyw dla osób z wrażliwymi oczami.
Niniejsza aplikacja jest tylko częścią naszej kolekcji prostych narzędzi. Ta, jak i pozostałe, dostępne są na stronie http://www.simplemobiletools.com
Niniejsza aplikacja jest tylko częścią naszej kolekcji prostych narzędzi. Ta, jak i pozostałe, dostępne są na stronie https://www.simplemobiletools.com
</string>
<!--

View file

@ -11,6 +11,7 @@
<string name="path_copied">Path copied</string>
<string name="select_audio_file">Please select an audio file</string>
<string name="search_folder">Search folder</string>
<string name="rooted_device_only">This operation works only on rooted devices</string>
<!-- Compression -->
<string name="compress">Compress</string>
@ -48,7 +49,7 @@
Não contém anúncios nem permissões desnecessárias. Disponibiliza um tema escuro e é totalmente \'open source\'.
Este aplicativo é apenas parte de um conjunto mais vasto de aplicações. Saiba mais em http://www.simplemobiletools.com
Este aplicativo é apenas parte de um conjunto mais vasto de aplicações. Saiba mais em https://www.simplemobiletools.com
</string>
<!--

View file

@ -11,6 +11,7 @@
<string name="path_copied">Caminho copiado</string>
<string name="select_audio_file">Selecione um ficheiro de áudio</string>
<string name="search_folder">Pesquisar pasta</string>
<string name="rooted_device_only">This operation works only on rooted devices</string>
<!-- Compression -->
<string name="compress">Comprimir</string>
@ -48,7 +49,7 @@
Não contém anúncios nem permissões desnecessárias. Disponibiliza um tema escuro e é totalmente \'open source\'.
Esta aplicação é apenas parte de um conjunto mais vasto de aplicações. Saiba mais em http://www.simplemobiletools.com
Esta aplicação é apenas parte de um conjunto mais vasto de aplicações. Saiba mais em https://www.simplemobiletools.com
</string>
<!--

View file

@ -11,6 +11,7 @@
<string name="path_copied">Путь скопирован</string>
<string name="select_audio_file">Пожалуйста, выберите аудиофайл</string>
<string name="search_folder">Искать в папке</string>
<string name="rooted_device_only">This operation works only on rooted devices</string>
<!-- Compression -->
<string name="compress">Сжать</string>
@ -48,7 +49,7 @@
Это приложение не будет показывать рекламу или запрашивать ненужные разрешения. У него полностью открытый исходный код и есть тёмная тема оформления.
Simple File Manager - это приложение из серии Simple Mobile Tools. Остальные приложения из этой серии можно найти здесь: http://www.simplemobiletools.com
Simple File Manager - это приложение из серии Simple Mobile Tools. Остальные приложения из этой серии можно найти здесь: https://www.simplemobiletools.com
</string>
<!--

View file

@ -11,6 +11,7 @@
<string name="path_copied">Cesta skopírovaná</string>
<string name="select_audio_file">Prosím zvoľte audio súbor</string>
<string name="search_folder">Hľadať v priečinku</string>
<string name="rooted_device_only">Táto operácia funguje iba na rootnutých zariadeniach</string>
<!-- Compression -->
<string name="compress">Komprimovať</string>
@ -48,7 +49,7 @@
Neobsahuje žiadne reklamy a nepotrebné oprávnenia. Je opensource, poskytuje možnosť zmeny farieb.
Táto aplikácia je iba jednou zo skupiny aplikácií. Ostatné viete nájsť na http://www.simplemobiletools.com
Táto aplikácia je iba jednou zo skupiny aplikácií. Ostatné viete nájsť na https://www.simplemobiletools.com
</string>
<!--

View file

@ -11,6 +11,7 @@
<string name="path_copied">Sökvägen har kopierats</string>
<string name="select_audio_file">Välj en ljudfil</string>
<string name="search_folder">Sök i mappen</string>
<string name="rooted_device_only">This operation works only on rooted devices</string>
<!-- Compression -->
<string name="compress">Komprimera</string>
@ -48,7 +49,7 @@
Innehåller ingen reklam eller onödiga behörigheter. Den har helt öppen källkod och anpassningsbara färger.
Denna app är bara en del av en större serie appar. Du hittar resten av dem på http://www.simplemobiletools.com
Denna app är bara en del av en större serie appar. Du hittar resten av dem på https://www.simplemobiletools.com
</string>
<!--

View file

@ -11,6 +11,7 @@
<string name="path_copied">Path copied</string>
<string name="select_audio_file">Please select an audio file</string>
<string name="search_folder">Search folder</string>
<string name="rooted_device_only">This operation works only on rooted devices</string>
<!-- Compression -->
<string name="compress">Compress</string>
@ -48,7 +49,7 @@
Reklam içermeyen veya gereksiz izinler. Tamamen açık kaynaklı, Karanlık bir tema da sunuyor.
Bu uygulama, daha büyük bir uygulama serisinden sadece bir parça. Geri kalanını şu adresten bulabilirsiniz http://www.simplemobiletools.com
Bu uygulama, daha büyük bir uygulama serisinden sadece bir parça. Geri kalanını şu adresten bulabilirsiniz https://www.simplemobiletools.com
</string>
<!--

View file

@ -11,6 +11,7 @@
<string name="path_copied">路徑已複製</string>
<string name="select_audio_file">請選擇一個音訊檔案</string>
<string name="search_folder">搜尋資料夾</string>
<string name="rooted_device_only">This operation works only on rooted devices</string>
<!-- Compression -->
<string name="compress">壓縮</string>
@ -48,7 +49,7 @@
不包含廣告及非必要的權限,而且完全開放原始碼,並提供自訂顏色。
這程式只是一系列眾多應用程式的其中一項,你可以在這發現更多 http://www.simplemobiletools.com
這程式只是一系列眾多應用程式的其中一項,你可以在這發現更多 https://www.simplemobiletools.com
</string>
<!--

View file

@ -11,6 +11,7 @@
<string name="path_copied">Path copied</string>
<string name="select_audio_file">Please select an audio file</string>
<string name="search_folder">Search folder</string>
<string name="rooted_device_only">This operation works only on rooted devices</string>
<!-- Compression -->
<string name="compress">Compress</string>
@ -48,7 +49,7 @@
Contains no ads or unnecessary permissions. It is fully opensource, provides customizable colors.
This app is just one piece of a bigger series of apps. You can find the rest of them at http://www.simplemobiletools.com
This app is just one piece of a bigger series of apps. You can find the rest of them at https://www.simplemobiletools.com
</string>
<!--