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: Sync of photos wifiOnly #1313

Open
wants to merge 11 commits into
base: Update-feature-wifi-only
Choose a base branch
from
13 changes: 11 additions & 2 deletions kDrive/Resources/de.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* Project: kDrive
* Locale: de, German
* Tagged: ios
* Exported by: Matthieu Déglon
* Exported at: Thu, 03 Oct 2024 08:22:20 +0200
* Exported by: Baptiste Griva
* Exported at: Fri, 20 Dec 2024 14:32:53 +0100
*/

/* loco:610a8791fa12ab20713c09e4 */
Expand Down Expand Up @@ -1540,6 +1540,12 @@
/* loco:63846ac1f8786f515b61f752 */
"photoLibraryAccessLimitedTitle" = "Eingeschränkter oder verweigerter Zugang";

/* loco:6765711b1f6cfc8c5408ee33 */
"photoSyncSuspended" = "Verbinden Sie sich mit einem Wi-Fi-Netzwerk oder erlauben Sie die mobile Datennutzung";

/* loco:67657012f62b39abc50deb62 */
"photoSyncSuspendedTitle" = "Fotosicherung ausgesetzt";

/* loco:627cf782146a6d748e5e7262 */
"photosHeaderDateFormat" = "MMMM yyyy";

Expand Down Expand Up @@ -2155,6 +2161,9 @@
/* loco:6049df4d5c2c3a04bc397a8c */
"uploadNetworkErrorWifiRequired" = "Warten auf WLAN";

/* loco:66fbba74682fe9a0990df012 */
"uploadOverDataRestrictedError" = "Warten auf Wi-Fi";

/* loco:60928fcf72952001716b86d2 */
"uploadPausedDescription" = "Einige Uploads sind in kDrive noch im Gange. Öffnen Sie die App und lassen Sie das Gerät verbunden, um den Upload zu beschleunigen.";

Expand Down
13 changes: 11 additions & 2 deletions kDrive/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* Loco ios export: iOS Localizable.strings
* Loco ios export: Xcode Strings (legacy)
* Project: kDrive
* Locale: en, English
* Tagged: ios
* Exported by: Baptiste Griva
* Exported at: Thu, 26 Sep 2024 10:46:53 +0200
* Exported at: Fri, 20 Dec 2024 14:32:53 +0100
*/

/* loco:610a8791fa12ab20713c09e4 */
Expand Down Expand Up @@ -1540,6 +1540,12 @@
/* loco:63846ac1f8786f515b61f752 */
"photoLibraryAccessLimitedTitle" = "Restricted or denied access";

/* loco:6765711b1f6cfc8c5408ee33 */
"photoSyncSuspended" = "Connect to a Wi-Fi network or allow mobile data usage";

/* loco:67657012f62b39abc50deb62 */
"photoSyncSuspendedTitle" = "Photo backup suspended";

/* loco:627cf782146a6d748e5e7262 */
"photosHeaderDateFormat" = "MMMM yyyy";

Expand Down Expand Up @@ -2155,6 +2161,9 @@
/* loco:6049df4d5c2c3a04bc397a8c */
"uploadNetworkErrorWifiRequired" = "Waiting for WiFi network";

/* loco:66fbba74682fe9a0990df012 */
"uploadOverDataRestrictedError" = "Waiting for Wi-Fi";

/* loco:60928fcf72952001716b86d2 */
"uploadPausedDescription" = "Some uploads are still in progress in kDrive. Open the app and keep the device connected to speed up the upload.";

Expand Down
13 changes: 11 additions & 2 deletions kDrive/Resources/es.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* Project: kDrive
* Locale: es, Spanish
* Tagged: ios
* Exported by: Matthieu Déglon
* Exported at: Thu, 03 Oct 2024 08:22:20 +0200
* Exported by: Baptiste Griva
* Exported at: Fri, 20 Dec 2024 14:32:53 +0100
*/

/* loco:610a8791fa12ab20713c09e4 */
Expand Down Expand Up @@ -1540,6 +1540,12 @@
/* loco:63846ac1f8786f515b61f752 */
"photoLibraryAccessLimitedTitle" = "Acceso restringido o denegado";

/* loco:6765711b1f6cfc8c5408ee33 */
"photoSyncSuspended" = "Conectarse a una red Wi-Fi o permitir el uso de datos móviles";

/* loco:67657012f62b39abc50deb62 */
"photoSyncSuspendedTitle" = "Suspendida la copia de seguridad de fotos";

/* loco:627cf782146a6d748e5e7262 */
"photosHeaderDateFormat" = "MMMM yyyy";

Expand Down Expand Up @@ -2155,6 +2161,9 @@
/* loco:6049df4d5c2c3a04bc397a8c */
"uploadNetworkErrorWifiRequired" = "A la espera de red WiFi";

