Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions iOSClient/NCGlobal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,9 @@ class NCGlobal: NSObject {
let notificationCenterEnableSwipeGesture = "enableSwipeGesture"
let notificationCenterDisableSwipeGesture = "disableSwipeGesture"

let notificationCenterPlayerIsPlaying = "playerIsPlaying"
let notificationCenterPlayerStoppedPlaying = "playerStoppedPlaying"

// TIP
//
let tipNCViewerPDFThumbnail = "tipncviewerpdfthumbnail"
Expand Down
22 changes: 17 additions & 5 deletions iOSClient/Networking/NCNetworkingProcess.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,21 @@ class NCNetworkingProcess {
private var hasRun: Bool = false
private let lockQueue = DispatchQueue(label: "com.nextcloud.networkingprocess.lockqueue")
private var timerProcess: Timer?
private var enableControllingScreenAwake = true

private init() {
self.startTimer()
self.startObserveTableMetadata()

NotificationCenter.default.addObserver(forName: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterPlayerIsPlaying), object: nil, queue: nil) { _ in

self.enableControllingScreenAwake = false
}

NotificationCenter.default.addObserver(forName: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterPlayerStoppedPlaying), object: nil, queue: nil) { _ in

self.enableControllingScreenAwake = true
}
}

private func startObserveTableMetadata() {
Expand Down Expand Up @@ -85,23 +96,24 @@ class NCNetworkingProcess {
let results = self.database.getResultsMetadatas(predicate: NSPredicate(format: "status != %d", self.global.metadataStatusNormal))?.freeze()
else { return }
self.hasRun = true

/// Keep screen awake
///
/*
Task {
let tasks = await self.networking.getAllDataTask()
let hasSynchronizationTask = tasks.contains { $0.taskDescription == NCGlobal.shared.taskDescriptionSynchronization }
let resultsTransfer = results.filter { self.global.metadataStatusInTransfer.contains($0.status) }



if !self.enableControllingScreenAwake { return }

if resultsTransfer.isEmpty && !hasSynchronizationTask {
ScreenAwakeManager.shared.mode = .off
} else {
ScreenAwakeManager.shared.mode = NCKeychain().screenAwakeMode
}
}
*/


if results.isEmpty {

/// Remove Photo CameraRoll
Expand Down
2 changes: 0 additions & 2 deletions iOSClient/Settings/Display/NCDisplayView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ struct NCDisplayView: View {
}
.font(.system(size: 16))

/*
Section(header: Text(NSLocalizedString("_additional_options_", comment: ""))) {

Picker(NSLocalizedString("_keep_screen_awake_", comment: ""),
Expand All @@ -79,7 +78,6 @@ struct NCDisplayView: View {
.frame(height: 50)
}
.pickerStyle(.menu)
*/
}
.navigationBarTitle(NSLocalizedString("_display_", comment: ""))
.defaultViewModifier(model)
Expand Down
2 changes: 1 addition & 1 deletion iOSClient/Supporting Files/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@
"_additional_view_options_" = "Additional view options";
"_while_charging_" = "While charging";
"_additional_options_" = "Additional options";
"_keep_screen_awake_" = "Keep screen awake while transferring files";
"_keep_screen_awake_" = "Keep screen awake\n while transferring files";
"_error_not_found_" = "The requested resource could not be found";
"_error_conflict_" = "The request could not be completed due to a conflict with the current state of the resource";
"_error_precondition_" = "The server does not meet one of the preconditions that the requester";
Expand Down
7 changes: 0 additions & 7 deletions iOSClient/Utility/ScreenAwakeManager/ScreenAwakeManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@
// Modified from https://github.com/ochococo/Insomnia
import UIKit

/**

Sometimes you want your iPhone to stay active a little bit longer is it an import or just game interface.

This simple class aims to simplify the code and give you a well tested solution.

*/
class ScreenAwakeManager {
static let shared: ScreenAwakeManager = {
let instance = ScreenAwakeManager()
Expand Down
13 changes: 11 additions & 2 deletions iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class NCPlayer: NSObject {
player.stop()
print("deinit NCPlayer with ocId \(metadata.ocId)")
NotificationCenter.default.removeObserver(self, name: UIApplication.didEnterBackgroundNotification, object: nil)
NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterPlayerStoppedPlaying)
}

func openAVPlayer(url: URL, autoplay: Bool = false) {
Expand Down Expand Up @@ -166,7 +167,7 @@ class NCPlayer: NSObject {

// MARK: -

func isPlay() -> Bool {
func isPlaying() -> Bool {
return player.isPlaying
}

Expand Down Expand Up @@ -201,7 +202,7 @@ class NCPlayer: NSObject {
}

func savePosition() {
guard metadata.isVideo, isPlay() else { return }
guard metadata.isVideo, isPlaying() else { return }
self.database.addVideo(metadata: metadata, position: player.position)
}

Expand All @@ -228,6 +229,9 @@ extension NCPlayer: VLCMediaPlayerDelegate {
switch player.state {
case .stopped:
playerToolBar?.playButtonPlay()

NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterPlayerStoppedPlaying)

print("Played mode: STOPPED")
case .opening:
print("Played mode: OPENING")
Expand Down Expand Up @@ -273,8 +277,13 @@ extension NCPlayer: VLCMediaPlayerDelegate {
self.height = Int(size.height)
playerToolBar.updateTopToolBar(videoSubTitlesIndexes: player.videoSubTitlesIndexes, audioTrackIndexes: player.audioTrackIndexes)
self.database.addVideo(metadata: metadata, width: self.width, height: self.height, length: self.length)

NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterPlayerIsPlaying)

print("Played mode: PLAYING")
case .paused:
NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterPlayerStoppedPlaying)

playerToolBar?.playButtonPlay()
print("Played mode: PAUSED")
default: break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class NCPlayerToolBar: UIView {
@IBAction func tapPlayerPause(_ sender: Any) {
guard let ncplayer = ncplayer else { return }

if ncplayer.isPlay() {
if ncplayer.isPlaying() {
ncplayer.playerPause()
} else {
ncplayer.playerPlay()
Expand Down
2 changes: 1 addition & 1 deletion iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)

if let ncplayer = ncplayer, ncplayer.isPlay() {
if let ncplayer = ncplayer, ncplayer.isPlaying() {
ncplayer.playerPause()
}
}
Expand Down Expand Up @@ -262,7 +262,7 @@
NCNetworking.shared.download(metadata: metadata, withNotificationProgressTask: true)
}

if metadata.isImage, (fileNameExtension == "GIF" || fileNameExtension == "SVG"), !utilityFileSystem.fileProviderStorageExists(metadata) {

Check warning on line 265 in iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift

View workflow job for this annotation

GitHub Actions / Lint

Control Statement Violation: `if`, `for`, `guard`, `switch`, `while`, and `catch` statements shouldn't unnecessarily wrap their conditionals or arguments in parentheses (control_statement)
downloadImage()
}

Expand Down
8 changes: 4 additions & 4 deletions iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ class NCViewerMediaPage: UIViewController {

if metadata.isAudioOrVideo, let ncplayer = self.currentViewController.ncplayer {
let url = URL(fileURLWithPath: self.utilityFileSystem.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView))
if ncplayer.isPlay() {
if ncplayer.isPlaying() {
ncplayer.playerPause()
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
ncplayer.openAVPlayer(url: url)
Expand Down Expand Up @@ -386,7 +386,7 @@ class NCViewerMediaPage: UIViewController {
NCContentPresenter().showError(error: error)
}

if let ncplayer = currentViewController.ncplayer, ncplayer.isPlay() {
if let ncplayer = currentViewController.ncplayer, ncplayer.isPlaying() {
ncplayer.playerPause()
}

Expand All @@ -410,7 +410,7 @@ class NCViewerMediaPage: UIViewController {
MPRemoteCommandCenter.shared().playCommand.isEnabled = true
playCommand = MPRemoteCommandCenter.shared().playCommand.addTarget { _ in

if !ncplayer.isPlay() {
if !ncplayer.isPlaying() {
ncplayer.playerPlay()
return .success
}
Expand All @@ -421,7 +421,7 @@ class NCViewerMediaPage: UIViewController {
MPRemoteCommandCenter.shared().pauseCommand.isEnabled = true
pauseCommand = MPRemoteCommandCenter.shared().pauseCommand.addTarget { _ in

if ncplayer.isPlay() {
if ncplayer.isPlaying() {
ncplayer.playerPause()
return .success
}
Expand Down
Loading