From 78407c445707e0bf07e81a2eeca79965bc648fd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Sch=C3=A4ferdiek?= Date: Sat, 9 Sep 2017 14:09:23 +0200 Subject: [PATCH 01/89] update german translations --- app/src/main/res/values-de/strings.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 6815e2f67..fbfa8bf60 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -19,7 +19,7 @@ Keine Kamera-App gefunden Kacheln verkleinern Kacheln vergrößern - Cover-Bild ändern + Coverbild ändern Auswählen Standard Festlegen als @@ -27,12 +27,12 @@ Helligkeit - Filter media + Medienfilter Images Videos GIFs - No media files have been found with the selected filters. - Change filters + Keine Medien für die ausgewählten Filter gefunden + Filter wechseln Diese Funktion versteckt ausgewählte Ordner (auch für andere Apps), indem dort im Dateisystem eine \'.nomedia\'-Datei abgelegt wird. Dadurch werden auch deren Unterordner versteckt. Solche Ordner werden nur gezeigt, wenn die Einstellung \'Versteckte Ordner zeigen\' aktiv ist (auch andere Apps bieten üblicherweise eine solche Option). Fortfahren? @@ -98,7 +98,7 @@ Zufällige Reihenfolge Übergänge animieren Rückwärts abspielen - Loop slideshow + Slideshow in Endlosschleife Diashow beendet Keine Medien für Diashow gefunden @@ -117,8 +117,8 @@ Schwarzer Hintergrund im Vollbild Kacheln horizontal scrollen Systemleisten ausblenden im Vollbild - Delete empty folders after deleting their content - Allow controlling video volume and brightness with vertical gestures + Lösche leere Ordner nachdem ihr Inhalt gelöscht wurde + Erlaube die Kontrolle von Videolautstärke und Helligkeit über vertikale Gesten Teilen/Drehen im Vollbild-Menü vertauschen From 98aa0ae9a7e12c1e0ff99b6141298c9afd3f1dfc Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 9 Sep 2017 14:36:58 +0200 Subject: [PATCH 02/89] updating some german strings --- app/src/main/res/values-de/strings.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 6815e2f67..2cfddfe01 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -28,11 +28,11 @@ Filter media - Images + Bilder Videos GIFs - No media files have been found with the selected filters. - Change filters + Keine entsprechenden Medien gefunden. + Filter ändern Diese Funktion versteckt ausgewählte Ordner (auch für andere Apps), indem dort im Dateisystem eine \'.nomedia\'-Datei abgelegt wird. Dadurch werden auch deren Unterordner versteckt. Solche Ordner werden nur gezeigt, wenn die Einstellung \'Versteckte Ordner zeigen\' aktiv ist (auch andere Apps bieten üblicherweise eine solche Option). Fortfahren? @@ -94,11 +94,11 @@ Intervall (Sekunden): Bilder verwenden Videos verwenden - GIF verwenden + GIFs verwenden Zufällige Reihenfolge Übergänge animieren Rückwärts abspielen - Loop slideshow + Endlos abspielen Diashow beendet Keine Medien für Diashow gefunden @@ -117,8 +117,8 @@ Schwarzer Hintergrund im Vollbild Kacheln horizontal scrollen Systemleisten ausblenden im Vollbild - Delete empty folders after deleting their content - Allow controlling video volume and brightness with vertical gestures + Nach Löschen leere Ordner löschen + Gesten für Video-Lautstärke/Helligkeit Teilen/Drehen im Vollbild-Menü vertauschen From a10b3ecdc6996db031ca597e9c422cec09a8da1e Mon Sep 17 00:00:00 2001 From: en2sv Date: Sun, 10 Sep 2017 10:28:53 +0200 Subject: [PATCH 03/89] Update Swedish translation --- app/src/main/res/values-sv/strings.xml | 50 +++++++++++++------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 6442a31fe..aa1fea2ec 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -23,16 +23,16 @@ Välj foto Använd standard Ange som - Volume - Brightness + Volym + Ljusstyrka - Filter media - Images - Videos - GIFs - No media files have been found with the selected filters. - Change filters + Filtrera media + Bilder + Videor + GIF-bilder + Inga mediefiler hittades med valda filter. + Ändra filter Denna funktion döljer mappen och alla dess undermappar genom att lägga till en \'.nomedia\'-fil i den. Du kan se dem genom att växla \'Visa dolda mappar\'-alternativet i Inställningar. Vill du fortsätta? @@ -49,7 +49,7 @@ Inkluderade mappar Hantera inkluderade mappar Lägg till mapp - Om du har vissa mappar som innehåller media men som inte känns igen av appen kan du lägga till dem manuellt här. + Om du har vissa mappar som innehåller media men som inte känns igen av appen, kan du lägga till dem manuellt här. Ändra storlek @@ -90,17 +90,17 @@ Liggande bildförhållande - Slideshow - Interval (seconds): - Include photos - Include videos - Include GIFs - Random order - Use fade animations - Move backwards - Loop slideshow - The slideshow ended - No media for the slideshow have been found + Bildspel + Intervall (sekunder): + Inkludera foton + Inkludera videor + Inkludera GIF-bilder + Spela upp i slumpmässig ordning + Använd toningsanimationer + Spela upp i omvänd ordning + Spela upp i en slinga + Bildspelet har avslutats + Ingen media hittades för bildspelet Visa dolda mappar @@ -117,17 +117,17 @@ Mörk bakgrund när media visas i helskärmsläge Rulla horisontellt genom miniatyrer Dölj systemanvändargränssnittet automatiskt när media visas i helskärmsläge - Delete empty folders after deleting their content - Allow controlling video volume and brightness with vertical gestures - Replace Share with Rotate at fullscreen menu + Ta bort tomma mappar när deras innehåll tas bort + Tillåt styrning av videovolym och videoljusstyrka med vertikala gester + Ersätt Dela med Rotera i helskärmsmenyn Ett Galleri för att visa bilder och videos utan en massa reklam. - Ett enkelt verktyg för att visa bilder och vdeos. Objekten kan sorteras efter datum, storlek, namn både stigande och fallande, bilder kan zoomas in. Mediafiler visas i flera kolumner beroende av skärmens storlek, du kan ändra antalet kolumner genom en nyp-rörelse. De går att döpa om, dela, ta bort, kopiera, flytta. Bilder kan också beskäras, roteras och anges som bakgrundsbild direkt från appen. + Ett enkelt verktyg för att visa bilder och videos. Objekten kan sorteras efter datum, storlek, namn både stigande och fallande, bilder kan zoomas in. Mediafiler visas i flera kolumner beroende av skärmens storlek, du kan ändra antalet kolumner genom en nyp-rörelse. De går att döpa om, dela, ta bort, kopiera, flytta. Bilder kan också beskäras, roteras och anges som bakgrundsbild direkt från appen. - Galleriet kan också användas av tredjeparts för förhandsgranskning av bilder / videos, bifoga bilagor i e-postklienter etc. Den är perfekt för det dagliga användandet. + Galleriet kan också användas av tredjepartsappar för förhandsgranskning av bilder / videos, bifoga bilagor i e-postklienter etc. Den är perfekt för det dagliga användandet. Innehåller ingen reklam eller onödiga behörigheter. Det är helt och hållet opensource, innehåller anpassningsbara färger. From 5273ea431bea76ad78ea0217426edfd7a853a062 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 10 Sep 2017 18:57:04 +0200 Subject: [PATCH 04/89] show an error toast if something breaks during loading the image --- .../com/simplemobiletools/gallery/fragments/PhotoFragment.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt index 8a1f24ffc..c722958f3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt @@ -26,8 +26,10 @@ import com.davemorrissey.labs.subscaleview.ImageSource import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView import com.simplemobiletools.commons.extensions.beGone import com.simplemobiletools.commons.extensions.beVisible +import com.simplemobiletools.commons.extensions.showErrorToast import com.simplemobiletools.commons.extensions.toast import com.simplemobiletools.gallery.R +import com.simplemobiletools.gallery.activities.SimpleActivity import com.simplemobiletools.gallery.activities.ViewPagerActivity import com.simplemobiletools.gallery.extensions.config import com.simplemobiletools.gallery.extensions.getFileSignature @@ -221,9 +223,10 @@ class PhotoFragment : ViewPagerFragment() { override fun onPreviewReleased() { } - override fun onImageLoadError(e: Exception?) { + override fun onImageLoadError(e: Exception) { background = ColorDrawable(Color.TRANSPARENT) beGone() + (activity as SimpleActivity).showErrorToast(e) } override fun onPreviewLoadError(e: Exception?) { From 9e809adf10d83f79a039b923541f17dbd83d2f75 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 10 Sep 2017 19:19:06 +0200 Subject: [PATCH 05/89] update commons to 2.27.10 --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index a4500bd24..bd165fa86 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -37,7 +37,7 @@ android { } dependencies { - compile 'com.simplemobiletools:commons:2.27.9' + compile 'com.simplemobiletools:commons:2.27.10' compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0' compile 'com.theartofdev.edmodo:android-image-cropper:2.4.0' compile 'com.bignerdranch.android:recyclerview-multiselect:0.2' From 316566b09c5818ffbde533fa43178d32a6e21c90 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 10 Sep 2017 19:59:37 +0200 Subject: [PATCH 06/89] clear media on destroy at third party intents --- .../simplemobiletools/gallery/activities/ViewPagerActivity.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index fb809047b..6e300077d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -160,6 +160,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } if (config.isThirdPartyIntent) { + mMedia.clear() config.isThirdPartyIntent = false } } From 832d549fedd59787353f9dbcf11d9e09e596ce58 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 10 Sep 2017 21:50:58 +0200 Subject: [PATCH 07/89] remove the manual setting of max tilesize to 10000 --- .../com/simplemobiletools/gallery/fragments/PhotoFragment.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt index c722958f3..d7aca9dbf 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt @@ -203,7 +203,6 @@ class PhotoFragment : ViewPagerFragment() { if ((medium.isImage()) && isFragmentVisible && view.subsampling_view.visibility == View.GONE) { view.subsampling_view.apply { setBitmapDecoderClass(GlideDecoder::class.java) - setMaxTileSize(10000) maxScale = 10f beVisible() setImage(ImageSource.uri(medium.path)) From ffcd632bad0b3a5d682ee84d75097d329a02957b Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 11 Sep 2017 21:15:59 +0200 Subject: [PATCH 08/89] small code style update --- .../com/simplemobiletools/gallery/extensions/activity.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt index d66248274..a7fc915a2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt @@ -250,10 +250,10 @@ fun SimpleActivity.removeNoMedia(path: String, callback: () -> Unit) { fun SimpleActivity.toggleFileVisibility(oldFile: File, hide: Boolean, callback: (newFile: File) -> Unit) { val path = oldFile.parent var filename = oldFile.name - if (hide) { - filename = ".${filename.trimStart('.')}" + filename = if (hide) { + ".${filename.trimStart('.')}" } else { - filename = filename.substring(1, filename.length) + filename.substring(1, filename.length) } val newFile = File(path, filename) renameFile(oldFile, newFile) { From 624c0e2d083e780fade5ab541d277589eab03841 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 11 Sep 2017 21:34:15 +0200 Subject: [PATCH 09/89] check the filesize only after checking the file type --- .../gallery/extensions/context.kt | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt index d0d6dcd00..3d0d115b6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt @@ -81,14 +81,6 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP do { try { val path = cur.getStringValue(MediaStore.Images.Media.DATA) - var size = cur.getLongValue(MediaStore.Images.Media.SIZE) - if (size == 0L) { - size = File(path).length() - } - - if (size <= 0L) { - continue - } var filename = cur.getStringValue(MediaStore.Images.Media.DISPLAY_NAME) ?: "" if (filename.isEmpty()) @@ -113,6 +105,15 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP if (!showHidden && filename.startsWith('.')) continue + var size = cur.getLongValue(MediaStore.Images.Media.SIZE) + val file = File(path) + if (size == 0L) { + size = file.length() + } + + if (size <= 0L) + continue + var isExcluded = false excludedFolders.forEach { if (path.startsWith(it)) { @@ -168,11 +169,6 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP private fun getMediaInFolder(folder: String, curMedia: ArrayList, isPickImage: Boolean, isPickVideo: Boolean, filterMedia: Int) { val files = File(folder).listFiles() ?: return for (file in files) { - val size = file.length() - if (size <= 0L) { - continue - } - val filename = file.name val isImage = filename.isImageFast() val isVideo = if (isImage) false else filename.isVideoFast() @@ -190,6 +186,10 @@ private fun getMediaInFolder(folder: String, curMedia: ArrayList, isPick if (isGif && filterMedia and GIFS == 0) continue + val size = file.length() + if (size <= 0L) + continue + val dateTaken = file.lastModified() val dateModified = file.lastModified() From 28ccfb6fe1f49e240345579633b3a12a442bd2e1 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 11 Sep 2017 21:34:23 +0200 Subject: [PATCH 10/89] add a file.exists() check too --- .../kotlin/com/simplemobiletools/gallery/extensions/context.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt index 3d0d115b6..8a0613a58 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt @@ -139,6 +139,9 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP } if (!isExcluded || isThirdPartyIntent) { + if (!file.exists()) + continue + val dateTaken = cur.getLongValue(MediaStore.Images.Media.DATE_TAKEN) val dateModified = cur.getIntValue(MediaStore.Images.Media.DATE_MODIFIED) * 1000L From bc82d940b1d6cda45eaa5ebf775f4e982da280f3 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 11 Sep 2017 22:44:04 +0200 Subject: [PATCH 11/89] update commons to 2.27.11 --- app/build.gradle | 2 +- .../com/simplemobiletools/gallery/activities/MediaActivity.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index bd165fa86..d375e73ea 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -37,7 +37,7 @@ android { } dependencies { - compile 'com.simplemobiletools:commons:2.27.10' + compile 'com.simplemobiletools:commons:2.27.11' compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0' compile 'com.theartofdev.edmodo:android-image-cropper:2.4.0' compile 'com.bignerdranch.android:recyclerview-multiselect:0.2' diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index e5d2d7fc7..6ef9182f7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -309,7 +309,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { mIsGettingMedia = true val token = object : TypeToken>() {}.type - val media = Gson().fromJson>(config.loadFolderMedia(mPath), token) ?: ArrayList(1) + val media = Gson().fromJson>(config.loadFolderMedia(mPath), token) ?: ArrayList(1) if (media.isNotEmpty() && !mLoadedInitialPhotos) { gotMedia(media, true) } else { From 0ba5262f00d54c98cddc4055441fcc73d3d6484a Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 11 Sep 2017 22:47:06 +0200 Subject: [PATCH 12/89] update version to 2.14.2 (130) --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index d375e73ea..5bc9dd503 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "com.simplemobiletools.gallery" minSdkVersion 16 targetSdkVersion 23 - versionCode 129 - versionName "2.14.1" + versionCode 130 + versionName "2.14.2" } signingConfigs { From 17947e369acc2b014e1b3f3f12d6f5bcda43de17 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 11 Sep 2017 22:47:11 +0200 Subject: [PATCH 13/89] updating changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ab949842..595a80b08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ Changelog ========== +Version 2.14.2 *(2017-09-11)* +---------------------------- + + * Fixing some glitches with fullscreen images + * Add an extra check to avoid displaying non-existing media + * Fix opening media from third party intents + Version 2.14.1 *(2017-09-07)* ---------------------------- From 7539bf35529b675f56c5f81dd376a05675b44a95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Marques?= Date: Wed, 13 Sep 2017 21:29:16 +0100 Subject: [PATCH 14/89] Update strings.xml --- app/src/main/res/values-pt/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index 0ac84d7d6..d0869b9c2 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -31,7 +31,7 @@ Imagens Vídeos GIFs - Naõ foram encontrados ficheiros que cumpram os requisitos. + Não foram encontrados ficheiros que cumpram os requisitos. Alterar filtros @@ -98,7 +98,7 @@ Ordem aleatória Usar animações Mover para trás - Loop slideshow + Apresentação em ciclo Apresentação terminada Não foram encontrados ficheiros para a apresentação From 0af594ee0bd44eb2d59a0ab0b2d0723576e8a7e0 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 14 Sep 2017 15:40:33 +0200 Subject: [PATCH 15/89] use glide rotate transformation only when needed --- .../com/simplemobiletools/gallery/helpers/GlideDecoder.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/GlideDecoder.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/GlideDecoder.kt index fe7c7f9e5..08d7002b3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/GlideDecoder.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/GlideDecoder.kt @@ -28,9 +28,12 @@ class GlideDecoder : ImageDecoder { .signature(uri.path.getFileSignature()) .format(DecodeFormat.PREFER_ARGB_8888) .diskCacheStrategy(DiskCacheStrategy.RESOURCE) - .transform(GlideRotateTransformation(context, getRotationDegrees(orientation))) .override(targetWidth, targetHeight) + val degrees = getRotationDegrees(orientation) + if (degrees != 0f) + options.transform(GlideRotateTransformation(context, getRotationDegrees(orientation))) + val drawable = Glide.with(context) .load(uri) .apply(options) From 6f3fd675e23d99de6d963d66682e4d3119f42fff Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 15 Sep 2017 15:48:18 +0200 Subject: [PATCH 16/89] remove some empty spaces --- .../com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt | 2 -- 1 file changed, 2 deletions(-) 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 08e08e439..86fbc9e4e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -405,8 +405,6 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList Date: Fri, 15 Sep 2017 23:22:33 +0200 Subject: [PATCH 17/89] simplify the squareImageView creation --- .../com/simplemobiletools/gallery/views/MySquareImageView.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/views/MySquareImageView.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/views/MySquareImageView.kt index 3e0c79df1..f254d4183 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/views/MySquareImageView.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/views/MySquareImageView.kt @@ -14,8 +14,7 @@ class MySquareImageView : ImageView { constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle) override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { - super.onMeasure(widthMeasureSpec, heightMeasureSpec) - val spec = if (isVerticalScrolling) measuredWidth else measuredHeight - setMeasuredDimension(spec, spec) + val spec = if (isVerticalScrolling) widthMeasureSpec else heightMeasureSpec + super.onMeasure(spec, spec) } } From d09acabdc3f6643fff3721471a0ddf241859024e Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 16 Sep 2017 20:20:25 +0200 Subject: [PATCH 18/89] use match_parent height at directories grid --- app/src/main/res/layout/dialog_directory_picker.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/layout/dialog_directory_picker.xml b/app/src/main/res/layout/dialog_directory_picker.xml index 0a586affb..bc18bfb19 100644 --- a/app/src/main/res/layout/dialog_directory_picker.xml +++ b/app/src/main/res/layout/dialog_directory_picker.xml @@ -10,7 +10,7 @@ From f7e7d83382b92888d21fabbebd3ce3962f2ee67e Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 16 Sep 2017 20:20:43 +0200 Subject: [PATCH 19/89] do not force ARGB_8888 format at fullscreen media --- .../com/simplemobiletools/gallery/helpers/GlideDecoder.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/GlideDecoder.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/GlideDecoder.kt index 08d7002b3..fbddb788b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/GlideDecoder.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/GlideDecoder.kt @@ -8,7 +8,6 @@ import android.graphics.drawable.Drawable import android.media.ExifInterface import android.net.Uri import com.bumptech.glide.Glide -import com.bumptech.glide.load.DecodeFormat import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.request.RequestOptions import com.bumptech.glide.request.target.Target @@ -26,7 +25,6 @@ class GlideDecoder : ImageDecoder { val options = RequestOptions() .signature(uri.path.getFileSignature()) - .format(DecodeFormat.PREFER_ARGB_8888) .diskCacheStrategy(DiskCacheStrategy.RESOURCE) .override(targetWidth, targetHeight) From 9247b5119478f0bafdac48251b27f31cb8a85954 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 16 Sep 2017 20:37:18 +0200 Subject: [PATCH 20/89] lets not toast errors if loading fullscreen media fails --- .../com/simplemobiletools/gallery/fragments/PhotoFragment.kt | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt index d7aca9dbf..c24c09f96 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt @@ -26,10 +26,8 @@ import com.davemorrissey.labs.subscaleview.ImageSource import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView import com.simplemobiletools.commons.extensions.beGone import com.simplemobiletools.commons.extensions.beVisible -import com.simplemobiletools.commons.extensions.showErrorToast import com.simplemobiletools.commons.extensions.toast import com.simplemobiletools.gallery.R -import com.simplemobiletools.gallery.activities.SimpleActivity import com.simplemobiletools.gallery.activities.ViewPagerActivity import com.simplemobiletools.gallery.extensions.config import com.simplemobiletools.gallery.extensions.getFileSignature @@ -225,7 +223,6 @@ class PhotoFragment : ViewPagerFragment() { override fun onImageLoadError(e: Exception) { background = ColorDrawable(Color.TRANSPARENT) beGone() - (activity as SimpleActivity).showErrorToast(e) } override fun onPreviewLoadError(e: Exception?) { From ea74fcf2c494258c2b9880aaa7905b7a5e5e2901 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 16 Sep 2017 22:13:15 +0200 Subject: [PATCH 21/89] disable swipe-to-refresh in horizontal scrolling --- .../com/simplemobiletools/gallery/activities/MainActivity.kt | 2 ++ .../com/simplemobiletools/gallery/activities/MediaActivity.kt | 2 ++ 2 files changed, 4 insertions(+) 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 c484be0a4..42dc79140 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -462,6 +462,8 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { } private fun setupScrollDirection() { + directories_refresh_layout.isEnabled = !config.scrollHorizontally + directories_vertical_fastscroller.isHorizontal = false directories_vertical_fastscroller.beGoneIf(config.scrollHorizontally) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index 6ef9182f7..67765fab8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -159,6 +159,8 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { } private fun setupScrollDirection() { + media_refresh_layout.isEnabled = !config.scrollHorizontally + media_vertical_fastscroller.isHorizontal = false media_vertical_fastscroller.beGoneIf(config.scrollHorizontally) From b8478f1a5c11fca7cd02235f473d4a9b4f2038c8 Mon Sep 17 00:00:00 2001 From: SuperUser Date: Sat, 16 Sep 2017 16:13:23 -0400 Subject: [PATCH 22/89] Add full copy of the Apache license This pull request adds a full copy of the Apache 2.0 license to uncopyright the code correctly. Current file leaves the code technically copyrighted since that statement included is only supposed to be used if the license is present in the repository. --- LICENSE | 208 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 198 insertions(+), 10 deletions(-) diff --git a/LICENSE b/LICENSE index 28c26588c..ff97af7d9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,13 +1,201 @@ -Copyright 2016 SimpleMobileTools + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - https://www.apache.org/licenses/LICENSE-2.0 + 1. Definitions. -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2017 SimpleMobileTools + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. From a64195750fd55fb6cfee26933b84eb16bae3e3f6 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 16 Sep 2017 22:31:00 +0200 Subject: [PATCH 23/89] remove some visual glitches at horizontally swiping at the folder thumbnails --- app/src/main/res/layout/directory_item.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/layout/directory_item.xml b/app/src/main/res/layout/directory_item.xml index f6d296e07..6903b7f46 100644 --- a/app/src/main/res/layout/directory_item.xml +++ b/app/src/main/res/layout/directory_item.xml @@ -39,7 +39,9 @@ android:id="@+id/dir_shadow_holder" android:layout_width="match_parent" android:layout_height="@dimen/tmb_shadow_height" + android:layout_alignLeft="@+id/dir_bottom_holder" android:layout_alignParentBottom="true" + android:layout_alignRight="@+id/dir_bottom_holder" android:background="@drawable/gradient_background"/> Date: Sun, 17 Sep 2017 10:50:23 +0200 Subject: [PATCH 24/89] change the way we get layout position in adapters --- .../gallery/adapters/DirectoryAdapter.kt | 24 +++++++++---------- .../gallery/adapters/MediaAdapter.kt | 24 +++++++++---------- 2 files changed, 24 insertions(+), 24 deletions(-) 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 86fbc9e4e..02aae82b2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -336,7 +336,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList -1 && min < to) { - (min..to - 1).filter { it != from } + (min until to).filter { it != from } .forEach { toggleItemSelection(false, it) } } if (max > -1) { @@ -386,7 +386,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList -1) { - for (i in min..from - 1) + for (i in min until from) toggleItemSelection(false, i) } } @@ -395,7 +395,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList (Unit)) : SwappingHolder(view, MultiSelector()) { - fun bindView(directory: Directory, isPinned: Boolean, scrollVertically: Boolean): View { + fun bindView(directory: Directory, isPinned: Boolean, scrollVertically: Boolean, position: Int): View { itemView.apply { dir_name.text = directory.name photo_cnt.text = directory.mediaCnt.toString() @@ -403,29 +403,29 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList, } override fun onBindViewHolder(holder: ViewHolder, position: Int) { - itemViews.put(position, holder.bindView(media[position], displayFilenames, scrollVertically)) + itemViews.put(position, holder.bindView(media[position], displayFilenames, scrollVertically, position)) toggleItemSelection(selectedPositions.contains(position), position) holder.itemView.tag = holder } @@ -289,7 +289,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, toggleItemSelection(true, i) if (min > -1 && min < to) { - (min..to - 1).filter { it != from } + (min until to).filter { it != from } .forEach { toggleItemSelection(false, it) } } if (max > -1) { @@ -306,7 +306,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, } if (min > -1) { - for (i in min..from - 1) + for (i in min until from) toggleItemSelection(false, i) } } @@ -315,36 +315,36 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, class ViewHolder(val view: View, val adapterListener: MyAdapterListener, val activity: SimpleActivity, val multiSelectorCallback: ModalMultiSelectorCallback, val multiSelector: MultiSelector, val listener: MediaOperationsListener?, val isPickIntent: Boolean, val itemClick: (Medium) -> (Unit)) : SwappingHolder(view, MultiSelector()) { - fun bindView(medium: Medium, displayFilenames: Boolean, scrollVertically: Boolean): View { + fun bindView(medium: Medium, displayFilenames: Boolean, scrollVertically: Boolean, position: Int): View { itemView.apply { play_outline.visibility = if (medium.video) View.VISIBLE else View.GONE photo_name.beVisibleIf(displayFilenames) photo_name.text = medium.name activity.loadImage(medium.path, medium_thumbnail, scrollVertically) - setOnClickListener { viewClicked(medium) } - setOnLongClickListener { if (isPickIntent) viewClicked(medium) else viewLongClicked(); true } + setOnClickListener { viewClicked(medium, position) } + setOnLongClickListener { if (isPickIntent) viewClicked(medium, position) else viewLongClicked(position); true } } return itemView } - fun viewClicked(medium: Medium) { + private fun viewClicked(medium: Medium, position: Int) { if (multiSelector.isSelectable) { - val isSelected = adapterListener.getSelectedPositions().contains(layoutPosition) - adapterListener.toggleItemSelectionAdapter(!isSelected, layoutPosition) + val isSelected = adapterListener.getSelectedPositions().contains(position) + adapterListener.toggleItemSelectionAdapter(!isSelected, position) } else { itemClick(medium) } } - fun viewLongClicked() { + private fun viewLongClicked(position: Int) { if (listener != null) { if (!multiSelector.isSelectable) { activity.startSupportActionMode(multiSelectorCallback) - adapterListener.toggleItemSelectionAdapter(true, layoutPosition) + adapterListener.toggleItemSelectionAdapter(true, position) } - listener.itemLongClicked(layoutPosition) + listener.itemLongClicked(position) } } From 2fe1f91c87a8bef7ee072a2672209a48ee26327b Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 17 Sep 2017 11:07:14 +0200 Subject: [PATCH 25/89] moving a toast further --- .../simplemobiletools/gallery/activities/ViewPagerActivity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index 6e300077d..468e2d69c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -511,8 +511,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View val bmp = Bitmap.createBitmap(bitmap, 0, 0, bitmap.width, bitmap.height, matrix, true) bmp.compress(file.getCompressionFormat(), 90, out) out.flush() - toast(R.string.file_saved) out.close() + toast(R.string.file_saved) } From 56a31e6ced95b9a923099503f66250067c4fc8d6 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 17 Sep 2017 11:17:51 +0200 Subject: [PATCH 26/89] fix #326, properly set bottom padding in landscape mode videos --- .../gallery/extensions/context.kt | 29 +++++++++++++++++++ .../gallery/fragments/VideoFragment.kt | 6 ++-- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt index 8a0613a58..51ac6da09 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt @@ -4,9 +4,12 @@ import android.content.Context import android.content.Intent import android.content.res.Configuration import android.database.Cursor +import android.graphics.Point import android.media.AudioManager import android.net.Uri +import android.os.Build import android.provider.MediaStore +import android.view.WindowManager import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.SORT_BY_DATE_MODIFIED import com.simplemobiletools.commons.helpers.SORT_BY_NAME @@ -19,6 +22,32 @@ import java.io.File val Context.portrait get() = resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT val Context.audioManager get() = getSystemService(Context.AUDIO_SERVICE) as AudioManager +val Context.windowManager: WindowManager get() = getSystemService(Context.WINDOW_SERVICE) as WindowManager +val Context.navigationBarRight: Boolean get() = usableScreenSize.x < realScreenSize.x +val Context.navigationBarBottom: Boolean get() = usableScreenSize.y < realScreenSize.y +val Context.navigationBarHeight: Int get() = if (navigationBarBottom) navigationBarSize.y else 0 + +internal val Context.navigationBarSize: Point + get() = when { + navigationBarRight -> Point(realScreenSize.x - usableScreenSize.x, usableScreenSize.y) + navigationBarBottom -> Point(usableScreenSize.x, realScreenSize.y - usableScreenSize.y) + else -> Point() + } + +val Context.usableScreenSize: Point + get() { + val size = Point() + windowManager.defaultDisplay.getSize(size) + return size + } + +val Context.realScreenSize: Point + get() { + val size = Point() + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) + windowManager.defaultDisplay.getRealSize(size) + return size + } fun Context.getRealPathFromURI(uri: Uri): String? { var cursor: Cursor? = null diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt index a2762d99a..1828912e7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt @@ -20,10 +20,7 @@ import com.simplemobiletools.commons.extensions.toast import com.simplemobiletools.commons.extensions.updateTextColors import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.activities.ViewPagerActivity -import com.simplemobiletools.gallery.extensions.audioManager -import com.simplemobiletools.gallery.extensions.config -import com.simplemobiletools.gallery.extensions.getNavBarHeight -import com.simplemobiletools.gallery.extensions.hasNavBar +import com.simplemobiletools.gallery.extensions.* import com.simplemobiletools.gallery.helpers.MEDIUM import com.simplemobiletools.gallery.models.Medium import kotlinx.android.synthetic.main.pager_video_item.view.* @@ -273,6 +270,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee bottom += height } else { right += height + bottom += context.navigationBarHeight } mTimeHolder!!.setPadding(left, top, right, bottom) } From fc3363987ee005d2ca3496a7d47458b8fbbd28ca Mon Sep 17 00:00:00 2001 From: anthologist Date: Sun, 17 Sep 2017 11:25:00 +0200 Subject: [PATCH 27/89] Updated italian --- app/src/main/res/values-it/strings.xml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index b723068ba..725bdbf01 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -27,12 +27,12 @@ Luminosità - Filter media - Images - Videos - GIFs - No media files have been found with the selected filters. - Change filters + Filtra i media + Immagini + Video + GIF + Nessun file trovato per il filtro selezionato. + Cambia filtro Questa funzione nasconde la cartella aggiungendo un file \'.nomedia\' all\'interno, nasconderà anche tutte le sottocartelle. Puoi vederle attivando l\'opzione \'Mostra cartelle nascoste\' nelle impostazioni. Continuare? @@ -98,7 +98,7 @@ Ordine sparso Usa animazioni a dissolvenza Scorri al contrario - Loop slideshow + Ripeti presentazione La presentazione è terminata Nessun media trovato per la presentazione @@ -117,8 +117,8 @@ Sfondo scuro a schermo intero Scorri miniature orizzontalmente Nascondi UI di sistema con media a schermo intero - Delete empty folders after deleting their content - Allow controlling video volume and brightness with vertical gestures + Elimina cartelle vuote dopo averne eliminato il contenuto + Gestisci il volume e la luminosità dei video con gesti verticali Sostituisci Condividi con Ruota a schermo intero From 3c01cb9fb62cdfffef015cdef9fcd5808e5474f6 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 17 Sep 2017 22:21:29 +0200 Subject: [PATCH 28/89] update commons to 2.28.0 --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 5bc9dd503..d1a3d40a5 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -37,7 +37,7 @@ android { } dependencies { - compile 'com.simplemobiletools:commons:2.27.11' + compile 'com.simplemobiletools:commons:2.28.0' compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0' compile 'com.theartofdev.edmodo:android-image-cropper:2.4.0' compile 'com.bignerdranch.android:recyclerview-multiselect:0.2' From de264466feb47857bc3bda5a01719164adeed146 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 17 Sep 2017 23:05:52 +0200 Subject: [PATCH 29/89] update version to 2.14.3 --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index d1a3d40a5..78040bab9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "com.simplemobiletools.gallery" minSdkVersion 16 targetSdkVersion 23 - versionCode 130 - versionName "2.14.2" + versionCode 131 + versionName "2.14.3" } signingConfigs { From 11be1b1e14daa57576034e9388b4fb243441cc60 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 17 Sep 2017 23:05:58 +0200 Subject: [PATCH 30/89] updating changelog --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 595a80b08..ffbe7a0df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,14 @@ Changelog ========== +Version 2.14.3 *(2017-09-17)* +---------------------------- + + * Removed some error toast messages after delete, or if image loading failed + * Fixed some visual glitches at horizontal scrolling + * Disable pull-to-refresh at horizontal scrolling + * Many other smaller bugfixes and improvements + Version 2.14.2 *(2017-09-11)* ---------------------------- From 6ed100e2047914bcf879bb0cff46ebb20ecac15a Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 18 Sep 2017 10:31:45 +0200 Subject: [PATCH 31/89] do not use GlideDecoder at SubsamplingScaleImageView for now --- .../com/simplemobiletools/gallery/fragments/PhotoFragment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt index c24c09f96..c3709bd68 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt @@ -200,7 +200,7 @@ class PhotoFragment : ViewPagerFragment() { private fun addZoomableView() { if ((medium.isImage()) && isFragmentVisible && view.subsampling_view.visibility == View.GONE) { view.subsampling_view.apply { - setBitmapDecoderClass(GlideDecoder::class.java) + //setBitmapDecoderClass(GlideDecoder::class.java) // causing random crashes on Android 7+ maxScale = 10f beVisible() setImage(ImageSource.uri(medium.path)) From 07429c70093985a851ed7a382b0af65ed77f0259 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 18 Sep 2017 10:32:07 +0200 Subject: [PATCH 32/89] update version to 2.14.4 (132) --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 78040bab9..90b986ddb 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "com.simplemobiletools.gallery" minSdkVersion 16 targetSdkVersion 23 - versionCode 131 - versionName "2.14.3" + versionCode 132 + versionName "2.14.4" } signingConfigs { From 7597efcba272fd597403a6b2d33b83328a54dc5b Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 18 Sep 2017 10:32:46 +0200 Subject: [PATCH 33/89] updating changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ffbe7a0df..19b5481bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ Changelog ========== +Version 2.14.4 *(2017-09-18)* +---------------------------- + + * Revert to the old way of loading fullscreen images to avoid issues on Android 7+ + Version 2.14.3 *(2017-09-17)* ---------------------------- From aa160841922ee40be52fed867eaa8ad2c5176723 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 18 Sep 2017 20:25:03 +0200 Subject: [PATCH 34/89] use layoutPosition at directory and media adapters --- .../gallery/adapters/DirectoryAdapter.kt | 20 +++++++++---------- .../gallery/adapters/MediaAdapter.kt | 20 +++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) 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 02aae82b2..c7e3dcbbf 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -336,7 +336,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList (Unit)) : SwappingHolder(view, MultiSelector()) { - fun bindView(directory: Directory, isPinned: Boolean, scrollVertically: Boolean, position: Int): View { + fun bindView(directory: Directory, isPinned: Boolean, scrollVertically: Boolean): View { itemView.apply { dir_name.text = directory.name photo_cnt.text = directory.mediaCnt.toString() @@ -403,29 +403,29 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList, } override fun onBindViewHolder(holder: ViewHolder, position: Int) { - itemViews.put(position, holder.bindView(media[position], displayFilenames, scrollVertically, position)) + itemViews.put(position, holder.bindView(media[position], displayFilenames, scrollVertically)) toggleItemSelection(selectedPositions.contains(position), position) holder.itemView.tag = holder } @@ -315,36 +315,36 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, class ViewHolder(val view: View, val adapterListener: MyAdapterListener, val activity: SimpleActivity, val multiSelectorCallback: ModalMultiSelectorCallback, val multiSelector: MultiSelector, val listener: MediaOperationsListener?, val isPickIntent: Boolean, val itemClick: (Medium) -> (Unit)) : SwappingHolder(view, MultiSelector()) { - fun bindView(medium: Medium, displayFilenames: Boolean, scrollVertically: Boolean, position: Int): View { + fun bindView(medium: Medium, displayFilenames: Boolean, scrollVertically: Boolean): View { itemView.apply { play_outline.visibility = if (medium.video) View.VISIBLE else View.GONE photo_name.beVisibleIf(displayFilenames) photo_name.text = medium.name activity.loadImage(medium.path, medium_thumbnail, scrollVertically) - setOnClickListener { viewClicked(medium, position) } - setOnLongClickListener { if (isPickIntent) viewClicked(medium, position) else viewLongClicked(position); true } + setOnClickListener { viewClicked(medium) } + setOnLongClickListener { if (isPickIntent) viewClicked(medium) else viewLongClicked(); true } } return itemView } - private fun viewClicked(medium: Medium, position: Int) { + private fun viewClicked(medium: Medium) { if (multiSelector.isSelectable) { - val isSelected = adapterListener.getSelectedPositions().contains(position) - adapterListener.toggleItemSelectionAdapter(!isSelected, position) + val isSelected = adapterListener.getSelectedPositions().contains(layoutPosition) + adapterListener.toggleItemSelectionAdapter(!isSelected, layoutPosition) } else { itemClick(medium) } } - private fun viewLongClicked(position: Int) { + private fun viewLongClicked() { if (listener != null) { if (!multiSelector.isSelectable) { activity.startSupportActionMode(multiSelectorCallback) - adapterListener.toggleItemSelectionAdapter(true, position) + adapterListener.toggleItemSelectionAdapter(true, layoutPosition) } - listener.itemLongClicked(position) + listener.itemLongClicked(layoutPosition) } } From 11068f5d7582c52dae52dce04fa64910c1f848c4 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 20 Sep 2017 00:57:38 +0900 Subject: [PATCH 35/89] Update Japanese translation --- app/src/main/res/values-ja/strings.xml | 168 ++++++++++++------------- 1 file changed, 84 insertions(+), 84 deletions(-) diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index f0fbd9f19..869005886 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -4,122 +4,122 @@ ギャラリー 編集 カメラを開く - …で開く + 別のアプリで開く 有効なアプリが見つかりません (非表示) - Pin folder - Unpin folder - Show all folders content - All media - Switch to folder view - Other folder - Show on map - Unknown location - No application with maps has been found - No Camera app has been found - Increase column count - Reduce column count - Change cover image - Select photo - Use default - Set as - Volume - Brightness + フォルダーをピン留めする + フォルダーのピン留めを外す + すべてのフォルダーの内容を表示 + すべてのフォルダー + フォルダーを選択する + その他のフォルダー + 地図で表示 + 位置情報がありません + 地図アプリが見つかりません + カメラアプリが見つかりません + 表示列数を増やす + 表示列数を減らす + カバー画像を変更 + 写真を選択 + デフォルトに戻す + 他で使う + 音量 + 明るさ - Filter media - Images - Videos - GIFs - No media files have been found with the selected filters. - Change filters + 絞り込み + 画像 + ビデオ + GIF + 絞り込み条件に該当するメディアがありません。 + 絞り込み条件を変更 - This function hides the folder by adding a \'.nomedia\' file into it, it will hide all subfolders too. You can see them by toggling the \'Show hidden folders\' option in Settings. Continue? - Exclude - Excluded folders - Manage excluded folders - This will exclude the selection together with its subfolders from Simple Gallery only. You can manage excluded folders in Settings. - Exclude a parent instead? - Excluding folders will make them together with their subfolders hidden just in Simple Gallery, they will still be visible in other applications.\\n\\nIf you want to hide them from other apps too, use the Hide function. - Remove all - Remove all folders from the list of excluded? This will not delete the folders. + 対象のフォルダーに「.nomedia」というファイルを作成し、フォルダーを非表示にします。そのフォルダー以下のすべてのサブフォルダーも、同様に非表示となります。非表示となったフォルダーを見るには、「設定」の中にある「非表示のフォルダーを表示」オプションを切り替えてください。このフォルダーを非表示にしますか? + 除外する + 除外フォルダー + 除外フォルダーを管理 + 選択したフォルダーとそのサブフォルダーを、Simple Galleyの一覧から除外します。除外したフォルダーは「設定」で管理できます。 + 親フォルダーを選択して除外することもできます。 + フォルダーを除外すると、サブフォルダーも含めSimple Galleyの一覧から除外します。他のアプリでは引き続き表示されます。\\n\\n他のアプリでも非表示にしたい場合は、「非表示」機能を使用してください。 + すべて解除 + 除外するフォルダーの登録をすべて解除しますか? フォルダー自体は削除されません。 - Included folders - Manage included folders - Add folder - If you have some folders which contain media, but were not recognized by the app, you can add them manually here. + 追加フォルダー + 追加フォルダーを管理 + フォルダーを追加 + メディアを含んでいるフォルダーがアプリから認識されていない場合は、手動で追加できます。 - Resize - Resize selection and save - Width - Height - Keep aspect ratio - Please enter a valid resolution + リサイズ + 選択領域をリサイズして保存 + + 高さ + 縦横比を固定 + 解像度を正しく入力してください エディター 保存 回転 - Path + パス 無効な画像パス 画像の編集に失敗しました 画像を編集: 画像エディターが見つかりません ファイルの場所が不明です 元のファイルを上書きできません - Rotate left - Rotate right - Rotate by 180º - Flip - Flip horizontally - Flip vertically - Edit with + 左に回転 + 右に回転 + 180º回転 + 反転 + 水平方向に反転 + 垂直方向に反転 + 他のアプリで編集 シンプル壁紙 - 壁紙として設定 - 壁紙としての設定に失敗しました - 壁紙として設定: + 壁紙に設定 + 壁紙の設定に失敗しました + 壁紙に設定: 対応できるアプリが見つかりません - 壁紙の設定… + 壁紙に設定中… 壁紙を正常に設定しました - Portrait aspect ratio - Landscape aspect ratio + 縦向きの縦横比 + 横向きの縦横比 - Slideshow - Interval (seconds): - Include photos - Include videos - Include GIFs - Random order - Use fade animations - Move backwards - Loop slideshow - The slideshow ended - No media for the slideshow have been found + スライドショー + 間隔 (秒): + 写真を含める + ビデオを含める + GIFを含める + ランダムな順序 + フェードアニメーションを使用する + 逆方向に進む + スライドショーをリピート再生する + スライドショーが終了しました + スライドショーに表示するメディアがありません 非表示フォルダーを表示 - 自動的にビデオを再生 + ビデオを自動再生する ファイル名の表示を切り替え - Loop videos - Animate GIFs at thumbnails - Max brightness when viewing media - Crop thumbnails into squares - Rotate fullscreen media by - System setting - Device rotation - Aspect ratio - Dark background at fullscreen media - Scroll thumbnails horizontally - Automatically hide system UI at fullscreen media - Delete empty folders after deleting their content - Allow controlling video volume and brightness with vertical gestures - Replace Share with Rotate at fullscreen menu + ビデオをリピート再生する + GIF画像のサムネイルをアニメーション表示する + メディア再生時に明るさを最大にする + サムネイルを正方形に切り取る + メディア再生時のフルスクリーン表示切り替え + システム設定に従う + 端末の向きに従う + メディアの縦横比に従う + 黒背景でフルスクリーン表示 + サムネイル画面を横方向にスクロール + フルスクリーン時にシステムUIを非表示にする + メディアの削除後にフォルダーが空になった場合、そのフォルダーを削除する + ビデオ再生中に、音量と明るさを縦方向のジェスチャーで変更する + フルスクリーンメニューの「共有」を「回転」に置き換える From c314d3dad71a0f04383b7fb43fefc112093f05b7 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 20 Sep 2017 23:50:28 +0200 Subject: [PATCH 36/89] updating some Frech string styling --- app/src/main/res/values-fr/strings.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index ec733b59c..cb8271195 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -125,13 +125,13 @@ Un album pour visionner photos et vidéos sans publicité. - Un simple outil pour visionner les photos et les vidéos. Elles peuvent être triées par dates, tailles, noms dans les deux sens (alphabétique comme désalphabétique), il est possible de zoomer sur les photos. Les fichiers sont affichés sur de multiple colonnes en fonction de la taille de l\'écran, vous pouvez changer le nombre de colonnes par pincement. Elles peuvent être renommées, partagées, supprimées, copiées et déplacées. Les images peuvent en plus être tournées, rognées ou être définies comme fond d\'écran directement depuis l\'application. La galerie est aussi offerte pour l\'utiliser comme une tierce partie pour de la prévisualisation des images/vidéos, joindre aux clients mail etc. C\'est parfait pour un usage au quotidien. + Un simple outil pour visionner les photos et les vidéos. Elles peuvent être triées par dates, tailles, noms dans les deux sens (alphabétique comme désalphabétique), il est possible de zoomer sur les photos. Les fichiers sont affichés sur de multiple colonnes en fonction de la taille de l\'écran, vous pouvez changer le nombre de colonnes par pincement. Elles peuvent être renommées, partagées, supprimées, copiées et déplacées. Les images peuvent en plus être tournées, rognées ou être définies comme fond d\'écran directement depuis l\'application. + + La galerie est aussi offerte pour l\'utiliser comme une tierce partie pour de la prévisualisation des images/vidéos, joindre aux clients mail etc. C\'est parfait pour un usage au quotidien. L\'application ne contient ni de publicité ni d\'autorisation inutile. Elle est totalement OpenSource et est aussi fournie avec un thème sombre. - Cette application est juste l\'une des applications d\'une plus grande suite. - - Vous pouvez trouver les autres sur http://www.simplemobiletools.com + Cette application est juste l\'une des applications d\'une plus grande suite. Vous pouvez trouver les autres sur http://www.simplemobiletools.com - 絞り込み + 表示メディア種 画像 ビデオ GIF From faf0aba579e6e75b067f948e46dcdfe195acc10d Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 23 Sep 2017 12:15:26 +0200 Subject: [PATCH 38/89] update commons to 2.28.4 --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 90b986ddb..2e21c56de 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -37,7 +37,7 @@ android { } dependencies { - compile 'com.simplemobiletools:commons:2.28.0' + compile 'com.simplemobiletools:commons:2.28.4' compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0' compile 'com.theartofdev.edmodo:android-image-cropper:2.4.0' compile 'com.bignerdranch.android:recyclerview-multiselect:0.2' From 2640f99e229e89d7a88ef186b23c27759d29d18e Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 23 Sep 2017 12:15:41 +0200 Subject: [PATCH 39/89] update kotlin to 1.1.50 --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 2e21c56de..c50f15187 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -52,7 +52,7 @@ dependencies { } buildscript { - ext.kotlin_version = '1.1.4-3' + ext.kotlin_version = '1.1.50' repositories { mavenCentral() } From 7a653ec0c6211dd8b44df41f0b53cc17e3b8cbc8 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 24 Sep 2017 22:51:03 +0200 Subject: [PATCH 40/89] some code style update at the Directory and Medium classes --- .../gallery/models/Directory.kt | 40 ++++++++----------- .../gallery/models/Medium.kt | 40 ++++++++----------- 2 files changed, 34 insertions(+), 46 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/models/Directory.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/models/Directory.kt index 6293eba76..ec877c43c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/models/Directory.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/models/Directory.kt @@ -16,29 +16,23 @@ data class Directory(val path: String, val tmb: String, val name: String, var me override fun compareTo(other: Directory): Int { var result: Int - if (sorting and SORT_BY_NAME != 0) { - result = AlphanumComparator().compare(name.toLowerCase(), other.name.toLowerCase()) - } else if (sorting and SORT_BY_SIZE != 0) { - result = if (size == other.size) - 0 - else if (size > other.size) - 1 - else - -1 - } else if (sorting and SORT_BY_DATE_MODIFIED != 0) { - result = if (modified == other.modified) - 0 - else if (modified > other.modified) - 1 - else - -1 - } else { - result = if (taken == other.taken) - 0 - else if (taken > other.taken) - 1 - else - -1 + when { + sorting and SORT_BY_NAME != 0 -> result = AlphanumComparator().compare(name.toLowerCase(), other.name.toLowerCase()) + sorting and SORT_BY_SIZE != 0 -> result = when { + size == other.size -> 0 + size > other.size -> 1 + else -> -1 + } + sorting and SORT_BY_DATE_MODIFIED != 0 -> result = when { + modified == other.modified -> 0 + modified > other.modified -> 1 + else -> -1 + } + else -> result = when { + taken == other.taken -> 0 + taken > other.taken -> 1 + else -> -1 + } } if (sorting and SORT_DESCENDING != 0) { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/models/Medium.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/models/Medium.kt index 1663c60b1..a04a39aa9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/models/Medium.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/models/Medium.kt @@ -25,29 +25,23 @@ data class Medium(var name: String, var path: String, val video: Boolean, val mo override fun compareTo(other: Medium): Int { var result: Int - if (sorting and SORT_BY_NAME != 0) { - result = AlphanumComparator().compare(name.toLowerCase(), other.name.toLowerCase()) - } else if (sorting and SORT_BY_SIZE != 0) { - result = if (size == other.size) - 0 - else if (size > other.size) - 1 - else - -1 - } else if (sorting and SORT_BY_DATE_MODIFIED != 0) { - result = if (modified == other.modified) - 0 - else if (modified > other.modified) - 1 - else - -1 - } else { - result = if (taken == other.taken) - 0 - else if (taken > other.taken) - 1 - else - -1 + when { + sorting and SORT_BY_NAME != 0 -> result = AlphanumComparator().compare(name.toLowerCase(), other.name.toLowerCase()) + sorting and SORT_BY_SIZE != 0 -> result = when { + size == other.size -> 0 + size > other.size -> 1 + else -> -1 + } + sorting and SORT_BY_DATE_MODIFIED != 0 -> result = when { + modified == other.modified -> 0 + modified > other.modified -> 1 + else -> -1 + } + else -> result = when { + taken == other.taken -> 0 + taken > other.taken -> 1 + else -> -1 + } } if (sorting and SORT_DESCENDING != 0) { From 9d9866c1d23451ecbd693e2c76193b99c3b26e29 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 25 Sep 2017 20:42:47 +0200 Subject: [PATCH 41/89] use simple asynctask execute() at fetching directories --- .../com/simplemobiletools/gallery/activities/MainActivity.kt | 3 +-- 1 file changed, 1 insertion(+), 2 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 42dc79140..5a6075197 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -5,7 +5,6 @@ import android.app.Activity import android.content.Intent import android.content.pm.PackageManager import android.net.Uri -import android.os.AsyncTask import android.os.Build import android.os.Bundle import android.os.Handler @@ -216,7 +215,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { mCurrAsyncTask = GetDirectoriesAsynctask(applicationContext, mIsPickVideoIntent || mIsGetVideoContentIntent, mIsPickImageIntent || mIsGetImageContentIntent) { gotDirectories(addTempFolderIfNeeded(it), false) } - mCurrAsyncTask!!.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR) + mCurrAsyncTask!!.execute() } private fun showSortingDialog() { From 0da84f295887c9ce8c33fa2a5aab6692b20069b2 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 25 Sep 2017 21:04:09 +0200 Subject: [PATCH 42/89] change the way directories are grouped and sorted --- .../asynctasks/GetDirectoriesAsynctask.kt | 100 +++++++++++------- .../gallery/extensions/arrayList.kt | 5 + .../gallery/helpers/Config.kt | 8 +- 3 files changed, 69 insertions(+), 44 deletions(-) create mode 100644 app/src/main/kotlin/com/simplemobiletools/gallery/extensions/arrayList.kt 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 b68d69d09..9f609bb23 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt @@ -6,10 +6,12 @@ import com.simplemobiletools.commons.extensions.getFilenameFromPath import com.simplemobiletools.commons.extensions.hasWriteStoragePermission import com.simplemobiletools.commons.extensions.internalStoragePath import com.simplemobiletools.commons.extensions.sdCardPath +import com.simplemobiletools.commons.helpers.SORT_DESCENDING import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.extensions.config import com.simplemobiletools.gallery.extensions.containsNoMedia import com.simplemobiletools.gallery.extensions.getFilesFrom +import com.simplemobiletools.gallery.extensions.sumByLong import com.simplemobiletools.gallery.models.Directory import com.simplemobiletools.gallery.models.Medium import java.io.File @@ -19,7 +21,7 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va val callback: (dirs: ArrayList) -> Unit) : AsyncTask>() { var config = context.config var shouldStop = false - val showHidden = config.shouldShowHidden + private val showHidden = config.shouldShowHidden override fun doInBackground(vararg params: Void): ArrayList { if (!context.hasWriteStoragePermission()) @@ -28,53 +30,71 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va val media = context.getFilesFrom("", isPickImage, isPickVideo) val excludedPaths = config.excludedFolders val includedPaths = config.includedFolders + val hidden = context.resources.getString(R.string.hidden) val directories = groupDirectories(media) - val dirs = ArrayList(directories.values - .filter { File(it.path).exists() }) - .filter { shouldFolderBeVisible(it.path, excludedPaths, includedPaths) } as ArrayList + + val removePaths = ArrayList() + directories.keys.forEach { + if (!File(it).exists() || !shouldFolderBeVisible(it, excludedPaths, includedPaths)) { + removePaths.add(it) + } + } + + removePaths.forEach { + directories.remove(it) + } + + val dirs = ArrayList() + val albumCovers = config.parseAlbumCovers() + for ((path, curMedia) in directories) { + Medium.sorting = config.getFileSorting(path) + curMedia.sort() + + val firstItem = curMedia.first() + val lastItem = curMedia.last() + val parentDir = File(firstItem.path).parent + var thumbnail = firstItem.path + albumCovers.forEach { + if (it.path == parentDir && File(it.tmb).exists()) { + thumbnail = it.tmb + } + } + + var dirName = when (parentDir) { + context.internalStoragePath -> context.getString(R.string.internal) + context.sdCardPath -> context.getString(R.string.sd_card) + else -> parentDir.getFilenameFromPath() + } + + if (File(path).containsNoMedia()) { + dirName += " $hidden" + } + + val lastModified = if (config.directorySorting and SORT_DESCENDING > 0) Math.max(firstItem.modified, lastItem.modified) else Math.min(firstItem.modified, lastItem.modified) + val dateTaken = if (config.directorySorting and SORT_DESCENDING > 0) Math.max(firstItem.taken, lastItem.taken) else Math.min(firstItem.taken, lastItem.taken) + val size = curMedia.sumByLong { it.size } + val directory = Directory(parentDir, thumbnail, dirName, curMedia.size, lastModified, dateTaken, size) + dirs.add(directory) + } + Directory.sorting = config.directorySorting dirs.sort() return movePinnedToFront(dirs) } - private fun groupDirectories(media: ArrayList): Map { - val albumCovers = config.parseAlbumCovers() - val hidden = context.resources.getString(R.string.hidden) - val directories = LinkedHashMap() - for ((name, path, isVideo, dateModified, dateTaken, size) in media) { - if (shouldStop) + private fun groupDirectories(media: ArrayList): HashMap> { + val directories = LinkedHashMap>() + for (medium in media) { + if (shouldStop) { cancel(true) + break + } - val parentDir = File(path).parent ?: continue - if (directories.containsKey(parentDir.toLowerCase())) { - val directory = directories[parentDir.toLowerCase()]!! - val newImageCnt = directory.mediaCnt + 1 - directory.mediaCnt = newImageCnt - directory.addSize(size) + val parentDir = File(medium.path).parent?.toLowerCase() ?: continue + if (directories.containsKey(parentDir)) { + directories[parentDir]!!.add(medium) } else { - var dirName = parentDir.getFilenameFromPath() - if (parentDir == context.internalStoragePath) { - dirName = context.getString(R.string.internal) - } else if (parentDir == context.sdCardPath) { - dirName = context.getString(R.string.sd_card) - } - - if (File(parentDir).containsNoMedia()) { - dirName += " $hidden" - - if (!showHidden) - continue - } - - var thumbnail = path - albumCovers.forEach { - if (it.path == parentDir && File(it.tmb).exists()) { - thumbnail = it.tmb - } - } - - val directory = Directory(parentDir, thumbnail, dirName, 1, dateModified, dateTaken, size) - directories.put(parentDir.toLowerCase(), directory) + directories.put(parentDir, arrayListOf(medium)) } } return directories @@ -86,7 +106,7 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va true } else if (isThisOrParentExcluded(path, excludedPaths, includedPaths)) { false - } else if (!config.shouldShowHidden && file.isDirectory && file.canonicalFile == file.absoluteFile) { + } else if (!showHidden && file.isDirectory && file.canonicalFile == file.absoluteFile) { var containsNoMediaOrDot = file.containsNoMedia() || path.contains("/.") if (!containsNoMediaOrDot) { containsNoMediaOrDot = checkParentHasNoMedia(file.parentFile) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/arrayList.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/arrayList.kt new file mode 100644 index 000000000..8d5d3ad27 --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/arrayList.kt @@ -0,0 +1,5 @@ +package com.simplemobiletools.gallery.extensions + +import java.util.* + +fun ArrayList.sumByLong(selector: (E) -> Long) = map { selector(it) }.sum() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt index f17e9eed1..5cd08be16 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt @@ -28,17 +28,17 @@ class Config(context: Context) : BaseConfig(context) { if (path.isEmpty()) { fileSorting = value } else { - prefs.edit().putInt(SORT_FOLDER_PREFIX + path, value).apply() + prefs.edit().putInt(SORT_FOLDER_PREFIX + path.toLowerCase(), value).apply() } } - fun getFileSorting(path: String) = prefs.getInt(SORT_FOLDER_PREFIX + path, fileSorting) + fun getFileSorting(path: String) = prefs.getInt(SORT_FOLDER_PREFIX + path.toLowerCase(), fileSorting) fun removeFileSorting(path: String) { - prefs.edit().remove(SORT_FOLDER_PREFIX + path).apply() + prefs.edit().remove(SORT_FOLDER_PREFIX + path.toLowerCase()).apply() } - fun hasCustomSorting(path: String) = prefs.contains(SORT_FOLDER_PREFIX + path) + fun hasCustomSorting(path: String) = prefs.contains(SORT_FOLDER_PREFIX + path.toLowerCase()) var wasHideFolderTooltipShown: Boolean get() = prefs.getBoolean(HIDE_FOLDER_TOOLTIP_SHOWN, false) From 417c1169f8edcb6a7ac3e01410b145a528608f57 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 25 Sep 2017 22:34:58 +0200 Subject: [PATCH 43/89] just quickly resort directories at sorting change, when possible --- .../gallery/activities/MainActivity.kt | 15 ++++++++++++--- .../asynctasks/GetDirectoriesAsynctask.kt | 14 +------------- .../gallery/dialogs/PickDirectoryDialog.kt | 12 +++++++----- .../gallery/extensions/context.kt | 19 +++++++++++++++++++ 4 files changed, 39 insertions(+), 21 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 5a6075197..220d5e4b9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -19,6 +19,8 @@ import com.google.gson.Gson import com.simplemobiletools.commons.dialogs.CreateNewFolderDialog import com.simplemobiletools.commons.dialogs.FilePickerDialog import com.simplemobiletools.commons.extensions.* +import com.simplemobiletools.commons.helpers.SORT_BY_DATE_MODIFIED +import com.simplemobiletools.commons.helpers.SORT_BY_DATE_TAKEN import com.simplemobiletools.commons.models.Release import com.simplemobiletools.commons.views.MyScalableRecyclerView import com.simplemobiletools.gallery.BuildConfig @@ -220,7 +222,11 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { private fun showSortingDialog() { ChangeSortingDialog(this, true, false) { - getDirectories() + if (config.directorySorting and SORT_BY_DATE_MODIFIED > 0 || config.directorySorting and SORT_BY_DATE_TAKEN > 0) { + getDirectories() + } else { + gotDirectories(mDirs, true) + } } } @@ -420,7 +426,9 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { } } - private fun gotDirectories(dirs: ArrayList, isFromCache: Boolean) { + private fun gotDirectories(newDirs: ArrayList, isFromCache: Boolean) { + val dirs = getSortedDirectories(newDirs) + mLastMediaModified = getLastMediaModified() directories_refresh_layout.isRefreshing = false mIsGettingDirs = false @@ -429,8 +437,9 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { directories_empty_text.beVisibleIf(dirs.isEmpty() && !isFromCache) checkLastMediaChanged() - if (dirs.hashCode() == mDirs.hashCode()) + if (dirs.hashCode() == mDirs.hashCode()) { return + } mDirs = dirs 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 9f609bb23..604822008 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt @@ -77,9 +77,7 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va dirs.add(directory) } - Directory.sorting = config.directorySorting - dirs.sort() - return movePinnedToFront(dirs) + return dirs } private fun groupDirectories(media: ArrayList): HashMap> { @@ -133,16 +131,6 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va private fun isThisOrParentExcluded(path: String, excludedPaths: MutableSet, includedPaths: MutableSet) = includedPaths.none { path.startsWith(it) } && excludedPaths.any { path.startsWith(it) } - private fun movePinnedToFront(dirs: ArrayList): ArrayList { - val foundFolders = ArrayList() - val pinnedFolders = config.pinnedFolders - - dirs.forEach { if (pinnedFolders.contains(it.path)) foundFolders.add(it) } - dirs.removeAll(foundFolders) - dirs.addAll(0, foundFolders) - return dirs - } - override fun onPostExecute(dirs: ArrayList) { super.onPostExecute(dirs) callback(dirs) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickDirectoryDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickDirectoryDialog.kt index a52a395cd..a4e877bad 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickDirectoryDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickDirectoryDialog.kt @@ -15,6 +15,7 @@ import com.simplemobiletools.gallery.adapters.DirectoryAdapter import com.simplemobiletools.gallery.asynctasks.GetDirectoriesAsynctask import com.simplemobiletools.gallery.extensions.config import com.simplemobiletools.gallery.extensions.getCachedDirectories +import com.simplemobiletools.gallery.extensions.getSortedDirectories import com.simplemobiletools.gallery.models.Directory import kotlinx.android.synthetic.main.dialog_directory_picker.view.* @@ -47,19 +48,20 @@ class PickDirectoryDialog(val activity: SimpleActivity, val sourcePath: String, } } - fun showOtherFolder() { + private fun showOtherFolder() { val showHidden = activity.config.shouldShowHidden FilePickerDialog(activity, sourcePath, false, showHidden, true) { callback(it) } } - private fun gotDirectories(directories: ArrayList) { - if (directories.hashCode() == shownDirectories.hashCode()) + private fun gotDirectories(newDirs: ArrayList) { + val dirs = activity.getSortedDirectories(newDirs) + if (dirs.hashCode() == shownDirectories.hashCode()) return - shownDirectories = directories - val adapter = DirectoryAdapter(activity, directories, null, true) { + shownDirectories = dirs + val adapter = DirectoryAdapter(activity, dirs, null, true) { if (it.path.trimEnd('/') == sourcePath) { activity.toast(R.string.source_and_destination_same) return@DirectoryAdapter diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt index 51ac6da09..e6ae6d99e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt @@ -17,6 +17,7 @@ import com.simplemobiletools.commons.helpers.SORT_BY_SIZE import com.simplemobiletools.commons.helpers.SORT_DESCENDING import com.simplemobiletools.gallery.activities.SettingsActivity import com.simplemobiletools.gallery.helpers.* +import com.simplemobiletools.gallery.models.Directory import com.simplemobiletools.gallery.models.Medium import java.io.File @@ -289,3 +290,21 @@ fun Context.getLastMediaModified(): Int { } return 0 } + +fun Context.movePinnedDirectoriesToFront(dirs: ArrayList): ArrayList { + val foundFolders = ArrayList() + val pinnedFolders = config.pinnedFolders + + dirs.forEach { if (pinnedFolders.contains(it.path)) foundFolders.add(it) } + dirs.removeAll(foundFolders) + dirs.addAll(0, foundFolders) + return dirs +} + +@Suppress("UNCHECKED_CAST") +fun Context.getSortedDirectories(source: ArrayList): ArrayList { + Directory.sorting = config.directorySorting + val dirs = source.clone() as ArrayList + dirs.sort() + return movePinnedDirectoriesToFront(dirs) +} From c242f74f9b41a9aab09232064cb7e6cca7b8285c Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 25 Sep 2017 22:55:22 +0200 Subject: [PATCH 44/89] fix some glitches with incasesensitive paths at directories --- .../gallery/asynctasks/GetDirectoriesAsynctask.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 604822008..d6054eb74 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt @@ -34,9 +34,11 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va val directories = groupDirectories(media) val removePaths = ArrayList() - directories.keys.forEach { - if (!File(it).exists() || !shouldFolderBeVisible(it, excludedPaths, includedPaths)) { - removePaths.add(it) + for ((path, curMedia) in directories) { + // make sure the path has uppercase letters wherever appropriate + val groupPath = File(curMedia.first().path).parent + if (!File(groupPath).exists() || !shouldFolderBeVisible(groupPath, excludedPaths, includedPaths)) { + removePaths.add(groupPath) } } @@ -66,7 +68,7 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va else -> parentDir.getFilenameFromPath() } - if (File(path).containsNoMedia()) { + if (File(parentDir).containsNoMedia()) { dirName += " $hidden" } From fcad1f6fa590d6aefd8feacba56746b522bf340f Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 25 Sep 2017 23:01:02 +0200 Subject: [PATCH 45/89] properly hide hidden folders --- .../gallery/asynctasks/GetDirectoriesAsynctask.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 d6054eb74..80d629d32 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt @@ -38,7 +38,7 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va // make sure the path has uppercase letters wherever appropriate val groupPath = File(curMedia.first().path).parent if (!File(groupPath).exists() || !shouldFolderBeVisible(groupPath, excludedPaths, includedPaths)) { - removePaths.add(groupPath) + removePaths.add(groupPath.toLowerCase()) } } From d8811d66b80310769680c210e2c9381acf7fbe3f Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 25 Sep 2017 23:19:17 +0200 Subject: [PATCH 46/89] move some media getting functions in Context extensions --- .../gallery/activities/MainActivity.kt | 1 - .../asynctasks/GetDirectoriesAsynctask.kt | 83 ++----------------- .../gallery/extensions/context.kt | 73 ++++++++++++++++ 3 files changed, 79 insertions(+), 78 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 220d5e4b9..35deec3c1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -146,7 +146,6 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { override fun onPause() { super.onPause() - mCurrAsyncTask?.shouldStop = true storeDirectories() directories_refresh_layout.isRefreshing = false mIsGettingDirs = false 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 80d629d32..a6450aac1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt @@ -10,45 +10,25 @@ import com.simplemobiletools.commons.helpers.SORT_DESCENDING import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.extensions.config import com.simplemobiletools.gallery.extensions.containsNoMedia -import com.simplemobiletools.gallery.extensions.getFilesFrom +import com.simplemobiletools.gallery.extensions.getMediaByDirectories import com.simplemobiletools.gallery.extensions.sumByLong import com.simplemobiletools.gallery.models.Directory import com.simplemobiletools.gallery.models.Medium import java.io.File -import java.util.* class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, val isPickImage: Boolean, val callback: (dirs: ArrayList) -> Unit) : AsyncTask>() { - var config = context.config - var shouldStop = false - private val showHidden = config.shouldShowHidden override fun doInBackground(vararg params: Void): ArrayList { if (!context.hasWriteStoragePermission()) return ArrayList() - val media = context.getFilesFrom("", isPickImage, isPickVideo) - val excludedPaths = config.excludedFolders - val includedPaths = config.includedFolders + val config = context.config + val groupedMedia = context.getMediaByDirectories(isPickVideo, isPickImage) + val directories = ArrayList() val hidden = context.resources.getString(R.string.hidden) - val directories = groupDirectories(media) - - val removePaths = ArrayList() - for ((path, curMedia) in directories) { - // make sure the path has uppercase letters wherever appropriate - val groupPath = File(curMedia.first().path).parent - if (!File(groupPath).exists() || !shouldFolderBeVisible(groupPath, excludedPaths, includedPaths)) { - removePaths.add(groupPath.toLowerCase()) - } - } - - removePaths.forEach { - directories.remove(it) - } - - val dirs = ArrayList() val albumCovers = config.parseAlbumCovers() - for ((path, curMedia) in directories) { + for ((path, curMedia) in groupedMedia) { Medium.sorting = config.getFileSorting(path) curMedia.sort() @@ -76,63 +56,12 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va val dateTaken = if (config.directorySorting and SORT_DESCENDING > 0) Math.max(firstItem.taken, lastItem.taken) else Math.min(firstItem.taken, lastItem.taken) val size = curMedia.sumByLong { it.size } val directory = Directory(parentDir, thumbnail, dirName, curMedia.size, lastModified, dateTaken, size) - dirs.add(directory) + directories.add(directory) } - return dirs - } - - private fun groupDirectories(media: ArrayList): HashMap> { - val directories = LinkedHashMap>() - for (medium in media) { - if (shouldStop) { - cancel(true) - break - } - - val parentDir = File(medium.path).parent?.toLowerCase() ?: continue - if (directories.containsKey(parentDir)) { - directories[parentDir]!!.add(medium) - } else { - directories.put(parentDir, arrayListOf(medium)) - } - } return directories } - private fun shouldFolderBeVisible(path: String, excludedPaths: MutableSet, includedPaths: MutableSet): Boolean { - val file = File(path) - return if (includedPaths.contains(path)) { - true - } else if (isThisOrParentExcluded(path, excludedPaths, includedPaths)) { - false - } else if (!showHidden && file.isDirectory && file.canonicalFile == file.absoluteFile) { - var containsNoMediaOrDot = file.containsNoMedia() || path.contains("/.") - if (!containsNoMediaOrDot) { - containsNoMediaOrDot = checkParentHasNoMedia(file.parentFile) - } - !containsNoMediaOrDot - } else { - true - } - } - - private fun checkParentHasNoMedia(file: File): Boolean { - var curFile = file - while (true) { - if (curFile.containsNoMedia()) { - return true - } - curFile = curFile.parentFile - if (curFile.absolutePath == "/") - break - } - return false - } - - private fun isThisOrParentExcluded(path: String, excludedPaths: MutableSet, includedPaths: MutableSet) = - includedPaths.none { path.startsWith(it) } && excludedPaths.any { path.startsWith(it) } - override fun onPostExecute(dirs: ArrayList) { super.onPostExecute(dirs) callback(dirs) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt index e6ae6d99e..095d8f348 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt @@ -20,6 +20,10 @@ import com.simplemobiletools.gallery.helpers.* import com.simplemobiletools.gallery.models.Directory import com.simplemobiletools.gallery.models.Medium import java.io.File +import java.util.LinkedHashMap +import kotlin.collections.ArrayList +import kotlin.collections.component1 +import kotlin.collections.component2 val Context.portrait get() = resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT val Context.audioManager get() = getSystemService(Context.AUDIO_SERVICE) as AudioManager @@ -301,6 +305,75 @@ fun Context.movePinnedDirectoriesToFront(dirs: ArrayList): ArrayList< return dirs } +fun Context.getMediaByDirectories(isPickVideo: Boolean, isPickImage: Boolean): HashMap> { + val media = getFilesFrom("", isPickImage, isPickVideo) + val excludedPaths = config.excludedFolders + val includedPaths = config.includedFolders + val showHidden = config.shouldShowHidden + val directories = groupDirectories(media) + + val removePaths = ArrayList() + for ((path, curMedia) in directories) { + // make sure the path has uppercase letters wherever appropriate + val groupPath = File(curMedia.first().path).parent + if (!File(groupPath).exists() || !shouldFolderBeVisible(groupPath, excludedPaths, includedPaths, showHidden)) { + removePaths.add(groupPath.toLowerCase()) + } + } + + removePaths.forEach { + directories.remove(it) + } + + return directories +} + +private fun groupDirectories(media: ArrayList): HashMap> { + val directories = LinkedHashMap>() + for (medium in media) { + val parentDir = File(medium.path).parent?.toLowerCase() ?: continue + if (directories.containsKey(parentDir)) { + directories[parentDir]!!.add(medium) + } else { + directories.put(parentDir, arrayListOf(medium)) + } + } + return directories +} + +private fun shouldFolderBeVisible(path: String, excludedPaths: MutableSet, includedPaths: MutableSet, showHidden: Boolean): Boolean { + val file = File(path) + return if (includedPaths.contains(path)) { + true + } else if (isThisOrParentExcluded(path, excludedPaths, includedPaths)) { + false + } else if (!showHidden && file.isDirectory && file.canonicalFile == file.absoluteFile) { + var containsNoMediaOrDot = file.containsNoMedia() || path.contains("/.") + if (!containsNoMediaOrDot) { + containsNoMediaOrDot = checkParentHasNoMedia(file.parentFile) + } + !containsNoMediaOrDot + } else { + true + } +} + +private fun checkParentHasNoMedia(file: File): Boolean { + var curFile = file + while (true) { + if (curFile.containsNoMedia()) { + return true + } + curFile = curFile.parentFile + if (curFile.absolutePath == "/") + break + } + return false +} + +private fun isThisOrParentExcluded(path: String, excludedPaths: MutableSet, includedPaths: MutableSet) = + includedPaths.none { path.startsWith(it) } && excludedPaths.any { path.startsWith(it) } + @Suppress("UNCHECKED_CAST") fun Context.getSortedDirectories(source: ArrayList): ArrayList { Directory.sorting = config.directorySorting From 64f8d3754474aee5ad8c672a72b6d57a658f134d Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 25 Sep 2017 23:26:26 +0200 Subject: [PATCH 47/89] fix #370, make sure only the proper items are shown in "All media" view --- .../gallery/asynctasks/GetMediaAsynctask.kt | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetMediaAsynctask.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetMediaAsynctask.kt index 68595ae46..13002eb86 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetMediaAsynctask.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetMediaAsynctask.kt @@ -2,7 +2,9 @@ package com.simplemobiletools.gallery.asynctasks import android.content.Context import android.os.AsyncTask +import com.simplemobiletools.gallery.extensions.config import com.simplemobiletools.gallery.extensions.getFilesFrom +import com.simplemobiletools.gallery.extensions.getMediaByDirectories import com.simplemobiletools.gallery.models.Medium import java.util.* @@ -11,8 +13,19 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickVideo AsyncTask>() { override fun doInBackground(vararg params: Void): ArrayList { - val path = if (showAll) "" else mPath - return context.getFilesFrom(path, isPickImage, isPickVideo) + return if (showAll) { + val mediaMap = context.getMediaByDirectories(isPickVideo, isPickImage) + val media = ArrayList() + for ((path, curMedia) in mediaMap) { + media.addAll(curMedia) + } + + Medium.sorting = context.config.getFileSorting("") + media.sort() + media + } else { + context.getFilesFrom(mPath, isPickImage, isPickVideo) + } } override fun onPostExecute(media: ArrayList) { From 80f6df5e2958337ac9fd806985508e716a1af900 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 25 Sep 2017 23:53:15 +0200 Subject: [PATCH 48/89] do not autosave rotated images, related to #372 --- app/build.gradle | 2 +- .../gallery/activities/ViewPagerActivity.kt | 35 +++---------------- 2 files changed, 5 insertions(+), 32 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index c50f15187..1dbbd4cac 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -37,7 +37,7 @@ android { } dependencies { - compile 'com.simplemobiletools:commons:2.28.4' + compile 'com.simplemobiletools:commons:2.28.5' compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0' compile 'com.theartofdev.edmodo:android-image-cropper:2.4.0' compile 'com.bignerdranch.android:recyclerview-multiselect:0.2' diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index 468e2d69c..8b1150d40 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -434,34 +434,6 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } private fun rotateImage() { - val currentMedium = getCurrentMedium() ?: return - if (currentMedium.isJpg() && !isPathOnSD(currentMedium.path)) { - rotateByExif() - } else { - rotateByDegrees() - } - } - - private fun rotateByExif() { - val exif = ExifInterface(getCurrentPath()) - val orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL) - val newOrientation = getNewOrientation(orientation) - exif.setAttribute(ExifInterface.TAG_ORIENTATION, newOrientation) - exif.saveAttributes() - File(getCurrentPath()).setLastModified(System.currentTimeMillis()) - (getCurrentFragment() as? PhotoFragment)?.refreshBitmap() - } - - private fun getNewOrientation(rotation: Int): String { - return when (rotation) { - ExifInterface.ORIENTATION_ROTATE_90 -> ExifInterface.ORIENTATION_ROTATE_180 - ExifInterface.ORIENTATION_ROTATE_180 -> ExifInterface.ORIENTATION_ROTATE_270 - ExifInterface.ORIENTATION_ROTATE_270 -> ExifInterface.ORIENTATION_NORMAL - else -> ExifInterface.ORIENTATION_ROTATE_90 - }.toString() - } - - private fun rotateByDegrees() { mRotationDegrees = (mRotationDegrees + 90) % 360 getCurrentFragment()?.let { (it as? PhotoFragment)?.rotateImageViewBy(mRotationDegrees) @@ -475,7 +447,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View Thread({ toast(R.string.saving) val selectedFile = File(it) - val tmpFile = File(selectedFile.parent, "tmp_${it.getFilenameFromPath()}") + val tmpFile = File(selectedFile.parent, ".tmp_${it.getFilenameFromPath()}") try { val bitmap = BitmapFactory.decodeFile(currPath) getFileOutputStream(tmpFile) { @@ -498,7 +470,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View toast(R.string.out_of_memory_error) deleteFile(tmpFile) {} } catch (e: Exception) { - toast(R.string.unknown_error_occurred) + showErrorToast(e) deleteFile(tmpFile) {} } }).start() @@ -513,9 +485,10 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View out.flush() out.close() toast(R.string.file_saved) + mRotationDegrees = 0f + invalidateOptionsMenu() } - private fun isShowHiddenFlagNeeded(): Boolean { val file = File(mPath) if (file.isHidden) From dfdfd8894125060cef4ba8e78f11a160e29f8770 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 27 Sep 2017 21:50:42 +0200 Subject: [PATCH 49/89] fix #181, add fingerprint protection to hidden folder showing --- app/build.gradle | 2 +- app/src/main/kotlin/com/simplemobiletools/gallery/App.kt | 2 ++ .../simplemobiletools/gallery/activities/SettingsActivity.kt | 5 ++++- .../kotlin/com/simplemobiletools/gallery/models/Directory.kt | 2 +- .../kotlin/com/simplemobiletools/gallery/models/Medium.kt | 2 +- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 1dbbd4cac..697211b8f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -37,7 +37,7 @@ android { } dependencies { - compile 'com.simplemobiletools:commons:2.28.5' + compile 'com.simplemobiletools:commons:2.28.7' compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0' compile 'com.theartofdev.edmodo:android-image-cropper:2.4.0' compile 'com.bignerdranch.android:recyclerview-multiselect:0.2' diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/App.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/App.kt index 4cbda3237..48ef23b19 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/App.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/App.kt @@ -1,12 +1,14 @@ package com.simplemobiletools.gallery import android.app.Application +import com.github.ajalt.reprint.core.Reprint import com.squareup.leakcanary.LeakCanary class App : Application() { val USE_LEAK_CANARY = false override fun onCreate() { super.onCreate() + Reprint.initialize(this) if (USE_LEAK_CANARY) { if (LeakCanary.isInAnalyzerProcess(this)) { return diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt index 92329d023..8ba896f00 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt @@ -8,6 +8,7 @@ import com.simplemobiletools.commons.dialogs.RadioGroupDialog import com.simplemobiletools.commons.dialogs.SecurityDialog import com.simplemobiletools.commons.extensions.handleHiddenFolderPasswordProtection import com.simplemobiletools.commons.extensions.updateTextColors +import com.simplemobiletools.commons.helpers.PROTECTION_FINGERPRINT import com.simplemobiletools.commons.helpers.SHOW_ALL_TABS import com.simplemobiletools.commons.models.RadioItem import com.simplemobiletools.gallery.R @@ -169,7 +170,9 @@ class SettingsActivity : SimpleActivity() { config.protectionType = type if (config.isPasswordProtectionOn) { - ConfirmationDialog(this, "", R.string.protection_setup_successfully, R.string.ok, 0) { } + val confirmationTextId = if (config.protectionType == PROTECTION_FINGERPRINT) + R.string.fingerprint_setup_successfully else R.string.protection_setup_successfully + ConfirmationDialog(this, "", confirmationTextId, R.string.ok, 0) { } } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/models/Directory.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/models/Directory.kt index ec877c43c..7271dc2e8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/models/Directory.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/models/Directory.kt @@ -17,7 +17,7 @@ data class Directory(val path: String, val tmb: String, val name: String, var me override fun compareTo(other: Directory): Int { var result: Int when { - sorting and SORT_BY_NAME != 0 -> result = AlphanumComparator().compare(name.toLowerCase(), other.name.toLowerCase()) + sorting and SORT_BY_NAME != 0 -> result = AlphanumericComparator().compare(name.toLowerCase(), other.name.toLowerCase()) sorting and SORT_BY_SIZE != 0 -> result = when { size == other.size -> 0 size > other.size -> 1 diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/models/Medium.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/models/Medium.kt index a04a39aa9..fadf715ea 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/models/Medium.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/models/Medium.kt @@ -26,7 +26,7 @@ data class Medium(var name: String, var path: String, val video: Boolean, val mo override fun compareTo(other: Medium): Int { var result: Int when { - sorting and SORT_BY_NAME != 0 -> result = AlphanumComparator().compare(name.toLowerCase(), other.name.toLowerCase()) + sorting and SORT_BY_NAME != 0 -> result = AlphanumericComparator().compare(name.toLowerCase(), other.name.toLowerCase()) sorting and SORT_BY_SIZE != 0 -> result = when { size == other.size -> 0 size > other.size -> 1 From 373e06c98fbca38e0ef2969586846e48c341fd5e Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 27 Sep 2017 23:10:14 +0200 Subject: [PATCH 50/89] ignore the root folders at fetching media --- .../gallery/extensions/context.kt | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt index 095d8f348..e22a90243 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt @@ -89,8 +89,8 @@ fun Context.getFilesFrom(curPath: String, isPickImage: Boolean, isPickVideo: Boo MediaStore.Images.Media.DATA, MediaStore.Images.Media.SIZE) val uri = MediaStore.Files.getContentUri("external") - val selection = if (curPath.isEmpty()) null else "(${MediaStore.Images.Media.DATA} LIKE ? AND ${MediaStore.Images.Media.DATA} NOT LIKE ?)" - val selectionArgs = if (curPath.isEmpty()) null else arrayOf("$curPath/%", "$curPath/%/%") + val selection = getSelectionQuery(curPath) + val selectionArgs = getSelectionArgsQuery(curPath) return try { val cur = contentResolver.query(uri, projection, selection, selectionArgs, getSortingForFolder(curPath)) @@ -100,6 +100,27 @@ fun Context.getFilesFrom(curPath: String, isPickImage: Boolean, isPickVideo: Boo } } +fun Context.getSelectionQuery(path: String): String { + val dataQuery = "${MediaStore.Images.Media.DATA} LIKE ?" + return if (path.isEmpty()) { + var query = "($dataQuery)" + if (hasExternalSDCard()) { + query += " OR ($dataQuery)" + } + query + } else { + "($dataQuery AND ${MediaStore.Images.Media.DATA} NOT LIKE ?)" + } +} + +fun Context.getSelectionArgsQuery(path: String): Array { + return if (path.isEmpty()) { + if (hasExternalSDCard()) arrayOf("$internalStoragePath/%", "$sdCardPath/%") else arrayOf("$internalStoragePath/%") + } else { + arrayOf("$path/%", "$path/%/%") + } +} + private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isPickVideo: Boolean, curPath: String): ArrayList { val curMedia = ArrayList() val config = context.config From 33a4b81279dc632a2ab4c1d92d22a0385210aab2 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 27 Sep 2017 23:58:30 +0200 Subject: [PATCH 51/89] replace lastModified mediaitem checking with latest media date taken --- app/build.gradle | 2 +- .../gallery/activities/MainActivity.kt | 10 +++++----- .../gallery/activities/MediaActivity.kt | 10 +++++----- .../gallery/extensions/context.kt | 16 ---------------- 4 files changed, 11 insertions(+), 27 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 697211b8f..1b8f6288b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -37,7 +37,7 @@ android { } dependencies { - compile 'com.simplemobiletools:commons:2.28.7' + compile 'com.simplemobiletools:commons:2.28.9' compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0' compile 'com.theartofdev.edmodo:android-image-cropper:2.4.0' compile 'com.bignerdranch.android:recyclerview-multiselect:0.2' 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 35deec3c1..b7227be6e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -56,7 +56,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { private var mStoredCropThumbnails = true private var mStoredScrollHorizontally = true private var mLoadedInitialPhotos = false - private var mLastMediaModified = 0 + private var mLatestMediaId = 0L private var mLastMediaHandler = Handler() private var mCurrAsyncTask: GetDirectoriesAsynctask? = null @@ -428,7 +428,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { private fun gotDirectories(newDirs: ArrayList, isFromCache: Boolean) { val dirs = getSortedDirectories(newDirs) - mLastMediaModified = getLastMediaModified() + mLatestMediaId = getLatestMediaId() directories_refresh_layout.isRefreshing = false mIsGettingDirs = false @@ -491,9 +491,9 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { mLastMediaHandler.removeCallbacksAndMessages(null) mLastMediaHandler.postDelayed({ Thread({ - val lastModified = getLastMediaModified() - if (mLastMediaModified != lastModified) { - mLastMediaModified = lastModified + val mediaId = getLatestMediaId() + if (mLatestMediaId != mediaId) { + mLatestMediaId = mediaId runOnUiThread { getDirectories() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index 67765fab8..8be958661 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -51,7 +51,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { private var mStoredCropThumbnails = true private var mStoredScrollHorizontally = true private var mLastDrawnHashCode = 0 - private var mLastMediaModified = 0 + private var mLatestMediaId = 0L private var mLastMediaHandler = Handler() companion object { @@ -181,9 +181,9 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { mLastMediaHandler.removeCallbacksAndMessages(null) mLastMediaHandler.postDelayed({ Thread({ - val lastModified = getLastMediaModified() - if (mLastMediaModified != lastModified) { - mLastMediaModified = lastModified + val mediaId = getLatestMediaId() + if (mLatestMediaId != mediaId) { + mLatestMediaId = mediaId runOnUiThread { getMedia() } @@ -463,7 +463,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { } private fun gotMedia(media: ArrayList, isFromCache: Boolean = false) { - mLastMediaModified = getLastMediaModified() + mLatestMediaId = getLatestMediaId() mIsGettingMedia = false media_refresh_layout.isRefreshing = false diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt index e22a90243..ac943fe25 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt @@ -300,22 +300,6 @@ fun Context.getNoMediaFolders(): ArrayList { return folders } -fun Context.getLastMediaModified(): Int { - val max = "max" - val uri = MediaStore.Files.getContentUri("external") - val projection = arrayOf(MediaStore.Images.Media._ID, "MAX(${MediaStore.Images.Media.DATE_MODIFIED}) AS $max") - var cursor: Cursor? = null - try { - cursor = contentResolver.query(uri, projection, null, null, null) - if (cursor?.moveToFirst() == true) { - return cursor.getIntValue(max) - } - } finally { - cursor?.close() - } - return 0 -} - fun Context.movePinnedDirectoriesToFront(dirs: ArrayList): ArrayList { val foundFolders = ArrayList() val pinnedFolders = config.pinnedFolders From fc3565129d4c0afb65a426d90f38ae67db6701a6 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 28 Sep 2017 21:04:24 +0200 Subject: [PATCH 52/89] add the dialogs for changing the view type --- .../gallery/activities/MainActivity.kt | 13 +++++++++++++ .../gallery/activities/MediaActivity.kt | 13 +++++++++++++ .../com/simplemobiletools/gallery/helpers/Config.kt | 8 ++++++++ .../simplemobiletools/gallery/helpers/Constants.kt | 6 ++++++ app/src/main/res/menu/menu_main.xml | 4 ++++ app/src/main/res/menu/menu_media.xml | 4 ++++ app/src/main/res/values-ca/strings.xml | 5 +++++ app/src/main/res/values-cs/strings.xml | 5 +++++ app/src/main/res/values-de/strings.xml | 5 +++++ app/src/main/res/values-es/strings.xml | 5 +++++ app/src/main/res/values-fr/strings.xml | 5 +++++ app/src/main/res/values-hu/strings.xml | 5 +++++ app/src/main/res/values-it/strings.xml | 5 +++++ app/src/main/res/values-ja/strings.xml | 5 +++++ app/src/main/res/values-pl/strings.xml | 5 +++++ app/src/main/res/values-pt-rBR/strings.xml | 5 +++++ app/src/main/res/values-pt/strings.xml | 5 +++++ app/src/main/res/values-ru/strings.xml | 5 +++++ app/src/main/res/values-sk/strings.xml | 5 +++++ app/src/main/res/values-sv/strings.xml | 5 +++++ app/src/main/res/values-tr/strings.xml | 5 +++++ app/src/main/res/values-zh-rCN/strings.xml | 5 +++++ app/src/main/res/values-zh-rTW/strings.xml | 5 +++++ app/src/main/res/values/strings.xml | 5 +++++ 24 files changed, 138 insertions(+) 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 b7227be6e..e9dc6255a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -18,9 +18,11 @@ import android.widget.FrameLayout import com.google.gson.Gson import com.simplemobiletools.commons.dialogs.CreateNewFolderDialog import com.simplemobiletools.commons.dialogs.FilePickerDialog +import com.simplemobiletools.commons.dialogs.RadioGroupDialog import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.SORT_BY_DATE_MODIFIED import com.simplemobiletools.commons.helpers.SORT_BY_DATE_TAKEN +import com.simplemobiletools.commons.models.RadioItem import com.simplemobiletools.commons.models.Release import com.simplemobiletools.commons.views.MyScalableRecyclerView import com.simplemobiletools.gallery.BuildConfig @@ -107,6 +109,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { R.id.filter -> showFilterMediaDialog() R.id.open_camera -> launchCamera() R.id.show_all -> showAllMedia() + R.id.change_view_type -> changeViewType() R.id.temporarily_show_hidden -> tryToggleTemporarilyShowHidden() R.id.stop_showing_hidden -> tryToggleTemporarilyShowHidden() R.id.create_new_folder -> createNewFolder() @@ -245,6 +248,16 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { finish() } + private fun changeViewType() { + val items = arrayListOf( + RadioItem(VIEW_TYPE_GRID, getString(R.string.grid)), + RadioItem(VIEW_TYPE_LIST, getString(R.string.list))) + + RadioGroupDialog(this, items, config.viewTypeFolders) { + config.viewTypeFolders = it as Int + } + } + private fun tryToggleTemporarilyShowHidden() { if (config.temporarilyShowHidden) { toggleTemporarilyShowHidden(false) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index 8be958661..f02a18cfa 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -20,7 +20,9 @@ import com.bumptech.glide.request.transition.Transition import com.google.gson.Gson import com.google.gson.reflect.TypeToken import com.simplemobiletools.commons.dialogs.ConfirmationDialog +import com.simplemobiletools.commons.dialogs.RadioGroupDialog import com.simplemobiletools.commons.extensions.* +import com.simplemobiletools.commons.models.RadioItem import com.simplemobiletools.commons.views.MyScalableRecyclerView import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.adapters.MediaAdapter @@ -223,6 +225,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { R.id.toggle_filename -> toggleFilenameVisibility() R.id.open_camera -> launchCamera() R.id.folder_view -> switchToFolderView() + R.id.change_view_type -> changeViewType() R.id.hide_folder -> tryHideFolder() R.id.unhide_folder -> unhideFolder() R.id.exclude_folder -> tryExcludeFolder() @@ -262,6 +265,16 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { finish() } + private fun changeViewType() { + val items = arrayListOf( + RadioItem(VIEW_TYPE_GRID, getString(R.string.grid)), + RadioItem(VIEW_TYPE_LIST, getString(R.string.list))) + + RadioGroupDialog(this, items, config.viewTypeFiles) { + config.viewTypeFiles = it as Int + } + } + private fun tryHideFolder() { if (config.wasHideFolderTooltipShown) { hideFolder() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt index 5cd08be16..26f679028 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt @@ -280,4 +280,12 @@ class Config(context: Context) : BaseConfig(context) { var tempFolderPath: String get() = prefs.getString(TEMP_FOLDER_PATH, "") set(tempFolderPath) = prefs.edit().putString(TEMP_FOLDER_PATH, tempFolderPath).apply() + + var viewTypeFolders: Int + get() = prefs.getInt(VIEW_TYPE_FOLDERS, VIEW_TYPE_GRID) + set(viewTypeFolders) = prefs.edit().putInt(VIEW_TYPE_FOLDERS, viewTypeFolders).apply() + + var viewTypeFiles: Int + get() = prefs.getInt(VIEW_TYPE_FILES, VIEW_TYPE_GRID) + set(viewTypeFiles) = prefs.edit().putInt(VIEW_TYPE_FILES, viewTypeFiles).apply() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt index 705c91d76..691031eb3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt @@ -37,6 +37,8 @@ val REPLACE_SHARE_WITH_ROTATE = "replace_share_with_rotate" val DELETE_EMPTY_FOLDERS = "delete_empty_folders" val ALLOW_VIDEO_GESTURES = "allow_video_gestures" val TEMP_FOLDER_PATH = "temp_folder_path" +val VIEW_TYPE_FOLDERS = "view_type_folders" +val VIEW_TYPE_FILES = "view_type_files" // slideshow val SLIDESHOW_INTERVAL = "slideshow_interval" @@ -77,3 +79,7 @@ val ORIENT_LANDSCAPE_RIGHT = 2 val IMAGES = 1 val VIDEOS = 2 val GIFS = 4 + +// view types +val VIEW_TYPE_GRID = 1 +val VIEW_TYPE_LIST = 2 diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index e94eacea7..b1a4035e7 100644 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -16,6 +16,10 @@ android:icon="@drawable/ic_filter" android:title="@string/filter_media" app:showAsAction="ifRoom"/> + + The slideshow ended No media for the slideshow have been found + + Change view type + Grid + List + Show hidden media Play videos automatically diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index ee99698ff..af7703ab4 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -102,6 +102,11 @@ The slideshow ended No media for the slideshow have been found + + Change view type + Grid + List + Zobrazit skryté média Automaticky přehrávat videa diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index f0351f613..96580f927 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -102,6 +102,11 @@ Diashow beendet Keine Medien für Diashow gefunden + + Change view type + Grid + List + Versteckte Ordner zeigen Videos automatisch abspielen diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 6aad7a9c4..5b5350d6c 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -102,6 +102,11 @@ The slideshow ended No media for the slideshow have been found + + Change view type + Grid + List + Mostrar carpetas ocultas Reproducir vídeos automáticamente diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index cb8271195..ca60589f2 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -102,6 +102,11 @@ Diaporama terminé Aucun média trouvé pour le diaporama + + Change view type + Grid + List + Afficher les dossiers cachés Lecture automatique des vidéos diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index 70e9df0c8..c42d41e12 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -102,6 +102,11 @@ The slideshow ended No media for the slideshow have been found + + Change view type + Grid + List + Show hidden media Play videos automatically diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 725bdbf01..e77d073ef 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -102,6 +102,11 @@ La presentazione è terminata Nessun media trovato per la presentazione + + Change view type + Grid + List + Mostra cartelle nascoste Riproduci video automaticamente diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index d9af73f59..ef90a0d11 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -102,6 +102,11 @@ スライドショーが終了しました スライドショーに表示するメディアがありません + + Change view type + Grid + List + 非表示フォルダーを表示 ビデオを自動再生する diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 7b9f6575f..0c8b066f8 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -102,6 +102,11 @@ Pokaz slajdów zakończony Nie znalazłem multimediów do pokazu slajdów + + Change view type + Grid + List + Pokazuj ukryte foldery Odtwarzaj filmy automatycznie diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 3c4b4032f..e549de037 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -102,6 +102,11 @@ The slideshow ended No media for the slideshow have been found + + Change view type + Grid + List + Mostrar pastas ocultas Reproduzir vídeos automaticamente diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index d0869b9c2..5128dfaf4 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -102,6 +102,11 @@ Apresentação terminada Não foram encontrados ficheiros para a apresentação + + Change view type + Grid + List + Mostrar pastas ocultas Reproduzir vídeos automaticamente diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 1576a4b44..f0ff4a8df 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -102,6 +102,11 @@ Слайдшоу завершилось Никаких медиафайлов для слайдшоу не было найдено. + + Change view type + Grid + List + Показать скрытые папки Воспроизводить видео автоматически diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index 0d7fe9f86..89a8fe5bb 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -102,6 +102,11 @@ Prezentácia skončila Pre prezentáciu sa nenašli žiadne vhodné súbory + + Zmeniť typ zobrazenia + Mriežka + Zoznam + Zobraziť skryté médiá Spúšťať videá automaticky diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index aa1fea2ec..834755adf 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -102,6 +102,11 @@ Bildspelet har avslutats Ingen media hittades för bildspelet + + Change view type + Grid + List + Visa dolda mappar Spela upp videos automatiskt diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index ded134a6d..e98004c41 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -102,6 +102,11 @@ The slideshow ended No media for the slideshow have been found + + Change view type + Grid + List + Gizli klasörleri göster Videoları otomatik olarak oynat diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index ccbd2c8cd..1b6a61f9e 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -102,6 +102,11 @@ 幻灯片结束 未发现可用媒体 + + Change view type + Grid + List + 显示所有 自动播放 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index a2b80e15e..6f7ec0dc1 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -102,6 +102,11 @@ 投影片結束 找不到投影片的媒體檔案 + + Change view type + Grid + List + 顯示隱藏的媒體檔案 自動播放影片 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 13d30d4ba..ddc156702 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -102,6 +102,11 @@ The slideshow ended No media for the slideshow have been found + + Change view type + Grid + List + Show hidden media Play videos automatically From 9c5c359e4d780f419b01360e999a91e75f324837 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 28 Sep 2017 21:28:42 +0200 Subject: [PATCH 53/89] rename directory_item to directory_item_grid --- .../simplemobiletools/gallery/adapters/DirectoryAdapter.kt | 4 ++-- .../layout/{directory_item.xml => directory_item_grid.xml} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename app/src/main/res/layout/{directory_item.xml => directory_item_grid.xml} (100%) 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 c7e3dcbbf..49ac1c739 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -22,7 +22,7 @@ import com.simplemobiletools.gallery.dialogs.PickMediumDialog import com.simplemobiletools.gallery.extensions.* import com.simplemobiletools.gallery.models.AlbumCover import com.simplemobiletools.gallery.models.Directory -import kotlinx.android.synthetic.main.directory_item.view.* +import kotlinx.android.synthetic.main.directory_item_grid.view.* import java.io.File import java.util.* @@ -330,7 +330,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList Date: Thu, 28 Sep 2017 21:48:08 +0200 Subject: [PATCH 54/89] minor code style updates --- .../gallery/activities/MainActivity.kt | 2 +- .../gallery/activities/MediaActivity.kt | 2 +- .../gallery/adapters/DirectoryAdapter.kt | 24 ++--- .../gallery/adapters/MediaAdapter.kt | 20 ++-- .../main/res/layout/directory_item_list.xml | 93 +++++++++++++++++++ 5 files changed, 113 insertions(+), 28 deletions(-) create mode 100644 app/src/main/res/layout/directory_item_list.xml 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 e9dc6255a..6cc80922d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -135,7 +135,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { if (mStoredScrollHorizontally != config.scrollHorizontally) { directories_grid.adapter?.let { - (it as DirectoryAdapter).scrollVertically = !config.scrollHorizontally + (it as DirectoryAdapter).scrollVertically = config.viewTypeFolders == VIEW_TYPE_LIST || !config.scrollHorizontally it.notifyDataSetChanged() } setupScrollDirection() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index f02a18cfa..95e18c854 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -95,7 +95,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { if (mStoredScrollHorizontally != config.scrollHorizontally) { media_grid.adapter?.let { - (it as MediaAdapter).scrollVertically = !config.scrollHorizontally + (it as MediaAdapter).scrollVertically = config.viewTypeFiles == VIEW_TYPE_LIST || !config.scrollHorizontally it.notifyDataSetChanged() } setupScrollDirection() 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 49ac1c739..e9e01d93d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -56,12 +56,12 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList = selectedPositions } - val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) { + private val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) { override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean { when (item.itemId) { R.id.cab_properties -> showProperties() @@ -119,7 +119,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList() - var curIndex = 0 - for (i in 0..itemViews.size() - 1) { - if (itemViews[i] != null) { - newItems.put(curIndex, itemViews[i]) - curIndex++ - } - } + (0 until itemViews.size()) + .filter { itemViews[it] != null } + .forEachIndexed { curIndex, i -> newItems.put(curIndex, itemViews[i]) } itemViews = newItems } @@ -330,7 +326,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList, updateTitle(selectedPositions.size) } - fun updateTitle(cnt: Int) { + private fun updateTitle(cnt: Int) { actMode?.title = "$cnt / ${media.size}" actMode?.invalidate() } - val adapterListener = object : MyAdapterListener { + private val adapterListener = object : MyAdapterListener { override fun toggleItemSelectionAdapter(select: Boolean, position: Int) { toggleItemSelection(select, position) } @@ -66,7 +66,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, override fun getSelectedPositions(): HashSet = selectedPositions } - val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) { + private val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) { override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean { when (item.itemId) { R.id.cab_properties -> showProperties() @@ -112,7 +112,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, fun checkHideBtnVisibility(menu: Menu) { var hiddenCnt = 0 var unhiddenCnt = 0 - selectedPositions.map { media.getOrNull(it) }.filterNotNull().forEach { + selectedPositions.mapNotNull { media.getOrNull(it) }.forEach { if (it.name.startsWith('.')) hiddenCnt++ else @@ -184,7 +184,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, fun selectAll() { val cnt = media.size - for (i in 0..cnt - 1) { + for (i in 0 until cnt) { selectedPositions.add(i) multiSelector.setSelected(i, 0, true) notifyItemChanged(i) @@ -227,13 +227,9 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, listener?.deleteFiles(files) val newItems = SparseArray() - var curIndex = 0 - for (i in 0..itemViews.size() - 1) { - if (itemViews[i] != null) { - newItems.put(curIndex, itemViews[i]) - curIndex++ - } - } + (0 until itemViews.size()) + .filter { itemViews[it] != null } + .forEachIndexed { curIndex, i -> newItems.put(curIndex, itemViews[i]) } itemViews = newItems } diff --git a/app/src/main/res/layout/directory_item_list.xml b/app/src/main/res/layout/directory_item_list.xml new file mode 100644 index 000000000..6903b7f46 --- /dev/null +++ b/app/src/main/res/layout/directory_item_list.xml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + From 5e733a44c342770afcf8e96b57ec24d1e6d5f326 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 28 Sep 2017 21:51:14 +0200 Subject: [PATCH 55/89] use the directory grid view by default --- .../com/simplemobiletools/gallery/activities/MediaActivity.kt | 1 - .../com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index 95e18c854..9778bd761 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -38,7 +38,6 @@ import java.io.File import java.io.IOException class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { - private val TAG = MediaActivity::class.java.simpleName private val SAVE_MEDIA_CNT = 40 private val LAST_MEDIA_CHECK_PERIOD = 3000L 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 e9e01d93d..6a7d4874e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -326,7 +326,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList Date: Thu, 28 Sep 2017 21:55:33 +0200 Subject: [PATCH 56/89] hide the menu buttons for changing column count at list views --- .../com/simplemobiletools/gallery/activities/MainActivity.kt | 5 +++-- .../simplemobiletools/gallery/activities/MediaActivity.kt | 5 +++-- 2 files changed, 6 insertions(+), 4 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 6cc80922d..9799dd666 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -95,8 +95,8 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { menuInflater.inflate(R.menu.menu_main_intent, menu) } else { menuInflater.inflate(R.menu.menu_main, menu) - menu.findItem(R.id.increase_column_count).isVisible = config.dirColumnCnt < 10 - menu.findItem(R.id.reduce_column_count).isVisible = config.dirColumnCnt > 1 + menu.findItem(R.id.increase_column_count).isVisible = config.viewTypeFolders == VIEW_TYPE_GRID && config.dirColumnCnt < 10 + menu.findItem(R.id.reduce_column_count).isVisible = config.viewTypeFolders == VIEW_TYPE_GRID && config.dirColumnCnt > 1 } menu.findItem(R.id.temporarily_show_hidden).isVisible = !config.shouldShowHidden menu.findItem(R.id.stop_showing_hidden).isVisible = config.temporarilyShowHidden @@ -255,6 +255,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { RadioGroupDialog(this, items, config.viewTypeFolders) { config.viewTypeFolders = it as Int + invalidateOptionsMenu() } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index 9778bd761..47eff4f7c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -210,8 +210,8 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { findItem(R.id.temporarily_show_hidden).isVisible = !config.shouldShowHidden findItem(R.id.stop_showing_hidden).isVisible = config.temporarilyShowHidden - findItem(R.id.increase_column_count).isVisible = config.mediaColumnCnt < 10 - findItem(R.id.reduce_column_count).isVisible = config.mediaColumnCnt > 1 + findItem(R.id.increase_column_count).isVisible = config.viewTypeFiles == VIEW_TYPE_GRID && config.mediaColumnCnt < 10 + findItem(R.id.reduce_column_count).isVisible = config.viewTypeFiles == VIEW_TYPE_GRID && config.mediaColumnCnt > 1 } return true @@ -271,6 +271,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { RadioGroupDialog(this, items, config.viewTypeFiles) { config.viewTypeFiles = it as Int + invalidateOptionsMenu() } } From c9e355eecfdca974b6ad8d66c501a9d65b378e2a Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 28 Sep 2017 23:17:53 +0200 Subject: [PATCH 57/89] adding an initial implementation of directory_item_list --- .../gallery/activities/MainActivity.kt | 17 +++- .../main/res/layout/directory_item_list.xml | 80 +++++++------------ app/src/main/res/values/dimens.xml | 1 + 3 files changed, 46 insertions(+), 52 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 9799dd666..4380187b1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -181,7 +181,12 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { showAllMedia() else getDirectories() - setupLayoutManager() + + if (config.viewTypeFolders == VIEW_TYPE_GRID) + setupGridLayoutManager() + else + setupListLayoutManager() + checkIfColorChanged() } else { ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE), STORAGE_PERMISSION) @@ -295,7 +300,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { private fun getRecyclerAdapter() = (directories_grid.adapter as DirectoryAdapter) - private fun setupLayoutManager() { + private fun setupGridLayoutManager() { val layoutManager = directories_grid.layoutManager as GridLayoutManager if (config.scrollHorizontally) { layoutManager.orientation = GridLayoutManager.HORIZONTAL @@ -333,6 +338,14 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { } } + private fun setupListLayoutManager() { + directories_grid.isDragSelectionEnabled = true + directories_grid.isZoomingEnabled = false + + val layoutManager = directories_grid.layoutManager as GridLayoutManager + layoutManager.spanCount = 1 + } + private fun createNewFolder() { FilePickerDialog(this, internalStoragePath, false, config.shouldShowHidden) { CreateNewFolderDialog(this, it) { diff --git a/app/src/main/res/layout/directory_item_list.xml b/app/src/main/res/layout/directory_item_list.xml index 6903b7f46..3f282976f 100644 --- a/app/src/main/res/layout/directory_item_list.xml +++ b/app/src/main/res/layout/directory_item_list.xml @@ -4,12 +4,13 @@ android:id="@+id/dir_holder" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:padding="1px"> + android:paddingLeft="@dimen/small_margin" + android:paddingTop="@dimen/small_margin"> + android:layout_width="@dimen/list_view_folder_thumbnail_size" + android:layout_height="@dimen/list_view_folder_thumbnail_size"/> + + + + - - - - - - - - - - 24dp 50dp 150dp + 72dp From 2ee425e21d7cc09c95e3eb7c189f597ffb384492 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 29 Sep 2017 20:24:35 +0200 Subject: [PATCH 58/89] couple UI updates to the directory list view --- .../main/res/layout/directory_item_list.xml | 47 ++++++++++--------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/app/src/main/res/layout/directory_item_list.xml b/app/src/main/res/layout/directory_item_list.xml index 3f282976f..2588e528f 100644 --- a/app/src/main/res/layout/directory_item_list.xml +++ b/app/src/main/res/layout/directory_item_list.xml @@ -31,10 +31,10 @@ android:layout_toRightOf="@+id/dir_thumbnail" android:ellipsize="end" android:maxLines="1" - android:paddingLeft="@dimen/small_margin" - android:paddingRight="@dimen/small_margin" + android:paddingLeft="6dp" + android:paddingRight="6dp" android:textColor="@android:color/white" - android:textSize="@dimen/normal_text_size"/> + android:textSize="@dimen/bigger_text_size"/> - + android:layout_marginRight="@dimen/small_margin" + android:gravity="end" + android:orientation="horizontal"> - + + + From da00ed8422e1096c3e7403d72edefdc018deb936 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 29 Sep 2017 21:31:12 +0200 Subject: [PATCH 59/89] add a divider between folders --- .../gallery/adapters/DirectoryAdapter.kt | 5 ++++- app/src/main/res/layout/directory_item_list.xml | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) 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 6a7d4874e..098aa11b9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -20,6 +20,7 @@ import com.simplemobiletools.gallery.activities.SimpleActivity import com.simplemobiletools.gallery.dialogs.ExcludeFolderDialog import com.simplemobiletools.gallery.dialogs.PickMediumDialog import com.simplemobiletools.gallery.extensions.* +import com.simplemobiletools.gallery.helpers.VIEW_TYPE_LIST import com.simplemobiletools.gallery.models.AlbumCover import com.simplemobiletools.gallery.models.Directory import kotlinx.android.synthetic.main.directory_item_grid.view.* @@ -31,6 +32,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList() @@ -326,7 +328,8 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList + + + From 9947d661a3345b4e21bab2429a01dc4186ea3295 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 29 Sep 2017 21:47:27 +0200 Subject: [PATCH 60/89] refresh the folders at changing view type --- .../gallery/activities/MainActivity.kt | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 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 4380187b1..57d7dff6c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -182,11 +182,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { else getDirectories() - if (config.viewTypeFolders == VIEW_TYPE_GRID) - setupGridLayoutManager() - else - setupListLayoutManager() - + setupLayoutManager() checkIfColorChanged() } else { ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE), STORAGE_PERMISSION) @@ -261,6 +257,9 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { RadioGroupDialog(this, items, config.viewTypeFolders) { config.viewTypeFolders = it as Int invalidateOptionsMenu() + setupLayoutManager() + directories_grid.adapter = null + setupAdapter() } } @@ -300,6 +299,13 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { private fun getRecyclerAdapter() = (directories_grid.adapter as DirectoryAdapter) + private fun setupLayoutManager() { + if (config.viewTypeFolders == VIEW_TYPE_GRID) + setupGridLayoutManager() + else + setupListLayoutManager() + } + private fun setupGridLayoutManager() { val layoutManager = directories_grid.layoutManager as GridLayoutManager if (config.scrollHorizontally) { From d7eaaa070dcff34b244fa3622fb4afd0ab8ab6f4 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 29 Sep 2017 21:57:24 +0200 Subject: [PATCH 61/89] show folder path at the list view --- .../gallery/adapters/DirectoryAdapter.kt | 3 ++- app/src/main/res/layout/directory_item_list.xml | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) 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 098aa11b9..5b0f851bc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -23,7 +23,7 @@ import com.simplemobiletools.gallery.extensions.* import com.simplemobiletools.gallery.helpers.VIEW_TYPE_LIST import com.simplemobiletools.gallery.models.AlbumCover import com.simplemobiletools.gallery.models.Directory -import kotlinx.android.synthetic.main.directory_item_grid.view.* +import kotlinx.android.synthetic.main.directory_item_list.view.* import java.io.File import java.util.* @@ -397,6 +397,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList + + From 216e51beff5a20062b79881f6149ff1f54c36f46 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 29 Sep 2017 22:52:30 +0200 Subject: [PATCH 62/89] rename photo_video_item to photo_video_item_grid --- .../gallery/adapters/DirectoryAdapter.kt | 6 +-- .../gallery/adapters/MediaAdapter.kt | 13 ++--- ...deo_item.xml => photo_video_item_grid.xml} | 0 .../main/res/layout/photo_video_item_list.xml | 53 +++++++++++++++++++ 4 files changed, 62 insertions(+), 10 deletions(-) rename app/src/main/res/layout/{photo_video_item.xml => photo_video_item_grid.xml} (100%) create mode 100644 app/src/main/res/layout/photo_video_item_list.xml 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 5b0f851bc..c70d13194 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -430,10 +430,8 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList= Build.VERSION_CODES.JELLY_BEAN_MR1 && activity.isDestroyed) - return - - Glide.with(activity).clear(view.dir_thumbnail) + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1 || !activity.isDestroyed) + Glide.with(activity).clear(view.dir_thumbnail) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt index 5441df3c2..3c71c7f6c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt @@ -18,8 +18,9 @@ import com.simplemobiletools.commons.extensions.beVisibleIf import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.activities.SimpleActivity import com.simplemobiletools.gallery.extensions.* +import com.simplemobiletools.gallery.helpers.VIEW_TYPE_LIST import com.simplemobiletools.gallery.models.Medium -import kotlinx.android.synthetic.main.photo_video_item.view.* +import kotlinx.android.synthetic.main.photo_video_item_grid.view.* import java.io.File import java.util.* @@ -28,6 +29,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, val multiSelector = MultiSelector() val config = activity.config + val isListViewType = config.viewTypeFiles == VIEW_TYPE_LIST var actMode: ActionMode? = null var itemViews = SparseArray() @@ -242,7 +244,8 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, } override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder { - val view = LayoutInflater.from(parent?.context).inflate(R.layout.photo_video_item, parent, false) + val layoutType = if (isListViewType) R.layout.photo_video_item_list else R.layout.photo_video_item_grid + val view = LayoutInflater.from(parent?.context).inflate(layoutType, parent, false) return ViewHolder(view, adapterListener, activity, multiSelectorMode, multiSelector, listener, isPickIntent, itemClick) } @@ -345,10 +348,8 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, } fun stopLoad() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && activity.isDestroyed) - return - - Glide.with(activity).clear(view.medium_thumbnail) + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1 || !activity.isDestroyed) + Glide.with(activity).clear(view.medium_thumbnail) } } diff --git a/app/src/main/res/layout/photo_video_item.xml b/app/src/main/res/layout/photo_video_item_grid.xml similarity index 100% rename from app/src/main/res/layout/photo_video_item.xml rename to app/src/main/res/layout/photo_video_item_grid.xml diff --git a/app/src/main/res/layout/photo_video_item_list.xml b/app/src/main/res/layout/photo_video_item_list.xml new file mode 100644 index 000000000..a8fdf5d21 --- /dev/null +++ b/app/src/main/res/layout/photo_video_item_list.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + From c8c09e09118beaa9373db614c29ec920a3db96c5 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 29 Sep 2017 23:22:52 +0200 Subject: [PATCH 63/89] add the list view type handling in media activity --- .../gallery/activities/MediaActivity.kt | 20 +++++++ .../gallery/adapters/MediaAdapter.kt | 2 +- .../main/res/layout/directory_item_list.xml | 3 +- .../main/res/layout/photo_video_item_list.xml | 53 +++++++++++-------- app/src/main/res/values/dimens.xml | 1 + 5 files changed, 55 insertions(+), 24 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index 47eff4f7c..66a4eb984 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -212,6 +212,8 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { findItem(R.id.increase_column_count).isVisible = config.viewTypeFiles == VIEW_TYPE_GRID && config.mediaColumnCnt < 10 findItem(R.id.reduce_column_count).isVisible = config.viewTypeFiles == VIEW_TYPE_GRID && config.mediaColumnCnt > 1 + + findItem(R.id.toggle_filename).isVisible = config.viewTypeFiles == VIEW_TYPE_GRID } return true @@ -272,6 +274,9 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { RadioGroupDialog(this, items, config.viewTypeFiles) { config.viewTypeFiles = it as Int invalidateOptionsMenu() + setupLayoutManager() + media_grid.adapter = null + setupAdapter() } } @@ -365,6 +370,13 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { private fun getRecyclerAdapter() = (media_grid.adapter as MediaAdapter) private fun setupLayoutManager() { + if (config.viewTypeFiles == VIEW_TYPE_GRID) + setupGridLayoutManager() + else + setupListLayoutManager() + } + + private fun setupGridLayoutManager() { val layoutManager = media_grid.layoutManager as GridLayoutManager if (config.scrollHorizontally) { layoutManager.orientation = GridLayoutManager.HORIZONTAL @@ -402,6 +414,14 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { } } + private fun setupListLayoutManager() { + media_grid.isDragSelectionEnabled = true + media_grid.isZoomingEnabled = false + + val layoutManager = media_grid.layoutManager as GridLayoutManager + layoutManager.spanCount = 1 + } + private fun increaseColumnCount() { config.mediaColumnCnt = ++(media_grid.layoutManager as GridLayoutManager).spanCount invalidateOptionsMenu() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt index 3c71c7f6c..e89d3b8c4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt @@ -250,7 +250,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, } override fun onBindViewHolder(holder: ViewHolder, position: Int) { - itemViews.put(position, holder.bindView(media[position], displayFilenames, scrollVertically)) + itemViews.put(position, holder.bindView(media[position], displayFilenames || isListViewType, scrollVertically)) toggleItemSelection(selectedPositions.contains(position), position) holder.itemView.tag = holder } diff --git a/app/src/main/res/layout/directory_item_list.xml b/app/src/main/res/layout/directory_item_list.xml index 3ecc8152d..5d5b4c21f 100644 --- a/app/src/main/res/layout/directory_item_list.xml +++ b/app/src/main/res/layout/directory_item_list.xml @@ -69,7 +69,8 @@ android:layout_alignParentRight="true" android:layout_marginRight="@dimen/small_margin" android:gravity="end" - android:orientation="horizontal"> + android:orientation="horizontal" + android:paddingBottom="@dimen/tiny_margin"> + android:paddingLeft="@dimen/small_margin" + android:paddingTop="@dimen/small_margin"> + android:layout_width="@dimen/list_view_folder_thumbnail_size" + android:layout_height="@dimen/list_view_folder_thumbnail_size"/> + + + android:layout_height="1dp" + android:layout_alignBottom="@+id/medium_thumbnail" + android:layout_marginTop="2dp" + android:layout_toRightOf="@+id/medium_thumbnail" + android:background="@drawable/divider"/> diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 0c8d41eea..58e7e8c8e 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -3,6 +3,7 @@ 150dp 100dp 20dp + 22dp 26dp 150dp 24dp From d89ebec57a96c9c88a80d033368e5bcdd60e690f Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 29 Sep 2017 23:28:55 +0200 Subject: [PATCH 64/89] remove a redundant function --- .../simplemobiletools/gallery/fragments/PhotoFragment.kt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt index c3709bd68..108cf9bc9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt @@ -33,7 +33,6 @@ import com.simplemobiletools.gallery.extensions.config import com.simplemobiletools.gallery.extensions.getFileSignature import com.simplemobiletools.gallery.extensions.getRealPathFromURI import com.simplemobiletools.gallery.extensions.portrait -import com.simplemobiletools.gallery.helpers.GlideDecoder import com.simplemobiletools.gallery.helpers.GlideRotateTransformation import com.simplemobiletools.gallery.helpers.MEDIUM import com.simplemobiletools.gallery.models.Medium @@ -254,11 +253,6 @@ class PhotoFragment : ViewPagerFragment() { } } - fun refreshBitmap() { - view.subsampling_view.beGone() - loadBitmap() - } - fun rotateImageViewBy(degrees: Float) { view.subsampling_view.beGone() loadBitmap(degrees) From 1cd68fe9a034eaafb2c5bfb243506e82e2171448 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 29 Sep 2017 23:46:09 +0200 Subject: [PATCH 65/89] color icons and texts in list views appropriately --- .../gallery/adapters/DirectoryAdapter.kt | 11 +++++++++-- .../gallery/adapters/MediaAdapter.kt | 12 +++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) 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 c70d13194..257b94375 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -38,6 +38,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList() val selectedPositions = HashSet() var primaryColor = config.primaryColor + var textColor = config.textColor var pinnedFolders = config.pinnedFolders var scrollVertically = !config.scrollHorizontally @@ -335,7 +336,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList (Unit)) : SwappingHolder(view, MultiSelector()) { - fun bindView(directory: Directory, isPinned: Boolean, scrollVertically: Boolean): View { + fun bindView(directory: Directory, isPinned: Boolean, scrollVertically: Boolean, isListView: Boolean, textColor: Int): View { itemView.apply { dir_name.text = directory.name dir_path?.text = "${directory.path.substringBeforeLast("/")}/" @@ -403,6 +404,12 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList, var itemViews = SparseArray() val selectedPositions = HashSet() var primaryColor = config.primaryColor + var textColor = config.textColor var displayFilenames = config.displayFileNames var scrollVertically = !config.scrollHorizontally @@ -250,7 +251,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, } override fun onBindViewHolder(holder: ViewHolder, position: Int) { - itemViews.put(position, holder.bindView(media[position], displayFilenames || isListViewType, scrollVertically)) + itemViews.put(position, holder.bindView(media[position], displayFilenames, scrollVertically, isListViewType, textColor)) toggleItemSelection(selectedPositions.contains(position), position) holder.itemView.tag = holder } @@ -314,13 +315,18 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, class ViewHolder(val view: View, val adapterListener: MyAdapterListener, val activity: SimpleActivity, val multiSelectorCallback: ModalMultiSelectorCallback, val multiSelector: MultiSelector, val listener: MediaOperationsListener?, val isPickIntent: Boolean, val itemClick: (Medium) -> (Unit)) : SwappingHolder(view, MultiSelector()) { - fun bindView(medium: Medium, displayFilenames: Boolean, scrollVertically: Boolean): View { + fun bindView(medium: Medium, displayFilenames: Boolean, scrollVertically: Boolean, isListViewType: Boolean, textColor: Int): View { itemView.apply { play_outline.visibility = if (medium.video) View.VISIBLE else View.GONE - photo_name.beVisibleIf(displayFilenames) + photo_name.beVisibleIf(displayFilenames || isListViewType) photo_name.text = medium.name activity.loadImage(medium.path, medium_thumbnail, scrollVertically) + if (isListViewType) { + photo_name.setTextColor(textColor) + play_outline.setColorFilter(textColor, PorterDuff.Mode.SRC_IN) + } + setOnClickListener { viewClicked(medium) } setOnLongClickListener { if (isPickIntent) viewClicked(medium) else viewLongClicked(); true } } From 99da56deec7562043c9b7efc8f879a3da6bd420e Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 29 Sep 2017 23:54:23 +0200 Subject: [PATCH 66/89] use a different video icon at list view, without fill --- .../gallery/adapters/DirectoryAdapter.kt | 2 ++ .../res/drawable-hdpi/img_play_outline_empty.png | Bin 0 -> 2228 bytes .../drawable-xhdpi/img_play_outline_empty.png | Bin 0 -> 2857 bytes .../drawable-xxhdpi/img_play_outline_empty.png | Bin 0 -> 5674 bytes .../drawable-xxxhdpi/img_play_outline_empty.png | Bin 0 -> 6911 bytes .../main/res/layout/photo_video_item_list.xml | 2 +- 6 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 app/src/main/res/drawable-hdpi/img_play_outline_empty.png create mode 100644 app/src/main/res/drawable-xhdpi/img_play_outline_empty.png create mode 100644 app/src/main/res/drawable-xxhdpi/img_play_outline_empty.png create mode 100644 app/src/main/res/drawable-xxxhdpi/img_play_outline_empty.png 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 257b94375..875115514 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -406,6 +406,8 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableListS 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 Hu0mjfyHa=o literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxhdpi/img_play_outline_empty.png b/app/src/main/res/drawable-xxhdpi/img_play_outline_empty.png new file mode 100644 index 0000000000000000000000000000000000000000..95a4f7d28d423042ab1402a1a7181145dc7cc1ac GIT binary patch literal 5674 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 QdjJ3c07*qoM6N<$f`c;9-T(jq literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxxhdpi/img_play_outline_empty.png b/app/src/main/res/drawable-xxxhdpi/img_play_outline_empty.png new file mode 100644 index 0000000000000000000000000000000000000000..df8727abdb133e6d99e3b44abe6934d0e86d5ed2 GIT binary patch literal 6911 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 FV1g~FaR2}S literal 0 HcmV?d00001 diff --git a/app/src/main/res/layout/photo_video_item_list.xml b/app/src/main/res/layout/photo_video_item_list.xml index 8fd7e34f3..dd1e17da8 100644 --- a/app/src/main/res/layout/photo_video_item_list.xml +++ b/app/src/main/res/layout/photo_video_item_list.xml @@ -47,7 +47,7 @@ android:layout_alignParentRight="true" android:layout_marginRight="@dimen/small_margin" android:paddingBottom="6dp" - android:src="@drawable/img_play_outline" + android:src="@drawable/img_play_outline_empty" android:visibility="gone"/> Date: Sat, 30 Sep 2017 18:07:26 +0200 Subject: [PATCH 67/89] update kotlin to 1.1.51 --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 1b8f6288b..15c7c312c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -52,7 +52,7 @@ dependencies { } buildscript { - ext.kotlin_version = '1.1.50' + ext.kotlin_version = '1.1.51' repositories { mavenCentral() } From 73bcad0f682fdb16b0a105a8c285c91a41edb691 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 30 Sep 2017 20:24:18 +0200 Subject: [PATCH 68/89] try using adapterPosition instead of layoutPosition in recyclerView adapters --- .../gallery/adapters/DirectoryAdapter.kt | 8 ++++---- .../simplemobiletools/gallery/adapters/MediaAdapter.kt | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) 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 875115514..6c6077fab 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -420,8 +420,8 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList, private fun viewClicked(medium: Medium) { if (multiSelector.isSelectable) { - val isSelected = adapterListener.getSelectedPositions().contains(layoutPosition) - adapterListener.toggleItemSelectionAdapter(!isSelected, layoutPosition) + val isSelected = adapterListener.getSelectedPositions().contains(adapterPosition) + adapterListener.toggleItemSelectionAdapter(!isSelected, adapterPosition) } else { itemClick(medium) } @@ -346,10 +346,10 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, if (listener != null) { if (!multiSelector.isSelectable) { activity.startSupportActionMode(multiSelectorCallback) - adapterListener.toggleItemSelectionAdapter(true, layoutPosition) + adapterListener.toggleItemSelectionAdapter(true, adapterPosition) } - listener.itemLongClicked(layoutPosition) + listener.itemLongClicked(adapterPosition) } } From 3d674c65ba4a822c8dbacd038986703c0f600630 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 30 Sep 2017 20:32:58 +0200 Subject: [PATCH 69/89] properly update text color at list view, if it changes --- .../gallery/activities/MainActivity.kt | 13 ++++++++++--- .../gallery/activities/MediaActivity.kt | 13 ++++++++++--- .../gallery/adapters/DirectoryAdapter.kt | 5 +++++ .../gallery/adapters/MediaAdapter.kt | 5 +++++ 4 files changed, 30 insertions(+), 6 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 57d7dff6c..d9997a500 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -57,6 +57,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { private var mStoredAnimateGifs = true private var mStoredCropThumbnails = true private var mStoredScrollHorizontally = true + private var mStoredTextColor = 0 private var mLoadedInitialPhotos = false private var mLatestMediaId = 0L private var mLastMediaHandler = Handler() @@ -82,6 +83,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { mStoredAnimateGifs = config.animateGifs mStoredCropThumbnails = config.cropThumbnails mStoredScrollHorizontally = config.scrollHorizontally + mStoredTextColor = config.textColor storeStoragePaths() checkWhatsNewDialog() @@ -134,13 +136,17 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { } if (mStoredScrollHorizontally != config.scrollHorizontally) { - directories_grid.adapter?.let { - (it as DirectoryAdapter).scrollVertically = config.viewTypeFolders == VIEW_TYPE_LIST || !config.scrollHorizontally - it.notifyDataSetChanged() + (directories_grid.adapter as? DirectoryAdapter)?.apply { + scrollVertically = config.viewTypeFolders == VIEW_TYPE_LIST || !config.scrollHorizontally + notifyDataSetChanged() } setupScrollDirection() } + if (mStoredTextColor != config.textColor) { + (directories_grid.adapter as? DirectoryAdapter)?.updateTextColor(config.textColor) + } + tryloadGallery() invalidateOptionsMenu() directories_empty_text_label.setTextColor(config.textColor) @@ -155,6 +161,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { mStoredAnimateGifs = config.animateGifs mStoredCropThumbnails = config.cropThumbnails mStoredScrollHorizontally = config.scrollHorizontally + mStoredTextColor = config.textColor directories_grid.listener = null mLastMediaHandler.removeCallbacksAndMessages(null) } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index 66a4eb984..e6efe5776 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -51,6 +51,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { private var mStoredAnimateGifs = true private var mStoredCropThumbnails = true private var mStoredScrollHorizontally = true + private var mStoredTextColor = 0 private var mLastDrawnHashCode = 0 private var mLatestMediaId = 0L private var mLastMediaHandler = Handler() @@ -73,6 +74,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { mStoredAnimateGifs = config.animateGifs mStoredCropThumbnails = config.cropThumbnails mStoredScrollHorizontally = config.scrollHorizontally + mStoredTextColor = config.textColor mShowAll = config.showAll if (mShowAll) supportActionBar?.setDisplayHomeAsUpEnabled(false) @@ -93,13 +95,17 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { } if (mStoredScrollHorizontally != config.scrollHorizontally) { - media_grid.adapter?.let { - (it as MediaAdapter).scrollVertically = config.viewTypeFiles == VIEW_TYPE_LIST || !config.scrollHorizontally - it.notifyDataSetChanged() + (media_grid.adapter as? MediaAdapter)?.apply { + scrollVertically = config.viewTypeFiles == VIEW_TYPE_LIST || !config.scrollHorizontally + notifyDataSetChanged() } setupScrollDirection() } + if (mStoredTextColor != config.textColor) { + (media_grid.adapter as? MediaAdapter)?.updateTextColor(config.textColor) + } + tryloadGallery() invalidateOptionsMenu() media_empty_text_label.setTextColor(config.textColor) @@ -113,6 +119,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { mStoredAnimateGifs = config.animateGifs mStoredCropThumbnails = config.cropThumbnails mStoredScrollHorizontally = config.scrollHorizontally + mStoredTextColor = config.textColor media_grid.listener = null mLastMediaHandler.removeCallbacksAndMessages(null) } 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 6c6077fab..2cfff88c5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -353,6 +353,11 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList, notifyDataSetChanged() } + fun updateTextColor(textColor: Int) { + this.textColor = textColor + notifyDataSetChanged() + } + fun selectItem(pos: Int) { toggleItemSelection(true, pos) } From 50a693d5e66ad6ac012afa9b6f9c713d0abf58fe Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 30 Sep 2017 20:49:08 +0200 Subject: [PATCH 70/89] do not trigger click event at swiping at videos --- .../simplemobiletools/gallery/fragments/VideoFragment.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt index 1828912e7..1e945a15e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt @@ -165,7 +165,9 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee mLastTouchY = event.y } MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> { - if (System.currentTimeMillis() - mTouchDownTime < CLICK_MAX_DURATION) { + val diffX = Math.abs(event.x - mTouchDownX) + val diffY = Math.abs(event.y - mTouchDownY) + if (System.currentTimeMillis() - mTouchDownTime < CLICK_MAX_DURATION && diffX < 20 && diffY < 20) { mView.video_holder.performClick() } } @@ -201,7 +203,9 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee mLastTouchY = event.y } MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> { - if (System.currentTimeMillis() - mTouchDownTime < CLICK_MAX_DURATION) { + val diffX = Math.abs(event.x - mTouchDownX) + val diffY = Math.abs(event.y - mTouchDownY) + if (System.currentTimeMillis() - mTouchDownTime < CLICK_MAX_DURATION && diffX < 20 && diffY < 20) { mView.video_holder.performClick() } mTouchDownBrightness = mTempBrightness From e67253ccaed5974527e9abec1e9d9bd048525dbd Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 30 Sep 2017 21:04:21 +0200 Subject: [PATCH 71/89] clear selection at folders and media, if content changes --- .../com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt | 1 + .../com/simplemobiletools/gallery/adapters/MediaAdapter.kt | 1 + 2 files changed, 2 insertions(+) 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 2cfff88c5..cf0a6fad1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -351,6 +351,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList) { dirs = newDirs notifyDataSetChanged() + actMode?.finish() } fun updateTextColor(textColor: Int) { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt index 0096275ce..50a03e7ca 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt @@ -266,6 +266,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, fun updateMedia(newMedia: ArrayList) { media = newMedia notifyDataSetChanged() + actMode?.finish() } fun updateDisplayFilenames(display: Boolean) { From 1390d9541cf520b1efd87d8d1a8681d35a3f743c Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 30 Sep 2017 21:05:20 +0200 Subject: [PATCH 72/89] try caching 100 items per folder, up from 40 --- .../com/simplemobiletools/gallery/activities/MediaActivity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index e6efe5776..feda91d45 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -38,7 +38,7 @@ import java.io.File import java.io.IOException class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { - private val SAVE_MEDIA_CNT = 40 + private val SAVE_MEDIA_CNT = 100 private val LAST_MEDIA_CHECK_PERIOD = 3000L private var mPath = "" From 7cc1a9ce178e6009b63ef3f854469284895de55b Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 30 Sep 2017 22:06:32 +0200 Subject: [PATCH 73/89] move the media fetching related functions in a separate class --- .../asynctasks/GetDirectoriesAsynctask.kt | 4 +- .../gallery/asynctasks/GetMediaAsynctask.kt | 7 +- .../gallery/extensions/context.kt | 302 +---------------- .../gallery/helpers/MediaFetcher.kt | 311 ++++++++++++++++++ 4 files changed, 318 insertions(+), 306 deletions(-) create mode 100644 app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt 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 a6450aac1..44a1921dc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt @@ -10,8 +10,8 @@ import com.simplemobiletools.commons.helpers.SORT_DESCENDING import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.extensions.config import com.simplemobiletools.gallery.extensions.containsNoMedia -import com.simplemobiletools.gallery.extensions.getMediaByDirectories import com.simplemobiletools.gallery.extensions.sumByLong +import com.simplemobiletools.gallery.helpers.MediaFetcher import com.simplemobiletools.gallery.models.Directory import com.simplemobiletools.gallery.models.Medium import java.io.File @@ -24,7 +24,7 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va return ArrayList() val config = context.config - val groupedMedia = context.getMediaByDirectories(isPickVideo, isPickImage) + val groupedMedia = MediaFetcher(context).getMediaByDirectories(isPickVideo, isPickImage) val directories = ArrayList() val hidden = context.resources.getString(R.string.hidden) val albumCovers = config.parseAlbumCovers() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetMediaAsynctask.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetMediaAsynctask.kt index 13002eb86..f0016b7f1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetMediaAsynctask.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetMediaAsynctask.kt @@ -3,8 +3,7 @@ package com.simplemobiletools.gallery.asynctasks import android.content.Context import android.os.AsyncTask import com.simplemobiletools.gallery.extensions.config -import com.simplemobiletools.gallery.extensions.getFilesFrom -import com.simplemobiletools.gallery.extensions.getMediaByDirectories +import com.simplemobiletools.gallery.helpers.MediaFetcher import com.simplemobiletools.gallery.models.Medium import java.util.* @@ -14,7 +13,7 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickVideo override fun doInBackground(vararg params: Void): ArrayList { return if (showAll) { - val mediaMap = context.getMediaByDirectories(isPickVideo, isPickImage) + val mediaMap = MediaFetcher(context).getMediaByDirectories(isPickVideo, isPickImage) val media = ArrayList() for ((path, curMedia) in mediaMap) { media.addAll(curMedia) @@ -24,7 +23,7 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickVideo media.sort() media } else { - context.getFilesFrom(mPath, isPickImage, isPickVideo) + MediaFetcher(context).getFilesFrom(mPath, isPickImage, isPickVideo) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt index ac943fe25..c04c3371e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt @@ -10,20 +10,10 @@ import android.net.Uri import android.os.Build import android.provider.MediaStore import android.view.WindowManager -import com.simplemobiletools.commons.extensions.* -import com.simplemobiletools.commons.helpers.SORT_BY_DATE_MODIFIED -import com.simplemobiletools.commons.helpers.SORT_BY_NAME -import com.simplemobiletools.commons.helpers.SORT_BY_SIZE -import com.simplemobiletools.commons.helpers.SORT_DESCENDING +import com.simplemobiletools.commons.extensions.humanizePath import com.simplemobiletools.gallery.activities.SettingsActivity -import com.simplemobiletools.gallery.helpers.* +import com.simplemobiletools.gallery.helpers.Config import com.simplemobiletools.gallery.models.Directory -import com.simplemobiletools.gallery.models.Medium -import java.io.File -import java.util.LinkedHashMap -import kotlin.collections.ArrayList -import kotlin.collections.component1 -import kotlin.collections.component2 val Context.portrait get() = resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT val Context.audioManager get() = getSystemService(Context.AUDIO_SERVICE) as AudioManager @@ -81,225 +71,6 @@ fun Context.launchSettings() { val Context.config: Config get() = Config.newInstance(this) -fun Context.getFilesFrom(curPath: String, isPickImage: Boolean, isPickVideo: Boolean): ArrayList { - val projection = arrayOf(MediaStore.Images.Media._ID, - MediaStore.Images.Media.DISPLAY_NAME, - MediaStore.Images.Media.DATE_TAKEN, - MediaStore.Images.Media.DATE_MODIFIED, - MediaStore.Images.Media.DATA, - MediaStore.Images.Media.SIZE) - val uri = MediaStore.Files.getContentUri("external") - val selection = getSelectionQuery(curPath) - val selectionArgs = getSelectionArgsQuery(curPath) - - return try { - val cur = contentResolver.query(uri, projection, selection, selectionArgs, getSortingForFolder(curPath)) - parseCursor(this, cur, isPickImage, isPickVideo, curPath) - } catch (e: Exception) { - ArrayList() - } -} - -fun Context.getSelectionQuery(path: String): String { - val dataQuery = "${MediaStore.Images.Media.DATA} LIKE ?" - return if (path.isEmpty()) { - var query = "($dataQuery)" - if (hasExternalSDCard()) { - query += " OR ($dataQuery)" - } - query - } else { - "($dataQuery AND ${MediaStore.Images.Media.DATA} NOT LIKE ?)" - } -} - -fun Context.getSelectionArgsQuery(path: String): Array { - return if (path.isEmpty()) { - if (hasExternalSDCard()) arrayOf("$internalStoragePath/%", "$sdCardPath/%") else arrayOf("$internalStoragePath/%") - } else { - arrayOf("$path/%", "$path/%/%") - } -} - -private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isPickVideo: Boolean, curPath: String): ArrayList { - val curMedia = ArrayList() - val config = context.config - val filterMedia = config.filterMedia - val showHidden = config.shouldShowHidden - val includedFolders = config.includedFolders.map { "${it.trimEnd('/')}/" } - val excludedFolders = config.excludedFolders.map { "${it.trimEnd('/')}/" } - val noMediaFolders = context.getNoMediaFolders() - val isThirdPartyIntent = config.isThirdPartyIntent - - cur.use { - if (cur.moveToFirst()) { - do { - try { - val path = cur.getStringValue(MediaStore.Images.Media.DATA) - - var filename = cur.getStringValue(MediaStore.Images.Media.DISPLAY_NAME) ?: "" - if (filename.isEmpty()) - filename = path.getFilenameFromPath() - - val isImage = filename.isImageFast() - val isVideo = if (isImage) false else filename.isVideoFast() - val isGif = if (isImage || isVideo) false else filename.isGif() - - if (!isImage && !isVideo && !isGif) - continue - - if (isVideo && (isPickImage || filterMedia and VIDEOS == 0)) - continue - - if (isImage && (isPickVideo || filterMedia and IMAGES == 0)) - continue - - if (isGif && filterMedia and GIFS == 0) - continue - - if (!showHidden && filename.startsWith('.')) - continue - - var size = cur.getLongValue(MediaStore.Images.Media.SIZE) - val file = File(path) - if (size == 0L) { - size = file.length() - } - - if (size <= 0L) - continue - - var isExcluded = false - excludedFolders.forEach { - if (path.startsWith(it)) { - isExcluded = true - includedFolders.forEach { - if (path.startsWith(it)) { - isExcluded = false - } - } - } - } - - if (!isExcluded && !showHidden) { - noMediaFolders.forEach { - if (path.startsWith(it)) { - isExcluded = true - } - } - } - - if (!isExcluded && !showHidden && path.contains("/.")) { - isExcluded = true - } - - if (!isExcluded || isThirdPartyIntent) { - if (!file.exists()) - continue - - val dateTaken = cur.getLongValue(MediaStore.Images.Media.DATE_TAKEN) - val dateModified = cur.getIntValue(MediaStore.Images.Media.DATE_MODIFIED) * 1000L - - val medium = Medium(filename, path, isVideo, dateModified, dateTaken, size) - curMedia.add(medium) - } - } catch (e: Exception) { - continue - } - } while (cur.moveToNext()) - } - } - - config.includedFolders.filter { it.isNotEmpty() && (curPath.isEmpty() || it == curPath) }.forEach { - getMediaInFolder(it, curMedia, isPickImage, isPickVideo, filterMedia) - } - - if (isThirdPartyIntent && curPath.isNotEmpty() && curMedia.isEmpty()) { - getMediaInFolder(curPath, curMedia, isPickImage, isPickVideo, filterMedia) - } - - Medium.sorting = config.getFileSorting(curPath) - curMedia.sort() - - return curMedia -} - -private fun getMediaInFolder(folder: String, curMedia: ArrayList, isPickImage: Boolean, isPickVideo: Boolean, filterMedia: Int) { - val files = File(folder).listFiles() ?: return - for (file in files) { - val filename = file.name - val isImage = filename.isImageFast() - val isVideo = if (isImage) false else filename.isVideoFast() - val isGif = if (isImage || isVideo) false else filename.isGif() - - if (!isImage && !isVideo) - continue - - if (isVideo && (isPickImage || filterMedia and VIDEOS == 0)) - continue - - if (isImage && (isPickVideo || filterMedia and IMAGES == 0)) - continue - - if (isGif && filterMedia and GIFS == 0) - continue - - val size = file.length() - if (size <= 0L) - continue - - val dateTaken = file.lastModified() - val dateModified = file.lastModified() - - val medium = Medium(filename, file.absolutePath, isVideo, dateModified, dateTaken, size) - val isAlreadyAdded = curMedia.any { it.path == file.absolutePath } - if (!isAlreadyAdded) - curMedia.add(medium) - } -} - -fun Context.getSortingForFolder(path: String): String { - val sorting = config.getFileSorting(path) - val sortValue = when { - sorting and SORT_BY_NAME > 0 -> MediaStore.Images.Media.DISPLAY_NAME - sorting and SORT_BY_SIZE > 0 -> MediaStore.Images.Media.SIZE - sorting and SORT_BY_DATE_MODIFIED > 0 -> MediaStore.Images.Media.DATE_MODIFIED - else -> MediaStore.Images.Media.DATE_TAKEN - } - - return if (sorting and SORT_DESCENDING > 0) - "$sortValue DESC" - else - "$sortValue ASC" -} - -fun Context.getNoMediaFolders(): ArrayList { - val folders = ArrayList() - val noMediaCondition = "${MediaStore.Files.FileColumns.MEDIA_TYPE} = ${MediaStore.Files.FileColumns.MEDIA_TYPE_NONE}" - - val uri = MediaStore.Files.getContentUri("external") - val columns = arrayOf(MediaStore.Files.FileColumns.DATA) - val where = "$noMediaCondition AND ${MediaStore.Files.FileColumns.TITLE} LIKE ?" - val args = arrayOf("%$NOMEDIA%") - var cursor: Cursor? = null - - try { - cursor = contentResolver.query(uri, columns, where, args, null) - if (cursor?.moveToFirst() == true) { - do { - val path = cursor.getString(cursor.getColumnIndex(MediaStore.Files.FileColumns.DATA)) ?: continue - val noMediaFile = File(path) - if (noMediaFile.exists()) - folders.add("${noMediaFile.parent}/") - } while (cursor.moveToNext()) - } - } finally { - cursor?.close() - } - - return folders -} - fun Context.movePinnedDirectoriesToFront(dirs: ArrayList): ArrayList { val foundFolders = ArrayList() val pinnedFolders = config.pinnedFolders @@ -310,75 +81,6 @@ fun Context.movePinnedDirectoriesToFront(dirs: ArrayList): ArrayList< return dirs } -fun Context.getMediaByDirectories(isPickVideo: Boolean, isPickImage: Boolean): HashMap> { - val media = getFilesFrom("", isPickImage, isPickVideo) - val excludedPaths = config.excludedFolders - val includedPaths = config.includedFolders - val showHidden = config.shouldShowHidden - val directories = groupDirectories(media) - - val removePaths = ArrayList() - for ((path, curMedia) in directories) { - // make sure the path has uppercase letters wherever appropriate - val groupPath = File(curMedia.first().path).parent - if (!File(groupPath).exists() || !shouldFolderBeVisible(groupPath, excludedPaths, includedPaths, showHidden)) { - removePaths.add(groupPath.toLowerCase()) - } - } - - removePaths.forEach { - directories.remove(it) - } - - return directories -} - -private fun groupDirectories(media: ArrayList): HashMap> { - val directories = LinkedHashMap>() - for (medium in media) { - val parentDir = File(medium.path).parent?.toLowerCase() ?: continue - if (directories.containsKey(parentDir)) { - directories[parentDir]!!.add(medium) - } else { - directories.put(parentDir, arrayListOf(medium)) - } - } - return directories -} - -private fun shouldFolderBeVisible(path: String, excludedPaths: MutableSet, includedPaths: MutableSet, showHidden: Boolean): Boolean { - val file = File(path) - return if (includedPaths.contains(path)) { - true - } else if (isThisOrParentExcluded(path, excludedPaths, includedPaths)) { - false - } else if (!showHidden && file.isDirectory && file.canonicalFile == file.absoluteFile) { - var containsNoMediaOrDot = file.containsNoMedia() || path.contains("/.") - if (!containsNoMediaOrDot) { - containsNoMediaOrDot = checkParentHasNoMedia(file.parentFile) - } - !containsNoMediaOrDot - } else { - true - } -} - -private fun checkParentHasNoMedia(file: File): Boolean { - var curFile = file - while (true) { - if (curFile.containsNoMedia()) { - return true - } - curFile = curFile.parentFile - if (curFile.absolutePath == "/") - break - } - return false -} - -private fun isThisOrParentExcluded(path: String, excludedPaths: MutableSet, includedPaths: MutableSet) = - includedPaths.none { path.startsWith(it) } && excludedPaths.any { path.startsWith(it) } - @Suppress("UNCHECKED_CAST") fun Context.getSortedDirectories(source: ArrayList): ArrayList { Directory.sorting = config.directorySorting diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt new file mode 100644 index 000000000..7bb0d0e8f --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt @@ -0,0 +1,311 @@ +package com.simplemobiletools.gallery.helpers + +import android.content.Context +import android.database.Cursor +import android.provider.MediaStore +import android.util.Log +import com.simplemobiletools.commons.extensions.* +import com.simplemobiletools.commons.helpers.SORT_BY_DATE_MODIFIED +import com.simplemobiletools.commons.helpers.SORT_BY_NAME +import com.simplemobiletools.commons.helpers.SORT_BY_SIZE +import com.simplemobiletools.commons.helpers.SORT_DESCENDING +import com.simplemobiletools.gallery.extensions.config +import com.simplemobiletools.gallery.extensions.containsNoMedia +import com.simplemobiletools.gallery.models.Medium +import java.io.File +import java.util.LinkedHashMap +import kotlin.collections.ArrayList +import kotlin.collections.component1 +import kotlin.collections.component2 + +class MediaFetcher(val context: Context) { + fun getMediaByDirectories(isPickVideo: Boolean, isPickImage: Boolean): HashMap> { + val media = getFilesFrom("", isPickImage, isPickVideo) + val excludedPaths = context.config.excludedFolders + val includedPaths = context.config.includedFolders + val showHidden = context.config.shouldShowHidden + val directories = groupDirectories(media) + + val removePaths = ArrayList() + for ((path, curMedia) in directories) { + // make sure the path has uppercase letters wherever appropriate + val groupPath = File(curMedia.first().path).parent + if (!File(groupPath).exists() || !shouldFolderBeVisible(groupPath, excludedPaths, includedPaths, showHidden)) { + removePaths.add(groupPath.toLowerCase()) + } + } + + removePaths.forEach { + directories.remove(it) + } + + return directories + } + + fun getFilesFrom(curPath: String, isPickImage: Boolean, isPickVideo: Boolean): ArrayList { + val projection = arrayOf(MediaStore.Images.Media._ID, + MediaStore.Images.Media.DISPLAY_NAME, + MediaStore.Images.Media.DATE_TAKEN, + MediaStore.Images.Media.DATE_MODIFIED, + MediaStore.Images.Media.DATA, + MediaStore.Images.Media.SIZE) + val uri = MediaStore.Files.getContentUri("external") + val selection = getSelectionQuery(curPath) + val selectionArgs = getSelectionArgsQuery(curPath) + + return try { + val cur = context.contentResolver.query(uri, projection, selection, selectionArgs, getSortingForFolder(curPath)) + parseCursor(context, cur, isPickImage, isPickVideo, curPath) + } catch (e: Exception) { + ArrayList() + } + } + + private fun getSelectionQuery(path: String): String { + val dataQuery = "${MediaStore.Images.Media.DATA} LIKE ?" + return if (path.isEmpty()) { + var query = "($dataQuery)" + if (context.hasExternalSDCard()) { + query += " OR ($dataQuery)" + } + query + } else { + "($dataQuery AND ${MediaStore.Images.Media.DATA} NOT LIKE ?)" + } + } + + private fun getSelectionArgsQuery(path: String): Array { + return if (path.isEmpty()) { + if (context.hasExternalSDCard()) arrayOf("${context.internalStoragePath}/%", "${context.sdCardPath}/%") else arrayOf("${context.internalStoragePath}/%") + } else { + arrayOf("$path/%", "$path/%/%") + } + } + + private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isPickVideo: Boolean, curPath: String): ArrayList { + val curMedia = ArrayList() + val config = context.config + val filterMedia = config.filterMedia + val showHidden = config.shouldShowHidden + val includedFolders = config.includedFolders.map { "${it.trimEnd('/')}/" } + val excludedFolders = config.excludedFolders.map { "${it.trimEnd('/')}/" } + val noMediaFolders = getNoMediaFolders() + val isThirdPartyIntent = config.isThirdPartyIntent + + cur.use { + if (cur.moveToFirst()) { + do { + try { + val path = cur.getStringValue(MediaStore.Images.Media.DATA) + + Log.e("DEBUG", "checking $path") + var filename = cur.getStringValue(MediaStore.Images.Media.DISPLAY_NAME) ?: "" + if (filename.isEmpty()) + filename = path.getFilenameFromPath() + + val isImage = filename.isImageFast() + val isVideo = if (isImage) false else filename.isVideoFast() + val isGif = if (isImage || isVideo) false else filename.isGif() + + if (!isImage && !isVideo && !isGif) + continue + + if (isVideo && (isPickImage || filterMedia and VIDEOS == 0)) + continue + + if (isImage && (isPickVideo || filterMedia and IMAGES == 0)) + continue + + if (isGif && filterMedia and GIFS == 0) + continue + + if (!showHidden && filename.startsWith('.')) + continue + + var size = cur.getLongValue(MediaStore.Images.Media.SIZE) + val file = File(path) + if (size == 0L) { + size = file.length() + } + + if (size <= 0L) + continue + + var isExcluded = false + excludedFolders.forEach { + if (path.startsWith(it)) { + isExcluded = true + includedFolders.forEach { + if (path.startsWith(it)) { + isExcluded = false + } + } + } + } + + if (!isExcluded && !showHidden) { + noMediaFolders.forEach { + if (path.startsWith(it)) { + isExcluded = true + } + } + } + + if (!isExcluded && !showHidden && path.contains("/.")) { + isExcluded = true + } + + if (!isExcluded || isThirdPartyIntent) { + if (!file.exists()) + continue + + val dateTaken = cur.getLongValue(MediaStore.Images.Media.DATE_TAKEN) + val dateModified = cur.getIntValue(MediaStore.Images.Media.DATE_MODIFIED) * 1000L + + val medium = Medium(filename, path, isVideo, dateModified, dateTaken, size) + curMedia.add(medium) + } + } catch (e: Exception) { + continue + } + } while (cur.moveToNext()) + } + } + + config.includedFolders.filter { it.isNotEmpty() && (curPath.isEmpty() || it == curPath) }.forEach { + getMediaInFolder(it, curMedia, isPickImage, isPickVideo, filterMedia) + } + + if (isThirdPartyIntent && curPath.isNotEmpty() && curMedia.isEmpty()) { + getMediaInFolder(curPath, curMedia, isPickImage, isPickVideo, filterMedia) + } + + Medium.sorting = config.getFileSorting(curPath) + curMedia.sort() + + return curMedia + } + + private fun groupDirectories(media: ArrayList): HashMap> { + val directories = LinkedHashMap>() + for (medium in media) { + val parentDir = File(medium.path).parent?.toLowerCase() ?: continue + if (directories.containsKey(parentDir)) { + directories[parentDir]!!.add(medium) + } else { + directories.put(parentDir, arrayListOf(medium)) + } + } + return directories + } + + private fun shouldFolderBeVisible(path: String, excludedPaths: MutableSet, includedPaths: MutableSet, showHidden: Boolean): Boolean { + val file = File(path) + return if (includedPaths.contains(path)) { + true + } else if (isThisOrParentExcluded(path, excludedPaths, includedPaths)) { + false + } else if (!showHidden && file.isDirectory && file.canonicalFile == file.absoluteFile) { + var containsNoMediaOrDot = file.containsNoMedia() || path.contains("/.") + if (!containsNoMediaOrDot) { + containsNoMediaOrDot = checkParentHasNoMedia(file.parentFile) + } + !containsNoMediaOrDot + } else { + true + } + } + + private fun checkParentHasNoMedia(file: File): Boolean { + var curFile = file + while (true) { + if (curFile.containsNoMedia()) { + return true + } + curFile = curFile.parentFile + if (curFile.absolutePath == "/") + break + } + return false + } + + private fun isThisOrParentExcluded(path: String, excludedPaths: MutableSet, includedPaths: MutableSet) = + includedPaths.none { path.startsWith(it) } && excludedPaths.any { path.startsWith(it) } + + + private fun getMediaInFolder(folder: String, curMedia: ArrayList, isPickImage: Boolean, isPickVideo: Boolean, filterMedia: Int) { + val files = File(folder).listFiles() ?: return + for (file in files) { + val filename = file.name + val isImage = filename.isImageFast() + val isVideo = if (isImage) false else filename.isVideoFast() + val isGif = if (isImage || isVideo) false else filename.isGif() + + if (!isImage && !isVideo) + continue + + if (isVideo && (isPickImage || filterMedia and VIDEOS == 0)) + continue + + if (isImage && (isPickVideo || filterMedia and IMAGES == 0)) + continue + + if (isGif && filterMedia and GIFS == 0) + continue + + val size = file.length() + if (size <= 0L) + continue + + val dateTaken = file.lastModified() + val dateModified = file.lastModified() + + val medium = Medium(filename, file.absolutePath, isVideo, dateModified, dateTaken, size) + val isAlreadyAdded = curMedia.any { it.path == file.absolutePath } + if (!isAlreadyAdded) + curMedia.add(medium) + } + } + + private fun getSortingForFolder(path: String): String { + val sorting = context.config.getFileSorting(path) + val sortValue = when { + sorting and SORT_BY_NAME > 0 -> MediaStore.Images.Media.DISPLAY_NAME + sorting and SORT_BY_SIZE > 0 -> MediaStore.Images.Media.SIZE + sorting and SORT_BY_DATE_MODIFIED > 0 -> MediaStore.Images.Media.DATE_MODIFIED + else -> MediaStore.Images.Media.DATE_TAKEN + } + + return if (sorting and SORT_DESCENDING > 0) + "$sortValue DESC" + else + "$sortValue ASC" + } + + private fun getNoMediaFolders(): ArrayList { + val folders = ArrayList() + val noMediaCondition = "${MediaStore.Files.FileColumns.MEDIA_TYPE} = ${MediaStore.Files.FileColumns.MEDIA_TYPE_NONE}" + + val uri = MediaStore.Files.getContentUri("external") + val columns = arrayOf(MediaStore.Files.FileColumns.DATA) + val where = "$noMediaCondition AND ${MediaStore.Files.FileColumns.TITLE} LIKE ?" + val args = arrayOf("%$NOMEDIA%") + var cursor: Cursor? = null + + try { + cursor = context.contentResolver.query(uri, columns, where, args, null) + if (cursor?.moveToFirst() == true) { + do { + val path = cursor.getString(cursor.getColumnIndex(MediaStore.Files.FileColumns.DATA)) ?: continue + val noMediaFile = File(path) + if (noMediaFile.exists()) + folders.add("${noMediaFile.parent}/") + } while (cursor.moveToNext()) + } + } finally { + cursor?.close() + } + + return folders + } +} From 5c7dfb87be8b893201a5a03d9b21b39987f28165 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 30 Sep 2017 22:23:28 +0200 Subject: [PATCH 74/89] stop media fetching on the calling activity pause --- .../gallery/activities/MainActivity.kt | 2 +- .../gallery/activities/MediaActivity.kt | 7 +++++-- .../gallery/asynctasks/GetDirectoriesAsynctask.kt | 8 +++++++- .../gallery/asynctasks/GetMediaAsynctask.kt | 10 ++++++++-- .../gallery/helpers/MediaFetcher.kt | 14 +++++++++++--- 5 files changed, 32 insertions(+), 9 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 d9997a500..0694bbc53 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -61,7 +61,6 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { private var mLoadedInitialPhotos = false private var mLatestMediaId = 0L private var mLastMediaHandler = Handler() - private var mCurrAsyncTask: GetDirectoriesAsynctask? = null override fun onCreate(savedInstanceState: Bundle?) { @@ -164,6 +163,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { mStoredTextColor = config.textColor directories_grid.listener = null mLastMediaHandler.removeCallbacksAndMessages(null) + mCurrAsyncTask?.stopFetching() } override fun onDestroy() { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index feda91d45..678db7f7f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -55,6 +55,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { private var mLastDrawnHashCode = 0 private var mLatestMediaId = 0L private var mLastMediaHandler = Handler() + private var mCurrAsyncTask: GetMediaAsynctask? = null companion object { var mMedia = ArrayList() @@ -122,6 +123,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { mStoredTextColor = config.textColor media_grid.listener = null mLastMediaHandler.removeCallbacksAndMessages(null) + mCurrAsyncTask?.stopFetching() } override fun onDestroy() { @@ -344,9 +346,10 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { } mLoadedInitialPhotos = true - GetMediaAsynctask(applicationContext, mPath, mIsGetVideoIntent, mIsGetImageIntent, mShowAll) { + mCurrAsyncTask = GetMediaAsynctask(applicationContext, mPath, mIsGetVideoIntent, mIsGetImageIntent, mShowAll) { gotMedia(it) - }.execute() + } + mCurrAsyncTask!!.execute() } private fun isDirEmpty(): Boolean { 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 44a1921dc..676b45f8b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt @@ -18,13 +18,14 @@ import java.io.File class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, val isPickImage: Boolean, val callback: (dirs: ArrayList) -> Unit) : AsyncTask>() { + val mediaFetcher = MediaFetcher(context) override fun doInBackground(vararg params: Void): ArrayList { if (!context.hasWriteStoragePermission()) return ArrayList() val config = context.config - val groupedMedia = MediaFetcher(context).getMediaByDirectories(isPickVideo, isPickImage) + val groupedMedia = mediaFetcher.getMediaByDirectories(isPickVideo, isPickImage) val directories = ArrayList() val hidden = context.resources.getString(R.string.hidden) val albumCovers = config.parseAlbumCovers() @@ -66,4 +67,9 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va super.onPostExecute(dirs) callback(dirs) } + + fun stopFetching() { + mediaFetcher.shouldStop = true + cancel(true) + } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetMediaAsynctask.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetMediaAsynctask.kt index f0016b7f1..2c99f54d6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetMediaAsynctask.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetMediaAsynctask.kt @@ -10,10 +10,11 @@ import java.util.* class GetMediaAsynctask(val context: Context, val mPath: String, val isPickVideo: Boolean = false, val isPickImage: Boolean = false, val showAll: Boolean, val callback: (media: ArrayList) -> Unit) : AsyncTask>() { + val mediaFetcher = MediaFetcher(context) override fun doInBackground(vararg params: Void): ArrayList { return if (showAll) { - val mediaMap = MediaFetcher(context).getMediaByDirectories(isPickVideo, isPickImage) + val mediaMap = mediaFetcher.getMediaByDirectories(isPickVideo, isPickImage) val media = ArrayList() for ((path, curMedia) in mediaMap) { media.addAll(curMedia) @@ -23,7 +24,7 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickVideo media.sort() media } else { - MediaFetcher(context).getFilesFrom(mPath, isPickImage, isPickVideo) + mediaFetcher.getFilesFrom(mPath, isPickImage, isPickVideo) } } @@ -31,4 +32,9 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickVideo super.onPostExecute(media) callback(media) } + + fun stopFetching() { + mediaFetcher.shouldStop = true + cancel(true) + } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt index 7bb0d0e8f..210e44258 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt @@ -3,7 +3,6 @@ package com.simplemobiletools.gallery.helpers import android.content.Context import android.database.Cursor import android.provider.MediaStore -import android.util.Log import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.SORT_BY_DATE_MODIFIED import com.simplemobiletools.commons.helpers.SORT_BY_NAME @@ -19,6 +18,8 @@ import kotlin.collections.component1 import kotlin.collections.component2 class MediaFetcher(val context: Context) { + var shouldStop = false + fun getMediaByDirectories(isPickVideo: Boolean, isPickImage: Boolean): HashMap> { val media = getFilesFrom("", isPickImage, isPickVideo) val excludedPaths = context.config.excludedFolders @@ -96,9 +97,10 @@ class MediaFetcher(val context: Context) { if (cur.moveToFirst()) { do { try { - val path = cur.getStringValue(MediaStore.Images.Media.DATA) + if (shouldStop) + break - Log.e("DEBUG", "checking $path") + val path = cur.getStringValue(MediaStore.Images.Media.DATA) var filename = cur.getStringValue(MediaStore.Images.Media.DISPLAY_NAME) ?: "" if (filename.isEmpty()) filename = path.getFilenameFromPath() @@ -189,6 +191,9 @@ class MediaFetcher(val context: Context) { private fun groupDirectories(media: ArrayList): HashMap> { val directories = LinkedHashMap>() for (medium in media) { + if (shouldStop) + break + val parentDir = File(medium.path).parent?.toLowerCase() ?: continue if (directories.containsKey(parentDir)) { directories[parentDir]!!.add(medium) @@ -236,6 +241,9 @@ class MediaFetcher(val context: Context) { private fun getMediaInFolder(folder: String, curMedia: ArrayList, isPickImage: Boolean, isPickVideo: Boolean, filterMedia: Int) { val files = File(folder).listFiles() ?: return for (file in files) { + if (shouldStop) + break + val filename = file.name val isImage = filename.isImageFast() val isVideo = if (isImage) false else filename.isVideoFast() From 0ef9ff06bf9583583052cf4d4068e37fecc4ec5a Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 30 Sep 2017 22:33:58 +0200 Subject: [PATCH 75/89] refresh directories instantly after un/pinning --- .../simplemobiletools/gallery/activities/MainActivity.kt | 4 ++++ .../simplemobiletools/gallery/adapters/DirectoryAdapter.kt | 4 +++- .../com/simplemobiletools/gallery/extensions/context.kt | 6 +++++- 3 files changed, 12 insertions(+), 2 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 0694bbc53..0ca8e74a9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -552,6 +552,10 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { directories_grid.setDragSelectActive(position) } + override fun recheckPinnedFolders() { + gotDirectories(movePinnedDirectoriesToFront(mDirs), true) + } + 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 cf0a6fad1..9454f0ca4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -221,7 +221,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList) fun itemLongClicked(position: Int) + + fun recheckPinnedFolders() } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt index c04c3371e..f7cd61529 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt @@ -75,7 +75,11 @@ fun Context.movePinnedDirectoriesToFront(dirs: ArrayList): ArrayList< val foundFolders = ArrayList() val pinnedFolders = config.pinnedFolders - dirs.forEach { if (pinnedFolders.contains(it.path)) foundFolders.add(it) } + dirs.forEach { + if (pinnedFolders.contains(it.path)) + foundFolders.add(it) + } + dirs.removeAll(foundFolders) dirs.addAll(0, foundFolders) return dirs From b7cb6a5364281bdd19689afd8d22989da654f027 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 30 Sep 2017 22:55:25 +0200 Subject: [PATCH 76/89] make viewPager nullable during fake drag --- .../simplemobiletools/gallery/activities/ViewPagerActivity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index 8b1150d40..9fe6db7fd 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -327,7 +327,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View val dragPosition = animation.animatedValue as Int val dragOffset = dragPosition - oldDragPosition oldDragPosition = dragPosition - view_pager.fakeDragBy(dragOffset * (if (forward) 1f else -1f)) + view_pager?.fakeDragBy(dragOffset * (if (forward) 1f else -1f)) } }) From 6e6af530bfd28eb83ad5f3e35011c59b35a0dcca Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 30 Sep 2017 23:39:04 +0200 Subject: [PATCH 77/89] do not clear mMedia if the intent came from the gallery itself --- .../gallery/activities/PhotoVideoActivity.kt | 4 ++++ .../gallery/activities/ViewPagerActivity.kt | 5 ++++- .../com/simplemobiletools/gallery/extensions/activity.kt | 8 +++++--- .../com/simplemobiletools/gallery/helpers/Constants.kt | 1 + 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt index 96fc44b10..4a5b48097 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt @@ -21,6 +21,7 @@ import com.simplemobiletools.gallery.extensions.* import com.simplemobiletools.gallery.fragments.PhotoFragment import com.simplemobiletools.gallery.fragments.VideoFragment import com.simplemobiletools.gallery.fragments.ViewPagerFragment +import com.simplemobiletools.gallery.helpers.IS_FROM_GALLERY import com.simplemobiletools.gallery.helpers.IS_VIEW_INTENT import com.simplemobiletools.gallery.helpers.MEDIUM import com.simplemobiletools.gallery.models.Medium @@ -31,6 +32,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList private val STORAGE_PERMISSION = 1 private var mMedium: Medium? = null private var mIsFullScreen = false + private var mIsFromGallery = false private var mFragment: ViewPagerFragment? = null lateinit var mUri: Uri @@ -52,6 +54,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList private fun checkIntent(savedInstanceState: Bundle? = null) { mUri = intent.data ?: return + mIsFromGallery = intent.getBooleanExtra(IS_FROM_GALLERY, false) if (mUri.scheme == "file") { scanPath(mUri.path) {} @@ -126,6 +129,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList private fun sendViewPagerIntent(path: String) { Intent(this, ViewPagerActivity::class.java).apply { putExtra(IS_VIEW_INTENT, true) + putExtra(IS_FROM_GALLERY, mIsFromGallery) putExtra(MEDIUM, path) startActivity(this) } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index 9fe6db7fd..7aacc2376 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -160,8 +160,11 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } if (config.isThirdPartyIntent) { - mMedia.clear() config.isThirdPartyIntent = false + + if (intent.extras == null || !intent.getBooleanExtra(IS_FROM_GALLERY, false)) { + mMedia.clear() + } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt index a7fc915a2..756f9578b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt @@ -24,6 +24,7 @@ import com.simplemobiletools.commons.helpers.* import com.simplemobiletools.gallery.BuildConfig import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.activities.SimpleActivity +import com.simplemobiletools.gallery.helpers.IS_FROM_GALLERY import com.simplemobiletools.gallery.helpers.NOMEDIA import com.simplemobiletools.gallery.helpers.REQUEST_EDIT_IMAGE import com.simplemobiletools.gallery.helpers.REQUEST_SET_AS @@ -91,14 +92,14 @@ fun Activity.setAs(uri: Uri, file: File, showToast: Boolean = true): Boolean { addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) val chooser = Intent.createChooser(this, getString(R.string.set_as)) - if (resolveActivity(packageManager) != null) { + success = if (resolveActivity(packageManager) != null) { startActivityForResult(chooser, REQUEST_SET_AS) - success = true + true } else { if (showToast) { toast(R.string.no_capable_app_found) } - success = false + false } } @@ -130,6 +131,7 @@ fun Activity.openWith(file: File, forceChooser: Boolean = true) { action = Intent.ACTION_VIEW setDataAndType(uri, file.getMimeType()) addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) + putExtra(IS_FROM_GALLERY, true) if (resolveActivity(packageManager) != null) { val chooser = Intent.createChooser(this, getString(R.string.open_with)) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt index 691031eb3..18bf6ac29 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt @@ -62,6 +62,7 @@ val GET_ANY_INTENT = "get_any_intent" val SET_WALLPAPER_INTENT = "set_wallpaper_intent" val DIRECTORIES = "directories2" val IS_VIEW_INTENT = "is_view_intent" +val IS_FROM_GALLERY = "is_from_gallery" val REQUEST_EDIT_IMAGE = 1 val REQUEST_SET_AS = 2 From e4b77eacb01d8d82da94dc320edce70e111b2e38 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 30 Sep 2017 23:56:28 +0200 Subject: [PATCH 78/89] fixing some fastscroller glitches --- .../simplemobiletools/gallery/activities/MainActivity.kt | 7 ++++--- .../simplemobiletools/gallery/activities/MediaActivity.kt | 7 ++++--- .../gallery/dialogs/PickDirectoryDialog.kt | 8 +++++--- 3 files changed, 13 insertions(+), 9 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 0ca8e74a9..bbde246e1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -509,15 +509,16 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { } private fun setupScrollDirection() { + val allowHorizontalScroll = config.scrollHorizontally && config.viewTypeFolders == VIEW_TYPE_GRID directories_refresh_layout.isEnabled = !config.scrollHorizontally directories_vertical_fastscroller.isHorizontal = false - directories_vertical_fastscroller.beGoneIf(config.scrollHorizontally) + directories_vertical_fastscroller.beGoneIf(allowHorizontalScroll) directories_horizontal_fastscroller.isHorizontal = true - directories_horizontal_fastscroller.beVisibleIf(config.scrollHorizontally) + directories_horizontal_fastscroller.beVisibleIf(allowHorizontalScroll) - if (config.scrollHorizontally) { + if (allowHorizontalScroll) { directories_horizontal_fastscroller.setViews(directories_grid, directories_refresh_layout) } else { directories_vertical_fastscroller.setViews(directories_grid, directories_refresh_layout) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index 678db7f7f..79baeed6a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -169,15 +169,16 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { } private fun setupScrollDirection() { + val allowHorizontalScroll = config.scrollHorizontally && config.viewTypeFiles == VIEW_TYPE_GRID media_refresh_layout.isEnabled = !config.scrollHorizontally media_vertical_fastscroller.isHorizontal = false - media_vertical_fastscroller.beGoneIf(config.scrollHorizontally) + media_vertical_fastscroller.beGoneIf(allowHorizontalScroll) media_horizontal_fastscroller.isHorizontal = true - media_horizontal_fastscroller.beVisibleIf(config.scrollHorizontally) + media_horizontal_fastscroller.beVisibleIf(allowHorizontalScroll) - if (config.scrollHorizontally) { + if (allowHorizontalScroll) { media_horizontal_fastscroller.setViews(media_grid, media_refresh_layout) } else { media_vertical_fastscroller.setViews(media_grid, media_refresh_layout) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickDirectoryDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickDirectoryDialog.kt index a4e877bad..1d53684cb 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickDirectoryDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickDirectoryDialog.kt @@ -16,6 +16,7 @@ import com.simplemobiletools.gallery.asynctasks.GetDirectoriesAsynctask import com.simplemobiletools.gallery.extensions.config import com.simplemobiletools.gallery.extensions.getCachedDirectories import com.simplemobiletools.gallery.extensions.getSortedDirectories +import com.simplemobiletools.gallery.helpers.VIEW_TYPE_GRID import com.simplemobiletools.gallery.models.Directory import kotlinx.android.synthetic.main.dialog_directory_picker.view.* @@ -23,11 +24,12 @@ class PickDirectoryDialog(val activity: SimpleActivity, val sourcePath: String, var dialog: AlertDialog var shownDirectories: ArrayList = ArrayList() var view: View = LayoutInflater.from(activity).inflate(R.layout.dialog_directory_picker, null) + var isGridViewType = activity.config.viewTypeFolders == VIEW_TYPE_GRID init { (view.directories_grid.layoutManager as GridLayoutManager).apply { - orientation = if (activity.config.scrollHorizontally) GridLayoutManager.HORIZONTAL else GridLayoutManager.VERTICAL - spanCount = activity.config.dirColumnCnt + orientation = if (activity.config.scrollHorizontally && isGridViewType) GridLayoutManager.HORIZONTAL else GridLayoutManager.VERTICAL + spanCount = if (isGridViewType) activity.config.dirColumnCnt else 1 } dialog = AlertDialog.Builder(activity) @@ -71,7 +73,7 @@ class PickDirectoryDialog(val activity: SimpleActivity, val sourcePath: String, } } - val scrollHorizontally = activity.config.scrollHorizontally + val scrollHorizontally = activity.config.scrollHorizontally && isGridViewType view.apply { directories_grid.adapter = adapter From 80b6279f83d4d1498e467efa02e1578c4433e3ca Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 1 Oct 2017 00:03:17 +0200 Subject: [PATCH 79/89] fix some layout manager glitch at list view with horizontal scrolling --- .../com/simplemobiletools/gallery/activities/MainActivity.kt | 2 ++ .../com/simplemobiletools/gallery/activities/MediaActivity.kt | 2 ++ 2 files changed, 4 insertions(+) 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 bbde246e1..b5498cccc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -357,6 +357,8 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { val layoutManager = directories_grid.layoutManager as GridLayoutManager layoutManager.spanCount = 1 + layoutManager.orientation = GridLayoutManager.VERTICAL + directories_refresh_layout.layoutParams = FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) } private fun createNewFolder() { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index 79baeed6a..f9816269f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -431,6 +431,8 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { val layoutManager = media_grid.layoutManager as GridLayoutManager layoutManager.spanCount = 1 + layoutManager.orientation = GridLayoutManager.VERTICAL + media_refresh_layout.layoutParams = FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) } private fun increaseColumnCount() { From 95f26a13cf0e22709d6b2da36b58e2276fffb045 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 1 Oct 2017 00:07:22 +0200 Subject: [PATCH 80/89] updating Whats new --- .../com/simplemobiletools/gallery/activities/MainActivity.kt | 1 + app/src/main/res/values/donottranslate.xml | 4 ++++ 2 files changed, 5 insertions(+) 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 b5498cccc..76d0303a3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -596,6 +596,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { add(Release(123, R.string.release_123)) add(Release(125, R.string.release_125)) add(Release(127, R.string.release_127)) + add(Release(133, R.string.release_133)) checkWhatsNew(this, BuildConfig.VERSION_CODE) } } diff --git a/app/src/main/res/values/donottranslate.xml b/app/src/main/res/values/donottranslate.xml index b880748b9..10ac92ba7 100644 --- a/app/src/main/res/values/donottranslate.xml +++ b/app/src/main/res/values/donottranslate.xml @@ -2,6 +2,10 @@ + + Added fingerprint to hidden item protection\n + Added a new List view type + Added a switch for disabling video gestures\n Added a switch for deleting empty folders after deleting content From cd9f3912e053558a96755167547b6872cf528f74 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 1 Oct 2017 00:10:36 +0200 Subject: [PATCH 81/89] update version to 2.15.0 --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 15c7c312c..2c49a9298 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "com.simplemobiletools.gallery" minSdkVersion 16 targetSdkVersion 23 - versionCode 132 - versionName "2.14.4" + versionCode 133 + versionName "2.15.0" } signingConfigs { From b19cf9a6ac02455a98fd9a765b50eb225eb889f0 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 1 Oct 2017 00:11:02 +0200 Subject: [PATCH 82/89] updating changelog --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19b5481bd..ea35d3112 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,16 @@ Changelog ========== +Version 2.15.0 *(2017-10-01)* +---------------------------- + + * Added fingerprint to hidden item protection + * Added a new List view type + * Fixed an issue with some hidden items being shown at "Show all folders content" + * Fixed typing in color hex codes manually with some keyboards + * Do not autosave rotated images in any case + * Tons of other performance, stability and UX improvements + Version 2.14.4 *(2017-09-18)* ---------------------------- From 3a0579c2e880a72a92bc80a88dd31faea0c2d2ac Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 1 Oct 2017 08:16:00 +0200 Subject: [PATCH 83/89] update commons to 2.29.0 --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 2c49a9298..c12f5fb84 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -37,7 +37,7 @@ android { } dependencies { - compile 'com.simplemobiletools:commons:2.28.9' + compile 'com.simplemobiletools:commons:2.29.0' compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0' compile 'com.theartofdev.edmodo:android-image-cropper:2.4.0' compile 'com.bignerdranch.android:recyclerview-multiselect:0.2' From cd75718d56b0491769c15361689da12ca9463f4b Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 1 Oct 2017 09:16:31 +0200 Subject: [PATCH 84/89] try adding missing media files in the mediastore by scanning it --- .../com/simplemobiletools/gallery/helpers/MediaFetcher.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt index 210e44258..ac3178dc7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt @@ -270,8 +270,10 @@ class MediaFetcher(val context: Context) { val medium = Medium(filename, file.absolutePath, isVideo, dateModified, dateTaken, size) val isAlreadyAdded = curMedia.any { it.path == file.absolutePath } - if (!isAlreadyAdded) + if (!isAlreadyAdded) { curMedia.add(medium) + context.scanPath(file.absolutePath) {} + } } } From 0ef76d857c8d2e6473b8c356b974e1e9edb60c2e Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 1 Oct 2017 09:34:03 +0200 Subject: [PATCH 85/89] update version to 2.15.1 --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index c12f5fb84..44cc83b52 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "com.simplemobiletools.gallery" minSdkVersion 16 targetSdkVersion 23 - versionCode 133 - versionName "2.15.0" + versionCode 134 + versionName "2.15.1" } signingConfigs { From a8b64a6587402f561e250ef2a346fb1c335d0707 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 1 Oct 2017 09:34:32 +0200 Subject: [PATCH 86/89] updating changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea35d3112..ce87f8506 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ Changelog ========== +Version 2.15.1 *(2017-10-01)* +---------------------------- + + * Updated commons library with minor fixes + Version 2.15.0 *(2017-10-01)* ---------------------------- From 1d9fadf58e6ee6536f1cc78f69a790b3e31034f2 Mon Sep 17 00:00:00 2001 From: gregory678 Date: Mon, 2 Oct 2017 12:44:26 +0200 Subject: [PATCH 87/89] Updates and fixes for 2.15.1 --- app/src/main/res/values-pl/strings.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 0c8b066f8..1e4c90da8 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -57,7 +57,7 @@ Szerokość Wysokość Zachowaj proporcje - Wpisz poprawną rozdzielczość +    Podaj poprawną rozdzielczość Edycja @@ -98,14 +98,14 @@ Losowa kolejność Używaj płynnych przejść    Odwrotna kolejność - Loop slideshow +    Zapętlaj Pokaz slajdów zakończony Nie znalazłem multimediów do pokazu slajdów - Change view type - Grid - List +    Zmień typ widoku +    Siatka +    Lista Pokazuj ukryte foldery From 4203939d628c81e8d271157771fc68ccabad7bae Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 2 Oct 2017 18:27:42 +0200 Subject: [PATCH 88/89] fix #378, allow adding multiple items as email attachments --- app/build.gradle | 2 +- .../gallery/activities/MainActivity.kt | 78 ++++++++++++------- .../gallery/activities/MediaActivity.kt | 12 ++- .../gallery/adapters/MediaAdapter.kt | 18 ++++- .../gallery/dialogs/PickMediumDialog.kt | 2 +- .../gallery/helpers/Constants.kt | 1 + app/src/main/res/menu/cab_media.xml | 5 ++ 7 files changed, 84 insertions(+), 34 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 44cc83b52..41c499e1e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -37,7 +37,7 @@ android { } dependencies { - compile 'com.simplemobiletools:commons:2.29.0' + compile 'com.simplemobiletools:commons:2.29.1' compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0' compile 'com.theartofdev.edmodo:android-image-cropper:2.4.0' compile 'com.bignerdranch.android:recyclerview-multiselect:0.2' 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 76d0303a3..8a9da9d4a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -2,6 +2,7 @@ package com.simplemobiletools.gallery.activities import android.Manifest import android.app.Activity +import android.content.ClipData import android.content.Intent import android.content.pm.PackageManager import android.net.Uri @@ -412,36 +413,22 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) { if (resultCode == Activity.RESULT_OK) { - if (requestCode == PICK_MEDIA && resultData?.data != null) { - Intent().apply { + if (requestCode == PICK_MEDIA && resultData != null) { + val resultIntent = Intent() + if (mIsGetImageContentIntent || mIsGetVideoContentIntent || mIsGetAnyContentIntent) { + when { + intent.extras?.containsKey(MediaStore.EXTRA_OUTPUT) == true -> fillExtraOutput(resultData) + resultData.extras?.containsKey(PICKED_PATHS) == true -> fillPickedPaths(resultData, resultIntent) + else -> fillIntentPath(resultData, resultIntent) + } + } else if ((mIsPickImageIntent || mIsPickVideoIntent)) { val path = resultData.data.path val uri = Uri.fromFile(File(path)) - if (mIsGetImageContentIntent || mIsGetVideoContentIntent || mIsGetAnyContentIntent) { - if (intent.extras?.containsKey(MediaStore.EXTRA_OUTPUT) == true) { - var inputStream: InputStream? = null - var outputStream: OutputStream? = null - try { - val output = intent.extras.get(MediaStore.EXTRA_OUTPUT) as Uri - inputStream = FileInputStream(File(path)) - outputStream = contentResolver.openOutputStream(output) - inputStream.copyTo(outputStream) - } catch (ignored: FileNotFoundException) { - } finally { - inputStream?.close() - outputStream?.close() - } - } else { - val type = File(path).getMimeType("image/jpeg") - setDataAndTypeAndNormalize(uri, type) - flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION - } - } else if (mIsPickImageIntent || mIsPickVideoIntent) { - data = uri - flags = Intent.FLAG_GRANT_READ_URI_PERMISSION - } - - setResult(Activity.RESULT_OK, this) + resultIntent.data = uri + resultIntent.flags = Intent.FLAG_GRANT_READ_URI_PERMISSION } + + setResult(Activity.RESULT_OK, resultIntent) finish() } else if (requestCode == PICK_WALLPAPER) { setResult(Activity.RESULT_OK) @@ -451,6 +438,42 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { super.onActivityResult(requestCode, resultCode, resultData) } + private fun fillExtraOutput(resultData: Intent) { + val path = resultData.data.path + var inputStream: InputStream? = null + var outputStream: OutputStream? = null + try { + val output = intent.extras.get(MediaStore.EXTRA_OUTPUT) as Uri + inputStream = FileInputStream(File(path)) + outputStream = contentResolver.openOutputStream(output) + inputStream.copyTo(outputStream) + } catch (ignored: FileNotFoundException) { + } finally { + inputStream?.close() + outputStream?.close() + } + } + + private fun fillPickedPaths(resultData: Intent, resultIntent: Intent) { + val paths = resultData.extras.getStringArrayList(PICKED_PATHS) + val uris = paths.map { Uri.fromFile(File(it)) } as ArrayList + val clipData = ClipData("Attachment", arrayOf("image/*", "video/*"), ClipData.Item(uris.removeAt(0))) + + uris.forEach { + clipData.addItem(ClipData.Item(it)) + } + + resultIntent.clipData = clipData + } + + private fun fillIntentPath(resultData: Intent, resultIntent: Intent) { + val path = resultData.data.path + val uri = Uri.fromFile(File(path)) + val type = File(path).getMimeType("image/jpeg") + resultIntent.setDataAndTypeAndNormalize(uri, type) + resultIntent.flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION + } + private fun itemClicked(path: String) { Intent(this, MediaActivity::class.java).apply { putExtra(DIRECTORY, path) @@ -462,6 +485,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { putExtra(GET_IMAGE_INTENT, mIsPickImageIntent || mIsGetImageContentIntent) putExtra(GET_VIDEO_INTENT, mIsPickVideoIntent || mIsGetVideoContentIntent) putExtra(GET_ANY_INTENT, mIsGetAnyContentIntent) + putExtra(Intent.EXTRA_ALLOW_MULTIPLE, intent.getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE, false)) startActivityForResult(this, PICK_MEDIA) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index f9816269f..4851c7305 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -46,6 +46,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { private var mIsGetVideoIntent = false private var mIsGetAnyIntent = false private var mIsGettingMedia = false + private var mAllowPickingMultiple = false private var mShowAll = false private var mLoadedInitialPhotos = false private var mStoredAnimateGifs = true @@ -68,6 +69,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { mIsGetImageIntent = getBooleanExtra(GET_IMAGE_INTENT, false) mIsGetVideoIntent = getBooleanExtra(GET_VIDEO_INTENT, false) mIsGetAnyIntent = getBooleanExtra(GET_ANY_INTENT, false) + mAllowPickingMultiple = getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE, false) } media_refresh_layout.setOnRefreshListener({ getMedia() }) @@ -159,7 +161,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { val currAdapter = media_grid.adapter if (currAdapter == null) { - media_grid.adapter = MediaAdapter(this, mMedia, this, mIsGetAnyIntent) { + media_grid.adapter = MediaAdapter(this, mMedia, this, mIsGetAnyIntent, mAllowPickingMultiple) { itemClicked(it.path) } } else { @@ -561,4 +563,12 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { override fun itemLongClicked(position: Int) { media_grid.setDragSelectActive(position) } + + override fun selectedPaths(paths: ArrayList) { + Intent().apply { + putExtra(PICKED_PATHS, paths) + setResult(Activity.RESULT_OK, this) + } + finish() + } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt index 50a03e7ca..7296f51d7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt @@ -25,7 +25,7 @@ import java.io.File import java.util.* class MediaAdapter(val activity: SimpleActivity, var media: MutableList, val listener: MediaOperationsListener?, val isPickIntent: Boolean, - val itemClick: (Medium) -> Unit) : RecyclerView.Adapter() { + val allowMultiplePicks: Boolean, val itemClick: (Medium) -> Unit) : RecyclerView.Adapter() { val multiSelector = MultiSelector() val config = activity.config @@ -72,6 +72,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, private val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) { override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean { when (item.itemId) { + R.id.cab_confirm_selection -> confirmSelection() R.id.cab_properties -> showProperties() R.id.cab_rename -> renameFile() R.id.cab_edit -> editFile() @@ -97,6 +98,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, override fun onPrepareActionMode(actionMode: ActionMode?, menu: Menu): Boolean { menu.findItem(R.id.cab_rename).isVisible = selectedPositions.size <= 1 menu.findItem(R.id.cab_edit).isVisible = selectedPositions.size == 1 && media.size > selectedPositions.first() && media[selectedPositions.first()].isImage() + menu.findItem(R.id.cab_confirm_selection).isVisible = isPickIntent && allowMultiplePicks && selectedPositions.size > 0 checkHideBtnVisibility(menu) @@ -127,6 +129,11 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, } } + private fun confirmSelection() { + val paths = getSelectedMedia().map { it.path } as ArrayList + listener?.selectedPaths(paths) + } + private fun showProperties() { if (selectedPositions.size <= 1) { PropertiesDialog(activity, media[selectedPositions.first()].path, config.shouldShowHidden) @@ -247,7 +254,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder { val layoutType = if (isListViewType) R.layout.photo_video_item_list else R.layout.photo_video_item_grid val view = LayoutInflater.from(parent?.context).inflate(layoutType, parent, false) - return ViewHolder(view, adapterListener, activity, multiSelectorMode, multiSelector, listener, isPickIntent, itemClick) + return ViewHolder(view, adapterListener, activity, multiSelectorMode, multiSelector, listener, allowMultiplePicks || !isPickIntent, itemClick) } override fun onBindViewHolder(holder: ViewHolder, position: Int) { @@ -319,7 +326,8 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, } class ViewHolder(val view: View, val adapterListener: MyAdapterListener, val activity: SimpleActivity, val multiSelectorCallback: ModalMultiSelectorCallback, - val multiSelector: MultiSelector, val listener: MediaOperationsListener?, val isPickIntent: Boolean, val itemClick: (Medium) -> (Unit)) : + val multiSelector: MultiSelector, val listener: MediaOperationsListener?, val allowMultiplePicks: Boolean, + val itemClick: (Medium) -> (Unit)) : SwappingHolder(view, MultiSelector()) { fun bindView(medium: Medium, displayFilenames: Boolean, scrollVertically: Boolean, isListViewType: Boolean, textColor: Int): View { itemView.apply { @@ -334,7 +342,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, } setOnClickListener { viewClicked(medium) } - setOnLongClickListener { if (isPickIntent) viewClicked(medium) else viewLongClicked(); true } + setOnLongClickListener { if (allowMultiplePicks) viewLongClicked() else viewClicked(medium); true } } return itemView } @@ -377,5 +385,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, fun deleteFiles(files: ArrayList) fun itemLongClicked(position: Int) + + fun selectedPaths(paths: ArrayList) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickMediumDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickMediumDialog.kt index 4c57c68f1..fe0a86add 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickMediumDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickMediumDialog.kt @@ -47,7 +47,7 @@ class PickMediumDialog(val activity: SimpleActivity, val path: String, val callb return shownMedia = media - val adapter = MediaAdapter(activity, media, null, true) { + val adapter = MediaAdapter(activity, media, null, true, false) { callback(it.path) dialog.dismiss() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt index 18bf6ac29..d875a0f18 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt @@ -63,6 +63,7 @@ val SET_WALLPAPER_INTENT = "set_wallpaper_intent" val DIRECTORIES = "directories2" val IS_VIEW_INTENT = "is_view_intent" val IS_FROM_GALLERY = "is_from_gallery" +val PICKED_PATHS = "picked_paths" val REQUEST_EDIT_IMAGE = 1 val REQUEST_SET_AS = 2 diff --git a/app/src/main/res/menu/cab_media.xml b/app/src/main/res/menu/cab_media.xml index 4b47e6025..fa787d520 100644 --- a/app/src/main/res/menu/cab_media.xml +++ b/app/src/main/res/menu/cab_media.xml @@ -1,6 +1,11 @@ + Date: Mon, 2 Oct 2017 22:47:23 +0200 Subject: [PATCH 89/89] fix #381, handle media pick intents in Show All Folders content view --- .../gallery/activities/MainActivity.kt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 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 8a9da9d4a..b25521bb1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -252,9 +252,14 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { config.showAll = true Intent(this, MediaActivity::class.java).apply { putExtra(DIRECTORY, "/") - startActivity(this) + + if (mIsThirdPartyIntent) { + handleMediaIntent(this) + } else { + startActivity(this) + finish() + } } - finish() } private fun changeViewType() { @@ -477,7 +482,12 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { private fun itemClicked(path: String) { Intent(this, MediaActivity::class.java).apply { putExtra(DIRECTORY, path) + handleMediaIntent(this) + } + } + private fun handleMediaIntent(intent: Intent) { + intent.apply { if (mIsSetWallpaperIntent) { putExtra(SET_WALLPAPER_INTENT, true) startActivityForResult(this, PICK_WALLPAPER)