/* loco:66fbba74682fe9a0990df012 */
"uploadOverDataRestrictedError" = "A la espera de Wi-Fi";

/* loco:60928fcf72952001716b86d2 */
"uploadPausedDescription" = "Algunas subidas siguen en curso en kDrive. Abre la aplicación y mantén el dispositivo conectado para acelerar la carga.";

Expand Down
13 changes: 11 additions & 2 deletions kDrive/Resources/fr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* Project: kDrive
* Locale: fr, French
* Tagged: ios
* Exported by: Matthieu Déglon
* Exported at: Thu, 03 Oct 2024 08:22:20 +0200
* Exported by: Baptiste Griva
* Exported at: Fri, 20 Dec 2024 14:32:53 +0100
*/

/* loco:610a8791fa12ab20713c09e4 */
Expand Down Expand Up @@ -1540,6 +1540,12 @@
/* loco:63846ac1f8786f515b61f752 */
"photoLibraryAccessLimitedTitle" = "Accès limité ou refusé";

/* loco:6765711b1f6cfc8c5408ee33 */
"photoSyncSuspended" = "Se connecter à un réseau Wi-Fi ou autoriser l’utilisation de données mobiles";

/* loco:67657012f62b39abc50deb62 */
"photoSyncSuspendedTitle" = "Sauvegarde des photos suspendue";

/* loco:627cf782146a6d748e5e7262 */
"photosHeaderDateFormat" = "MMMM yyyy";

Expand Down Expand Up @@ -2155,6 +2161,9 @@
/* loco:6049df4d5c2c3a04bc397a8c */
"uploadNetworkErrorWifiRequired" = "En attente de réseau Wi-Fi";

/* loco:66fbba74682fe9a0990df012 */
"uploadOverDataRestrictedError" = "En attente de Wi-Fi";

/* loco:60928fcf72952001716b86d2 */
"uploadPausedDescription" = "Des importations sont toujours en cours dans kDrive. Ouvrez l’app et gardez l’appareil branché pour accélérer l’upload.";

Expand Down
13 changes: 11 additions & 2 deletions kDrive/Resources/it.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* Project: kDrive
* Locale: it, Italian
* Tagged: ios
* Exported by: Matthieu Déglon
* Exported at: Thu, 03 Oct 2024 08:22:20 +0200
* Exported by: Baptiste Griva
* Exported at: Fri, 20 Dec 2024 14:32:53 +0100
*/

/* loco:610a8791fa12ab20713c09e4 */
Expand Down Expand Up @@ -1540,6 +1540,12 @@
/* loco:63846ac1f8786f515b61f752 */
"photoLibraryAccessLimitedTitle" = "Accesso limitato o negato";

/* loco:6765711b1f6cfc8c5408ee33 */
"photoSyncSuspended" = "Collegarsi a una rete Wi-Fi o consentire l’utilizzo di dati mobili";

/* loco:67657012f62b39abc50deb62 */
"photoSyncSuspendedTitle" = "Backup delle foto sospeso";

/* loco:627cf782146a6d748e5e7262 */
"photosHeaderDateFormat" = "MMMM yyyy";

Expand Down Expand Up @@ -2155,6 +2161,9 @@
/* loco:6049df4d5c2c3a04bc397a8c */
"uploadNetworkErrorWifiRequired" = "In attesa di connessione alla rete Wi-Fi";

/* loco:66fbba74682fe9a0990df012 */
"uploadOverDataRestrictedError" = "In attesa del Wi-Fi";

/* loco:60928fcf72952001716b86d2 */
"uploadPausedDescription" = "Alcuni caricamenti sono ancora in corso in kDrive. Aprite l’app e mantenete il dispositivo connesso per accelerare il caricamento.";

Expand Down
44 changes: 30 additions & 14 deletions kDrive/UI/Controller/Files/Upload/UploadQueueViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ final class UploadQueueViewController: UIViewController {
navigationItem.hideBackButtonText()

tableView.register(cellView: UploadTableViewCell.self)
tableView.register(cellView: ErrorUploadTableViewCell.self)

retryButton.accessibilityLabel = KDriveResourcesStrings.Localizable.buttonRetry
cancelButton.accessibilityLabel = KDriveResourcesStrings.Localizable.buttonCancel
Expand All @@ -58,6 +59,7 @@ final class UploadQueueViewController: UIViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
MatomoUtils.track(view: [MatomoUtils.Views.uploadQueue.displayName, "Main"])

}

