Skip to content

Commit

Permalink
Merge pull request #580 from Piwigo/LocalImagesProvider
Browse files Browse the repository at this point in the history
Version 3.2.2
  • Loading branch information
EddyLB authored Sep 11, 2024
2 parents 313e145 + 2e63030 commit 233431a
Show file tree
Hide file tree
Showing 190 changed files with 2,279 additions and 1,440 deletions.
Binary file added Assets/App Icon/Icon-Dark-1024x1024.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/App Icon/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/App Icon/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/App Icon/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/App Icon/Icon-Light-1024x1024.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/App Icon/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/App Icon/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/App Icon/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/App Icon/Icon-Tinted-1024x1024.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
Binary file not shown.
Binary file removed Assets/App Icon/icon-1024.png
Binary file not shown.
Binary file removed Assets/App Icon/icon-20.png
Binary file not shown.
Binary file removed Assets/App Icon/[email protected]
Binary file not shown.
Binary file removed Assets/App Icon/[email protected]
Binary file not shown.
Binary file removed Assets/App Icon/icon-29.png
Binary file not shown.
Binary file removed Assets/App Icon/[email protected]
Binary file not shown.
Binary file removed Assets/App Icon/[email protected]
Binary file not shown.
Binary file removed Assets/App Icon/icon-40.png
Binary file not shown.
Binary file removed Assets/App Icon/[email protected]
Binary file not shown.
Binary file removed Assets/App Icon/[email protected]
Binary file not shown.
Binary file removed Assets/App Icon/icon-60.png
Binary file not shown.
Binary file removed Assets/App Icon/[email protected]
Binary file not shown.
Binary file removed Assets/App Icon/[email protected]
Binary file not shown.
Binary file removed Assets/App Icon/icon-76.png
Binary file not shown.
Binary file removed Assets/App Icon/[email protected]
Binary file not shown.
Binary file removed Assets/App Icon/[email protected]
Binary file not shown.
8 changes: 8 additions & 0 deletions Assets/App Icon/piwigo.org-icon-edited.svg
7 changes: 7 additions & 0 deletions Assets/App Icon/piwigo.org-icon-original.svg
Binary file added Assets/App Icon/piwigo.org-icon.afdesign
Binary file not shown.
Binary file removed Assets/App Icon/piwigoIcon-1024.png
Diff not rendered.
42 changes: 25 additions & 17 deletions piwigo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions piwigo.xcodeproj/xcshareddata/xcschemes/piwigo.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1530"
LastUpgradeVersion = "1600"
version = "2.0">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -48,7 +48,6 @@
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
enableASanStackUseAfterReturn = "YES"
enableUBSanitizer = "YES"
disableMainThreadChecker = "YES"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1530"
LastUpgradeVersion = "1600"
version = "2.2">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1530"
LastUpgradeVersion = "1600"
wasCreatedForAppExtension = "YES"
version = "1.8">
<BuildAction
Expand Down
2 changes: 1 addition & 1 deletion piwigo.xcodeproj/xcshareddata/xcschemes/piwigoKit.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1530"
LastUpgradeVersion = "1600"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1530"
LastUpgradeVersion = "1600"
version = "2.0">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1530"
LastUpgradeVersion = "1600"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion piwigo.xcodeproj/xcshareddata/xcschemes/uploadKit.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1530"
LastUpgradeVersion = "1600"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ extension SelectCategoryViewController {
self.copyImage(imageData, toAlbum: albumData) { [self] in
// Next image…
self.inputImages.remove(imageData)
self.updateHUD(withProgress: 1.0 - Float(self.inputImages.count) / Float(self.nberOfImages))
self.updateHUD(withProgress: Float(1) - Float(self.inputImages.count) / Float(self.nberOfImages))
self.copyImages(toAlbum: albumData)
}
onFailure: { [self] error in
Expand Down
6 changes: 3 additions & 3 deletions piwigo/Album/AlbumSelector/SelectCategoryViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,18 @@ class SelectCategoryViewController: UIViewController, UITableViewDataSource, UIT

case .copyImages, .moveImages:
guard let array = parameter as? [Any],
let imageIds = array[0] as? Set<Int64>,
let imageIDs = array[0] as? Set<Int64>,
let albumId = array[1] as? Int32 else {
debugPrint("Input parameter expected to be of type [[NSNumber], Int32]")
return false
}
// IDs of the selected images which will be copied/moved to the selected album
inputImageIds = imageIds
inputImageIds = imageIDs
if inputImageIds.isEmpty {
debugPrint("List of image IDs should not be empty")
return false
}
inputImages = imageProvider.getImages(inContext: mainContext, withIds: imageIds)
inputImages = imageProvider.getImages(inContext: mainContext, withIds: imageIDs)
nberOfImages = Int64(inputImages.count)
if inputImages.isEmpty {
debugPrint("No image in cache with these IDs: \(inputImageIds)")
Expand Down
16 changes: 7 additions & 9 deletions piwigo/Album/AlbumViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import uploadKit
enum pwgImageAction {
case edit, delete, share
case copyImages, moveImages
case addToFavorites, removeFromFavorites
case favorite, unfavorite
case rotateImagesLeft, rotateImagesRight
}

Expand Down Expand Up @@ -92,17 +92,15 @@ class AlbumViewController: UIViewController
var imageOfInterest = IndexPath(item: 0, section: 0)
var indexOfImageToRestore = Int.min
var isSelect = false
var touchedImageIds = [Int64]()
var selectedImageIds = Set<Int64>()
var selectedImageIdsLoop = Set<Int64>()
var selectedFavoriteIds = Set<Int64>()
var selectedVideosIds = Set<Int64>()
var totalNumberOfImages = 0
var touchedImageIDs = [Int64]()
var selectedImageIDs = Set<Int64>()
var selectedFavoriteIDs = Set<Int64>()
var selectedVideosIDs = Set<Int64>()
var selectedSections = [Int : SelectButtonState]() // State of Select buttons


// MARK: - Cached Values
private var timeCounter = CFAbsoluteTime(0)
var timeCounter = CFAbsoluteTime(0)
lazy var thumbSize = pwgImageSize(rawValue: AlbumVars.shared.defaultAlbumThumbnailSize) ?? .medium
lazy var albumCellSize: CGSize = getAlbumCellSize()
lazy var albumPlaceHolder = UIImage(named: "placeholder")!
Expand All @@ -129,7 +127,7 @@ class AlbumViewController: UIViewController

// MARK: - Fetch
// Number of images to download per page
var oldImageIds = Set<Int64>()
var oldImageIDs = Set<Int64>()
var onPage = 0, lastPage = 0
lazy var perPage: Int = {
return max(AlbumUtilities.numberOfImagesToDownloadPerPage(), 100)
Expand Down
52 changes: 34 additions & 18 deletions piwigo/Album/Extensions/AlbumViewController+Bars.swift
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ extension AlbumViewController
}

func updateBarsInSelectMode() {
let hasImagesSelected = !selectedImageIds.isEmpty
setTitleViewFromAlbumData(whileUpdating: false)
let hasImagesSelected = !selectedImageIDs.isEmpty
cancelBarButton.isEnabled = true

// User with admin or upload rights can do everything
Expand All @@ -299,11 +300,9 @@ extension AlbumViewController
shareBarButton.isEnabled = hasImagesSelected
deleteBarButton.isEnabled = hasImagesSelected
favoriteBarButton?.isEnabled = hasImagesSelected
let selected = selectedImageIds
let favorites = selectedFavoriteIds
let areFavorites = selected == favorites
let areFavorites = selectedImageIDs == selectedFavoriteIDs
favoriteBarButton?.setFavoriteImage(for: areFavorites)
favoriteBarButton?.action = areFavorites ? #selector(removeFromFavorites) : #selector(addToFavorites)
favoriteBarButton?.action = areFavorites ? #selector(unfavoriteSelection) : #selector(favoriteSelection)

if #available(iOS 14, *) {
let children = [albumMenu(), imagesMenu()].compactMap({$0})
Expand All @@ -318,11 +317,9 @@ extension AlbumViewController
/// — non-guest users can set favorites in addition
shareBarButton.isEnabled = hasImagesSelected
favoriteBarButton?.isEnabled = hasImagesSelected
let selected = selectedImageIds
let favorites = selectedFavoriteIds
let areFavorites = selected == favorites
let areFavorites = selectedImageIDs == selectedFavoriteIDs
favoriteBarButton?.setFavoriteImage(for: areFavorites)
favoriteBarButton?.action = areFavorites ? #selector(removeFromFavorites) : #selector(addToFavorites)
favoriteBarButton?.action = areFavorites ? #selector(unfavoriteSelection) : #selector(favoriteSelection)
}
}

Expand Down Expand Up @@ -377,17 +374,38 @@ extension AlbumViewController
titleLabel.sizeToFit()

// There is no subtitle in landscape mode on iPhone
var lastUpdated = ""
var subtitle = ""
if !(UIDevice.current.userInterfaceIdiom == .phone &&
UIApplication.shared.statusBarOrientation.isLandscape) {
if isUpdating {
// Inform user that the app is fetching album data
lastUpdated = NSLocalizedString("categoryUpdating", comment: "Updating…")
subtitle = NSLocalizedString("categoryUpdating", comment: "Updating…")
}
else if isSelect {
let nberPhotos = selectedImageIDs.count
switch nberPhotos {
case 0:
subtitle = NSLocalizedString("selectImages", comment: "Select Photos")
case 1:
subtitle = NSLocalizedString("selectImageSelected", comment: "1 Photo Selected")
case 2...nberPhotos:
var nberPhotosStr = ""
if #available(iOS 16, *) {
nberPhotosStr = nberPhotos.formatted(.number)
} else {
let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = NumberFormatter.Style.decimal
nberPhotosStr = numberFormatter.string(from: NSNumber(value: nberPhotos)) ?? String(nberPhotos)
}
subtitle = String(format: NSLocalizedString("selectImagesSelected", comment: "%@ Photos Selected"), nberPhotosStr)
default:
subtitle = ""
}
}
else if albumData.dateGetImages > TimeInterval(86400) { // i.e. a day after minimum date
let dateGetImages = Date(timeIntervalSinceReferenceDate: albumData.dateGetImages)
if Date().timeIntervalSinceReferenceDate - albumData.dateGetImages < 60 {
lastUpdated = NSLocalizedString("categoryUpdatedNow", comment: "Updated just now")
subtitle = NSLocalizedString("categoryUpdatedNow", comment: "Updated just now")
} else {
let calendar = Calendar.current
let updatedDay = calendar.dateComponents([.day], from: dateGetImages)
Expand All @@ -396,21 +414,19 @@ extension AlbumViewController
// Album data updated today
let time = DateFormatter.localizedString(from: dateGetImages,
dateStyle: .none, timeStyle: .short)
lastUpdated = String(format: NSLocalizedString("categoryUpdatedAt",
comment: "Updated at…"), time)
subtitle = String(format: NSLocalizedString("categoryUpdatedAt", comment: "Updated at…"), time)
} else {
// Album data updated yesterday or before
let date = DateFormatter.localizedString(from: dateGetImages,
dateStyle: .short, timeStyle: .none)
lastUpdated = String(format: NSLocalizedString("categoryUpdatedOn",
comment: "Updated on…"), date)
subtitle = String(format: NSLocalizedString("categoryUpdatedOn", comment: "Updated on…"), date)
}
}
}
}

