From 841d77016763029190204d095c7fe5ef61dcc58d Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 8 Oct 2021 21:51:12 +0200 Subject: [PATCH] formatting some code style and imports in activities, no real change --- .../gallery/pro/activities/EditActivity.kt | 30 +++++-- .../gallery/pro/activities/MainActivity.kt | 40 ++++++--- .../gallery/pro/activities/MediaActivity.kt | 6 +- .../pro/activities/PanoramaPhotoActivity.kt | 4 +- .../pro/activities/PanoramaVideoActivity.kt | 8 +- .../pro/activities/PhotoVideoActivity.kt | 16 ++-- .../pro/activities/SetWallpaperActivity.kt | 7 +- .../pro/activities/SettingsActivity.kt | 46 ++++++---- .../gallery/pro/activities/SimpleActivity.kt | 52 +++++------ .../pro/activities/VideoPlayerActivity.kt | 16 +++- .../pro/activities/ViewPagerActivity.kt | 29 ++++-- .../pro/activities/WidgetConfigureActivity.kt | 3 +- .../gallery/pro/extensions/Context.kt | 89 +++++++++++++++---- .../gallery/pro/helpers/MediaFetcher.kt | 41 ++++++--- 14 files changed, 268 insertions(+), 119 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt index 8a082817f..93f6d4051 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt @@ -215,7 +215,13 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener return false } - override fun onResourceReady(bitmap: Bitmap?, model: Any?, target: Target?, dataSource: DataSource?, isFirstResource: Boolean): Boolean { + override fun onResourceReady( + bitmap: Bitmap?, + model: Any?, + target: Target?, + dataSource: DataSource?, + isFirstResource: Boolean + ): Boolean { val currentFilter = getFiltersAdapter()?.getCurrentFilter() if (filterInitialBitmap == null) { loadCropImageView() @@ -604,7 +610,13 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener return false } - override fun onResourceReady(resource: Bitmap?, model: Any?, target: Target?, dataSource: DataSource?, isFirstResource: Boolean) = false + override fun onResourceReady( + resource: Bitmap?, + model: Any?, + target: Target?, + dataSource: DataSource?, + isFirstResource: Boolean + ) = false }) .submit(thumbnailSize, thumbnailSize) .get() @@ -678,7 +690,13 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener } private fun updateAspectRatioButtons() { - arrayOf(bottom_aspect_ratio_free, bottom_aspect_ratio_one_one, bottom_aspect_ratio_four_three, bottom_aspect_ratio_sixteen_nine, bottom_aspect_ratio_other).forEach { + arrayOf( + bottom_aspect_ratio_free, + bottom_aspect_ratio_one_one, + bottom_aspect_ratio_four_three, + bottom_aspect_ratio_sixteen_nine, + bottom_aspect_ratio_other + ).forEach { it.setTextColor(Color.WHITE) } @@ -808,7 +826,8 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener if (newPath.isEmpty()) { val filename = applicationContext.getFilenameFromContentUri(saveUri) ?: "" if (filename.isNotEmpty()) { - val path = if (intent.extras?.containsKey(REAL_FILE_PATH) == true) intent.getStringExtra(REAL_FILE_PATH)?.getParentPath() else internalStoragePath + val path = + if (intent.extras?.containsKey(REAL_FILE_PATH) == true) intent.getStringExtra(REAL_FILE_PATH)?.getParentPath() else internalStoragePath newPath = "$path/$filename" shouldAppendFilename = false } @@ -825,7 +844,8 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener private fun saveBitmapToFile(bitmap: Bitmap, path: String, showSavingToast: Boolean) { if (!packageName.contains("slootelibomelpmis".reversed(), true)) { if (baseConfig.appRunCount > 100) { - val label = "sknahT .moc.slootelibomelpmis.www morf eno lanigiro eht daolnwod ytefas nwo ruoy roF .ppa eht fo noisrev ekaf a gnisu era uoY".reversed() + val label = + "sknahT .moc.slootelibomelpmis.www morf eno lanigiro eht daolnwod ytefas nwo ruoy roF .ppa eht fo noisrev ekaf a gnisu era uoY".reversed() runOnUiThread { ConfirmationDialog(this, label, positive = com.simplemobiletools.commons.R.string.ok, negative = 0) { launchViewIntent("6629852208836920709=di?ved/sppa/erots/moc.elgoog.yalp//:sptth".reversed()) 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 e07942993..4a4a3d6a1 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 @@ -548,7 +548,8 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { } override fun deleteFolders(folders: ArrayList) { - val fileDirItems = folders.asSequence().filter { it.isDirectory }.map { FileDirItem(it.absolutePath, it.name, true) }.toMutableList() as ArrayList + val fileDirItems = + folders.asSequence().filter { it.isDirectory }.map { FileDirItem(it.absolutePath, it.name, true) }.toMutableList() as ArrayList when { fileDirItems.isEmpty() -> return fileDirItems.size == 1 -> { @@ -609,9 +610,10 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { } if (config.deleteEmptyFolders) { - folders.filter { !it.absolutePath.isDownloadsFolder() && it.isDirectory && it.toFileDirItem(this).getProperFileCount(this, true) == 0 }.forEach { - tryDeleteFileDirItem(it.toFileDirItem(this), true, true) - } + folders.filter { !it.absolutePath.isDownloadsFolder() && it.isDirectory && it.toFileDirItem(this).getProperFileCount(this, true) == 0 } + .forEach { + tryDeleteFileDirItem(it.toFileDirItem(this), true, true) + } } } } @@ -958,8 +960,10 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { 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) + val curMedia = mLastMediaFetcher!!.getFilesFrom( + directory.path, getImagesOnly, getVideosOnly, getProperDateTaken, getProperLastModified, + getProperFileSize, favoritePaths, false, lastModifieds, dateTakens + ) val newDir = if (curMedia.isEmpty()) { if (directory.path != tempFolderPath) { @@ -1057,8 +1061,10 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { 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) + val newMedia = mLastMediaFetcher!!.getFilesFrom( + folder, getImagesOnly, getVideosOnly, getProperDateTaken, getProperLastModified, + getProperFileSize, favoritePaths, false, lastModifieds, dateTakens + ) if (newMedia.isEmpty()) { continue @@ -1189,7 +1195,15 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { if (currAdapter == null || forceRecreate) { initZoomListener() val fastscroller = if (config.scrollHorizontally) directories_horizontal_fastscroller else directories_vertical_fastscroller - DirectoryAdapter(this, dirsToShow, this, directories_grid, isPickIntent(intent) || isGetAnyContentIntent(intent), directories_refresh_layout, fastscroller) { + DirectoryAdapter( + this, + dirsToShow, + this, + directories_grid, + isPickIntent(intent) || isGetAnyContentIntent(intent), + directories_refresh_layout, + fastscroller + ) { val clickedDir = it as Directory val path = clickedDir.path if (clickedDir.subfoldersCount == 1 || !config.groupDirectSubfolders) { @@ -1216,7 +1230,8 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { } else { runOnUiThread { if (textToSearch.isNotEmpty()) { - dirsToShow = dirsToShow.filter { it.name.contains(textToSearch, true) }.sortedBy { !it.name.startsWith(textToSearch, true) }.toMutableList() as ArrayList + dirsToShow = dirsToShow.filter { it.name.contains(textToSearch, true) }.sortedBy { !it.name.startsWith(textToSearch, true) } + .toMutableList() as ArrayList } checkPlaceholderVisibility(dirsToShow) @@ -1299,8 +1314,9 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { private fun getCurrentlyDisplayedDirs() = getRecyclerAdapter()?.dirs ?: ArrayList() - private fun getBubbleTextItem(index: Int) = getRecyclerAdapter()?.dirs?.getOrNull(index)?.getBubbleText(config.directorySorting, this, mDateFormat, mTimeFormat) - ?: "" + private fun getBubbleTextItem(index: Int) = + getRecyclerAdapter()?.dirs?.getOrNull(index)?.getBubbleText(config.directorySorting, this, mDateFormat, mTimeFormat) + ?: "" private fun setupLatestMediaId() { ensureBackgroundThread { 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 a49dd6bbf..7df4bbf73 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 @@ -411,8 +411,10 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { if (currAdapter == null) { initZoomListener() val fastscroller = if (config.scrollHorizontally) media_horizontal_fastscroller else media_vertical_fastscroller - MediaAdapter(this, mMedia.clone() as ArrayList, this, mIsGetImageIntent || mIsGetVideoIntent || mIsGetAnyIntent, - mAllowPickingMultiple, mPath, media_grid, fastscroller) { + MediaAdapter( + this, mMedia.clone() as ArrayList, this, mIsGetImageIntent || mIsGetVideoIntent || mIsGetAnyIntent, + mAllowPickingMultiple, mPath, media_grid, fastscroller + ) { if (it is Medium && !isFinishing) { itemClicked(it.path) } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaPhotoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaPhotoActivity.kt index f2bb28a04..e8b3dad26 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaPhotoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaPhotoActivity.kt @@ -14,7 +14,9 @@ import com.google.vr.sdk.widgets.pano.VrPanoramaView import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.gallery.pro.R -import com.simplemobiletools.gallery.pro.extensions.* +import com.simplemobiletools.gallery.pro.extensions.config +import com.simplemobiletools.gallery.pro.extensions.hideSystemUI +import com.simplemobiletools.gallery.pro.extensions.showSystemUI import com.simplemobiletools.gallery.pro.helpers.PATH import kotlinx.android.synthetic.main.activity_panorama_photo.* diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaVideoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaVideoActivity.kt index e546ec1af..a1dc97ee1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaVideoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaVideoActivity.kt @@ -14,7 +14,10 @@ import com.google.vr.sdk.widgets.video.VrVideoEventListener import com.google.vr.sdk.widgets.video.VrVideoView import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.gallery.pro.R -import com.simplemobiletools.gallery.pro.extensions.* +import com.simplemobiletools.gallery.pro.extensions.config +import com.simplemobiletools.gallery.pro.extensions.hasNavBar +import com.simplemobiletools.gallery.pro.extensions.hideSystemUI +import com.simplemobiletools.gallery.pro.extensions.showSystemUI import com.simplemobiletools.gallery.pro.helpers.MIN_SKIP_LENGTH import com.simplemobiletools.gallery.pro.helpers.PATH import kotlinx.android.synthetic.main.activity_panorama_video.* @@ -244,7 +247,8 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList video_time_holder.setPadding(0, 0, right, bottom) video_time_holder.background = resources.getDrawable(R.drawable.gradient_background) video_time_holder.onGlobalLayout { - val newBottomMargin = video_time_holder.height - resources.getDimension(R.dimen.video_player_play_pause_size).toInt() - resources.getDimension(R.dimen.activity_margin).toInt() + val newBottomMargin = video_time_holder.height - resources.getDimension(R.dimen.video_player_play_pause_size) + .toInt() - resources.getDimension(R.dimen.activity_margin).toInt() (explore.layoutParams as RelativeLayout.LayoutParams).bottomMargin = newBottomMargin (cardboard.layoutParams as RelativeLayout.LayoutParams).apply { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt index ff328654b..3d59b23b6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt @@ -274,11 +274,11 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList private fun isFileTypeVisible(path: String): Boolean { val filter = config.filterMedia return !(path.isImageFast() && filter and TYPE_IMAGES == 0 || - path.isVideoFast() && filter and TYPE_VIDEOS == 0 || - path.isGif() && filter and TYPE_GIFS == 0 || - path.isRawFast() && filter and TYPE_RAWS == 0 || - path.isSvg() && filter and TYPE_SVGS == 0 || - path.isPortrait() && filter and TYPE_PORTRAITS == 0) + path.isVideoFast() && filter and TYPE_VIDEOS == 0 || + path.isGif() && filter and TYPE_GIFS == 0 || + path.isRawFast() && filter and TYPE_RAWS == 0 || + path.isSvg() && filter and TYPE_SVGS == 0 || + path.isPortrait() && filter and TYPE_PORTRAITS == 0) } private fun initBottomActions() { @@ -296,8 +296,10 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList } private fun initBottomActionButtons() { - arrayListOf(bottom_favorite, bottom_delete, bottom_rotate, bottom_properties, bottom_change_orientation, bottom_slideshow, bottom_show_on_map, - bottom_toggle_file_visibility, bottom_rename, bottom_copy, bottom_move, bottom_resize).forEach { + arrayListOf( + bottom_favorite, bottom_delete, bottom_rotate, bottom_properties, bottom_change_orientation, bottom_slideshow, bottom_show_on_map, + bottom_toggle_file_visibility, bottom_rename, bottom_copy, bottom_move, bottom_resize + ).forEach { it.beGone() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SetWallpaperActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SetWallpaperActivity.kt index a6941c2b4..a616a1285 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SetWallpaperActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SetWallpaperActivity.kt @@ -104,9 +104,10 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete private fun confirmWallpaper() { if (isNougatPlus()) { val items = arrayListOf( - RadioItem(WallpaperManager.FLAG_SYSTEM, getString(R.string.home_screen)), - RadioItem(WallpaperManager.FLAG_LOCK, getString(R.string.lock_screen)), - RadioItem(WallpaperManager.FLAG_SYSTEM or WallpaperManager.FLAG_LOCK, getString(R.string.home_and_lock_screen))) + RadioItem(WallpaperManager.FLAG_SYSTEM, getString(R.string.home_screen)), + RadioItem(WallpaperManager.FLAG_LOCK, getString(R.string.lock_screen)), + RadioItem(WallpaperManager.FLAG_SYSTEM or WallpaperManager.FLAG_LOCK, getString(R.string.home_and_lock_screen)) + ) RadioGroupDialog(this, items) { wallpaperFlag = it as Int diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt index c27fd6530..6942b3e62 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt @@ -107,9 +107,11 @@ class SettingsActivity : SimpleActivity() { private fun setupSectionColors() { val adjustedPrimaryColor = getAdjustedPrimaryColor() - arrayListOf(visibility_label, videos_label, thumbnails_label, scrolling_label, fullscreen_media_label, security_label, + arrayListOf( + visibility_label, videos_label, thumbnails_label, scrolling_label, fullscreen_media_label, security_label, file_operations_label, deep_zoomable_images_label, extended_details_label, bottom_actions_label, recycle_bin_label, - migrating_label).forEach { + migrating_label + ).forEach { it.setTextColor(adjustedPrimaryColor) } } @@ -142,7 +144,8 @@ class SettingsActivity : SimpleActivity() { val items = arrayListOf( RadioItem(PRIORITY_SPEED, getString(R.string.speed)), RadioItem(PRIORITY_COMPROMISE, getString(R.string.compromise)), - RadioItem(PRIORITY_VALIDITY, getString(R.string.avoid_showing_invalid_files))) + RadioItem(PRIORITY_VALIDITY, getString(R.string.avoid_showing_invalid_files)) + ) RadioGroupDialog(this@SettingsActivity, items, config.fileLoadingPriority) { config.fileLoadingPriority = it as Int @@ -151,11 +154,13 @@ class SettingsActivity : SimpleActivity() { } } - private fun getFileLoadingPriorityText() = getString(when (config.fileLoadingPriority) { - PRIORITY_SPEED -> R.string.speed - PRIORITY_COMPROMISE -> R.string.compromise - else -> R.string.avoid_showing_invalid_files - }) + private fun getFileLoadingPriorityText() = getString( + when (config.fileLoadingPriority) { + PRIORITY_SPEED -> R.string.speed + PRIORITY_COMPROMISE -> R.string.compromise + else -> R.string.avoid_showing_invalid_files + } + ) private fun setupManageIncludedFolders() { settings_manage_included_folders_holder.setOnClickListener { @@ -403,10 +408,12 @@ class SettingsActivity : SimpleActivity() { } } - private fun getFolderStyleText() = getString(when (config.folderStyle) { - FOLDER_STYLE_SQUARE -> R.string.square - else -> R.string.rounded_corners - }) + private fun getFolderStyleText() = getString( + when (config.folderStyle) { + FOLDER_STYLE_SQUARE -> R.string.square + else -> R.string.rounded_corners + } + ) private fun setupKeepLastModified() { settings_keep_last_modified.isChecked = config.keepLastModified @@ -508,7 +515,8 @@ class SettingsActivity : SimpleActivity() { val items = arrayListOf( RadioItem(ROTATE_BY_SYSTEM_SETTING, getString(R.string.screen_rotation_system_setting)), RadioItem(ROTATE_BY_DEVICE_ROTATION, getString(R.string.screen_rotation_device_rotation)), - RadioItem(ROTATE_BY_ASPECT_RATIO, getString(R.string.screen_rotation_aspect_ratio))) + RadioItem(ROTATE_BY_ASPECT_RATIO, getString(R.string.screen_rotation_aspect_ratio)) + ) RadioGroupDialog(this@SettingsActivity, items, config.screenRotation) { config.screenRotation = it as Int @@ -517,11 +525,13 @@ class SettingsActivity : SimpleActivity() { } } - private fun getScreenRotationText() = getString(when (config.screenRotation) { - ROTATE_BY_SYSTEM_SETTING -> R.string.screen_rotation_system_setting - ROTATE_BY_DEVICE_ROTATION -> R.string.screen_rotation_device_rotation - else -> R.string.screen_rotation_aspect_ratio - }) + private fun getScreenRotationText() = getString( + when (config.screenRotation) { + ROTATE_BY_SYSTEM_SETTING -> R.string.screen_rotation_system_setting + ROTATE_BY_DEVICE_ROTATION -> R.string.screen_rotation_device_rotation + else -> R.string.screen_rotation_aspect_ratio + } + ) private fun setupBottomActions() { settings_bottom_actions.isChecked = config.bottomActions diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SimpleActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SimpleActivity.kt index 66abce29d..95b9f5841 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SimpleActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SimpleActivity.kt @@ -22,36 +22,36 @@ open class SimpleActivity : BaseSimpleActivity() { val observer = object : ContentObserver(null) { override fun onChange(selfChange: Boolean, uri: Uri?) { super.onChange(selfChange, uri) - if (uri != null) { - val path = getRealPathFromURI(uri) - if (path != null) { - updateDirectoryPath(path.getParentPath()) - addPathToDB(path) - } - } + if (uri != null) { + val path = getRealPathFromURI(uri) + if (path != null) { + updateDirectoryPath(path.getParentPath()) + addPathToDB(path) + } + } } } override fun getAppIconIDs() = arrayListOf( - R.mipmap.ic_launcher_red, - R.mipmap.ic_launcher_pink, - R.mipmap.ic_launcher_purple, - R.mipmap.ic_launcher_deep_purple, - R.mipmap.ic_launcher_indigo, - R.mipmap.ic_launcher_blue, - R.mipmap.ic_launcher_light_blue, - R.mipmap.ic_launcher_cyan, - R.mipmap.ic_launcher_teal, - R.mipmap.ic_launcher_green, - R.mipmap.ic_launcher_light_green, - R.mipmap.ic_launcher_lime, - R.mipmap.ic_launcher_yellow, - R.mipmap.ic_launcher_amber, - R.mipmap.ic_launcher, - R.mipmap.ic_launcher_deep_orange, - R.mipmap.ic_launcher_brown, - R.mipmap.ic_launcher_blue_grey, - R.mipmap.ic_launcher_grey_black + R.mipmap.ic_launcher_red, + R.mipmap.ic_launcher_pink, + R.mipmap.ic_launcher_purple, + R.mipmap.ic_launcher_deep_purple, + R.mipmap.ic_launcher_indigo, + R.mipmap.ic_launcher_blue, + R.mipmap.ic_launcher_light_blue, + R.mipmap.ic_launcher_cyan, + R.mipmap.ic_launcher_teal, + R.mipmap.ic_launcher_green, + R.mipmap.ic_launcher_light_green, + R.mipmap.ic_launcher_lime, + R.mipmap.ic_launcher_yellow, + R.mipmap.ic_launcher_amber, + R.mipmap.ic_launcher, + R.mipmap.ic_launcher_deep_orange, + R.mipmap.ic_launcher_brown, + R.mipmap.ic_launcher_blue_grey, + R.mipmap.ic_launcher_grey_black ) override fun getAppLauncherName() = getString(R.string.app_launcher_name) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt index 879f5bd4f..61c4f2684 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt @@ -443,7 +443,16 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen } val newAlpha = if (isFullScreen) 0f else 1f - arrayOf(video_prev_file, video_toggle_play_pause, video_next_file, video_curr_time, video_seekbar, video_duration, top_shadow, video_bottom_gradient).forEach { + arrayOf( + video_prev_file, + video_toggle_play_pause, + video_next_file, + video_curr_time, + video_seekbar, + video_duration, + top_shadow, + video_bottom_gradient + ).forEach { it.animate().alpha(newAlpha).start() } video_seekbar.setOnSeekBarChangeListener(if (mIsFullscreen) null else this) @@ -540,8 +549,9 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen val downGestureDuration = System.currentTimeMillis() - mTouchDownTime if (config.allowDownGesture && !mIgnoreCloseDown && Math.abs(diffY) > Math.abs(diffX) && diffY < -mCloseDownThreshold && - downGestureDuration < MAX_CLOSE_DOWN_GESTURE_DURATION && - video_surface_frame.controller.state.zoom == 1f) { + downGestureDuration < MAX_CLOSE_DOWN_GESTURE_DURATION && + video_surface_frame.controller.state.zoom == 1f + ) { supportFinishAfterTransition() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt index 3a36cdea6..0fe226c5d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt @@ -180,10 +180,14 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View findItem(R.id.menu_save_as).isVisible = rotationDegrees != 0 findItem(R.id.menu_print).isVisible = currentMedium.isImage() || currentMedium.isRaw() findItem(R.id.menu_resize).isVisible = visibleBottomActions and BOTTOM_ACTION_RESIZE == 0 && currentMedium.isImage() - findItem(R.id.menu_hide).isVisible = !currentMedium.isHidden() && visibleBottomActions and BOTTOM_ACTION_TOGGLE_VISIBILITY == 0 && !currentMedium.getIsInRecycleBin() - findItem(R.id.menu_unhide).isVisible = currentMedium.isHidden() && visibleBottomActions and BOTTOM_ACTION_TOGGLE_VISIBILITY == 0 && !currentMedium.getIsInRecycleBin() - findItem(R.id.menu_add_to_favorites).isVisible = !currentMedium.isFavorite && visibleBottomActions and BOTTOM_ACTION_TOGGLE_FAVORITE == 0 && !currentMedium.getIsInRecycleBin() - findItem(R.id.menu_remove_from_favorites).isVisible = currentMedium.isFavorite && visibleBottomActions and BOTTOM_ACTION_TOGGLE_FAVORITE == 0 && !currentMedium.getIsInRecycleBin() + findItem(R.id.menu_hide).isVisible = + !currentMedium.isHidden() && visibleBottomActions and BOTTOM_ACTION_TOGGLE_VISIBILITY == 0 && !currentMedium.getIsInRecycleBin() + findItem(R.id.menu_unhide).isVisible = + currentMedium.isHidden() && visibleBottomActions and BOTTOM_ACTION_TOGGLE_VISIBILITY == 0 && !currentMedium.getIsInRecycleBin() + findItem(R.id.menu_add_to_favorites).isVisible = + !currentMedium.isFavorite && visibleBottomActions and BOTTOM_ACTION_TOGGLE_FAVORITE == 0 && !currentMedium.getIsInRecycleBin() + findItem(R.id.menu_remove_from_favorites).isVisible = + currentMedium.isFavorite && visibleBottomActions and BOTTOM_ACTION_TOGGLE_FAVORITE == 0 && !currentMedium.getIsInRecycleBin() findItem(R.id.menu_restore_file).isVisible = currentMedium.path.startsWith(recycleBinPath) findItem(R.id.menu_create_shortcut).isVisible = isOreoPlus() findItem(R.id.menu_change_orientation).isVisible = rotationDegrees == 0 && visibleBottomActions and BOTTOM_ACTION_CHANGE_ORIENTATION == 0 @@ -193,7 +197,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View MenuItem.SHOW_AS_ACTION_ALWAYS } else { MenuItem.SHOW_AS_ACTION_IF_ROOM - }) + } + ) } if (visibleBottomActions != 0) { @@ -401,7 +406,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View val isFavorite = favoritesDB.isFavorite(mPath) val duration = if (type == TYPE_VIDEOS) getDuration(mPath) ?: 0 else 0 val ts = System.currentTimeMillis() - val medium = Medium(null, mPath.getFilenameFromPath(), mPath, mPath.getParentPath(), ts, ts, File(mPath).length(), type, duration, isFavorite, 0) + val medium = + Medium(null, mPath.getFilenameFromPath(), mPath, mPath.getParentPath(), ts, ts, File(mPath).length(), type, duration, isFavorite, 0) mediaDB.insert(medium) } } @@ -952,7 +958,13 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View return false } - override fun onResourceReady(bitmap: Bitmap?, model: Any?, target: Target?, dataSource: DataSource?, isFirstResource: Boolean): Boolean { + override fun onResourceReady( + bitmap: Bitmap?, + model: Any?, + target: Target?, + dataSource: DataSource?, + isFirstResource: Boolean + ): Boolean { if (bitmap != null) { printHelper.printBitmap(path.getFilenameFromPath(), bitmap) } @@ -1134,7 +1146,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } private fun gotMedia(thumbnailItems: ArrayList, ignorePlayingVideos: Boolean = false) { - val media = thumbnailItems.asSequence().filter { it is Medium && !mIgnoredPaths.contains(it.path) }.map { it as Medium }.toMutableList() as ArrayList + val media = + thumbnailItems.asSequence().filter { it is Medium && !mIgnoredPaths.contains(it.path) }.map { it as Medium }.toMutableList() as ArrayList if (isDirEmpty(media) || media.hashCode() == mPrevHashcode) { return } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt index 662dbd17c..43741c140 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt @@ -178,6 +178,7 @@ class WidgetConfigureActivity : SimpleActivity() { private fun handleFolderNameDisplay() { val showFolderName = folder_picker_show_folder_name.isChecked config_folder_name.beVisibleIf(showFolderName) - (config_image.layoutParams as RelativeLayout.LayoutParams).bottomMargin = if (showFolderName) 0 else resources.getDimension(R.dimen.normal_margin).toInt() + (config_image.layoutParams as RelativeLayout.LayoutParams).bottomMargin = + if (showFolderName) 0 else resources.getDimension(R.dimen.normal_margin).toInt() } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt index 5fee49423..d95fb11a4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt @@ -2,12 +2,14 @@ package com.simplemobiletools.gallery.pro.extensions import android.appwidget.AppWidgetManager import android.content.ComponentName +import android.content.ContentUris import android.content.Context import android.content.Intent import android.database.Cursor import android.graphics.Bitmap import android.graphics.drawable.PictureDrawable import android.media.AudioManager +import android.net.Uri import android.os.Process import android.provider.MediaStore.Files import android.provider.MediaStore.Images @@ -27,6 +29,7 @@ import com.bumptech.glide.request.target.Target import com.bumptech.glide.signature.ObjectKey import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.* +import com.simplemobiletools.commons.models.FileDirItem import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.activities.SettingsActivity import com.simplemobiletools.gallery.pro.asynctasks.GetMediaAsynctask @@ -42,8 +45,7 @@ import java.io.File import java.io.FileInputStream import java.nio.ByteBuffer import java.nio.channels.FileChannel -import java.util.HashSet -import java.util.LinkedHashSet +import java.util.* import kotlin.Comparator import kotlin.collections.ArrayList import kotlin.collections.HashMap @@ -239,7 +241,8 @@ fun Context.getDirectParentSubfolders(dirs: ArrayList, currentPathPre mediaTypes = mediaTypes or it.types } - val directory = Directory(newDirId++, + val directory = Directory( + newDirId++, parent, subDirs.first().tmb, getFolderNameFromPath(parent), @@ -249,7 +252,8 @@ fun Context.getDirectParentSubfolders(dirs: ArrayList, currentPathPre subDirs.sumByLong { it.size }, getPathLocation(parent), mediaTypes, - "") + "" + ) directory.containsMediaFilesDirectly = false dirs.add(directory) @@ -422,8 +426,10 @@ fun Context.getFolderNameFromPath(path: String): String { } } -fun Context.loadImage(type: Int, path: String, target: MySquareImageView, horizontalScroll: Boolean, animateGifs: Boolean, cropThumbnails: Boolean, - roundCorners: Int, signature: ObjectKey, skipMemoryCacheAtPaths: ArrayList? = null) { +fun Context.loadImage( + type: Int, path: String, target: MySquareImageView, horizontalScroll: Boolean, animateGifs: Boolean, cropThumbnails: Boolean, + roundCorners: Int, signature: ObjectKey, skipMemoryCacheAtPaths: ArrayList? = null +) { target.isHorizontalScrolling = horizontalScroll if (type == TYPE_IMAGES || type == TYPE_VIDEOS || type == TYPE_RAWS || type == TYPE_PORTRAITS) { if (type == TYPE_IMAGES && path.isPng()) { @@ -474,7 +480,14 @@ fun Context.getPathLocation(path: String): Int { } } -fun Context.loadPng(path: String, target: MySquareImageView, cropThumbnails: Boolean, roundCorners: Int, signature: ObjectKey, skipMemoryCacheAtPaths: ArrayList? = null) { +fun Context.loadPng( + path: String, + target: MySquareImageView, + cropThumbnails: Boolean, + roundCorners: Int, + signature: ObjectKey, + skipMemoryCacheAtPaths: ArrayList? = null +) { val options = RequestOptions() .signature(signature) .skipMemoryCache(skipMemoryCacheAtPaths?.contains(path) == true) @@ -493,7 +506,13 @@ fun Context.loadPng(path: String, target: MySquareImageView, cropThumbnails: Boo return true } - override fun onResourceReady(resource: Bitmap?, model: Any?, targetBitmap: Target?, dataSource: DataSource?, isFirstResource: Boolean): Boolean { + override fun onResourceReady( + resource: Bitmap?, + model: Any?, + targetBitmap: Target?, + dataSource: DataSource?, + isFirstResource: Boolean + ): Boolean { return false } }) @@ -507,7 +526,14 @@ fun Context.loadPng(path: String, target: MySquareImageView, cropThumbnails: Boo builder.into(target) } -fun Context.loadJpg(path: String, target: MySquareImageView, cropThumbnails: Boolean, roundCorners: Int, signature: ObjectKey, skipMemoryCacheAtPaths: ArrayList? = null) { +fun Context.loadJpg( + path: String, + target: MySquareImageView, + cropThumbnails: Boolean, + roundCorners: Int, + signature: ObjectKey, + skipMemoryCacheAtPaths: ArrayList? = null +) { val options = RequestOptions() .signature(signature) .skipMemoryCache(skipMemoryCacheAtPaths?.contains(path) == true) @@ -529,7 +555,14 @@ fun Context.loadJpg(path: String, target: MySquareImageView, cropThumbnails: Boo builder.into(target) } -fun Context.loadStaticGIF(path: String, target: MySquareImageView, cropThumbnails: Boolean, roundCorners: Int, signature: ObjectKey, skipMemoryCacheAtPaths: ArrayList? = null) { +fun Context.loadStaticGIF( + path: String, + target: MySquareImageView, + cropThumbnails: Boolean, + roundCorners: Int, + signature: ObjectKey, + skipMemoryCacheAtPaths: ArrayList? = null +) { val options = RequestOptions() .signature(signature) .skipMemoryCache(skipMemoryCacheAtPaths?.contains(path) == true) @@ -598,7 +631,12 @@ fun Context.tryLoadingWithPicasso(path: String, view: MySquareImageView, cropThu } } -fun Context.getCachedDirectories(getVideosOnly: Boolean = false, getImagesOnly: Boolean = false, forceShowHidden: Boolean = false, callback: (ArrayList) -> Unit) { +fun Context.getCachedDirectories( + getVideosOnly: Boolean = false, + getImagesOnly: Boolean = false, + forceShowHidden: Boolean = false, + callback: (ArrayList) -> Unit +) { ensureBackgroundThread { try { Process.setThreadPriority(Process.THREAD_PRIORITY_MORE_FAVORABLE) @@ -780,7 +818,16 @@ fun Context.updateDBMediaPath(oldPath: String, newPath: String) { fun Context.updateDBDirectory(directory: Directory) { try { - directoryDao.updateDirectory(directory.path, directory.tmb, directory.mediaCnt, directory.modified, directory.taken, directory.size, directory.types, directory.sortValue) + directoryDao.updateDirectory( + directory.path, + directory.tmb, + directory.mediaCnt, + directory.modified, + directory.taken, + directory.size, + directory.types, + directory.sortValue + ) } catch (ignored: Exception) { } } @@ -923,8 +970,10 @@ fun Context.addPathToDB(path: String) { try { val isFavorite = favoritesDB.isFavorite(path) val videoDuration = if (type == TYPE_VIDEOS) getDuration(path) ?: 0 else 0 - val medium = Medium(null, path.getFilenameFromPath(), path, path.getParentPath(), System.currentTimeMillis(), System.currentTimeMillis(), - File(path).length(), type, videoDuration, isFavorite, 0L) + val medium = Medium( + null, path.getFilenameFromPath(), path, path.getParentPath(), System.currentTimeMillis(), System.currentTimeMillis(), + File(path).length(), type, videoDuration, isFavorite, 0L + ) mediaDB.insert(medium) } catch (ignored: Exception) { @@ -932,8 +981,10 @@ fun Context.addPathToDB(path: String) { } } -fun Context.createDirectoryFromMedia(path: String, curMedia: ArrayList, albumCovers: ArrayList, hiddenString: String, - includedFolders: MutableSet, getProperFileSize: Boolean, noMediaFolders: ArrayList): Directory { +fun Context.createDirectoryFromMedia( + path: String, curMedia: ArrayList, albumCovers: ArrayList, hiddenString: String, + includedFolders: MutableSet, getProperFileSize: Boolean, noMediaFolders: ArrayList +): Directory { val OTGPath = config.OTGPath val grouped = MediaFetcher(this).groupMedia(curMedia, path) var thumbnail: String? = null @@ -1018,8 +1069,10 @@ fun Context.updateDirectoryPath(path: String) { val lastModifieds = if (getProperLastModified) mediaFetcher.getFolderLastModifieds(path) else HashMap() val dateTakens = mediaFetcher.getFolderDateTakens(path) val favoritePaths = getFavoritePaths() - val curMedia = mediaFetcher.getFilesFrom(path, getImagesOnly, getVideosOnly, getProperDateTaken, getProperLastModified, getProperFileSize, - favoritePaths, false, lastModifieds, dateTakens) + val curMedia = mediaFetcher.getFilesFrom( + path, getImagesOnly, getVideosOnly, getProperDateTaken, getProperLastModified, getProperFileSize, + favoritePaths, false, lastModifieds, dateTakens + ) val directory = createDirectoryFromMedia(path, curMedia, albumCovers, hiddenString, includedFolders, getProperFileSize, noMediaFolders) updateDBDirectory(directory) } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt index 8eccf1215..05838c375 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt @@ -24,9 +24,11 @@ import java.util.* class MediaFetcher(val context: Context) { var shouldStop = false - fun getFilesFrom(curPath: String, isPickImage: Boolean, isPickVideo: Boolean, getProperDateTaken: Boolean, getProperLastModified: Boolean, - getProperFileSize: Boolean, favoritePaths: ArrayList, getVideoDurations: Boolean, - lastModifieds: HashMap, dateTakens: HashMap): ArrayList { + fun getFilesFrom( + curPath: String, isPickImage: Boolean, isPickVideo: Boolean, getProperDateTaken: Boolean, getProperLastModified: Boolean, + getProperFileSize: Boolean, favoritePaths: ArrayList, getVideoDurations: Boolean, + lastModifieds: HashMap, dateTakens: HashMap + ): ArrayList { val filterMedia = context.config.filterMedia if (filterMedia == 0) { return ArrayList() @@ -39,8 +41,10 @@ class MediaFetcher(val context: Context) { curMedia.addAll(newMedia) } } else { - val newMedia = getMediaInFolder(curPath, isPickImage, isPickVideo, filterMedia, getProperDateTaken, getProperLastModified, getProperFileSize, - favoritePaths, getVideoDurations, lastModifieds, dateTakens) + val newMedia = getMediaInFolder( + curPath, isPickImage, isPickVideo, filterMedia, getProperDateTaken, getProperLastModified, getProperFileSize, + favoritePaths, getVideoDurations, lastModifieds, dateTakens + ) curMedia.addAll(newMedia) } @@ -248,9 +252,11 @@ class MediaFetcher(val context: Context) { } } - private fun getMediaInFolder(folder: String, isPickImage: Boolean, isPickVideo: Boolean, filterMedia: Int, getProperDateTaken: Boolean, - getProperLastModified: Boolean, getProperFileSize: Boolean, favoritePaths: ArrayList, - getVideoDurations: Boolean, lastModifieds: HashMap, dateTakens: HashMap): ArrayList { + private fun getMediaInFolder( + folder: String, isPickImage: Boolean, isPickVideo: Boolean, filterMedia: Int, getProperDateTaken: Boolean, + getProperLastModified: Boolean, getProperFileSize: Boolean, favoritePaths: ArrayList, + getVideoDurations: Boolean, lastModifieds: HashMap, dateTakens: HashMap + ): ArrayList { val media = ArrayList() val isRecycleBin = folder == RECYCLE_BIN val deletedMedia = if (isRecycleBin) { @@ -387,8 +393,10 @@ class MediaFetcher(val context: Context) { return media } - private fun getMediaOnOTG(folder: String, isPickImage: Boolean, isPickVideo: Boolean, filterMedia: Int, favoritePaths: ArrayList, - getVideoDurations: Boolean): ArrayList { + private fun getMediaOnOTG( + folder: String, isPickImage: Boolean, isPickVideo: Boolean, filterMedia: Int, favoritePaths: ArrayList, + getVideoDurations: Boolean + ): ArrayList { val media = ArrayList() val files = context.getDocumentFile(folder)?.listFiles() ?: return media val checkFileExistence = context.config.fileLoadingPriority == PRIORITY_VALIDITY @@ -443,7 +451,9 @@ class MediaFetcher(val context: Context) { else -> TYPE_IMAGES } - val path = Uri.decode(file.uri.toString().replaceFirst("${context.config.OTGTreeUri}/document/${context.config.OTGPartition}%3A", "${context.config.OTGPath}/")) + val path = Uri.decode( + file.uri.toString().replaceFirst("${context.config.OTGTreeUri}/document/${context.config.OTGPartition}%3A", "${context.config.OTGPath}/") + ) val videoDuration = if (getVideoDurations) context.getDuration(path) ?: 0 else 0 val isFavorite = favoritePaths.contains(path) val medium = Medium(null, filename, path, folder, dateModified, dateTaken, size, type, videoDuration, isFavorite, 0L) @@ -692,7 +702,8 @@ class MediaFetcher(val context: Context) { val sortDescending = currentGrouping and GROUP_DESCENDING != 0 val sorted = if (currentGrouping and GROUP_BY_LAST_MODIFIED_DAILY != 0 || currentGrouping and GROUP_BY_LAST_MODIFIED_MONTHLY != 0 || - currentGrouping and GROUP_BY_DATE_TAKEN_DAILY != 0 || currentGrouping and GROUP_BY_DATE_TAKEN_MONTHLY != 0) { + currentGrouping and GROUP_BY_DATE_TAKEN_DAILY != 0 || currentGrouping and GROUP_BY_DATE_TAKEN_MONTHLY != 0 + ) { mediumGroups.toSortedMap(if (sortDescending) compareByDescending { it.toLongOrNull() ?: 0L } else { @@ -726,7 +737,11 @@ class MediaFetcher(val context: Context) { private fun getFormattedKey(key: String, grouping: Int, today: String, yesterday: String): String { var result = when { - grouping and GROUP_BY_LAST_MODIFIED_DAILY != 0 || grouping and GROUP_BY_DATE_TAKEN_DAILY != 0 -> getFinalDate(formatDate(key, true), today, yesterday) + grouping and GROUP_BY_LAST_MODIFIED_DAILY != 0 || grouping and GROUP_BY_DATE_TAKEN_DAILY != 0 -> getFinalDate( + formatDate(key, true), + today, + yesterday + ) grouping and GROUP_BY_LAST_MODIFIED_MONTHLY != 0 || grouping and GROUP_BY_DATE_TAKEN_MONTHLY != 0 -> formatDate(key, false) grouping and GROUP_BY_FILE_TYPE != 0 -> getFileTypeString(key) grouping and GROUP_BY_EXTENSION != 0 -> key.toUpperCase()