Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add to my drive action #1349

Open
wants to merge 56 commits into
base: feature-externalLinks
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
5bd3729
refactor(SaveFileViewController): Split this class in some digestible…
adrien-coye Dec 6, 2024
65f7160
chore: SonarCloud
adrien-coye Dec 6, 2024
db10f5a
feat: Base work for add to my drive feature.
adrien-coye Dec 9, 2024
f802366
feat: Public share offline routing.
adrien-coye Dec 10, 2024
9493c63
chore: Merge branch 'feature-externalLinks' into externalLinks-famous…
adrien-coye Dec 10, 2024
ca518b7
feat: Offline in-memory DriveFileManager.
adrien-coye Dec 10, 2024
93bbb8e
feat: Authenticating add to kDrive call.
adrien-coye Dec 10, 2024
fa0097e
refactor(OnboardingViewController): Abstracted away the post login an…
adrien-coye Dec 11, 2024
1dea01e
fix: Allow disabled public share files
adrien-coye Dec 12, 2024
eb5bc34
feat: Add to my drive working
adrien-coye Dec 12, 2024
384b52d
refactor: Upsale floating panel constructor method
adrien-coye Dec 12, 2024
abd2bae
feat: Add to my kDrive floating action.
adrien-coye Dec 12, 2024
cdc49fa
chore: Merge branch 'feature-externalLinks' into externalLinks-famous…
adrien-coye Dec 17, 2024
f80e953
chore: Merge branch 'externalLinks-famousLastFivePercent' into extern…
adrien-coye Dec 17, 2024
691feee
fix(AddToMykDrive): Big button selects the correct drive by default
adrien-coye Dec 18, 2024
f349a1a
chore: Merge branch 'externalLinks-famousLastFivePercent' into extern…
adrien-coye Dec 18, 2024
b2f40c3
fix(AddToMykDrive): Big button selects the correct drive by default
adrien-coye Dec 18, 2024
26b1097
chore: Merge branch 'externalLinks-famousLastFivePercent' into extern…
adrien-coye Dec 18, 2024
711de84
refactor(UniversalLinksHelper): Public share deeplinks removed from U…
adrien-coye Dec 19, 2024
909c5b7
feat(DeeplinkService): If app started with a public share link before…
adrien-coye Dec 19, 2024
304bc54
chore: Merge branch 'feature-externalLinks' into externalLinks-famous…
adrien-coye Dec 30, 2024
6deacca
chore: Merge branch 'feature-externalLinks' into externalLinks-famous…
adrien-coye Jan 2, 2025
b9eb981
chore: Merge branch 'externalLinks-famousLastFivePercent' into extern…
adrien-coye Jan 2, 2025
6fadaec
chore: Merge branch 'externalLinks-famousLastFivePercent' into extern…
adrien-coye Jan 2, 2025
f23e753
chore: PR Feedback
adrien-coye Jan 2, 2025
d8eb82a
fix(VideoPlayer): Disable streaming for VideoPlayer within a public s…
adrien-coye Jan 2, 2025
37464bc
refactor(APIPublicShareParameter): Renamed PublicShareAPIParameters
adrien-coye Jan 2, 2025
2c1fbf4
chore: Self assessed PR feedback
adrien-coye Jan 6, 2025
16985c9
chore: Merge branch 'externalLinks-famousLastFivePercent' into extern…
adrien-coye Jan 7, 2025
5604594
chore: Merge branch 'feature-externalLinks' into externalLinks-famous…
adrien-coye Jan 7, 2025
2d113f3
chore: Merge branch 'feature-externalLinks' into externalLinks-famous…
adrien-coye Jan 7, 2025
4d4dd6a
chore: Self review changes
adrien-coye Jan 7, 2025
d4b67a5
fix: Close multiSelection since the merge
adrien-coye Jan 7, 2025
944dac6
chore: Merge branch 'externalLinks-famousLastFivePercent' into extern…
adrien-coye Jan 7, 2025
7907779
feat: Keep addToMyDrive button enabled while multiselect
adrien-coye Jan 8, 2025
dd7c93c
chore: Matomo event naming
adrien-coye Jan 8, 2025
10332da
chore(UpsaleViewController): Removed comments
adrien-coye Jan 8, 2025
fe4a329
refactor(PublicShareAction): Factorised addToMyDrive code
adrien-coye Jan 8, 2025
6aa1342
feat(Router): New showUpsaleFloatingPanel method
adrien-coye Jan 8, 2025
6f6c012
refactor: Rework deeplinks (#1358)
adrien-coye Jan 8, 2025
46a882f
fix(addToMyDrive): Modified and checked new logic against every use c…
adrien-coye Jan 8, 2025
60bba8f
feat(PublicShareViewModel): Disable multi selection on addToMyDrive a…
adrien-coye Jan 8, 2025
3cbf6b3
chore(UT): Fix protocol changes in mocks
adrien-coye Jan 8, 2025
511dac2
chore: Merge branch 'externalLinks-famousLastFivePercent' into extern…
adrien-coye Jan 8, 2025
74eb232
feat: Loading ui on public share download all
adrien-coye Jan 9, 2025
65db643
refactor(SaveFileViewController): Rework init method
adrien-coye Jan 9, 2025
e9abcf7
feat: Factorise add to my drive action (#1350)
adrien-coye Jan 9, 2025
e73173e
feat: Cancel a download all action from UITabBarItem
adrien-coye Jan 9, 2025
d3a9775
refactor: Simpler UITapGestureRecognizer passthrew
adrien-coye Jan 9, 2025
4ff6630
chore: Perhaps a more consensual naming
adrien-coye Jan 9, 2025
34f71ca
fix(DeeplinkService): Clear public share deeplink on user initiated exit
adrien-coye Jan 10, 2025
170ca99
fix(AppRouter): Made sure showUpsaleFloatingPanel works offline
adrien-coye Jan 10, 2025
2ac721a
fix(PublicShare): Fix a bug where a reused PublicShare in memory data…
adrien-coye Jan 10, 2025
fa6ee29
feat: External links download all progres UI (#1375)
PhilippeWeidmann Jan 14, 2025
d32391f
refactor: Renamed nextVC to destinationViewController
adrien-coye Jan 14, 2025
f2822e3
chore: PR Feedback
adrien-coye Jan 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions kDrive/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {
Task {
try! await Task.sleep(nanoseconds: 5_000_000_000)

@InjectService var router: AppNavigable
//let upsaleViewController = UpsaleViewController()
let noDriveViewController = NoDriveUpsaleViewController()
let floatingPanel = UpsaleFloatingPanelController(upsaleViewController: noDriveViewController)
router.topMostViewController?.present(floatingPanel, animated: true, completion: nil)
// @InjectService var router: AppNavigable
// //let upsaleViewController = UpsaleViewController()
// let noDriveViewController = NoDriveUpsaleViewController()
// let floatingPanel = UpsaleFloatingPanelController(upsaleViewController: noDriveViewController)
// router.topMostViewController?.present(floatingPanel, animated: true, completion: nil)

/* Temp code to test out the feature. TODO: Remove later
// a public share expired
Expand All @@ -123,6 +123,11 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {

await UniversalLinksHelper.handleURL(somePublicShare!)
*/

// a valid public share
let somePublicShare =
URL(string: "https://kdrive.infomaniak.com/app/share/140946/01953831-16d3-4df6-8b48-33c8001c7981")
await UniversalLinksHelper.handleURL(somePublicShare!)
}

return true
Expand Down
43 changes: 13 additions & 30 deletions kDrive/AppRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,7 @@ public struct AppRouter: AppNavigable {

@MainActor public func presentPublicShareLocked(_ destinationURL: URL) {
guard let window,
let rootViewController = window.rootViewController as? MainTabViewController else {
fatalError("TODO: fix offline routing - presentPublicShareLocked")
let rootViewController = window.rootViewController else {
return
}

Expand All @@ -599,20 +598,13 @@ public struct AppRouter: AppNavigable {
publicShareNavigationController.modalPresentationStyle = .fullScreen
publicShareNavigationController.modalTransitionStyle = .coverVertical

rootViewController.selectedIndex = MainTabBarIndex.files.rawValue

guard let navigationController = rootViewController.selectedViewController as? UINavigationController else {
return
}

navigationController.present(publicShareNavigationController, animated: true, completion: nil)
rootViewController.present(publicShareNavigationController, animated: true, completion: nil)
}
}

@MainActor public func presentPublicShareExpired() {
guard let window,
let rootViewController = window.rootViewController as? MainTabViewController else {
fatalError("TODO: fix offline routing - presentPublicShareExpired")
let rootViewController = window.rootViewController else {
return
}

Expand All @@ -622,13 +614,7 @@ public struct AppRouter: AppNavigable {
publicShareNavigationController.modalPresentationStyle = .fullScreen
publicShareNavigationController.modalTransitionStyle = .coverVertical

rootViewController.selectedIndex = MainTabBarIndex.files.rawValue

guard let navigationController = rootViewController.selectedViewController as? UINavigationController else {
return
}

navigationController.present(publicShareNavigationController, animated: true, completion: nil)
rootViewController.present(publicShareNavigationController, animated: true, completion: nil)
}
}

Expand All @@ -639,21 +625,18 @@ public struct AppRouter: AppNavigable {
apiFetcher: PublicShareApiFetcher
) {
guard let window,
let rootViewController = window.rootViewController as? MainTabViewController else {
fatalError("TODO: fix offline routing - presentPublicShare")
return
}

// TODO: Fix access right
guard !frozenRootFolder.isDisabled else {
fatalError("isDisabled")
let rootViewController = window.rootViewController else {
return
}

rootViewController.dismiss(animated: false) {
rootViewController.selectedIndex = MainTabBarIndex.files.rawValue

guard let navigationController = rootViewController.selectedViewController as? UINavigationController else {
guard !frozenRootFolder.isDisabled else {
let noDriveViewController = NoDriveUpsaleViewController()
noDriveViewController.dismissCallback = {
rootViewController.dismiss(animated: false) {}
}
let floatingPanel = UpsaleFloatingPanelController(upsaleViewController: noDriveViewController)
adrien-coye marked this conversation as resolved.
Show resolved Hide resolved
rootViewController.present(floatingPanel, animated: true, completion: nil)
return
}

Expand All @@ -667,7 +650,7 @@ public struct AppRouter: AppNavigable {
publicShareNavigationController.modalPresentationStyle = .fullScreen
publicShareNavigationController.modalTransitionStyle = .coverVertical

navigationController.present(publicShareNavigationController, animated: true, completion: nil)
rootViewController.present(publicShareNavigationController, animated: true, completion: nil)
}
}

Expand Down
36 changes: 34 additions & 2 deletions kDrive/UI/Controller/Files/File List/FileListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,40 @@ class FileListViewController: UICollectionViewController, SwipeActionCollectionV
])
}

@objc func addToMyDriveButtonTapped(_ sender: UIView?) {
viewModel.barButtonPressed(sender: sender, type: .downloadAll)
@objc func addToMyDriveButtonTapped(_ sender: UIButton?) {
defer {
sender?.isSelected = false
sender?.isEnabled = true
sender?.isHighlighted = false
}

guard accountManager.currentAccount != nil else {
#if !ISEXTENSION
let upsaleViewController = UpsaleViewController()

// Create an account
upsaleViewController.freeTrialCallback = { [weak self] in
self?.dismiss(animated: true)
// TODO: Present login
adrien-coye marked this conversation as resolved.
Show resolved Hide resolved
// MatomoUtils.track(eventWithCategory: .account, name: "openCreationWebview")
// present(RegisterViewController.instantiateInNavigationController(delegate: self), animated: true)
}

// Let the user login with the onboarding
upsaleViewController.loginCallback = { [weak self] in
self?.dismiss(animated: true)
}

let floatingPanel = UpsaleFloatingPanelController(upsaleViewController: upsaleViewController)
present(floatingPanel, animated: true, completion: nil)
#else
dismiss(animated: true)
#endif

return
}

viewModel.barButtonPressed(sender: sender, type: .addToMyDrive)
}

func reloadCollectionViewWith(files: [File]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ enum FileListBarButtonType {
case photoSort
case addFolder
case downloadAll
case addToMyDrive
}

enum FileListQuickActionType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,44 @@ extension SaveFileViewController: FooterButtonDelegate {
let button = sender as? IKLargeButton
button?.setLoading(true)

let items = items
guard !items.isEmpty else {
if let publicShareProxy {
adrien-coye marked this conversation as resolved.
Show resolved Hide resolved
Task {
try await savePublicShareToDrive(sourceDriveId: publicShareProxy.driveId,
destinationDriveId: drive.accountId,
fileIds: publicShareFileIds,
exceptIds: publicShareExceptIds)
}
} else {
guard !items.isEmpty else {
dismiss(animated: true)
return
}

Task {
await saveAndDismiss(files: items, directory: directory, drive: drive)
}
}
}

private func savePublicShareToDrive(sourceDriveId: Int,
destinationDriveId: Int,
fileIds: [Int],
exceptIds: [Int]) async {
defer {
dismiss(animated: true)
return
}

Task {
await presentSnackBarSaveAndDismiss(files: items, directory: directory, drive: drive)
guard let currentDriveFileManager = accountManager.currentDriveFileManager else {
return
}

try await currentDriveFileManager.apiFetcher.importShareLinkFiles(sourceDriveId: sourceDriveId,
destinationDriveId: destinationDriveId,
fileIds: fileIds,
exceptIds: exceptIds)
}

private func presentSnackBarSaveAndDismiss(files: [ImportedFile], directory: File, drive: Drive) async {
private func saveAndDismiss(files: [ImportedFile], directory: File, drive: Drive) async {
let message: String
do {
try await processForUpload(files: files, directory: directory, drive: drive)
Expand All @@ -59,6 +85,10 @@ extension SaveFileViewController: FooterButtonDelegate {
message = error.localizedDescription
}

presentSnackBar(message)
}

private func presentSnackBar(_ message: String) {
Task { @MainActor in
self.dismiss(animated: true, clean: false) {
UIConstants.showSnackBar(message: message)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Infomaniak kDrive - iOS App
Copyright (C) 2024 Infomaniak Network SA

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import Foundation
import kDriveCore

// MARK: - SelectDriveDelegate

extension SaveFileViewController: SelectDriveDelegate {
func didSelectDrive(_ drive: Drive) {
if let selectedDriveFileManager = accountManager.getDriveFileManager(for: drive.id, userId: drive.userId) {
self.selectedDriveFileManager = selectedDriveFileManager
selectedDirectory = getBestDirectory()
sections = [.fileName, .driveSelection, .directorySelection]
if itemProvidersContainHeicPhotos {
sections.append(.photoFormatOption)
}
}
updateButton()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
Infomaniak kDrive - iOS App
Copyright (C) 2024 Infomaniak Network SA

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import Foundation
import kDriveCore

// MARK: - SelectFolderDelegate

extension SaveFileViewController: SelectFolderDelegate {
func didSelectFolder(_ folder: File) {
if folder.id == DriveFileManager.constants.rootID {
selectedDirectory = selectedDriveFileManager?.getCachedRootFile()
} else {
selectedDirectory = folder
}
updateButton()
tableView.reloadData()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
Infomaniak kDrive - iOS App
Copyright (C) 2024 Infomaniak Network SA

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import Foundation
import kDriveCore

// MARK: - SelectPhotoFormatDelegate

extension SaveFileViewController: SelectPhotoFormatDelegate {
func didSelectPhotoFormat(_ format: PhotoFileFormat) {
if userPreferredPhotoFormat != format {
userPreferredPhotoFormat = format
if itemProviders?.isEmpty == false {
setItemProviders()
} else {
setAssetIdentifiers()
}
}
}
}
Loading
Loading