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)* ---------------------------- diff --git a/app/build.gradle b/app/build.gradle index b39eaf4aa..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 { @@ -32,7 +32,7 @@ android { } dependencies { - compile 'com.simplemobiletools:commons:2.18.8' + 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' 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) 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 ed2fb22a1..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 @@ -402,30 +406,41 @@ 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() { 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 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() + } }) } }