From ee444326657614113e32f8f8e0b86b991712dfae Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 29 May 2017 20:06:56 +0200 Subject: [PATCH 1/7] request an overwrite confirmation when replacing the original image with edited --- app/build.gradle | 2 +- .../gallery/dialogs/SaveAsDialog.kt | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index b39eaf4aa..9227a4bc9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -32,7 +32,7 @@ android { } dependencies { - compile 'com.simplemobiletools:commons:2.18.8' + compile 'com.simplemobiletools:commons:2.18.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/dialogs/SaveAsDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/SaveAsDialog.kt index 9a146c371..3a5bd3320 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/SaveAsDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/SaveAsDialog.kt @@ -3,6 +3,7 @@ package com.simplemobiletools.gallery.dialogs import android.support.v7.app.AlertDialog import android.view.LayoutInflater import android.view.WindowManager +import com.simplemobiletools.commons.dialogs.ConfirmationDialog import com.simplemobiletools.commons.dialogs.FilePickerDialog import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.gallery.R @@ -62,8 +63,16 @@ class SaveAsDialog(val activity: SimpleActivity, val path: String, val callback: return@setOnClickListener } - callback.invoke(newFile.absolutePath) - dismiss() + if (newFile.exists()) { + val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFile.name) + ConfirmationDialog(activity, title) { + callback.invoke(newFile.absolutePath) + dismiss() + } + } else { + callback.invoke(newFile.absolutePath) + dismiss() + } }) } } From ec22c274dd4466ef3a67f6fa8563b73459765326 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 29 May 2017 20:55:10 +0200 Subject: [PATCH 2/7] update Commons to 2.19.0 --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 9227a4bc9..f35ddec06 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -32,7 +32,7 @@ android { } dependencies { - compile 'com.simplemobiletools:commons:2.18.9' + compile 'com.simplemobiletools:commons:2.19.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 28a2f59514569c2133ad6d3faff532d2e35ff17a Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 29 May 2017 21:00:23 +0200 Subject: [PATCH 3/7] use a different function for getting screen size on kitkat --- .../gallery/activities/ViewPagerActivity.kt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 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 ed2fb22a1..01a77afb3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -402,9 +402,15 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View private fun measureScreen() { val metrics = DisplayMetrics() - windowManager.defaultDisplay.getRealMetrics(metrics) - screenWidth = metrics.widthPixels - screenHeight = metrics.heightPixels + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + windowManager.defaultDisplay.getRealMetrics(metrics) + screenWidth = metrics.widthPixels + screenHeight = metrics.heightPixels + } else { + windowManager.defaultDisplay.getMetrics(metrics) + screenWidth = metrics.widthPixels + screenHeight = metrics.heightPixels + } } private fun reloadViewPager() { From 5758b2eee18b3fbd651a8840fc74c0c0828cbf02 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 29 May 2017 21:21:47 +0200 Subject: [PATCH 4/7] reuse the list of media files of thumbnail view at the fullscreen view --- .../gallery/activities/MediaActivity.kt | 7 +++- .../gallery/activities/ViewPagerActivity.kt | 41 +++++++++++-------- 2 files changed, 30 insertions(+), 18 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 f3b861a9b..8e9d307c3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -37,8 +37,6 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { private val SAVE_MEDIA_CNT = 40 private val LAST_MEDIA_CHECK_PERIOD = 3000L - private var mMedia = ArrayList() - private var mPath = "" private var mIsGetImageIntent = false private var mIsGetVideoIntent = false @@ -51,6 +49,10 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { private var mLastMediaModified = 0 private var mLastMediaHandler = Handler() + companion object { + var mMedia = ArrayList() + } + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_media) @@ -95,6 +97,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { override fun onDestroy() { super.onDestroy() config.temporarilyShowHidden = false + mMedia.clear() } private fun tryloadGallery() { 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 01a77afb3..24aa738e7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -97,6 +97,10 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View mDirectory = File(mPath).parent title = mPath.getFilenameFromPath() + + if (MediaActivity.mMedia.isNotEmpty()) + gotMedia(MediaActivity.mMedia) + reloadViewPager() scanPath(mPath) {} setupOrientationEventListener() @@ -379,8 +383,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } } - private fun isDirEmpty(): Boolean { - return if (mMedia.size <= 0) { + private fun isDirEmpty(media: ArrayList): Boolean { + return if (media.isEmpty()) { deleteDirectoryIfEmpty() finish() true @@ -415,23 +419,28 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View private fun reloadViewPager() { GetMediaAsynctask(applicationContext, mDirectory, false, false, mShowAll) { - mMedia = it - if (isDirEmpty()) - return@GetMediaAsynctask - - if (mPos == -1) { - mPos = getProperPosition() - } else { - mPos = Math.min(mPos, mMedia.size - 1) - } - - updateActionbarTitle() - updatePagerItems() - invalidateOptionsMenu() - checkOrientation() + gotMedia(it) }.execute() } + private fun gotMedia(media: ArrayList) { + if (isDirEmpty(media) || mMedia.hashCode() == media.hashCode()) { + return + } + + mMedia = media + if (mPos == -1) { + mPos = getProperPosition() + } else { + mPos = Math.min(mPos, mMedia.size - 1) + } + + updateActionbarTitle() + updatePagerItems() + invalidateOptionsMenu() + checkOrientation() + } + private fun getProperPosition(): Int { mPos = 0 var i = 0 From d7740ae7b81b0dfc6169ad7778ae7d93265dbc80 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 29 May 2017 21:39:56 +0200 Subject: [PATCH 5/7] fix the condition checking if Editor was opened via a Crop intent --- .../com/simplemobiletools/gallery/activities/EditActivity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt index e860cce52..b6c69a410 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt @@ -49,7 +49,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener return } - isCropIntent = intent.extras?.get(CROP) == true + isCropIntent = intent.extras?.get(CROP) == "true" crop_image_view.apply { setOnCropImageCompleteListener(this@EditActivity) From dd3fe03341521918bff61dfec573824fa8bcc29b Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 29 May 2017 23:08:06 +0200 Subject: [PATCH 6/7] update version to 2.10.7 --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index f35ddec06..786bb1d31 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "com.simplemobiletools.gallery" minSdkVersion 16 targetSdkVersion 23 - versionCode 105 - versionName "2.10.6" + versionCode 106 + versionName "2.10.7" } signingConfigs { From ba8fbd11948a1347126820a33e3d914866f21406 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 29 May 2017 23:11:01 +0200 Subject: [PATCH 7/7] updating changelog --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c242d25ec..8d63e5505 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,14 @@ Changelog ========== +Version 2.10.7 *(2017-05-29)* +---------------------------- + + * Show hidden folders when they should be shown + * Add an overwrite confirmation dialog when replacing the original image with edited + * Reuse the list of media at fullscreen view from thumbnails, increasing performance + * Some crashfixes + Version 2.10.6 *(2017-05-26)* ----------------------------