From 61a621fc3c93405914c55f53c6d9bfdfa6f4fb69 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 7 Jan 2017 12:22:25 +0100 Subject: [PATCH] remove the Undo function from folder view --- .../gallery/activities/MainActivity.kt | 54 ++----------------- .../gallery/adapters/DirectoryAdapter.kt | 14 +++-- .../asynctasks/GetDirectoriesAsynctask.kt | 4 +- .../gallery/dialogs/PickAlbumDialog.kt | 3 +- app/src/main/res/layout/activity_main.xml | 24 ++++----- app/src/main/res/values-de/strings.xml | 8 --- app/src/main/res/values-es/strings.xml | 8 --- app/src/main/res/values-fr/strings.xml | 8 --- app/src/main/res/values-it/strings.xml | 8 --- app/src/main/res/values-ja/strings.xml | 8 --- app/src/main/res/values-pt-rPT/strings.xml | 9 +--- app/src/main/res/values-ru/strings.xml | 8 --- app/src/main/res/values-sv/strings.xml | 8 --- app/src/main/res/values-zh-rCN/strings.xml | 8 --- app/src/main/res/values-zh-rTW/strings.xml | 8 --- app/src/main/res/values/strings.xml | 8 --- 16 files changed, 25 insertions(+), 163 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index 836cfd0ea..6449a73fa 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -4,16 +4,13 @@ import android.Manifest import android.app.Activity import android.content.Intent import android.content.pm.PackageManager -import android.graphics.Color import android.net.Uri import android.os.Bundle import android.provider.MediaStore -import android.support.design.widget.Snackbar import android.support.v4.app.ActivityCompat import android.support.v7.widget.GridLayoutManager import android.view.Menu import android.view.MenuItem -import android.view.View import com.google.gson.Gson import com.google.gson.reflect.TypeToken import com.simplemobiletools.commons.extensions.* @@ -39,9 +36,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { private val PICK_MEDIA = 2 private val PICK_WALLPAPER = 3 - private var mSnackbar: Snackbar? = null lateinit var mDirs: ArrayList - lateinit var mToBeDeleted: ArrayList private var mIsPickImageIntent = false private var mIsPickVideoIntent = false @@ -66,7 +61,6 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { mIsThirdPartyIntent = mIsPickImageIntent || mIsPickVideoIntent || mIsGetImageContentIntent || mIsGetVideoContentIntent || mIsGetAnyContentIntent || mIsSetWallpaperIntent - mToBeDeleted = ArrayList() directories_holder.setOnRefreshListener({ getDirectories() }) mDirs = ArrayList() } @@ -98,7 +92,6 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { override fun onPause() { super.onPause() - deleteDirs() storeDirectories() } @@ -143,7 +136,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { gotDirectories(dirs) mIsGettingDirs = true - GetDirectoriesAsynctask(applicationContext, mIsPickVideoIntent || mIsGetVideoContentIntent, mIsPickImageIntent || mIsGetImageContentIntent, mToBeDeleted) { + GetDirectoriesAsynctask(applicationContext, mIsPickVideoIntent || mIsGetVideoContentIntent, mIsPickImageIntent || mIsGetImageContentIntent) { gotDirectories(it) }.execute() } @@ -170,36 +163,9 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { } } - override fun prepareForDeleting(paths: ArrayList) { - toast(R.string.deleting) - mToBeDeleted = paths - val deletedCnt = mToBeDeleted.size - - if (isShowingPermDialog(File(mToBeDeleted[0]))) - return - - notifyDeletion(deletedCnt) - } - - private fun notifyDeletion(cnt: Int) { - val res = resources - val msg = res.getQuantityString(R.plurals.folders_deleted, cnt, cnt) - mSnackbar = Snackbar.make(coordinator_layout, msg, Snackbar.LENGTH_INDEFINITE) - mSnackbar!!.apply { - setAction(res.getString(R.string.undo), undoDeletion) - setActionTextColor(Color.WHITE) - show() - } - } - - private fun deleteDirs() { - if (mToBeDeleted.isEmpty()) - return - - mSnackbar?.dismiss() - + override fun deleteFiles(paths: ArrayList) { val updatedFiles = ArrayList() - for (delPath in mToBeDeleted) { + for (delPath in paths) { val dir = File(delPath) if (dir.exists()) { val files = dir.listFiles() ?: continue @@ -216,7 +182,6 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { } scanFiles(updatedFiles) {} - mToBeDeleted.clear() } private fun deleteItem(file: File) { @@ -233,12 +198,6 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { } } - private val undoDeletion = View.OnClickListener { - mSnackbar!!.dismiss() - mToBeDeleted.clear() - getDirectories() - } - private fun handleZooming() { val layoutManager = directories_grid.layoutManager as GridLayoutManager layoutManager.spanCount = config.dirColumnCnt @@ -350,19 +309,12 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { } directories_grid.adapter = adapter - directories_grid.setOnTouchListener { view, motionEvent -> checkDelete(); false } } override fun refreshItems() { getDirectories() } - fun checkDelete() { - if (mSnackbar?.isShown == true) { - deleteDirs() - } - } - private fun checkWhatsNewDialog() { arrayListOf().apply { add(Release(46, R.string.release_46)) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt index fe3b1ecc1..b266165ed 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -231,11 +231,13 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList(selections.size) val removeDirs = ArrayList(selections.size) @@ -245,11 +247,13 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList { @@ -333,6 +337,6 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList) + fun deleteFiles(paths: ArrayList) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt index 1019786b3..8f991c375 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt @@ -16,7 +16,7 @@ import java.io.File import java.util.* class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, val isPickImage: Boolean, - val mToBeDeleted: List, val callback: (dirs: ArrayList) -> Unit) : AsyncTask>() { + val callback: (dirs: ArrayList) -> Unit) : AsyncTask>() { lateinit var mConfig: Config override fun onPreExecute() { @@ -80,7 +80,7 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va val newImageCnt = directory.mediaCnt + 1 directory.mediaCnt = newImageCnt directory.addSize(size) - } else if (!mToBeDeleted.contains(parentDir)) { + } else { var dirName = context.getHumanizedFilename(parentDir) if (mConfig.getIsFolderHidden(parentDir)) { dirName += " ${context.resources.getString(R.string.hidden)}" diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickAlbumDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickAlbumDialog.kt index 503cd32ce..bd8bd8a01 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickAlbumDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickAlbumDialog.kt @@ -12,7 +12,6 @@ import com.simplemobiletools.gallery.adapters.DirectoryAdapter import com.simplemobiletools.gallery.asynctasks.GetDirectoriesAsynctask import com.simplemobiletools.gallery.helpers.Config import kotlinx.android.synthetic.main.dialog_album_picker.view.* -import java.util.* class PickAlbumDialog(val activity: SimpleActivity, val callback: (path: String) -> Unit) { var directoriesGrid: RecyclerView @@ -28,7 +27,7 @@ class PickAlbumDialog(val activity: SimpleActivity, val callback: (path: String) .create().apply { activity.setupDialogStuff(view, this, R.string.select_destination) - GetDirectoriesAsynctask(activity, false, false, ArrayList()) { + GetDirectoriesAsynctask(activity, false, false) { val adapter = DirectoryAdapter(activity, it, null) { callback.invoke(it.path) dismiss() diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index cf32a3fb7..35d03f92c 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,23 +1,17 @@ - - + android:layout_height="wrap_content" + android:scrollbars="vertical" + app:layoutManager="android.support.v7.widget.GridLayoutManager" + app:spanCount="@integer/directory_columns"/> - - - - + diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index cdc6cc308..3de16bb4c 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -4,10 +4,7 @@ Galerie Teilen via Ohne Zugriff auf deinen Speicher gibt es hier nicht viel zu tun - Lösche Bearbeiten - Rückgängig - Datei gelöscht Kamera öffnen Ein unbekannter Fehler ist aufgetreten Öffnen mit @@ -24,11 +21,6 @@ wechsle zu Ordner Ansicht Other folder - - 1 Ordner gelöscht - %1$d Ordner gelöscht - - Resize Resize selection and save diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 7832aec23..48f0e30ca 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -4,10 +4,7 @@ Gallery Compartir vía No hay mucho que hacer en una galería sin acceso al almacenamiento - Eliminando Edit - Deshacer - Archivo eliminado Abrir cámara Ocurrió un error desconocido Abrir con… @@ -24,11 +21,6 @@ Switch to folder view Other folder - - 1 carpeta eliminada - %1$d carpetas eliminadas - - Resize Resize selection and save diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 8060dd5e6..6cc25b938 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -4,10 +4,7 @@ Galerie Partager via Peu de choses à faire dans l\'album sans accès à la mémoire - Suppression Édition - Annuler - Fichier supprimé Ouvrir caméra Une erreur inconnue est survenue. Ouvrir avec @@ -24,11 +21,6 @@ Permuter vers la vue du dossier Autre dossier - - 1 dossier supprimé - %1$d dossiers supprimés - - Redimensionner Redimensionner la sélection et enregistrer diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 198afe398..93d2c9ccd 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -4,10 +4,7 @@ Galleria Condividi via Non c\'è molto da fare in una galleria senza l\'accesso all\'archiviazione - Eliminazione Modifica - Annulla - File eliminato Apri fotocamera Riscontrato un errore sconosciuto Apri con @@ -24,11 +21,6 @@ Switch to folder view Other folder - - 1 cartella eliminata - %1$d cartelle eliminate - - Resize Resize selection and save diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 6cfd57731..8bf95beb2 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -4,10 +4,7 @@ ギャラリー 共有… ストレージにアクセスしないとギャラリーでできることはほとんどありません - 削除中 編集 - 元に戻す - ファイルを削除しました カメラを開く 不明なエラーが発生しました …で開く @@ -24,11 +21,6 @@ Switch to folder view Other folder - - 1 フォルダーを削除しました - %1$d フォルダーを削除しました - - Resize Resize selection and save diff --git a/app/src/main/res/values-pt-rPT/strings.xml b/app/src/main/res/values-pt-rPT/strings.xml index c362f38e5..d7a91ef14 100644 --- a/app/src/main/res/values-pt-rPT/strings.xml +++ b/app/src/main/res/values-pt-rPT/strings.xml @@ -1,12 +1,10 @@ + Simple Gallery Galeria Partilhar via É necessário o acesso ao armazenamento para a galeria ter utilidade - A apagar Editar - Desfazer - Ficheiro apagado Abrir câmara Ocorreu um erro desconhecido Abrir com @@ -23,11 +21,6 @@ Alternar para a vista de pastas Outra pasta - - 1 pasta apagada - %1$d pastas apagadas - - Redimensionar Redimensionar seleção e guardar diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index ca265f6a9..7edbf5f6d 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -4,10 +4,7 @@ Галерея Отправить по Не предоставлено разрешение для доступа к файловой системе - Удаление Редактировать - Отменить - Файл удален Открыть камеру Произошла неизвестная ошибка Открыть в @@ -24,11 +21,6 @@ Переключиться к виду с папками Другая папка - - 1 папка удалена - Папок удалено: %1$d - - Изменить размер Изменить выбранное и сохранить diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 890877a74..74fd2e9e8 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -4,10 +4,7 @@ Gallery Dela via Inte mycket att göra i ett galleri om jag inte kommer åt lagringsutrymmet - Tar bort Edit - Ångra - Fil borttagen Starta kameran Ett okänt fel har uppstått Open with @@ -24,11 +21,6 @@ Switch to folder view Другая папка - - 1 mapp borttagen - %1$d mappar borttagna - - Resize Resize selection and save diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index b48598537..8b1e3d6dc 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -4,10 +4,7 @@ 相册 分享到 需要访问储存权限 - 删除中 编辑 - 撤销 - 文件删除成功 打开相机 未知错误 打开方式 @@ -24,11 +21,6 @@ 切换到文件夹视图 其他文件夹 - - 已删除 1 个文件夹 - 已删除 %1$d 个文件夹 - - 缩放 缩放选定区域并保存 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 83f751d16..3136f3ef3 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -4,10 +4,7 @@ 藝廊 分享到 一個沒有權限存取您的儲存空間的藝廊能做的事情寥寥無幾 - 正在刪除 編輯 - 復原 - 檔案成功刪除 開啟相機 未知錯誤 以其他應用軟體開啟 @@ -24,11 +21,6 @@ 切換到資料夾檢視 其他資料夾 - - 刪除 1 個資料夾 - 刪除 %1$d 個資料夾 - - 縮放 縮放選區並儲存 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1b490e1b3..279dc576b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -4,10 +4,7 @@ Gallery Share via Not much to do in a gallery without accessing your storage - Deleting Edit - Undo - File deleted Open camera An unknown error occurred Open with @@ -24,11 +21,6 @@ Switch to folder view Other folder - - 1 folder deleted - %1$d folders deleted - - Resize Resize selection and save