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
2 changes: 1 addition & 1 deletion .github/workflows/xcode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd # v1.6.0
with:
xcode-version: latest-stable
xcode-version: 16.4

- name: Run Xcode Build
run: |
Expand Down
13 changes: 6 additions & 7 deletions iOSClient/Main/Collection Common/Cell/NCGridCell.xib
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="22505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="24127" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="dark"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22504"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="24063"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand Down Expand Up @@ -61,7 +60,7 @@
<stackView opaque="NO" contentMode="scaleToFill" alignment="top" translatesAutoresizingMaskIntoConstraints="NO" id="VRH-IZ-lXO">
<rect key="frame" x="5" y="447" width="406" height="36"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="254" horizontalCompressionResistancePriority="756" verticalCompressionResistancePriority="759" text="Label" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="eU3-lY-fKr" userLabel="labelTitle">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="254" horizontalCompressionResistancePriority="756" verticalCompressionResistancePriority="759" text="Label" textAlignment="center" lineBreakMode="wordWrap" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="eU3-lY-fKr" userLabel="labelTitle" customClass="BidiFilenameLabel" customModule="Nextcloud" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="406" height="18"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<nil key="textColor"/>
Expand Down Expand Up @@ -148,13 +147,13 @@
<image name="ellipsis" catalog="system" width="128" height="37"/>
<image name="star.fill" catalog="system" width="128" height="116"/>
<systemColor name="separatorColor">
<color red="0.23529411764705882" green="0.23529411764705882" blue="0.2627450980392157" alpha="0.28999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.23529411759999999" green="0.23529411759999999" blue="0.26274509800000001" alpha="0.28999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemGray2Color">
<color red="0.68235294117647061" green="0.68235294117647061" blue="0.69803921568627447" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.68235294120000001" green="0.68235294120000001" blue="0.69803921570000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
<systemColor name="systemGrayColor">
<color red="0.55686274509803924" green="0.55686274509803924" blue="0.57647058823529407" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.5568627451" green="0.5568627451" blue="0.57647058819999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
</resources>
</document>
73 changes: 73 additions & 0 deletions iOSClient/Main/Collection Common/Cell/NCListCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -342,3 +342,76 @@ class NCListLayout: UICollectionViewFlowLayout {
return proposedContentOffset
}
}

class BidiFilenameLabel: UILabel {
var fullFilename: String = ""

var isFolder: Bool = false

var isRTL: Bool = false

override init(frame: CGRect) {
super.init(frame: frame)
}

required init?(coder: NSCoder) {
super.init(coder: coder)
}

override func layoutSubviews() {
super.layoutSubviews()
updateText()
}

private func updateText() {
guard !fullFilename.isEmpty else {
self.text = ""
return
}

let availableWidth = bounds.width
guard availableWidth > 0 else { return }

let isRTL = UIView.userInterfaceLayoutDirection(for: semanticContentAttribute) == .rightToLeft
let sanitizedFilename = fullFilename.sanitizeForBidiCharacters(isFolder: isFolder, isRTL: isRTL)

let nsFilename = sanitizedFilename as NSString
let ext = nsFilename.pathExtension
let base = nsFilename.deletingPathExtension

let dotExt = ext.isEmpty ? "" : "." + ext
let truncatedBase = truncateBase(base: base, dotExt: dotExt, maxWidth: availableWidth, font: font ?? UIFont.systemFont(ofSize: 17))

self.text = sanitizedFilename.replacingOccurrences(of: base, with: truncatedBase)
}

private func truncateBase(base: String, dotExt: String, maxWidth: CGFloat, font: UIFont) -> String {
let extWidth = (dotExt as NSString).size(withAttributes: [.font: font]).width

if (base as NSString).size(withAttributes: [.font: font]).width + extWidth <= maxWidth {
return base
}

let characters = Array(base)
var low = 0
var high = characters.count
var result = ""

while low <= high {
let mid = (low + high) / 2
let prefixCount = mid / 2
let suffixCount = mid - prefixCount
let finalString = String(characters.prefix(prefixCount)) + "…" + String(characters.suffix(suffixCount))
let finalStringWidth = (finalString as NSString).size(withAttributes: [.font: font]).width + extWidth

if finalStringWidth <= maxWidth {
result = finalString
low = mid + 1
} else {
high = mid - 1
}
}

return result
}
}
7 changes: 3 additions & 4 deletions iOSClient/Main/Collection Common/Cell/NCListCell.xib
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="23504" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="24127" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_0" orientation="landscape" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23506"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="24063"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand Down Expand Up @@ -60,7 +59,7 @@
<constraint firstAttribute="height" constant="15" id="mPH-zc-eH5"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" tag="101" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="UtT-L6-mgW" userLabel="labelTitle">
<label opaque="NO" userInteractionEnabled="NO" tag="101" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="clip" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="UtT-L6-mgW" userLabel="labelTitle" customClass="BidiFilenameLabel" customModule="Nextcloud" customModuleProvider="target">
<rect key="frame" x="107" y="13" width="425" height="18"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<nil key="highlightedColor"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,25 +192,31 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
cell.fileUser = metadata.ownerId

if isSearchingMode {
cell.fileTitleLabel?.text = metadata.fileName
cell.fileTitleLabel?.lineBreakMode = .byTruncatingTail
if metadata.name == global.appName {
cell.fileInfoLabel?.text = NSLocalizedString("_in_", comment: "") + " " + utilityFileSystem.getPath(path: metadata.path, user: metadata.user)
} else {
cell.fileInfoLabel?.text = metadata.subline
}
cell.fileSubinfoLabel?.isHidden = true
} else if !metadata.sessionError.isEmpty, metadata.status != global.metadataStatusNormal {
cell.fileTitleLabel?.text = metadata.fileNameView
cell.fileSubinfoLabel?.isHidden = false
cell.fileInfoLabel?.text = metadata.sessionError
} else {
cell.fileSubinfoLabel?.isHidden = false
cell.fileTitleLabel?.text = metadata.fileNameView
cell.fileTitleLabel?.lineBreakMode = .byTruncatingMiddle

cell.writeInfoDateSize(date: metadata.date, size: metadata.size)
}

if cell.fileTitleLabel is BidiFilenameLabel {
(cell.fileTitleLabel as? BidiFilenameLabel)?.fullFilename = metadata.fileNameView
(cell.fileTitleLabel as? BidiFilenameLabel)?.isFolder = metadata.directory
(cell.fileTitleLabel as? BidiFilenameLabel)?.numberOfLines = 1
// (cell.fileTitleLabel as? BidiFilenameLabel)?.lineBreakMode = .byCharWrapping

} else {
cell.fileTitleLabel?.text = metadata.fileNameView
}

// Accessibility [shared] if metadata.ownerId != appDelegate.userId, appDelegate.account == metadata.account {
if metadata.ownerId != metadata.userId {
a11yValues.append(NSLocalizedString("_shared_with_you_by_", comment: "") + " " + metadata.ownerDisplayName)
Expand Down
Loading