From 56d721b68aa0c61c9e373ee9133eed16d20e860a Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 24 Jan 2020 22:47:42 +0100 Subject: [PATCH 01/36] moving the isFavorite function at FavoritesDAO --- .../gallery/pro/activities/ViewPagerActivity.kt | 2 +- .../com/simplemobiletools/gallery/pro/extensions/Context.kt | 2 +- .../simplemobiletools/gallery/pro/interfaces/FavoritesDAO.kt | 4 +++- .../com/simplemobiletools/gallery/pro/interfaces/MediumDao.kt | 3 --- 4 files changed, 5 insertions(+), 6 deletions(-) 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 0dc77ed6c..1e456721b 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 @@ -375,7 +375,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View else -> TYPE_IMAGES } - val isFavorite = mediumDao.isFavorite(mPath) + val isFavorite = galleryDB.FavoritesDAO().isFavorite(mPath) val duration = if (type == TYPE_VIDEOS) mPath.getVideoDuration() else 0 val ts = System.currentTimeMillis() val medium = Medium(null, mPath.getFilenameFromPath(), mPath, mPath.getParentPath(), ts, ts, File(mPath).length(), type, duration, isFavorite, 0) 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 552b47339..b21e4a390 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 @@ -827,7 +827,7 @@ fun Context.addPathToDB(path: String) { try { val mediumDao = galleryDB.MediumDao() - val isFavorite = mediumDao.isFavorite(path) + val isFavorite = galleryDB.FavoritesDAO().isFavorite(path) val videoDuration = if (type == TYPE_VIDEOS) path.getVideoDuration() else 0 val medium = Medium(null, path.getFilenameFromPath(), path, path.getParentPath(), System.currentTimeMillis(), System.currentTimeMillis(), File(path).length(), type, videoDuration, isFavorite, 0L) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDAO.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDAO.kt index 1d80c3e80..d1fa0856e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDAO.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDAO.kt @@ -1,8 +1,10 @@ package com.simplemobiletools.gallery.pro.interfaces import androidx.room.Dao +import androidx.room.Query @Dao interface FavoritesDAO { - + @Query("SELECT id FROM favorites WHERE full_path = :path COLLATE NOCASE") + fun isFavorite(path: String): Boolean } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/MediumDao.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/MediumDao.kt index 490bd62f4..1ce2bb641 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/MediumDao.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/MediumDao.kt @@ -21,9 +21,6 @@ interface MediumDao { @Query("SELECT filename, full_path, parent_path, last_modified, date_taken, size, type, video_duration, is_favorite, deleted_ts FROM media WHERE deleted_ts != 0") fun getDeletedMedia(): List - @Query("SELECT is_favorite FROM media WHERE full_path = :path COLLATE NOCASE") - fun isFavorite(path: String): Boolean - @Insert(onConflict = REPLACE) fun insert(medium: Medium) From b867d2a2eb872d9dfef857eba97a9f37758e950e Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 24 Jan 2020 23:10:40 +0100 Subject: [PATCH 02/36] at deleting a file path from db, delete it from favorites too --- .../simplemobiletools/gallery/pro/extensions/Context.kt | 7 ++++++- .../gallery/pro/interfaces/FavoritesDAO.kt | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) 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 b21e4a390..5ead9ba4e 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 @@ -736,8 +736,13 @@ fun Context.getUpdatedDeletedMedia(mediumDao: MediumDao): ArrayList { } fun Context.deleteDBPath(mediumDao: MediumDao, path: String) { + deleteMediumWithPath(mediumDao, path.replaceFirst(recycleBinPath, RECYCLE_BIN)) +} + +fun Context.deleteMediumWithPath(mediumDao: MediumDao, path: String) { try { - mediumDao.deleteMediumPath(path.replaceFirst(recycleBinPath, RECYCLE_BIN)) + mediumDao.deleteMediumPath(path) + galleryDB.FavoritesDAO().deleteFavoritePath(path) } catch (ignored: Exception) { } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDAO.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDAO.kt index d1fa0856e..6daa09356 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDAO.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDAO.kt @@ -7,4 +7,7 @@ import androidx.room.Query interface FavoritesDAO { @Query("SELECT id FROM favorites WHERE full_path = :path COLLATE NOCASE") fun isFavorite(path: String): Boolean + + @Query("DELETE FROM favorites WHERE full_path = :path COLLATE NOCASE") + fun deleteFavoritePath(path: String) } From fb0badeca5288d4a7d5583c43e68ef2b13e9354c Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 24 Jan 2020 23:29:03 +0100 Subject: [PATCH 03/36] adding a few more favorites related queries --- .../gallery/pro/extensions/Context.kt | 7 +++---- .../gallery/pro/interfaces/FavoritesDAO.kt | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) 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 5ead9ba4e..b013354bf 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 @@ -28,10 +28,7 @@ import com.simplemobiletools.gallery.pro.helpers.* import com.simplemobiletools.gallery.pro.interfaces.DirectoryDao import com.simplemobiletools.gallery.pro.interfaces.MediumDao import com.simplemobiletools.gallery.pro.interfaces.WidgetsDao -import com.simplemobiletools.gallery.pro.models.AlbumCover -import com.simplemobiletools.gallery.pro.models.Directory -import com.simplemobiletools.gallery.pro.models.Medium -import com.simplemobiletools.gallery.pro.models.ThumbnailItem +import com.simplemobiletools.gallery.pro.models.* import com.simplemobiletools.gallery.pro.svg.SvgSoftwareLayerSetter import com.simplemobiletools.gallery.pro.views.MySquareImageView import pl.droidsonroids.gif.GifDrawable @@ -721,6 +718,8 @@ fun Context.getFavoritePaths(): ArrayList { } } +fun Context.getFavoriteFromPath(path: String) = Favorite(null, path, path.getFilenameFromPath(), path.getParentPath()) + // remove the "recycle_bin" from the file path prefix, replace it with real bin path /data/user... fun Context.getUpdatedDeletedMedia(mediumDao: MediumDao): ArrayList { val media = try { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDAO.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDAO.kt index 6daa09356..f3b97e6ad 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDAO.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDAO.kt @@ -1,10 +1,25 @@ package com.simplemobiletools.gallery.pro.interfaces import androidx.room.Dao +import androidx.room.Insert +import androidx.room.OnConflictStrategy import androidx.room.Query +import com.simplemobiletools.gallery.pro.models.Favorite @Dao interface FavoritesDAO { + @Insert(onConflict = OnConflictStrategy.REPLACE) + fun insert(favorite: Favorite) + + @Insert(onConflict = OnConflictStrategy.REPLACE) + fun insertAll(favorites: List) + + @Query("SELECT full_path FROM favorites") + fun getFavoriteRawPaths(): List + + @Query("SELECT favorites.full_path FROM favorites INNER JOIN media ON favorites.full_path = media.full_path WHERE media.deleted_ts = 0") + fun getValidFavoritePaths(): List + @Query("SELECT id FROM favorites WHERE full_path = :path COLLATE NOCASE") fun isFavorite(path: String): Boolean From a7b7881d732caab95874acb4f5864b68ca924143 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 25 Jan 2020 09:34:33 +0100 Subject: [PATCH 04/36] moving the favorite toggling function into FavoritesDao --- .../gallery/pro/activities/ViewPagerActivity.kt | 2 +- .../gallery/pro/adapters/MediaAdapter.kt | 3 +-- .../simplemobiletools/gallery/pro/extensions/Context.kt | 9 +++++++++ .../gallery/pro/interfaces/MediumDao.kt | 3 --- 4 files changed, 11 insertions(+), 6 deletions(-) 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 1e456721b..1befd61d9 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 @@ -864,7 +864,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View val medium = getCurrentMedium() ?: return medium.isFavorite = !medium.isFavorite ensureBackgroundThread { - galleryDB.MediumDao().updateFavorite(medium.path, medium.isFavorite) + updateFavorite(medium.path, medium.isFavorite) if (medium.isFavorite) { mFavoritePaths.add(medium.path) } else { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt index 298a90def..5dcf75275 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt @@ -266,10 +266,9 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList { fun Context.getFavoriteFromPath(path: String) = Favorite(null, path, path.getFilenameFromPath(), path.getParentPath()) +fun Context.updateFavorite(path: String, isFavorite: Boolean) { + val favoritesDAO = galleryDB.FavoritesDAO() + if (isFavorite) { + favoritesDAO.insert(getFavoriteFromPath(path)) + } else { + favoritesDAO.deleteFavoritePath(path) + } +} + // remove the "recycle_bin" from the file path prefix, replace it with real bin path /data/user... fun Context.getUpdatedDeletedMedia(mediumDao: MediumDao): ArrayList { val media = try { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/MediumDao.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/MediumDao.kt index 1ce2bb641..3f89a2f5d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/MediumDao.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/MediumDao.kt @@ -39,9 +39,6 @@ interface MediumDao { @Query("UPDATE OR REPLACE media SET filename = :newFilename, full_path = :newFullPath, parent_path = :newParentPath WHERE full_path = :oldPath COLLATE NOCASE") fun updateMedium(oldPath: String, newParentPath: String, newFilename: String, newFullPath: String) - @Query("UPDATE media SET is_favorite = :isFavorite WHERE full_path = :path COLLATE NOCASE") - fun updateFavorite(path: String, isFavorite: Boolean) - @Query("UPDATE OR REPLACE media SET full_path = :newPath, deleted_ts = :deletedTS WHERE full_path = :oldPath COLLATE NOCASE") fun updateDeleted(newPath: String, deletedTS: Long, oldPath: String) From 61c4db155d74b3ec913735577d5d30cb430f1784 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 25 Jan 2020 09:39:56 +0100 Subject: [PATCH 05/36] removing the favorite paths getting function from MediumDao --- .../com/simplemobiletools/gallery/pro/extensions/Context.kt | 2 +- .../com/simplemobiletools/gallery/pro/interfaces/MediumDao.kt | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) 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 c597a6f0d..cd098f6cd 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 @@ -712,7 +712,7 @@ fun Context.getOTGFolderChildrenNames(path: String) = getOTGFolderChildren(path) fun Context.getFavoritePaths(): ArrayList { return try { - galleryDB.MediumDao().getFavoritePaths() as ArrayList + galleryDB.FavoritesDAO().getValidFavoritePaths() as ArrayList } catch (e: Exception) { ArrayList() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/MediumDao.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/MediumDao.kt index 3f89a2f5d..1bf91b543 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/MediumDao.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/MediumDao.kt @@ -15,9 +15,6 @@ interface MediumDao { @Query("SELECT filename, full_path, parent_path, last_modified, date_taken, size, type, video_duration, is_favorite, deleted_ts FROM media WHERE deleted_ts = 0 AND is_favorite = 1") fun getFavorites(): List - @Query("SELECT full_path FROM media WHERE deleted_ts = 0 AND is_favorite = 1") - fun getFavoritePaths(): List - @Query("SELECT filename, full_path, parent_path, last_modified, date_taken, size, type, video_duration, is_favorite, deleted_ts FROM media WHERE deleted_ts != 0") fun getDeletedMedia(): List From b9369139f190f15ae8121cefd32da039f11ecc16 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 25 Jan 2020 09:51:28 +0100 Subject: [PATCH 06/36] renaming some DAO to Dao --- .../gallery/pro/activities/ViewPagerActivity.kt | 2 +- .../gallery/pro/adapters/DirectoryAdapter.kt | 2 +- .../gallery/pro/databases/GalleryDatabase.kt | 4 ++-- .../gallery/pro/extensions/Context.kt | 14 ++++++++------ .../{DateTakensDAO.kt => DateTakensDao.kt} | 2 +- .../{FavoritesDAO.kt => FavoritesDao.kt} | 5 ++++- .../gallery/pro/interfaces/MediumDao.kt | 3 --- 7 files changed, 17 insertions(+), 15 deletions(-) rename app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/{DateTakensDAO.kt => DateTakensDao.kt} (77%) rename app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/{FavoritesDAO.kt => FavoritesDao.kt} (91%) 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 1befd61d9..4ffb2d73d 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 @@ -375,7 +375,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View else -> TYPE_IMAGES } - val isFavorite = galleryDB.FavoritesDAO().isFavorite(mPath) + val isFavorite = favoritesDB.isFavorite(mPath) val duration = if (type == TYPE_VIDEOS) mPath.getVideoDuration() else 0 val ts = System.currentTimeMillis() val medium = Medium(null, mPath.getFilenameFromPath(), mPath, mPath.getParentPath(), ts, ts, File(mPath).length(), type, duration, isFavorite, 0) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt index abc71941e..a70362d67 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt @@ -555,7 +555,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList { return try { - galleryDB.FavoritesDAO().getValidFavoritePaths() as ArrayList + favoritesDB.getValidFavoritePaths() as ArrayList } catch (e: Exception) { ArrayList() } @@ -721,11 +724,10 @@ fun Context.getFavoritePaths(): ArrayList { fun Context.getFavoriteFromPath(path: String) = Favorite(null, path, path.getFilenameFromPath(), path.getParentPath()) fun Context.updateFavorite(path: String, isFavorite: Boolean) { - val favoritesDAO = galleryDB.FavoritesDAO() if (isFavorite) { - favoritesDAO.insert(getFavoriteFromPath(path)) + favoritesDB.insert(getFavoriteFromPath(path)) } else { - favoritesDAO.deleteFavoritePath(path) + favoritesDB.deleteFavoritePath(path) } } @@ -750,7 +752,7 @@ fun Context.deleteDBPath(mediumDao: MediumDao, path: String) { fun Context.deleteMediumWithPath(mediumDao: MediumDao, path: String) { try { mediumDao.deleteMediumPath(path) - galleryDB.FavoritesDAO().deleteFavoritePath(path) + favoritesDB.deleteFavoritePath(path) } catch (ignored: Exception) { } } @@ -840,7 +842,7 @@ fun Context.addPathToDB(path: String) { try { val mediumDao = galleryDB.MediumDao() - val isFavorite = galleryDB.FavoritesDAO().isFavorite(path) + val isFavorite = favoritesDB.isFavorite(path) val videoDuration = if (type == TYPE_VIDEOS) path.getVideoDuration() else 0 val medium = Medium(null, path.getFilenameFromPath(), path, path.getParentPath(), System.currentTimeMillis(), System.currentTimeMillis(), File(path).length(), type, videoDuration, isFavorite, 0L) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/DateTakensDAO.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/DateTakensDao.kt similarity index 77% rename from app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/DateTakensDAO.kt rename to app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/DateTakensDao.kt index 107801537..0d3380408 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/DateTakensDAO.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/DateTakensDao.kt @@ -3,6 +3,6 @@ package com.simplemobiletools.gallery.pro.interfaces import androidx.room.Dao @Dao -interface DateTakensDAO { +interface DateTakensDao { } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDAO.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDao.kt similarity index 91% rename from app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDAO.kt rename to app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDao.kt index f3b97e6ad..d835d9f65 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDAO.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDao.kt @@ -7,7 +7,7 @@ import androidx.room.Query import com.simplemobiletools.gallery.pro.models.Favorite @Dao -interface FavoritesDAO { +interface FavoritesDao { @Insert(onConflict = OnConflictStrategy.REPLACE) fun insert(favorite: Favorite) @@ -25,4 +25,7 @@ interface FavoritesDAO { @Query("DELETE FROM favorites WHERE full_path = :path COLLATE NOCASE") fun deleteFavoritePath(path: String) + + @Query("DELETE FROM favorites") + fun clearFavorites() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/MediumDao.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/MediumDao.kt index 1bf91b543..ec0a8befc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/MediumDao.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/MediumDao.kt @@ -44,7 +44,4 @@ interface MediumDao { @Query("DELETE FROM media WHERE deleted_ts != 0") fun clearRecycleBin() - - @Query("UPDATE media SET is_favorite = 0") - fun clearFavorites() } From 3ca8e685b81a21efb3f3c0d11bec1060fc1682e8 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 25 Jan 2020 10:56:08 +0100 Subject: [PATCH 07/36] shortening some code related to getting DAOs --- .../gallery/pro/activities/MainActivity.kt | 36 +++++-------- .../gallery/pro/activities/MediaActivity.kt | 26 ++++----- .../gallery/pro/activities/SearchActivity.kt | 4 +- .../pro/activities/SettingsActivity.kt | 7 +-- .../pro/activities/ViewPagerActivity.kt | 5 +- .../pro/activities/WidgetConfigureActivity.kt | 2 +- .../gallery/pro/adapters/DirectoryAdapter.kt | 2 +- .../gallery/pro/extensions/Activity.kt | 22 ++++---- .../gallery/pro/extensions/Context.kt | 53 +++++++++---------- .../gallery/pro/helpers/MediaFetcher.kt | 2 +- .../gallery/pro/helpers/MyWidgetProvider.kt | 4 +- 11 files changed, 69 insertions(+), 94 deletions(-) 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 1af9c13d0..7cad1ca04 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 @@ -36,9 +36,7 @@ import com.simplemobiletools.gallery.pro.dialogs.ChangeViewTypeDialog import com.simplemobiletools.gallery.pro.dialogs.FilterMediaDialog import com.simplemobiletools.gallery.pro.extensions.* import com.simplemobiletools.gallery.pro.helpers.* -import com.simplemobiletools.gallery.pro.interfaces.DirectoryDao import com.simplemobiletools.gallery.pro.interfaces.DirectoryOperationsListener -import com.simplemobiletools.gallery.pro.interfaces.MediumDao import com.simplemobiletools.gallery.pro.jobs.NewPhotoFetcher import com.simplemobiletools.gallery.pro.models.Directory import com.simplemobiletools.gallery.pro.models.Medium @@ -85,17 +83,11 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { private var mStoredTextColor = 0 private var mStoredPrimaryColor = 0 - private lateinit var mMediumDao: MediumDao - private lateinit var mDirectoryDao: DirectoryDao - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) appLaunched(BuildConfig.APPLICATION_ID) - mMediumDao = galleryDB.MediumDao() - mDirectoryDao = galleryDB.DirectoryDao() - if (savedInstanceState == null) { config.temporarilyShowHidden = false config.tempSkipDeleteConfirmation = false @@ -464,7 +456,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { val getImagesOnly = mIsPickImageIntent || mIsGetImageContentIntent val getVideosOnly = mIsPickVideoIntent || mIsGetVideoContentIntent - getCachedDirectories(getVideosOnly, getImagesOnly, mDirectoryDao) { + getCachedDirectories(getVideosOnly, getImagesOnly) { gotDirectories(addTempFolderIfNeeded(it)) } } @@ -569,7 +561,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { val pathsToDelete = ArrayList() itemsToDelete.mapTo(pathsToDelete) { it.path } - movePathsInRecycleBin(pathsToDelete, mMediumDao) { + movePathsInRecycleBin(pathsToDelete) { if (it) { deleteFilteredFileDirItems(itemsToDelete, folders) } else { @@ -590,7 +582,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { ensureBackgroundThread { folders.filter { !getDoesFilePathExist(it.absolutePath, OTGPath) }.forEach { - mDirectoryDao.deleteDirPath(it.absolutePath) + directoryDao.deleteDirPath(it.absolutePath) } if (config.deleteEmptyFolders) { @@ -936,16 +928,16 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { setupAdapter(dirs) // update directories and media files in the local db, delete invalid items - updateDBDirectory(directory, mDirectoryDao) + updateDBDirectory(directory) if (!directory.isRecycleBin()) { - mMediumDao.insertAll(curMedia) + mediaDB.insertAll(curMedia) } - getCachedMedia(directory.path, getVideosOnly, getImagesOnly, mMediumDao) { + getCachedMedia(directory.path, getVideosOnly, getImagesOnly) { it.forEach { if (!curMedia.contains(it)) { val path = (it as? Medium)?.path if (path != null) { - deleteDBPath(mMediumDao, path) + deleteDBPath(path) } } } @@ -955,7 +947,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { if (dirPathsToRemove.isNotEmpty()) { val dirsToRemove = dirs.filter { dirPathsToRemove.contains(it.path) } dirsToRemove.forEach { - mDirectoryDao.deleteDirPath(it.path) + directoryDao.deleteDirPath(it.path) } dirs.removeAll(dirsToRemove) setupAdapter(dirs) @@ -999,9 +991,9 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { dirs.add(newDir) setupAdapter(dirs) try { - mDirectoryDao.insert(newDir) + directoryDao.insert(newDir) if (folder != RECYCLE_BIN) { - mMediumDao.insertAll(newMedia) + mediaDB.insertAll(newMedia) } } catch (ignored: Exception) { } @@ -1156,7 +1148,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { if (config.useRecycleBin) { try { val binFolder = dirs.firstOrNull { it.path == RECYCLE_BIN } - if (binFolder != null && mMediumDao.getDeletedMedia().isEmpty()) { + if (binFolder != null && mediaDB.getDeletedMedia().isEmpty()) { invalidDirs.add(binFolder) } } catch (ignored: Exception) { @@ -1168,7 +1160,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { setupAdapter(dirs) invalidDirs.forEach { try { - mDirectoryDao.deleteDirPath(it.path) + directoryDao.deleteDirPath(it.path) } catch (ignored: Exception) { } } @@ -1218,7 +1210,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { Handler().postDelayed({ ensureBackgroundThread { try { - mMediumDao.deleteOldRecycleBinItems(System.currentTimeMillis() - MONTH_MILLISECONDS) + mediaDB.deleteOldRecycleBinItems(System.currentTimeMillis() - MONTH_MILLISECONDS) } catch (e: Exception) { } } @@ -1283,7 +1275,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { override fun updateDirectories(directories: ArrayList) { ensureBackgroundThread { - storeDirectoryItems(directories, mDirectoryDao) + storeDirectoryItems(directories) removeInvalidDBDirectories() } } 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 6aa7d5fcd..7f05afad3 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 @@ -39,9 +39,7 @@ import com.simplemobiletools.gallery.pro.databases.GalleryDatabase import com.simplemobiletools.gallery.pro.dialogs.* import com.simplemobiletools.gallery.pro.extensions.* import com.simplemobiletools.gallery.pro.helpers.* -import com.simplemobiletools.gallery.pro.interfaces.DirectoryDao import com.simplemobiletools.gallery.pro.interfaces.MediaOperationsListener -import com.simplemobiletools.gallery.pro.interfaces.MediumDao import com.simplemobiletools.gallery.pro.models.Medium import com.simplemobiletools.gallery.pro.models.ThumbnailItem import com.simplemobiletools.gallery.pro.models.ThumbnailSection @@ -78,9 +76,6 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { private var mStoredTextColor = 0 private var mStoredPrimaryColor = 0 - private lateinit var mMediumDao: MediumDao - private lateinit var mDirectoryDao: DirectoryDao - companion object { var mMedia = ArrayList() } @@ -89,9 +84,6 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { super.onCreate(savedInstanceState) setContentView(R.layout.activity_media) - mMediumDao = galleryDB.MediumDao() - mDirectoryDao = galleryDB.DirectoryDao() - intent.apply { mIsGetImageIntent = getBooleanExtra(GET_IMAGE_INTENT, false) mIsGetVideoIntent = getBooleanExtra(GET_VIDEO_INTENT, false) @@ -495,9 +487,9 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { private fun restoreAllFiles() { val paths = mMedia.filter { it is Medium }.map { (it as Medium).path } as ArrayList - restoreRecycleBinPaths(paths, mMediumDao) { + restoreRecycleBinPaths(paths) { ensureBackgroundThread { - mDirectoryDao.deleteDirPath(RECYCLE_BIN) + directoryDao.deleteDirPath(RECYCLE_BIN) } finish() } @@ -584,7 +576,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { if (mLoadedInitialPhotos) { startAsyncTask() } else { - getCachedMedia(mPath, mIsGetVideoIntent, mIsGetImageIntent, mMediumDao) { + getCachedMedia(mPath, mIsGetVideoIntent, mIsGetImageIntent) { if (it.isEmpty()) { runOnUiThread { media_refresh_layout.isRefreshing = true @@ -608,7 +600,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { try { gotMedia(newMedia, false) oldMedia.filter { !newMedia.contains(it) }.mapNotNull { it as? Medium }.filter { !getDoesFilePathExist(it.path) }.forEach { - mMediumDao.deleteMediumPath(it.path) + mediaDB.deleteMediumPath(it.path) } } catch (e: Exception) { } @@ -627,7 +619,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { if (mPath == FAVORITES) { ensureBackgroundThread { - mDirectoryDao.deleteDirPath(FAVORITES) + directoryDao.deleteDirPath(FAVORITES) } } @@ -641,7 +633,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { private fun deleteDBDirectory() { ensureBackgroundThread { try { - mDirectoryDao.deleteDirPath(mPath) + directoryDao.deleteDirPath(mPath) } catch (ignored: Exception) { } } @@ -897,7 +889,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { if (!isFromCache) { val mediaToInsert = (mMedia).filter { it is Medium && it.deletedTS == 0L }.map { it as Medium } try { - mMediumDao.insertAll(mediaToInsert) + mediaDB.insertAll(mediaToInsert) } catch (e: Exception) { } } @@ -913,7 +905,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { val movingItems = resources.getQuantityString(R.plurals.moving_items_into_bin, filtered.size, filtered.size) toast(movingItems) - movePathsInRecycleBin(filtered.map { it.path } as ArrayList, mMediumDao) { + movePathsInRecycleBin(filtered.map { it.path } as ArrayList) { if (it) { deleteFilteredFiles(filtered) } else { @@ -940,7 +932,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { val useRecycleBin = config.useRecycleBin filtered.forEach { if (it.path.startsWith(recycleBinPath) || !useRecycleBin) { - deleteDBPath(mMediumDao, it.path) + deleteDBPath(it.path) } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SearchActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SearchActivity.kt index 0febbfd0b..2ef59a3bc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SearchActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SearchActivity.kt @@ -315,7 +315,7 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener { val movingItems = resources.getQuantityString(R.plurals.moving_items_into_bin, filtered.size, filtered.size) toast(movingItems) - movePathsInRecycleBin(filtered.map { it.path } as ArrayList, galleryDB.MediumDao()) { + movePathsInRecycleBin(filtered.map { it.path } as ArrayList) { if (it) { deleteFilteredFiles(filtered) } else { @@ -342,7 +342,7 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener { val useRecycleBin = config.useRecycleBin filtered.forEach { if (it.path.startsWith(recycleBinPath) || !useRecycleBin) { - deleteDBPath(galleryDB.MediumDao(), it.path) + deleteDBPath(it.path) } } } 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 0be79e7fe..50133ccf5 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 @@ -13,10 +13,7 @@ import com.simplemobiletools.commons.models.RadioItem import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.dialogs.ManageBottomActionsDialog import com.simplemobiletools.gallery.pro.dialogs.ManageExtendedDetailsDialog -import com.simplemobiletools.gallery.pro.extensions.config -import com.simplemobiletools.gallery.pro.extensions.emptyTheRecycleBin -import com.simplemobiletools.gallery.pro.extensions.galleryDB -import com.simplemobiletools.gallery.pro.extensions.showRecycleBinEmptyingDialog +import com.simplemobiletools.gallery.pro.extensions.* import com.simplemobiletools.gallery.pro.helpers.* import com.simplemobiletools.gallery.pro.models.AlbumCover import kotlinx.android.synthetic.main.activity_settings.* @@ -593,7 +590,7 @@ class SettingsActivity : SimpleActivity() { private fun setupEmptyRecycleBin() { ensureBackgroundThread { try { - mRecycleBinContentSize = galleryDB.MediumDao().getDeletedMedia().sumByLong { it.size } + mRecycleBinContentSize = mediaDB.getDeletedMedia().sumByLong { it.size } } catch (ignored: Exception) { } runOnUiThread { 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 4ffb2d73d..089d3da5d 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 @@ -364,8 +364,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View if (intent.action == "com.android.camera.action.REVIEW") { ensureBackgroundThread { - val mediumDao = galleryDB.MediumDao() - if (mediumDao.getMediaFromPath(mPath).isEmpty()) { + if (mediaDB.getMediaFromPath(mPath).isEmpty()) { val type = when { mPath.isVideoFast() -> TYPE_VIDEOS mPath.isGif() -> TYPE_GIFS @@ -379,7 +378,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View val duration = if (type == TYPE_VIDEOS) mPath.getVideoDuration() else 0 val ts = System.currentTimeMillis() val medium = Medium(null, mPath.getFilenameFromPath(), mPath, mPath.getParentPath(), ts, ts, File(mPath).length(), type, duration, isFavorite, 0) - mediumDao.insert(medium) + mediaDB.insert(medium) } } } 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 d2e1696bb..3f0c66912 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 @@ -163,7 +163,7 @@ class WidgetConfigureActivity : SimpleActivity() { } ensureBackgroundThread { - val path = directoryDB.getDirectoryThumbnail(folderPath) + val path = directoryDao.getDirectoryThumbnail(folderPath) if (path != null) { runOnUiThread { loadJpg(path, config_image, config.cropThumbnails) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt index a70362d67..84113cfa9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt @@ -198,7 +198,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList, mediumDao: MediumDao = galleryDB.MediumDao(), callback: ((wasSuccess: Boolean) -> Unit)?) { +fun BaseSimpleActivity.movePathsInRecycleBin(paths: ArrayList, callback: ((wasSuccess: Boolean) -> Unit)?) { ensureBackgroundThread { var pathsCnt = paths.size val OTGPath = config.OTGPath @@ -261,7 +260,7 @@ fun BaseSimpleActivity.movePathsInRecycleBin(paths: ArrayList, mediumDao out?.flush() if (fileDocument?.getItemSize(true) == copiedSize && getDoesFilePathExist(destination)) { - mediumDao.updateDeleted("$RECYCLE_BIN$source", System.currentTimeMillis(), source) + mediaDB.updateDeleted("$RECYCLE_BIN$source", System.currentTimeMillis(), source) pathsCnt-- } } catch (e: Exception) { @@ -277,7 +276,7 @@ fun BaseSimpleActivity.movePathsInRecycleBin(paths: ArrayList, mediumDao val lastModified = file.lastModified() try { if (file.copyRecursively(internalFile, true)) { - mediumDao.updateDeleted("$RECYCLE_BIN$source", System.currentTimeMillis(), source) + mediaDB.updateDeleted("$RECYCLE_BIN$source", System.currentTimeMillis(), source) pathsCnt-- if (config.keepLastModified) { @@ -295,10 +294,10 @@ fun BaseSimpleActivity.movePathsInRecycleBin(paths: ArrayList, mediumDao } fun BaseSimpleActivity.restoreRecycleBinPath(path: String, callback: () -> Unit) { - restoreRecycleBinPaths(arrayListOf(path), galleryDB.MediumDao(), callback) + restoreRecycleBinPaths(arrayListOf(path), callback) } -fun BaseSimpleActivity.restoreRecycleBinPaths(paths: ArrayList, mediumDao: MediumDao = galleryDB.MediumDao(), callback: () -> Unit) { +fun BaseSimpleActivity.restoreRecycleBinPaths(paths: ArrayList, callback: () -> Unit) { ensureBackgroundThread { val newPaths = ArrayList() for (source in paths) { @@ -328,7 +327,7 @@ fun BaseSimpleActivity.restoreRecycleBinPaths(paths: ArrayList, mediumDa out?.flush() if (File(source).length() == copiedSize) { - mediumDao.updateDeleted(destination.removePrefix(recycleBinPath), 0, "$RECYCLE_BIN$destination") + mediaDB.updateDeleted(destination.removePrefix(recycleBinPath), 0, "$RECYCLE_BIN$destination") } newPaths.add(destination) @@ -357,8 +356,8 @@ fun BaseSimpleActivity.emptyTheRecycleBin(callback: (() -> Unit)? = null) { ensureBackgroundThread { try { recycleBin.deleteRecursively() - galleryDB.MediumDao().clearRecycleBin() - galleryDB.DirectoryDao().deleteRecycleBin() + mediaDB.clearRecycleBin() + directoryDao.deleteRecycleBin() toast(R.string.recycle_bin_emptied) callback?.invoke() } catch (e: Exception) { @@ -413,7 +412,6 @@ fun Activity.fixDateTaken(paths: ArrayList, showToasts: Boolean, hasResc try { var didUpdateFile = false val operations = ArrayList() - val mediumDao = galleryDB.MediumDao() ensureBackgroundThread { for (path in paths) { @@ -442,7 +440,7 @@ fun Activity.fixDateTaken(paths: ArrayList, showToasts: Boolean, hasResc operations.clear() } - mediumDao.updateFavoriteDateTaken(path, timestamp) + mediaDB.updateFavoriteDateTaken(path, timestamp) didUpdateFile = true if (!hasRescanned && getFileDateTaken(path) == 0L) { 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 8b3574847..31c37b75a 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 @@ -111,11 +111,11 @@ fun Context.launchSettings() { val Context.config: Config get() = Config.newInstance(applicationContext) -val Context.galleryDB: GalleryDatabase get() = GalleryDatabase.getInstance(applicationContext) - val Context.widgetsDB: WidgetsDao get() = GalleryDatabase.getInstance(applicationContext).WidgetsDao() -val Context.directoryDB: DirectoryDao get() = GalleryDatabase.getInstance(applicationContext).DirectoryDao() +val Context.mediaDB: MediumDao get() = GalleryDatabase.getInstance(applicationContext).MediumDao() + +val Context.directoryDao: DirectoryDao get() = GalleryDatabase.getInstance(applicationContext).DirectoryDao() val Context.favoritesDB: FavoritesDao get() = GalleryDatabase.getInstance(applicationContext).FavoritesDao() @@ -400,16 +400,15 @@ fun Context.rescanFolderMediaSync(path: String) { GetMediaAsynctask(applicationContext, path, false, false, false) { ensureBackgroundThread { val newMedia = it - val mediumDao = galleryDB.MediumDao() val media = newMedia.filter { it is Medium } as ArrayList try { - mediumDao.insertAll(media) + mediaDB.insertAll(media) cached.forEach { if (!newMedia.contains(it)) { val mediumPath = (it as? Medium)?.path if (mediumPath != null) { - deleteDBPath(mediumDao, mediumPath) + deleteDBPath(mediumPath) } } } @@ -420,7 +419,7 @@ fun Context.rescanFolderMediaSync(path: String) { } } -fun Context.storeDirectoryItems(items: ArrayList, directoryDao: DirectoryDao) { +fun Context.storeDirectoryItems(items: ArrayList) { ensureBackgroundThread { directoryDao.insertAll(items) } @@ -559,7 +558,7 @@ fun Context.loadSVG(path: String, target: MySquareImageView, cropThumbnails: Boo .into(target) } -fun Context.getCachedDirectories(getVideosOnly: Boolean = false, getImagesOnly: Boolean = false, directoryDao: DirectoryDao = galleryDB.DirectoryDao(), forceShowHidden: Boolean = false, callback: (ArrayList) -> Unit) { +fun Context.getCachedDirectories(getVideosOnly: Boolean = false, getImagesOnly: Boolean = false, forceShowHidden: Boolean = false, callback: (ArrayList) -> Unit) { ensureBackgroundThread { val directories = try { directoryDao.getAll() as ArrayList @@ -602,22 +601,21 @@ fun Context.getCachedDirectories(getVideosOnly: Boolean = false, getImagesOnly: val clone = filteredDirectories.clone() as ArrayList callback(clone.distinctBy { it.path.getDistinctPath() } as ArrayList) - removeInvalidDBDirectories(filteredDirectories, directoryDao) + removeInvalidDBDirectories(filteredDirectories) } } -fun Context.getCachedMedia(path: String, getVideosOnly: Boolean = false, getImagesOnly: Boolean = false, mediumDao: MediumDao = galleryDB.MediumDao(), - callback: (ArrayList) -> Unit) { +fun Context.getCachedMedia(path: String, getVideosOnly: Boolean = false, getImagesOnly: Boolean = false, callback: (ArrayList) -> Unit) { ensureBackgroundThread { val mediaFetcher = MediaFetcher(this) val foldersToScan = if (path.isEmpty()) mediaFetcher.getFoldersToScan() else arrayListOf(path) var media = ArrayList() if (path == FAVORITES) { - media.addAll(mediumDao.getFavorites()) + media.addAll(mediaDB.getFavorites()) } if (path == RECYCLE_BIN) { - media.addAll(getUpdatedDeletedMedia(mediumDao)) + media.addAll(getUpdatedDeletedMedia()) } if (config.filterMedia and TYPE_PORTRAITS != 0) { @@ -634,7 +632,7 @@ fun Context.getCachedMedia(path: String, getVideosOnly: Boolean = false, getImag val shouldShowHidden = config.shouldShowHidden foldersToScan.filter { path.isNotEmpty() || !config.isFolderProtected(it) }.forEach { try { - val currMedia = mediumDao.getMediaFromPath(it) + val currMedia = mediaDB.getMediaFromPath(it) media.addAll(currMedia) } catch (ignored: Exception) { } @@ -667,7 +665,7 @@ fun Context.getCachedMedia(path: String, getVideosOnly: Boolean = false, getImag val mediaToDelete = ArrayList() media.filter { !getDoesFilePathExist(it.path, OTGPath) }.forEach { if (it.path.startsWith(recycleBinPath)) { - deleteDBPath(mediumDao, it.path) + deleteDBPath(it.path) } else { mediaToDelete.add(it) } @@ -675,14 +673,14 @@ fun Context.getCachedMedia(path: String, getVideosOnly: Boolean = false, getImag try { if (mediaToDelete.isNotEmpty()) { - mediumDao.deleteMedia(*mediaToDelete.toTypedArray()) + mediaDB.deleteMedia(*mediaToDelete.toTypedArray()) } } catch (ignored: Exception) { } } } -fun Context.removeInvalidDBDirectories(dirs: ArrayList? = null, directoryDao: DirectoryDao = galleryDB.DirectoryDao()) { +fun Context.removeInvalidDBDirectories(dirs: ArrayList? = null) { val dirsToCheck = dirs ?: directoryDao.getAll() val OTGPath = config.OTGPath dirsToCheck.filter { !it.areFavorites() && !it.isRecycleBin() && !getDoesFilePathExist(it.path, OTGPath) && it.path != config.tempFolderPath }.forEach { @@ -697,12 +695,12 @@ fun Context.updateDBMediaPath(oldPath: String, newPath: String) { val newFilename = newPath.getFilenameFromPath() val newParentPath = newPath.getParentPath() try { - galleryDB.MediumDao().updateMedium(oldPath, newParentPath, newFilename, newPath) + mediaDB.updateMedium(oldPath, newParentPath, newFilename, newPath) } catch (ignored: Exception) { } } -fun Context.updateDBDirectory(directory: Directory, directoryDao: DirectoryDao) { +fun Context.updateDBDirectory(directory: Directory) { try { directoryDao.updateDirectory(directory.path, directory.tmb, directory.mediaCnt, directory.modified, directory.taken, directory.size, directory.types) } catch (ignored: Exception) { @@ -732,9 +730,9 @@ fun Context.updateFavorite(path: String, isFavorite: Boolean) { } // remove the "recycle_bin" from the file path prefix, replace it with real bin path /data/user... -fun Context.getUpdatedDeletedMedia(mediumDao: MediumDao): ArrayList { +fun Context.getUpdatedDeletedMedia(): ArrayList { val media = try { - mediumDao.getDeletedMedia() as ArrayList + mediaDB.getDeletedMedia() as ArrayList } catch (ignored: Exception) { ArrayList() } @@ -745,13 +743,13 @@ fun Context.getUpdatedDeletedMedia(mediumDao: MediumDao): ArrayList { return media } -fun Context.deleteDBPath(mediumDao: MediumDao, path: String) { - deleteMediumWithPath(mediumDao, path.replaceFirst(recycleBinPath, RECYCLE_BIN)) +fun Context.deleteDBPath(path: String) { + deleteMediumWithPath(path.replaceFirst(recycleBinPath, RECYCLE_BIN)) } -fun Context.deleteMediumWithPath(mediumDao: MediumDao, path: String) { +fun Context.deleteMediumWithPath(path: String) { try { - mediumDao.deleteMediumPath(path) + mediaDB.deleteMediumPath(path) favoritesDB.deleteFavoritePath(path) } catch (ignored: Exception) { } @@ -841,13 +839,12 @@ fun Context.addPathToDB(path: String) { } try { - val mediumDao = galleryDB.MediumDao() val isFavorite = favoritesDB.isFavorite(path) val videoDuration = if (type == TYPE_VIDEOS) path.getVideoDuration() else 0 val medium = Medium(null, path.getFilenameFromPath(), path, path.getParentPath(), System.currentTimeMillis(), System.currentTimeMillis(), File(path).length(), type, videoDuration, isFavorite, 0L) - mediumDao.insert(medium) + mediaDB.insert(medium) } catch (ignored: Exception) { } } @@ -891,7 +888,7 @@ fun Context.updateDirectoryPath(path: String) { val favoritePaths = getFavoritePaths() val curMedia = mediaFetcher.getFilesFrom(path, getImagesOnly, getVideosOnly, getProperDateTaken, getProperFileSize, favoritePaths, false) val directory = createDirectoryFromMedia(path, curMedia, albumCovers, hiddenString, includedFolders, isSortingAscending, getProperFileSize) - updateDBDirectory(directory, galleryDB.DirectoryDao()) + updateDBDirectory(directory) } fun Context.getFileDateTaken(path: String): Long { 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 8b625e5e5..6a4db386a 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 @@ -216,7 +216,7 @@ class MediaFetcher(val context: Context) { val media = ArrayList() val isRecycleBin = folder == RECYCLE_BIN val deletedMedia = if (isRecycleBin) { - context.getUpdatedDeletedMedia(context.galleryDB.MediumDao()) + context.getUpdatedDeletedMedia() } else { ArrayList() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MyWidgetProvider.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MyWidgetProvider.kt index 199d90952..f2e1b3d02 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MyWidgetProvider.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MyWidgetProvider.kt @@ -18,7 +18,7 @@ import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.activities.MediaActivity import com.simplemobiletools.gallery.pro.extensions.config -import com.simplemobiletools.gallery.pro.extensions.directoryDB +import com.simplemobiletools.gallery.pro.extensions.directoryDao import com.simplemobiletools.gallery.pro.extensions.getFolderNameFromPath import com.simplemobiletools.gallery.pro.extensions.widgetsDB import com.simplemobiletools.gallery.pro.models.Widget @@ -45,7 +45,7 @@ class MyWidgetProvider : AppWidgetProvider() { setText(R.id.widget_folder_name, context.getFolderNameFromPath(it.folderPath)) } - val path = context.directoryDB.getDirectoryThumbnail(it.folderPath) ?: return@forEach + val path = context.directoryDao.getDirectoryThumbnail(it.folderPath) ?: return@forEach val options = RequestOptions() .signature(path.getFileSignature()) .diskCacheStrategy(DiskCacheStrategy.RESOURCE) From e578036a227b22000d58814f32816cf852eed59e Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 25 Jan 2020 11:11:23 +0100 Subject: [PATCH 08/36] delete favorites at deleting media --- .../simplemobiletools/gallery/pro/extensions/Context.kt | 2 ++ .../gallery/pro/interfaces/FavoritesDao.kt | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) 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 31c37b75a..be0f31756 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 @@ -674,6 +674,8 @@ fun Context.getCachedMedia(path: String, getVideosOnly: Boolean = false, getImag try { if (mediaToDelete.isNotEmpty()) { mediaDB.deleteMedia(*mediaToDelete.toTypedArray()) + val favorites = mediaToDelete.map { getFavoriteFromPath(it.path) } + favoritesDB.deleteFavorites(*favorites.toTypedArray()) } } catch (ignored: Exception) { } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDao.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDao.kt index d835d9f65..8a890e20a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDao.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDao.kt @@ -1,9 +1,6 @@ package com.simplemobiletools.gallery.pro.interfaces -import androidx.room.Dao -import androidx.room.Insert -import androidx.room.OnConflictStrategy -import androidx.room.Query +import androidx.room.* import com.simplemobiletools.gallery.pro.models.Favorite @Dao @@ -23,6 +20,9 @@ interface FavoritesDao { @Query("SELECT id FROM favorites WHERE full_path = :path COLLATE NOCASE") fun isFavorite(path: String): Boolean + @Delete + fun deleteFavorites(vararg favorite: Favorite) + @Query("DELETE FROM favorites WHERE full_path = :path COLLATE NOCASE") fun deleteFavoritePath(path: String) From 29a521d107859e7c66f21043d5abe0b2f57bf334 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 25 Jan 2020 11:50:09 +0100 Subject: [PATCH 09/36] update Favorite too at updating a medium --- .../com/simplemobiletools/gallery/pro/extensions/Context.kt | 3 ++- .../simplemobiletools/gallery/pro/interfaces/FavoritesDao.kt | 3 +++ .../com/simplemobiletools/gallery/pro/interfaces/MediumDao.kt | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) 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 be0f31756..7e69583e8 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 @@ -697,7 +697,8 @@ fun Context.updateDBMediaPath(oldPath: String, newPath: String) { val newFilename = newPath.getFilenameFromPath() val newParentPath = newPath.getParentPath() try { - mediaDB.updateMedium(oldPath, newParentPath, newFilename, newPath) + mediaDB.updateMedium(newFilename, newPath, newParentPath, oldPath) + favoritesDB.updateFavorite(newFilename, newPath, newParentPath, oldPath) } catch (ignored: Exception) { } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDao.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDao.kt index 8a890e20a..52056cb7e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDao.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDao.kt @@ -20,6 +20,9 @@ interface FavoritesDao { @Query("SELECT id FROM favorites WHERE full_path = :path COLLATE NOCASE") fun isFavorite(path: String): Boolean + @Query("UPDATE OR REPLACE favorites SET filename = :newFilename, full_path = :newFullPath, parent_path = :newParentPath WHERE full_path = :oldPath COLLATE NOCASE") + fun updateFavorite(newFilename: String, newFullPath: String, newParentPath: String, oldPath: String) + @Delete fun deleteFavorites(vararg favorite: Favorite) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/MediumDao.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/MediumDao.kt index ec0a8befc..8552256de 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/MediumDao.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/MediumDao.kt @@ -34,7 +34,7 @@ interface MediumDao { fun deleteOldRecycleBinItems(timestmap: Long) @Query("UPDATE OR REPLACE media SET filename = :newFilename, full_path = :newFullPath, parent_path = :newParentPath WHERE full_path = :oldPath COLLATE NOCASE") - fun updateMedium(oldPath: String, newParentPath: String, newFilename: String, newFullPath: String) + fun updateMedium(newFilename: String, newFullPath: String, newParentPath: String, oldPath: String) @Query("UPDATE OR REPLACE media SET full_path = :newPath, deleted_ts = :deletedTS WHERE full_path = :oldPath COLLATE NOCASE") fun updateDeleted(newPath: String, deletedTS: Long, oldPath: String) From 9607348b5029241bde31ba8a8c2d7ace49076f19 Mon Sep 17 00:00:00 2001 From: herkul-s <58790982+herkul-s@users.noreply.github.com> Date: Sat, 25 Jan 2020 18:43:41 +0100 Subject: [PATCH 10/36] updating czech strings --- app/src/main/res/values-cs/strings.xml | 44 +++++++++++++------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 2e17b6791..100e451e2 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -32,7 +32,7 @@ Opravuji… Datumy byly úspěšně opraveny Sdílet verzi se změněnou velikostí - Zdravím,\n\nzdá se, že jse přešli ze staré bezplatné aplikace. Starou aplikaci, která má nahoře v nastavení tlačítko \'Stáhnout Pro verzi\', můžete již odinstalovat.\n\nZtratíte tím pouze soubory v odpadkovém koši, označení oblíbených souborů a také budete muset znovu nastavit položky v nastavení aplikace.\n\nDěkuji! + Zdravím,\n\nzdá se, že jste přešli ze staré bezplatné aplikace. Starou aplikaci, která má nahoře v nastavení tlačítko \'Stáhnout Pro verzi\', můžete již odinstalovat.\n\nZtratíte tím pouze soubory v odpadkovém koši, označení oblíbených souborů a také budete muset znovu nastavit položky v nastavení aplikace.\n\nDěkuji! Přepnout na vyhledávání souborů ve všech viditelných složkách @@ -43,7 +43,7 @@ RAW obrázky SVGčka Portréty - Se zvolenými filtry nebyly nalezeny žádné médiální soubory. + Se zvolenými filtry nebyly nalezeny žádné mediální soubory. Změnit filtry @@ -53,7 +53,7 @@ Spravovat vyloučené složky Tato funkce vyloučí výběr včetně podsložek jen z Jednoduché galerie. V nastavení můžete spravovat vyloučené složky. Chcete vyloučit nadřazenou složku? - Vyloučené složky budou spolu s podsložkami vyloučeny jen z Jednoduché Galerie, ostatní aplikace je nadále uvidí.\n\nPokud je chcete skrýt i před ostatními aplikacemi, použijte funkci Skrýt. + Vyloučené složky budou spolu s podsložkami vyloučeny jen z Jednoduché galerie, ostatní aplikace je nadále uvidí.\n\nPokud je chcete skrýt i před ostatními aplikacemi, použijte funkci Skrýt. Odstranit všechny Odstranit všechny složky ze seznamu vyloučených? Tato operace neodstraní obsah složek. Skryté složky @@ -111,7 +111,7 @@ Prezentace - Interval (vteřin): + Interval (sekund): Zahrnout fotografie Zahrnout videa Zahrnout GIFy @@ -169,10 +169,10 @@ Povolit ovládání jasu vertikálními tahy Povolit ovládání hlasitosti a jasu videí vertikálními tahy Zobrazit počet médií ve složce na hlavní obrazovce - Zobrazit rozšířené vlastnosti přes celoobrazovkové média + Zobrazit rozšířené vlastnosti přes celoobrazovková média Spravovat rozšířené vlastnosti Povolit přibližování jedním prstem v celoobrazovkovém režimu - Povolit okamžité přepínání médií ťuknutím na okraj obrazovky + Povolit okamžité přepínání médií klepnutím na okraj obrazovky Povolit hluboké přibližování obrázků Skrýt rozšířené vlastnosti pokud je skrytá stavová lišta Zobrazit některá akční tlačítka ve spodní části obrazovky @@ -198,7 +198,7 @@ Spodní akční tlačítka - Upravit viditelné spodní akční tlačítka + Upravit viditelná spodní akční tlačítka Přepnutí oblíbenosti Přepnutí viditelnosti souboru @@ -284,17 +284,17 @@ Pipetovatelná barva - Jak nastavím Jednoduchou Galerii jako výchozí galerii? + Jak nastavím Jednoduchou galerii jako výchozí galerii? Nejdříve musíte najít v nastavení zařízení, v sekci Aplikace, současnou výchozí galerii, zvolit tlačítko s textem ve smyslu \"Nastavení výchozího otevírání\" a následně \"Vymazat výchozí nastavení\". - Pokud poté zkusíte otevřít obrázek nebo video, zobrazí se seznam aplikací, kde můžete zvolit Jednoduchou Galerii a nastavit ji jako výchozí. + Pokud poté zkusíte otevřít obrázek nebo video, zobrazí se seznam aplikací, kde můžete zvolit Jednoduchou galerii a nastavit ji jako výchozí. Uzamknul jsem aplikaci heslem, ale zapomněl jsem ho. Co můžu udělat? - Můžete to vyriešǐť 2 způsoby. Můžete aplikaci buď přeinstalovat nebo ji najít v nastavení zařízení a zvolit \"Vymazat data\". Vymažou se pouze nastavení aplikace, nikoliv soubory. + Můžete to vyriešit 2 způsoby. Můžete aplikaci buď přeinstalovat nebo ji najít v nastavení zařízení a zvolit \"Vymazat data\". Vymažou se pouze nastavení aplikace, nikoliv soubory. Jak mohu dosáhnout, aby bylo dané album stále zobrazeno jako první? - Můžete označit danou složku dlouhým podržením a zvolit tlačítko s obrázkem připínáčku, to ji připne na vrch. Můžete připnout i více složek, budou seřazeny podle zvoleného řazení. + Můžete označit danou složku dlouhým podržením a zvolit tlačítko s obrázkem připínáčku, to ji připne nahoru. Můžete připnout i více složek, budou seřazeny podle zvoleného řazení. Jak mohu video posunout vpřed? - Můžete toho dosáhnout buď tažením prstu vodorovně přes okno přehrávače nebo ťuknutím na text aktuální či celkové délky videa, které najdete po bocích indikátoru aktuální pozice. To posune video buď zpět nebo vpřed. + Můžete toho dosáhnout buď tažením prstu vodorovně přes okno přehrávače nebo klepnutím na text aktuální či celkové délky videa, který najdete po bocích indikátoru aktuální pozice. To posune video buď zpět nebo vpřed. Jaký je rozdíl mezi Skrytím a Vyloučením složky? - Zatímco vyloučení zamezí zobrazení složky pouze vrámci Jednoduché Galerie, skrytí ji ukryje vrámci celého systému, tedy to ovlivní i ostatní galerie. Skrytí funguje pomocí vytvoření prázdného souboru \".nomedia\" v daném adresáři, který můžete vymazat i libovolným správcem souborů. + Zatímco vyloučení zamezí zobrazení složky pouze vrámci Jednoduché galerie, skrytí ji ukryje v celém systému, tedy to ovlivní i ostatní galerie. Skrytí funguje pomocí vytvoření prázdného souboru \".nomedia\" v daném adresáři, který můžete vymazat i libovolným správcem souborů. Proč se mi zobrazují složky s obaly hudebních alb, nebo nálepkami? Může se stát, že se vám zobrazí také neobvyklé složky. Můžete je ale jednoduše skrýt jejich vybráním pomocí dlouhého podržení a zvolením Vyloučit. Pokud na následujícím dialogu zvolíte vyloučení nadřazené složky, pravděpodobně budou vyloučeny i ostatní podobné složky. Složka s fotografiemi se mi nezobrazuje nebo ve složce nevidím všechny soubory. Co s tím? @@ -317,13 +317,13 @@ - Jednoduchá Galerie Pro - Organizér a editor fotografií + Jednoduchá galerie Pro - Organizér a editor fotografií - Browse your memories without any interruptions with this photo and video gallery + Prohlížejte svoje vzpomínky bez prerušení s touto foto a video galerií. - Jednoduchá Galerie Pro je vysoce přizpůsobitelná offline galerie. Organizujte a upravujte své fotografie, obnovujte smazané fotografie s funkcí odpadkového koše, chraňte je a skrývejte. Prohlížejte množství různých foto a video formátů včetně RAW, SVG a mnoho dalších. + Jednoduchá galerie Pro je vysoce přizpůsobitelná offline galerie. Organizujte a upravujte své fotografie, obnovujte smazané fotografie s funkcí odpadkového koše, chraňte je a skrývejte. Prohlížejte množství různých foto a video formátů včetně RAW, SVG a mnoho dalších. - Aplikace neobsahuje žádné reklamy ani nepotřebná oprávnění. Tím, že ani nevyžaduje připojení k internetu je vaše soukromí maximálně chráněno. + Aplikace neobsahuje žádné reklamy ani nepotřebná oprávnění. Tím, že ani nevyžaduje připojení k internetu, je vaše soukromí maximálně chráněno. ------------------------------------------------- JEDNODUCHÁ GALERIE PRO – FUNKCE @@ -337,7 +337,7 @@ • Otevírejte mnoho rozličných formátů fotografií a videí (RAW, SVG, GIF, panorama, atd) • Množství intuitivních gest pro jednoduchou úpravu a organizaci souborů • Mnoho různých způsobů filtrování, seskupování a řazení souborů - • Změňte si vzhled Jednoduché galerie pro + • Změňte si vzhled Jednoduché galerie Pro • Dostupná ve 32 jazycích • Označte si oblíbené soubory pro rychlý přístup • Chraňte své fotografie a videa pomocí pinu, vzoru nebo otiskem prstu @@ -350,16 +350,16 @@ … a mnoho dalších! EDITOR OBRÁZKŮ - Jednoduchá Galerie Pro umožňuje snadnou úpravu obrázků. Ořezávejte, překlápějte, otáčejte či měňte jejich velikost. Pokud se cítíte kreativně, můžete také aplikovat filtry nebo do obrázku kreslit! + Jednoduchá galerie Pro umožňuje snadnou úpravu obrázků. Ořezávejte, překlápějte, otáčejte či měňte jejich velikost. Pokud se cítíte kreativně, můžete také aplikovat filtry nebo do obrázku kreslit! PODPORA MNOHA TYPŮ SOUBORŮ - Na rozdíl od některých galerií podporuje Jednoduchá Galerie Pro velké množství různých druhů souborů včetně JPEG, PNG, MP4, MKV, RAW, SVG, panoramatických fotografií a videí. + Na rozdíl od některých galerií podporuje Jednoduchá galerie Pro velké množství různých druhů souborů včetně JPEG, PNG, MP4, MKV, RAW, SVG, panoramatických fotografií a videí. Vysoce upravitelný správce galerie - Od vzhledu až po funkční tlačítka na spodní liště, Jednoduchá Galerie Pro je plně nastavitelná a bude fungovat přesně jak si budete přát. Žádná jiná galerie nenabízí takovou flexibilitu! A díky otevřenému kódu je naše aplikace dostupná ve 32 jazycích! + Od vzhledu až po funkční tlačítka na spodní liště, Jednoduchá galerie Pro je plně nastavitelná a bude fungovat přesně jak si budete přát. Žádná jiná galerie nenabízí takovou flexibilitu! A díky otevřenému kódu je naše aplikace dostupná ve 32 jazycích! OBNOVTE SMAZANÉ FOTOGRAFIE A VIDEA - Smazali jste nechtěně důležitou fotografii nebo video? Žádný strach! Jednoduchá Galerie Pro pro podobné případy nabízí funkci odpadkového koše, odkud smazané fotografie a videa snadno obnovíte. + Smazali jste nechtěně důležitou fotografii nebo video? Žádný strach! Jednoduchá galerie Pro pro podobné případy nabízí funkci odpadkového koše, odkud smazané fotografie a videa snadno obnovíte. CHRAŇTE A SKRÝVEJTE SVÉ FOTOGRAFIE A VIDEA Použitím pinu, vzoru nebo otisku prstu snadno své fotografie, videa či celá alba ochráníte nebo skryjete. Můžete ochránit i spuštění samotné aplikace, nebo některé její funkce. Například můžete zabránit náhodnému smazání souboru bez potvrzení otiskem prstu. From ea187e117ee7dbee659cdbbdff82b2ffde976078 Mon Sep 17 00:00:00 2001 From: AioiLight Date: Sun, 26 Jan 2020 17:22:52 +0900 Subject: [PATCH 11/36] updating the app description from original language --- app/src/main/res/values-ja/strings.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 7b34fa90f..8aa0d66da 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -366,6 +366,9 @@ Check out the full suite of Simple Tools here: https://www.simplemobiletools.com + + Standalone website of Simple Gallery Pro: + https://www.simplemobiletools.com/gallery Facebook: https://www.facebook.com/simplemobiletools From fef507e16d83600331f1be570b777da84370407d Mon Sep 17 00:00:00 2001 From: AioiLight Date: Sun, 26 Jan 2020 17:56:16 +0900 Subject: [PATCH 12/36] updating Japanese translation(New editor strings) --- app/src/main/res/values-ja/strings.xml | 126 ++++++++++++------------- 1 file changed, 63 insertions(+), 63 deletions(-) diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 8aa0d66da..203820656 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -203,69 +203,69 @@ 表示/非表示の切替 - Custom - Reset - Square - Transform - Filter - None - Adjust - Shadows - Exposure - Highlights - Brightness - Contrast - Saturation - Clarity - Gamma - Blacks - Whites - Temperature - Sharpness - Reset - Focus - None - Radial - Linear - Mirrored - Gaussian - Text - Text Options - Text Color - Font - Add - Edit - Straighten - Font - Color - BG Color - Alignment - To Front - Delete - Your text - Brush - Color - Size - Hardness - To Front - Delete - Brush Color - Editor - Close Editor? - Do you really want to discard the image? - Yes - No - Cancel - Accept - Save - Exporting image… - Exporting image %s. - Flip H - Flip V - Undo - Redo - Color Picker - Transparent + カスタム + リセット + 正方形 + 変形 + フィルター + なし + 調整 + シャドウ + 露出 + ハイライト + 明るさ + コントラスト + 彩度 + 明瞭度 + ガンマ + 黒レベル + 白レベル + 色温度 + シャープネス + リセット + ぼかし + なし + 円形 + 直線 + ミラー + ガウス + テキスト + テキスト オプション + 文字色 + フォント + 追加 + 編集 + まっすぐにする + フォント + + 背景色 + 配置 + 前面に + 削除 + テキストを入力 + ブラシ + + 太さ + 硬度 + 前面に + 削除 + ブラシの色 + エディター + エディターを閉じますか? + 画像を破棄して閉じますか? + はい + いいえ + キャンセル + 了解 + 保存 + 画像を保存中…… + 画像を保存中 %s. + 水平方向に反転 + 垂直方向に反転 + 元に戻す + やり直し + カラーピッカー + 透明 White Gray Black From 76571aab9a86d0c210ac6aa714a50d947493bbde Mon Sep 17 00:00:00 2001 From: AioiLight Date: Sun, 26 Jan 2020 18:31:49 +0900 Subject: [PATCH 13/36] updating Japanese translation(some strings) --- app/src/main/res/values-ja/strings.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 203820656..f97b63ada 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -32,8 +32,8 @@ 修正中… 撮影日が正常に修正されました リサイズした画像を共有 - Hey,\n\nseems like you upgraded from the old free app. You can now uninstall the old version, which has an \'Upgrade to Pro\' button at the top of the app settings.\n\nYou will only have the Recycle bin items deleted, favorite items unmarked and you will also have to reset your app settings.\n\nThanks! - Switch to file search across all visible folders + あなたは無料版からアップグレードしたと思われます。"Upgrade to Pro"というボタンが設定の上部にある無料版はアンインストールすることができます。\n\nごみ箱の中身は削除され、お気に入りもアプリの設定もリセットされることになります。\n\nありがとう! + 表示されているすべてのフォルダで検索 に切り替え 表示する形式 @@ -42,7 +42,7 @@ GIF RAW SVG - Portraits + ポートレイト 条件に該当するメディアがありません。 絞り込み条件を変更 @@ -82,7 +82,7 @@ パス 無効な画像パス 画像の編集に失敗しました - File edited successfully + ファイルの編集に成功しました 画像を編集: 画像エディターが見つかりません ファイルの場所が不明です @@ -180,11 +180,11 @@ 画像のズームを深くする 可能な限り高品質で画像を表示 ごみ箱をメイン画面の最後に表示 - Allow closing the fullscreen view with a down gesture - Allow 1:1 zooming in with two double taps + フルスクリーン表示を下にスワイプするジェスチャーで閉じる + ダブルタップして 1:1 ズームする Always open videos on a separate screen with new horizontal gestures Show a notch if available - Allow rotating images with gestures + ジェスチャーで画像を回転する File loading priority Speed Compromise From 1c2d23c57d286ec5eeaba4ad99eccf96a4ee86f2 Mon Sep 17 00:00:00 2001 From: AioiLight Date: Sun, 26 Jan 2020 19:05:20 +0900 Subject: [PATCH 14/36] fix escape missing --- app/src/main/res/values-ja/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index f97b63ada..f35577c8c 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -32,7 +32,7 @@ 修正中… 撮影日が正常に修正されました リサイズした画像を共有 - あなたは無料版からアップグレードしたと思われます。"Upgrade to Pro"というボタンが設定の上部にある無料版はアンインストールすることができます。\n\nごみ箱の中身は削除され、お気に入りもアプリの設定もリセットされることになります。\n\nありがとう! + あなたは無料版からアップグレードしたと思われます。\"Upgrade to Pro\"というボタンが設定の上部にある無料版はアンインストールすることができます。\n\nごみ箱の中身は削除され、お気に入りもアプリの設定もリセットされることになります。\n\nありがとう! 表示されているすべてのフォルダで検索 に切り替え From 9e702ce59352977fbc5e52f19faa4d26d9fd2391 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 26 Jan 2020 19:18:33 +0100 Subject: [PATCH 15/36] adding czech fastlane app data --- fastlane/metadata/android/cs/full_description.txt | 14 +++++++------- fastlane/metadata/android/cs/short_description.txt | 2 +- fastlane/metadata/android/cs/title.txt | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/fastlane/metadata/android/cs/full_description.txt b/fastlane/metadata/android/cs/full_description.txt index 70cb84ae8..621e34bd7 100644 --- a/fastlane/metadata/android/cs/full_description.txt +++ b/fastlane/metadata/android/cs/full_description.txt @@ -1,6 +1,6 @@ -Jednoduchá Galerie Pro je vysoce přizpůsobitelná offline galerie. Organizujte a upravujte své fotografie, obnovujte smazané fotografie s funkcí odpadkového koše, chraňte je a skrývejte. Prohlížejte množství různých foto a video formátů včetně RAW, SVG a mnoho dalších. +Jednoduchá galerie Pro je vysoce přizpůsobitelná offline galerie. Organizujte a upravujte své fotografie, obnovujte smazané fotografie s funkcí odpadkového koše, chraňte je a skrývejte. Prohlížejte množství různých foto a video formátů včetně RAW, SVG a mnoho dalších. -Aplikace neobsahuje žádné reklamy ani nepotřebná oprávnění. Tím, že ani nevyžaduje připojení k internetu je vaše soukromí maximálně chráněno. +Aplikace neobsahuje žádné reklamy ani nepotřebná oprávnění. Tím, že ani nevyžaduje připojení k internetu, je vaše soukromí maximálně chráněno. ------------------------------------------------- JEDNODUCHÁ GALERIE PRO – FUNKCE @@ -14,7 +14,7 @@ Aplikace neobsahuje žádné reklamy ani nepotřebná oprávnění. Tím, že an • Otevírejte mnoho rozličných formátů fotografií a videí (RAW, SVG, GIF, panorama, atd) • Množství intuitivních gest pro jednoduchou úpravu a organizaci souborů • Mnoho různých způsobů filtrování, seskupování a řazení souborů -• Změňte si vzhled Jednoduché galerie pro +• Změňte si vzhled Jednoduché galerie Pro • Dostupná ve 32 jazycích • Označte si oblíbené soubory pro rychlý přístup • Chraňte své fotografie a videa pomocí pinu, vzoru nebo otiskem prstu @@ -27,16 +27,16 @@ Aplikace neobsahuje žádné reklamy ani nepotřebná oprávnění. Tím, že an … a mnoho dalších! EDITOR OBRÁZKŮ -Jednoduchá Galerie Pro umožňuje snadnou úpravu obrázků. Ořezávejte, překlápějte, otáčejte či měňte jejich velikost. Pokud se cítíte kreativně, můžete také aplikovat filtry nebo do obrázku kreslit! +Jednoduchá galerie Pro umožňuje snadnou úpravu obrázků. Ořezávejte, překlápějte, otáčejte či měňte jejich velikost. Pokud se cítíte kreativně, můžete také aplikovat filtry nebo do obrázku kreslit! PODPORA MNOHA TYPŮ SOUBORŮ -Na rozdíl od některých galerií podporuje Jednoduchá Galerie Pro velké množství různých druhů souborů včetně JPEG, PNG, MP4, MKV, RAW, SVG, panoramatických fotografií a videí. +Na rozdíl od některých galerií podporuje Jednoduchá galerie Pro velké množství různých druhů souborů včetně JPEG, PNG, MP4, MKV, RAW, SVG, panoramatických fotografií a videí. Vysoce upravitelný správce galerie -Od vzhledu až po funkční tlačítka na spodní liště, Jednoduchá Galerie Pro je plně nastavitelná a bude fungovat přesně jak si budete přát. Žádná jiná galerie nenabízí takovou flexibilitu! A díky otevřenému kódu je naše aplikace dostupná ve 32 jazycích! +Od vzhledu až po funkční tlačítka na spodní liště, Jednoduchá galerie Pro je plně nastavitelná a bude fungovat přesně jak si budete přát. Žádná jiná galerie nenabízí takovou flexibilitu! A díky otevřenému kódu je naše aplikace dostupná ve 32 jazycích! OBNOVTE SMAZANÉ FOTOGRAFIE A VIDEA -Smazali jste nechtěně důležitou fotografii nebo video? Žádný strach! Jednoduchá Galerie Pro pro podobné případy nabízí funkci odpadkového koše, odkud smazané fotografie a videa snadno obnovíte. +Smazali jste nechtěně důležitou fotografii nebo video? Žádný strach! Jednoduchá galerie Pro pro podobné případy nabízí funkci odpadkového koše, odkud smazané fotografie a videa snadno obnovíte. CHRAŇTE A SKRÝVEJTE SVÉ FOTOGRAFIE A VIDEA Použitím pinu, vzoru nebo otisku prstu snadno své fotografie, videa či celá alba ochráníte nebo skryjete. Můžete ochránit i spuštění samotné aplikace, nebo některé její funkce. Například můžete zabránit náhodnému smazání souboru bez potvrzení otiskem prstu. diff --git a/fastlane/metadata/android/cs/short_description.txt b/fastlane/metadata/android/cs/short_description.txt index 838a83301..07d253324 100644 --- a/fastlane/metadata/android/cs/short_description.txt +++ b/fastlane/metadata/android/cs/short_description.txt @@ -1 +1 @@ -Prohlížejte své vzpomínky bez přerušení. +Prohlížejte svoje vzpomínky bez prerušení s touto foto a video galerií. diff --git a/fastlane/metadata/android/cs/title.txt b/fastlane/metadata/android/cs/title.txt index 085c5b107..c4d4949ec 100644 --- a/fastlane/metadata/android/cs/title.txt +++ b/fastlane/metadata/android/cs/title.txt @@ -1 +1 @@ -Jednoduchá Galerie Pro - Organizér a editor fotografií +Jednoduchá Galerie Pro - Organizér fotografií From 4d7e95d72a4ca23a7ef2eac0be6b2f15f64727c6 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 26 Jan 2020 19:18:43 +0100 Subject: [PATCH 16/36] shortening the czech app title --- app/src/main/res/values-cs/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 100e451e2..9ed63b894 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -317,7 +317,7 @@ - Jednoduchá galerie Pro - Organizér a editor fotografií + Jednoduchá galerie Pro - Organizér fotografií Prohlížejte svoje vzpomínky bez prerušení s touto foto a video galerií. From 86db0b8f19386d4697612647a394f336daebcaca Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 27 Jan 2020 14:47:17 +0100 Subject: [PATCH 17/36] fix unselecting invalid favorite items --- .../com/simplemobiletools/gallery/pro/extensions/Context.kt | 6 ++++-- .../gallery/pro/interfaces/FavoritesDao.kt | 3 --- 2 files changed, 4 insertions(+), 5 deletions(-) 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 7e69583e8..179832a97 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 @@ -674,8 +674,10 @@ fun Context.getCachedMedia(path: String, getVideosOnly: Boolean = false, getImag try { if (mediaToDelete.isNotEmpty()) { mediaDB.deleteMedia(*mediaToDelete.toTypedArray()) - val favorites = mediaToDelete.map { getFavoriteFromPath(it.path) } - favoritesDB.deleteFavorites(*favorites.toTypedArray()) + + mediaToDelete.filter { it.isFavorite }.forEach { + favoritesDB.deleteFavoritePath(it.path) + } } } catch (ignored: Exception) { } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDao.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDao.kt index 52056cb7e..102454e79 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDao.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDao.kt @@ -23,9 +23,6 @@ interface FavoritesDao { @Query("UPDATE OR REPLACE favorites SET filename = :newFilename, full_path = :newFullPath, parent_path = :newParentPath WHERE full_path = :oldPath COLLATE NOCASE") fun updateFavorite(newFilename: String, newFullPath: String, newParentPath: String, oldPath: String) - @Delete - fun deleteFavorites(vararg favorite: Favorite) - @Query("DELETE FROM favorites WHERE full_path = :path COLLATE NOCASE") fun deleteFavoritePath(path: String) From 9d2239d1c1b39ef35e1be989b33b4db824d273de Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 27 Jan 2020 15:05:17 +0100 Subject: [PATCH 18/36] really clear all Favorites at deleting the given folder --- .../simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt | 1 + .../com/simplemobiletools/gallery/pro/interfaces/MediumDao.kt | 3 +++ 2 files changed, 4 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt index 84113cfa9..ec683644d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt @@ -555,6 +555,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList Date: Mon, 27 Jan 2020 15:17:46 +0100 Subject: [PATCH 19/36] migrate favorites in the new table on app upgrade --- .../gallery/pro/activities/SplashActivity.kt | 32 +++++++++++++++++++ .../gallery/pro/helpers/Config.kt | 4 +++ .../gallery/pro/helpers/Constants.kt | 1 + 3 files changed, 37 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SplashActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SplashActivity.kt index 20c9c9387..ede321fc2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SplashActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SplashActivity.kt @@ -2,9 +2,41 @@ package com.simplemobiletools.gallery.pro.activities import android.content.Intent import com.simplemobiletools.commons.activities.BaseSplashActivity +import com.simplemobiletools.commons.helpers.ensureBackgroundThread +import com.simplemobiletools.gallery.pro.extensions.config +import com.simplemobiletools.gallery.pro.extensions.favoritesDB +import com.simplemobiletools.gallery.pro.extensions.getFavoriteFromPath +import com.simplemobiletools.gallery.pro.extensions.mediaDB +import com.simplemobiletools.gallery.pro.models.Favorite class SplashActivity : BaseSplashActivity() { override fun initActivity() { + + // check if previously selected favorite items have been properly migrated into the new Favorites table + if (config.wereFavoritesMigrated) { + launchActivity() + } else { + if (config.appRunCount == 0) { + config.wereFavoritesMigrated = true + } else { + ensureBackgroundThread { + val favorites = ArrayList() + val favoritePaths = mediaDB.getFavorites().map { it.path }.toMutableList() as ArrayList + favoritePaths.forEach { + favorites.add(getFavoriteFromPath(it)) + } + favoritesDB.insertAll(favorites) + config.wereFavoritesMigrated = true + + runOnUiThread { + launchActivity() + } + } + } + } + } + + private fun launchActivity() { startActivity(Intent(this, MainActivity::class.java)) finish() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt index 4f8bce7c8..6769ec72d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt @@ -494,4 +494,8 @@ class Config(context: Context) : BaseConfig(context) { var editorBrushSize: Float get() = prefs.getFloat(EDITOR_BRUSH_SIZE, 0.05f) set(editorBrushSize) = prefs.edit().putFloat(EDITOR_BRUSH_SIZE, editorBrushSize).apply() + + var wereFavoritesMigrated: Boolean + get() = prefs.getBoolean(WERE_FAVORITES_MIGRATED, false) + set(wereFavoritesMigrated) = prefs.edit().putBoolean(WERE_FAVORITES_MIGRATED, wereFavoritesMigrated).apply() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt index 50ca3f376..9b549de78 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt @@ -80,6 +80,7 @@ const val SHOW_THUMBNAIL_FILE_TYPES = "show_thumbnail_file_types" const val EDITOR_BRUSH_COLOR = "editor_brush_color" const val EDITOR_BRUSH_HARDNESS = "editor_brush_hardness" const val EDITOR_BRUSH_SIZE = "editor_brush_size" +const val WERE_FAVORITES_MIGRATED = "were_favorites_migrated" // slideshow const val SLIDESHOW_INTERVAL = "slideshow_interval" From 817229a697e8a06d75d4de9fde72754023e262db Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 27 Jan 2020 17:22:16 +0100 Subject: [PATCH 20/36] lets set wereFavoritesMigrated earlier to avoid some crashlooping --- .../simplemobiletools/gallery/pro/activities/SplashActivity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SplashActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SplashActivity.kt index ede321fc2..45332bcd2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SplashActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SplashActivity.kt @@ -19,6 +19,7 @@ class SplashActivity : BaseSplashActivity() { if (config.appRunCount == 0) { config.wereFavoritesMigrated = true } else { + config.wereFavoritesMigrated = true ensureBackgroundThread { val favorites = ArrayList() val favoritePaths = mediaDB.getFavorites().map { it.path }.toMutableList() as ArrayList @@ -26,7 +27,6 @@ class SplashActivity : BaseSplashActivity() { favorites.add(getFavoriteFromPath(it)) } favoritesDB.insertAll(favorites) - config.wereFavoritesMigrated = true runOnUiThread { launchActivity() From 665690c81912ec993f5512ec3f515319b3a9893f Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 27 Jan 2020 20:34:59 +0100 Subject: [PATCH 21/36] removing an unused debug function --- .../gallery/pro/interfaces/FavoritesDao.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDao.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDao.kt index 102454e79..39a4c4530 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDao.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDao.kt @@ -1,6 +1,9 @@ package com.simplemobiletools.gallery.pro.interfaces -import androidx.room.* +import androidx.room.Dao +import androidx.room.Insert +import androidx.room.OnConflictStrategy +import androidx.room.Query import com.simplemobiletools.gallery.pro.models.Favorite @Dao @@ -11,9 +14,6 @@ interface FavoritesDao { @Insert(onConflict = OnConflictStrategy.REPLACE) fun insertAll(favorites: List) - @Query("SELECT full_path FROM favorites") - fun getFavoriteRawPaths(): List - @Query("SELECT favorites.full_path FROM favorites INNER JOIN media ON favorites.full_path = media.full_path WHERE media.deleted_ts = 0") fun getValidFavoritePaths(): List From 2517170aebcf5a2b25eff23317d64889270edafe Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 27 Jan 2020 20:48:37 +0100 Subject: [PATCH 22/36] store the fixed Date Taken values in the new table --- .../gallery/pro/extensions/Activity.kt | 9 +++++++++ .../gallery/pro/extensions/Context.kt | 7 +++---- .../gallery/pro/interfaces/DateTakensDao.kt | 11 +++++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt index 4020ed9f5..b23b28522 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt @@ -31,6 +31,7 @@ import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.activities.SimpleActivity import com.simplemobiletools.gallery.pro.dialogs.PickDirectoryDialog import com.simplemobiletools.gallery.pro.helpers.RECYCLE_BIN +import com.simplemobiletools.gallery.pro.models.DateTaken import com.squareup.picasso.Picasso import java.io.File import java.io.FileOutputStream @@ -414,6 +415,8 @@ fun Activity.fixDateTaken(paths: ArrayList, showToasts: Boolean, hasResc val operations = ArrayList() ensureBackgroundThread { + val dateTakens = ArrayList() + for (path in paths) { val dateTime = ExifInterface(path).getAttribute(ExifInterface.TAG_DATETIME_ORIGINAL) ?: ExifInterface(path).getAttribute(ExifInterface.TAG_DATETIME) ?: continue @@ -443,6 +446,8 @@ fun Activity.fixDateTaken(paths: ArrayList, showToasts: Boolean, hasResc mediaDB.updateFavoriteDateTaken(path, timestamp) didUpdateFile = true + val dateTaken = DateTaken(null, path, path.getFilenameFromPath(), path.getParentPath(), timestamp, (System.currentTimeMillis() / 1000).toInt()) + dateTakens.add(dateTaken) if (!hasRescanned && getFileDateTaken(path) == 0L) { pathsToRescan.add(path) } @@ -454,6 +459,10 @@ fun Activity.fixDateTaken(paths: ArrayList, showToasts: Boolean, hasResc } if (hasRescanned || pathsToRescan.isEmpty()) { + if (dateTakens.isNotEmpty()) { + dateTakensDB.insertAll(dateTakens) + } + runOnUiThread { if (showToasts) { toast(if (didUpdateFile) R.string.dates_fixed_successfully else R.string.unknown_error_occurred) 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 179832a97..a3d542674 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 @@ -25,10 +25,7 @@ import com.simplemobiletools.gallery.pro.activities.SettingsActivity import com.simplemobiletools.gallery.pro.asynctasks.GetMediaAsynctask import com.simplemobiletools.gallery.pro.databases.GalleryDatabase import com.simplemobiletools.gallery.pro.helpers.* -import com.simplemobiletools.gallery.pro.interfaces.DirectoryDao -import com.simplemobiletools.gallery.pro.interfaces.FavoritesDao -import com.simplemobiletools.gallery.pro.interfaces.MediumDao -import com.simplemobiletools.gallery.pro.interfaces.WidgetsDao +import com.simplemobiletools.gallery.pro.interfaces.* import com.simplemobiletools.gallery.pro.models.* import com.simplemobiletools.gallery.pro.svg.SvgSoftwareLayerSetter import com.simplemobiletools.gallery.pro.views.MySquareImageView @@ -119,6 +116,8 @@ val Context.directoryDao: DirectoryDao get() = GalleryDatabase.getInstance(appli val Context.favoritesDB: FavoritesDao get() = GalleryDatabase.getInstance(applicationContext).FavoritesDao() +val Context.dateTakensDB: DateTakensDao get() = GalleryDatabase.getInstance(applicationContext).DateTakensDao() + val Context.recycleBin: File get() = filesDir val Context.recycleBinPath: String get() = filesDir.absolutePath diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/DateTakensDao.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/DateTakensDao.kt index 0d3380408..6f8b609a8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/DateTakensDao.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/DateTakensDao.kt @@ -1,8 +1,19 @@ package com.simplemobiletools.gallery.pro.interfaces import androidx.room.Dao +import androidx.room.Insert +import androidx.room.OnConflictStrategy +import androidx.room.Query +import com.simplemobiletools.gallery.pro.models.DateTaken @Dao interface DateTakensDao { + @Insert(onConflict = OnConflictStrategy.REPLACE) + fun insertAll(dateTakens: List) + @Query("SELECT full_path, filename, parent_path, date_taken, last_fixed FROM date_takens WHERE parent_path = :path COLLATE NOCASE") + fun getDateTakensFromPath(path: String): List + + @Query("SELECT full_path, filename, parent_path, date_taken, last_fixed FROM date_takens") + fun getAllDateTakens(): List } From 650a985a9cecc0676bf3ea0ba92fe818cf0d7279 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 27 Jan 2020 21:05:05 +0100 Subject: [PATCH 23/36] make the Date Taken from Fix Date Taken value be higher priority than mediastore --- .../simplemobiletools/gallery/pro/helpers/MediaFetcher.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 6a4db386a..955ce9eed 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 @@ -407,8 +407,8 @@ class MediaFetcher(val context: Context) { try { val dateTaken = cursor.getLongValue(MediaStore.Images.Media.DATE_TAKEN) if (dateTaken != 0L) { - val path = cursor.getStringValue(MediaStore.Images.Media.DISPLAY_NAME) - dateTakens[path] = dateTaken + val name = cursor.getStringValue(MediaStore.Images.Media.DISPLAY_NAME) + dateTakens[name] = dateTaken } } catch (e: Exception) { } @@ -416,6 +416,10 @@ class MediaFetcher(val context: Context) { } } + context.dateTakensDB.getDateTakensFromPath(folder).forEach { + dateTakens[it.filename] = it.taken + } + return dateTakens } From f4c02d11687861ca2ff04256c674381b2456c2f8 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 27 Jan 2020 21:22:10 +0100 Subject: [PATCH 24/36] fix #1545, properly sort Favorites by date taken --- .../gallery/pro/helpers/MediaFetcher.kt | 60 +++++++++++-------- 1 file changed, 34 insertions(+), 26 deletions(-) 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 955ce9eed..8f060f922 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 @@ -226,7 +226,7 @@ class MediaFetcher(val context: Context) { val checkFileExistence = config.fileLoadingPriority == PRIORITY_VALIDITY val showHidden = config.shouldShowHidden val showPortraits = filterMedia and TYPE_PORTRAITS != 0 - val dateTakens = if (getProperDateTaken && folder != FAVORITES && !isRecycleBin) getFolderDateTakens(folder) else HashMap() + val dateTakens = if (getProperDateTaken && !isRecycleBin) getFolderDateTakens(folder) else HashMap() val files = when (folder) { FAVORITES -> favoritePaths.filter { showHidden || !it.contains("/.") }.map { File(it) }.toMutableList() as ArrayList @@ -302,7 +302,7 @@ class MediaFetcher(val context: Context) { val videoDuration = if (getVideoDurations && isVideo) path.getVideoDuration() else 0 if (getProperDateTaken) { - dateTaken = dateTakens.remove(filename) ?: lastModified + dateTaken = dateTakens.remove(path) ?: lastModified } val type = when { @@ -390,34 +390,42 @@ class MediaFetcher(val context: Context) { } private fun getFolderDateTakens(folder: String): HashMap { - val projection = arrayOf( - MediaStore.Images.Media.DISPLAY_NAME, - MediaStore.Images.Media.DATE_TAKEN - ) - - val uri = MediaStore.Files.getContentUri("external") - val selection = "${MediaStore.Images.Media.DATA} LIKE ? AND ${MediaStore.Images.Media.DATA} NOT LIKE ?" - val selectionArgs = arrayOf("$folder/%", "$folder/%/%") - val dateTakens = HashMap() - val cursor = context.contentResolver.query(uri, projection, selection, selectionArgs, null) - cursor?.use { - if (cursor.moveToFirst()) { - do { - try { - val dateTaken = cursor.getLongValue(MediaStore.Images.Media.DATE_TAKEN) - if (dateTaken != 0L) { - val name = cursor.getStringValue(MediaStore.Images.Media.DISPLAY_NAME) - dateTakens[name] = dateTaken + if (folder != FAVORITES) { + val projection = arrayOf( + MediaStore.Images.Media.DISPLAY_NAME, + MediaStore.Images.Media.DATE_TAKEN + ) + + val uri = MediaStore.Files.getContentUri("external") + val selection = "${MediaStore.Images.Media.DATA} LIKE ? AND ${MediaStore.Images.Media.DATA} NOT LIKE ?" + val selectionArgs = arrayOf("$folder/%", "$folder/%/%") + + val cursor = context.contentResolver.query(uri, projection, selection, selectionArgs, null) + cursor?.use { + if (cursor.moveToFirst()) { + do { + try { + val dateTaken = cursor.getLongValue(MediaStore.Images.Media.DATE_TAKEN) + if (dateTaken != 0L) { + val name = cursor.getStringValue(MediaStore.Images.Media.DISPLAY_NAME) + dateTakens["$folder/$name"] = dateTaken + } + } catch (e: Exception) { } - } catch (e: Exception) { - } - } while (cursor.moveToNext()) + } while (cursor.moveToNext()) + } } } - context.dateTakensDB.getDateTakensFromPath(folder).forEach { - dateTakens[it.filename] = it.taken + val dateTakenValues = if (folder == FAVORITES) { + context.dateTakensDB.getAllDateTakens() + } else { + context.dateTakensDB.getDateTakensFromPath(folder) + } + + dateTakenValues.forEach { + dateTakens[it.fullPath] = it.taken } return dateTakens @@ -460,7 +468,6 @@ class MediaFetcher(val context: Context) { } fun groupMedia(media: ArrayList, path: String): ArrayList { - val mediumGroups = LinkedHashMap>() val pathToCheck = if (path.isEmpty()) SHOW_ALL else path val currentGrouping = context.config.getFolderGrouping(pathToCheck) if (currentGrouping and GROUP_BY_NONE != 0) { @@ -473,6 +480,7 @@ class MediaFetcher(val context: Context) { return thumbnailItems } + val mediumGroups = LinkedHashMap>() media.forEach { val key = it.getGroupingKey(currentGrouping) if (!mediumGroups.containsKey(key)) { From 3e7f99fc01dc285320c079c98e0bfe5df03da250 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 27 Jan 2020 23:04:18 +0100 Subject: [PATCH 25/36] fix #1725, properly remember last video playback position, if paused --- .../gallery/pro/fragments/VideoFragment.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt index 96879d3c1..92b98f653 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt @@ -273,8 +273,12 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S } private fun saveVideoProgress() { - if (!videoEnded() && mExoPlayer != null) { - mConfig.saveLastVideoPosition(mMedium.path, mExoPlayer!!.currentPosition.toInt() / 1000) + if (!videoEnded()) { + if (mExoPlayer != null) { + mConfig.saveLastVideoPosition(mMedium.path, mExoPlayer!!.currentPosition.toInt() / 1000) + } else { + mConfig.saveLastVideoPosition(mMedium.path, mPositionAtPause.toInt() / 1000) + } } } From 035d0363e3b10987bf3317aed54d0deefc796831 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 27 Jan 2020 23:15:47 +0100 Subject: [PATCH 26/36] fix #1723, recognize panoramic photos by a new xml tag too --- .../simplemobiletools/gallery/pro/fragments/PhotoFragment.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt index f5cf3f93e..d7555a5b4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt @@ -657,7 +657,9 @@ class PhotoFragment : ViewPagerFragment() { mIsPanorama = try { val inputStream = if (mMedium.path.startsWith("content:/")) context!!.contentResolver.openInputStream(Uri.parse(mMedium.path)) else File(mMedium.path).inputStream() val imageParser = JpegImageParser().getXmpXml(ByteSourceInputStream(inputStream, mMedium.name), HashMap()) - imageParser.contains("GPano:UsePanoramaViewer=\"True\"", true) || imageParser.contains("True", true) + imageParser.contains("GPano:UsePanoramaViewer=\"True\"", true) || + imageParser.contains("True", true) || + imageParser.contains("GPano:FullPanoWidthPixels=") } catch (e: Exception) { false } catch (e: OutOfMemoryError) { From f8315438d86fb974a871fee18557ca7a97119428 Mon Sep 17 00:00:00 2001 From: ForgottenUmbrella Date: Mon, 27 Jan 2020 01:41:38 +1100 Subject: [PATCH 27/36] Let ExoPlayer handle video looping seamlessly Now that videos are replacing the inefficient GIF format, gapless loops are important. ExoPlayer's built-in mechanism prebuffers the video to enable this, whereas the current implementation of seeking to the start presents a short but noticeable delay between each loop. Note that this change introduces an incompatibility with current behaviour: due to google/ExoPlayer#6459, certain videos with broken audio tracks that played fine before will no longer start. Disabling the audio track is a workaround to re-enable looping playback, but ExoPlayer does not appear to expose a way to check if the audio track is short enough to produce the bug. --- .../gallery/pro/activities/VideoPlayerActivity.kt | 3 +++ .../simplemobiletools/gallery/pro/fragments/VideoFragment.kt | 3 +++ 2 files changed, 6 insertions(+) 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 bed9bc018..6d0f4f245 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 @@ -214,6 +214,9 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen mExoPlayer = ExoPlayerFactory.newSimpleInstance(applicationContext).apply { seekParameters = SeekParameters.CLOSEST_SYNC audioStreamType = C.STREAM_TYPE_MUSIC + if (config.loopVideos) { + repeatMode = Player.REPEAT_MODE_ONE + } prepare(audioSource) } initExoPlayerListeners() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt index 92b98f653..162f98c86 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt @@ -317,6 +317,9 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S mExoPlayer = ExoPlayerFactory.newSimpleInstance(context) mExoPlayer!!.seekParameters = SeekParameters.CLOSEST_SYNC + if (mConfig.loopVideos) { + mExoPlayer?.repeatMode = Player.REPEAT_MODE_ONE + } val isContentUri = mMedium.path.startsWith("content://") val uri = if (isContentUri) Uri.parse(mMedium.path) else Uri.fromFile(File(mMedium.path)) From e83db406a9a0f3cc0ea19fe1de447cfacdd7fddb Mon Sep 17 00:00:00 2001 From: ForgottenUmbrella Date: Mon, 27 Jan 2020 02:12:40 +1100 Subject: [PATCH 28/36] Reset progress views on video loop The previous loop method of seeking to the beginning at video completion ensured that the seekbar and current time text were immediately reset. Using ExoPlayer's own implementation of video looping means that `Player.STATE_ENDED` is no longer reached, thus the UI no longer accurately tracks progress. Restore the old behaviour by resetting the views on position discontinuity. --- .../gallery/pro/activities/VideoPlayerActivity.kt | 8 +++++++- .../gallery/pro/fragments/VideoFragment.kt | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) 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 6d0f4f245..6b306ba4c 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 @@ -234,7 +234,13 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen override fun onLoadingChanged(isLoading: Boolean) {} - override fun onPositionDiscontinuity(reason: Int) {} + override fun onPositionDiscontinuity(reason: Int) { + // Reset progress views when video loops. + if (reason == Player.DISCONTINUITY_REASON_PERIOD_TRANSITION) { + video_seekbar.progress = 0 + video_curr_time.text = 0.getFormattedDuration() + } + } override fun onRepeatModeChanged(repeatMode: Int) {} diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt index 162f98c86..56deff9a1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt @@ -353,7 +353,13 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S override fun onLoadingChanged(isLoading: Boolean) {} - override fun onPositionDiscontinuity(reason: Int) {} + override fun onPositionDiscontinuity(reason: Int) { + // Reset progress views when video loops. + if (reason == Player.DISCONTINUITY_REASON_PERIOD_TRANSITION) { + mSeekBar.progress = 0 + mCurrTimeView.text = 0.getFormattedDuration() + } + } override fun onRepeatModeChanged(repeatMode: Int) {} From 9877cbaf2cde09f190f4ee15a9f51f1973d091d9 Mon Sep 17 00:00:00 2001 From: ForgottenUmbrella Date: Mon, 27 Jan 2020 02:13:25 +1100 Subject: [PATCH 29/36] Remove unreachable branches in video completion handling It is never the case that `loopVideos == true` in the `videoCompleted` handler, since enabling that preference sets `repeatMode`, which in turn prevents the player from reaching `STATE_ENDED`. Thus, the branches are unreachable. --- .../gallery/pro/activities/VideoPlayerActivity.kt | 10 +++------- .../gallery/pro/fragments/VideoFragment.kt | 10 +++------- 2 files changed, 6 insertions(+), 14 deletions(-) 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 6b306ba4c..27839af11 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 @@ -347,13 +347,9 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen clearLastVideoSavedProgress() mCurrTime = (mExoPlayer!!.duration / 1000).toInt() - if (config.loopVideos) { - resumeVideo() - } else { - video_seekbar.progress = video_seekbar.max - video_curr_time.text = mDuration.getFormattedDuration() - pauseVideo() - } + video_seekbar.progress = video_seekbar.max + video_curr_time.text = mDuration.getFormattedDuration() + pauseVideo() } private fun didVideoEnd(): Boolean { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt index 56deff9a1..bc7a69b56 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt @@ -681,13 +681,9 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S } mCurrTime = (mExoPlayer!!.duration / 1000).toInt() - if (listener?.videoEnded() == false && mConfig.loopVideos) { - playVideo() - } else { - mSeekBar.progress = mSeekBar.max - mCurrTimeView.text = mDuration.getFormattedDuration() - pauseVideo() - } + mSeekBar.progress = mSeekBar.max + mCurrTimeView.text = mDuration.getFormattedDuration() + pauseVideo() } private fun cleanup() { From 61ded74c064f9e1ba788d36bca95f76e19a12f69 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 28 Jan 2020 18:45:22 +0100 Subject: [PATCH 30/36] update commons to 5.21.28 --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 9b9269853..9fefcf351 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -69,7 +69,7 @@ android { } dependencies { - implementation 'com.simplemobiletools:commons:5.21.25' + implementation 'com.simplemobiletools:commons:5.21.28' implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0' implementation 'androidx.multidex:multidex:2.0.1' implementation 'it.sephiroth.android.exif:library:1.0.1' From 2476b974524c261fd69b15e3eb53707dd785fac9 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 28 Jan 2020 18:51:28 +0100 Subject: [PATCH 31/36] properly launch the main activity on first app use --- .../simplemobiletools/gallery/pro/activities/SplashActivity.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SplashActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SplashActivity.kt index 45332bcd2..9d0c0cc79 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SplashActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SplashActivity.kt @@ -18,6 +18,7 @@ class SplashActivity : BaseSplashActivity() { } else { if (config.appRunCount == 0) { config.wereFavoritesMigrated = true + launchActivity() } else { config.wereFavoritesMigrated = true ensureBackgroundThread { From 6bb6853d4907d787b0b278badd27c0b1033ad49e Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 28 Jan 2020 19:02:48 +0100 Subject: [PATCH 32/36] update version to 6.12.0 --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 9fefcf351..759a1442b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -17,8 +17,8 @@ android { applicationId "com.simplemobiletools.gallery.pro" minSdkVersion 21 targetSdkVersion 28 - versionCode 288 - versionName "6.11.8" + versionCode 289 + versionName "6.12.0" multiDexEnabled true setProperty("archivesBaseName", "gallery") vectorDrawables.useSupportLibrary = true From 8840a1ad0a945f6464576e281a9c051291d4fa74 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 28 Jan 2020 19:02:56 +0100 Subject: [PATCH 33/36] updating changelog --- CHANGELOG.md | 12 ++++++++++++ fastlane/metadata/android/en-US/changelogs/289.txt | 8 ++++++++ 2 files changed, 20 insertions(+) create mode 100644 fastlane/metadata/android/en-US/changelogs/289.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index a76981def..c4d6db2ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,18 @@ Changelog ========== +Version 6.12.0 *(2020-01-28)* +---------------------------- + + * Properly handle sorting by date taken after using "Fix Date Taken values" on the wrong files + * Fixed some issues at copying files, when the source was on an SD card + * Change the way Favorite items are stored, to avoid accidental removal + * Improved video looping (by ForgottenUmbrella) + * Recognize a new type of panoramic photos + * Properly remember last video playback position if the video is paused on exit + * Properly color the top status bar icons at using light primary colors + * Other UX and translation improvements + Version 6.11.8 *(2020-01-19)* ---------------------------- diff --git a/fastlane/metadata/android/en-US/changelogs/289.txt b/fastlane/metadata/android/en-US/changelogs/289.txt new file mode 100644 index 000000000..6c4167f4f --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/289.txt @@ -0,0 +1,8 @@ + * Properly handle sorting by date taken after using "Fix Date Taken values" on the wrong files + * Fixed some issues at copying files, when the source was on an SD card + * Change the way Favorite items are stored, to avoid accidental removal + * Improved video looping (by ForgottenUmbrella) + * Recognize a new type of panoramic photos + * Properly remember last video playback position if the video is paused on exit + * Properly color the top status bar icons at using light primary colors + * Other UX and translation improvements From 4d96af4d7fbafb9561efee321530fe3361bc3f16 Mon Sep 17 00:00:00 2001 From: akcanSoft Date: Wed, 29 Jan 2020 12:15:04 +0300 Subject: [PATCH 34/36] new tr strings updated --- app/src/main/res/values-tr/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index bb700f47a..f04d9abc6 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -317,9 +317,9 @@ - Basit Galeri Pro - Fotoğraf Yönetici & Düzenleyici + Basit Galeri Pro - Fotoğraf Yönetici, Düzenleyici - Browse your memories without any interruptions with this photo and video gallery + Bu fotoğraf ve video galerisinde kesintisiz olarak anılarınıza göz atın Basit Galeri Pro, özelleştirilebilir bir çevrimdışı galeridir. Fotoğraflarınızı düzenleyin ve organize edin, geri dönüşüm kutusuyla silinen dosyaları kurtarın, dosyaları koruyun ve gizleyin ve RAW, SVG ve çok daha fazlası dahil olmak üzere çok çeşitli fotoğraf ve video formatlarını görüntüleyin. From 0faf477e41f66dd4f9253d6e4e8f3862d571882b Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 29 Jan 2020 11:04:38 +0100 Subject: [PATCH 35/36] updating the turkish app fastlane data --- fastlane/metadata/android/tr/short_description.txt | 2 +- fastlane/metadata/android/tr/title.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fastlane/metadata/android/tr/short_description.txt b/fastlane/metadata/android/tr/short_description.txt index 690c2cc5a..66c5ba9e8 100644 --- a/fastlane/metadata/android/tr/short_description.txt +++ b/fastlane/metadata/android/tr/short_description.txt @@ -1 +1 @@ -Reklamsız çevrimdışı galeri. Fotoğraf & videolarınızı yönetin ve düzenleyin +Bu fotoğraf ve video galerisinde kesintisiz olarak anılarınıza göz atın diff --git a/fastlane/metadata/android/tr/title.txt b/fastlane/metadata/android/tr/title.txt index 7110dfc6f..5a8fd5a45 100644 --- a/fastlane/metadata/android/tr/title.txt +++ b/fastlane/metadata/android/tr/title.txt @@ -1 +1 @@ -Basit Galeri Pro - Fotoğraf Yönetici & Düzenleyici +Basit Galeri Pro - Fotoğraf Yönetici, Düzenleyici From 193b5c1f2f8eb152bd59433daed91410802fdfbe Mon Sep 17 00:00:00 2001 From: Luis Alfredo Figueroa Bracamontes Date: Wed, 29 Jan 2020 20:14:14 -0600 Subject: [PATCH 36/36] =?UTF-8?q?Update=20strings.xml=20Espa=C3=B1ol?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The new editor translations --- app/src/main/res/values-es/strings.xml | 148 ++++++++++++------------- 1 file changed, 74 insertions(+), 74 deletions(-) diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index e5ab52d0e..f64c4896c 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -203,85 +203,85 @@ Alternar visibilidad de archivo - Custom - Reset - Square - Transform - Filter - None - Adjust - Shadows - Exposure - Highlights - Brightness - Contrast - Saturation - Clarity - Gamma - Blacks - Whites - Temperature - Sharpness - Reset - Focus - None + Personalizado + Reiniciar + Cuadrado + Recortar + Filtros + Ninguno + Ajustes + Sombras + Exposición + Luces + Brillo + Contraste + Saturación + Claridad + Colores + Negros + Blancos + Temperatura + Nitidez + Reiniciar + Enfoque + Ninguno Radial - Linear - Mirrored - Gaussian - Text - Text Options - Text Color - Font - Add - Edit - Straighten - Font + Lineal + Reflejado + Gaussiano + Texto + Opciones de texto + Color de texto + Fuente + Añadir + Editar + Enderezar + Fuente Color - BG Color - Alignment - To Front - Delete - Your text - Brush + Color de fondo + Alineación + Traer al frente + Eliminar + Tu texto + Pincel Color - Size - Hardness - To Front - Delete - Brush Color + Tamaño + Dureza + Traer al frente + Eliminar + Color del pincel Editor - Close Editor? - Do you really want to discard the image? - Yes + ¿Cerrar editor? + ¿Realmente quieres descartar la imagen? + No - Cancel - Accept - Save - Exporting image… - Exporting image %s. - Flip H - Flip V - Undo - Redo - Color Picker - Transparent - White - Gray - Black - Light blue - Blue - Purple - Orchid - Pink - Red - Orange - Gold - Yellow - Olive - Green - Aquamarin - Pipettable color + Cancelar + Aceptar + Guardar + Exportando imagen… + Exportando imagen %s. + Girar Hor + Girar Vert + Deshacer + Rehacer + Cuentagotas + Transparente + Blanco + Gris + Negro + Azul claro + Azul + Púrpura + Orquídea + Rosa + Rojo + Naranja + Dorado + Amarillo + Oliva + Verde + Aguamarina + Color pipetable ¿Cómo puedo hacer que Simple Gallery sea la galería de dispositivos predeterminada?