Merge pull request #2401 from KryptKode/fix/editor-sdk30+

SDK 30+ changes for Editor
This commit is contained in:
Tibor Kaputa 2022-04-10 11:42:06 +02:00 committed by GitHub
commit c3a71b8102
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
40 changed files with 45 additions and 44 deletions

View file

@ -77,7 +77,7 @@ android {
}
dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:38f1c0331c'
implementation 'com.github.SimpleMobileTools:Simple-Commons:69ac8d3f2f'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
implementation 'it.sephiroth.android.exif:library:1.0.1'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.24'

View file

@ -28,6 +28,7 @@ import com.bumptech.glide.request.target.Target
import com.simplemobiletools.commons.dialogs.ColorPickerDialog
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
import com.simplemobiletools.commons.helpers.REAL_FILE_PATH
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.commons.helpers.isNougatPlus
@ -101,7 +102,13 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
return
}
initEditActivity()
handlePermission(PERMISSION_WRITE_STORAGE){
if (!it) {
toast(R.string.no_storage_permissions)
finish()
}
initEditActivity()
}
}
override fun onResume() {

View file

@ -112,7 +112,7 @@ class PickDirectoryDialog(
activity.toast(R.string.source_and_destination_same)
return@DirectoryAdapter
} else if (isRPlus() && path.isBasePath(activity)) {
activity.toast(R.string.copy_to_restricted_folder_message)
activity.toast(R.string.system_folder_restriction)
return@DirectoryAdapter
} else {
activity.handleLockedFolderOpening(path) { success ->

View file

@ -5,7 +5,9 @@ import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
import com.simplemobiletools.commons.dialogs.FilePickerDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.isRPlus
import com.simplemobiletools.gallery.pro.R
import java.io.File
import kotlinx.android.synthetic.main.dialog_save_as.view.*
class SaveAsDialog(
@ -15,6 +17,9 @@ class SaveAsDialog(
init {
var realPath = path.getParentPath()
if (activity.isRestrictedWithSAFSdk30(realPath) && !activity.isInDownloadDir(realPath)) {
realPath = activity.getPicturesDirectoryPath(realPath)
}
val view = activity.layoutInflater.inflate(R.layout.dialog_save_as, null).apply {
save_as_path.text = "${activity.humanizePath(realPath).trimEnd('/')}/"
@ -74,15 +79,36 @@ class SaveAsDialog(
if (activity.getDoesFilePathExist(newPath)) {
val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFilename)
ConfirmationDialog(activity, title) {
callback(newPath)
dismiss()
val newFile = File(newPath)
val isInDownloadDir = activity.isInDownloadDir(newPath)
val isInSubFolderInDownloadDir = activity.isInSubFolderInDownloadDir(newPath)
if (isRPlus() && isInDownloadDir && !isInSubFolderInDownloadDir && !newFile.canWrite()) {
val fileDirItem = arrayListOf(File(newPath).toFileDirItem(activity))
val fileUris = activity.getFileUrisFromFileDirItems(fileDirItem).second
activity.updateSDK30Uris(fileUris) { success ->
if (success) {
selectPath(this, newPath)
}
}
} else {
selectPath(this, newPath)
}
}
} else {
callback(newPath)
dismiss()
selectPath(this, newPath)
}
}
}
}
}
private fun selectPath(alertDialog: AlertDialog, newPath: String) {
activity.handleSAFDialogSdk30(newPath) {
if (!it) {
return@handleSAFDialogSdk30
}
callback(newPath)
alertDialog.dismiss()
}
}
}

View file

@ -39,7 +39,6 @@
<string name="set_as_default_folder">تعيين كمجلد افتراضي</string>
<string name="unset_as_default_folder">إلغاء التعيين كمجلد افتراضي</string>
<string name="reorder_by_dragging">إعادة ترتيب المجلدات عن طريق السحب</string>
<string name="copy_to_restricted_folder_message">The system does not allow copying to this folder.</string>
<!-- Filter -->
<string name="filter_media">فلترة الوسائط</string>

View file

@ -33,7 +33,6 @@
<string name="set_as_default_folder">Set as default folder</string>
<string name="unset_as_default_folder">Unset as default folder</string>
<string name="reorder_by_dragging">Reorder folders by dragging</string>
<string name="copy_to_restricted_folder_message">The system does not allow copying to this folder.</string>
<!-- Filter -->
<string name="filter_media">Filter media</string>

View file

@ -33,7 +33,6 @@
<string name="set_as_default_folder">ডিফল্ট ফোল্ডার হিশেবে সেট করুন</string>
<string name="unset_as_default_folder">ডিফল্ট ফোল্ডার হিশেবে আর রাখবেন না</string>
<string name="reorder_by_dragging">Reorder folders by dragging</string>
<string name="copy_to_restricted_folder_message">The system does not allow copying to this folder.</string>
<!-- Filter -->
<string name="filter_media">মিডিয়া ফিল্টার করুন</string>

View file

@ -33,7 +33,6 @@
<string name="set_as_default_folder">Set as default folder</string>
<string name="unset_as_default_folder">Unset as default folder</string>
<string name="reorder_by_dragging">Reorder folders by dragging</string>
<string name="copy_to_restricted_folder_message">The system does not allow copying to this folder.</string>
<!-- Filter -->
<string name="filter_media">Filtr médií</string>

View file

@ -33,7 +33,6 @@
<string name="set_as_default_folder">Vælg som standardmappe</string>
<string name="unset_as_default_folder">Fravælg som standardmappe</string>
<string name="reorder_by_dragging">Omorganiser mapper ved at trække</string>
<string name="copy_to_restricted_folder_message">The system does not allow copying to this folder.</string>
<!-- Filter -->
<string name="filter_media">Filtrer medier</string>

View file

@ -39,7 +39,6 @@
<string name="set_as_default_folder">Als Standardordner festlegen</string>
<string name="unset_as_default_folder">Nicht mehr als Standardordner festlegen</string>
<string name="reorder_by_dragging">Neuordnung von Ordnern durch Ziehen</string>
<string name="copy_to_restricted_folder_message">Das System lässt das Kopieren in diesen Ordner nicht zu.</string>
<!-- Filter -->
<string name="filter_media">Medien filtern</string>
<string name="images">Bilder</string>

View file

@ -33,7 +33,6 @@
<string name="set_as_default_folder">Set as default folder</string>
<string name="unset_as_default_folder">Unset as default folder</string>
<string name="reorder_by_dragging">Reorder folders by dragging</string>
<string name="copy_to_restricted_folder_message">The system does not allow copying to this folder.</string>
<!-- Filter -->
<string name="filter_media">Filter media</string>
<string name="images">Bildoj</string>

View file

@ -33,7 +33,6 @@
<string name="set_as_default_folder">Poner como carpeta predeterminada</string>
<string name="unset_as_default_folder">Quitar como carpeta predeterminada</string>
<string name="reorder_by_dragging">Reordenar carpetas arrastrándolas</string>
<string name="copy_to_restricted_folder_message">The system does not allow copying to this folder.</string>
<!-- Filter -->
<string name="filter_media">Filtro de medios</string>

View file

@ -33,7 +33,6 @@
<string name="set_as_default_folder">Set as default folder</string>
<string name="unset_as_default_folder">Unset as default folder</string>
<string name="reorder_by_dragging">Reorder folders by dragging</string>
<string name="copy_to_restricted_folder_message">The system does not allow copying to this folder.</string>
<!-- Filter -->
<string name="filter_media">Filter media</string>

View file

@ -33,7 +33,6 @@
<string name="set_as_default_folder">Ezarri lehenetsitako karpeta gisa</string>
<string name="unset_as_default_folder">Kendu karpeta lehenetsitako karpeta gisa</string>
<string name="reorder_by_dragging">Berrordenatu karpetak arrastatuz</string>
<string name="copy_to_restricted_folder_message">The system does not allow copying to this folder.</string>
<!-- Filter -->
<string name="filter_media">Iragazi multimedia</string>

View file

@ -33,7 +33,6 @@
<string name="set_as_default_folder">تنظیم به عنوان شاخهٔ پیش‌گزیده</string>
<string name="unset_as_default_folder">برداشتن تنظیم به عنوان شاخهٔ پیش‌گزیده</string>
<string name="reorder_by_dragging">مرتب‌سازی مجدد شاخه‌ها با کشیدن</string>
<string name="copy_to_restricted_folder_message">The system does not allow copying to this folder.</string>
<!-- Filter -->
<string name="filter_media">پالایش رسانه</string>

View file

@ -39,7 +39,6 @@
<string name="set_as_default_folder">Aseta oletushakemistoksi</string>
<string name="unset_as_default_folder">Älä käytä oletushakemistona</string>
<string name="reorder_by_dragging">Järjestä kansiot uudelleen vetämällä</string>
<string name="copy_to_restricted_folder_message">The system does not allow copying to this folder.</string>
<!-- Filter -->
<string name="filter_media">Suodata media</string>

View file

@ -33,7 +33,6 @@
<string name="set_as_default_folder">Dossier par défaut</string>
<string name="unset_as_default_folder">Oublier le dossier</string>
<string name="reorder_by_dragging">Réordonner par glisser</string>
<string name="copy_to_restricted_folder_message">Le système ne permet pas de copier dans ce dossier.</string>
<!-- Filter -->
<string name="filter_media">Filtrer les médias</string>
<string name="images">Images</string>

View file

@ -33,7 +33,6 @@
<string name="set_as_default_folder">Set as default folder</string>
<string name="unset_as_default_folder">Unset as default folder</string>
<string name="reorder_by_dragging">Reorder folders by dragging</string>
<string name="copy_to_restricted_folder_message">The system does not allow copying to this folder.</string>
<!-- Filter -->
<string name="filter_media">Filtrar medios</string>
<string name="images">Imaxes</string>

View file

@ -33,7 +33,6 @@
<string name="set_as_default_folder">Set as default folder</string>
<string name="unset_as_default_folder">Unset as default folder</string>
<string name="reorder_by_dragging">Reorder folders by dragging</string>
<string name="copy_to_restricted_folder_message">The system does not allow copying to this folder.</string>
<!-- Filter -->
<string name="filter_media">Filtriranje medija</string>
<string name="images">Slike</string>

View file

@ -39,7 +39,6 @@
<string name="set_as_default_folder">Beállítás alapértelmezett mappaként</string>
<string name="unset_as_default_folder">Eltávolítás mint alapértelmezett mappa</string>
<string name="reorder_by_dragging">Mappák átrendezése húzással</string>
<string name="copy_to_restricted_folder_message">The system does not allow copying to this folder.</string>
<!-- Filter -->
<string name="filter_media">Médiafájlok szűrése</string>

View file

@ -33,7 +33,6 @@
<string name="set_as_default_folder">Set as default folder</string>
<string name="unset_as_default_folder">Unset as default folder</string>
<string name="reorder_by_dragging">Reorder folders by dragging</string>
<string name="copy_to_restricted_folder_message">The system does not allow copying to this folder.</string>
<!-- Filter -->
<string name="filter_media">Filter media</string>

View file

@ -33,7 +33,6 @@
<string name="set_as_default_folder">Imposta come cartella predefinita</string>
<string name="unset_as_default_folder">Non impostare come cartella predefinita</string>
<string name="reorder_by_dragging">Riordina cartelle trascinandole</string>
<string name="copy_to_restricted_folder_message">Il sistema non permette di copiare in questa cartella.</string>
<!-- Filter -->
<string name="filter_media">Filtra i file</string>
<string name="images">Immagini</string>

View file

@ -33,7 +33,6 @@
<string name="set_as_default_folder">デフォルトのフォルダとして設定</string>
<string name="unset_as_default_folder">デフォルトのフォルダから外す</string>
<string name="reorder_by_dragging">Reorder folders by dragging</string>
<string name="copy_to_restricted_folder_message">The system does not allow copying to this folder.</string>
<!-- Filter -->
<string name="filter_media">表示する形式</string>

View file

@ -33,7 +33,6 @@
<string name="set_as_default_folder">Set as default folder</string>
<string name="unset_as_default_folder">Unset as default folder</string>
<string name="reorder_by_dragging">Reorder folders by dragging</string>
<string name="copy_to_restricted_folder_message">The system does not allow copying to this folder.</string>
<!-- Filter -->
<string name="filter_media">필터 설정</string>

View file

@ -33,7 +33,6 @@
<string name="set_as_default_folder">Set as default folder</string>
<string name="unset_as_default_folder">Unset as default folder</string>
<string name="reorder_by_dragging">Reorder folders by dragging</string>
<string name="copy_to_restricted_folder_message">The system does not allow copying to this folder.</string>
<!-- Filter -->
<string name="filter_media">Filtruoti mediją</string>

View file

@ -33,7 +33,6 @@
<string name="set_as_default_folder">Sett som standardmappe</string>
<string name="unset_as_default_folder">Ikke lenger sett som standardmappe</string>
<string name="reorder_by_dragging">Endre mapperekkefølge ved å dra</string>
<string name="copy_to_restricted_folder_message">The system does not allow copying to this folder.</string>
<!-- Filter -->
<string name="filter_media">Filtrer media</string>

View file

@ -33,7 +33,6 @@
<string name="set_as_default_folder">Set as default folder</string>
<string name="unset_as_default_folder">Unset as default folder</string>
<string name="reorder_by_dragging">Reorder folders by dragging</string>
<string name="copy_to_restricted_folder_message">The system does not allow copying to this folder.</string>
<!-- Filter -->
<string name="filter_media">Filter media</string>

View file

@ -39,7 +39,6 @@
<string name="set_as_default_folder">Definir como pasta padrão</string>
<string name="unset_as_default_folder">Indefinir como pasta padrão</string>
<string name="reorder_by_dragging">Reordenar as pastas ao arrastar</string>
<string name="copy_to_restricted_folder_message">The system does not allow copying to this folder.</string>
<!-- Filter -->
<string name="filter_media">Filtrar mídia</string>

View file

@ -39,7 +39,6 @@
<string name="set_as_default_folder">Utilizar como pasta padrão</string>
<string name="unset_as_default_folder">Deixar de utilizar como pasta padrão</string>
<string name="reorder_by_dragging">Organizar pasta por arrasto</string>
<string name="copy_to_restricted_folder_message">The system does not allow copying to this folder.</string>
<!-- Filter -->
<string name="filter_media">Filtrar multimédia</string>

View file

@ -33,7 +33,6 @@
<string name="set_as_default_folder">Setază ca dosar implicit</string>
<string name="unset_as_default_folder">Dezactivează ca dosar implicit</string>
<string name="reorder_by_dragging">Reordonează dosarele prin tragere</string>
<string name="copy_to_restricted_folder_message">Sistemul nu permite copierea în acest dosar.</string>
<!-- Filter -->
<string name="filter_media">Filtrează elementele media</string>
<string name="images">Imagini</string>

View file

@ -33,7 +33,6 @@
<string name="set_as_default_folder">Set as default folder</string>
<string name="unset_as_default_folder">Unset as default folder</string>
<string name="reorder_by_dragging">Reorder folders by dragging</string>
<string name="copy_to_restricted_folder_message">The system does not allow copying to this folder.</string>
<!-- Filter -->
<string name="filter_media">Filtriranje datotek</string>

View file

@ -33,7 +33,6 @@
<string name="set_as_default_folder">Set as default folder</string>
<string name="unset_as_default_folder">Unset as default folder</string>
<string name="reorder_by_dragging">Reorder folders by dragging</string>
<string name="copy_to_restricted_folder_message">The system does not allow copying to this folder.</string>
<!-- Filter -->
<string name="filter_media">Филтрирај медију</string>

View file

@ -33,7 +33,6 @@
<string name="set_as_default_folder">Set as default folder</string>
<string name="unset_as_default_folder">Unset as default folder</string>
<string name="reorder_by_dragging">Reorder folders by dragging</string>
<string name="copy_to_restricted_folder_message">The system does not allow copying to this folder.</string>
<!-- Filter -->
<string name="filter_media">Filtrera media</string>
<string name="images">Bilder</string>

View file

@ -39,7 +39,6 @@
<string name="set_as_default_folder">இயல்புநிலை அடைவாக அமை</string>
<string name="unset_as_default_folder">இயல்புநிலை அடைவாக அமைக்காதே</string>
<string name="reorder_by_dragging">பிடித்திழுத்து அடைவுகளை மறுசீரமை</string>
<string name="copy_to_restricted_folder_message">The system does not allow copying to this folder.</string>
<!-- Filter -->
<string name="filter_media">ஊடகத்தை வடிகட்டு</string>
<string name="images">படங்கள்</string>

View file

@ -33,7 +33,6 @@
<string name="set_as_default_folder">Встановити теку за замовчуванням</string>
<string name="unset_as_default_folder">Відмінити встановлення теки за замовчуванням</string>
<string name="reorder_by_dragging">Сортувати папки шляхом переміщення</string>
<string name="copy_to_restricted_folder_message">The system does not allow copying to this folder.</string>
<!-- Filter -->
<string name="filter_media">Фільтр мультимедійних файлів</string>

View file

@ -33,7 +33,6 @@
<string name="set_as_default_folder">Set as default folder</string>
<string name="unset_as_default_folder">Unset as default folder</string>
<string name="reorder_by_dragging">Reorder folders by dragging</string>
<string name="copy_to_restricted_folder_message">The system does not allow copying to this folder.</string>
<!-- Filter -->
<string name="filter_media">Lọc</string>

View file

@ -33,7 +33,6 @@
<string name="set_as_default_folder">Set as default folder</string>
<string name="unset_as_default_folder">Unset as default folder</string>
<string name="reorder_by_dragging">Reorder folders by dragging</string>
<string name="copy_to_restricted_folder_message">The system does not allow copying to this folder.</string>
<!-- Filter -->
<string name="filter_media">篩選媒體檔案</string>

View file

@ -33,7 +33,6 @@
<string name="set_as_default_folder">Set as default folder</string>
<string name="unset_as_default_folder">Unset as default folder</string>
<string name="reorder_by_dragging">Reorder folders by dragging</string>
<string name="copy_to_restricted_folder_message">The system does not allow copying to this folder.</string>
<!-- Filter -->
<string name="filter_media">Filter media</string>

View file

@ -13,6 +13,7 @@ import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
import com.simplemobiletools.commons.helpers.REAL_FILE_PATH
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.commons.helpers.isNougatPlus
import com.simplemobiletools.commons.helpers.isRPlus
import com.simplemobiletools.commons.models.FileDirItem
import com.simplemobiletools.gallery.pro.R
import com.simplemobiletools.gallery.pro.dialogs.SaveAsDialog
@ -207,7 +208,7 @@ class NewPhotoEditActivity : SimpleActivity() {
// In case the user wants to overwrite the original file and it is on an SD card, delete it manually first. Else the system just appends (1)
private fun handleFileOverwriting(path: String, callback: () -> Unit) {
if (getDoesFilePathExist(path) && isPathOnSD(path)) {
if (!isRPlus() && getDoesFilePathExist(path) && isPathOnSD(path)) {
val fileDirItem = FileDirItem(path, path.getFilenameFromPath())
tryDeleteFileDirItem(fileDirItem, false, true) { success ->
if (success) {

View file

@ -13,6 +13,7 @@ import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
import com.simplemobiletools.commons.helpers.REAL_FILE_PATH
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.commons.helpers.isNougatPlus
import com.simplemobiletools.commons.helpers.isRPlus
import com.simplemobiletools.commons.models.FileDirItem
import com.simplemobiletools.gallery.pro.R
import com.simplemobiletools.gallery.pro.dialogs.SaveAsDialog
@ -198,7 +199,7 @@ class NewVideoEditActivity : SimpleActivity() {
// In case the user wants to overwrite the original file and it is on an SD card, delete it manually first. Else the system just appends (1)
private fun handleFileOverwriting(path: String, callback: () -> Unit) {
if (getDoesFilePathExist(path) && isPathOnSD(path)) {
if (!isRPlus() && getDoesFilePathExist(path) && isPathOnSD(path)) {
val fileDirItem = FileDirItem(path, path.getFilenameFromPath())
tryDeleteFileDirItem(fileDirItem, false, true) { success ->
if (success) {