deinit {
Expand Down Expand Up @@ -134,21 +136,35 @@ extension UploadQueueViewController: UITableViewDataSource {
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(type: UploadTableViewCell.self, for: indexPath)
cell.initWithPositionAndShadow(isFirst: indexPath.row == 0,
isLast: indexPath.row == self.tableView(
tableView,
numberOfRowsInSection: indexPath.section
) - 1)

/// Make sure the file is valid
let file = uploadingFiles[indexPath.row]
if !file.isInvalidated {
let progress: CGFloat? = (file.progress != nil) ? CGFloat(file.progress!) : nil
cell.configureWith(uploadFile: file, progress: progress)
if indexPath.row == 0 && UserDefaults.shared.isWifiOnly && ReachabilityListener.instance.currentStatus == .cellular {
let cell = tableView.dequeueReusableCell(type: ErrorUploadTableViewCell.self, for: indexPath)
cell.initWithPositionAndShadow(isFirst: true,
isLast: true)
cell.delegate = self
return cell
} else {
let cell = tableView.dequeueReusableCell(type: UploadTableViewCell.self, for: indexPath)
cell.initWithPositionAndShadow(isFirst: indexPath.row == 0,
isLast: indexPath.row == self.tableView(
tableView,
numberOfRowsInSection: indexPath.section
) - 1)

/// Make sure the file is valid
let file = uploadingFiles[indexPath.row]
if !file.isInvalidated {
let progress: CGFloat? = (file.progress != nil) ? CGFloat(file.progress!) : nil
cell.configureWith(uploadFile: file, progress: progress)
}

cell.selectionStyle = .none
return cell
}
}
}

cell.selectionStyle = .none
return cell
extension UploadQueueViewController: AccessParametersDelegate {
func parameterButtonTapped() {
navigationController?.pushViewController(PhotoSyncSettingsViewController(), animated: true)
}
}
45 changes: 41 additions & 4 deletions kDrive/UI/Controller/Home/RootMenuHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class RootMenuHeaderView: UICollectionReusableView {

var onUploadCardViewTapped: (() -> Void)?

deinit {
NotificationCenter.default.removeObserver(self)
}

override func awakeFromNib() {
super.awakeFromNib()

Expand All @@ -45,16 +49,21 @@ class RootMenuHeaderView: UICollectionReusableView {
radius: 10
)

uploadCardView.titleLabel.text = KDriveResourcesStrings.Localizable.uploadInProgressTitle
uploadCardView.progressView.setInfomaniakStyle()
uploadCardView.progressView.enableIndeterminate()
updateWifiView()

uploadCardView.isHidden = true
offlineView.isHidden = true
hideIfNeeded()

let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(didTapOnUploadCardView))
uploadCardView.addGestureRecognizer(tapGestureRecognizer)

NotificationCenter.default.addObserver(
self,
selector: #selector(reloadWifiView),
name: .reloadWifiView,
object: nil
)
}

func configureInCollectionView(
Expand Down Expand Up @@ -82,6 +91,11 @@ class RootMenuHeaderView: UICollectionReusableView {
}
}

@objc func reloadWifiView(_ notification: Notification) {
print("Call observeNetworkChange")
updateWifiView()
}

@objc func didTapOnUploadCardView() {
onUploadCardViewTapped?()
}
Expand Down Expand Up @@ -113,11 +127,34 @@ class RootMenuHeaderView: UICollectionReusableView {
guard let self else { return }

offlineView.isHidden = status != .offline
reloadHeader()

updateWifiView()
}
}
}

private func updateWifiView() {
if UserDefaults.shared.isWifiOnly && ReachabilityListener.instance.currentStatus == .cellular {
uploadCardView.titleLabel.text = KDriveResourcesStrings.Localizable.uploadPausedTitle
uploadCardView.progressView.isHidden = true
uploadCardView.iconView.image = UIImage(systemName: "exclamationmark.arrow.triangle.2.circlepath")
uploadCardView.iconView.isHidden = false
uploadCardView.iconView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
uploadCardView.iconView.widthAnchor.constraint(equalToConstant: 24),
uploadCardView.iconView.heightAnchor.constraint(equalToConstant: 24)
])
uploadCardView.iconView.tintColor = .gray
} else {
uploadCardView.titleLabel.text = KDriveResourcesStrings.Localizable.uploadInProgressTitle
uploadCardView.progressView.isHidden = false
uploadCardView.iconView.isHidden = true
uploadCardView.progressView.setInfomaniakStyle()
uploadCardView.progressView.enableIndeterminate()
}
reloadHeader()
}

private func reloadHeader() {
hideIfNeeded()

Expand Down
2 changes: 1 addition & 1 deletion kDrive/UI/Controller/Home/RootMenuHeaderView.xib
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
<color red="0.62352941176470589" green="0.62352941176470589" blue="0.62352941176470589" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="titleColor">
<color red="0.20000000000000001" green="0.20000000000000001" blue="0.20000000000000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.20000000298023224" green="0.20000000298023224" blue="0.20000000298023224" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
Expand Down
Loading
Loading