From 698448b8475415a2058c88ee17a00fdc7aa0dd1e Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 19 Feb 2021 17:05:36 +0100 Subject: [PATCH] properly update the colors onResume --- app/build.gradle | 2 +- .../gallery/pro/activities/MainActivity.kt | 59 ++++++++++--------- .../gallery/pro/activities/MediaActivity.kt | 11 ++-- 3 files changed, 37 insertions(+), 35 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index d1bf8a066..45c4a2882 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -77,7 +77,7 @@ android { } dependencies { - implementation 'com.simplemobiletools:commons:5.33.32' + implementation 'com.simplemobiletools:commons:5.33.33' implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0' implementation 'it.sephiroth.android.exif:library:1.0.1' implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.22' diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index 496f0968d..b8b6e0266 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -84,7 +84,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { private var mStoredCropThumbnails = true private var mStoredScrollHorizontally = true private var mStoredTextColor = 0 - private var mStoredPrimaryColor = 0 + private var mStoredAdjustedPrimaryColor = 0 private var mStoredStyleString = "" override fun onCreate(savedInstanceState: Bundle?) { @@ -108,7 +108,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { mIsSetWallpaperIntent = isSetWallpaperIntent(intent) mAllowPickingMultiple = intent.getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE, false) mIsThirdPartyIntent = mIsPickImageIntent || mIsPickVideoIntent || mIsGetImageContentIntent || mIsGetVideoContentIntent || - mIsGetAnyContentIntent || mIsSetWallpaperIntent + mIsGetAnyContentIntent || mIsSetWallpaperIntent directories_refresh_layout.setOnRefreshListener { getDirectories() } storeStateVariables() @@ -185,10 +185,11 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { getRecyclerAdapter()?.updateTextColor(config.textColor) } - if (mStoredPrimaryColor != config.primaryColor) { + val adjustedPrimaryColor = getAdjustedPrimaryColor() + if (mStoredAdjustedPrimaryColor != adjustedPrimaryColor) { getRecyclerAdapter()?.updatePrimaryColor(config.primaryColor) - directories_vertical_fastscroller.updatePrimaryColor() - directories_horizontal_fastscroller.updatePrimaryColor() + directories_vertical_fastscroller.updatePrimaryColor(adjustedPrimaryColor) + directories_horizontal_fastscroller.updatePrimaryColor(adjustedPrimaryColor) } val styleString = "${config.folderStyle}${config.showFolderMediaCount}${config.limitFolderTitle}" @@ -201,8 +202,8 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { directories_refresh_layout.isEnabled = config.enablePullToRefresh directories_empty_placeholder.setTextColor(config.textColor) - directories_empty_placeholder_2.setTextColor(getAdjustedPrimaryColor()) - directories_switch_searching.setTextColor(getAdjustedPrimaryColor()) + directories_empty_placeholder_2.setTextColor(adjustedPrimaryColor) + directories_switch_searching.setTextColor(adjustedPrimaryColor) directories_switch_searching.underlineText() if (!mIsSearchOpen) { @@ -337,9 +338,9 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { mStoredCropThumbnails = cropThumbnails mStoredScrollHorizontally = scrollHorizontally mStoredTextColor = textColor - mStoredPrimaryColor = primaryColor mStoredStyleString = "$folderStyle$showFolderMediaCount$limitFolderTitle" } + mStoredAdjustedPrimaryColor = getAdjustedPrimaryColor() } private fun setupSearch(menu: Menu) { @@ -571,11 +572,11 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { val files = File(it.path).listFiles() files?.filter { it.absolutePath.isMediaFile() && (showHidden || !it.name.startsWith('.')) && - ((it.isImageFast() && filter and TYPE_IMAGES != 0) || - (it.isVideoFast() && filter and TYPE_VIDEOS != 0) || - (it.isGif() && filter and TYPE_GIFS != 0) || - (it.isRawFast() && filter and TYPE_RAWS != 0) || - (it.isSvg() && filter and TYPE_SVGS != 0)) + ((it.isImageFast() && filter and TYPE_IMAGES != 0) || + (it.isVideoFast() && filter and TYPE_VIDEOS != 0) || + (it.isGif() && filter and TYPE_GIFS != 0) || + (it.isRawFast() && filter and TYPE_RAWS != 0) || + (it.isSvg() && filter and TYPE_SVGS != 0)) }?.mapTo(itemsToDelete) { it.toFileDirItem(applicationContext) } } @@ -776,20 +777,20 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { private fun isGetContentIntent(intent: Intent) = intent.action == Intent.ACTION_GET_CONTENT && intent.type != null private fun isGetImageContentIntent(intent: Intent) = isGetContentIntent(intent) && - (intent.type!!.startsWith("image/") || intent.type == Images.Media.CONTENT_TYPE) + (intent.type!!.startsWith("image/") || intent.type == Images.Media.CONTENT_TYPE) private fun isGetVideoContentIntent(intent: Intent) = isGetContentIntent(intent) && - (intent.type!!.startsWith("video/") || intent.type == Video.Media.CONTENT_TYPE) + (intent.type!!.startsWith("video/") || intent.type == Video.Media.CONTENT_TYPE) private fun isGetAnyContentIntent(intent: Intent) = isGetContentIntent(intent) && intent.type == "*/*" private fun isSetWallpaperIntent(intent: Intent?) = intent?.action == Intent.ACTION_SET_WALLPAPER private fun hasImageContentData(intent: Intent) = (intent.data == Images.Media.EXTERNAL_CONTENT_URI || - intent.data == Images.Media.INTERNAL_CONTENT_URI) + intent.data == Images.Media.INTERNAL_CONTENT_URI) private fun hasVideoContentData(intent: Intent) = (intent.data == Video.Media.EXTERNAL_CONTENT_URI || - intent.data == Video.Media.INTERNAL_CONTENT_URI) + intent.data == Video.Media.INTERNAL_CONTENT_URI) private fun isImageType(intent: Intent) = (intent.type?.startsWith("image/") == true || intent.type == Images.Media.CONTENT_TYPE) @@ -948,14 +949,14 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { val sorting = config.getFolderSorting(directory.path) val grouping = config.getFolderGrouping(directory.path) val getProperDateTaken = config.directorySorting and SORT_BY_DATE_TAKEN != 0 || - sorting and SORT_BY_DATE_TAKEN != 0 || - grouping and GROUP_BY_DATE_TAKEN_DAILY != 0 || - grouping and GROUP_BY_DATE_TAKEN_MONTHLY != 0 + sorting and SORT_BY_DATE_TAKEN != 0 || + grouping and GROUP_BY_DATE_TAKEN_DAILY != 0 || + grouping and GROUP_BY_DATE_TAKEN_MONTHLY != 0 val getProperLastModified = config.directorySorting and SORT_BY_DATE_MODIFIED != 0 || - sorting and SORT_BY_DATE_MODIFIED != 0 || - grouping and GROUP_BY_LAST_MODIFIED_DAILY != 0 || - grouping and GROUP_BY_LAST_MODIFIED_MONTHLY != 0 + sorting and SORT_BY_DATE_MODIFIED != 0 || + grouping and GROUP_BY_LAST_MODIFIED_DAILY != 0 || + grouping and GROUP_BY_LAST_MODIFIED_MONTHLY != 0 val curMedia = mLastMediaFetcher!!.getFilesFrom(directory.path, getImagesOnly, getVideosOnly, getProperDateTaken, getProperLastModified, getProperFileSize, favoritePaths, false, lastModifieds, dateTakens) @@ -1047,14 +1048,14 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { val sorting = config.getFolderSorting(folder) val grouping = config.getFolderGrouping(folder) val getProperDateTaken = config.directorySorting and SORT_BY_DATE_TAKEN != 0 || - sorting and SORT_BY_DATE_TAKEN != 0 || - grouping and GROUP_BY_DATE_TAKEN_DAILY != 0 || - grouping and GROUP_BY_DATE_TAKEN_MONTHLY != 0 + sorting and SORT_BY_DATE_TAKEN != 0 || + grouping and GROUP_BY_DATE_TAKEN_DAILY != 0 || + grouping and GROUP_BY_DATE_TAKEN_MONTHLY != 0 val getProperLastModified = config.directorySorting and SORT_BY_DATE_MODIFIED != 0 || - sorting and SORT_BY_DATE_MODIFIED != 0 || - grouping and GROUP_BY_LAST_MODIFIED_DAILY != 0 || - grouping and GROUP_BY_LAST_MODIFIED_MONTHLY != 0 + sorting and SORT_BY_DATE_MODIFIED != 0 || + grouping and GROUP_BY_LAST_MODIFIED_DAILY != 0 || + grouping and GROUP_BY_LAST_MODIFIED_MONTHLY != 0 val newMedia = mLastMediaFetcher!!.getFilesFrom(folder, getImagesOnly, getVideosOnly, getProperDateTaken, getProperLastModified, getProperFileSize, favoritePaths, false, lastModifieds, dateTakens) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt index 48395d4f0..a9f0eb0b4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt @@ -77,7 +77,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { private var mStoredShowFileTypes = true private var mStoredRoundedCorners = false private var mStoredTextColor = 0 - private var mStoredPrimaryColor = 0 + private var mStoredAdjustedPrimaryColor = 0 private var mStoredThumbnailSpacing = 0 companion object { @@ -150,10 +150,11 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { getMediaAdapter()?.updateTextColor(config.textColor) } - if (mStoredPrimaryColor != config.primaryColor) { + val adjustedPrimaryColor = getAdjustedPrimaryColor() + if (mStoredAdjustedPrimaryColor != adjustedPrimaryColor) { getMediaAdapter()?.updatePrimaryColor(config.primaryColor) - media_horizontal_fastscroller.updatePrimaryColor() - media_vertical_fastscroller.updatePrimaryColor() + media_horizontal_fastscroller.updatePrimaryColor(adjustedPrimaryColor) + media_vertical_fastscroller.updatePrimaryColor(adjustedPrimaryColor) } if (mStoredThumbnailSpacing != config.thumbnailSpacing) { @@ -310,11 +311,11 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { mStoredScrollHorizontally = scrollHorizontally mStoredShowFileTypes = showThumbnailFileTypes mStoredTextColor = textColor - mStoredPrimaryColor = primaryColor mStoredThumbnailSpacing = thumbnailSpacing mStoredRoundedCorners = fileRoundedCorners mShowAll = showAll } + mStoredAdjustedPrimaryColor = getAdjustedPrimaryColor() } private fun setupSearch(menu: Menu) {