From 7358bb7ccec3560e562f2e6e04f8295aab2f773a Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 31 May 2017 20:36:20 +0200 Subject: [PATCH 01/33] handle Crop intent for setting contact photo etc --- app/src/main/AndroidManifest.xml | 12 ++++++++++ .../gallery/activities/EditActivity.kt | 24 ++++++++++++++++--- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f3cf094b3..8c640a923 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -145,6 +145,18 @@ + + + + + + + + + + + + Date: Wed, 31 May 2017 22:06:54 +0200 Subject: [PATCH 02/33] fix a different type of contact photo picking too --- .../gallery/activities/MainActivity.kt | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 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 e2c9649b9..aa86c6a72 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -28,6 +28,9 @@ import com.simplemobiletools.gallery.models.Directory import com.simplemobiletools.gallery.views.MyScalableRecyclerView import kotlinx.android.synthetic.main.activity_main.* import java.io.File +import java.io.FileInputStream +import java.io.InputStream +import java.io.OutputStream import java.util.* class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { @@ -291,9 +294,23 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { val path = resultData.data.path val uri = Uri.fromFile(File(path)) if (mIsGetImageContentIntent || mIsGetVideoContentIntent || mIsGetAnyContentIntent) { - val type = File(path).getMimeType("image/jpeg") - setDataAndTypeAndNormalize(uri, type) - flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION + 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) + } 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 From f4ddc129112246e229d27c3da1fb8560ebc1af22 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 31 May 2017 23:04:56 +0200 Subject: [PATCH 03/33] add another check at getting current media of viewpager --- .../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 24aa738e7..652ac5b8d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -498,7 +498,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } private fun getCurrentMedium(): Medium? { - return if (mMedia.isEmpty()) + return if (mMedia.isEmpty() || mPos >= mMedia.size) null else mMedia[Math.min(mPos, mMedia.size - 1)] From d2713635d5c01d14305630736d7ba0a44f2402ec Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 31 May 2017 23:20:34 +0200 Subject: [PATCH 04/33] add an additional null check at surfaceholder of video fragment --- .../com/simplemobiletools/gallery/fragments/VideoFragment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 3f894e8e8..5359bcc67 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt @@ -302,7 +302,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee if (mSurfaceHolder == null) mSurfaceHolder = mSurfaceView!!.holder - if (activity == null || !mSurfaceHolder!!.surface.isValid) + if (activity == null || mSurfaceHolder == null || !mSurfaceHolder!!.surface.isValid) return initMediaPlayer() From 6248f0db76d4d73af9ffe0211749387e6d78d0b5 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 31 May 2017 23:36:43 +0200 Subject: [PATCH 05/33] reuse the same list of media at thumbnails and fullscreen view --- .../simplemobiletools/gallery/activities/MediaActivity.kt | 7 ++++++- .../gallery/activities/ViewPagerActivity.kt | 6 +++--- 2 files changed, 9 insertions(+), 4 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 8e9d307c3..3892816ff 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 mLoadedInitialPhotos = false private var mStoredAnimateGifs = true private var mStoredCropThumbnails = true + private var mLastDrawnHashCode = 0 private var mLastMediaModified = 0 private var mLastMediaHandler = Handler() @@ -393,9 +394,13 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { media_refresh_layout.isRefreshing = false checkLastMediaChanged() - if (media.hashCode() == mMedia.hashCode()) + if (mLastDrawnHashCode == 0) + mLastDrawnHashCode = media.hashCode() + + if (media.hashCode() == mMedia.hashCode() && media.hashCode() == mLastDrawnHashCode) return + mLastDrawnHashCode = media.hashCode() mMedia = media setupAdapter() storeFolder() 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 652ac5b8d..95024233f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -27,6 +27,7 @@ import com.simplemobiletools.commons.dialogs.PropertiesDialog import com.simplemobiletools.commons.dialogs.RenameItemDialog import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.gallery.R +import com.simplemobiletools.gallery.activities.MediaActivity.Companion.mMedia import com.simplemobiletools.gallery.adapters.MyPagerAdapter import com.simplemobiletools.gallery.asynctasks.GetMediaAsynctask import com.simplemobiletools.gallery.dialogs.SaveAsDialog @@ -42,7 +43,6 @@ import java.util.* class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, ViewPagerFragment.FragmentListener { lateinit var mOrientationEventListener: OrientationEventListener - private var mMedia = ArrayList() private var mPath = "" private var mDirectory = "" @@ -98,8 +98,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View mDirectory = File(mPath).parent title = mPath.getFilenameFromPath() - if (MediaActivity.mMedia.isNotEmpty()) - gotMedia(MediaActivity.mMedia) + if (mMedia.isNotEmpty()) + gotMedia(mMedia) reloadViewPager() scanPath(mPath) {} From 5beadedfe23f5faab8db6b0ea3a9860b01651268 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 31 May 2017 23:39:13 +0200 Subject: [PATCH 06/33] small tweak to viewpager cursor --- .../gallery/activities/ViewPagerActivity.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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 95024233f..a8f4c20f0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -73,10 +73,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View try { val proj = arrayOf(MediaStore.Images.Media.DATA) cursor = contentResolver.query(uri, proj, null, null, null) - if (cursor != null) { - val dataIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA) - cursor.moveToFirst() - mPath = cursor.getString(dataIndex) + if (cursor?.moveToFirst() == true) { + mPath = cursor.getStringValue(MediaStore.Images.Media.DATA) } } finally { cursor?.close() From 52e95827ec00e5db348f341566d02204e10097a0 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 2 Jun 2017 21:40:49 +0200 Subject: [PATCH 07/33] update commons to 2.19.4 --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 786bb1d31..4e185cebc 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -32,7 +32,7 @@ android { } dependencies { - compile 'com.simplemobiletools:commons:2.19.0' + compile 'com.simplemobiletools:commons:2.19.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 5a4b6065fb0294d29ed19ee3bf369170537e0972 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 2 Jun 2017 21:57:31 +0200 Subject: [PATCH 08/33] fix #270, temporarily show hidden files when opening a third party intent --- .../gallery/activities/PhotoVideoActivity.kt | 2 ++ .../gallery/activities/ViewPagerActivity.kt | 11 +++++++++++ .../simplemobiletools/gallery/helpers/Constants.kt | 1 + 3 files changed, 14 insertions(+) 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 06c4d890a..56e39f852 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_VIEW_INTENT import com.simplemobiletools.gallery.helpers.MEDIUM import com.simplemobiletools.gallery.models.Medium import kotlinx.android.synthetic.main.fragment_holder.* @@ -119,6 +120,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList private fun sendViewPagerIntent(path: String) { Intent(this, ViewPagerActivity::class.java).apply { + putExtra(IS_VIEW_INTENT, true) 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 a8f4c20f0..4862f84f3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -90,6 +90,10 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View return } + if (intent.extras?.containsKey(IS_VIEW_INTENT) == true) { + config.temporarilyShowHidden = true + } + mMedia = ArrayList() showSystemUI() @@ -107,6 +111,13 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View view_pager.background = ColorDrawable(Color.BLACK) } + override fun onDestroy() { + super.onDestroy() + if (intent.extras?.containsKey(IS_VIEW_INTENT) == true) { + config.temporarilyShowHidden = false + } + } + private fun setupOrientationEventListener() { mOrientationEventListener = object : OrientationEventListener(this, SensorManager.SENSOR_DELAY_NORMAL) { override fun onOrientationChanged(orientation: Int) { 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 5ebaa98a6..0a3b1ef3e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt @@ -33,6 +33,7 @@ val GET_VIDEO_INTENT = "get_video_intent" 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 REQUEST_EDIT_IMAGE = 1 val REQUEST_SET_WALLPAPER = 2 From ea42c4f1aa65162f63d8a457af84c8fa0f188a9c Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 2 Jun 2017 22:17:30 +0200 Subject: [PATCH 09/33] catch exceptions at fetching media --- .../com/simplemobiletools/gallery/extensions/context.kt | 8 ++++++-- 1 file changed, 6 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 5c781f4df..e4e04a2d4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt @@ -57,8 +57,12 @@ fun Context.getFilesFrom(curPath: String, isPickImage: Boolean, isPickVideo: Boo 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 cur = contentResolver.query(uri, projection, selection, selectionArgs, getSortingForFolder(curPath)) - return parseCursor(this, cur, isPickImage, isPickVideo, curPath) + try { + val cur = contentResolver.query(uri, projection, selection, selectionArgs, getSortingForFolder(curPath)) + return parseCursor(this, cur, isPickImage, isPickVideo, curPath) + } catch (e: Exception) { + return ArrayList() + } } private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isPickVideo: Boolean, curPath: String): ArrayList { From d480aab06353020f68213ced2c7939a6d09ca283 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 2 Jun 2017 22:41:01 +0200 Subject: [PATCH 10/33] catch out of memory errors at setting wallpaper --- app/build.gradle | 2 +- .../gallery/activities/SetWallpaperActivity.kt | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 4e185cebc..f88b686a3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -32,7 +32,7 @@ android { } dependencies { - compile 'com.simplemobiletools:commons:2.19.4' + compile 'com.simplemobiletools:commons:2.19.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/SetWallpaperActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SetWallpaperActivity.kt index 1dd599eff..9d2fddb3c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SetWallpaperActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SetWallpaperActivity.kt @@ -94,8 +94,13 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete val wantedHeight = wallpaperManager.desiredMinimumHeight val ratio = wantedHeight / bitmap.height.toFloat() val wantedWidth = (bitmap.width * ratio).toInt() - wallpaperManager.setBitmap(Bitmap.createScaledBitmap(bitmap, wantedWidth, wantedHeight, true)) - setResult(Activity.RESULT_OK) + try { + wallpaperManager.setBitmap(Bitmap.createScaledBitmap(bitmap, wantedWidth, wantedHeight, true)) + setResult(Activity.RESULT_OK) + } catch (e: OutOfMemoryError) { + toast(R.string.out_of_memory_error) + setResult(Activity.RESULT_CANCELED) + } finish() }).start() } else { From e26f7fe93ef971e9e049562aaed6eb92a01a5a91 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 2 Jun 2017 22:48:24 +0200 Subject: [PATCH 11/33] use "Hide folder" instead of "Hide" if un/hiding folders --- app/src/main/res/menu/cab_directories.xml | 4 ++-- app/src/main/res/menu/menu_media.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/res/menu/cab_directories.xml b/app/src/main/res/menu/cab_directories.xml index 5900ba1e9..1a7c733a8 100644 --- a/app/src/main/res/menu/cab_directories.xml +++ b/app/src/main/res/menu/cab_directories.xml @@ -24,12 +24,12 @@ Date: Fri, 2 Jun 2017 22:48:33 +0200 Subject: [PATCH 12/33] update version to 2.10.8 --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index f88b686a3..c5edcbb4f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "com.simplemobiletools.gallery" minSdkVersion 16 targetSdkVersion 23 - versionCode 106 - versionName "2.10.7" + versionCode 107 + versionName "2.10.8" } signingConfigs { From 0c3a4c625370bf45ccf25baa0e6954830ddd4183 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 2 Jun 2017 22:48:54 +0200 Subject: [PATCH 13/33] updating changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d63e5505..16960c35f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ Changelog ========== +Version 2.10.8 *(2017-06-02)* +---------------------------- + + * Always properly show hidden files from third party intents + * Properly handle Crop intent used for example at selecting contact photos + * Couple smaller fixes and crashfixes + Version 2.10.7 *(2017-05-29)* ---------------------------- From 3001ea4a235d341d792f16277d0a89e3bbfb6cb5 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 3 Jun 2017 08:37:52 +0200 Subject: [PATCH 14/33] adding a crashfix at updating actionbar title --- .../simplemobiletools/gallery/activities/ViewPagerActivity.kt | 4 +++- 1 file changed, 3 insertions(+), 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 4862f84f3..d92ed325a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -502,7 +502,9 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View private fun updateActionbarTitle() { runOnUiThread { - title = mMedia[mPos].path.getFilenameFromPath() + if (mPos < mMedia.size) { + title = mMedia[mPos].path.getFilenameFromPath() + } } } From b8dc90de87a031476efc85bde2162fd8a1a798fb Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 6 Jun 2017 17:52:57 +0200 Subject: [PATCH 15/33] add line number keeping in proguard --- app/proguard-rules.pro | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index a9c0f371b..34de0fb81 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -1,2 +1,5 @@ -keep class com.simplemobiletools.** { *; } -dontwarn com.simplemobiletools.** + +-renamesourcefileattribute SourceFile +-keepattributes SourceFile, LineNumberTable From 9676a78c1d5191b98e6a8dd8573860fc9ece67d3 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 6 Jun 2017 19:27:54 +0200 Subject: [PATCH 16/33] add some strings related to changing album cover photo --- app/src/main/res/values-cs/strings.xml | 3 +++ app/src/main/res/values-de/strings.xml | 3 +++ app/src/main/res/values-es/strings.xml | 3 +++ app/src/main/res/values-fr/strings.xml | 3 +++ app/src/main/res/values-hu/strings.xml | 3 +++ app/src/main/res/values-it/strings.xml | 3 +++ app/src/main/res/values-ja/strings.xml | 3 +++ app/src/main/res/values-pl/strings.xml | 3 +++ app/src/main/res/values-pt-rBR/strings.xml | 3 +++ app/src/main/res/values-pt/strings.xml | 3 +++ app/src/main/res/values-ru/strings.xml | 3 +++ app/src/main/res/values-sk/strings.xml | 3 +++ app/src/main/res/values-sv/strings.xml | 3 +++ app/src/main/res/values-tr/strings.xml | 3 +++ app/src/main/res/values-zh-rCN/strings.xml | 3 +++ app/src/main/res/values-zh-rTW/strings.xml | 3 +++ app/src/main/res/values/strings.xml | 3 +++ 17 files changed, 51 insertions(+) diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index b33d8328a..6a050bdb0 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -20,6 +20,9 @@ Zvýšit počet sloupců Snížit počet sloupců Dočasně zobrazit skryté + Change cover image + Select photo + Use default Tato funkce skryje složku, včetně podsložek, přidáním souboru \'.nomedia\'. Zobrazíte je zvolením možnosti \'Zobrazit skryté složky\' v nastavení. Pokračovat? diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 6740ea0d9..9e11aa57d 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -20,6 +20,9 @@ Kacheln verkleinern Kacheln vergrößern Verstecktes temporär zeigen + Change cover image + Select photo + Use default 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? diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 2f5f40426..76f58a47a 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -20,6 +20,9 @@ Aumentar el número de columnas Reducir el número de columnas Mostrar ocultos temporalmente + Change cover image + Select photo + Use default Esta función oculta la carpeta agregando un archivo \'.nomedia\' en ella, y ocultará también las subcarpetas. Puede mostrarlas cambiando la opción \'Mostrar carpetas ocultas\' en los Ajustes. ¿Continuar? diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 14b972ee6..f7f193ee6 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -20,6 +20,9 @@ Augmenter le nombre de colonnes Réduire le nombre de colonnes Afficher temporairement les fichiers masqués + Change cover image + Select photo + Use default Cette option masque le dossier en ajoutant un fichier \'.nomedia\' à l\'intérieur, cela masquera aussi tous les sous-dossiers. Vous pouvez les voir en modifiant l\'option \'Afficher les dossiers cachés\' dans les Paramètres. Continuer ? diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index 06fd2d48e..04f2444bf 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -20,6 +20,9 @@ Increase column count Reduce column count Temporarily show hidden + Change cover image + Select photo + Use default 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? diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index fa72ec622..8e4f8f860 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -20,6 +20,9 @@ Aumenta numero colonne Riduci numero colonne Mostra temporaneamente nascosti + Change cover image + Select photo + Use default 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? diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 1a8f07151..e14475379 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -20,6 +20,9 @@ Increase column count Reduce column count Temporarily show hidden + Change cover image + Select photo + Use default 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? diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index f09badda8..7d2b270d5 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -20,6 +20,9 @@ Zwiększ liczbę kolumn Zmniejsz liczbę kolumn Temporarily show hidden + Change cover image + Select photo + Use default Ta funkcja ukrywa folder dodając \'. \' Nomedia plik do niego, można tak ukryć wszystkie podfoldery. Można je zobaczyć poprzez przełączanie \'Pokaż ukryte foldery \' opcję w ustawieniach. Kontyntynuj? diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 704b2ca4b..e94fb4e9a 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -20,6 +20,9 @@ Aumentar número de colunas Reduzir número de colunas Mostrar pastas ocultas temporariamente + Change cover image + Select photo + Use default Esta opção oculta uma pasta com a adição de um arquivo \'.nomedia\' dentro dela, e irá ocultar todas as subpastas que estejam dentro da mesma. Você poderá rever essas pastas com a opção \'Mostrar pastas ocultas\'. Continuar? diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index fa5099f3f..0cc0e2bff 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -20,6 +20,9 @@ Aumentar número de colunas Reduzir número de colunas Mostrar ocultas temporariamente + Change cover image + Select photo + Use default Esta opção oculta uma pasta com a adição de um ficheiro \'.nomedia\' na pasta, e irá ocultar todas as subpastas existentes. Pode ver as pastas com a opção \'Mostrar pastas ocultas\'. Continuar? diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 70e652789..f0dfe5c73 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -20,6 +20,9 @@ Добавить 1 столбец Убрать 1 столбец Временный показ скрытых + Change cover image + Select photo + Use default Эта опция скрывает папку, добавляя в неё файл \'.nomedia\'; будут скрыты все подпапки. Можно показывать их, переключая \'Показать скрытые папки\' в настройках. Продолжить? diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index 08cdcd80c..29ef555a9 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -20,6 +20,9 @@ Zvýšiť počet stĺpcov Znížiť počet stĺpcov Dočasne zobraziť skryté + Zmeniť obal albumu + Zvoliť foto + Použiť predvolený Táto funkcia skryje priečinok pridaním súboru \'.nomedia\', skryté budú aj podpriečinky. Môžete ich vidieť zvolením možnosti \'Zobraziť skryté priečinky\' v nastaveniach. Pokračovať? diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 844ac7150..aecfe3444 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -20,6 +20,9 @@ Increase column count Reduce column count Temporarily show hidden + Change cover image + Select photo + Use default 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? diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index d3e441d8a..6b456a3e8 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -20,6 +20,9 @@ Sütun sayısını artır Sütun sayısını azalt Geçici olarak gizli göster + Change cover image + Select photo + Use default Bu işlev, klasöre\'.medya yok\'dosyası ekleyerek gizler; tüm alt klasörleri de gizler. Bunları Ayarlar\'da\'Gizli klasörleri göster\'seçeneğine basarak görebilirsiniz. Devam et? diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index aa0150eb8..a7f8cb590 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -20,6 +20,9 @@ 增加一行 减少一行 显示/隐藏缓存内容 + Change cover image + Select photo + Use default 通过添加一个 \'.nomedia\' 文件到目录下,该目录包括子目录下的所有媒体都不会被扫描。 你可以通过设置中的 \'Show hidden folders\' 选项改变设置, 继续? diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index a1f2f43c8..c531f2e1a 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -20,6 +20,9 @@ Increase column count Reduce column count Temporarily show hidden + Change cover image + Select photo + Use default 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? diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fc650dc22..5517162a2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -20,6 +20,9 @@ Increase column count Reduce column count Temporarily show hidden + Change cover image + Select photo + Use default 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? From e05ef4a9f25ad3ec9b98418f29a87d80ed4e3ec7 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 6 Jun 2017 20:00:45 +0200 Subject: [PATCH 17/33] add the menu buttons for changing album cover --- .../gallery/adapters/DirectoryAdapter.kt | 7 +++++++ app/src/main/res/menu/cab_directories.xml | 13 +++++++++++++ 2 files changed, 20 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 4a5876a18..4a60982f6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -111,6 +111,8 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList copyMoveTo(false) R.id.cab_select_all -> selectAll() R.id.cab_delete -> askConfirmDelete() + R.id.cab_select_photo -> changeAlbumCover(false) + R.id.cab_use_default -> changeAlbumCover(true) else -> return false } return true @@ -125,6 +127,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList { val paths = HashSet(selectedPositions.size) selectedPositions.forEach { paths.add(dirs[it].path) } diff --git a/app/src/main/res/menu/cab_directories.xml b/app/src/main/res/menu/cab_directories.xml index 1a7c733a8..2267e4c6e 100644 --- a/app/src/main/res/menu/cab_directories.xml +++ b/app/src/main/res/menu/cab_directories.xml @@ -48,6 +48,19 @@ android:icon="@drawable/ic_select_all" android:title="@string/select_all" app:showAsAction="ifRoom"/> + + + + + + Date: Tue, 6 Jun 2017 20:25:31 +0200 Subject: [PATCH 18/33] rename PickAlbumDialog to PickDirectoryDialog --- .../simplemobiletools/gallery/activities/SimpleActivity.kt | 4 ++-- .../dialogs/{PickAlbumDialog.kt => PickDirectoryDialog.kt} | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/{PickAlbumDialog.kt => PickDirectoryDialog.kt} (95%) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SimpleActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SimpleActivity.kt index 86ca2eada..6cfd6eb38 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SimpleActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SimpleActivity.kt @@ -3,7 +3,7 @@ package com.simplemobiletools.gallery.activities import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.extensions.toast import com.simplemobiletools.gallery.R -import com.simplemobiletools.gallery.dialogs.PickAlbumDialog +import com.simplemobiletools.gallery.dialogs.PickDirectoryDialog import java.io.File import java.util.* @@ -15,7 +15,7 @@ open class SimpleActivity : BaseSimpleActivity() { } val source = if (files[0].isFile) files[0].parent else files[0].absolutePath - PickAlbumDialog(this, source) { + PickDirectoryDialog(this, source) { copyMoveFilesTo(files, source.trimEnd('/'), it, isCopyOperation, true, callback) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickAlbumDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickDirectoryDialog.kt similarity index 95% rename from app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickAlbumDialog.kt rename to app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickDirectoryDialog.kt index 9318120bb..9c68c310f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickAlbumDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickDirectoryDialog.kt @@ -15,7 +15,7 @@ import com.simplemobiletools.gallery.extensions.getCachedDirectories import com.simplemobiletools.gallery.models.Directory import kotlinx.android.synthetic.main.dialog_album_picker.view.* -class PickAlbumDialog(val activity: SimpleActivity, val sourcePath: String, val callback: (path: String) -> Unit) { +class PickDirectoryDialog(val activity: SimpleActivity, val sourcePath: String, val callback: (path: String) -> Unit) { var dialog: AlertDialog var directoriesGrid: RecyclerView var shownDirectories: ArrayList = ArrayList() From add3320c4af913b3ca2e55978bd9f008be0fe0d0 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 6 Jun 2017 21:16:19 +0200 Subject: [PATCH 19/33] allow setting up custom album covers --- .../gallery/adapters/DirectoryAdapter.kt | 28 +++++++++- .../gallery/dialogs/PickDirectoryDialog.kt | 4 +- .../gallery/dialogs/PickMediumDialog.kt | 56 +++++++++++++++++++ .../gallery/helpers/Config.kt | 4 ++ .../gallery/helpers/Constants.kt | 3 +- .../gallery/models/AlbumCover.kt | 3 + ...picker.xml => dialog_directory_picker.xml} | 1 + .../main/res/layout/dialog_medium_picker.xml | 10 ++++ 8 files changed, 105 insertions(+), 4 deletions(-) create mode 100644 app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickMediumDialog.kt create mode 100644 app/src/main/kotlin/com/simplemobiletools/gallery/models/AlbumCover.kt rename app/src/main/res/layout/{dialog_album_picker.xml => dialog_directory_picker.xml} (90%) create mode 100644 app/src/main/res/layout/dialog_medium_picker.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 4a60982f6..8aaa5cb3d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -10,6 +10,8 @@ import com.bignerdranch.android.multiselector.ModalMultiSelectorCallback import com.bignerdranch.android.multiselector.MultiSelector import com.bignerdranch.android.multiselector.SwappingHolder import com.bumptech.glide.Glide +import com.google.gson.Gson +import com.google.gson.reflect.TypeToken import com.simplemobiletools.commons.dialogs.ConfirmationDialog import com.simplemobiletools.commons.dialogs.PropertiesDialog import com.simplemobiletools.commons.dialogs.RenameItemDialog @@ -20,7 +22,9 @@ import com.simplemobiletools.commons.extensions.toast import com.simplemobiletools.gallery.R 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.models.AlbumCover import com.simplemobiletools.gallery.models.Directory import kotlinx.android.synthetic.main.directory_item.view.* import kotlinx.android.synthetic.main.directory_tmb.view.* @@ -253,10 +257,10 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList() if (selectedPositions.isEmpty()) return + val files = ArrayList() selectedPositions.forEach { val dir = File(dirs[it].path) files.addAll(dir.listFiles().filter { it.isFile && it.isImageVideoGif() }) @@ -324,6 +328,28 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList>() {}.type + var albumCovers = Gson().fromJson>(config.albumCovers, listType) ?: ArrayList(1) + + if (useDefault) { + albumCovers = albumCovers.filterNot { it.path == path } as ArrayList + storeCovers(albumCovers) + } else { + PickMediumDialog(activity, path) { + albumCovers = albumCovers.filterNot { it.path == path } as ArrayList + albumCovers.add(AlbumCover(path, it)) + storeCovers(albumCovers) + } + } + } + + private fun storeCovers(albumCovers: ArrayList) { + activity.config.albumCovers = Gson().toJson(albumCovers) + actMode?.finish() listener?.refreshItems() } 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 9c68c310f..cf384829e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickDirectoryDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickDirectoryDialog.kt @@ -13,7 +13,7 @@ import com.simplemobiletools.gallery.asynctasks.GetDirectoriesAsynctask import com.simplemobiletools.gallery.extensions.config import com.simplemobiletools.gallery.extensions.getCachedDirectories import com.simplemobiletools.gallery.models.Directory -import kotlinx.android.synthetic.main.dialog_album_picker.view.* +import kotlinx.android.synthetic.main.dialog_directory_picker.view.* class PickDirectoryDialog(val activity: SimpleActivity, val sourcePath: String, val callback: (path: String) -> Unit) { var dialog: AlertDialog @@ -21,7 +21,7 @@ class PickDirectoryDialog(val activity: SimpleActivity, val sourcePath: String, var shownDirectories: ArrayList = ArrayList() init { - val view = LayoutInflater.from(activity).inflate(R.layout.dialog_album_picker, null) + val view = LayoutInflater.from(activity).inflate(R.layout.dialog_directory_picker, null) directoriesGrid = view.directories_grid dialog = AlertDialog.Builder(activity) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickMediumDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickMediumDialog.kt new file mode 100644 index 000000000..8d2bacf2b --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickMediumDialog.kt @@ -0,0 +1,56 @@ +package com.simplemobiletools.gallery.dialogs + +import android.support.v7.app.AlertDialog +import android.support.v7.widget.RecyclerView +import android.view.LayoutInflater +import com.google.gson.Gson +import com.google.gson.reflect.TypeToken +import com.simplemobiletools.commons.extensions.setupDialogStuff +import com.simplemobiletools.gallery.R +import com.simplemobiletools.gallery.activities.SimpleActivity +import com.simplemobiletools.gallery.adapters.MediaAdapter +import com.simplemobiletools.gallery.asynctasks.GetMediaAsynctask +import com.simplemobiletools.gallery.extensions.config +import com.simplemobiletools.gallery.models.Medium +import kotlinx.android.synthetic.main.dialog_medium_picker.view.* + +class PickMediumDialog(val activity: SimpleActivity, val path: String, val callback: (path: String) -> Unit) { + var dialog: AlertDialog + var mediaGrid: RecyclerView + var shownMedia: ArrayList = ArrayList() + + init { + val view = LayoutInflater.from(activity).inflate(R.layout.dialog_medium_picker, null) + mediaGrid = view.media_grid + + dialog = AlertDialog.Builder(activity) + .setPositiveButton(R.string.ok, null) + .setNegativeButton(R.string.cancel, null) + .create().apply { + activity.setupDialogStuff(view, this, R.string.select_photo) + + val token = object : TypeToken>() {}.type + val media = Gson().fromJson>(activity.config.loadFolderMedia(path), token) ?: ArrayList(1) + + if (media.isNotEmpty()) { + gotMedia(media) + } + + GetMediaAsynctask(activity, path, false, true, false) { + gotMedia(it) + }.execute() + } + } + + private fun gotMedia(media: ArrayList) { + if (media.hashCode() == shownMedia.hashCode()) + return + + shownMedia = media + val adapter = MediaAdapter(activity, media, null) { + callback(it.path) + dialog.dismiss() + } + mediaGrid.adapter = adapter + } +} 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 e84570f46..d35a981bf 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt @@ -167,4 +167,8 @@ class Config(context: Context) : BaseConfig(context) { var directories: String get() = prefs.getString(DIRECTORIES, "") set(directories) = prefs.edit().putString(DIRECTORIES, directories).apply() + + var albumCovers: String + get() = prefs.getString(ALBUM_COVERS, "") + set(albumCovers) = prefs.edit().putString(ALBUM_COVERS, albumCovers).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 0a3b1ef3e..21dc7c6de 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt @@ -17,12 +17,13 @@ val DARK_BACKGROUND = "dark_background" val PINNED_FOLDERS = "pinned_folders" val DIR_COLUMN_CNT = "dir_column_cnt" val MEDIA_COLUMN_CNT = "media_column_cnt" -val SHOW_ALL = "show_all" // display images and videos from all folders together +val SHOW_ALL = "show_all" // display images and videos from all folders together val SHOW_MEDIA = "show_media" val SAVE_FOLDER_PREFIX = "folder2_" val HIDE_FOLDER_TOOLTIP_SHOWN = "hide_folder_tooltip_shown" val EXCLUDED_FOLDERS = "excluded_folders" val INCLUDED_FOLDERS = "included_folders" +val ALBUM_COVERS = "album_covers" val NOMEDIA = ".nomedia" diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/models/AlbumCover.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/models/AlbumCover.kt new file mode 100644 index 000000000..f5937ad08 --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/models/AlbumCover.kt @@ -0,0 +1,3 @@ +package com.simplemobiletools.gallery.models + +data class AlbumCover(val path: String, val tmb: String) diff --git a/app/src/main/res/layout/dialog_album_picker.xml b/app/src/main/res/layout/dialog_directory_picker.xml similarity index 90% rename from app/src/main/res/layout/dialog_album_picker.xml rename to app/src/main/res/layout/dialog_directory_picker.xml index 079c72fa4..0feb6bf5a 100644 --- a/app/src/main/res/layout/dialog_album_picker.xml +++ b/app/src/main/res/layout/dialog_directory_picker.xml @@ -5,5 +5,6 @@ android:id="@+id/directories_grid" android:layout_width="match_parent" android:layout_height="wrap_content" + android:paddingTop="@dimen/activity_margin" app:layoutManager="android.support.v7.widget.GridLayoutManager" app:spanCount="@integer/directory_columns"/> diff --git a/app/src/main/res/layout/dialog_medium_picker.xml b/app/src/main/res/layout/dialog_medium_picker.xml new file mode 100644 index 000000000..f2aebbd17 --- /dev/null +++ b/app/src/main/res/layout/dialog_medium_picker.xml @@ -0,0 +1,10 @@ + + From e98de74ae4d0847e8ab74af1ee0a63849ed35a53 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 6 Jun 2017 21:24:06 +0200 Subject: [PATCH 20/33] fix #115, allow setting a custom image as --- .../gallery/adapters/DirectoryAdapter.kt | 4 +--- .../gallery/asynctasks/GetDirectoriesAsynctask.kt | 10 +++++++++- .../com/simplemobiletools/gallery/helpers/Config.kt | 8 ++++++++ 3 files changed, 18 insertions(+), 4 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 8aaa5cb3d..7b76fb7a9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -11,7 +11,6 @@ import com.bignerdranch.android.multiselector.MultiSelector import com.bignerdranch.android.multiselector.SwappingHolder import com.bumptech.glide.Glide import com.google.gson.Gson -import com.google.gson.reflect.TypeToken import com.simplemobiletools.commons.dialogs.ConfirmationDialog import com.simplemobiletools.commons.dialogs.PropertiesDialog import com.simplemobiletools.commons.dialogs.RenameItemDialog @@ -332,8 +331,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList>() {}.type - var albumCovers = Gson().fromJson>(config.albumCovers, listType) ?: ArrayList(1) + var albumCovers = config.parseAlbumCovers() if (useDefault) { albumCovers = albumCovers.filterNot { it.path == path } as ArrayList diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt index 2ba94ceee..539e78e1e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt @@ -35,6 +35,7 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va } 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) { @@ -62,7 +63,14 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va continue } - val directory = Directory(parentDir, path, dirName, 1, dateModified, dateTaken, size) + 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, directory) } } 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 d35a981bf..424721c88 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt @@ -1,10 +1,13 @@ package com.simplemobiletools.gallery.helpers import android.content.Context +import com.google.gson.Gson +import com.google.gson.reflect.TypeToken import com.simplemobiletools.commons.helpers.BaseConfig import com.simplemobiletools.commons.helpers.SORT_BY_DATE_MODIFIED import com.simplemobiletools.commons.helpers.SORT_DESCENDING import com.simplemobiletools.gallery.R +import com.simplemobiletools.gallery.models.AlbumCover import java.util.* class Config(context: Context) : BaseConfig(context) { @@ -171,4 +174,9 @@ class Config(context: Context) : BaseConfig(context) { var albumCovers: String get() = prefs.getString(ALBUM_COVERS, "") set(albumCovers) = prefs.edit().putString(ALBUM_COVERS, albumCovers).apply() + + fun parseAlbumCovers(): ArrayList { + val listType = object : TypeToken>() {}.type + return Gson().fromJson>(albumCovers, listType) ?: ArrayList(1) + } } From 6dc132325217d5de165fb66d23ba93b59906abe0 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 6 Jun 2017 22:26:35 +0200 Subject: [PATCH 21/33] correcting a check at getting current medium at viewpager --- .../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 d92ed325a..a91695969 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -509,7 +509,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } private fun getCurrentMedium(): Medium? { - return if (mMedia.isEmpty() || mPos >= mMedia.size) + return if (mMedia.isEmpty() || mPos == -1) null else mMedia[Math.min(mPos, mMedia.size - 1)] From 53261310a265a5181b487945b4d2fa2bb1197fee Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 6 Jun 2017 22:30:55 +0200 Subject: [PATCH 22/33] properly reuse thumbnails media list at fullscreen view --- app/build.gradle | 2 +- .../gallery/activities/ViewPagerActivity.kt | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index c5edcbb4f..810c0c42f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -32,7 +32,7 @@ android { } dependencies { - compile 'com.simplemobiletools:commons:2.19.5' + compile 'com.simplemobiletools:commons:2.19.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/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index a91695969..fbd122166 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -51,6 +51,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View private var mShowAll = false private var mRotationDegrees = 0f private var mLastHandledOrientation = 0 + private var mPrevHashcode = 0 companion object { var screenWidth = 0 @@ -94,14 +95,14 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View config.temporarilyShowHidden = true } - mMedia = ArrayList() showSystemUI() mDirectory = File(mPath).parent title = mPath.getFilenameFromPath() - if (mMedia.isNotEmpty()) + if (mMedia.isNotEmpty()) { gotMedia(mMedia) + } reloadViewPager() scanPath(mPath) {} @@ -433,10 +434,11 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } private fun gotMedia(media: ArrayList) { - if (isDirEmpty(media) || mMedia.hashCode() == media.hashCode()) { + if (isDirEmpty(media) || media.hashCode() == mPrevHashcode) { return } + mPrevHashcode = media.hashCode() mMedia = media if (mPos == -1) { mPos = getProperPosition() From 3de178a5eb53fcd79ce0efc9002876159e002c45 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 6 Jun 2017 22:39:32 +0200 Subject: [PATCH 23/33] add the setting string for horizontal scrolling --- app/src/main/res/values-cs/strings.xml | 1 + app/src/main/res/values-de/strings.xml | 1 + app/src/main/res/values-es/strings.xml | 1 + app/src/main/res/values-fr/strings.xml | 1 + app/src/main/res/values-hu/strings.xml | 1 + app/src/main/res/values-it/strings.xml | 1 + app/src/main/res/values-ja/strings.xml | 1 + app/src/main/res/values-pl/strings.xml | 1 + app/src/main/res/values-pt-rBR/strings.xml | 1 + app/src/main/res/values-pt/strings.xml | 1 + app/src/main/res/values-ru/strings.xml | 1 + app/src/main/res/values-sk/strings.xml | 1 + app/src/main/res/values-sv/strings.xml | 1 + app/src/main/res/values-tr/strings.xml | 1 + app/src/main/res/values-zh-rCN/strings.xml | 1 + app/src/main/res/values-zh-rTW/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 17 files changed, 17 insertions(+) diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 6a050bdb0..d6b42eee7 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -98,6 +98,7 @@ Device rotation Aspect ratio Dark background at fullscreen media + Scroll thumbnails horizontally diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 9e11aa57d..5e8f7e578 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -98,6 +98,7 @@ Gerätedrehung Seitenverhältnis Schwarzer Hintergrund im Vollbild + Scroll thumbnails horizontally diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 76f58a47a..feea9961a 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -98,6 +98,7 @@ Rotación del dispositivo Relación de aspecto Utilizar siempre fondo oscuro en pantalla completa + Scroll thumbnails horizontally diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index f7f193ee6..e98176869 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -98,6 +98,7 @@ Rotation de l\'appareil Ratio d\'aspect Dark background at fullscreen media + Scroll thumbnails horizontally diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index 04f2444bf..709a41f0d 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -98,6 +98,7 @@ Device rotation Aspect ratio Dark background at fullscreen media + Scroll thumbnails horizontally diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 8e4f8f860..5087d0362 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -98,6 +98,7 @@ Rotazione dispositivo Proporzioni Sfondo scuro a schermo intero + Scroll thumbnails horizontally diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index e14475379..d14c6d20f 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -98,6 +98,7 @@ Device rotation Aspect ratio Dark background at fullscreen media + Scroll thumbnails horizontally diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 7d2b270d5..e850a9af4 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -98,6 +98,7 @@ Device rotation Aspect ratio Dark background at fullscreen media + Scroll thumbnails horizontally diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index e94fb4e9a..5fd798068 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -98,6 +98,7 @@ Sensor do aparelho Proporção da mídia Fundo de tela escuro em mídia tela cheia + Scroll thumbnails horizontally diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index 0cc0e2bff..89c7bfd08 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -98,6 +98,7 @@ Rotação do dispositivo Proporção Usar sempre um fundo escuro se em ecrã completo + Scroll thumbnails horizontally diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index f0dfe5c73..bd5fb9684 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -98,6 +98,7 @@ Поворот устройства Соотношение сторон Dark background at fullscreen media + Scroll thumbnails horizontally diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index 29ef555a9..cf7f93f41 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -98,6 +98,7 @@ Otočenia zariadenia Pomeru strán Tmavé pozadie pri médiách na celú obrazovku + Prehliadať miniatúry vodorovne diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index aecfe3444..a0c67d09e 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -98,6 +98,7 @@ Device rotation Aspect ratio Dark background at fullscreen media + Scroll thumbnails horizontally diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index 6b456a3e8..61ef91e0d 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -98,6 +98,7 @@ Cihaz döndürme En-boy oranı Dark background at fullscreen media + Scroll thumbnails horizontally diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index a7f8cb590..42deb7bcc 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -98,6 +98,7 @@ 设备方向 根据长宽比 全屏时黑色背景 + Scroll thumbnails horizontally diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index c531f2e1a..fdd431271 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -98,6 +98,7 @@ Device rotation Aspect ratio Dark background at fullscreen media + Scroll thumbnails horizontally diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5517162a2..a65e48784 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -98,6 +98,7 @@ Device rotation Aspect ratio Dark background at fullscreen media + Scroll thumbnails horizontally From 0f135c845bef33902501a63a01db1faad9d1cd03 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 6 Jun 2017 22:47:16 +0200 Subject: [PATCH 24/33] use local variables at fetching media --- .../gallery/extensions/context.kt | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 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 e4e04a2d4..4a47f7ce9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt @@ -73,20 +73,13 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP cur.use { cur -> if (cur.moveToFirst()) { - var filename: String - var path: String - var dateTaken: Long - var dateModified: Long - var size: Long - var isImage: Boolean - var isVideo: Boolean val excludedFolders = config.excludedFolders val noMediaFolders = context.getNoMediaFolders() do { try { - path = cur.getStringValue(MediaStore.Images.Media.DATA) - size = cur.getLongValue(MediaStore.Images.Media.SIZE) + val path = cur.getStringValue(MediaStore.Images.Media.DATA) + var size = cur.getLongValue(MediaStore.Images.Media.SIZE) if (size == 0L) { size = File(path).length() } @@ -95,12 +88,12 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP continue } - filename = cur.getStringValue(MediaStore.Images.Media.DISPLAY_NAME) ?: "" + var filename = cur.getStringValue(MediaStore.Images.Media.DISPLAY_NAME) ?: "" if (filename.isEmpty()) filename = path.getFilenameFromPath() - isImage = filename.isImageFast() || filename.isGif() - isVideo = if (isImage) false else filename.isVideoFast() + val isImage = filename.isImageFast() || filename.isGif() + val isVideo = if (isImage) false else filename.isVideoFast() if (!isImage && !isVideo) continue @@ -134,8 +127,8 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP } if (!isExcluded) { - dateTaken = cur.getLongValue(MediaStore.Images.Media.DATE_TAKEN) - dateModified = cur.getIntValue(MediaStore.Images.Media.DATE_MODIFIED) * 1000L + 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) From 868a98acfabac3aece4696ae3696eac2afec5904 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 6 Jun 2017 22:53:05 +0200 Subject: [PATCH 25/33] update commons to 2.20.0 --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 810c0c42f..c1595da8e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -32,7 +32,7 @@ android { } dependencies { - compile 'com.simplemobiletools:commons:2.19.9' + compile 'com.simplemobiletools:commons:2.20.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 13620df112f8702136f1fa1f53b1d89e02e06e20 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 6 Jun 2017 23:26:48 +0200 Subject: [PATCH 26/33] properly include files from manually Included folders --- .../gallery/extensions/context.kt | 37 +++++++++++++++++-- 1 file changed, 34 insertions(+), 3 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 4a47f7ce9..b8f37cf99 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt @@ -70,12 +70,11 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP val config = context.config val showMedia = config.showMedia val showHidden = config.shouldShowHidden + val excludedFolders = config.excludedFolders + val noMediaFolders = context.getNoMediaFolders() cur.use { cur -> if (cur.moveToFirst()) { - val excludedFolders = config.excludedFolders - val noMediaFolders = context.getNoMediaFolders() - do { try { val path = cur.getStringValue(MediaStore.Images.Media.DATA) @@ -140,6 +139,38 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP } } + if (curPath.isEmpty()) { + config.includedFolders.mapNotNull { File(it).listFiles() }.forEach { + for (file in it) { + val size = file.length() + if (size <= 0L) { + continue + } + + val filename = file.name + val isImage = filename.isImageFast() || filename.isGif() + val isVideo = if (isImage) false else filename.isVideoFast() + + if (!isImage && !isVideo) + continue + + if (isVideo && (isPickImage || showMedia == IMAGES)) + continue + + if (isImage && (isPickVideo || showMedia == VIDEOS)) + 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) + } + } + } + Medium.sorting = config.getFileSorting(curPath) curMedia.sort() From 659f355ca171532455f283728ffae20d37638ee2 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 6 Jun 2017 23:37:18 +0200 Subject: [PATCH 27/33] update version to 2.10.9 --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index c1595da8e..4486a9c15 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "com.simplemobiletools.gallery" minSdkVersion 16 targetSdkVersion 23 - versionCode 107 - versionName "2.10.8" + versionCode 108 + versionName "2.10.9" } signingConfigs { From 22ccf1d2978b74749c29570249b6671cf61af6a7 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 6 Jun 2017 23:40:16 +0200 Subject: [PATCH 28/33] add custom folder covers in release notes --- .../com/simplemobiletools/gallery/activities/MainActivity.kt | 1 + app/src/main/res/values/donottranslate.xml | 1 + 2 files changed, 2 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 aa86c6a72..8e5c99539 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -434,6 +434,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { add(Release(94, R.string.release_94)) add(Release(97, R.string.release_97)) add(Release(98, R.string.release_98)) + add(Release(108, R.string.release_108)) checkWhatsNew(this, BuildConfig.VERSION_CODE) } } diff --git a/app/src/main/res/values/donottranslate.xml b/app/src/main/res/values/donottranslate.xml index 205206c16..d1487c62f 100644 --- a/app/src/main/res/values/donottranslate.xml +++ b/app/src/main/res/values/donottranslate.xml @@ -2,6 +2,7 @@ + Allow setting custom folder covers Allow selecting multiple items by finger dragging\n Added an option to always use black background at fullscreen media From 6d4b7c020a8e72582a82d426c1f22caaabd29bd7 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 6 Jun 2017 23:40:24 +0200 Subject: [PATCH 29/33] updating changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16960c35f..dca75d2d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ Changelog ========== +Version 2.10.9 *(2017-06-06)* +---------------------------- + + * Allow setting custom folder covers + * Properly handle manually included folders + * Improve the performance at opening fullscreen media + Version 2.10.8 *(2017-06-02)* ---------------------------- From c99af629960c64486c414abaef1bff5741c8ca08 Mon Sep 17 00:00:00 2001 From: Tibor Kaputa Date: Wed, 7 Jun 2017 09:09:54 +0200 Subject: [PATCH 30/33] update commons to 2.20.1 --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 4486a9c15..831509e29 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -32,7 +32,7 @@ android { } dependencies { - compile 'com.simplemobiletools:commons:2.20.0' + compile 'com.simplemobiletools:commons:2.20.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' From 06530e78b8c3567f617cadd068afb581f6b81434 Mon Sep 17 00:00:00 2001 From: Tibor Kaputa Date: Wed, 7 Jun 2017 09:27:45 +0200 Subject: [PATCH 31/33] recheck media 1 second after refreshing too --- .../com/simplemobiletools/gallery/activities/MediaActivity.kt | 3 +++ 1 file changed, 3 insertions(+) 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 3892816ff..fb254a7f6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -427,6 +427,9 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { override fun refreshItems() { getMedia() + Handler().postDelayed({ + getMedia() + }, 1000) } override fun itemLongClicked(position: Int) { From 178b3b2d4d529de2977fca08960754b5a197493e Mon Sep 17 00:00:00 2001 From: Tibor Kaputa Date: Wed, 7 Jun 2017 09:28:34 +0200 Subject: [PATCH 32/33] update version to 2.10.10 --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 831509e29..cd03e6b5f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "com.simplemobiletools.gallery" minSdkVersion 16 targetSdkVersion 23 - versionCode 108 - versionName "2.10.9" + versionCode 109 + versionName "2.10.10" } signingConfigs { From b4657ff16c5ec5075302513cc1ed26984bce14be Mon Sep 17 00:00:00 2001 From: Tibor Kaputa Date: Wed, 7 Jun 2017 09:29:00 +0200 Subject: [PATCH 33/33] updating changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dca75d2d4..e7657fb9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ Changelog ========== +Version 2.10.10 *(2017-06-07)* +---------------------------- + + * Some crashfixes + Version 2.10.9 *(2017-06-06)* ----------------------------