// Prepare sub-title
if lastUpdated.isEmpty == false {
if subtitle.isEmpty == false {
let subTitleLabel = UILabel(frame: CGRect(x: 0.0, y: titleLabel.frame.size.height, width: 0, height: 0))
subTitleLabel.backgroundColor = UIColor.clear
subTitleLabel.textColor = .piwigoColorWhiteCream()
Expand All @@ -421,7 +437,7 @@ extension AlbumViewController
subTitleLabel.adjustsFontSizeToFitWidth = false
subTitleLabel.lineBreakMode = .byTruncatingTail
subTitleLabel.allowsDefaultTighteningForTruncation = true
subTitleLabel.text = lastUpdated
subTitleLabel.text = subtitle
subTitleLabel.sizeToFit()

var titleWidth = CGFloat(fmax(subTitleLabel.bounds.size.width, titleLabel.bounds.size.width))
Expand Down
16 changes: 8 additions & 8 deletions piwigo/Album/Extensions/AlbumViewController+CopyMove.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extension AlbumViewController
// Disable buttons during action
setEnableStateOfButtons(false)
// Retrieve complete image data before copying images
initSelection(beforeAction: .copyImages)
initSelection(ofImagesWithIDs: selectedImageIDs, beforeAction: .copyImages, contextually: false)
})
action.accessibilityIdentifier = "copy"
return action
Expand All @@ -44,7 +44,7 @@ extension AlbumViewController
// Disable buttons during action
setEnableStateOfButtons(false)
// Retrieve complete image data before moving images
initSelection(beforeAction: .moveImages)
initSelection(ofImagesWithIDs: selectedImageIDs, beforeAction: .moveImages, contextually: false)
})
action.accessibilityIdentifier = "move"
return action
Expand All @@ -69,14 +69,14 @@ extension AlbumViewController
title: NSLocalizedString("copyImage_title", comment: "Copy to Album"),
style: .default, handler: { [self] action in
// Retrieve complete image data before copying images
initSelection(beforeAction: .copyImages)
initSelection(ofImagesWithIDs: selectedImageIDs, beforeAction: .copyImages, contextually: false)
})

