Merge pull request #5 from SimpleMobileTools/master

update
This commit is contained in:
solokot 2017-11-26 19:43:10 +03:00 committed by GitHub
commit d356f18dde
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 47 additions and 49 deletions

View file

@ -1,6 +1,13 @@
Changelog Changelog
========== ==========
Version 2.19.0 *(2017-11-23)*
----------------------------
* Rolled back to displaying images in RGB_565 quality for proper zoom and performance
* Load directory thumbnails faster if a new medium has been discovered
* Couple performance and stability improvements
Version 2.18.1 *(2017-11-16)* Version 2.18.1 *(2017-11-16)*
---------------------------- ----------------------------

View file

@ -10,8 +10,8 @@ android {
applicationId "com.simplemobiletools.gallery" applicationId "com.simplemobiletools.gallery"
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 27 targetSdkVersion 27
versionCode 144 versionCode 145
versionName "2.18.1" versionName "2.19.0"
multiDexEnabled true multiDexEnabled true
setProperty("archivesBaseName", "gallery") setProperty("archivesBaseName", "gallery")
} }
@ -47,32 +47,19 @@ ext {
} }
dependencies { dependencies {
compile 'com.simplemobiletools:commons:2.39.10' implementation 'com.simplemobiletools:commons:2.41.8'
compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.8.0' implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.8.0'
compile 'com.theartofdev.edmodo:android-image-cropper:2.4.0' implementation 'com.theartofdev.edmodo:android-image-cropper:2.4.0'
compile 'com.android.support:multidex:1.0.2' implementation 'com.android.support:multidex:1.0.2'
compile 'com.google.code.gson:gson:2.8.2' implementation 'com.google.code.gson:gson:2.8.2'
compile 'it.sephiroth.android.exif:library:1.0.1' implementation 'it.sephiroth.android.exif:library:1.0.1'
compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.8' implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.8'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
debugCompile "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion" debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion"
releaseCompile "com.squareup.leakcanary:leakcanary-android-no-op:$leakCanaryVersion" releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leakCanaryVersion"
} }
buildscript { Properties props = new Properties()
ext.kotlin_version = '1.1.60'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
}
}
def Properties props = new Properties()
def propFile = new File('signing.properties') def propFile = new File('signing.properties')
if (propFile.canRead()) { if (propFile.canRead()) {
props.load(new FileInputStream(propFile)) props.load(new FileInputStream(propFile))

View file

@ -2,20 +2,18 @@ package com.simplemobiletools.gallery
import android.support.multidex.MultiDexApplication import android.support.multidex.MultiDexApplication
import com.github.ajalt.reprint.core.Reprint import com.github.ajalt.reprint.core.Reprint
import com.simplemobiletools.gallery.BuildConfig.USE_LEAK_CANARY
import com.simplemobiletools.gallery.extensions.config import com.simplemobiletools.gallery.extensions.config
import com.squareup.leakcanary.LeakCanary
import java.util.* import java.util.*
class App : MultiDexApplication() { class App : MultiDexApplication() {
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()
if (USE_LEAK_CANARY) { /*if (USE_LEAK_CANARY) {
if (LeakCanary.isInAnalyzerProcess(this)) { if (LeakCanary.isInAnalyzerProcess(this)) {
return return
} }
LeakCanary.install(this) LeakCanary.install(this)
} }*/
if (config.useEnglish) { if (config.useEnglish) {
val conf = resources.configuration val conf = resources.configuration

View file

@ -172,7 +172,9 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
try { try {
getFileOutputStream(file) { getFileOutputStream(file) {
if (it != null) { if (it != null) {
saveBitmap(file, bitmap, it) Thread {
saveBitmap(file, bitmap, it)
}.start()
} else { } else {
toast(R.string.image_editing_failed) toast(R.string.image_editing_failed)
} }

View file

@ -208,7 +208,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
val newFolder = File(config.tempFolderPath) val newFolder = File(config.tempFolderPath)
if (newFolder.exists() && newFolder.isDirectory) { if (newFolder.exists() && newFolder.isDirectory) {
if (newFolder.list()?.isEmpty() == true) { if (newFolder.list()?.isEmpty() == true) {
deleteFileBg(newFolder, true) deleteFile(newFolder, true)
} }
} }
config.tempFolderPath = "" config.tempFolderPath = ""
@ -247,7 +247,9 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
} }
mLoadedInitialPhotos = true mLoadedInitialPhotos = true
mCurrAsyncTask?.stopFetching()
mCurrAsyncTask = GetDirectoriesAsynctask(applicationContext, mIsPickVideoIntent || mIsGetVideoContentIntent, mIsPickImageIntent || mIsGetImageContentIntent) { mCurrAsyncTask = GetDirectoriesAsynctask(applicationContext, mIsPickVideoIntent || mIsGetVideoContentIntent, mIsPickImageIntent || mIsGetImageContentIntent) {
mCurrAsyncTask = null
gotDirectories(addTempFolderIfNeeded(it), false) gotDirectories(addTempFolderIfNeeded(it), false)
} }
mCurrAsyncTask!!.execute() mCurrAsyncTask!!.execute()

View file

@ -716,7 +716,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
} }
private fun deleteConfirmed() { private fun deleteConfirmed() {
deleteFileBg(File(getCurrentMedia()[mPos].path)) { deleteFile(File(getCurrentMedia()[mPos].path)) {
reloadViewPager() reloadViewPager()
} }
} }

View file

@ -26,7 +26,6 @@ import com.simplemobiletools.gallery.R
import com.simplemobiletools.gallery.activities.PhotoActivity import com.simplemobiletools.gallery.activities.PhotoActivity
import com.simplemobiletools.gallery.activities.ViewPagerActivity import com.simplemobiletools.gallery.activities.ViewPagerActivity
import com.simplemobiletools.gallery.extensions.* import com.simplemobiletools.gallery.extensions.*
import com.simplemobiletools.gallery.helpers.GlideDecoder
import com.simplemobiletools.gallery.helpers.GlideRotateTransformation import com.simplemobiletools.gallery.helpers.GlideRotateTransformation
import com.simplemobiletools.gallery.helpers.MEDIUM import com.simplemobiletools.gallery.helpers.MEDIUM
import com.simplemobiletools.gallery.models.Medium import com.simplemobiletools.gallery.models.Medium
@ -179,6 +178,9 @@ class PhotoFragment : ViewPagerFragment() {
} catch (e: Exception) { } catch (e: Exception) {
gifDrawable = null gifDrawable = null
loadBitmap() loadBitmap()
} catch (e: OutOfMemoryError) {
gifDrawable = null
loadBitmap()
} }
} }
@ -224,7 +226,6 @@ class PhotoFragment : ViewPagerFragment() {
if ((medium.isImage()) && isFragmentVisible && view.subsampling_view.isGone()) { if ((medium.isImage()) && isFragmentVisible && view.subsampling_view.isGone()) {
ViewPagerActivity.wasDecodedByGlide = false ViewPagerActivity.wasDecodedByGlide = false
view.subsampling_view.apply { view.subsampling_view.apply {
setBitmapDecoderClass(GlideDecoder::class.java)
maxScale = 10f maxScale = 10f
beVisible() beVisible()
setImage(ImageSource.uri(medium.path)) setImage(ImageSource.uri(medium.path))
@ -235,7 +236,7 @@ class PhotoFragment : ViewPagerFragment() {
override fun onReady() { override fun onReady() {
background = ColorDrawable(if (context.config.darkBackground) Color.BLACK else context.config.backgroundColor) background = ColorDrawable(if (context.config.darkBackground) Color.BLACK else context.config.backgroundColor)
setDoubleTapZoomScale(getDoubleTapZoomScale()) setDoubleTapZoomScale(getDoubleTapZoomScale(sWidth, sHeight))
} }
override fun onTileLoadError(e: Exception?) { override fun onTileLoadError(e: Exception?) {
@ -258,12 +259,7 @@ class PhotoFragment : ViewPagerFragment() {
} }
} }
private fun getDoubleTapZoomScale(): Float { private fun getDoubleTapZoomScale(width: Int, height: Int): Float {
val bitmapOptions = BitmapFactory.Options()
bitmapOptions.inJustDecodeBounds = true
BitmapFactory.decodeFile(medium.path, bitmapOptions)
val width = bitmapOptions.outWidth
val height = bitmapOptions.outHeight
val bitmapAspectRatio = height / (width).toFloat() val bitmapAspectRatio = height / (width).toFloat()
return if (context == null) { return if (context == null) {
@ -286,8 +282,7 @@ class PhotoFragment : ViewPagerFragment() {
} }
fun rotateImageViewBy(degrees: Float) { fun rotateImageViewBy(degrees: Float) {
// do not make Subsampling view Gone, because it gets recycled and can crash with "Error, cannot access an invalid/free'd bitmap here!" view.subsampling_view.beGone()
view.subsampling_view.beInvisible()
loadBitmap(degrees) loadBitmap(degrees)
} }

View file

@ -47,6 +47,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
private var mStoredExtendedDetails = 0 private var mStoredExtendedDetails = 0
private var mCurrTime = 0 private var mCurrTime = 0
private var mDuration = 0 private var mDuration = 0
private var mEncodedPath = ""
private var mTouchDownX = 0f private var mTouchDownX = 0f
private var mTouchDownY = 0f private var mTouchDownY = 0f
@ -416,9 +417,10 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
return return
} }
val mediumPath = if (wasEncoded) mEncodedPath else medium.path
try { try {
mMediaPlayer = MediaPlayer().apply { mMediaPlayer = MediaPlayer().apply {
setDataSource(context, Uri.parse(medium.path)) setDataSource(context, Uri.parse(mediumPath))
setDisplay(mSurfaceHolder) setDisplay(mSurfaceHolder)
setOnCompletionListener { videoCompleted() } setOnCompletionListener { videoCompleted() }
setOnVideoSizeChangedListener({ mediaPlayer, width, height -> setVideoSize() }) setOnVideoSizeChangedListener({ mediaPlayer, width, height -> setVideoSize() })
@ -427,7 +429,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
prepare() prepare()
} }
} catch (e: IOException) { } catch (e: IOException) {
medium.path = Uri.encode(medium.path) mEncodedPath = Uri.encode(medium.path)
if (wasEncoded) { if (wasEncoded) {
releaseMediaPlayer() releaseMediaPlayer()
} else { } else {

View file

@ -23,8 +23,8 @@
<string name="volume">Volume</string> <string name="volume">Volume</string>
<string name="brightness">Brilho</string> <string name="brightness">Brilho</string>
<string name="do_not_ask_again">Não perguntar de novo para esta sessão</string> <string name="do_not_ask_again">Não perguntar de novo para esta sessão</string>
<string name="lock_orientation">Lock orientation</string> <string name="lock_orientation">Bloquear orientação</string>
<string name="unlock_orientation">Unlock orientation</string> <string name="unlock_orientation">Desbloquear orientação</string>
<!-- Filter --> <!-- Filter -->
<string name="filter_media">Filtrar multimédia</string> <string name="filter_media">Filtrar multimédia</string>

View file

@ -1,11 +1,16 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { buildscript {
ext.kotlin_version = '1.1.60'
repositories { repositories {
jcenter() jcenter()
google()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.0.0' classpath 'com.android.tools.build:gradle:3.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files
@ -15,8 +20,8 @@ buildscript {
allprojects { allprojects {
repositories { repositories {
jcenter() jcenter()
google()
maven { url "https://jitpack.io" } maven { url "https://jitpack.io" }
maven { url "https://maven.google.com" }
} }
} }