Skip to content

[stable-5.2.7] NMC/2298 - Share extension #197

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

Closed
wants to merge 7 commits into from
Closed
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: 2 additions & 1 deletion Share/NCShareExtension+DataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ extension NCShareExtension: UICollectionViewDelegate {
header.emptyTitle.text = NSLocalizedString("_request_in_progress_", comment: "")
header.emptyDescription.text = ""
} else {
header.emptyImage.image = UIImage(named: "folder")?.image(color: NCBrandColor.shared.brandElement, size: UIScreen.main.bounds.width)
header.emptyImage.image = UIImage(named: "folder")
header.emptyTitle.text = NSLocalizedString("_files_no_folders_", comment: "")
header.emptyDescription.text = ""
}
Expand Down Expand Up @@ -160,6 +160,7 @@ extension NCShareExtension: UICollectionViewDataSource {
}

cell.labelInfo.text = utility.dateDiff(metadata.date as Date)
cell.labelSubinfo.text = " · " + utilityFileSystem.transformedSize(metadata.size)

let lockServerUrl = utilityFileSystem.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName)
let tableDirectory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", activeAccount.account, lockServerUrl))
Expand Down
51 changes: 9 additions & 42 deletions Share/NCShareExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class NCShareExtension: UIViewController {

// uploadImage.image = utility).loadImage(named: "square.and.arrow.up", color: .label)
uploadLabel.text = NSLocalizedString("_upload_", comment: "")
uploadLabel.textColor = .systemBlue
uploadLabel.textColor = NCBrandColor.shared.customer
let uploadGesture = UITapGestureRecognizer(target: self, action: #selector(actionUpload))
uploadView.addGestureRecognizer(uploadGesture)

Expand All @@ -126,14 +126,6 @@ class NCShareExtension: UIViewController {
NextcloudKit.shared.nkCommonInstance.writeLog("[INFO] Start Share session with level \(levelLog) " + versionNextcloudiOS)
}

// Colors
if let activeAccount = NCManageDatabase.shared.getActiveAccount() {
NCBrandColor.shared.settingThemingColor(account: activeAccount.account)
}
NCBrandColor.shared.createUserColors()
NCImageCache.shared.createImagesCache()
NCImageCache.shared.createImagesBrandCache()

hud.indicatorView = JGProgressHUDRingIndicatorView()
if let indicatorView = hud.indicatorView as? JGProgressHUDRingIndicatorView {
indicatorView.ringWidth = 1.5
Expand Down Expand Up @@ -198,14 +190,15 @@ class NCShareExtension: UIViewController {

navigationItem.title = navigationTitle
cancelButton.title = NSLocalizedString("_cancel_", comment: "")
cancelButton.tintColor = NCBrandColor.shared.customer

// BACK BUTTON
let backButton = UIButton(type: .custom)
backButton.setImage(UIImage(named: "back"), for: .normal)
backButton.tintColor = .systemBlue
backButton.setImage(UIImage(named: "back")?.imageColor(NCBrandColor.shared.customer), for: .normal)
backButton.tintColor = NCBrandColor.shared.customer
backButton.semanticContentAttribute = .forceLeftToRight
backButton.setTitle(" " + NSLocalizedString("_back_", comment: ""), for: .normal)
backButton.setTitleColor(.systemBlue, for: .normal)
backButton.setTitleColor(NCBrandColor.shared.customer, for: .normal)
backButton.action(for: .touchUpInside) { _ in
if !self.uploadStarted {
while self.serverUrl.last != "/" { self.serverUrl.removeLast() }
Expand All @@ -220,38 +213,12 @@ class NCShareExtension: UIViewController {
self.setNavigationBar(navigationTitle: navigationTitle)
}
}

let image = utility.loadUserImage(for: activeAccount.user, displayName: activeAccount.displayName, userBaseUrl: activeAccount)
let profileButton = UIButton(type: .custom)
profileButton.setImage(image, for: .normal)

if serverUrl == utilityFileSystem.getHomeServer(urlBase: activeAccount.urlBase, userId: activeAccount.userId) {

var title = " "
if let userAlias = activeAccount?.alias, !userAlias.isEmpty {
title += userAlias
} else {
title += activeAccount?.displayName ?? ""
}

profileButton.setTitle(title, for: .normal)
profileButton.setTitleColor(.systemBlue, for: .normal)
}

profileButton.semanticContentAttribute = .forceLeftToRight
profileButton.sizeToFit()
profileButton.action(for: .touchUpInside) { _ in
if !self.uploadStarted {
self.showAccountPicker()
}
}
var navItems = [UIBarButtonItem(customView: profileButton)]

if serverUrl != utilityFileSystem.getHomeServer(urlBase: activeAccount.urlBase, userId: activeAccount.userId) {
let space = UIBarButtonItem(barButtonSystemItem: .fixedSpace, target: nil, action: nil)
space.width = 20
navItems.append(contentsOf: [UIBarButtonItem(customView: backButton), space])
navigationItem.leftBarButtonItem = UIBarButtonItem(customView: backButton)
} else {
navigationItem.leftBarButtonItem = nil
}
navigationItem.setLeftBarButtonItems(navItems, animated: true)
}

func setCommandView() {
Expand Down