From 4c865de3013dc85e57d71ea66f6f7ce8678654cc Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 30 Mar 2018 23:32:37 +0200 Subject: [PATCH] update commons to 3.17.16 with some cosmetic code changes --- app/build.gradle | 6 +-- .../activities/ExcludedFoldersActivity.kt | 1 - .../activities/HiddenFoldersActivity.kt | 1 - .../activities/IncludedFoldersActivity.kt | 1 - .../gallery/activities/MainActivity.kt | 38 +++++++++---------- .../gallery/activities/MediaActivity.kt | 28 ++++++-------- .../gallery/adapters/DirectoryAdapter.kt | 4 ++ .../gallery/adapters/ManageFoldersAdapter.kt | 4 ++ .../adapters/ManageHiddenFoldersAdapter.kt | 4 ++ .../gallery/adapters/MediaAdapter.kt | 1 + 10 files changed, 45 insertions(+), 43 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 5a7f62277..72a5e3021 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -46,15 +46,15 @@ ext { } dependencies { - implementation 'com.simplemobiletools:commons:3.17.14' + implementation 'com.simplemobiletools:commons:3.17.16' implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.0' implementation 'com.android.support:multidex:1.0.3' implementation 'it.sephiroth.android.exif:library:1.0.1' - implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.8' + implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.12' implementation 'com.github.chrisbanes:PhotoView:2.1.3' //implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.9.0' - implementation 'com.github.tibbi:subsampling-scale-image-view:v3.9.0.6-fork' + implementation 'com.github.tibbi:subsampling-scale-image-view:v3.10.0-fork' debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion" releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leakCanaryVersion" diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ExcludedFoldersActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ExcludedFoldersActivity.kt index f8d398eac..c9fb9820a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ExcludedFoldersActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ExcludedFoldersActivity.kt @@ -28,7 +28,6 @@ class ExcludedFoldersActivity : SimpleActivity(), RefreshRecyclerViewListener { } val adapter = ManageFoldersAdapter(this, folders, true, this, manage_folders_list) {} - adapter.setupDragListener(true) manage_folders_list.adapter = adapter } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/HiddenFoldersActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/HiddenFoldersActivity.kt index 79ce030f4..e1e33aec3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/HiddenFoldersActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/HiddenFoldersActivity.kt @@ -30,7 +30,6 @@ class HiddenFoldersActivity : SimpleActivity(), RefreshRecyclerViewListener { } val adapter = ManageHiddenFoldersAdapter(this, it, this, manage_folders_list) {} - adapter.setupDragListener(true) manage_folders_list.adapter = adapter } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/IncludedFoldersActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/IncludedFoldersActivity.kt index cb565c6b3..be04fbdf4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/IncludedFoldersActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/IncludedFoldersActivity.kt @@ -29,7 +29,6 @@ class IncludedFoldersActivity : SimpleActivity(), RefreshRecyclerViewListener { } val adapter = ManageFoldersAdapter(this, folders, false, this, manage_folders_list) {} - adapter.setupDragListener(true) manage_folders_list.adapter = adapter } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index 79f54954e..76614616a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -71,6 +71,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { private var mStoredShowMediaCount = true private var mStoredShowInfoBubble = true private var mStoredTextColor = 0 + private var mStoredPrimaryColor = 0 override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -121,24 +122,30 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { } if (mStoredAnimateGifs != config.animateGifs) { - getDirectoryAdapter()?.updateAnimateGifs(config.animateGifs) + getRecyclerAdapter()?.updateAnimateGifs(config.animateGifs) } if (mStoredCropThumbnails != config.cropThumbnails) { - getDirectoryAdapter()?.updateCropThumbnails(config.cropThumbnails) + getRecyclerAdapter()?.updateCropThumbnails(config.cropThumbnails) } if (mStoredShowMediaCount != config.showMediaCount) { - getDirectoryAdapter()?.updateShowMediaCount(config.showMediaCount) + getRecyclerAdapter()?.updateShowMediaCount(config.showMediaCount) } if (mStoredScrollHorizontally != config.scrollHorizontally || mStoredShowInfoBubble != config.showInfoBubble) { - getDirectoryAdapter()?.updateScrollHorizontally(config.viewTypeFolders != VIEW_TYPE_LIST && config.scrollHorizontally) + getRecyclerAdapter()?.updateScrollHorizontally(config.viewTypeFolders != VIEW_TYPE_LIST && config.scrollHorizontally) setupScrollDirection() } if (mStoredTextColor != config.textColor) { - getDirectoryAdapter()?.updateTextColor(config.textColor) + getRecyclerAdapter()?.updateTextColor(config.textColor) + } + + if (mStoredPrimaryColor != config.primaryColor) { + getRecyclerAdapter()?.updatePrimaryColor(config.primaryColor) + directories_vertical_fastscroller.updatePrimaryColor() + directories_horizontal_fastscroller.updatePrimaryColor() } directories_horizontal_fastscroller.updateBubbleColors() @@ -224,7 +231,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { return true } - private fun getDirectoryAdapter() = directories_grid.adapter as? DirectoryAdapter + private fun getRecyclerAdapter() = directories_grid.adapter as? DirectoryAdapter private fun storeStateVariables() { config.apply { @@ -235,6 +242,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { mStoredShowMediaCount = showMediaCount mStoredShowInfoBubble = showInfoBubble mStoredTextColor = textColor + mStoredPrimaryColor = primaryColor } } @@ -260,7 +268,6 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { } setupLayoutManager() - checkIfColorChanged() } else { toast(R.string.no_storage_permissions) finish() @@ -353,14 +360,6 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { invalidateOptionsMenu() } - private fun checkIfColorChanged() { - if (directories_grid.adapter != null && getRecyclerAdapter().primaryColor != config.primaryColor) { - getRecyclerAdapter().primaryColor = config.primaryColor - directories_vertical_fastscroller.updatePrimaryColor() - directories_horizontal_fastscroller.updatePrimaryColor() - } - } - override fun deleteFolders(folders: ArrayList) { val fileDirItems = folders.map { FileDirItem(it.absolutePath, it.name, true) } as ArrayList deleteFolders(fileDirItems) { @@ -370,8 +369,6 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { } } - private fun getRecyclerAdapter() = (directories_grid.adapter as DirectoryAdapter) - private fun setupLayoutManager() { if (config.viewTypeFolders == VIEW_TYPE_GRID) { setupGridLayoutManager() @@ -400,14 +397,14 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { override fun zoomIn() { if (layoutManager.spanCount > 1) { reduceColumnCount() - getRecyclerAdapter().finishActMode() + getRecyclerAdapter()?.finishActMode() } } override fun zoomOut() { if (layoutManager.spanCount < MAX_COLUMN_COUNT) { increaseColumnCount() - getRecyclerAdapter().finishActMode() + getRecyclerAdapter()?.finishActMode() } } } @@ -618,7 +615,6 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { itemClicked((it as Directory).path) }.apply { setupZoomListener(mZoomListener) - setupDragListener(true) directories_grid.adapter = this } } else { @@ -650,7 +646,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { } } - private fun getBubbleTextItem(index: Int) = getRecyclerAdapter().dirs.getOrNull(index)?.getBubbleText() ?: "" + private fun getBubbleTextItem(index: Int) = getRecyclerAdapter()?.dirs?.getOrNull(index)?.getBubbleText() ?: "" private fun setupLatestMediaId() { Thread { 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 9df15a242..f9b6a9fb7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -69,6 +69,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { private var mStoredScrollHorizontally = true private var mStoredShowInfoBubble = true private var mStoredTextColor = 0 + private var mStoredPrimaryColor = 0 companion object { var mMedia = ArrayList() @@ -131,6 +132,12 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { getMediaAdapter()?.updateTextColor(config.textColor) } + if (mStoredPrimaryColor != config.primaryColor) { + getMediaAdapter()?.updatePrimaryColor(config.primaryColor) + media_horizontal_fastscroller.updatePrimaryColor() + media_vertical_fastscroller.updatePrimaryColor() + } + media_horizontal_fastscroller.updateBubbleColors() media_vertical_fastscroller.updateBubbleColors() media_refresh_layout.isEnabled = config.enablePullToRefresh @@ -231,6 +238,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { mStoredScrollHorizontally = scrollHorizontally mStoredShowInfoBubble = showInfoBubble mStoredTextColor = textColor + mStoredPrimaryColor = primaryColor mShowAll = showAll } } @@ -287,7 +295,6 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { supportActionBar?.title = if (mShowAll) resources.getString(R.string.all_folders) else dirName getMedia() setupLayoutManager() - checkIfColorChanged() } else { toast(R.string.no_storage_permissions) finish() @@ -297,14 +304,6 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { private fun getMediaAdapter() = media_grid.adapter as? MediaAdapter - private fun checkIfColorChanged() { - if (media_grid.adapter != null && getRecyclerAdapter().primaryColor != config.primaryColor) { - getRecyclerAdapter().primaryColor = config.primaryColor - media_horizontal_fastscroller.updatePrimaryColor() - media_vertical_fastscroller.updatePrimaryColor() - } - } - private fun setupAdapter() { if (!mShowAll && isDirEmpty()) { return @@ -318,7 +317,6 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { itemClicked((it as Medium).path) }.apply { setupZoomListener(mZoomListener) - setupDragListener(true) media_grid.adapter = this } } else { @@ -348,7 +346,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { } } - private fun getBubbleTextItem(index: Int) = getRecyclerAdapter().media.getOrNull(index)?.getBubbleText() ?: "" + private fun getBubbleTextItem(index: Int) = getMediaAdapter()?.media?.getOrNull(index)?.getBubbleText() ?: "" private fun checkLastMediaChanged() { if (isActivityDestroyed()) @@ -388,7 +386,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { private fun toggleFilenameVisibility() { config.displayFileNames = !config.displayFileNames if (media_grid.adapter != null) - getRecyclerAdapter().updateDisplayFilenames(config.displayFileNames) + getMediaAdapter()?.updateDisplayFilenames(config.displayFileNames) } private fun switchToFolderView() { @@ -501,8 +499,6 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { invalidateOptionsMenu() } - private fun getRecyclerAdapter() = (media_grid.adapter as MediaAdapter) - private fun setupLayoutManager() { if (config.viewTypeFiles == VIEW_TYPE_GRID) { setupGridLayoutManager() @@ -531,14 +527,14 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { override fun zoomIn() { if (layoutManager.spanCount > 1) { reduceColumnCount() - getRecyclerAdapter().finishActMode() + getMediaAdapter()?.finishActMode() } } override fun zoomOut() { if (layoutManager.spanCount < MAX_COLUMN_COUNT) { increaseColumnCount() - getRecyclerAdapter().finishActMode() + getMediaAdapter()?.finishActMode() } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt index 2db143623..c495fa1f9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -41,6 +41,10 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: MutableList, private var displayFilenames = config.displayFileNames init { + setupDragListener(true) enableInstantLoad() }