Merge pull request #2 from SimpleMobileTools/master

merge.
This commit is contained in:
fiepi 2017-05-30 09:45:43 -05:00 committed by GitHub
commit a6aba63db9
6 changed files with 62 additions and 27 deletions

View file

@ -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)*
----------------------------

View file

@ -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'

View file

@ -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)

View file

@ -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<Medium>()
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<Medium>()
}
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() {

View file

@ -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<Medium>): 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<Medium>) {
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

View file

@ -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()
}
})
}
}