let moveAction = UIAlertAction(
title: NSLocalizedString("moveImage_title", comment: "Move to Album"),
style: .default, handler: { [self] action in
// Retrieve complete image data before moving images
initSelection(beforeAction: .moveImages)
initSelection(ofImagesWithIDs: selectedImageIDs, beforeAction: .moveImages, contextually: false)
})

// Add actions
Expand All @@ -98,21 +98,21 @@ extension AlbumViewController
}
}

func copyImagesToAlbum() {
func copyToAlbum(imagesWithID imageIDs: Set<Int64>) {
let copySB = UIStoryboard(name: "SelectCategoryViewController", bundle: nil)
guard let copyVC = copySB.instantiateViewController(withIdentifier: "SelectCategoryViewController") as? SelectCategoryViewController else { return }
let parameter: [Any] = [selectedImageIds, albumData.pwgID]
let parameter: [Any] = [imageIDs, albumData.pwgID]
copyVC.user = user
if copyVC.setInput(parameter: parameter, for: .copyImages) {
copyVC.delegate = self // To re-enable toolbar
pushView(copyVC)
}
}

func moveImagesToAlbum() {
func moveToAlbum(imagesWithID imageIDs: Set<Int64>) {
let moveSB = UIStoryboard(name: "SelectCategoryViewController", bundle: nil)
guard let moveVC = moveSB.instantiateViewController(withIdentifier: "SelectCategoryViewController") as? SelectCategoryViewController else { return }
let parameter: [Any] = [selectedImageIds, albumData.pwgID]
let parameter: [Any] = [imageIDs, albumData.pwgID]
moveVC.user = user
if moveVC.setInput(parameter: parameter, for: .moveImages) {
moveVC.delegate = self // To re-enable toolbar
Expand Down
Loading

0 comments on commit 233431a

Please sign in to comment.