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 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)* Version 2.10.6 *(2017-05-26)*
---------------------------- ----------------------------

View File

@ -10,8 +10,8 @@ android {
applicationId "com.simplemobiletools.gallery" applicationId "com.simplemobiletools.gallery"
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 23 targetSdkVersion 23
versionCode 105 versionCode 106
versionName "2.10.6" versionName "2.10.7"
} }
signingConfigs { signingConfigs {
@ -32,7 +32,7 @@ android {
} }
dependencies { 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.davemorrissey.labs:subsampling-scale-image-view:3.6.0'
compile 'com.theartofdev.edmodo:android-image-cropper:2.4.0' compile 'com.theartofdev.edmodo:android-image-cropper:2.4.0'
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2' compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'

View File

@ -49,7 +49,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
return return
} }
isCropIntent = intent.extras?.get(CROP) == true isCropIntent = intent.extras?.get(CROP) == "true"
crop_image_view.apply { crop_image_view.apply {
setOnCropImageCompleteListener(this@EditActivity) setOnCropImageCompleteListener(this@EditActivity)

View File

@ -37,8 +37,6 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
private val SAVE_MEDIA_CNT = 40 private val SAVE_MEDIA_CNT = 40
private val LAST_MEDIA_CHECK_PERIOD = 3000L private val LAST_MEDIA_CHECK_PERIOD = 3000L
private var mMedia = ArrayList<Medium>()
private var mPath = "" private var mPath = ""
private var mIsGetImageIntent = false private var mIsGetImageIntent = false
private var mIsGetVideoIntent = false private var mIsGetVideoIntent = false
@ -51,6 +49,10 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
private var mLastMediaModified = 0 private var mLastMediaModified = 0
private var mLastMediaHandler = Handler() private var mLastMediaHandler = Handler()
companion object {
var mMedia = ArrayList<Medium>()
}
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_media) setContentView(R.layout.activity_media)
@ -95,6 +97,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
config.temporarilyShowHidden = false config.temporarilyShowHidden = false
mMedia.clear()
} }
private fun tryloadGallery() { private fun tryloadGallery() {

View File

@ -97,6 +97,10 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
mDirectory = File(mPath).parent mDirectory = File(mPath).parent
title = mPath.getFilenameFromPath() title = mPath.getFilenameFromPath()
if (MediaActivity.mMedia.isNotEmpty())
gotMedia(MediaActivity.mMedia)
reloadViewPager() reloadViewPager()
scanPath(mPath) {} scanPath(mPath) {}
setupOrientationEventListener() setupOrientationEventListener()
@ -379,8 +383,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
} }
} }
private fun isDirEmpty(): Boolean { private fun isDirEmpty(media: ArrayList<Medium>): Boolean {
return if (mMedia.size <= 0) { return if (media.isEmpty()) {
deleteDirectoryIfEmpty() deleteDirectoryIfEmpty()
finish() finish()
true true
@ -402,30 +406,41 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
private fun measureScreen() { private fun measureScreen() {
val metrics = DisplayMetrics() val metrics = DisplayMetrics()
windowManager.defaultDisplay.getRealMetrics(metrics) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
screenWidth = metrics.widthPixels windowManager.defaultDisplay.getRealMetrics(metrics)
screenHeight = metrics.heightPixels screenWidth = metrics.widthPixels
screenHeight = metrics.heightPixels
} else {
windowManager.defaultDisplay.getMetrics(metrics)
screenWidth = metrics.widthPixels
screenHeight = metrics.heightPixels
}
} }
private fun reloadViewPager() { private fun reloadViewPager() {
GetMediaAsynctask(applicationContext, mDirectory, false, false, mShowAll) { GetMediaAsynctask(applicationContext, mDirectory, false, false, mShowAll) {
mMedia = it gotMedia(it)
if (isDirEmpty())
return@GetMediaAsynctask
if (mPos == -1) {
mPos = getProperPosition()
} else {
mPos = Math.min(mPos, mMedia.size - 1)
}
updateActionbarTitle()
updatePagerItems()
invalidateOptionsMenu()
checkOrientation()
}.execute() }.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 { private fun getProperPosition(): Int {
mPos = 0 mPos = 0
var i = 0 var i = 0

View File

@ -3,6 +3,7 @@ package com.simplemobiletools.gallery.dialogs
import android.support.v7.app.AlertDialog import android.support.v7.app.AlertDialog
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.WindowManager import android.view.WindowManager
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
import com.simplemobiletools.commons.dialogs.FilePickerDialog import com.simplemobiletools.commons.dialogs.FilePickerDialog
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.R
@ -62,8 +63,16 @@ class SaveAsDialog(val activity: SimpleActivity, val path: String, val callback:
return@setOnClickListener return@setOnClickListener
} }
callback.invoke(newFile.absolutePath) if (newFile.exists()) {
dismiss() 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()
}
}) })
} }
} }